@wazobiatech/wazui 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PictureBlot-D8_tvMig.js → PictureBlot-C_HVu8n_.js} +2 -2
- package/dist/{PictureBlot-D8_tvMig.js.map → PictureBlot-C_HVu8n_.js.map} +1 -1
- package/dist/{PictureBlot-hHIPKPv0.cjs → PictureBlot-C_waorkz.cjs} +2 -2
- package/dist/{PictureBlot-hHIPKPv0.cjs.map → PictureBlot-C_waorkz.cjs.map} +1 -1
- package/dist/components/wazui/RecipeContentComponent/utils.d.ts.map +1 -1
- package/dist/{index-e6grgv3t.cjs → index-BM2sjY9N.cjs} +4 -4
- package/dist/index-BM2sjY9N.cjs.map +4 -0
- package/dist/{index-C8e21ezp.js → index-Bt3HQLDr.js} +6 -6
- package/dist/index-Bt3HQLDr.js.map +4 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{quill-vc5vrP24.cjs → quill-D06vxijP.cjs} +2 -2
- package/dist/{quill-vc5vrP24.cjs.map → quill-D06vxijP.cjs.map} +1 -1
- package/dist/{quill-CfGcSGjN.js → quill-L6wcuHsS.js} +2 -2
- package/dist/{quill-CfGcSGjN.js.map → quill-L6wcuHsS.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-C8e21ezp.js.map +0 -4
- package/dist/index-e6grgv3t.cjs.map +0 -4
|
@@ -424,7 +424,7 @@ Valid keys: `+JSON.stringify(Object.keys(Z),null," "));var U=_(R,$,J,F,eA+"."+$
|
|
|
424
424
|
*/var Ay;function UeA(){return Ay||(Ay=1,(function(A){(function(){var e={}.hasOwnProperty;function t(){for(var s="",a=0;a<arguments.length;a++){var o=arguments[a];o&&(s=r(s,n(o)))}return s}function n(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return t.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var a="";for(var o in s)e.call(s,o)&&s[o]&&(a=r(a,o));return a}function r(s,a){return a?s?s+" "+a:s+a:s}A.exports?(t.default=t,A.exports=t):window.classNames=t})()})(Nm)),Nm.exports}var _eA=UeA();const YA=jc(_eA);function $eA(A,e){var t=i4({},e);return{stencilSize:function(n,r){var s=fe(A.stencilSize)?A.stencilSize(n,r):A.stencilSize;return Gn(aA(aA({},s),{aspectRatio:RAA(t.aspectRatio,ro(FA(s)))}))}}}function y0(A,e){var t=A.boundary,n=fe(e.stencilSize)?e.stencilSize(A,e):e.stencilSize;return(n.width>t.width||n.height>t.height)&&(n=Gn({sizeRestrictions:{maxWidth:t.width,maxHeight:t.height,minWidth:0,minHeight:0},width:n.width,height:n.height,aspectRatio:{minimum:FA(n),maximum:FA(n)}})),n}function AtA(A,e){var t=y0(A,aA(aA({},e),{stencilSize:e.stencilSize})),n=Wn(A,e);return{maxWidth:n.maxWidth*t.width/A.boundary.width,maxHeight:n.maxHeight*t.height/A.boundary.height,minWidth:0,minHeight:0}}function etA(A,e){var t=A.imageSize,n=A.visibleArea,r=A.boundary,s=Fn(A,e),a=sa(A,e),o=fe(e.stencilSize)?e.stencilSize(A,e):e.stencilSize,i=n||t,l,u;return FA(i)>FA(r)?(l=o.height*i.height/r.height,u=l*FA(o)):(u=o.width*i.width/r.width,l=u/FA(o)),Gn({width:u,height:l,aspectRatio:a,sizeRestrictions:s})}function ttA(A,e){var t=FA(y0(A,e));return{minimum:t,maximum:t}}function ntA(A,e){if(xn(A)){var t=Zt(A),n=y0(A,e);t.visibleArea=gr(t.visibleArea,t.coordinates.width*t.boundary.width/(t.visibleArea.width*n.width));var r=p0(t.visibleArea,Wn(t,e));return r!==1&&(t.visibleArea=gr(t.visibleArea,r),t.coordinates=gr(t.coordinates,r)),t.visibleArea=pt(t.visibleArea,Xn(Ce(t.coordinates),Ce(t.visibleArea))),t.visibleArea=Ge(t.visibleArea,Yn(t,e)),t.coordinates=Ge(t.coordinates,ra(un(t.visibleArea),Yn(t,e))),t}return A}function rtA(A,e,t){return t&&t.immediately?ntA(A,e):A}function stA(A,e){if(xn(A)){var t=Zt(A),n={width:0,height:0};FA(t.boundary)>FA(t.coordinates)?(n.height=t.boundary.height*.8,n.width=n.height*FA(t.coordinates)):(n.width=t.boundary.width*.8,n.height=n.width*FA(t.coordinates)),t.visibleArea=gr(t.visibleArea,t.coordinates.width*t.boundary.width/(t.visibleArea.width*n.width));var r=p0(t.visibleArea,Wn(t,e));return t.visibleArea=gr(t.visibleArea,r),r!==1&&(n.height/=r,n.width/=r),t.visibleArea=pt(t.visibleArea,Xn(Ce(t.coordinates),Ce(t.visibleArea))),t.visibleArea=Ge(t.visibleArea,Yn(t,e)),t.coordinates=Ge(t.coordinates,ra(un(t.visibleArea),fn(t,e))),t}return A}function atA(A,e,t){return t.immediately?stA(A,e):A}function otA(A){process.env.NODE_ENV==="development"&&console.warn("Deprecation warning: ".concat(A))}function itA(){var A=y.useRef([]);return function(e){A.current.indexOf(e)===-1&&(otA(e),A.current.push(e))}}function ltA(A){return y.forwardRef(A)}function ctA(){var A=y.useRef(!0);return A.current?(A.current=!1,!0):A.current}var kl=function(A,e){var t=ctA();y.useEffect(function(){if(!t)return A()},e)};function c4(A){var e=je(y.useState(A),2),t=e[0],n=e[1],r=je(y.useState(null),2),s=r[0],a=r[1],o=y.useRef(A);return kl(function(){s&&s(t,o.current)},[s]),[t,function(i,l){o.current=t,n(i),a(function(){return l})}]}var utA=(function(A){zr(e,A);function e(t,n){var r=A.call(this)||this;return r.props=t,r.notify=n,r.data={state:null,transitions:!1,interactions:weA()},r}return e.prototype.getProps=function(){return this.props()},e.prototype.setData=function(t){this.data=t,this.notify()},e.prototype.getData=function(){return this.data},e})(OeA);function u4(){var A=je(y.useState({}),2);A[0];var e=A[1];return function(){e({})}}function ftA(A){var e=y.useRef(A);return e.current=A,function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.current.apply(e,mr([],je(t),!1))}}function dtA(A){var e=u4(),t=ftA(function(){var r=A(),s=r.settings,a=Rs(r,["settings"]),o=aA({imageRestriction:_a.fitArea,transformImage:{adjustStencil:!0}},s),i=aA({transitions:!0},a);return aA({settings:aA(aA({},o),jeA(o))},i)}),n=y.useRef(new utA(t,e));return n.current}function gtA(A){var e=A.src,t=A.onLoadingStart,n=A.onLoadingEnd,r=A.onError,s=A.onLoad,a=A.crossOrigin,o=A.checkOrientation,i=A.canvas,l=A.unloadTime,u=je(y.useState(null),2),f=u[0],d=u[1],g=je(y.useState(!1),2),v=g[0],m=g[1],p=je(c4(!1),2),h=p[0],P=p[1],b=y.useRef(null);return y.useEffect(function(){if(b.current!==e)if(b.current=e||null,P(!1),e){m(!0),t==null||t();var x=[WeA(e,{crossOrigin:Ke(a)?i:a,checkOrientation:o})];h&&l&&x.push(QP(l)),Promise.all(x).then(function(z){var D=je(z,1),B=D[0];b.current===e&&d(B)}).catch(function(){b.current===e&&(r==null||r())}).finally(function(){b.current===e&&(n==null||n(),m(!1))})}else l?QP(l).then(function(){b.current===e&&d(null)}):d(null)},[e,f]),y.useEffect(function(){f&&P(!0,function(){s==null||s(f)})},[f]),{isLoading:function(){return v},isLoaded:function(){return h},getImage:function(){return f},setImage:d}}var f4=function(A){var e=y.useRef(A),t=function(){e.current&&e.current()};y.useEffect(function(){e.current=A},[A]),y.useEffect(function(){return window.addEventListener("resize",t),window.addEventListener("orientationchange",t),function(){window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[])};function vtA(A,e){e===void 0&&(e=!0);var t=je(y.useState(e),2),n=t[0],r=t[1];return y.useLayoutEffect(function(){n&&!A.hasInteractions()&&A.reconcileState()}),{pause:function(){r(!1)},resume:function(){r(!0)}}}function mtA(A){var e=this,t=A(),n=t.src,r=t.onReady,s=t.onError,a=t.onUpdate,o=t.canvas,i=o===void 0?!0:o,l=t.unloadTime,u=l===void 0?500:l,f=t.crossOrigin,d=f===void 0?!0:f,g=t.checkOrientation,v=g===void 0?!0:g,m=t.autoReconcileState,p=m===void 0?!0:m,h=y.useRef(null),P=y.useRef(null),b=y.useRef(null),x=y.useRef(null),z=je(c4(null),2),D=z[0],B=z[1],M=dtA(function(){return aA(aA({},A()),{getInstance:function(){return x.current}})}),Y=gtA({src:n,crossOrigin:d,checkOrientation:v,unloadTime:u,canvas:i,onError:function(){x.current&&(s==null||s(x.current))}}),V=vtA(M,p),j=function(){return fp(e,void 0,void 0,function(){var N,q,I;return Nf(this,function(G){switch(G.label){case 0:return P.current?(V.pause(),N=Y.getImage(),[4,(I=P.current)===null||I===void 0?void 0:I.stretchTo(N)]):[3,2];case 1:q=G.sent(),B(N,function(){q&&N?M.reset(q,N):M.clear()}),V.resume(),G.label=2;case 2:return[2]}})})},C=function(){return fp(e,void 0,void 0,function(){var N,q,I,G;return Nf(this,function(H){switch(H.label){case 0:return P.current?(V.pause(),N=Y.getImage(),[4,(G=P.current)===null||G===void 0?void 0:G.stretchTo(N)]):[3,2];case 1:q=H.sent(),q&&N?(I=M.getState(),I?(q.width!==I.boundary.width||q.height!==I.boundary.height)&&(M.setBoundary(q),M.reconcileState()):M.reset(q,N)):M.clear(),V.resume(),H.label=2;case 2:return[2]}})})},E={reset:function(){return j()},refresh:function(){return C()},setImage:function(N){return B(N)},reconcileState:M.reconcileState,moveCoordinates:M.moveCoordinates,moveCoordinatesEnd:M.moveCoordinatesEnd,resizeCoordinates:M.resizeCoordinates,clear:M.clear,resizeCoordinatesEnd:M.resizeCoordinatesEnd,moveImage:M.moveImage,flipImage:M.flipImage,zoomImage:M.zoomImage,rotateImage:M.rotateImage,transformImage:M.transformImage,transformImageEnd:M.transformImageEnd,setCoordinates:M.setCoordinates,setVisibleArea:M.setVisibleArea,startTransitions:M.startTransitions,setState:M.setState,hasInteractions:M.hasInteractions,getStencilCoordinates:M.getStencilCoordinates,getCoordinates:M.getCoordinates,getVisibleArea:M.getVisibleArea,getTransforms:M.getTransforms,getTransitions:M.getTransitions,getInteractions:M.getInteractions,getSettings:M.getSettings,getState:M.getState,getDefaultState:function(){var N=M.getState(),q=Y.getImage();return N&&q?M.createDefaultState(N.boundary,q):null},getCanvas:function(N){var q=M.getState();return h.current&&b.current&&q?b.current.draw(q,h.current,N):null},getImage:function(){return D?aA({},D):null},isLoading:Y.isLoading,isLoaded:Y.isLoaded};return f4(function(){C()}),kl(function(){j()},[Y.getImage()]),kl(function(){x.current&&D&&(r==null||r(x.current))},[D]),kl(function(){x.current&&(a==null||a(x.current))},[Y.isLoaded(),Y.isLoading()]),y.useImperativeHandle(x,function(){return E}),{cropper:E,refs:{image:h,boundary:P,canvas:b},image:D}}var b0=y.forwardRef(function(A,e){var t=A.className,n=A.style,r=A.stretcherClassName,s=A.contentClassName,a=A.stretchAlgorithm,o=a===void 0?keA:a,i=A.sizeAlgorithm,l=i===void 0?MeA:i,u=A.children,f=y.useRef(null),d=y.useRef(null);return y.useImperativeHandle(e,function(){return{reset:function(){var g=f.current;g&&(g.style.height="",g.style.width="")},stretchTo:function(g){var v=f.current,m=d.current;if(g!=null&&g.width&&(g!=null&&g.height)&&v&&m){o(m,v,g);var p=l(m,g);return Promise.resolve(p.width&&p.height?p:null)}else return v&&(v.style.height="",v.style.width=""),Promise.resolve(null)}}}),y.createElement("div",{ref:d,style:n,className:YA("advanced-cropper-boundary",t)},y.createElement("div",{ref:f,className:YA(["advanced-cropper-boundary__stretcher",r])}),y.createElement("div",{className:YA(["advanced-cropper-boundary__content",s])},u))});b0.displayName="StretchableBoundary";var d4=function(A){var e=A.visible,t=A.className,n=A.style,r=A.children;return y.createElement("div",{style:n,className:YA(t,"advanced-cropper-fade",!!e&&"advanced-cropper-fade--visible")},r)},ptA=function(A){var e=A.cropper,t=A.children,n=A.className,r=A.style,s=e?e.getState():null,a=e?e.isLoaded():!1;return y.createElement("div",{className:YA(n,"advanced-cropper-wrapper"),style:r},y.createElement(d4,{visible:s&&a,className:"advanced-cropper-wrapper__fade"},t))};function g4(A){A.preventDefault()}var v4=y.forwardRef(function(A,e){var t=A.className,n=A.style,r=A.cropper,s=A.crossOrigin,a=s===void 0?!0:s,o=r.getState(),i=r.getTransitions(),l=r.getImage(),u=l&&o?FeA(l,o,i):{},f=l?l.src:void 0;return f?y.createElement("img",{key:f,ref:e,className:YA("advanced-cropper-background-image",t),src:f,crossOrigin:a===!0?"anonymous":a||void 0,style:aA(aA({},u),n),onMouseDown:g4}):null});v4.displayName="CropperBackgroundImage";var m4=y.forwardRef(function(A,e){var t=y.useRef(null),n=y.useRef(null);return y.useImperativeHandle(e,function(){return{draw:function(r,s,a){return a===void 0&&(a={}),s&&t.current&&n.current?NeA(r,s,t.current,n.current,a):null}}}),y.createElement(y.Fragment,null,y.createElement("canvas",{className:"advanced-cropper-canvas",ref:t}),y.createElement("canvas",{className:"advanced-cropper-canvas",ref:n}))});m4.displayName="CropperCanvas";var ev=(function(A){zr(e,A);function e(t){var n=A.call(this,t)||this;return n.processMove=function(r,s){var a,o=n.container.current;if(o&&n.touches.length){var i=o.getBoundingClientRect(),l=i.left,u=i.top;if(n.touches.length===1&&s.length===1&&n.props.onMove){var f={left:Math.abs(s[0].clientX-n.anchor.left-l)<Math.abs(n.touches[0].clientX-n.anchor.left-l),top:Math.abs(s[0].clientY-n.anchor.top-u)<Math.abs(n.touches[0].clientY-n.anchor.top-u)},d={left:0,top:0};(!n.props.useAnchor||!f.left)&&(d.left=s[0].clientX-n.touches[0].clientX),(!n.props.useAnchor||!f.top)&&(d.top=s[0].clientY-n.touches[0].clientY),(a=n.props)===null||a===void 0||a.onMove(d,r),n.touches=mr([],je(s),!1)}}},n.processEnd=function(){var r=n.props,s=r.onMoveEnd,a=r.onLeave;!n.props.disabled&&n.touches.length&&(s==null||s()),n.hovered&&(a==null||a(),n.hovered=!1),n.touches=[]},n.initAnchor=function(r){var s=n.container.current;if(s){var a=s.getBoundingClientRect(),o=a.left,i=a.top;n.anchor={left:r.clientX-o,top:r.clientY-i}}},n.onMouseOver=function(){var r=n.props,s=r.onEnter,a=r.disabled;!n.hovered&&!a&&(n.hovered=!0,s==null||s())},n.onMouseLeave=function(){var r=n.props.onLeave;n.hovered&&!n.touches.length&&(n.hovered=!1,r==null||r())},n.onTouchStart=function(r){var s=n.props,a=s.onEnter,o=s.onMoveStart,i=s.disabled;if(r.cancelable){n.touches=Array.from(r.touches);var l=!i&&r.touches.length===1;l&&(n.touches=Array.from(r.touches),o==null||o()),!n.hovered&&!i&&(n.hovered=!0,a==null||a()),(n.started||l)&&(r.preventDefault(),r.stopPropagation())}},n.onTouchEnd=function(){n.started=!1,n.processEnd()},n.onTouchMove=function(r){n.touches.length>=1&&(n.started?(n.processMove(r,Array.from(r.touches)),r.preventDefault(),r.stopPropagation()):UC({left:n.touches[0].clientX,top:n.touches[0].clientY},{left:r.touches[0].clientX,top:r.touches[0].clientY})>(n.props.activationDistance||0)&&(n.initAnchor({clientX:r.touches[0].clientX,clientY:r.touches[0].clientY}),n.started=!0))},n.onMouseDown=function(r){var s=n.props,a=s.onMoveStart,o=s.disabled;if(!o&&r.button===0){var i={clientX:r.clientX,clientY:r.clientY};n.touches=[i],n.initAnchor(i),r.stopPropagation(),a==null||a()}},n.onMouseMove=function(r){!n.props.disabled&&n.touches.length&&(n.processMove(r,[{clientX:r.clientX,clientY:r.clientY}]),r.preventDefault&&r.cancelable&&r.preventDefault(),r.stopPropagation())},n.onMouseUp=function(){n.processEnd()},n.touches=[],n.hovered=!1,n.started=!1,n.anchor={left:0,top:0},n.container=y.createRef(),n}return e.prototype.componentWillUnmount=function(){window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd);var t=this.container.current;t&&(t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("mousedown",this.onMouseDown))},e.prototype.componentDidMount=function(){window.addEventListener("mouseup",this.onMouseUp,{passive:!1}),window.addEventListener("mousemove",this.onMouseMove,{passive:!1}),window.addEventListener("touchmove",this.onTouchMove,{passive:!1}),window.addEventListener("touchend",this.onTouchEnd,{passive:!1});var t=this.container.current;t&&(t.addEventListener("touchstart",this.onTouchStart,{passive:!1}),t.addEventListener("mousedown",this.onMouseDown,{passive:!1}))},e.prototype.componentDidUpdate=function(t){this.props.disabled&&!t.disabled&&(this.touches=[])},e.prototype.render=function(){var t=this.props,n=t.children,r=t.className;return y.createElement("div",{className:YA("advanced-cropper-draggable-element",r),ref:this.container,onMouseOver:this.onMouseOver,onMouseLeave:this.onMouseLeave},n)},e.defaultProps={disabled:!1,activationDistance:30,useAnchor:!0,rerender:!0},e})(y.Component),htA=function(A){var e=A.position,t=A.className,n=A.disabled,r=A.onDrag,s=A.onDragEnd,a=A.onLeave,o=A.onEnter,i=A.children;return y.createElement(ev,{className:YA(["advanced-cropper-line-wrapper",e&&"advanced-cropper-line-wrapper--".concat(e),n&&"advanced-cropper-line-wrapper--disabled",t]),disabled:n,onMove:r,onMoveEnd:s,onLeave:a,onEnter:o,activationDistance:0},y.createElement("div",{className:YA(["advanced-cropper-line-wrapper__content",e&&"advanced-cropper-line-wrapper__content--".concat(e)])},i))},x0=function(A){var e,t,n=A.position,r=A.hoverClassName,s=A.wrapperClassName,a=A.defaultClassName,o=A.disabled,i=A.onMove,l=A.onMoveEnd,u=je(y.useState(!1),2),f=u[0],d=u[1],g=function(){d(!0)},v=function(){d(!1)};return y.createElement(htA,{className:YA("advanced-cropper-simple-line-wrapper",s,(e={},e["advanced-cropper-simple-line-wrapper--".concat(n)]=!!n,e)),position:n,disabled:o,onDrag:i,onDragEnd:l,onLeave:v,onEnter:g},y.createElement("div",{className:YA("advanced-cropper-simple-line",f&&"advanced-cropper-simple-line--hover",a,f&&r,(t={},t["advanced-cropper-simple-line--".concat(n)]=!!n,t))}))},wtA=function(A){var e=A.horizontalPosition,t=A.verticalPosition,n=A.className,r=A.disabled,s=A.onDrag,a=A.onDragEnd,o=A.onLeave,i=A.onEnter,l=A.children,u=A.style,f=e||t?k2(e,t).snakeCase:null;return y.createElement("div",{style:u,className:YA(n,"advanced-cropper-handler-wrapper",f&&"advanced-cropper-handler-wrapper--".concat(f),r&&"advanced-cropper-handler-wrapper--disabled")},y.createElement(ev,{className:"advanced-cropper-handler-wrapper__draggable",disabled:r,onMove:s,onMoveEnd:a,onLeave:o,onEnter:i,activationDistance:0},l))},z0=function(A){var e,t=A.verticalPosition,n=A.horizontalPosition,r=A.hoverClassName,s=A.wrapperClassName,a=A.defaultClassName,o=A.wrapperStyle,i=A.disabled,l=A.onMove,u=A.onMoveEnd,f=je(y.useState(!1),2),d=f[0],g=f[1],v=function(){g(!0)},m=function(){g(!1)};return y.createElement(wtA,{style:o,className:YA("advanced-cropper-simple-handler-wrapper",s,t&&"advanced-cropper-simple-handler-wrapper--".concat(t),n&&"advanced-cropper-simple-handler-wrapper--".concat(n),n&&t&&"advanced-cropper-simple-handler-wrapper--".concat(n,"-").concat(t),d&&"advanced-cropper-simple-handler-wrapper--hover"),verticalPosition:t,horizontalPosition:n,disabled:i,onDrag:l,onDragEnd:u,onLeave:m,onEnter:v},y.createElement("div",{className:YA("advanced-cropper-simple-handler",d&&"advanced-cropper-simple-handler--hover",a,d&&r,(e={},e["advanced-cropper-simple-handler--".concat(t)]=!!t,e["advanced-cropper-simple-handler--".concat(n)]=!!n,e["advanced-cropper-simple-handler--".concat(n,"-").concat(t)]=n&&t,e))}))},PtA=["east","west",null],ytA=["south","north",null],p4=function(A){var e=A.style,t=A.className,n=A.children,r=A.onResize,s=A.onResizeEnd,a=A.handlerComponent,o=a===void 0?z0:a,i=A.handlers,l=i===void 0?{eastNorth:!0,north:!0,westNorth:!0,west:!0,westSouth:!0,south:!0,eastSouth:!0,east:!0}:i,u=A.handlerClassNames,f=u===void 0?{}:u,d=A.handlerWrapperClassNames,g=d===void 0?{}:d,v=A.lines,m=v===void 0?{west:!0,north:!0,east:!0,south:!0}:v,p=A.lineComponent,h=p===void 0?x0:p,P=A.lineClassNames,b=P===void 0?{}:P,x=A.lineWrapperClassNames,z=x===void 0?{}:x,D=A.disabled,B=D===void 0?!1:D,M=A.reference,Y=M===void 0?null:M,V=je(y.useState(null),2),j=V[0],C=V[1],E=y.useMemo(function(){var H=[];return PtA.forEach(function(T){ytA.forEach(function(Z){if(T!==Z){var O=k2(T,Z),k=O.snakeCase,X=O.camelCase;k&&X&&H.push({name:X,className:k,verticalPosition:Z,horizontalPosition:T})}})}),H},[]),N=y.useMemo(function(){var H=[];return E.forEach(function(T){IAA(T.name)&&(Ha(m)?m[T.name]:m)&&H.push({name:T.name,component:h,className:YA(b.default,b[T.name],B&&b.disabled),wrapperClassName:YA("advanced-cropper-bounding-box__line","advanced-cropper-bounding-box__line--".concat(T.name),z.default,z[T.name],B&&z.disabled),hoverClassName:b.hover,verticalPosition:T.verticalPosition,horizontalPosition:T.horizontalPosition,disabled:B})}),H},[E,m,h,b,z,B]),q=y.useMemo(function(){var H=[];return E.forEach(function(T){(Ha(l)?l[T.name]:l)&&H.push({name:T.name,component:o,className:YA(f.default,f[T.name]),containerClassName:YA("advanced-cropper-bounding-box__handler-wrapper","advanced-cropper-bounding-box__handler-wrapper--".concat(T.className)),wrapperClassName:YA("advanced-cropper-bounding-box__handler","advanced-cropper-bounding-box__handler--".concat(T.className),g.default,g[T.name]),hoverClassName:f.hover,verticalPosition:T.verticalPosition,horizontalPosition:T.horizontalPosition,disabled:B})}),H},[E,l,o,f,g,B]),I=function(H,T){return function(Z,O){var k=Z.left,X=Z.top,J={left:k,top:X},F;if(!T&&H?F="width":T&&!H&&(F="height"),!B){if(r){var eA=k2(H,T).camelCase;eA&&r(eA,J,{reference:j||Y,preserveAspectRatio:O&&O.shiftKey,respectDirection:F,compensate:!0})}j||C(Y)}}},G=function(){s==null||s(),C(null)};return y.createElement("div",{className:YA("advanced-cropper-bounding-box",t),style:e},n,y.createElement("div",null,N.map(function(H){return y.createElement(H.component,{key:H.name,defaultClassName:H.className,hoverClassName:H.hoverClassName,wrapperClassName:H.wrapperClassName,position:H.name,disabled:H.disabled,onMove:I(H.horizontalPosition,H.verticalPosition),onMoveEnd:G})})),y.createElement("div",null,q.map(function(H){var T=y.createElement(H.component,{defaultClassName:H.className,hoverClassName:H.hoverClassName,wrapperClassName:H.wrapperClassName,horizontalPosition:H.horizontalPosition,verticalPosition:H.verticalPosition,disabled:H.disabled,onMove:I(H.horizontalPosition,H.verticalPosition),onMoveEnd:G});return y.createElement("div",{key:H.name,className:H.containerClassName},T)})))},h4=function(A){var e=A.className,t=A.children;return y.createElement("div",{className:YA("advanced-cropper-stencil-overlay",e)},t)};function btA(A){A===void 0&&(A=null);var e=y.useRef(new TeA),t=je(y.useState(!1),2),n=t[0],r=t[1];return[function(s){A&&A.active?e.current.start(aA(aA({},A),{onStart:function(){r(!0)},onProgress:function(a){s(a)},onStop:function(){r(!1)}})):e.current.active||s(1)},n]}var xtA=function(A){var e=A.className,t=A.transitions,n=A.children,r=Rs(A,["className","transitions","children"]),s=y.useRef(null),a=y.useRef(r),o=je(y.useState(r),2),i=o[0],l=o[1],u=je(btA(t),2),f=u[0],d=u[1];y.useLayoutEffect(function(){if(!Yo(i,r)){l(r);var m=d?aA({},a.current):i;f(function(p){var h=["left","top","height","width"];h.forEach(function(P){var b=r[P],x=m[P];a.current[P]=De(x)&&De(b)?x+(b-x)*p:b}),s.current&&(s.current.style.width="".concat(a.current.width,"px"),s.current.style.height="".concat(a.current.height,"px"),s.current.style.transform="translate3d(".concat(a.current.left,"px, ").concat(a.current.top,"px, 0px)"))})}},[i,d,r.width,r.height,r.top,r.left]);var g=d?a.current:r,v={left:0,top:0,width:"".concat(g.width,"px"),height:"".concat(g.height,"px"),transform:"translate3d(".concat(g.left,"px, ").concat(g.top,"px, 0px)")};return y.createElement("div",{ref:s,className:YA("advanced-cropper-artificial-transition",e),style:v},n)},w4=function(A){var e=A.className,t=A.transitions,n=A.width,r=A.height,s=A.left,a=A.top,o=A.children;return y.createElement(xtA,{className:YA("advanced-cropper-stencil-wrapper",e),transitions:t,width:n,height:r,top:a,left:s},o)},P4=function(A){var e=A.columns,t=e===void 0?3:e,n=A.rows,r=n===void 0?3:n,s=A.visible,a=s===void 0?!1:s,o=A.className,i=[],l=je(y.useState(t),2),u=l[0],f=l[1],d=je(y.useState(r),2),g=d[0],v=d[1];kl(function(){a&&(v(r),f(t))},[a,t,r]);for(var m=0;m<g;m++){for(var p=[],h=0;h<u;h++)p.push(y.createElement("div",{key:h,className:YA("advanced-cropper-stencil-grid__cell",m===0&&"advanced-cropper-stencil-grid__cell--top",m===g-1&&"advanced-cropper-stencil-grid__cell--bottom",h===0&&"advanced-cropper-stencil-grid__cell--left",h===u-1&&"advanced-cropper-stencil-grid__cell--right")}));i.push(y.createElement("div",{key:m,className:"advanced-cropper-stencil-grid__row"},p))}return y.createElement("div",{className:YA("advanced-cropper-stencil-grid",a&&"advanced-cropper-stencil-grid--visible",o)},i)},y4=y.forwardRef(function(A,e){var t=A.cropper,n=A.coordinates,r=A.aspectRatio,s=A.minAspectRatio,a=A.maxAspectRatio,o=A.handlerComponent,i=o===void 0?z0:o,l=A.handlers,u=l===void 0?{eastNorth:!0,north:!0,westNorth:!0,west:!0,westSouth:!0,south:!0,eastSouth:!0,east:!0}:l,f=A.handlerClassNames,d=f===void 0?{}:f,g=A.handlerWrapperClassNames,v=g===void 0?{}:g,m=A.lines,p=m===void 0?{west:!0,north:!0,east:!0,south:!0}:m,h=A.lineComponent,P=h===void 0?x0:h,b=A.lineClassNames,x=b===void 0?{}:b,z=A.lineWrapperClassNames,D=z===void 0?{}:z,B=A.resizable,M=B===void 0?!0:B,Y=A.movable,V=Y===void 0?!0:Y,j=A.grid,C=A.gridClassName,E=A.className,N=A.movingClassName,q=A.resizingClassName,I=A.previewClassName,G=A.boundingBoxClassName,H=A.overlayClassName,T=A.draggableAreaClassName,Z=A.disabled,O=t.getState(),k=t.getTransitions(),X=t.getInteractions(),J=M&&!Z,F=V&&!Z;y.useImperativeHandle(e,function(){return{aspectRatio:ro(r||{minimum:s,maximum:a})}});var eA=function(CA){t&&F&&t.moveCoordinates(CA)},R=function(){t&&t.moveCoordinatesEnd()},tA=function(CA,SA,de){t&&J&&t.resizeCoordinates(CA,SA,de)},K=function(){t&&t.resizeCoordinatesEnd()},$=n?fe(n)?n(O):n:h0(O),_=$.width,U=$.height,wA=$.left,HA=$.top;return O&&y.createElement(w4,{className:YA("advanced-cropper-rectangle-stencil",E,X.moveCoordinates&&N,X.resizeCoordinates&&q,{"advanced-cropper-rectangle-stencil--movable":F,"advanced-cropper-rectangle-stencil--moving":X.moveCoordinates,"advanced-cropper-rectangle-stencil--resizable":J,"advanced-cropper-rectangle-stencil--resizing":X.resizeCoordinates,"advanced-cropper-rectangle-stencil--disabled":Z}),width:_,height:U,left:wA,top:HA,transitions:k},y.createElement(p4,{reference:O.coordinates,className:YA(G,"advanced-cropper-rectangle-stencil__bounding-box"),handlers:u,handlerComponent:i,handlerClassNames:d,handlerWrapperClassNames:v,lines:p,lineComponent:P,lineClassNames:x,lineWrapperClassNames:D,onResize:tA,onResizeEnd:K,disabled:!J},y.createElement(ev,{disabled:!F,onMove:eA,onMoveEnd:R,className:YA("advanced-cropper-rectangle-stencil__draggable-area",T)},y.createElement(h4,{className:YA("advanced-cropper-rectangle-stencil__overlay",H)},j&&y.createElement(P4,{visible:t.hasInteractions(),columns:X.transformImage.rotate?9:3,rows:X.transformImage.rotate?9:3,className:YA("advanced-cropper-rectangle-stencil__grid",C)}),y.createElement("div",{className:YA("advanced-cropper-rectangle-stencil__preview",I)})))))});y4.displayName="RectangleStencil";function ztA(A){return y.useMemo(function(){return uu(A,{touch:!0},{touch:!1})},[A])}function DtA(A){return y.useMemo(function(){return uu(A,{touch:!0,wheel:{ratio:.1}},{touch:!1,wheel:!1})},[A])}function BtA(A){return y.useMemo(function(){return uu(A,{touch:!0,mouse:!0},{touch:!1,mouse:!1})},[A])}var MtA=(function(){function A(e){var t=e.active;this.active=t,this.defaultPrevented=!1}return A.prototype.preventDefault=function(){this.defaultPrevented=!0},A})(),CtA=(function(A){zr(e,A);function e(t){var n=A.call(this,t)||this;return n.processMove=function(r){var s=n.props,a=s.onTransform,o=s.touchScale,i=s.touchMove,l=s.touchRotate,u=n.container.current;u&&a&&(a(peA(r,n.touches,u,{scale:o,rotate:l,move:i})),n.touches=r)},n.processEnd=function(){var r=n.props.onTransformEnd;n.transforming&&(n.transforming=!1,r&&r())},n.processStart=function(){n.transforming=!0,n.debouncedProcessEnd.clear()},n.processEvent=function(r){var s=n.props,a=s.onEvent,o=s.disabled,i=s.preventDefault,l=i===void 0?!0:i,u=new MtA({active:n.transforming});return a?a(u,r):l&&(r.preventDefault(),r.stopPropagation()),!o&&!u.defaultPrevented},n.onWheel=function(r){var s=n.props,a=s.onTransform,o=s.wheelScale,i=n.container.current;o&&n.processEvent(r)&&(n.processStart(),a&&i&&a(heA(r,i,o===!0?.1:o.ratio)),n.touches.length||n.debouncedProcessEnd())},n.onTouchStart=function(r){var s=n.props,a=s.touchMove,o=s.touchScale,i=s.touchRotate;if(r.cancelable&&(a||(o||i)&&r.touches.length>1)&&n.processEvent(r)){var l=n.container.current;if(l){var u=l.getBoundingClientRect(),f=u.left,d=u.top,g=u.bottom,v=u.right;n.touches=Array.from(r.touches).filter(function(m){return m.clientX>f&&m.clientX<v&&m.clientY>d&&m.clientY<g})}}},n.onTouchEnd=function(r){r.touches.length===0&&(n.touches=[],n.processEnd())},n.onTouchMove=function(r){if(n.touches.length){var s=mr([],je(r.touches),!1).filter(function(a){return!a.identifier||n.touches.find(function(o){return o.identifier===a.identifier})});n.processEvent(r)&&(n.processMove(s),n.processStart())}},n.onMouseDown=function(r){var s=n.props.mouseMove;if(s&&"buttons"in r&&r.buttons===1&&n.processEvent(r)){var a={clientX:r.clientX,clientY:r.clientY};n.touches=[a],n.processStart()}},n.onMouseMove=function(r){n.touches.length&&n.processEvent(r)&&n.processMove([{clientX:r.clientX,clientY:r.clientY}])},n.onMouseUp=function(){n.touches=[],n.processEnd()},n.transforming=!1,n.touches=[],n.anchor={left:0,top:0},n.container=y.createRef(),n.debouncedProcessEnd=$C(n.processEnd,t.timeout),n}return e.prototype.shouldComponentUpdate=function(){return!0},e.prototype.componentWillUnmount=function(){window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd);var t=this.container.current;t&&(t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("mousedown",this.onMouseDown),t.removeEventListener("wheel",this.onWheel))},e.prototype.componentDidMount=function(){window.addEventListener("mouseup",this.onMouseUp,{passive:!1}),window.addEventListener("mousemove",this.onMouseMove,{passive:!1}),window.addEventListener("touchmove",this.onTouchMove,{passive:!1}),window.addEventListener("touchend",this.onTouchEnd,{passive:!1});var t=this.container.current;t&&(t.addEventListener("touchstart",this.onTouchStart,{passive:!1}),t.addEventListener("mousedown",this.onMouseDown,{passive:!1}),t.addEventListener("wheel",this.onWheel,{passive:!1}))},e.prototype.render=function(){var t=this.props,n=t.className,r=t.children,s=t.style;return y.createElement("div",{className:n,style:s,ref:this.container},r)},e.defaultProps={touchMove:!0,mouseMove:!0,touchScale:!0,touchRotate:!1,wheelScale:!0,timeout:500},e})(y.Component),jtA=function(A){var e=A.scaleImage,t=e===void 0?!0:e,n=A.moveImage,r=n===void 0?!0:n,s=A.rotateImage,a=s===void 0?!1:s,o=A.children,i=A.className,l=A.style,u=A.cropper,f=A.timeout,d=A.disabled,g=u.getTransitions(),v=ztA(a),m=DtA(t),p=BtA(r);return y.createElement(CtA,{className:i,style:l,onTransform:u.transformImage,onTransformEnd:u.transformImageEnd,touchMove:p.touch,mouseMove:p.mouse,touchScale:m.touch,wheelScale:m.wheel,touchRotate:v.touch,disabled:g.active||d,preventDefault:!d,timeout:f},o)},OtA=function(A,e){var t=A.style,n=A.className,r=A.stencilComponent,s=r===void 0?y4:r,a=A.stencilConstraints,o=a===void 0?i4:a,i=A.stencilProps,l=i===void 0?{}:i,u=A.wrapperComponent,f=u===void 0?ptA:u,d=A.wrapperProps,g=d===void 0?{}:d,v=A.backgroundComponent,m=v===void 0?v4:v,p=A.backgroundProps,h=p===void 0?{}:p,P=A.backgroundClassName,b=A.backgroundWrapperComponent,x=b===void 0?jtA:b,z=A.backgroundWrapperProps,D=z===void 0?{}:z,B=A.boundaryComponent,M=B===void 0?b0:B,Y=A.boundaryProps,V=A.boundaryClassName,j=A.canvas,C=j===void 0?!0:j,E=A.crossOrigin,N=E===void 0?!0:E,q=A.disabled,I=A.settings,G=Rs(A,["style","className","stencilComponent","stencilConstraints","stencilProps","wrapperComponent","wrapperProps","backgroundComponent","backgroundProps","backgroundClassName","backgroundWrapperComponent","backgroundWrapperProps","boundaryComponent","boundaryProps","boundaryClassName","canvas","crossOrigin","disabled","settings"]),H=y.useRef(null),T=mtA(function(){return aA(aA({},G),{crossOrigin:N,stencilProps:l,canvas:C,settings:aA(aA({},I),o(I,aA(aA({},l),H.current)))})}),Z=T.cropper,O=T.image,k=T.refs,X=s,J=f,F=x,eA=m,R=M;y.useImperativeHandle(e,function(){return Z});var tA={loading:Z.isLoading(),loaded:Z.isLoaded()};return y.createElement(J,aA({},g,{disabled:q,className:YA("advanced-cropper",n),cropper:Z,style:t},tA),y.createElement(R,aA({},Y,{ref:k.boundary,className:YA("advanced-cropper__boundary",V)}),y.createElement(F,aA({},D,{disabled:q,cropper:Z,className:"advanced-cropper__background-wrapper"}),Z.getState()&&y.createElement(eA,aA({},h,{ref:k.image,crossOrigin:N,cropper:Z,className:YA("advanced-cropper__background",P)})),y.createElement(X,aA({},l,{disabled:q,ref:H,cropper:Z,image:O}))),C&&y.createElement(m4,{ref:k.canvas})))},b4=ltA(OtA),x4=["transformImage","moveCoordinates","resizeCoordinates","defaultCoordinates","defaultVisibleArea","areaPositionRestrictions","areaSizeRestrictions","sizeRestrictions","positionRestrictions","aspectRatio","minWidth","minHeight","maxWidth","maxHeight","defaultSize","defaultPosition","defaultTransforms","imageRestriction","priority"];function z4(A,e){e===void 0&&(e=x4);var t={settings:{},props:{}};return Object.keys(A).forEach(function(n){e.some(function(r){return r===n})?t.settings[n]=A[n]:t.props[n]=A[n]}),t}var D4=y.forwardRef(function(A,e){var t=z4(A,mr(mr([],je(x4),!1),["stencilSize"],!1));return y.createElement(b4,aA({postProcess:rtA,stencilConstraints:$eA},t.props,{settings:aA(aA({defaultSize:etA,aspectRatio:ttA,sizeRestrictions:CeA(AtA)},t.settings),{transformImage:aA(aA({},t.settings.transformImage),{adjustStencil:!1})}),ref:e}))});D4.displayName="FixedCropper";var B4=y.forwardRef(function(A,e){var t=z4(A),n=t.props,r=t.settings,s=r.stencilSize,a=r.autoZoom,o=Rs(r,["stencilSize","autoZoom"]),i=itA();return Ke(a)||(n.postProcess||s?i("prop 'autoZoom' is deprecated now and will be removed, use 'postProcess' prop to pass your auto zoom function."):(i("prop 'autoZoom' is deprecated now and will be removed, use 'postProcess' prop to pass your auto zoom function. The 'postProcess' automatically set to 'hybridAutoZoom'"),n.postProcess=atA)),Ke(s)?y.createElement(b4,aA({},n,{ref:e,settings:o})):(i("prop 'stencilSize' is deprecated for <Cropper/> component now and will be removed, use <FixedCropper/> component instead."),y.createElement(D4,aA({ref:e,stencilSize:s},o,n)))});B4.displayName="CropperComponent";var TtA=y.forwardRef(function(A,e){var t=A.cropper,n=A.coordinates,r=A.handlerComponent,s=r===void 0?z0:r,a=A.handlers,o=a===void 0?{eastNorth:!0,westNorth:!0,westSouth:!0,eastSouth:!0}:a,i=A.handlerClassNames,l=i===void 0?{}:i,u=A.handlerWrapperClassNames,f=u===void 0?{}:u,d=A.lines,g=d===void 0?{west:!0,north:!0,east:!0,south:!0}:d,v=A.lineComponent,m=v===void 0?x0:v,p=A.lineClassNames,h=p===void 0?{}:p,P=A.lineWrapperClassNames,b=P===void 0?{}:P,x=A.resizable,z=x===void 0?!0:x,D=A.movable,B=D===void 0?!0:D,M=A.grid,Y=A.gridClassName,V=A.className,j=A.movingClassName,C=A.resizingClassName,E=A.previewClassName,N=A.boundingBoxClassName,q=A.overlayClassName,I=A.draggableAreaClassName,G=A.disabled,H=t.getState(),T=t.getTransitions(),Z=t.getInteractions(),O=z&&!G,k=B&&!G;y.useImperativeHandle(e,function(){return{aspectRatio:1,boundingBox:"circle"}});var X=function(U){t&&k&&t.moveCoordinates(U)},J=function(){t&&t.moveCoordinatesEnd()},F=function(U,wA,HA){t&&O&&t.resizeCoordinates(U,wA,HA)},eA=function(){t&&t.resizeCoordinatesEnd()},R=n?fe(n)?n(H):n:h0(H),tA=R.width,K=R.height,$=R.left,_=R.top;return H&&y.createElement(w4,{className:YA("advanced-cropper-circle-stencil",V,Z.moveCoordinates&&j,Z.resizeCoordinates&&C,{"advanced-cropper-circle-stencil--movable":k,"advanced-cropper-circle-stencil--moving":Z.moveCoordinates,"advanced-cropper-circle-stencil--resizable":O,"advanced-cropper-circle-stencil--resizing":Z.resizeCoordinates,"advanced-cropper-circle-stencil--disabled":G}),width:tA,height:K,left:$,top:_,transitions:T},y.createElement(p4,{reference:H.coordinates,className:YA(N,"advanced-cropper-circle-stencil__bounding-box"),handlers:o,handlerComponent:s,handlerClassNames:l,handlerWrapperClassNames:f,lines:g,lineComponent:m,lineClassNames:h,lineWrapperClassNames:b,onResize:F,onResizeEnd:eA,disabled:!O},y.createElement(ev,{disabled:!k,onMove:X,onMoveEnd:J,className:YA("advanced-cropper-circle-stencil__draggable-area",I)},y.createElement(h4,{className:YA("advanced-cropper-circle-stencil__overlay",q)},M&&y.createElement(P4,{visible:t.hasInteractions(),columns:Z.transformImage.rotate?9:3,rows:Z.transformImage.rotate?9:3,className:YA("advanced-cropper-circle-stencil__grid",Y)}),y.createElement("div",{className:YA("advanced-cropper-circle-stencil__preview",E)})))))});TtA.displayName="CircleStencil";var EtA=y.forwardRef(function(A,e){var t=A.src,n=A.crossOrigin,r=n===void 0?!0:n,s=Rs(A,["src","crossOrigin"]);return t?y.createElement("img",aA({key:t,ref:e,src:t,className:YA("advanced-cropper-source"),crossOrigin:r===!0?"anonymous":r||void 0},s)):null});EtA.displayName="CropperSource";var HtA=function(A){var e=A.children,t=A.cropper,n=A.className,r=A.style;return y.createElement("div",{className:YA(n,"cropper-preview-wrapper"),style:r},y.createElement(d4,{visible:t==null?void 0:t.isLoaded(),className:"cropper-preview-wrapper__fade"},e))},NtA=function(A){var e=A.className,t=A.cropper,n=A.crossOrigin,r=n===void 0?!0:n,s=A.size,a=A.style,o=t.getState(),i=t.getTransitions(),l=t.getImage(),u=s&&l&&(o!=null&&o.coordinates)?KeA(l,o,s,i):{},f=l?l.src:void 0;return f?y.createElement("img",{key:f,className:YA("advanced-cropper-background-image",e),src:f,crossOrigin:r===!0?"anonymous":r||void 0,style:aA(aA({},u),a),onMouseDown:g4}):null};y.forwardRef(function(A,e){var t,n,r,s,a=A.className,o=A.contentClassName,i=A.state,l=i===void 0?null:i,u=A.image,f=u===void 0?null:u,d=A.transitions,g=d===void 0?null:d,v=A.backgroundComponent,m=v===void 0?NtA:v,p=A.backgroundProps,h=A.backgroundClassName,P=A.boundaryComponent,b=P===void 0?b0:P,x=A.boundaryProps,z=A.boundaryClassName,D=A.wrapperComponent,B=D===void 0?HtA:D,M=A.wrapperProps,Y=A.loaded,V=Y===void 0?!0:Y,j=A.loading,C=j===void 0?!1:j,E=A.style,N=A.cropper,q=u4(),I=y.useRef(null),G=y.useRef(null),H=N||(G.current?G:{current:{getState:function(){return l},getTransitions:function(){return g},getImage:function(){return f},isLoaded:function(){return V},isLoading:function(){return C}}}),T=je(y.useState(null),2),Z=T[0],O=T[1],k=(n=(t=H.current)===null||t===void 0?void 0:t.getState())===null||n===void 0?void 0:n.coordinates,X=(s=(r=H.current)===null||r===void 0?void 0:r.getImage())===null||s===void 0?void 0:s.src,J=Z?{width:"".concat(Z.width,"px"),height:"".concat(Z.height,"px")}:{},F=function(){var K,$,_=($=(K=H.current)===null||K===void 0?void 0:K.getState())===null||$===void 0?void 0:$.coordinates;I.current&&_&&I.current.stretchTo(_).then(function(U){U&&_?Ys(FA(_),FA(U))?O({width:U.width,height:U.width/FA(_)}):O({width:U.height*FA(_),height:U.height}):O(null)}),q()};f4(F),y.useLayoutEffect(F,[k==null?void 0:k.height,k==null?void 0:k.width]),y.useImperativeHandle(e,function(){return{refresh:F,update:function(K){K?G.current=K:G.current=null,F()}}});var eA=B,R=m,tA=b;return y.createElement(eA,aA({},M,{className:YA(a,"advanced-cropper-preview"),cropper:H.current,style:E}),y.createElement(tA,aA({ref:I,stretchAlgorithm:ZeA},x,{className:YA("advanced-cropper-preview__boundary",z)}),y.createElement("div",{className:YA(o,"advanced-cropper-preview__content"),style:J},H.current&&y.createElement(R,aA({},p,{cropper:H.current,size:Z,className:YA(h,"advanced-cropper-preview__image",X&&"advanced-cropper-preview__image--visible")})))))});const km={custom:null,"1:1":{width:800,height:800},"16:9":{width:1920,height:1080},"3:2":{width:1200,height:800},"4:3":{width:1024,height:768}},ktA=()=>{const{state:{activeMedia:A},cropperRef:e,transformations:t,setTransformations:n,config:{cropperAspectRatio:r,viewOnly:s}}=Mr(),[a,o]=y.useState(null),[i,l]=y.useState(""),[u,f]=y.useState("desktop"),[d,g]=y.useState(r||"custom"),v=!((A==null?void 0:A.media)instanceof File)&&s,m=()=>{if(!r)return null;const[C,E]=r.split(":"),N=parseInt(C,10),q=parseInt(E,10);return isNaN(N)||isNaN(q)?null:{width:N,height:q}},p=()=>{if(r){const E=m();return E?E.width/E.height:void 0}if(d==="custom")return;const C=km[d];return C?C.width/C.height:void 0};y.useEffect(()=>{var E,N;if(!(A!=null&&A.media)||!e.current)return;if(!((A==null?void 0:A.media)instanceof File)){l(((E=A.media)==null?void 0:E.url)||((N=A.media)==null?void 0:N.src)),Y(!0);return}const C=new FileReader;C.onload=q=>{var I;e.current&&((I=q.target)!=null&&I.result)&&l(q.target.result.toString())},C.readAsDataURL(A==null?void 0:A.media),Y(!0)},[A]),y.useEffect(()=>{r&&g(r)},[r]);const h=[{icon:VZ,label:"desktop",size:"1920x1080"},{icon:uV,label:"tablet",size:"1024x768"},{icon:rV,label:"mobile",size:"414x896"}],P=()=>r?[]:Object.keys(km).map(C=>{let E=u7;return(C==="16:9"||C==="3:2"||C==="4:3")&&(E=c7),{icon:E,label:C}}),b=C=>{const E=C.getImage(),N=C.getCoordinates();let q;N&&(q=OP(N,(E==null?void 0:E.width)||0,(E==null?void 0:E.height)||0)),n(I=>({...I,[u]:{...I[u],coordinates:N,pillowCropBox:q||void 0,aspectRatio:r||d||"custom",originalImageWidth:(E==null?void 0:E.width)||0,originalImageHeight:(E==null?void 0:E.height)||0}}))},x=C=>{C&&(e.current&&e.current.reset(),f(C),setTimeout(()=>{z(C)},100))},z=C=>{const E=t[C];if(!(!e.current||!E)){if(E.rotation)for(let N=0;N<E.rotation/90;N++)e.current.rotateImage(90);if((E.flipHorizontal||E.flipVertical)&&e.current.flipImage(E.flipHorizontal||!1,E.flipVertical||!1),E.coordinates)e.current.setCoordinates(E.coordinates);else{const N=e.current.getImage();e.current.setCoordinates({height:N==null?void 0:N.height,left:0,top:0,width:N==null?void 0:N.width})}E.aspectRatio&&g(E.aspectRatio)}},D=(C,E)=>{if(e.current){e.current.flipImage(C,E);const N=e.current.getCoordinates(),q=e.current.getImage();n(I=>{var G,H,T,Z;return{...I,[u]:{...I[u],coordinates:N,flipHorizontal:C?!((G=I[u])!=null&&G.flipHorizontal):(H=I[u])==null?void 0:H.flipHorizontal,flipVertical:E?!((T=I[u])!=null&&T.flipVertical):(Z=I[u])==null?void 0:Z.flipVertical,originalImageWidth:(q==null?void 0:q.width)||0,originalImageHeight:(q==null?void 0:q.height)||0}}})}},B=()=>{if(!d||!a||!e.current)return;let C;if(r){const J=m();if(!J)return;C=J}else{const J=km[d];if(!J)return;C=J}const E=a.width,N=a.height,q=C.width,I=C.height,G=E/q,H=N/I,T=Math.min(G,H),Z=q*T,O=I*T,k={width:Z,height:O,left:(E-Z)/2,top:(N-O)/2};e.current.setCoordinates(k);const X=OP(k,E,N);n(J=>({...J,[u]:{...J[u],coordinates:k,pillowCropBox:X,aspectRatio:r||d,originalImageWidth:E,originalImageHeight:N}}))},M=()=>{if(e.current){e.current.rotateImage(-90);const C=e.current.getCoordinates(),E=e.current.getImage();n(N=>{var q;return{...N,[u]:{...N[u],coordinates:C,rotation:(((q=N[u])==null?void 0:q.rotation)||0)+90,originalImageWidth:(E==null?void 0:E.width)||0,originalImageHeight:(E==null?void 0:E.height)||0}}})}},Y=(C=!1)=>{if(e.current){const E={rotation:0,flipHorizontal:!1,flipVertical:!1,aspectRatio:r||"custom",coordinates:void 0,pillowCropBox:void 0,originalImageWidth:0,originalImageHeight:0};n(C?{desktop:E,tablet:E,mobile:E}:q=>({...q,[u]:E})),e.current.reset();const N=e.current.getImage();N&&e.current.setCoordinates({height:N==null?void 0:N.height,left:0,top:0,width:N==null?void 0:N.width}),r||g("custom")}};y.useEffect(()=>{B()},[d]);const V=P(),j=!r&&V.length>0;return c.jsxs("div",{className:"flex flex-col items-center space-y-4 h-full bg-muted p-4 px-6",children:[c.jsxs("div",{className:S("w-full flex justify-between items-center",{hidden:!v}),children:[c.jsx(Ff,{type:"single",value:u,onValueChange:x,className:"flex-1",children:h.map(C=>c.jsx(Kf,{value:C.label,className:"text-muted-foreground text-xs p-2 rounded-none gap-1 md:px-4 capitalize flex-col bg-transparent data-[state=on]:bg-transparent data-[state=on]:border-b-2 data-[state=on]:border-primary data-[state=on]:text-[#434343]",children:c.jsx(C.icon,{className:S("h-[16px] w-[20px]",{"text-[#434343]":C.label==u}),strokeWidth:2})},C.label))}),c.jsx(he,{size:"sm",variant:"outline",onClick:()=>Y(),children:"Reset"})]}),c.jsxs("div",{className:"bg-background overflow-hidden rounded border",children:[c.jsx(B4,{ref:e,src:i,onChange:v?b:void 0,onReady:C=>{const E=C.getImage();o(E),C.setCoordinates({height:E==null?void 0:E.height,left:0,top:0,width:E==null?void 0:E.width})},stencilProps:v?{movable:!0,resizable:!0,lines:!0,handlers:!0,overlayClassName:"bg-[#3338533D]",aspectRatio:p()}:{movable:!1,resizable:!1,lines:!1,handlers:!1},crossOrigin:!1,backgroundWrapperProps:{scaleImage:v,moveImage:v},resizeCoordinates:v,canvas:!0,className:"h-[25rem] w-lg relative bg-[red]",disabled:!v}),c.jsxs("div",{className:"flex gap-2 justify-center items-center text-muted-foreground text-xs p-4 border-t",children:[v&&j&&c.jsxs(c.Fragment,{children:[c.jsx(Ff,{type:"single",value:d,onValueChange:C=>g(C||"custom"),className:"gap-2",children:V.map(C=>c.jsxs(Kf,{value:C.label,className:"group text-muted-foreground text-xs h-fit p-2 rounded gap-1 capitalize flex-col bg-transparent data-[state=on]:bg-primary/40 data-[state=on]:text-[#434343]",children:[c.jsx(C.icon,{className:"h-[16px] w-[20px]",strokeWidth:2}),C.label]},C.label))}),c.jsx("div",{className:"w-px h-8 bg-border mx-2"})]}),r&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium ",children:[c.jsx(u7,{className:"h-4 w-4"}),r]}),v&&c.jsx("div",{className:"w-px h-8 bg-border mx-2"})]}),v&&c.jsxs(c.Fragment,{children:[c.jsxs(he,{variant:"ghost",className:"flex-col gap-1 !p-2 h-fit",onClick:M,children:[c.jsx(_Z,{className:"h-4 w-4"}),"Rotate"]}),c.jsxs(he,{variant:"ghost",className:"flex-col gap-1 !p-2 h-fit",onClick:()=>D(!0,!1),children:[c.jsx(MZ,{className:"h-4 w-4"}),"Flip H"]}),c.jsxs(he,{variant:"ghost",className:"flex-col gap-1 !p-2 h-fit",onClick:()=>D(!1,!0),children:[c.jsx(jZ,{className:"h-4 w-4"}),"Flip V"]})]})]})]})]})},ZtA=()=>{const{handleMediaUpdate:A,handleMediaAction:e,state:{activeMedia:t,activeTab:n},handleMediaSelect:r,config:s,mutations:{editMutationPending:a,uploadMutationPending:o}}=Mr(),i=(t==null?void 0:t.type)==="add"||(t==null?void 0:t.type)==="edit",l=a||o,[u,f]=y.useState({title:"",description:"",alternative_text:"",caption:""});y.useEffect(()=>{var m;if(!(t!=null&&t.media))return;const v={title:(t==null?void 0:t.media)instanceof File?t.media.name:((m=t.media)==null?void 0:m.title)??"",alternative_text:(t==null?void 0:t.media)instanceof File?t.media.name:t.media.alternative_text??"",caption:t.media.caption??""};f(v)},[t]);const d=y.useCallback((v,m)=>{f(p=>({...p,[v]:m}))},[]),g=y.useCallback(()=>{var v;if(s!=null&&s.viewOnly&&!((t==null?void 0:t.media)instanceof File))r({...t.media,...u});else{const m=u;(t==null?void 0:t.media)instanceof File||(m.uuid=(v=t==null?void 0:t.media)==null?void 0:v.uuid),A(m)}},[s==null?void 0:s.viewOnly,t.media,r,u,A]);return c.jsx(_t,{open:i,onOpenChange:()=>e(""),children:c.jsx(Vt,{className:"sm:max-w-[70%] sm:max-h-[50rem] p-6 gap-4 items-start overflow-auto",children:c.jsxs("div",{className:"flex flex-col gap-4",children:[c.jsxs(Ln,{className:"h-fit w-fit",children:[c.jsx(qh,{children:c.jsx("h1",{className:"text-left text-md",children:"Edit Image"})}),c.jsx(Ag,{className:" text-start text-muted-foreground text-base",children:"Modify your image to your preference"})]}),c.jsxs("div",{className:" flex-1 h-0 w-full overflow-auto grid grid-cols-[2fr_1fr] gap-4",children:[c.jsx(ktA,{}),c.jsxs("div",{className:"max-w-full flex flex-col justify-between items-center gap-3",children:[c.jsx("div",{className:"w-full justify-start h-fit bg-muted border text-base font-bold p-4 py-2 rounded",children:"Image Properties"}),c.jsxs("div",{className:"space-y-3 w-full overflow-y-auto h-10 flex-1",children:[c.jsx(st,{label:"Title",value:u.title,onChange:v=>d("title",v),inputProps:{placeholder:"Type here"}}),c.jsx(st,{label:c.jsxs("span",{className:"flex justify-between gap-2",children:["Alternative Text",c.jsx(fi,{children:c.jsxs(Ca,{children:[c.jsx(ja,{asChild:!0,children:c.jsx(l7,{className:"h-4 w-4 text-muted-foreground"})}),c.jsx(Oa,{children:c.jsx("p",{children:"Alternative text helps screen-reading tools describe images to visually impaired readers."})})]})})]}),value:u.alternative_text,onChange:v=>d("alternative_text",v),inputProps:{placeholder:"Describe the image"}}),c.jsx(st,{label:c.jsxs("span",{className:"flex justify-between gap-2",children:["Description",c.jsx(fi,{children:c.jsxs(Ca,{children:[c.jsx(ja,{asChild:!0,children:c.jsx(l7,{className:"h-4 w-4 text-muted-foreground"})}),c.jsx(Oa,{children:c.jsx("p",{className:"max-w-xs",children:"Add a caption to display below the image"})})]})})]}),type:"textarea",value:u.caption,onChange:v=>d("caption",v),textareaProps:{placeholder:"Image caption",rows:4}})]}),c.jsx(Dr,{className:"w-full items-center mt-auto mb-4",children:c.jsx(he,{onClick:g,isLoading:l,disabled:l,className:"w-full rounded capitalize",children:(t==null?void 0:t.media)instanceof File?"Upload Image":s.viewOnly||n!=null&&n.viewOnly?"add image":"Save Changes"})})]})]})]})})})},VtA=()=>{const{state:{activeMedia:A},mutations:{deleteMutationPending:e},handleMediaAction:t,handleMediaDelete:n}=Mr(),r=()=>t("");return c.jsx(_t,{open:A.type=="delete",onOpenChange:r,children:c.jsxs(Vt,{className:"max-w-[370px] p-0 overflow-hidden",children:[c.jsx(Ln,{className:"bg-secondary p-4 py-5 items-start",children:c.jsx(Jn,{className:"text-md",children:c.jsx("h1",{children:"Remove Image?"})})}),c.jsx(ki,{className:"px-4 text-base",children:"Are you sure you want to delete this image?"}),c.jsxs(Dr,{className:"flex flex-row p-4 pt-0 gap-4 justify-end mt-4",children:[c.jsx(he,{variant:"outline",className:"rounded",onClick:r,children:"No, don't delete"}),c.jsx(he,{className:"rounded",variant:"destructive",onClick:n,isLoading:e,disabled:e,children:"Delete"})]})]})})},StA=({className:A})=>{var n;const{dispatch:e,config:t}=Mr();return c.jsxs("div",{className:S("w-full h-[100vh] flex-1 flex flex-col p-6 overflow-hidden gap-4",A),children:[c.jsxs("div",{children:[c.jsx("h1",{"data-testid":"header",className:" text-3xl font-[UniversalFeature]",children:"Media Library"}),c.jsx("p",{className:"text-base text-muted-foreground",children:"Select your preferred image choice"})]}),c.jsxs(bg,{defaultValue:(n=jl[0])==null?void 0:n.id,onValueChange:r=>e({type:"SET_ACTIVE_TAB",payload:jl.find(s=>s.id==r)}),className:"p-0 w-full flex-1 flex flex-col",children:[c.jsxs("div",{className:"w-full max-w-full overflow-hidden flex items-center justify-between gap-4",children:[c.jsx(Kc,{className:"h-fit flex-1 p-0 justify-start bg-transparent border-0 overflow-hidden",children:jl.map((r,s)=>c.jsxs(Uc,{value:r.id,className:"px-4 py-2 rounded-none rounded-t flex items-center justify-center gap-2 data-[state=active]:border-b-3 data-[state=active]:border-[#6FFFF0] data-[state=active]:bg-accent data-[state=active]:text-accent-foreground data-[state=active]:shadow-none border-0",children:[r.icon&&c.jsx("img",{alt:r.label,src:f0(r.icon),className:"h-5 w-5"}),r.label]},r.id+s))}),c.jsx(nAA,{})]}),jl.map(r=>c.jsx(ZAA,{tab:r,viewOnly:!!t.viewOnly},r.id))]}),c.jsx(ZtA,{}),c.jsx(VtA,{})]})},ey={success:c.jsx(Ma,{className:"w-20 h-20 text-primary-foreground/70"}),error:c.jsx(PZ,{className:"w-20 h-20 text-white"}),warning:c.jsx(gV,{className:"w-20 h-20 text-yellow-500"}),info:c.jsx(Ma,{className:"w-20 h-20 text-primary-foreground"}),action:c.jsx(Ma,{className:"w-20 h-20 text-primary-foreground/90"})},XtA=()=>{const{isVisible:A,currentModal:e,hideModal:t}=cC(),[n,r]=y.useState(!1);if(!e)return null;const{type:s,title:a,message:o,icon:i,confirmText:l="OK",cancelText:u="Cancel",onAction:f,onCancel:d,variant:g="default",size:v="md"}=e,m=async()=>{if(f){r(!0);try{await f()}catch(b){console.error("Modal confirm action failed:",b)}finally{r(!1)}}t()},p=()=>{d&&d(),t()},h={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl"},P=()=>{switch(s){case"error":return"destructive";case"warning":return"outline";case"success":return"default";default:return g}};return c.jsx(_t,{"data-testid":"action-modal",open:A,onOpenChange:t,children:c.jsxs(Vt,{className:S("p-8 sm:max-w-[400px] ",h[v]),children:[c.jsxs(Ln,{className:"flex items-center justify-around text-center space-y-4",children:[(i||ey[s])&&c.jsx("div",{className:S("flex justify-center items-center p-4 text-3xl bg-primary/50 w-20 h-20 rounded-full border border-primary ",{"bg-destructive/90 border-destructive":s=="error"}),children:i||ey[s]}),c.jsx(Jn,{children:c.jsx("h1",{className:"text-md capitalize",children:a})}),o&&c.jsx(ki,{className:"text-sm lowercase first-letter:uppercase text-center text-muted-foreground px-10",children:o})]}),c.jsxs(Dr,{className:"flex justify-center space-x-4 mt-4",children:[s==="action"&&c.jsx(MA,{className:"flex-1 rounded",variant:"outline",onClick:m,disabled:n,children:n?"Processing...":l}),c.jsx(MA,{variant:P(),onClick:p,disabled:n,className:"flex-1 rounded",children:u})]})]})})},wc=({children:A})=>{const[e,t]=y.useState(!1),[n,r]=y.useState(null),s=y.useRef(null),a=y.useCallback(l=>{s.current&&clearTimeout(s.current),r(l),t(!0),l.autoClose&&l.autoClose>0&&(s.current=setTimeout(()=>{o()},l.autoClose))},[]),o=y.useCallback(()=>{s.current&&clearTimeout(s.current),t(!1),r(null)},[]);y.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const i={showModal:a,hideModal:o,isVisible:e,currentModal:n};return c.jsxs(lC.Provider,{value:i,children:[A,c.jsx(XtA,{})]})},M4=({className:A,config:e,onChange:t,image:n})=>c.jsx(wc,{children:c.jsx(AAA,{config:e,onChange:t,image:n,children:c.jsx(StA,{className:A})})}),C4=({open:A=!0,config:e,onChange:t,handleToggleOpen:n,className:r,image:s})=>c.jsx(_t,{open:A,onOpenChange:n,children:c.jsx(Vt,{className:S("sm:max-w-[70%] h-[90%] shadow-lg p-0",r),children:c.jsx(M4,{config:e,onChange:t,className:"h-full",image:s})})});function qu(A){return UA({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"},child:[]},{tag:"path",attr:{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"},child:[]},{tag:"path",attr:{d:"M7 3v4a1 1 0 0 0 1 1h7"},child:[]}]})(A)}function YtA(A){return UA({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19"},child:[]},{tag:"path",attr:{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z"},child:[]},{tag:"circle",attr:{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor"},child:[]}]})(A)}function tv(A){return UA({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 6h18"},child:[]},{tag:"path",attr:{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"},child:[]},{tag:"path",attr:{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"},child:[]},{tag:"line",attr:{x1:"10",x2:"10",y1:"11",y2:"17"},child:[]},{tag:"line",attr:{x1:"14",x2:"14",y1:"11",y2:"17"},child:[]}]})(A)}const GtA=()=>{const{state:A,dispatch:e,imageGalleryConfig:t}=qn(),{showImageGallery:n,value:r}=A,s=()=>{e({type:"TOGGLE_IMAGE_GALLERY"})},a=()=>{e({type:"SET_VALUE",payload:""})},o=u=>{u&&e({type:"SELECT_IMAGE",payload:u}),e({type:"TOGGLE_IMAGE_GALLERY",payload:!1})};if(!t)return null;const i=r,l=(i==null?void 0:i.url)||(i==null?void 0:i.src)||"";return c.jsxs("div",{className:S("flex-1 overflow-hidden",{"border-2 border-dashed ":!l}),children:[l&&c.jsxs("div",{className:"relative w-full max-h-full overflow-hidden flex-1 flex items-center justify-center",children:[c.jsx(qi,{url:l,alt:i.alternative_text,classname:"min-h-20 waz-input-box-content"}),c.jsxs("div",{className:"flex items-center gap-1 absolute top-2 right-2 z-10",children:[c.jsx(MA,{variant:"ghost",size:"icon",className:"rounded-md shadow-[0px_4.29px_12.86px_0px_#00000012] bg-background w-7 h-7",onClick:s,children:c.jsx(Xi,{color:"gray",fontSize:6})}),c.jsx(MA,{variant:"ghost",size:"icon",className:"rounded-md shadow-[0px_4.29px_12.86px_0px_#00000012] bg-background w-7 h-7",onClick:a,children:c.jsx(tv,{color:"red",size:"small"})})]})]}),!l&&c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 h-50",onClick:s,children:[c.jsx(bAA,{className:"text-muted-forground"}),c.jsxs("p",{className:"text-sm text-center",children:[c.jsx("span",{className:"text-[#EE6F71] cursor-pointer",children:"Click to open media library"})," ",c.jsx("br",{}),"PNG, JPG, JPEG"]})]}),c.jsx(C4,{config:{...t,viewOnly:!0},open:n,onChange:o,image:i,handleToggleOpen:u=>e({type:"TOGGLE_IMAGE_GALLERY",payload:u})})]})};function D0(A){return UA({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"},child:[]}]})(A)}function j4(A){return UA({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},child:[]}]})(A)}function G2(A){return UA({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"},child:[]}]})(A)}function O4(A){return UA({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512l388.6 0c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304l-91.4 0z"},child:[]}]})(A)}function ItA(A){return UA({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M16.1 260.2c-22.6 12.9-20.5 47.3 3.6 57.3L160 376l0 103.3c0 18.1 14.6 32.7 32.7 32.7c9.7 0 18.9-4.3 25.1-11.8l62-74.3 123.9 51.6c18.9 7.9 40.8-4.5 43.9-24.7l64-416c1.9-12.1-3.4-24.3-13.5-31.2s-23.3-7.5-34-1.4l-448 256zm52.1 25.5L409.7 90.6 190.1 336l1.2 1L68.2 285.7zM403.3 425.4L236.7 355.9 450.8 116.6 403.3 425.4z"},child:[]}]})(A)}const QtA=()=>{const{state:{value:A},dispatch:e,optionsQuery:{data:t,isLoading:n,fetchNextPage:r,hasNextPage:s,isFetchingNextPage:a},selectProps:o}=qn(),i=y.useMemo(()=>{const h=(t==null?void 0:t.pages.flatMap(P=>P==null?void 0:P.data))??[];if(Array.isArray(A)){const P=A.filter(b=>typeof b=="object"&&"label"in b&&"value"in b);return[...P.filter(b=>b==null?void 0:b.value),...h.filter(b=>!P.some(x=>x.value==b.value))]}else return typeof A=="object"&&A&&"label"in A&&"value"in A&&(A!=null&&A.value)?[A,...h.filter(P=>P.value!==A.value)]:h},[t,A]),[l,u]=w.useState(!1),{ref:f,inView:d}=_g(),g=y.useCallback(h=>{e({type:"SET_OPTIONS_SEARCH_VALUE",payload:h})},[e]),v=y.useCallback(h=>{if(o!=null&&o.multiple){let P=[];A&&Array.isArray(A)&&A.every(x=>typeof x=="object"&&"label"in x&&"value"in x)&&(P=A);const b=P.find(x=>x.value===h.value)?P.filter(x=>x.value!==h.value):[...P,h];e({type:"SET_VALUE",payload:b})}else e({type:"SET_VALUE",payload:h}),u(!1)},[o==null?void 0:o.multiple,A,e]),m=(o==null?void 0:o.placeholder)||"Select...",p=y.useMemo(()=>{const h={label:m,options:""};if(!A)return h;if(o!=null&&o.multiple){if(!Array.isArray(A))return h;const P=A.filter(B=>typeof B=="object"&&"label"in B&&"value"in B);if(!P.length)return h;const b=o.maximumLabelItems||P.length,z=P.slice(0,b).map(B=>B.label||B.value).join(", ");return{label:P.length>b?`${z} +${P.length-b}`:z,options:P.map(B=>B.label||B.value).join(", ")}}if(typeof A=="object"&&A&&"label"in A&&"value"in A){const P=A.label||A.value||m;return{label:P,options:P}}return h},[o==null?void 0:o.multiple,o==null?void 0:o.maximumLabelItems,A,m]);return w.useEffect(()=>{d&&s&&!a&&r()},[d,s,a,r]),c.jsxs(Zi,{open:l,onOpenChange:u,modal:!1,children:[c.jsx(Vi,{asChild:!0,children:c.jsxs(MA,{variant:"ghost",role:"combobox","aria-expanded":l,className:"w-full justify-between h-10 bg-background !p-2 rounded-none hover:bg-background",children:[c.jsx("span",{className:S("w-full text-left overflow-x-auto no-scrollbar capitalize",{"opacity-50":p.label==m}),children:p.label}),c.jsx(mZ,{className:"opacity-50"})]})}),c.jsx(no,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:c.jsxs(Lc,{children:[c.jsx(A9,{placeholder:(o==null?void 0:o.searchPlaceholder)||"Search options...",className:"h-10",onValueChange:o!=null&&o.queryConfig?g:void 0}),c.jsxs(sg,{children:[c.jsx(ag,{className:"flex items-center justify-center p-3 ",children:n?c.jsx(si,{className:"h-6 w-6 animate-spin"}):"No Options found."}),c.jsx(og,{children:i.map(h=>c.jsxs(ig,{value:h.label,onSelect:()=>v(h),className:"capitalize",children:[h.label,c.jsx(j4,{className:S("ml-auto",p!=null&&p.options.toString().includes(h.label)||p.options.toString().includes(h.value)?"opacity-100":"opacity-0")})]},h.value))}),s&&c.jsx("div",{ref:f,className:"w-full flex justify-center",children:a?c.jsx(si,{className:"h-6 w-6 animate-spin"}):c.jsx(MA,{variant:"ghost",onClick:()=>r(),children:"Load more"})})]})]})})]})},T4=y.createContext(void 0),aa=()=>{const A=y.useContext(T4);if(A===void 0)throw new Error("useWysiwyg must be used within a WysiwygProvider");return A},LtA=({icon:A,title:e,description:t,handleClick:n,className:r})=>c.jsxs(MA,{onClick:n,variant:"ghost",className:S("w-full h-fit flex items-center justify-start gap-4 p-3 rounded-none m-0 hover:bg-accent",r),children:[A,c.jsxs("div",{className:"flex flex-col justify-start items-start",children:[c.jsx("span",{className:"p-0",children:e}),c.jsx("span",{className:"text-sm text-muted-foreground",children:t})]})]}),JtA=()=>{const{handleInitiateEmbed:A}=aa(),e=n=>{A==null||A(n)},t=[{icon:c.jsx(NZ,{className:"w-[40px] text-[#FBBC9A]"}),title:"Picture",description:"jpeg, png",type:"image"},{icon:c.jsx(hV,{size:"10",className:"text-[#FBBC9A]"}),title:"Video",description:"JW player, Youtube, Vimeo",type:"video"},{icon:c.jsx(Bh,{size:"10",className:"text-[#FBBC9A]"}),title:"Social",description:"Instagram, Twitter, Tiktok, Snapchat, Facebook",type:"link"}];return c.jsxs(Zi,{children:[c.jsx(Vi,{asChild:!0,children:c.jsx(MA,{variant:"ghost",size:"icon",className:"p-1 h-6 w-6 rounded-full bg-gray-200 hover:bg-muted text-muted-foreground",children:c.jsx(Ao,{})})}),c.jsxs(no,{className:"w-fit p-0 bg-background",align:"start",sideOffset:5,children:[c.jsx("div",{className:"p-4 border-b leading-[18px]",children:c.jsx("span",{className:"text-md",children:"Embeds"})}),c.jsx("div",{children:t.map(n=>c.jsx(LtA,{icon:n.icon,title:n.title,description:n.description,handleClick:()=>e(n.type),className:""},n.type))})]})]})};function qtA(A){return UA({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5.82843 6.99955L8.36396 9.53509L6.94975 10.9493L2 5.99955L6.94975 1.0498L8.36396 2.46402L5.82843 4.99955H13C17.4183 4.99955 21 8.58127 21 12.9996C21 17.4178 17.4183 20.9996 13 20.9996H4V18.9996H13C16.3137 18.9996 19 16.3133 19 12.9996C19 9.68584 16.3137 6.99955 13 6.99955H5.82843Z"},child:[]}]})(A)}function RtA(A){return UA({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M16 7H11C7.68629 7 5 9.68629 5 13C5 16.3137 7.68629 19 11 19H20V21H11C6.58172 21 3 17.4183 3 13C3 8.58172 6.58172 5 11 5H16V1L22 6L16 11V7Z"},child:[]}]})(A)}function WtA(A){return UA({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M19 21H5C4.44772 21 4 20.5523 4 20V11L1 11L11.3273 1.6115C11.7087 1.26475 12.2913 1.26475 12.6727 1.6115L23 11L20 11V20C20 20.5523 19.5523 21 19 21ZM6 19H18V9.15745L12 3.7029L6 9.15745V19ZM8 15H16V17H8V15Z"},child:[]}]})(A)}function FtA(A){return UA({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 15H13V17H11V15ZM11 7H13V13H11V7Z"},child:[]}]})(A)}const ty=()=>{const{quillObj:A,state:e}=aa(),t=()=>{A&&A.history&&A.history.undo()},n=()=>{A&&A.history&&A.history.redo()};return c.jsxs("div",{className:"bg-muted order-2 w-full p-2 h-fit flex items-center justify-center gap-4 border-b",children:[c.jsx(JtA,{}),c.jsxs("div",{id:e.toolbarId,className:"!bg-transparent w-full !border-0 !p-0 h-fit flex flex-row gap-2 flex-wrap ql-toolbar",children:[c.jsx("span",{className:S("ql-formats","!rounded-sm !w-[120px] flex justify-between"),children:c.jsxs("select",{className:"ql-header !text-base !font-bold !w-full !m-0","data-tooltip":"Text Format",children:[c.jsx("option",{value:"",children:"Normal Text"}),c.jsx("option",{value:"1",className:"",children:"Heading 1"}),c.jsx("option",{value:"2",className:"",children:"Heading 2"}),c.jsx("option",{value:"3",className:"!",children:"Heading 3"}),c.jsx("option",{value:"4",className:"!",children:"Heading 4"}),c.jsx("option",{value:"5",className:"!",children:"Heading 5"}),c.jsx("option",{value:"6",className:"!",children:"Heading 6"})]})}),c.jsxs("span",{className:"ql-formats",children:[c.jsx("button",{className:"ql-bold","data-tooltip":"Bold (Ctrl+B)"}),c.jsx("button",{className:"ql-italic","data-tooltip":"Italic (Ctrl+I)"}),c.jsx("button",{className:"ql-underline","data-tooltip":"Underline (Ctrl+U)"}),c.jsx("button",{className:"ql-strike","data-tooltip":"Strike through"})]}),c.jsxs("span",{className:"ql-formats",children:[c.jsx("select",{className:"ql-align","data-tooltip":"Text Alignment"}),c.jsx("select",{className:"ql-color","data-tooltip":"Text Color"}),c.jsx("select",{className:"ql-background","data-tooltip":"Background Color"})]}),c.jsxs("span",{className:"ql-formats",children:[c.jsx("button",{className:"ql-blockquote","data-tooltip":"Blockquote"}),c.jsx("button",{className:"ql-code-block","data-tooltip":"Code Block"})]}),c.jsxs("span",{className:"ql-formats",children:[c.jsx("button",{className:"ql-list",value:"ordered","data-tooltip":"Numbered List"}),c.jsx("button",{className:"ql-list",value:"bullet","data-tooltip":"Bullet List"}),c.jsx("button",{className:"ql-indent",value:"-1","data-tooltip":"Decrease Indent"}),c.jsx("button",{className:"ql-indent",value:"+1","data-tooltip":"Increase Indent"})]}),c.jsx("span",{className:"ql-formats",children:c.jsx("button",{className:"ql-link","data-tooltip":"Insert Link (Ctrl+K)"})}),c.jsxs("span",{className:"ql-formats",children:[c.jsx("button",{onClick:t,"data-tooltip":"Undo (Ctrl+Z)",children:c.jsx(qtA,{className:"text-xl"})}),c.jsx("button",{className:"ql-redo",onClick:n,"data-tooltip":"Redo (Ctrl+Y)",children:c.jsx(RtA,{className:"text-xl"})})]})]})]})};function KtA(A){return UA({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 3H4a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1zM9 9H5V5h4v4zm11 4h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-6a1 1 0 0 0-1-1zm-1 6h-4v-4h4v4zM17 3c-2.206 0-4 1.794-4 4s1.794 4 4 4 4-1.794 4-4-1.794-4-4-4zm0 6c-1.103 0-2-.897-2-2s.897-2 2-2 2 .897 2 2-.897 2-2 2zM7 13c-2.206 0-4 1.794-4 4s1.794 4 4 4 4-1.794 4-4-1.794-4-4-4zm0 6c-1.103 0-2-.897-2-2s.897-2 2-2 2 .897 2 2-.897 2-2 2z"},child:[]}]})(A)}function UtA(A){return UA({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M20 2H10c-1.103 0-2 .897-2 2v4H4c-1.103 0-2 .897-2 2v10c0 1.103.897 2 2 2h10c1.103 0 2-.897 2-2v-4h4c1.103 0 2-.897 2-2V4c0-1.103-.897-2-2-2zM4 20V10h10l.002 10H4zm16-6h-4v-4c0-1.103-.897-2-2-2h-4V4h10v10z"},child:[]}]})(A)}function _tA(A){return UA({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M21 15c0-4.625-3.507-8.441-8-8.941V4h-2v2.059c-4.493.5-8 4.316-8 8.941v2h18v-2zM5 15c0-3.859 3.141-7 7-7s7 3.141 7 7H5zm-3 3h20v2H2z"},child:[]}]})(A)}function $tA(A){return UA({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z"},child:[]}]})(A)}const AnA=({selectedText:A})=>{const{dispatch:e,handleContentChange:t,handleInitiateEmbed:n,quillObj:r}=aa(),s=[{label:"Cut",action:"cut",disabled:!A,shortcut:"Ctrl+X"},{label:"Copy",action:"copy",disabled:!A,shortcut:"Ctrl+C"},{label:"Paste",action:"paste",disabled:!1,shortcut:"Ctrl+V"},{type:"separator"},{label:"Add Link",action:"link",disabled:!A,shortcut:"Ctrl+K"},{label:"Remove Link",action:"removeLink",disabled:!A,shortcut:""},{type:"separator"},{label:"Insert Image",action:"insertImage",disabled:!1,shortcut:""},{label:"Insert Video",action:"insertVideo",disabled:!1,shortcut:""},{label:"Insert Social Link",action:"insertSocial",disabled:!1,shortcut:""}],a=y.useCallback(()=>{var l;(l=r==null?void 0:r.root)!=null&&l.innerHTML&&t(r.root.innerHTML)},[r,t]),o=()=>{const l=document.querySelector('[data-state="open"]');l&&l.setAttribute("data-state","closed"),document.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:!0}))},i=y.useCallback(async l=>{if(!r)return;const u=r.getSelection();try{switch(l){case"cut":if(u&&u.length>0){const f=r.getText(u.index,u.length);await navigator.clipboard.writeText(f),r.deleteText(u.index,u.length),a()}break;case"copy":if(u&&u.length>0){const f=r.getText(u.index,u.length);await navigator.clipboard.writeText(f)}break;case"paste":try{const f=await navigator.clipboard.readText();u&&(r.insertText(u.index,f),a())}catch(f){console.warn("Failed to read clipboard:",f)}break;case"link":if(o(),u&&u.length>0){setTimeout(()=>{r.formatText(u.index,u.length,"link","https://","api"),a()},100);return}break;case"removeLink":u&&u.length>0&&(r.formatText(u.index,u.length,"link",!1),a());break;case"insertImage":o(),n("image");break;case"insertVideo":o(),n("video");break;case"insertSocial":o(),n("link");break}}catch(f){console.error("Context menu action failed:",f)}},[r,a,n]);return c.jsxs(u1,{className:"w-50",children:[s.map((l,u)=>l.type==="separator"?c.jsx(f1,{},u):c.jsxs(yp,{inset:!0,disabled:l.disabled,className:S("w-full text-left text-sm hover:bg-accent flex items-center justify-between !px-2 !py-2"),onClick:()=>!l.disabled&&i(l.action),children:[c.jsx("span",{children:l.label}),l.shortcut&&c.jsx(d1,{className:"text-xs text-gray-400 ml-4",children:l.shortcut})]},u)),c.jsxs(yp,{inset:!0,disabled:!A,className:S("w-full text-left text-sm hover:bg-accent flex items-center justify-start !px-2 !py-2 "),onClick:()=>{o(),e({type:"TOGGLE_EMBED_POST",payload:!0})},children:[c.jsx($tA,{className:"text-md text-current"}),c.jsx("span",{children:"Insert Article"})]})]})},ny=()=>{const[A,e]=y.useState(""),{dispatch:t,state:{content:n,embedType:r,embedValue:s,quillRef:a},handleContentChange:o,blogPostsConfig:i,quillObj:l,imageGalleryConfig:u}=aa(),f=r&&s?{type:r,value:s}:void 0,d=((u==null?void 0:u.apolloUri)||"").replaceAll("/graphql",""),g=y.useCallback(m=>{var p,h,P,b;if(!l){console.warn("Quill editor not available for embed");return}try{const x=l.getSelection(!0)||{index:l.getLength(),length:0},z=document.getElementById("editorParent"),D=(z==null?void 0:z.scrollTop)||0,{type:B,value:M}=m;switch(B){case"link":{const[V,j]=M.split("||>>");V&&j&&(l.insertText(x.index,V,"user"),l.setSelection(x.index,V.length),l.formatText(x.index,V.length,"link",j));break}case"post":{const V=s;if(i!=null&&i.postBaseURL&&(V!=null&&V.slug)){const j=l.getSelection();j&&j.length>0&&l.formatText(j.index,j.length,"link",i.postBaseURL+V.slug)}break}case"image":{const V=M,{desktop:j,tablet:C,mobile:E,url:N}=mc({url:V.url,transformationsUrl:d}),q=(h=(p=V==null?void 0:V.src)==null?void 0:p.includes)!=null&&h.call(p,"unsplash")?"Unsplash":"Pexels",I=`${V!=null&&V.photographer?`Photo by
|
|
425
425
|
<a href=${(P=V==null?void 0:V.photographer)==null?void 0:P.url} style="color: inherit;">${(b=V==null?void 0:V.photographer)==null?void 0:b.name}</a> on
|
|
426
426
|
<a href=${V==null?void 0:V.src} style="color: inherit;">${q}</a>`:(V==null?void 0:V.caption)??""}`,H={sources:[{srcset:Iu(E),media:"(max-width: 640px)",type:"image/webp"},{srcset:Iu(j),media:"(min-width: 1025px)",type:"image/webp"},{srcset:Iu(C),media:"(max-width: 1024px)",type:"image/webp"}],fallbackSrc:Iu(N),alt:(V==null?void 0:V.caption)||(V==null?void 0:V.alternate_text)||"",caption:I};l.insertEmbed(x.index,"picture",H,"user"),setTimeout(()=>{const T=l.getLength(),Z=x.index+1;Z>=T-1&&(l.insertText(Z,`
|
|
427
|
-
`,"user"),l.setSelection(Z+1,0))},100);break}case"htmlembed":l.clipboard.dangerouslyPasteHTML(x.index,M,"user");break;default:l.insertEmbed(x.index,B,M);break}z&&(z.scrollTop=D);const Y=l.root.innerHTML;o(Y),t({type:"RESET_EMBED"})}catch(x){console.error("Failed to handle embed:",x),t({type:"RESET_EMBED"})}},[l,t,o,i,s]);y.useEffect(()=>{f&&g(f)},[f,g]),y.useEffect(()=>{var p;if(!l)return;const m=h=>{const P=h&&h.length>0?l.getText(h.index,h.length):"";e(P.trim())};return(p=l==null?void 0:l.on)==null||p.call(l,"selection-change",m),()=>{var h;(h=l==null?void 0:l.off)==null||h.call(l,"selection-change",m)}},[l]);const v=y.useCallback(()=>{if(!n||n.trim().length===0)return 0;const m=n.replace(/<[^>]*>/g,"").trim();return m.length===0?0:m.split(/\s+/).filter(p=>p.length>0).length},[n]);return c.jsx(l1,{children:c.jsxs("div",{className:"flex order-3 h-full flex-col w-full relative bg-background",children:[c.jsx(c1,{className:"w-full h-10 grow flex flex-col items-center justify-center overflow-auto",children:c.jsx("div",{id:"editorParent",className:"flex w-full h-10 flex-1 items-center justify-center overflow-auto pb-10",children:c.jsx("div",{ref:a,id:"editor",className:"quill-editor text-md flex-1"})})}),c.jsx(AnA,{selectedText:A}),c.jsxs("div",{className:"flex justify-end text-sm text-muted-foreground border p-2 absolute bottom-0 right-0 w-full bg-muted",children:[v()," word count"]})]})})},nv=A=>new Promise(e=>{const t=setTimeout(()=>nv(A),10);typeof A<"u"&&(clearTimeout(t),e(null))}),Co=({src:A=null,innerHTML:e=null,tag:t="head",async:n=!1,id:r=null})=>new Promise((s,a)=>{const o=document.createElement("script");A&&(o.src=A),e&&(o.innerHTML=e),r&&(o.id=r),n&&(o.async=!0),o.defer=!0,o.onload=()=>{s()},o.onerror=a;const i=document.getElementsByTagName(t)[0];i?i.appendChild(o):a(new Error(`Target element "${t}" not found`))}),enA=(A="")=>{const e=document.createElement("div");e.innerHTML=A;const t=e.querySelector("iframe"),n=e.querySelector("span"),r=(n==null?void 0:n.style.width.replace("px",""))??"560",s=(n==null?void 0:n.style.height.replace("px",""))??"600";t.setAttribute("width",r),t.setAttribute("height",s);const a=t.getAttribute("src"),o=new URL(a);return o.searchParams.append("width",r),o.searchParams.append("height",s),t.setAttribute("src",o.toString()),t.outerHTML},tnA=(A="")=>{const e=document.createElement("div");e.innerHTML=A;const t=e.querySelector("iframe"),n="560",r="720",s=t.getAttribute("src"),a=new URL(s);return a.searchParams.append("width",n),a.searchParams.append("height",r),t.setAttribute("src",a.toString()),t.setAttribute("width",n),t.setAttribute("height",r),t.outerHTML},nnA=(A="")=>{var o,i;const e=document.createElement("div");e.innerHTML=A;const t=e.querySelector("iframe"),n=((o=t==null?void 0:t.getAttribute("height"))==null?void 0:o.replace("px",""))??"",r=((i=t==null?void 0:t.getAttribute("width"))==null?void 0:i.replace("px",""))??"",s=(t==null?void 0:t.getAttribute("src"))||"",a=new URL(s);return a.searchParams.append("height",n),a.searchParams.append("width",r),t==null||t.setAttribute("src",a.toString()),t.outerHTML},rnA=async()=>{await Co({src:"https://www.instagram.com/embed.js"}),await Co({src:"https://platform.twitter.com/widgets.js"}),await Co({src:"https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v14.0",tag:"body"}),await Co({src:"//embed.redditmedia.com/widgets/platform.js"})},snA=A=>A.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||A.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/)||A.match(/^.*(youtu.be\/|v\/|e\/|u\/\w+\/|embed\/|v=)([^#&?]*).*/),anA=A=>A.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/),jo=A=>{var n;const e=snA(A);if(e&&((n=e[2])==null?void 0:n.length)===11)return{embed:!0,url:"https://www.youtube.com/embed/"+e[2]+"?showinfo=0"};const t=anA(A);return t?{embed:!0,url:(t[1]||"https")+"://player.vimeo.com/video/"+t[2]+"/"}:{url:A,embed:!1}},onA={history:{delay:500,maxStack:100,userOnly:!0},clipboard:!0},inA=["header","size","bold","italic","underline","align","list","indent","link","strike","image","video","color","blockquote","background","code-block","picture"],E4=Ne({url:iA().url("Invalid URL, enter valid URL")}),lnA=()=>{const{state:{showEmbedVideo:A},dispatch:e,handleAddEmbed:t}=aa(),[n,r]=y.useState(jo("")),s=()=>{e({type:"TOGGLE_EMBED_VIDEO",payload:!1})},a=()=>{t("video",n.url),r(jo("")),s()},o=ug({resolver:Mg(E4),defaultValues:{url:""},reValidateMode:"onChange",mode:"onChange"}),i=async()=>{if(!l)throw new Error("Validation failed");a(),o.reset()},l=o.formState.isValid;return y.useEffect(()=>{const u=o.watch(async(f,{name:d,values:g})=>{d=="url"&&r(jo(g.url??""))});return()=>u.unsubscribe()},[o]),c.jsx(_t,{open:A,onOpenChange:s,children:c.jsxs(Vt,{className:"p-0 overflow-hidden rounded-xl border-0",children:[c.jsx(Ln,{className:"bg-secondary p-4 py-5 items-start",children:c.jsx(Jn,{children:c.jsx("h1",{className:"text-md",children:"Embed Video"})})}),c.jsxs("div",{className:"px-4 space-y-4 flex items-center justify-center flex-wrap",children:[l&&c.jsx("div",{className:"w-full [&_video]:max-h-50 [&_video]:lg:max-h-80",children:c.jsx(st,{label:"Video Preview",type:"video",value:n.url,linkProps:{className:"min-h-70 ![&_video]:lg:max-h-50"},onChange:u=>r(jo(u))})}),c.jsx(eo,{control:o.control,name:"url",render:({field:u,fieldState:f})=>c.jsx(st,{label:"Video Url",onChange:u.onChange,error:f.error,inputProps:{name:u.name,value:u.value,className:"underline",placeholder:"Video URL"}})},"url")]}),c.jsx(Dr,{className:"flex flex-row p-4 pt-0 gap-4 justify-end mt-4",children:c.jsx(he,{className:"rounded",variant:"primary",onClick:i,disabled:!l,children:"Embed"})})]})})};function cnA(A){return UA({attr:{version:"1.1",viewBox:"0 0 20 16"},child:[{tag:"path",attr:{d:"M13 11.5l1.5 1.5 5-5-5-5-1.5 1.5 3.5 3.5z"},child:[]},{tag:"path",attr:{d:"M7 4.5l-1.5-1.5-5 5 5 5 1.5-1.5-3.5-3.5z"},child:[]},{tag:"path",attr:{d:"M10.958 2.352l1.085 0.296-3 11-1.085-0.296 3-11z"},child:[]}]})(A)}const unA={title:"",content:"",showEmbedVideo:!1,showEmbedLink:!1,showEmbedImage:!1,showEmbedPost:!1,embedType:null,embedValue:"",error:!1,isLoading:!1,toolbarId:"",editorContainerId:""},fnA=(A,e)=>{switch(e.type){case"SET_TITLE":return{...A,title:e.payload};case"SET_CONTENT":return{...A,content:e.payload};case"TOGGLE_EMBED_VIDEO":return{...A,showEmbedVideo:e.payload};case"TOGGLE_EMBED_LINK":return{...A,showEmbedLink:e.payload};case"TOGGLE_EMBED_IMAGE":return{...A,showEmbedImage:e.payload};case"TOGGLE_EMBED_POST":return{...A,showEmbedPost:e.payload};case"SET_EMBED":return{...A,embedType:e.payload.type,embedValue:e.payload.value};case"INITIATE_EMBED":return{...A,embedType:e.payload,showEmbedVideo:e.payload==="video",showEmbedLink:e.payload==="link",showEmbedImage:e.payload==="image"};case"RESET_EMBED":return{...A,embedType:"",embedValue:"",showEmbedVideo:!1,showEmbedLink:!1,showEmbedImage:!1};case"SET_ERROR":return{...A,error:e.payload};case"SET_LOADING":return{...A,isLoading:e.payload};default:return A}};function dnA({config:A,url:e}){let t=Dt();const n=qg(e||"",300);re.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT&&(t=na(re.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT));const r=y.useCallback(async()=>{if(A!=null&&A.query){const s=A==null?void 0:A.query,a=A==null?void 0:A.variables;return(await t.query({query:s,variables:{...a||{},url:n}})).data[A.dataKey]}else throw console.error("Invalid Query Configuration"),Error("Invalid Query Configuration")},[t,A,n]);return Lg({queryKey:[(A==null?void 0:A.cacheKey)||(A==null?void 0:A.dataKey),n],queryFn:r,staleTime:300*1e3,gcTime:600*1e3,refetchOnMount:!1,refetchOnWindowFocus:!1})}const gnA=({value:A,label:e,removeCaption:t})=>{const n={text:s=>c.jsx("iframe",{className:"",allowFullScreen:!0,src:jo(s).url}),tiktok:s=>c.jsx(vnA,{url:s,className:"custom__embed tiktok__embed"}),twitter:s=>c.jsx(mnA,{url:s}),instagram:(s,a)=>c.jsx(hnA,{value:s,removeCaption:a}),facebook:(s,a)=>c.jsx(pnA,{value:s,removeCaption:a}),reddit:()=>c.jsx(wnA,{url:A})};y.useEffect(()=>{rnA()},[]);const r=n[e];if(!["text","facebook","tiktok","instagram","twitter","reddit"].includes(e)||!A)return c.jsx("div",{className:"w-fit max-h-[20vh] overflow-auto flex items-center justify-center border border-[#ccc]",children:c.jsx(cnA,{size:30})});if(r)return c.jsx(c.Fragment,{children:r(A,t)})},vnA=({url:A="",className:e=""})=>{const[t,n]=y.useState(null);return y.useEffect(()=>{const r=async a=>{try{const o=await fetch(`https://www.tiktok.com/oembed?url=${encodeURIComponent(a)}`),{html:i=""}=await o.json();return i}catch(o){return console.error({summary:`TikTok Embed Fetch Failed For: ${a}`,message:o==null?void 0:o.message}),null}};(async()=>{if(!A)return;const a=await r(A);n(a)})().then(()=>{Co({src:"https://www.tiktok.com/embed.js"})})},[A]),c.jsx("div",{className:e,dangerouslySetInnerHTML:{__html:t??""}})},mnA=({url:A=""})=>{var a;const[e,t]=y.useState(null),n=y.useRef(null),{twitterEmbedConfig:r}=aa(),s=dnA({config:r,url:A});return y.useEffect(()=>{const o=s.data;if(s.isError||!(o!=null&&o.data)||!n.current)return;const i=JSON.parse(o==null?void 0:o.data);t(i==null?void 0:i.html),(async()=>{await new Promise(u=>setTimeout(u,100)),window.twttr&&window.twttr.widgets&&n.current&&window.twttr.widgets.load(n.current)})()},[s.data,s.isError]),y.useEffect(()=>{if(!window.twttr){const o=document.createElement("script");o.src="https://platform.twitter.com/widgets.js",o.async=!0,document.body.appendChild(o)}},[]),c.jsxs("div",{className:"relative w-full max-w-[550px] min-h-20",children:[s.isLoading&&c.jsx("div",{className:"absolute h-full w-full inset-0 bg-secondary/20 animate-pulse rounded"}),s.isFetched&&c.jsx("div",{className:"w-full",ref:n,dangerouslySetInnerHTML:{__html:e}}),s.isError&&c.jsx("div",{className:"p-4 border border-red-200 bg-red-50 rounded text-red-600",children:(a=s.error)==null?void 0:a.message})]})},pnA=({value:A,removeCaption:e})=>(y.useEffect(()=>{(async()=>{var n,r,s;await nv(window.FB),(s=(r=(n=window.FB)==null?void 0:n.XFBML)==null?void 0:r.parse)==null||s.call(r)})()},[A,e]),c.jsx("div",{className:"fb-post custom__embed","data-href":A,"data-show-text":`${!e}`,children:c.jsx("blockquote",{cite:A,className:"fb-xfbml-parse-ignore"})})),hnA=({value:A,removeCaption:e})=>(y.useEffect(()=>{(async()=>{var n,r,s;await nv(window.instgrm),(s=(r=(n=window.instgrm)==null?void 0:n.Embeds)==null?void 0:r.process)==null||s.call(r)})()},[A,e]),c.jsx("div",{dangerouslySetInnerHTML:{__html:`<blockquote class="instagram-media" ${e?"":"data-instgrm-captioned"} data-instgrm-permalink="${A}?utm_source=ig_embed&utm_campaign=loading" data-instgrm-version="13" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:540px; min-width:326px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:16px;"> <a href="${A}?utm_source=ig_embed&utm_campaign=loading" style=" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%;" target="_blank"> <div style=" display: flex; flex-direction: row; align-items: center;"> <div style="background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 40px; margin-right: 14px; width: 40px;"></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 100px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 60px;"></div></div></div><div style="padding: 19% 0;"></div> <div style="display:block; height:50px; margin:0 auto 12px; width:50px;"><svg width="50px" height="50px" viewBox="0 0 60 60" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g transform="translate(-511.000000, -20.000000)" fill="#000000"><g><path d="M556.869,30.41 C554.814,30.41 553.148,32.076 553.148,34.131 C553.148,36.186 554.814,37.852 556.869,37.852 C558.924,37.852 560.59,36.186 560.59,34.131 C560.59,32.076 558.924,30.41 556.869,30.41 M541,60.657 C535.114,60.657 530.342,55.887 530.342,50 C530.342,44.114 535.114,39.342 541,39.342 C546.887,39.342 551.658,44.114 551.658,50 C551.658,55.887 546.887,60.657 541,60.657 M541,33.886 C532.1,33.886 524.886,41.1 524.886,50 C524.886,58.899 532.1,66.113 541,66.113 C549.9,66.113 557.115,58.899 557.115,50 C557.115,41.1 549.9,33.886 541,33.886 M565.378,62.101 C565.244,65.022 564.756,66.606 564.346,67.663 C563.803,69.06 563.154,70.057 562.106,71.106 C561.058,72.155 560.06,72.803 558.662,73.347 C557.607,73.757 556.021,74.244 553.102,74.378 C549.944,74.521 548.997,74.552 541,74.552 C533.003,74.552 532.056,74.521 528.898,74.378 C525.979,74.244 524.393,73.757 523.338,73.347 C521.94,72.803 520.942,72.155 519.894,71.106 C518.846,70.057 518.197,69.06 517.654,67.663 C517.244,66.606 516.755,65.022 516.623,62.101 C516.479,58.943 516.448,57.996 516.448,50 C516.448,42.003 516.479,41.056 516.623,37.899 C516.755,34.978 517.244,33.391 517.654,32.338 C518.197,30.938 518.846,29.942 519.894,28.894 C520.942,27.846 521.94,27.196 523.338,26.654 C524.393,26.244 525.979,25.756 528.898,25.623 C532.057,25.479 533.004,25.448 541,25.448 C548.997,25.448 549.943,25.479 553.102,25.623 C556.021,25.756 557.607,26.244 558.662,26.654 C560.06,27.196 561.058,27.846 562.106,28.894 C563.154,29.942 563.803,30.938 564.346,32.338 C564.756,33.391 565.244,34.978 565.378,37.899 C565.522,41.056 565.552,42.003 565.552,50 C565.552,57.996 565.522,58.943 565.378,62.101 M570.82,37.631 C570.674,34.438 570.167,32.258 569.425,30.349 C568.659,28.377 567.633,26.702 565.965,25.035 C564.297,23.368 562.623,22.342 560.652,21.575 C558.743,20.834 556.562,20.326 553.369,20.18 C550.169,20.033 549.148,20 541,20 C532.853,20 531.831,20.033 528.631,20.18 C525.438,20.326 523.257,20.834 521.349,21.575 C519.376,22.342 517.703,23.368 516.035,25.035 C514.368,26.702 513.342,28.377 512.574,30.349 C511.834,32.258 511.326,34.438 511.181,37.631 C511.035,40.831 511,41.851 511,50 C511,58.147 511.035,59.17 511.181,62.369 C511.326,65.562 511.834,67.743 512.574,69.651 C513.342,71.625 514.368,73.296 516.035,74.965 C517.703,76.634 519.376,77.658 521.349,78.425 C523.257,79.167 525.438,79.673 528.631,79.82 C531.831,79.965 532.853,80.001 541,80.001 C549.148,80.001 550.169,79.965 553.369,79.82 C556.562,79.673 558.743,79.167 560.652,78.425 C562.623,77.658 564.297,76.634 565.965,74.965 C567.633,73.296 568.659,71.625 569.425,69.651 C570.167,67.743 570.674,65.562 570.82,62.369 C570.966,59.17 571,58.147 571,50 C571,41.851 570.966,40.831 570.82,37.631"></path></g></g></g></svg></div><div style="padding-top: 8px;"> <div style=" color:#3897f0; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:550; line-height:18px;"> View this post on Instagram</div></div><div style="padding: 12.5% 0;"></div> <div style="display: flex; flex-direction: row; margin-bottom: 14px; align-items: center;"><div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(0px) translateY(7px);"></div> <div style="background-color: #F4F4F4; height: 12.5px; transform: rotate(-45deg) translateX(3px) translateY(1px); width: 12.5px; flex-grow: 0; margin-right: 14px; margin-left: 2px;"></div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(9px) translateY(-18px);"></div></div><div style="margin-left: 8px;"> <div style=" background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 20px; width: 20px;"></div> <div style=" width: 0; height: 0; border-top: 2px solid transparent; border-left: 6px solid #f4f4f4; border-bottom: 2px solid transparent; transform: translateX(16px) translateY(-4px) rotate(30deg)"></div></div><div style="margin-left: auto;"> <div style=" width: 0px; border-top: 8px solid #F4F4F4; border-right: 8px solid transparent; transform: translateY(16px);"></div> <div style=" background-color: #F4F4F4; flex-grow: 0; height: 12px; width: 16px; transform: translateY(-4px);"></div> <div style=" width: 0; height: 0; border-top: 8px solid #F4F4F4; border-left: 8px solid transparent; transform: translateY(-4px) translateX(8px);"></div></div></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center; margin-bottom: 24px;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 224px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 144px;"></div></div></a><p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;"><a href="${A}?utm_source=ig_embed&utm_campaign=loading" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;" target="_blank">A post shared by </a></p></div></blockquote>`}})),wnA=({url:A=""})=>{const e=y.useRef(null);return y.useEffect(()=>{(async()=>{!A||!e.current||(window.rembeddit||(await Co({src:"//embed.redditmedia.com/widgets/platform.js"}),await nv(window.rembeddit)),setTimeout(()=>{if(window.rembeddit&&e.current)try{window.rembeddit.createEmbeds()}catch(n){console.warn("Reddit embed processing failed:",n)}},500))})()},[A]),c.jsx("div",{className:"w-full max-w-[600px] p-2 relative",children:c.jsx("div",{className:"custom__embed p-4",ref:e,children:c.jsx("blockquote",{className:"reddit-embed-bq","data-card-created":Date.now(),children:c.jsx("a",{href:A,children:A})})})})},Zm=[{label:"Text",value:"text"},{label:"Instagram",value:"instagram"},{label:"Facebook",value:"facebook"},{label:"X",value:"twitter"},{label:"Reddit",value:"reddit"},{label:"TikTok",value:"tiktok"}],PnA=()=>{var v;const{state:{showEmbedLink:A},dispatch:e,handleAddEmbed:t}=aa(),[n,r]=y.useState(((v=Zm[0])==null?void 0:v.value)||"text"),[s,a]=y.useState(""),o=y.useRef(null),i=ug({resolver:Mg(E4),defaultValues:{url:""},reValidateMode:"onChange",mode:"onChange"}),l=i.formState.isValid,u=m=>{t("htmlembed",m),d(),a("")},f=async()=>{var m,p,h,P,b;try{if(!l)throw new Error("Validation failed");switch(n){case"text":u((m=o.current)==null?void 0:m.innerHTML);break;case"tiktok":case"twitter":u(tnA((p=o.current)==null?void 0:p.innerHTML));break;case"facebook":u(enA((h=o.current)==null?void 0:h.innerHTML));break;case"instagram":case"reddit":u(nnA((P=o.current)==null?void 0:P.innerHTML));break;default:break}r(((b=Zm[0])==null?void 0:b.value)||"text"),a("")}catch(x){console.log(x)}},d=()=>{e({type:"TOGGLE_EMBED_LINK",payload:!1})},g=m=>{const p=m;p!=null&&p.value&&r(p.value)};return y.useEffect(()=>{const m=i.watch((p,{name:h,values:P})=>{h=="url"&&a(P.url??"")});return()=>m.unsubscribe()},[i]),c.jsx(_t,{open:A,onOpenChange:d,children:c.jsxs(Vt,{className:"sm:max-w-[600px] p-0 overflow-hidden rounded border-0",children:[c.jsx(Ln,{className:"bg-secondary p-4 py-5 items-start",children:c.jsx(Jn,{children:c.jsx("h1",{className:"text-md",children:"Embed Link"})})}),c.jsx("div",{className:"mx-auto mb-5 w-fit max-h-90 overflow-auto",id:"postembed",ref:o,children:l&&c.jsx(gnA,{label:n,removeCaption:!1,value:s})}),c.jsxs("div",{className:"px-4 space-y-4",children:[c.jsx(st,{label:"Social Media Platform",type:"select",value:{value:n,label:n},selectProps:{options:Zm,dataKey:"social-media-platforms"},onChange:g}),c.jsx(eo,{control:i.control,name:"url",render:({field:m,fieldState:p})=>c.jsx(fr,{className:"flex-1",children:c.jsx(to,{className:"w-full",children:c.jsx(st,{label:"URL",inputProps:{name:m.name,value:m.value,className:"underline",placeholder:"URL"},error:p.error,onChange:m.onChange})})})},"url")]}),c.jsxs(Dr,{className:"flex flex-row p-4 pt-0 gap-4 justify-end mt-4",children:[c.jsx(he,{className:"rounded",variant:"primary",onClick:f,disabled:!l,children:"Embed"}),c.jsx(he,{variant:"outline",className:"rounded",onClick:d,children:"Cancel"})]})]})})},H4=({open:A=!0,onSave:e,handleToggleOpen:t,className:n,selectedPosts:r,columns:s,queryConfig:a,defaultState:o,gridCard:i,postType:l,filterFields:u,postBaseURL:f,apolloUri:d,...g})=>{const v=m=>{e==null||e(m),t==null||t(!1)};return c.jsx(_t,{open:A,onOpenChange:t,children:c.jsx(Vt,{className:S("sm:max-w-[80%] md:max-w-[80%] h-[90%] shadow-lg p-0 overflow-hidden",n),children:c.jsx(Cr,{columns:s,selectedPosts:r,queryConfig:a,defaultState:o,gridCard:i,postType:l,postBaseURL:f,filterFields:u,isSelect:!0,rootClassName:"h-full",gridColumnStyle:"repeat(auto-fit, minmax(210px, 1fr))",onSave:v,apolloUri:d,...g})})})},ynA=({className:A})=>{const{state:e,imageGalleryConfig:t,dispatch:n,handleAddEmbed:r,asChild:s,blogPostsConfig:a}=aa(),{showEmbedImage:o,showEmbedPost:i}=e,l=d=>{n({type:"TOGGLE_EMBED_IMAGE",payload:d})},u=d=>{r("image",d),l(!1)},f=d=>{d[0]&&r("post",d[0]),n({type:"TOGGLE_EMBED_POST",payload:!1})};return c.jsxs(c.Fragment,{children:[!s&&c.jsxs("div",{className:S("w-full h-full flex-1 flex flex-col no-scrollbar gap-2 border-1",A),"data-testid":"editor",children:[c.jsx(ty,{}),c.jsx(ny,{})]}),s&&c.jsxs(c.Fragment,{children:[c.jsx(ty,{}),c.jsx(ny,{})]}),c.jsx(lnA,{}),c.jsx(PnA,{}),t&&c.jsx(C4,{config:{...t,viewOnly:!0},open:o,onChange:d=>d&&u(d),handleToggleOpen:l}),a&&c.jsx(H4,{...a,open:i,selectedPosts:[],onSave:f,handleToggleOpen:d=>n({type:"TOGGLE_EMBED_POST",payload:d})})]})},bnA=({children:A,onChange:e,imageGalleryConfig:t,content:n,asChild:r,blogPostsConfig:s,twitterEmbedConfig:a})=>{const o=y.useRef(null),[i,l]=y.useState(null),u=y.useMemo(()=>({toolbarId:`toolbar-${Date.now()}`,editorContainerId:`editorParent-${Date.now()}`}),[]),[f,d]=y.useReducer(fnA,{...unA,toolbarId:u.toolbarId,editorContainerId:u.editorContainerId,content:n||"",quillRef:o}),g=y.useCallback(h=>{const P=h.replace(/<div class="ql-picture-caption"([^>]*?)>Click to edit caption\.\.\.<\/div>/g,'<div class="ql-picture-caption"$1></div>');d({type:"SET_CONTENT",payload:P}),e==null||e(P)},[e]),v=h=>{setTimeout(()=>{d({type:"INITIATE_EMBED",payload:h})},100)},m=(h,P)=>{d({type:"SET_EMBED",payload:{type:h,value:P}})};y.useEffect(()=>{let h=null;return(async()=>{if(!(typeof window>"u"))try{const x=(await Promise.resolve().then(()=>require("./quill-vc5vrP24.cjs"))).default,D=await(await Promise.resolve().then(()=>require("./PictureBlot-hHIPKPv0.cjs"))).default();D&&x.register("formats/picture",D,!0),o.current&&(h=new x(o.current,{theme:"snow",modules:{...onA,toolbar:{container:`#${u.toolbarId}`}},formats:inA,placeholder:"Add content"}),n&&n.trim()!==""&&(h==null||h.clipboard.dangerouslyPasteHTML(n,"silent")),h==null||h.root.addEventListener("paste",B=>{var C;const M=B.target,Y=M==null?void 0:M.closest(".ql-picture-caption");if((Y==null?void 0:Y.getAttribute("data-editing"))==="true")return;B.preventDefault(),B.stopPropagation();const j=((C=B.clipboardData)==null?void 0:C.getData("text/plain"))||"";if(j&&h){const E=h.getSelection(!0);h.insertText(E.index,j,"user"),h.setSelection(E.index+j.length)}},!0),h.on("text-change",()=>{if(h){const B=h.root.innerHTML;g(B)}}),h.root.addEventListener("keydown",B=>{var M,Y;if(B.key==="Enter"&&h){const V=h.getSelection();if(V){const j=h.getLength();if(V.index>=j-1){const N=h.root.lastElementChild;if(N!=null&&N.classList.contains("ql-picture-container")){B.preventDefault(),h.insertText(j,`
|
|
427
|
+
`,"user"),l.setSelection(Z+1,0))},100);break}case"htmlembed":l.clipboard.dangerouslyPasteHTML(x.index,M,"user");break;default:l.insertEmbed(x.index,B,M);break}z&&(z.scrollTop=D);const Y=l.root.innerHTML;o(Y),t({type:"RESET_EMBED"})}catch(x){console.error("Failed to handle embed:",x),t({type:"RESET_EMBED"})}},[l,t,o,i,s]);y.useEffect(()=>{f&&g(f)},[f,g]),y.useEffect(()=>{var p;if(!l)return;const m=h=>{const P=h&&h.length>0?l.getText(h.index,h.length):"";e(P.trim())};return(p=l==null?void 0:l.on)==null||p.call(l,"selection-change",m),()=>{var h;(h=l==null?void 0:l.off)==null||h.call(l,"selection-change",m)}},[l]);const v=y.useCallback(()=>{if(!n||n.trim().length===0)return 0;const m=n.replace(/<[^>]*>/g,"").trim();return m.length===0?0:m.split(/\s+/).filter(p=>p.length>0).length},[n]);return c.jsx(l1,{children:c.jsxs("div",{className:"flex order-3 h-full flex-col w-full relative bg-background",children:[c.jsx(c1,{className:"w-full h-10 grow flex flex-col items-center justify-center overflow-auto",children:c.jsx("div",{id:"editorParent",className:"flex w-full h-10 flex-1 items-center justify-center overflow-auto pb-10",children:c.jsx("div",{ref:a,id:"editor",className:"quill-editor text-md flex-1"})})}),c.jsx(AnA,{selectedText:A}),c.jsxs("div",{className:"flex justify-end text-sm text-muted-foreground border p-2 absolute bottom-0 right-0 w-full bg-muted",children:[v()," word count"]})]})})},nv=A=>new Promise(e=>{const t=setTimeout(()=>nv(A),10);typeof A<"u"&&(clearTimeout(t),e(null))}),Co=({src:A=null,innerHTML:e=null,tag:t="head",async:n=!1,id:r=null})=>new Promise((s,a)=>{const o=document.createElement("script");A&&(o.src=A),e&&(o.innerHTML=e),r&&(o.id=r),n&&(o.async=!0),o.defer=!0,o.onload=()=>{s()},o.onerror=a;const i=document.getElementsByTagName(t)[0];i?i.appendChild(o):a(new Error(`Target element "${t}" not found`))}),enA=(A="")=>{const e=document.createElement("div");e.innerHTML=A;const t=e.querySelector("iframe"),n=e.querySelector("span"),r=(n==null?void 0:n.style.width.replace("px",""))??"560",s=(n==null?void 0:n.style.height.replace("px",""))??"600";t.setAttribute("width",r),t.setAttribute("height",s);const a=t.getAttribute("src"),o=new URL(a);return o.searchParams.append("width",r),o.searchParams.append("height",s),t.setAttribute("src",o.toString()),t.outerHTML},tnA=(A="")=>{const e=document.createElement("div");e.innerHTML=A;const t=e.querySelector("iframe"),n="560",r="720",s=t.getAttribute("src"),a=new URL(s);return a.searchParams.append("width",n),a.searchParams.append("height",r),t.setAttribute("src",a.toString()),t.setAttribute("width",n),t.setAttribute("height",r),t.outerHTML},nnA=(A="")=>{var o,i;const e=document.createElement("div");e.innerHTML=A;const t=e.querySelector("iframe"),n=((o=t==null?void 0:t.getAttribute("height"))==null?void 0:o.replace("px",""))??"",r=((i=t==null?void 0:t.getAttribute("width"))==null?void 0:i.replace("px",""))??"",s=(t==null?void 0:t.getAttribute("src"))||"",a=new URL(s);return a.searchParams.append("height",n),a.searchParams.append("width",r),t==null||t.setAttribute("src",a.toString()),t.outerHTML},rnA=async()=>{await Co({src:"https://www.instagram.com/embed.js"}),await Co({src:"https://platform.twitter.com/widgets.js"}),await Co({src:"https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v14.0",tag:"body"}),await Co({src:"//embed.redditmedia.com/widgets/platform.js"})},snA=A=>A.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||A.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/)||A.match(/^.*(youtu.be\/|v\/|e\/|u\/\w+\/|embed\/|v=)([^#&?]*).*/),anA=A=>A.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/),jo=A=>{var n;const e=snA(A);if(e&&((n=e[2])==null?void 0:n.length)===11)return{embed:!0,url:"https://www.youtube.com/embed/"+e[2]+"?showinfo=0"};const t=anA(A);return t?{embed:!0,url:(t[1]||"https")+"://player.vimeo.com/video/"+t[2]+"/"}:{url:A,embed:!1}},onA={history:{delay:500,maxStack:100,userOnly:!0},clipboard:!0},inA=["header","size","bold","italic","underline","align","list","indent","link","strike","image","video","color","blockquote","background","code-block","picture"],E4=Ne({url:iA().url("Invalid URL, enter valid URL")}),lnA=()=>{const{state:{showEmbedVideo:A},dispatch:e,handleAddEmbed:t}=aa(),[n,r]=y.useState(jo("")),s=()=>{e({type:"TOGGLE_EMBED_VIDEO",payload:!1})},a=()=>{t("video",n.url),r(jo("")),s()},o=ug({resolver:Mg(E4),defaultValues:{url:""},reValidateMode:"onChange",mode:"onChange"}),i=async()=>{if(!l)throw new Error("Validation failed");a(),o.reset()},l=o.formState.isValid;return y.useEffect(()=>{const u=o.watch(async(f,{name:d,values:g})=>{d=="url"&&r(jo(g.url??""))});return()=>u.unsubscribe()},[o]),c.jsx(_t,{open:A,onOpenChange:s,children:c.jsxs(Vt,{className:"p-0 overflow-hidden rounded-xl border-0",children:[c.jsx(Ln,{className:"bg-secondary p-4 py-5 items-start",children:c.jsx(Jn,{children:c.jsx("h1",{className:"text-md",children:"Embed Video"})})}),c.jsxs("div",{className:"px-4 space-y-4 flex items-center justify-center flex-wrap",children:[l&&c.jsx("div",{className:"w-full [&_video]:max-h-50 [&_video]:lg:max-h-80",children:c.jsx(st,{label:"Video Preview",type:"video",value:n.url,linkProps:{className:"min-h-70 ![&_video]:lg:max-h-50"},onChange:u=>r(jo(u))})}),c.jsx(eo,{control:o.control,name:"url",render:({field:u,fieldState:f})=>c.jsx(st,{label:"Video Url",onChange:u.onChange,error:f.error,inputProps:{name:u.name,value:u.value,className:"underline",placeholder:"Video URL"}})},"url")]}),c.jsx(Dr,{className:"flex flex-row p-4 pt-0 gap-4 justify-end mt-4",children:c.jsx(he,{className:"rounded",variant:"primary",onClick:i,disabled:!l,children:"Embed"})})]})})};function cnA(A){return UA({attr:{version:"1.1",viewBox:"0 0 20 16"},child:[{tag:"path",attr:{d:"M13 11.5l1.5 1.5 5-5-5-5-1.5 1.5 3.5 3.5z"},child:[]},{tag:"path",attr:{d:"M7 4.5l-1.5-1.5-5 5 5 5 1.5-1.5-3.5-3.5z"},child:[]},{tag:"path",attr:{d:"M10.958 2.352l1.085 0.296-3 11-1.085-0.296 3-11z"},child:[]}]})(A)}const unA={title:"",content:"",showEmbedVideo:!1,showEmbedLink:!1,showEmbedImage:!1,showEmbedPost:!1,embedType:null,embedValue:"",error:!1,isLoading:!1,toolbarId:"",editorContainerId:""},fnA=(A,e)=>{switch(e.type){case"SET_TITLE":return{...A,title:e.payload};case"SET_CONTENT":return{...A,content:e.payload};case"TOGGLE_EMBED_VIDEO":return{...A,showEmbedVideo:e.payload};case"TOGGLE_EMBED_LINK":return{...A,showEmbedLink:e.payload};case"TOGGLE_EMBED_IMAGE":return{...A,showEmbedImage:e.payload};case"TOGGLE_EMBED_POST":return{...A,showEmbedPost:e.payload};case"SET_EMBED":return{...A,embedType:e.payload.type,embedValue:e.payload.value};case"INITIATE_EMBED":return{...A,embedType:e.payload,showEmbedVideo:e.payload==="video",showEmbedLink:e.payload==="link",showEmbedImage:e.payload==="image"};case"RESET_EMBED":return{...A,embedType:"",embedValue:"",showEmbedVideo:!1,showEmbedLink:!1,showEmbedImage:!1};case"SET_ERROR":return{...A,error:e.payload};case"SET_LOADING":return{...A,isLoading:e.payload};default:return A}};function dnA({config:A,url:e}){let t=Dt();const n=qg(e||"",300);re.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT&&(t=na(re.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT));const r=y.useCallback(async()=>{if(A!=null&&A.query){const s=A==null?void 0:A.query,a=A==null?void 0:A.variables;return(await t.query({query:s,variables:{...a||{},url:n}})).data[A.dataKey]}else throw console.error("Invalid Query Configuration"),Error("Invalid Query Configuration")},[t,A,n]);return Lg({queryKey:[(A==null?void 0:A.cacheKey)||(A==null?void 0:A.dataKey),n],queryFn:r,staleTime:300*1e3,gcTime:600*1e3,refetchOnMount:!1,refetchOnWindowFocus:!1})}const gnA=({value:A,label:e,removeCaption:t})=>{const n={text:s=>c.jsx("iframe",{className:"",allowFullScreen:!0,src:jo(s).url}),tiktok:s=>c.jsx(vnA,{url:s,className:"custom__embed tiktok__embed"}),twitter:s=>c.jsx(mnA,{url:s}),instagram:(s,a)=>c.jsx(hnA,{value:s,removeCaption:a}),facebook:(s,a)=>c.jsx(pnA,{value:s,removeCaption:a}),reddit:()=>c.jsx(wnA,{url:A})};y.useEffect(()=>{rnA()},[]);const r=n[e];if(!["text","facebook","tiktok","instagram","twitter","reddit"].includes(e)||!A)return c.jsx("div",{className:"w-fit max-h-[20vh] overflow-auto flex items-center justify-center border border-[#ccc]",children:c.jsx(cnA,{size:30})});if(r)return c.jsx(c.Fragment,{children:r(A,t)})},vnA=({url:A="",className:e=""})=>{const[t,n]=y.useState(null);return y.useEffect(()=>{const r=async a=>{try{const o=await fetch(`https://www.tiktok.com/oembed?url=${encodeURIComponent(a)}`),{html:i=""}=await o.json();return i}catch(o){return console.error({summary:`TikTok Embed Fetch Failed For: ${a}`,message:o==null?void 0:o.message}),null}};(async()=>{if(!A)return;const a=await r(A);n(a)})().then(()=>{Co({src:"https://www.tiktok.com/embed.js"})})},[A]),c.jsx("div",{className:e,dangerouslySetInnerHTML:{__html:t??""}})},mnA=({url:A=""})=>{var a;const[e,t]=y.useState(null),n=y.useRef(null),{twitterEmbedConfig:r}=aa(),s=dnA({config:r,url:A});return y.useEffect(()=>{const o=s.data;if(s.isError||!(o!=null&&o.data)||!n.current)return;const i=JSON.parse(o==null?void 0:o.data);t(i==null?void 0:i.html),(async()=>{await new Promise(u=>setTimeout(u,100)),window.twttr&&window.twttr.widgets&&n.current&&window.twttr.widgets.load(n.current)})()},[s.data,s.isError]),y.useEffect(()=>{if(!window.twttr){const o=document.createElement("script");o.src="https://platform.twitter.com/widgets.js",o.async=!0,document.body.appendChild(o)}},[]),c.jsxs("div",{className:"relative w-full max-w-[550px] min-h-20",children:[s.isLoading&&c.jsx("div",{className:"absolute h-full w-full inset-0 bg-secondary/20 animate-pulse rounded"}),s.isFetched&&c.jsx("div",{className:"w-full",ref:n,dangerouslySetInnerHTML:{__html:e}}),s.isError&&c.jsx("div",{className:"p-4 border border-red-200 bg-red-50 rounded text-red-600",children:(a=s.error)==null?void 0:a.message})]})},pnA=({value:A,removeCaption:e})=>(y.useEffect(()=>{(async()=>{var n,r,s;await nv(window.FB),(s=(r=(n=window.FB)==null?void 0:n.XFBML)==null?void 0:r.parse)==null||s.call(r)})()},[A,e]),c.jsx("div",{className:"fb-post custom__embed","data-href":A,"data-show-text":`${!e}`,children:c.jsx("blockquote",{cite:A,className:"fb-xfbml-parse-ignore"})})),hnA=({value:A,removeCaption:e})=>(y.useEffect(()=>{(async()=>{var n,r,s;await nv(window.instgrm),(s=(r=(n=window.instgrm)==null?void 0:n.Embeds)==null?void 0:r.process)==null||s.call(r)})()},[A,e]),c.jsx("div",{dangerouslySetInnerHTML:{__html:`<blockquote class="instagram-media" ${e?"":"data-instgrm-captioned"} data-instgrm-permalink="${A}?utm_source=ig_embed&utm_campaign=loading" data-instgrm-version="13" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:540px; min-width:326px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:16px;"> <a href="${A}?utm_source=ig_embed&utm_campaign=loading" style=" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%;" target="_blank"> <div style=" display: flex; flex-direction: row; align-items: center;"> <div style="background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 40px; margin-right: 14px; width: 40px;"></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 100px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 60px;"></div></div></div><div style="padding: 19% 0;"></div> <div style="display:block; height:50px; margin:0 auto 12px; width:50px;"><svg width="50px" height="50px" viewBox="0 0 60 60" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g transform="translate(-511.000000, -20.000000)" fill="#000000"><g><path d="M556.869,30.41 C554.814,30.41 553.148,32.076 553.148,34.131 C553.148,36.186 554.814,37.852 556.869,37.852 C558.924,37.852 560.59,36.186 560.59,34.131 C560.59,32.076 558.924,30.41 556.869,30.41 M541,60.657 C535.114,60.657 530.342,55.887 530.342,50 C530.342,44.114 535.114,39.342 541,39.342 C546.887,39.342 551.658,44.114 551.658,50 C551.658,55.887 546.887,60.657 541,60.657 M541,33.886 C532.1,33.886 524.886,41.1 524.886,50 C524.886,58.899 532.1,66.113 541,66.113 C549.9,66.113 557.115,58.899 557.115,50 C557.115,41.1 549.9,33.886 541,33.886 M565.378,62.101 C565.244,65.022 564.756,66.606 564.346,67.663 C563.803,69.06 563.154,70.057 562.106,71.106 C561.058,72.155 560.06,72.803 558.662,73.347 C557.607,73.757 556.021,74.244 553.102,74.378 C549.944,74.521 548.997,74.552 541,74.552 C533.003,74.552 532.056,74.521 528.898,74.378 C525.979,74.244 524.393,73.757 523.338,73.347 C521.94,72.803 520.942,72.155 519.894,71.106 C518.846,70.057 518.197,69.06 517.654,67.663 C517.244,66.606 516.755,65.022 516.623,62.101 C516.479,58.943 516.448,57.996 516.448,50 C516.448,42.003 516.479,41.056 516.623,37.899 C516.755,34.978 517.244,33.391 517.654,32.338 C518.197,30.938 518.846,29.942 519.894,28.894 C520.942,27.846 521.94,27.196 523.338,26.654 C524.393,26.244 525.979,25.756 528.898,25.623 C532.057,25.479 533.004,25.448 541,25.448 C548.997,25.448 549.943,25.479 553.102,25.623 C556.021,25.756 557.607,26.244 558.662,26.654 C560.06,27.196 561.058,27.846 562.106,28.894 C563.154,29.942 563.803,30.938 564.346,32.338 C564.756,33.391 565.244,34.978 565.378,37.899 C565.522,41.056 565.552,42.003 565.552,50 C565.552,57.996 565.522,58.943 565.378,62.101 M570.82,37.631 C570.674,34.438 570.167,32.258 569.425,30.349 C568.659,28.377 567.633,26.702 565.965,25.035 C564.297,23.368 562.623,22.342 560.652,21.575 C558.743,20.834 556.562,20.326 553.369,20.18 C550.169,20.033 549.148,20 541,20 C532.853,20 531.831,20.033 528.631,20.18 C525.438,20.326 523.257,20.834 521.349,21.575 C519.376,22.342 517.703,23.368 516.035,25.035 C514.368,26.702 513.342,28.377 512.574,30.349 C511.834,32.258 511.326,34.438 511.181,37.631 C511.035,40.831 511,41.851 511,50 C511,58.147 511.035,59.17 511.181,62.369 C511.326,65.562 511.834,67.743 512.574,69.651 C513.342,71.625 514.368,73.296 516.035,74.965 C517.703,76.634 519.376,77.658 521.349,78.425 C523.257,79.167 525.438,79.673 528.631,79.82 C531.831,79.965 532.853,80.001 541,80.001 C549.148,80.001 550.169,79.965 553.369,79.82 C556.562,79.673 558.743,79.167 560.652,78.425 C562.623,77.658 564.297,76.634 565.965,74.965 C567.633,73.296 568.659,71.625 569.425,69.651 C570.167,67.743 570.674,65.562 570.82,62.369 C570.966,59.17 571,58.147 571,50 C571,41.851 570.966,40.831 570.82,37.631"></path></g></g></g></svg></div><div style="padding-top: 8px;"> <div style=" color:#3897f0; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:550; line-height:18px;"> View this post on Instagram</div></div><div style="padding: 12.5% 0;"></div> <div style="display: flex; flex-direction: row; margin-bottom: 14px; align-items: center;"><div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(0px) translateY(7px);"></div> <div style="background-color: #F4F4F4; height: 12.5px; transform: rotate(-45deg) translateX(3px) translateY(1px); width: 12.5px; flex-grow: 0; margin-right: 14px; margin-left: 2px;"></div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(9px) translateY(-18px);"></div></div><div style="margin-left: 8px;"> <div style=" background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 20px; width: 20px;"></div> <div style=" width: 0; height: 0; border-top: 2px solid transparent; border-left: 6px solid #f4f4f4; border-bottom: 2px solid transparent; transform: translateX(16px) translateY(-4px) rotate(30deg)"></div></div><div style="margin-left: auto;"> <div style=" width: 0px; border-top: 8px solid #F4F4F4; border-right: 8px solid transparent; transform: translateY(16px);"></div> <div style=" background-color: #F4F4F4; flex-grow: 0; height: 12px; width: 16px; transform: translateY(-4px);"></div> <div style=" width: 0; height: 0; border-top: 8px solid #F4F4F4; border-left: 8px solid transparent; transform: translateY(-4px) translateX(8px);"></div></div></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center; margin-bottom: 24px;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 224px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 144px;"></div></div></a><p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;"><a href="${A}?utm_source=ig_embed&utm_campaign=loading" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;" target="_blank">A post shared by </a></p></div></blockquote>`}})),wnA=({url:A=""})=>{const e=y.useRef(null);return y.useEffect(()=>{(async()=>{!A||!e.current||(window.rembeddit||(await Co({src:"//embed.redditmedia.com/widgets/platform.js"}),await nv(window.rembeddit)),setTimeout(()=>{if(window.rembeddit&&e.current)try{window.rembeddit.createEmbeds()}catch(n){console.warn("Reddit embed processing failed:",n)}},500))})()},[A]),c.jsx("div",{className:"w-full max-w-[600px] p-2 relative",children:c.jsx("div",{className:"custom__embed p-4",ref:e,children:c.jsx("blockquote",{className:"reddit-embed-bq","data-card-created":Date.now(),children:c.jsx("a",{href:A,children:A})})})})},Zm=[{label:"Text",value:"text"},{label:"Instagram",value:"instagram"},{label:"Facebook",value:"facebook"},{label:"X",value:"twitter"},{label:"Reddit",value:"reddit"},{label:"TikTok",value:"tiktok"}],PnA=()=>{var v;const{state:{showEmbedLink:A},dispatch:e,handleAddEmbed:t}=aa(),[n,r]=y.useState(((v=Zm[0])==null?void 0:v.value)||"text"),[s,a]=y.useState(""),o=y.useRef(null),i=ug({resolver:Mg(E4),defaultValues:{url:""},reValidateMode:"onChange",mode:"onChange"}),l=i.formState.isValid,u=m=>{t("htmlembed",m),d(),a("")},f=async()=>{var m,p,h,P,b;try{if(!l)throw new Error("Validation failed");switch(n){case"text":u((m=o.current)==null?void 0:m.innerHTML);break;case"tiktok":case"twitter":u(tnA((p=o.current)==null?void 0:p.innerHTML));break;case"facebook":u(enA((h=o.current)==null?void 0:h.innerHTML));break;case"instagram":case"reddit":u(nnA((P=o.current)==null?void 0:P.innerHTML));break;default:break}r(((b=Zm[0])==null?void 0:b.value)||"text"),a("")}catch(x){console.log(x)}},d=()=>{e({type:"TOGGLE_EMBED_LINK",payload:!1})},g=m=>{const p=m;p!=null&&p.value&&r(p.value)};return y.useEffect(()=>{const m=i.watch((p,{name:h,values:P})=>{h=="url"&&a(P.url??"")});return()=>m.unsubscribe()},[i]),c.jsx(_t,{open:A,onOpenChange:d,children:c.jsxs(Vt,{className:"sm:max-w-[600px] p-0 overflow-hidden rounded border-0",children:[c.jsx(Ln,{className:"bg-secondary p-4 py-5 items-start",children:c.jsx(Jn,{children:c.jsx("h1",{className:"text-md",children:"Embed Link"})})}),c.jsx("div",{className:"mx-auto mb-5 w-fit max-h-90 overflow-auto",id:"postembed",ref:o,children:l&&c.jsx(gnA,{label:n,removeCaption:!1,value:s})}),c.jsxs("div",{className:"px-4 space-y-4",children:[c.jsx(st,{label:"Social Media Platform",type:"select",value:{value:n,label:n},selectProps:{options:Zm,dataKey:"social-media-platforms"},onChange:g}),c.jsx(eo,{control:i.control,name:"url",render:({field:m,fieldState:p})=>c.jsx(fr,{className:"flex-1",children:c.jsx(to,{className:"w-full",children:c.jsx(st,{label:"URL",inputProps:{name:m.name,value:m.value,className:"underline",placeholder:"URL"},error:p.error,onChange:m.onChange})})})},"url")]}),c.jsxs(Dr,{className:"flex flex-row p-4 pt-0 gap-4 justify-end mt-4",children:[c.jsx(he,{className:"rounded",variant:"primary",onClick:f,disabled:!l,children:"Embed"}),c.jsx(he,{variant:"outline",className:"rounded",onClick:d,children:"Cancel"})]})]})})},H4=({open:A=!0,onSave:e,handleToggleOpen:t,className:n,selectedPosts:r,columns:s,queryConfig:a,defaultState:o,gridCard:i,postType:l,filterFields:u,postBaseURL:f,apolloUri:d,...g})=>{const v=m=>{e==null||e(m),t==null||t(!1)};return c.jsx(_t,{open:A,onOpenChange:t,children:c.jsx(Vt,{className:S("sm:max-w-[80%] md:max-w-[80%] h-[90%] shadow-lg p-0 overflow-hidden",n),children:c.jsx(Cr,{columns:s,selectedPosts:r,queryConfig:a,defaultState:o,gridCard:i,postType:l,postBaseURL:f,filterFields:u,isSelect:!0,rootClassName:"h-full",gridColumnStyle:"repeat(auto-fit, minmax(210px, 1fr))",onSave:v,apolloUri:d,...g})})})},ynA=({className:A})=>{const{state:e,imageGalleryConfig:t,dispatch:n,handleAddEmbed:r,asChild:s,blogPostsConfig:a}=aa(),{showEmbedImage:o,showEmbedPost:i}=e,l=d=>{n({type:"TOGGLE_EMBED_IMAGE",payload:d})},u=d=>{r("image",d),l(!1)},f=d=>{d[0]&&r("post",d[0]),n({type:"TOGGLE_EMBED_POST",payload:!1})};return c.jsxs(c.Fragment,{children:[!s&&c.jsxs("div",{className:S("w-full h-full flex-1 flex flex-col no-scrollbar gap-2 border-1",A),"data-testid":"editor",children:[c.jsx(ty,{}),c.jsx(ny,{})]}),s&&c.jsxs(c.Fragment,{children:[c.jsx(ty,{}),c.jsx(ny,{})]}),c.jsx(lnA,{}),c.jsx(PnA,{}),t&&c.jsx(C4,{config:{...t,viewOnly:!0},open:o,onChange:d=>d&&u(d),handleToggleOpen:l}),a&&c.jsx(H4,{...a,open:i,selectedPosts:[],onSave:f,handleToggleOpen:d=>n({type:"TOGGLE_EMBED_POST",payload:d})})]})},bnA=({children:A,onChange:e,imageGalleryConfig:t,content:n,asChild:r,blogPostsConfig:s,twitterEmbedConfig:a})=>{const o=y.useRef(null),[i,l]=y.useState(null),u=y.useMemo(()=>({toolbarId:`toolbar-${Date.now()}`,editorContainerId:`editorParent-${Date.now()}`}),[]),[f,d]=y.useReducer(fnA,{...unA,toolbarId:u.toolbarId,editorContainerId:u.editorContainerId,content:n||"",quillRef:o}),g=y.useCallback(h=>{const P=h.replace(/<div class="ql-picture-caption"([^>]*?)>Click to edit caption\.\.\.<\/div>/g,'<div class="ql-picture-caption"$1></div>');d({type:"SET_CONTENT",payload:P}),e==null||e(P)},[e]),v=h=>{setTimeout(()=>{d({type:"INITIATE_EMBED",payload:h})},100)},m=(h,P)=>{d({type:"SET_EMBED",payload:{type:h,value:P}})};y.useEffect(()=>{let h=null;return(async()=>{if(!(typeof window>"u"))try{const x=(await Promise.resolve().then(()=>require("./quill-D06vxijP.cjs"))).default,D=await(await Promise.resolve().then(()=>require("./PictureBlot-C_waorkz.cjs"))).default();D&&x.register("formats/picture",D,!0),o.current&&(h=new x(o.current,{theme:"snow",modules:{...onA,toolbar:{container:`#${u.toolbarId}`}},formats:inA,placeholder:"Add content"}),n&&n.trim()!==""&&(h==null||h.clipboard.dangerouslyPasteHTML(n,"silent")),h==null||h.root.addEventListener("paste",B=>{var C;const M=B.target,Y=M==null?void 0:M.closest(".ql-picture-caption");if((Y==null?void 0:Y.getAttribute("data-editing"))==="true")return;B.preventDefault(),B.stopPropagation();const j=((C=B.clipboardData)==null?void 0:C.getData("text/plain"))||"";if(j&&h){const E=h.getSelection(!0);h.insertText(E.index,j,"user"),h.setSelection(E.index+j.length)}},!0),h.on("text-change",()=>{if(h){const B=h.root.innerHTML;g(B)}}),h.root.addEventListener("keydown",B=>{var M,Y;if(B.key==="Enter"&&h){const V=h.getSelection();if(V){const j=h.getLength();if(V.index>=j-1){const N=h.root.lastElementChild;if(N!=null&&N.classList.contains("ql-picture-container")){B.preventDefault(),h.insertText(j,`
|
|
428
428
|
`,"user"),h.setSelection(j+1,0);return}}const[C]=h.getLeaf(V.index);if((Y=(M=C==null?void 0:C.domNode)==null?void 0:M.closest)==null?void 0:Y.call(M,".ql-picture-container")){B.preventDefault();const N=V.index;h.insertText(N+1,`
|
|
429
429
|
`,"user"),h.setSelection(N+2,0)}}}}),h.on("text-change",(B,M,Y)=>{if(Y==="user"){if(document.querySelector('.ql-picture-caption[data-editing="true"]'))return;setTimeout(()=>{if(!h)return;const j=h.root.innerHTML,C=/<p[^>]*class="[^"]*ql-align-[^"]*"[^>]*><br><\/p>/g,E=j.replace(C,"<p><br></p>");if(/^<p[^>]*class="[^"]*ql-align-[^"]*"[^>]*><br><\/p>$/.test(j.trim()))h.root.innerHTML="<p><br></p>",h.setSelection(0,0);else if(E!==j){h.root.innerHTML=E;const q=h.getSelection();q&&h.setSelection(q.index,q.length)}},100)}}),l(h))}catch(b){console.error("Failed to load Quill editor:",b)}})(),()=>{h&&h.off("text-change"),l(null)}},[o]),y.useEffect(()=>{i&&n&&!f.content&&(i.clipboard.dangerouslyPasteHTML(n,"silent"),d({type:"SET_CONTENT",payload:n}))},[n,i]);const p={state:f,dispatch:d,handleContentChange:g,handleInitiateEmbed:v,handleAddEmbed:m,imageGalleryConfig:t,blogPostsConfig:s,onChange:e,asChild:r,quillObj:i,setQuillObj:l,twitterEmbedConfig:a};return c.jsx(T4.Provider,{value:p,children:A})},xnA=({className:A,onChange:e,initialValue:t,content:n,imageGalleryConfig:r,blogPostsConfig:s,asChild:a,twitterEmbedConfig:o})=>c.jsx(bnA,{content:n||t,onChange:e,imageGalleryConfig:r,asChild:a,blogPostsConfig:s,twitterEmbedConfig:o,children:c.jsx(ynA,{className:A})}),znA=()=>{const{state:A,dispatch:e,onChange:t,linkProps:n}=qn(),{value:r}=A,[s,a]=w.useState(!0),[o,i]=w.useState(0),[l,u]=w.useState(0),[f,d]=w.useState(0),[g,v]=w.useState(""),[m,p]=w.useState(0),[h,P]=w.useState(!1),[b,x]=w.useState({x:0,y:0}),z=w.useRef(null),D=w.useRef(null),B=w.useRef(null),M=w.useRef(null),Y=jo(r),V=()=>{e({type:"SET_VALUE",payload:""}),t&&t("")},j=w.useCallback(()=>{z.current&&(s?z.current.play():z.current.pause(),a(!s))},[s]),C=w.useCallback(()=>{if(z.current){const T=z.current.currentTime,Z=z.current.duration;i(T),d(Z>0?T/Z*100:0),D.current&&(D.current.currentTime=T)}},[]),E=w.useCallback(()=>{z.current&&(u(z.current.duration),G(Y.url))},[Y.url]),N=w.useCallback(T=>{if(B.current&&z.current&&l>0){const Z=B.current.getBoundingClientRect(),O=(T.clientX-Z.left)/Z.width*l;if(p(O),x({x:T.clientX-Z.left,y:Z.top-10}),P(!0),M.current&&z.current){const k=M.current,X=k.getContext("2d");if(X){const J=document.createElement("video");J.src=Y.url,J.currentTime=O,J.muted=!0,J.addEventListener("seeked",()=>{X.drawImage(J,0,0,k.width,k.height)},{once:!0})}}}},[l,Y]),q=w.useCallback(()=>{P(!1)},[]),I=w.useCallback(T=>{if(B.current&&z.current&&l>0){const Z=B.current.getBoundingClientRect(),O=(T.clientX-Z.left)/Z.width*l;z.current.currentTime=O,i(O),d(O/l*100)}},[l]),G=w.useCallback(T=>{try{const Z=T.split("/"),O=Z[Z.length-1];if(O&&O.includes(".")){const J=O.split(".").slice(0,-1).join("."),eA=decodeURIComponent(J).replace(/[_-]/g," ").replace(/\s+/g," ").trim();if(eA){v(eA);return}}const k=new URL(T).pathname.split("/").filter(Boolean);if(k.length>0){const J=k[k.length-1],F=decodeURIComponent(J).replace(/[_-]/g," ").replace(/\s+/g," ").trim();if(F&&!F.includes(".")){v(F);return}}const X=new URL(T).hostname;X.includes("youtube")||X.includes("youtu.be")?v("YouTube Video"):X.includes("vimeo")?v("Vimeo Video"):X.includes("twitch")?v("Twitch Video"):v("Video")}catch(Z){console.log(Z),v("Video")}},[]);w.useEffect(()=>{const T=z.current,Z=D.current;return T&&(T.src=Y.url,T.addEventListener("timeupdate",C),T.addEventListener("loadedmetadata",E),T.addEventListener("pause",()=>a(!0)),T.addEventListener("play",()=>a(!1))),Z&&(Z.src=Y.url,Z.muted=!0),()=>{T&&(T.removeEventListener("timeupdate",C),T.removeEventListener("loadedmetadata",E),T.removeEventListener("pause",()=>a(!0)),T.removeEventListener("play",()=>a(!1)))}},[r,C,E]),w.useEffect(()=>{setTimeout(()=>{s||j()},2e3)},[r]);const H=T=>{const Z=Math.floor(T/60),O=Math.floor(T%60);return`${Z}:${O.toString().padStart(2,"0")}`};return c.jsxs("div",{className:"flex-1 overflow-hidden h-full flex flex-col items-center justify-center gap-2 bg-background",children:[r&&!(Y!=null&&Y.embed)&&c.jsxs("div",{className:"group relative w-full h-full flex-1 flex items-center justify-center overflow-hidden ",children:[c.jsx("video",{className:"w-full h-100 flex-1",src:Y.url,ref:z,children:"Your browser does not support the video tag."}),c.jsxs("div",{className:"hidden group-hover:flex absolute w-full h-full flex-col justify-between p-4 bg-gradient-to-b from-transparent via-transparent via-60% to-black/50 ",children:[c.jsxs("div",{className:"flex-1 flex gap-1 justify-end",children:[c.jsx(MA,{variant:"ghost",size:"icon",className:"bg-background rounded-md shadow-[0px_4.29px_12.86px_0px_#00000012] h-7 w-7",onClick:j,children:s?c.jsx(WZ,{}):c.jsx(LZ,{})}),c.jsx(MA,{variant:"ghost",size:"icon",onClick:V,className:"bg-background shadow-[0px_4.29px_12.86px_0px_#00000012] rounded-md h-7 w-7",children:c.jsx(tv,{className:"text-destructive",size:"small"})})]}),c.jsxs("div",{className:"h-fit flex flex-col gap-2",children:[c.jsx("p",{className:"text-background capitalize text-xl",children:g||"Loading..."}),c.jsxs("div",{className:"flex w-full justify-between items-center",children:[c.jsx("p",{className:"text-background",children:"Video Player"}),c.jsxs("span",{className:"text-sm text-background",children:[H(o)," / ",H(l)]})]}),c.jsx("div",{className:"relative",children:c.jsx("div",{className:"flex items-center gap-2",children:c.jsxs("div",{className:"flex-1 relative",children:[c.jsxs("div",{ref:B,className:"h-[2px] bg-background/50 rounded-full cursor-pointer relative overflow-hidden",onMouseMove:N,onMouseLeave:q,onClick:I,children:[c.jsx("div",{className:"h-full bg-background rounded-full transition-all duration-[1000]",style:{width:`${f}%`}}),h&&c.jsx("div",{className:"absolute top-0 w-0.5 h-full bg-white/80 pointer-events-none",style:{left:`${m/l*100}%`,transform:"translateX(-50%)"}})]}),h&&c.jsx("div",{className:"absolute z-50 pointer-events-none",style:{left:`${b.x}px`,bottom:"100%",transform:"translateX(-50%)",marginBottom:"4px"},children:c.jsx("canvas",{ref:M,width:120,height:68,className:"rounded border border-background mb-1"})})]})})})]})]})]}),r&&(Y==null?void 0:Y.embed)&&c.jsx("iframe",{className:S("w-full h-full",n==null?void 0:n.className),allowFullScreen:!0,src:Y.url}),!r&&c.jsxs("div",{"data-testid":"no-video",className:"flex flex-col w-full h-80 items-center justify-center gap-2 text-muted-foreground",children:[c.jsx(IC,{className:"text-xl"}),c.jsx("p",{className:"text-xs text-center",children:"No video to display"})]})]})},DnA=()=>{const{state:A,dispatch:e,blogPostsConfig:t,label:n}=qn(),{showPostsModal:r,value:s}=A,a=()=>{e({type:"TOGGLE_POSTS_MODAL"})},o=u=>{const f=l.filter(d=>d.uuid!==u.uuid);e({type:"SET_VALUE",payload:f})},i=u=>{e({type:"SET_VALUE",payload:u})};if(!t)return null;const l=s;return c.jsxs("div",{className:S("flex-1 bg-background space-y-2"),children:[c.jsxs("div",{className:"w-full flex items-center justify-between gap-2",children:[c.jsx(he,{size:"icon",variant:"primary",className:"bg-muted rounded-full",onClick:a,children:c.jsx(Ao,{})}),c.jsx("div",{className:"flex-1 text-sm ",children:n}),!!l.length&&c.jsxs("p",{className:"text-sm p-2 bg-muted text-muted-foreground rounded",children:[l.length," selected articles"]})]}),c.jsx("div",{className:"space-y-1 max-h-60 overflow-y-auto",children:l.map(u=>{const f=u.featured_image?JSON.parse(u.featured_image):null;return c.jsxs("div",{className:"gap-2 flex flex-row items-center justify-between w-full waz_shadow py-2","data-testid":"post-row",children:[f!=null&&f.src?c.jsx("img",{src:mc({url:f==null?void 0:f.src,width:80,height:64}).url,alt:"Post Image",className:"w-[3rem] h-10 rounded-sm object-cover flex-shrink-0"}):c.jsx("div",{className:"w-[3rem] h-10 bg-muted rounded-sm flex items-center justify-center","data-testid":"post-no-image",children:c.jsxs("div",{className:"flex flex-col items-center text-muted-foreground",children:[c.jsx(EZ,{className:"h-3 w-3"}),c.jsx("span",{className:"text-[9px]",children:"No image"})]})}),c.jsx("a",{className:" flex-1 hover:underline cursor-pointer text-sm line-clamp-1",href:u.slug,target:"_blank",rel:"noopener noreferrer",children:Wr(u.title)}),c.jsx(he,{size:"icon",variant:"ghost",onClick:()=>o(u),"data-testid":"remove-post",children:c.jsx(Ts,{})})]},u.uuid)})}),c.jsx(H4,{...t,selectedPosts:l,open:r,onSave:i,handleToggleOpen:u=>e({type:"TOGGLE_POSTS_MODAL",payload:u})})]})};function BnA(A){return UA({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"},child:[]}]})(A)}function MnA(A){return UA({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"},child:[]}]})(A)}function B0(A){return UA({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"},child:[]}]})(A)}const CnA=()=>{const{state:{value:A,showEditLinkModal:e},dispatch:t,onChange:n,label:r,linkProps:s,error:a}=qn(),[o,i]=y.useState(A),l=()=>{t({type:"SET_VALUE",payload:o}),n&&n(o),u()},u=()=>{t({type:"TOGGLE_EDIT_LINK_MODAL"})};return y.useEffect(()=>{i(A)},[A]),c.jsx(c.Fragment,{children:c.jsx(_t,{open:e,onOpenChange:u,children:c.jsxs(Vt,{className:"p-0 border-none overflow-hidden rounded-xl",children:[c.jsx(Ln,{className:"bg-secondary p-4 py-5 items-start",children:c.jsx(Jn,{children:c.jsxs("h1",{className:"text-md capitalize",children:["Edit ",r]})})}),c.jsx("div",{className:"p-4 py-2",children:c.jsx(st,{label:c.jsxs("span",{className:"flex gap-2 items-center text-sm ",children:[r,a&&c.jsxs("span",{className:"flex items-center justify-center gap-1",children:[c.jsx(B0,{className:"text-destructive text-xl"}),c.jsx("span",{className:" capitalize text-xs text-muted-foreground",children:a==null?void 0:a.message})]})]}),value:o,type:"textarea",onChange:f=>i(f.toString()),textareaProps:{...s,className:S("underline text-[#101828] text-sm",s==null?void 0:s.className)}})}),c.jsx(Dr,{className:"flex flex-row p-4 pt-0 gap-4 justify-end mt-4",children:c.jsx(he,{className:"rounded",variant:"primary",onClick:l,disabled:o.toString().includes(" "),children:"Save"})})]})})})},jnA=()=>{const{state:{value:A},dispatch:e,optionsQuery:{data:t,isLoading:n,fetchNextPage:r,hasNextPage:s,isFetchingNextPage:a},selectProps:o}=qn(),i=w.useMemo(()=>(t==null?void 0:t.pages.flatMap(x=>x==null?void 0:x.data).filter(x=>x!=null))??[],[t]),[l,u]=w.useState(""),[f,d]=w.useState(!1),{ref:g,inView:v}=_g(),m=w.useRef(null),p=x=>{d(!0),u(x),e({type:"SET_OPTIONS_SEARCH_VALUE",payload:x})},h=x=>{let z=[];A&&Array.isArray(A)&&A.every(M=>typeof M=="object"&&"label"in M&&"value"in M)&&(z=A);const D=z.find(M=>M.value===x.value);let B;(o==null?void 0:o.multiple)===!1?B=D?[]:[x]:B=D?z.filter(M=>M.value!==x.value):[...z,x],e({type:"SET_VALUE",payload:B}),u("")},P=w.useMemo(()=>A?Array.isArray(A)?A.every(z=>typeof z=="object"&&"label"in z&&"value"in z)?A:[]:[]:[],[A]),b=x=>{var D;const z=(D=m.current)==null?void 0:D.value;x.key=="Enter"&&(x.preventDefault(),m.current&&z&&(o!=null&&o.createNewOption)&&(h({label:z,value:z}),m.current.value=""))};return w.useEffect(()=>{v&&s&&!a&&r()},[v,s,a,r]),c.jsxs(Zi,{open:f&&(!!(o!=null&&o.queryConfig)||!!(o!=null&&o.options)),onOpenChange:d,modal:!1,children:[c.jsx(Vi,{asChild:!0,onClick:x=>x.preventDefault(),children:c.jsxs("div",{className:S("w-full flex flex-wrap gap-2 p-2 items-center bg-background ",o==null?void 0:o.className),children:[P.map((x,z)=>c.jsxs(at,{className:"flex h-fit gap-2 p-1 px-2 items-center bg-[#86FC6540] text-current capitalize",children:[x.label||x.value,c.jsx(Ts,{onClick:()=>h(x),className:"h-4 w-4 p-1 bg-[#65FB3A] rounded-full"})]},x.value||x.label||z)),c.jsx(hn,{ref:m,placeholder:o==null?void 0:o.placeholder,className:"p-0 min-w-30 flex-1 border-none shadow-none bg-transparent hover:bg-transparent focus:bg-transparent focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none focus-visible:outline-none",value:l,onChange:x=>p(x.target.value),onKeyDown:b,onFocus:()=>d(!0)})]})}),c.jsx(no,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",onOpenAutoFocus:x=>x.preventDefault(),children:c.jsx(Lc,{shouldFilter:!1,children:c.jsxs(sg,{className:"text-sm",children:[c.jsx(ag,{className:"flex items-center justify-center p-3 ",children:n?c.jsx(si,{className:"h-6 w-6 animate-spin"}):"No Options found."}),c.jsxs(og,{children:[i.map(x=>x&&c.jsxs(ig,{value:x.value,onSelect:()=>h(x),className:"capitalize",children:[x.label,c.jsx(j4,{className:S("ml-auto",P.some(z=>x.value===z.value)?"opacity-100":"opacity-0")})]},x.value)),s&&c.jsx("div",{ref:g,className:"w-full flex justify-center",children:a?c.jsx(PAA,{className:"h-6 w-6 animate-spin"}):c.jsx(MA,{variant:"ghost",onClick:()=>r(),children:"Load more"})})]})]})})})]})};function OnA(){for(var A=arguments.length,e=new Array(A),t=0;t<A;t++)e[t]=arguments[t];return y.useMemo(()=>n=>{e.forEach(r=>r(n))},e)}const rv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ri(A){const e=Object.prototype.toString.call(A);return e==="[object Window]"||e==="[object global]"}function M0(A){return"nodeType"in A}function An(A){var e,t;return A?Ri(A)?A:M0(A)&&(e=(t=A.ownerDocument)==null?void 0:t.defaultView)!=null?e:window:window}function C0(A){const{Document:e}=An(A);return A instanceof e}function fu(A){return Ri(A)?!1:A instanceof An(A).HTMLElement}function N4(A){return A instanceof An(A).SVGElement}function Wi(A){return A?Ri(A)?A.document:M0(A)?C0(A)?A:fu(A)||N4(A)?A.ownerDocument:document:document:document}const yr=rv?y.useLayoutEffect:y.useEffect;function j0(A){const e=y.useRef(A);return yr(()=>{e.current=A}),y.useCallback(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.current==null?void 0:e.current(...n)},[])}function TnA(){const A=y.useRef(null),e=y.useCallback((n,r)=>{A.current=setInterval(n,r)},[]),t=y.useCallback(()=>{A.current!==null&&(clearInterval(A.current),A.current=null)},[]);return[e,t]}function Pc(A,e){e===void 0&&(e=[A]);const t=y.useRef(A);return yr(()=>{t.current!==A&&(t.current=A)},e),t}function du(A,e){const t=y.useRef();return y.useMemo(()=>{const n=A(t.current);return t.current=n,n},[...e])}function Pd(A){const e=j0(A),t=y.useRef(null),n=y.useCallback(r=>{r!==t.current&&(e==null||e(r,t.current)),t.current=r},[]);return[t,n]}function I2(A){const e=y.useRef();return y.useEffect(()=>{e.current=A},[A]),e.current}let Vm={};function gu(A,e){return y.useMemo(()=>{if(e)return e;const t=Vm[A]==null?0:Vm[A]+1;return Vm[A]=t,A+"-"+t},[A,e])}function k4(A){return function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((s,a)=>{const o=Object.entries(a);for(const[i,l]of o){const u=s[i];u!=null&&(s[i]=u+A*l)}return s},{...e})}}const Go=k4(1),yc=k4(-1);function EnA(A){return"clientX"in A&&"clientY"in A}function O0(A){if(!A)return!1;const{KeyboardEvent:e}=An(A.target);return e&&A instanceof e}function HnA(A){if(!A)return!1;const{TouchEvent:e}=An(A.target);return e&&A instanceof e}function Q2(A){if(HnA(A)){if(A.touches&&A.touches.length){const{clientX:e,clientY:t}=A.touches[0];return{x:e,y:t}}else if(A.changedTouches&&A.changedTouches.length){const{clientX:e,clientY:t}=A.changedTouches[0];return{x:e,y:t}}}return EnA(A)?{x:A.clientX,y:A.clientY}:null}const Gs=Object.freeze({Translate:{toString(A){if(!A)return;const{x:e,y:t}=A;return"translate3d("+(e?Math.round(e):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(A){if(!A)return;const{scaleX:e,scaleY:t}=A;return"scaleX("+e+") scaleY("+t+")"}},Transform:{toString(A){if(A)return[Gs.Translate.toString(A),Gs.Scale.toString(A)].join(" ")}},Transition:{toString(A){let{property:e,duration:t,easing:n}=A;return e+" "+t+"ms "+n}}}),ry="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function NnA(A){return A.matches(ry)?A:A.querySelector(ry)}const knA={display:"none"};function ZnA(A){let{id:e,value:t}=A;return y.createElement("div",{id:e,style:knA},t)}function VnA(A){let{id:e,announcement:t,ariaLiveType:n="assertive"}=A;const r={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return y.createElement("div",{id:e,style:r,role:"status","aria-live":n,"aria-atomic":!0},t)}function SnA(){const[A,e]=y.useState("");return{announce:y.useCallback(n=>{n!=null&&e(n)},[]),announcement:A}}const Z4=y.createContext(null);function XnA(A){const e=y.useContext(Z4);y.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(A)},[A,e])}function YnA(){const[A]=y.useState(()=>new Set),e=y.useCallback(n=>(A.add(n),()=>A.delete(n)),[A]);return[y.useCallback(n=>{let{type:r,event:s}=n;A.forEach(a=>{var o;return(o=a[r])==null?void 0:o.call(a,s)})},[A]),e]}const GnA={draggable:`
|
|
430
430
|
To pick up a draggable item, press the space bar.
|
|
@@ -432,7 +432,7 @@ Valid keys: `+JSON.stringify(Object.keys(Z),null," "));var U=_(R,$,J,F,eA+"."+$
|
|
|
432
432
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
433
433
|
`},InA={onDragStart(A){let{active:e}=A;return"Picked up draggable item "+e.id+"."},onDragOver(A){let{active:e,over:t}=A;return t?"Draggable item "+e.id+" was moved over droppable area "+t.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(A){let{active:e,over:t}=A;return t?"Draggable item "+e.id+" was dropped over droppable area "+t.id:"Draggable item "+e.id+" was dropped."},onDragCancel(A){let{active:e}=A;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function QnA(A){let{announcements:e=InA,container:t,hiddenTextDescribedById:n,screenReaderInstructions:r=GnA}=A;const{announce:s,announcement:a}=SnA(),o=gu("DndLiveRegion"),[i,l]=y.useState(!1);if(y.useEffect(()=>{l(!0)},[]),XnA(y.useMemo(()=>({onDragStart(f){let{active:d}=f;s(e.onDragStart({active:d}))},onDragMove(f){let{active:d,over:g}=f;e.onDragMove&&s(e.onDragMove({active:d,over:g}))},onDragOver(f){let{active:d,over:g}=f;s(e.onDragOver({active:d,over:g}))},onDragEnd(f){let{active:d,over:g}=f;s(e.onDragEnd({active:d,over:g}))},onDragCancel(f){let{active:d,over:g}=f;s(e.onDragCancel({active:d,over:g}))}}),[s,e])),!i)return null;const u=y.createElement(y.Fragment,null,y.createElement(ZnA,{id:n,value:r.draggable}),y.createElement(VnA,{id:o,announcement:a}));return t?ys.createPortal(u,t):u}var nt;(function(A){A.DragStart="dragStart",A.DragMove="dragMove",A.DragEnd="dragEnd",A.DragCancel="dragCancel",A.DragOver="dragOver",A.RegisterDroppable="registerDroppable",A.SetDroppableDisabled="setDroppableDisabled",A.UnregisterDroppable="unregisterDroppable"})(nt||(nt={}));function yd(){}function Is(A,e){return y.useMemo(()=>({sensor:A,options:e??{}}),[A,e])}function sv(){for(var A=arguments.length,e=new Array(A),t=0;t<A;t++)e[t]=arguments[t];return y.useMemo(()=>[...e].filter(n=>n!=null),[...e])}const In=Object.freeze({x:0,y:0});function V4(A,e){return Math.sqrt(Math.pow(A.x-e.x,2)+Math.pow(A.y-e.y,2))}function S4(A,e){let{data:{value:t}}=A,{data:{value:n}}=e;return t-n}function LnA(A,e){let{data:{value:t}}=A,{data:{value:n}}=e;return n-t}function sy(A){let{left:e,top:t,height:n,width:r}=A;return[{x:e,y:t},{x:e+r,y:t},{x:e,y:t+n},{x:e+r,y:t+n}]}function X4(A,e){if(!A||A.length===0)return null;const[t]=A;return t[e]}function ay(A,e,t){return e===void 0&&(e=A.left),t===void 0&&(t=A.top),{x:e+A.width*.5,y:t+A.height*.5}}const av=A=>{let{collisionRect:e,droppableRects:t,droppableContainers:n}=A;const r=ay(e,e.left,e.top),s=[];for(const a of n){const{id:o}=a,i=t.get(o);if(i){const l=V4(ay(i),r);s.push({id:o,data:{droppableContainer:a,value:l}})}}return s.sort(S4)},JnA=A=>{let{collisionRect:e,droppableRects:t,droppableContainers:n}=A;const r=sy(e),s=[];for(const a of n){const{id:o}=a,i=t.get(o);if(i){const l=sy(i),u=r.reduce((d,g,v)=>d+V4(l[v],g),0),f=Number((u/4).toFixed(4));s.push({id:o,data:{droppableContainer:a,value:f}})}}return s.sort(S4)};function qnA(A,e){const t=Math.max(e.top,A.top),n=Math.max(e.left,A.left),r=Math.min(e.left+e.width,A.left+A.width),s=Math.min(e.top+e.height,A.top+A.height),a=r-n,o=s-t;if(n<r&&t<s){const i=e.width*e.height,l=A.width*A.height,u=a*o,f=u/(i+l-u);return Number(f.toFixed(4))}return 0}const RnA=A=>{let{collisionRect:e,droppableRects:t,droppableContainers:n}=A;const r=[];for(const s of n){const{id:a}=s,o=t.get(a);if(o){const i=qnA(o,e);i>0&&r.push({id:a,data:{droppableContainer:s,value:i}})}}return r.sort(LnA)};function WnA(A,e,t){return{...A,scaleX:e&&t?e.width/t.width:1,scaleY:e&&t?e.height/t.height:1}}function Y4(A,e){return A&&e?{x:A.left-e.left,y:A.top-e.top}:In}function FnA(A){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((a,o)=>({...a,top:a.top+A*o.y,bottom:a.bottom+A*o.y,left:a.left+A*o.x,right:a.right+A*o.x}),{...t})}}const KnA=FnA(1);function UnA(A){if(A.startsWith("matrix3d(")){const e=A.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(A.startsWith("matrix(")){const e=A.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function _nA(A,e,t){const n=UnA(e);if(!n)return A;const{scaleX:r,scaleY:s,x:a,y:o}=n,i=A.left-a-(1-r)*parseFloat(t),l=A.top-o-(1-s)*parseFloat(t.slice(t.indexOf(" ")+1)),u=r?A.width/r:A.width,f=s?A.height/s:A.height;return{width:u,height:f,top:l,right:i+u,bottom:l+f,left:i}}const $nA={ignoreTransform:!1};function Fi(A,e){e===void 0&&(e=$nA);let t=A.getBoundingClientRect();if(e.ignoreTransform){const{transform:l,transformOrigin:u}=An(A).getComputedStyle(A);l&&(t=_nA(t,l,u))}const{top:n,left:r,width:s,height:a,bottom:o,right:i}=t;return{top:n,left:r,width:s,height:a,bottom:o,right:i}}function oy(A){return Fi(A,{ignoreTransform:!0})}function ArA(A){const e=A.innerWidth,t=A.innerHeight;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}function erA(A,e){return e===void 0&&(e=An(A).getComputedStyle(A)),e.position==="fixed"}function trA(A,e){e===void 0&&(e=An(A).getComputedStyle(A));const t=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const s=e[r];return typeof s=="string"?t.test(s):!1})}function ov(A,e){const t=[];function n(r){if(e!=null&&t.length>=e||!r)return t;if(C0(r)&&r.scrollingElement!=null&&!t.includes(r.scrollingElement))return t.push(r.scrollingElement),t;if(!fu(r)||N4(r)||t.includes(r))return t;const s=An(A).getComputedStyle(r);return r!==A&&trA(r,s)&&t.push(r),erA(r,s)?t:n(r.parentNode)}return A?n(A):t}function G4(A){const[e]=ov(A,1);return e??null}function Sm(A){return!rv||!A?null:Ri(A)?A:M0(A)?C0(A)||A===Wi(A).scrollingElement?window:fu(A)?A:null:null}function I4(A){return Ri(A)?A.scrollX:A.scrollLeft}function Q4(A){return Ri(A)?A.scrollY:A.scrollTop}function L2(A){return{x:I4(A),y:Q4(A)}}var ct;(function(A){A[A.Forward=1]="Forward",A[A.Backward=-1]="Backward"})(ct||(ct={}));function L4(A){return!rv||!A?!1:A===document.scrollingElement}function J4(A){const e={x:0,y:0},t=L4(A)?{height:window.innerHeight,width:window.innerWidth}:{height:A.clientHeight,width:A.clientWidth},n={x:A.scrollWidth-t.width,y:A.scrollHeight-t.height},r=A.scrollTop<=e.y,s=A.scrollLeft<=e.x,a=A.scrollTop>=n.y,o=A.scrollLeft>=n.x;return{isTop:r,isLeft:s,isBottom:a,isRight:o,maxScroll:n,minScroll:e}}const nrA={x:.2,y:.2};function rrA(A,e,t,n,r){let{top:s,left:a,right:o,bottom:i}=t;n===void 0&&(n=10),r===void 0&&(r=nrA);const{isTop:l,isBottom:u,isLeft:f,isRight:d}=J4(A),g={x:0,y:0},v={x:0,y:0},m={height:e.height*r.y,width:e.width*r.x};return!l&&s<=e.top+m.height?(g.y=ct.Backward,v.y=n*Math.abs((e.top+m.height-s)/m.height)):!u&&i>=e.bottom-m.height&&(g.y=ct.Forward,v.y=n*Math.abs((e.bottom-m.height-i)/m.height)),!d&&o>=e.right-m.width?(g.x=ct.Forward,v.x=n*Math.abs((e.right-m.width-o)/m.width)):!f&&a<=e.left+m.width&&(g.x=ct.Backward,v.x=n*Math.abs((e.left+m.width-a)/m.width)),{direction:g,speed:v}}function srA(A){if(A===document.scrollingElement){const{innerWidth:s,innerHeight:a}=window;return{top:0,left:0,right:s,bottom:a,width:s,height:a}}const{top:e,left:t,right:n,bottom:r}=A.getBoundingClientRect();return{top:e,left:t,right:n,bottom:r,width:A.clientWidth,height:A.clientHeight}}function q4(A){return A.reduce((e,t)=>Go(e,L2(t)),In)}function arA(A){return A.reduce((e,t)=>e+I4(t),0)}function orA(A){return A.reduce((e,t)=>e+Q4(t),0)}function irA(A,e){if(e===void 0&&(e=Fi),!A)return;const{top:t,left:n,bottom:r,right:s}=e(A);G4(A)&&(r<=0||s<=0||t>=window.innerHeight||n>=window.innerWidth)&&A.scrollIntoView({block:"center",inline:"center"})}const lrA=[["x",["left","right"],arA],["y",["top","bottom"],orA]];class T0{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=ov(t),r=q4(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,a,o]of lrA)for(const i of a)Object.defineProperty(this,i,{get:()=>{const l=o(n),u=r[s]-l;return this.rect[i]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Zl{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(t=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...t)})},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function crA(A){const{EventTarget:e}=An(A);return A instanceof e?A:Wi(A)}function Xm(A,e){const t=Math.abs(A.x),n=Math.abs(A.y);return typeof e=="number"?Math.sqrt(t**2+n**2)>e:"x"in e&&"y"in e?t>e.x&&n>e.y:"x"in e?t>e.x:"y"in e?n>e.y:!1}var vn;(function(A){A.Click="click",A.DragStart="dragstart",A.Keydown="keydown",A.ContextMenu="contextmenu",A.Resize="resize",A.SelectionChange="selectionchange",A.VisibilityChange="visibilitychange"})(vn||(vn={}));function iy(A){A.preventDefault()}function urA(A){A.stopPropagation()}var oe;(function(A){A.Space="Space",A.Down="ArrowDown",A.Right="ArrowRight",A.Left="ArrowLeft",A.Up="ArrowUp",A.Esc="Escape",A.Enter="Enter",A.Tab="Tab"})(oe||(oe={}));const R4={start:[oe.Space,oe.Enter],cancel:[oe.Esc],end:[oe.Space,oe.Enter,oe.Tab]},frA=(A,e)=>{let{currentCoordinates:t}=e;switch(A.code){case oe.Right:return{...t,x:t.x+25};case oe.Left:return{...t,x:t.x-25};case oe.Down:return{...t,y:t.y+25};case oe.Up:return{...t,y:t.y-25}}};class Ki{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new Zl(Wi(t)),this.windowListeners=new Zl(An(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(vn.Resize,this.handleCancel),this.windowListeners.add(vn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(vn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&irA(n),t(In)}handleKeyDown(e){if(O0(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:s=R4,coordinateGetter:a=frA,scrollBehavior:o="smooth"}=r,{code:i}=e;if(s.end.includes(i)){this.handleEnd(e);return}if(s.cancel.includes(i)){this.handleCancel(e);return}const{collisionRect:l}=n.current,u=l?{x:l.left,y:l.top}:In;this.referenceCoordinates||(this.referenceCoordinates=u);const f=a(e,{active:t,context:n.current,currentCoordinates:u});if(f){const d=yc(f,u),g={x:0,y:0},{scrollableAncestors:v}=n.current;for(const m of v){const p=e.code,{isTop:h,isRight:P,isLeft:b,isBottom:x,maxScroll:z,minScroll:D}=J4(m),B=srA(m),M={x:Math.min(p===oe.Right?B.right-B.width/2:B.right,Math.max(p===oe.Right?B.left:B.left+B.width/2,f.x)),y:Math.min(p===oe.Down?B.bottom-B.height/2:B.bottom,Math.max(p===oe.Down?B.top:B.top+B.height/2,f.y))},Y=p===oe.Right&&!P||p===oe.Left&&!b,V=p===oe.Down&&!x||p===oe.Up&&!h;if(Y&&M.x!==f.x){const j=m.scrollLeft+d.x,C=p===oe.Right&&j<=z.x||p===oe.Left&&j>=D.x;if(C&&!d.y){m.scrollTo({left:j,behavior:o});return}C?g.x=m.scrollLeft-j:g.x=p===oe.Right?m.scrollLeft-z.x:m.scrollLeft-D.x,g.x&&m.scrollBy({left:-g.x,behavior:o});break}else if(V&&M.y!==f.y){const j=m.scrollTop+d.y,C=p===oe.Down&&j<=z.y||p===oe.Up&&j>=D.y;if(C&&!d.x){m.scrollTo({top:j,behavior:o});return}C?g.y=m.scrollTop-j:g.y=p===oe.Down?m.scrollTop-z.y:m.scrollTop-D.y,g.y&&m.scrollBy({top:-g.y,behavior:o});break}}this.handleMove(e,Go(yc(f,this.referenceCoordinates),g))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Ki.activators=[{eventName:"onKeyDown",handler:(A,e,t)=>{let{keyboardCodes:n=R4,onActivation:r}=e,{active:s}=t;const{code:a}=A.nativeEvent;if(n.start.includes(a)){const o=s.activatorNode.current;return o&&A.target!==o?!1:(A.preventDefault(),r==null||r({event:A.nativeEvent}),!0)}return!1}}];function ly(A){return!!(A&&"distance"in A)}function cy(A){return!!(A&&"delay"in A)}class E0{constructor(e,t,n){var r;n===void 0&&(n=crA(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:s}=e,{target:a}=s;this.props=e,this.events=t,this.document=Wi(a),this.documentListeners=new Zl(this.document),this.listeners=new Zl(n),this.windowListeners=new Zl(An(a)),this.initialCoordinates=(r=Q2(s))!=null?r:In,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(vn.Resize,this.handleCancel),this.windowListeners.add(vn.DragStart,iy),this.windowListeners.add(vn.VisibilityChange,this.handleCancel),this.windowListeners.add(vn.ContextMenu,iy),this.documentListeners.add(vn.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(cy(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(ly(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(vn.Click,urA,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(vn.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:s}=this,{onMove:a,options:{activationConstraint:o}}=s;if(!r)return;const i=(t=Q2(e))!=null?t:In,l=yc(r,i);if(!n&&o){if(ly(o)){if(o.tolerance!=null&&Xm(l,o.tolerance))return this.handleCancel();if(Xm(l,o.distance))return this.handleStart()}if(cy(o)&&Xm(l,o.tolerance))return this.handleCancel();this.handlePending(o,l);return}e.cancelable&&e.preventDefault(),a(i)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===oe.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const drA={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ui extends E0{constructor(e){const{event:t}=e,n=Wi(t.target);super(e,drA,n)}}Ui.activators=[{eventName:"onPointerDown",handler:(A,e)=>{let{nativeEvent:t}=A,{onActivation:n}=e;return!t.isPrimary||t.button!==0?!1:(n==null||n({event:t}),!0)}}];const grA={move:{name:"mousemove"},end:{name:"mouseup"}};var J2;(function(A){A[A.RightClick=2]="RightClick"})(J2||(J2={}));class vrA extends E0{constructor(e){super(e,grA,Wi(e.event.target))}}vrA.activators=[{eventName:"onMouseDown",handler:(A,e)=>{let{nativeEvent:t}=A,{onActivation:n}=e;return t.button===J2.RightClick?!1:(n==null||n({event:t}),!0)}}];const Ym={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class mrA extends E0{constructor(e){super(e,Ym)}static setup(){return window.addEventListener(Ym.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Ym.move.name,e)};function e(){}}}mrA.activators=[{eventName:"onTouchStart",handler:(A,e)=>{let{nativeEvent:t}=A,{onActivation:n}=e;const{touches:r}=t;return r.length>1?!1:(n==null||n({event:t}),!0)}}];var Vl;(function(A){A[A.Pointer=0]="Pointer",A[A.DraggableRect=1]="DraggableRect"})(Vl||(Vl={}));var bd;(function(A){A[A.TreeOrder=0]="TreeOrder",A[A.ReversedTreeOrder=1]="ReversedTreeOrder"})(bd||(bd={}));function prA(A){let{acceleration:e,activator:t=Vl.Pointer,canScroll:n,draggingRect:r,enabled:s,interval:a=5,order:o=bd.TreeOrder,pointerCoordinates:i,scrollableAncestors:l,scrollableAncestorRects:u,delta:f,threshold:d}=A;const g=wrA({delta:f,disabled:!s}),[v,m]=TnA(),p=y.useRef({x:0,y:0}),h=y.useRef({x:0,y:0}),P=y.useMemo(()=>{switch(t){case Vl.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case Vl.DraggableRect:return r}},[t,r,i]),b=y.useRef(null),x=y.useCallback(()=>{const D=b.current;if(!D)return;const B=p.current.x*h.current.x,M=p.current.y*h.current.y;D.scrollBy(B,M)},[]),z=y.useMemo(()=>o===bd.TreeOrder?[...l].reverse():l,[o,l]);y.useEffect(()=>{if(!s||!l.length||!P){m();return}for(const D of z){if((n==null?void 0:n(D))===!1)continue;const B=l.indexOf(D),M=u[B];if(!M)continue;const{direction:Y,speed:V}=rrA(D,M,P,e,d);for(const j of["x","y"])g[j][Y[j]]||(V[j]=0,Y[j]=0);if(V.x>0||V.y>0){m(),b.current=D,v(x,a),p.current=V,h.current=Y;return}}p.current={x:0,y:0},h.current={x:0,y:0},m()},[e,x,n,m,s,a,JSON.stringify(P),JSON.stringify(g),v,l,z,u,JSON.stringify(d)])}const hrA={x:{[ct.Backward]:!1,[ct.Forward]:!1},y:{[ct.Backward]:!1,[ct.Forward]:!1}};function wrA(A){let{delta:e,disabled:t}=A;const n=I2(e);return du(r=>{if(t||!n||!r)return hrA;const s={x:Math.sign(e.x-n.x),y:Math.sign(e.y-n.y)};return{x:{[ct.Backward]:r.x[ct.Backward]||s.x===-1,[ct.Forward]:r.x[ct.Forward]||s.x===1},y:{[ct.Backward]:r.y[ct.Backward]||s.y===-1,[ct.Forward]:r.y[ct.Forward]||s.y===1}}},[t,e,n])}function PrA(A,e){const t=e!=null?A.get(e):void 0,n=t?t.node.current:null;return du(r=>{var s;return e==null?null:(s=n??r)!=null?s:null},[n,e])}function yrA(A,e){return y.useMemo(()=>A.reduce((t,n)=>{const{sensor:r}=n,s=r.activators.map(a=>({eventName:a.eventName,handler:e(a.handler,n)}));return[...t,...s]},[]),[A,e])}var bc;(function(A){A[A.Always=0]="Always",A[A.BeforeDragging=1]="BeforeDragging",A[A.WhileDragging=2]="WhileDragging"})(bc||(bc={}));var q2;(function(A){A.Optimized="optimized"})(q2||(q2={}));const uy=new Map;function brA(A,e){let{dragging:t,dependencies:n,config:r}=e;const[s,a]=y.useState(null),{frequency:o,measure:i,strategy:l}=r,u=y.useRef(A),f=p(),d=Pc(f),g=y.useCallback(function(h){h===void 0&&(h=[]),!d.current&&a(P=>P===null?h:P.concat(h.filter(b=>!P.includes(b))))},[d]),v=y.useRef(null),m=du(h=>{if(f&&!t)return uy;if(!h||h===uy||u.current!==A||s!=null){const P=new Map;for(let b of A){if(!b)continue;if(s&&s.length>0&&!s.includes(b.id)&&b.rect.current){P.set(b.id,b.rect.current);continue}const x=b.node.current,z=x?new T0(i(x),x):null;b.rect.current=z,z&&P.set(b.id,z)}return P}return h},[A,s,t,f,i]);return y.useEffect(()=>{u.current=A},[A]),y.useEffect(()=>{f||g()},[t,f]),y.useEffect(()=>{s&&s.length>0&&a(null)},[JSON.stringify(s)]),y.useEffect(()=>{f||typeof o!="number"||v.current!==null||(v.current=setTimeout(()=>{g(),v.current=null},o))},[o,f,g,...n]),{droppableRects:m,measureDroppableContainers:g,measuringScheduled:s!=null};function p(){switch(l){case bc.Always:return!1;case bc.BeforeDragging:return t;default:return!t}}}function W4(A,e){return du(t=>A?t||(typeof e=="function"?e(A):A):null,[e,A])}function xrA(A,e){return W4(A,e)}function zrA(A){let{callback:e,disabled:t}=A;const n=j0(e),r=y.useMemo(()=>{if(t||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(n)},[n,t]);return y.useEffect(()=>()=>r==null?void 0:r.disconnect(),[r]),r}function iv(A){let{callback:e,disabled:t}=A;const n=j0(e),r=y.useMemo(()=>{if(t||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(n)},[t]);return y.useEffect(()=>()=>r==null?void 0:r.disconnect(),[r]),r}function DrA(A){return new T0(Fi(A),A)}function fy(A,e,t){e===void 0&&(e=DrA);const[n,r]=y.useState(null);function s(){r(i=>{if(!A)return null;if(A.isConnected===!1){var l;return(l=i??t)!=null?l:null}const u=e(A);return JSON.stringify(i)===JSON.stringify(u)?i:u})}const a=zrA({callback(i){if(A)for(const l of i){const{type:u,target:f}=l;if(u==="childList"&&f instanceof HTMLElement&&f.contains(A)){s();break}}}}),o=iv({callback:s});return yr(()=>{s(),A?(o==null||o.observe(A),a==null||a.observe(document.body,{childList:!0,subtree:!0})):(o==null||o.disconnect(),a==null||a.disconnect())},[A]),n}function BrA(A){const e=W4(A);return Y4(A,e)}const dy=[];function MrA(A){const e=y.useRef(A),t=du(n=>A?n&&n!==dy&&A&&e.current&&A.parentNode===e.current.parentNode?n:ov(A):dy,[A]);return y.useEffect(()=>{e.current=A},[A]),t}function CrA(A){const[e,t]=y.useState(null),n=y.useRef(A),r=y.useCallback(s=>{const a=Sm(s.target);a&&t(o=>o?(o.set(a,L2(a)),new Map(o)):null)},[]);return y.useEffect(()=>{const s=n.current;if(A!==s){a(s);const o=A.map(i=>{const l=Sm(i);return l?(l.addEventListener("scroll",r,{passive:!0}),[l,L2(l)]):null}).filter(i=>i!=null);t(o.length?new Map(o):null),n.current=A}return()=>{a(A),a(s)};function a(o){o.forEach(i=>{const l=Sm(i);l==null||l.removeEventListener("scroll",r)})}},[r,A]),y.useMemo(()=>A.length?e?Array.from(e.values()).reduce((s,a)=>Go(s,a),In):q4(A):In,[A,e])}function gy(A,e){e===void 0&&(e=[]);const t=y.useRef(null);return y.useEffect(()=>{t.current=null},e),y.useEffect(()=>{const n=A!==In;n&&!t.current&&(t.current=A),!n&&t.current&&(t.current=null)},[A]),t.current?yc(A,t.current):In}function jrA(A){y.useEffect(()=>{if(!rv)return;const e=A.map(t=>{let{sensor:n}=t;return n.setup==null?void 0:n.setup()});return()=>{for(const t of e)t==null||t()}},A.map(e=>{let{sensor:t}=e;return t}))}function OrA(A,e){return y.useMemo(()=>A.reduce((t,n)=>{let{eventName:r,handler:s}=n;return t[r]=a=>{s(a,e)},t},{}),[A,e])}function F4(A){return y.useMemo(()=>A?ArA(A):null,[A])}const vy=[];function TrA(A,e){e===void 0&&(e=Fi);const[t]=A,n=F4(t?An(t):null),[r,s]=y.useState(vy);function a(){s(()=>A.length?A.map(i=>L4(i)?n:new T0(e(i),i)):vy)}const o=iv({callback:a});return yr(()=>{o==null||o.disconnect(),a(),A.forEach(i=>o==null?void 0:o.observe(i))},[A]),r}function ErA(A){if(!A)return null;if(A.children.length>1)return A;const e=A.children[0];return fu(e)?e:A}function HrA(A){let{measure:e}=A;const[t,n]=y.useState(null),r=y.useCallback(l=>{for(const{target:u}of l)if(fu(u)){n(f=>{const d=e(u);return f?{...f,width:d.width,height:d.height}:d});break}},[e]),s=iv({callback:r}),a=y.useCallback(l=>{const u=ErA(l);s==null||s.disconnect(),u&&(s==null||s.observe(u)),n(u?e(u):null)},[e,s]),[o,i]=Pd(a);return y.useMemo(()=>({nodeRef:o,rect:t,setRef:i}),[t,o,i])}const NrA=[{sensor:Ui,options:{}},{sensor:Ki,options:{}}],krA={current:{}},yf={draggable:{measure:oy},droppable:{measure:oy,strategy:bc.WhileDragging,frequency:q2.Optimized},dragOverlay:{measure:Fi}};class Sl extends Map{get(e){var t;return e!=null&&(t=super.get(e))!=null?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,n;return(t=(n=this.get(e))==null?void 0:n.node.current)!=null?t:void 0}}const ZrA={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Sl,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:yd},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:yf,measureDroppableContainers:yd,windowRect:null,measuringScheduled:!1},VrA={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:yd,draggableNodes:new Map,over:null,measureDroppableContainers:yd},lv=y.createContext(VrA),K4=y.createContext(ZrA);function SrA(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Sl}}}function XrA(A,e){switch(e.type){case nt.DragStart:return{...A,draggable:{...A.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case nt.DragMove:return A.draggable.active==null?A:{...A,draggable:{...A.draggable,translate:{x:e.coordinates.x-A.draggable.initialCoordinates.x,y:e.coordinates.y-A.draggable.initialCoordinates.y}}};case nt.DragEnd:case nt.DragCancel:return{...A,draggable:{...A.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case nt.RegisterDroppable:{const{element:t}=e,{id:n}=t,r=new Sl(A.droppable.containers);return r.set(n,t),{...A,droppable:{...A.droppable,containers:r}}}case nt.SetDroppableDisabled:{const{id:t,key:n,disabled:r}=e,s=A.droppable.containers.get(t);if(!s||n!==s.key)return A;const a=new Sl(A.droppable.containers);return a.set(t,{...s,disabled:r}),{...A,droppable:{...A.droppable,containers:a}}}case nt.UnregisterDroppable:{const{id:t,key:n}=e,r=A.droppable.containers.get(t);if(!r||n!==r.key)return A;const s=new Sl(A.droppable.containers);return s.delete(t),{...A,droppable:{...A.droppable,containers:s}}}default:return A}}function YrA(A){let{disabled:e}=A;const{active:t,activatorEvent:n,draggableNodes:r}=y.useContext(lv),s=I2(n),a=I2(t==null?void 0:t.id);return y.useEffect(()=>{if(!e&&!n&&s&&a!=null){if(!O0(s)||document.activeElement===s.target)return;const o=r.get(a);if(!o)return;const{activatorNode:i,node:l}=o;if(!i.current&&!l.current)return;requestAnimationFrame(()=>{for(const u of[i.current,l.current]){if(!u)continue;const f=NnA(u);if(f){f.focus();break}}})}},[n,e,r,a,s]),null}function GrA(A,e){let{transform:t,...n}=e;return A!=null&&A.length?A.reduce((r,s)=>s({transform:r,...n}),t):t}function IrA(A){return y.useMemo(()=>({draggable:{...yf.draggable,...A==null?void 0:A.draggable},droppable:{...yf.droppable,...A==null?void 0:A.droppable},dragOverlay:{...yf.dragOverlay,...A==null?void 0:A.dragOverlay}}),[A==null?void 0:A.draggable,A==null?void 0:A.droppable,A==null?void 0:A.dragOverlay])}function QrA(A){let{activeNode:e,measure:t,initialRect:n,config:r=!0}=A;const s=y.useRef(!1),{x:a,y:o}=typeof r=="boolean"?{x:r,y:r}:r;yr(()=>{if(!a&&!o||!e){s.current=!1;return}if(s.current||!n)return;const l=e==null?void 0:e.node.current;if(!l||l.isConnected===!1)return;const u=t(l),f=Y4(u,n);if(a||(f.x=0),o||(f.y=0),s.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const d=G4(l);d&&d.scrollBy({top:f.y,left:f.x})}},[e,a,o,n,t])}const U4=y.createContext({...In,scaleX:1,scaleY:1});var us;(function(A){A[A.Uninitialized=0]="Uninitialized",A[A.Initializing=1]="Initializing",A[A.Initialized=2]="Initialized"})(us||(us={}));const cv=y.memo(function(e){var t,n,r,s;let{id:a,accessibility:o,autoScroll:i=!0,children:l,sensors:u=NrA,collisionDetection:f=RnA,measuring:d,modifiers:g,...v}=e;const m=y.useReducer(XrA,void 0,SrA),[p,h]=m,[P,b]=YnA(),[x,z]=y.useState(us.Uninitialized),D=x===us.Initialized,{draggable:{active:B,nodes:M,translate:Y},droppable:{containers:V}}=p,j=B!=null?M.get(B):null,C=y.useRef({initial:null,translated:null}),E=y.useMemo(()=>{var se;return B!=null?{id:B,data:(se=j==null?void 0:j.data)!=null?se:krA,rect:C}:null},[B,j]),N=y.useRef(null),[q,I]=y.useState(null),[G,H]=y.useState(null),T=Pc(v,Object.values(v)),Z=gu("DndDescribedBy",a),O=y.useMemo(()=>V.getEnabled(),[V]),k=IrA(d),{droppableRects:X,measureDroppableContainers:J,measuringScheduled:F}=brA(O,{dragging:D,dependencies:[Y.x,Y.y],config:k.droppable}),eA=PrA(M,B),R=y.useMemo(()=>G?Q2(G):null,[G]),tA=Yt(),K=xrA(eA,k.draggable.measure);QrA({activeNode:B!=null?M.get(B):null,config:tA.layoutShiftCompensation,initialRect:K,measure:k.draggable.measure});const $=fy(eA,k.draggable.measure,K),_=fy(eA?eA.parentElement:null),U=y.useRef({activatorEvent:null,active:null,activeNode:eA,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:M,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),wA=V.getNodeFor((t=U.current.over)==null?void 0:t.id),HA=HrA({measure:k.dragOverlay.measure}),CA=(n=HA.nodeRef.current)!=null?n:eA,SA=D?(r=HA.rect)!=null?r:$:null,de=!!(HA.nodeRef.current&&HA.rect),Bt=BrA(de?null:$),xe=F4(CA?An(CA):null),Q=MrA(D?wA??eA:null),AA=TrA(Q),nA=GrA(g,{transform:{x:Y.x-Bt.x,y:Y.y-Bt.y,scaleX:1,scaleY:1},activatorEvent:G,active:E,activeNodeRect:$,containerNodeRect:_,draggingNodeRect:SA,over:U.current.over,overlayNodeRect:HA.rect,scrollableAncestors:Q,scrollableAncestorRects:AA,windowRect:xe}),fA=R?Go(R,Y):null,cA=CrA(Q),lA=gy(cA),vA=gy(cA,[$]),IA=Go(nA,lA),RA=SA?KnA(SA,nA):null,DA=E&&RA?f({active:E,collisionRect:RA,droppableRects:X,droppableContainers:O,pointerCoordinates:fA}):null,ge=X4(DA,"id"),[ne,Te]=y.useState(null),bA=de?nA:Go(nA,vA),Je=WnA(bA,(s=ne==null?void 0:ne.rect)!=null?s:null,$),Be=y.useRef(null),St=y.useCallback((se,_e)=>{let{sensor:TA,options:ce}=_e;if(N.current==null)return;const ue=M.get(N.current);if(!ue)return;const ze=se.nativeEvent,jt=new TA({active:N.current,activeNode:ue,event:ze,options:ce,context:U,onAbort(ve){if(!M.get(ve))return;const{onDragAbort:ke}=T.current,Ye={id:ve};ke==null||ke(Ye),P({type:"onDragAbort",event:Ye})},onPending(ve,tn,ke,Ye){if(!M.get(ve))return;const{onDragPending:nn}=T.current,Or={id:ve,constraint:tn,initialCoordinates:ke,offset:Ye};nn==null||nn(Or),P({type:"onDragPending",event:Or})},onStart(ve){const tn=N.current;if(tn==null)return;const ke=M.get(tn);if(!ke)return;const{onDragStart:Ye}=T.current,rs={activatorEvent:ze,active:{id:tn,data:ke.data,rect:C}};ys.unstable_batchedUpdates(()=>{Ye==null||Ye(rs),z(us.Initializing),h({type:nt.DragStart,initialCoordinates:ve,active:tn}),P({type:"onDragStart",event:rs}),I(Be.current),H(ze)})},onMove(ve){h({type:nt.DragMove,coordinates:ve})},onEnd:He(nt.DragEnd),onCancel:He(nt.DragCancel)});Be.current=jt;function He(ve){return async function(){const{active:ke,collisions:Ye,over:rs,scrollAdjustedTranslate:nn}=U.current;let Or=null;if(ke&&nn){const{cancelDrop:Al}=T.current;Or={activatorEvent:ze,active:ke,collisions:Ye,delta:nn,over:rs},ve===nt.DragEnd&&typeof Al=="function"&&await Promise.resolve(Al(Or))&&(ve=nt.DragCancel)}N.current=null,ys.unstable_batchedUpdates(()=>{h({type:ve}),z(us.Uninitialized),Te(null),I(null),H(null),Be.current=null;const Al=ve===nt.DragEnd?"onDragEnd":"onDragCancel";if(Or){const yv=T.current[Al];yv==null||yv(Or),P({type:Al,event:Or})}})}}},[M]),Mt=y.useCallback((se,_e)=>(TA,ce)=>{const ue=TA.nativeEvent,ze=M.get(ce);if(N.current!==null||!ze||ue.dndKit||ue.defaultPrevented)return;const jt={active:ze};se(TA,_e.options,jt)===!0&&(ue.dndKit={capturedBy:_e.sensor},N.current=ce,St(TA,_e))},[M,St]),Ct=yrA(u,Mt);jrA(u),yr(()=>{$&&x===us.Initializing&&z(us.Initialized)},[$,x]),y.useEffect(()=>{const{onDragMove:se}=T.current,{active:_e,activatorEvent:TA,collisions:ce,over:ue}=U.current;if(!_e||!TA)return;const ze={active:_e,activatorEvent:TA,collisions:ce,delta:{x:IA.x,y:IA.y},over:ue};ys.unstable_batchedUpdates(()=>{se==null||se(ze),P({type:"onDragMove",event:ze})})},[IA.x,IA.y]),y.useEffect(()=>{const{active:se,activatorEvent:_e,collisions:TA,droppableContainers:ce,scrollAdjustedTranslate:ue}=U.current;if(!se||N.current==null||!_e||!ue)return;const{onDragOver:ze}=T.current,jt=ce.get(ge),He=jt&&jt.rect.current?{id:jt.id,rect:jt.rect.current,data:jt.data,disabled:jt.disabled}:null,ve={active:se,activatorEvent:_e,collisions:TA,delta:{x:ue.x,y:ue.y},over:He};ys.unstable_batchedUpdates(()=>{Te(He),ze==null||ze(ve),P({type:"onDragOver",event:ve})})},[ge]),yr(()=>{U.current={activatorEvent:G,active:E,activeNode:eA,collisionRect:RA,collisions:DA,droppableRects:X,draggableNodes:M,draggingNode:CA,draggingNodeRect:SA,droppableContainers:V,over:ne,scrollableAncestors:Q,scrollAdjustedTranslate:IA},C.current={initial:SA,translated:RA}},[E,eA,DA,RA,M,CA,SA,X,V,ne,Q,IA]),prA({...tA,delta:Y,draggingRect:RA,pointerCoordinates:fA,scrollableAncestors:Q,scrollableAncestorRects:AA});const en=y.useMemo(()=>({active:E,activeNode:eA,activeNodeRect:$,activatorEvent:G,collisions:DA,containerNodeRect:_,dragOverlay:HA,draggableNodes:M,droppableContainers:V,droppableRects:X,over:ne,measureDroppableContainers:J,scrollableAncestors:Q,scrollableAncestorRects:AA,measuringConfiguration:k,measuringScheduled:F,windowRect:xe}),[E,eA,$,G,DA,_,HA,M,V,X,ne,J,Q,AA,k,F,xe]),Xt=y.useMemo(()=>({activatorEvent:G,activators:Ct,active:E,activeNodeRect:$,ariaDescribedById:{draggable:Z},dispatch:h,draggableNodes:M,over:ne,measureDroppableContainers:J}),[G,Ct,E,$,h,Z,M,ne,J]);return y.createElement(Z4.Provider,{value:b},y.createElement(lv.Provider,{value:Xt},y.createElement(K4.Provider,{value:en},y.createElement(U4.Provider,{value:Je},l)),y.createElement(YrA,{disabled:(o==null?void 0:o.restoreFocus)===!1})),y.createElement(QnA,{...o,hiddenTextDescribedById:Z}));function Yt(){const se=(q==null?void 0:q.autoScrollEnabled)===!1,_e=typeof i=="object"?i.enabled===!1:i===!1,TA=D&&!se&&!_e;return typeof i=="object"?{...i,enabled:TA}:{enabled:TA}}}),LrA=y.createContext(null),my="button",JrA="Draggable";function qrA(A){let{id:e,data:t,disabled:n=!1,attributes:r}=A;const s=gu(JrA),{activators:a,activatorEvent:o,active:i,activeNodeRect:l,ariaDescribedById:u,draggableNodes:f,over:d}=y.useContext(lv),{role:g=my,roleDescription:v="draggable",tabIndex:m=0}=r??{},p=(i==null?void 0:i.id)===e,h=y.useContext(p?U4:LrA),[P,b]=Pd(),[x,z]=Pd(),D=OrA(a,e),B=Pc(t);yr(()=>(f.set(e,{id:e,key:s,node:P,activatorNode:x,data:B}),()=>{const Y=f.get(e);Y&&Y.key===s&&f.delete(e)}),[f,e]);const M=y.useMemo(()=>({role:g,tabIndex:m,"aria-disabled":n,"aria-pressed":p&&g===my?!0:void 0,"aria-roledescription":v,"aria-describedby":u.draggable}),[n,g,m,p,v,u.draggable]);return{active:i,activatorEvent:o,activeNodeRect:l,attributes:M,isDragging:p,listeners:n?void 0:D,node:P,over:d,setNodeRef:b,setActivatorNodeRef:z,transform:h}}function RrA(){return y.useContext(K4)}const WrA="Droppable",FrA={timeout:25};function KrA(A){let{data:e,disabled:t=!1,id:n,resizeObserverConfig:r}=A;const s=gu(WrA),{active:a,dispatch:o,over:i,measureDroppableContainers:l}=y.useContext(lv),u=y.useRef({disabled:t}),f=y.useRef(!1),d=y.useRef(null),g=y.useRef(null),{disabled:v,updateMeasurementsFor:m,timeout:p}={...FrA,...r},h=Pc(m??n),P=y.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),g.current=null},p)},[p]),b=iv({callback:P,disabled:v||!a}),x=y.useCallback((M,Y)=>{b&&(Y&&(b.unobserve(Y),f.current=!1),M&&b.observe(M))},[b]),[z,D]=Pd(x),B=Pc(e);return y.useEffect(()=>{!b||!z.current||(b.disconnect(),f.current=!1,b.observe(z.current))},[z,b]),y.useEffect(()=>(o({type:nt.RegisterDroppable,element:{id:n,key:s,disabled:t,node:z,rect:d,data:B}}),()=>o({type:nt.UnregisterDroppable,key:s,id:n})),[n]),y.useEffect(()=>{t!==u.current.disabled&&(o({type:nt.SetDroppableDisabled,id:n,key:s,disabled:t}),u.current.disabled=t)},[n,s,t,o]),{active:a,rect:d,isOver:(i==null?void 0:i.id)===n,node:z,over:i,setNodeRef:D}}function _4(A,e,t){const n=A.slice();return n.splice(t<0?n.length+t:t,0,n.splice(e,1)[0]),n}function UrA(A,e){return A.reduce((t,n,r)=>{const s=e.get(n);return s&&(t[r]=s),t},Array(A.length))}function Ru(A){return A!==null&&A>=0}function _rA(A,e){if(A===e)return!0;if(A.length!==e.length)return!1;for(let t=0;t<A.length;t++)if(A[t]!==e[t])return!1;return!0}function $rA(A){return typeof A=="boolean"?{draggable:A,droppable:A}:A}const $4=A=>{let{rects:e,activeIndex:t,overIndex:n,index:r}=A;const s=_4(e,n,t),a=e[r],o=s[r];return!o||!a?null:{x:o.left-a.left,y:o.top-a.top,scaleX:o.width/a.width,scaleY:o.height/a.height}},Wu={scaleX:1,scaleY:1},uv=A=>{var e;let{activeIndex:t,activeNodeRect:n,index:r,rects:s,overIndex:a}=A;const o=(e=s[t])!=null?e:n;if(!o)return null;if(r===t){const l=s[a];return l?{x:0,y:t<a?l.top+l.height-(o.top+o.height):l.top-o.top,...Wu}:null}const i=AsA(s,r,t);return r>t&&r<=a?{x:0,y:-o.height-i,...Wu}:r<t&&r>=a?{x:0,y:o.height+i,...Wu}:{x:0,y:0,...Wu}};function AsA(A,e,t){const n=A[e],r=A[e-1],s=A[e+1];return n?t<e?r?n.top-(r.top+r.height):s?s.top-(n.top+n.height):0:s?s.top-(n.top+n.height):r?n.top-(r.top+r.height):0:0}const Aj="Sortable",ej=y.createContext({activeIndex:-1,containerId:Aj,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:$4,disabled:{draggable:!1,droppable:!1}});function fv(A){let{children:e,id:t,items:n,strategy:r=$4,disabled:s=!1}=A;const{active:a,dragOverlay:o,droppableRects:i,over:l,measureDroppableContainers:u}=RrA(),f=gu(Aj,t),d=o.rect!==null,g=y.useMemo(()=>n.map(D=>typeof D=="object"&&"id"in D?D.id:D),[n]),v=a!=null,m=a?g.indexOf(a.id):-1,p=l?g.indexOf(l.id):-1,h=y.useRef(g),P=!_rA(g,h.current),b=p!==-1&&m===-1||P,x=$rA(s);yr(()=>{P&&v&&u(g)},[P,g,v,u]),y.useEffect(()=>{h.current=g},[g]);const z=y.useMemo(()=>({activeIndex:m,containerId:f,disabled:x,disableTransforms:b,items:g,overIndex:p,useDragOverlay:d,sortedRects:UrA(g,i),strategy:r}),[m,f,x.draggable,x.droppable,b,g,p,i,d,r]);return y.createElement(ej.Provider,{value:z},e)}const esA=A=>{let{id:e,items:t,activeIndex:n,overIndex:r}=A;return _4(t,n,r).indexOf(e)},tsA=A=>{let{containerId:e,isSorting:t,wasDragging:n,index:r,items:s,newIndex:a,previousItems:o,previousContainerId:i,transition:l}=A;return!l||!n||o!==s&&r===a?!1:t?!0:a!==r&&e===i},nsA={duration:200,easing:"ease"},tj="transform",rsA=Gs.Transition.toString({property:tj,duration:0,easing:"linear"}),ssA={roleDescription:"sortable"};function asA(A){let{disabled:e,index:t,node:n,rect:r}=A;const[s,a]=y.useState(null),o=y.useRef(t);return yr(()=>{if(!e&&t!==o.current&&n.current){const i=r.current;if(i){const l=Fi(n.current,{ignoreTransform:!0}),u={x:i.left-l.left,y:i.top-l.top,scaleX:i.width/l.width,scaleY:i.height/l.height};(u.x||u.y)&&a(u)}}t!==o.current&&(o.current=t)},[e,t,n,r]),y.useEffect(()=>{s&&a(null)},[s]),s}function dv(A){let{animateLayoutChanges:e=tsA,attributes:t,disabled:n,data:r,getNewIndex:s=esA,id:a,strategy:o,resizeObserverConfig:i,transition:l=nsA}=A;const{items:u,containerId:f,activeIndex:d,disabled:g,disableTransforms:v,sortedRects:m,overIndex:p,useDragOverlay:h,strategy:P}=y.useContext(ej),b=osA(n,g),x=u.indexOf(a),z=y.useMemo(()=>({sortable:{containerId:f,index:x,items:u},...r}),[f,r,x,u]),D=y.useMemo(()=>u.slice(u.indexOf(a)),[u,a]),{rect:B,node:M,isOver:Y,setNodeRef:V}=KrA({id:a,data:z,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:D,...i}}),{active:j,activatorEvent:C,activeNodeRect:E,attributes:N,setNodeRef:q,listeners:I,isDragging:G,over:H,setActivatorNodeRef:T,transform:Z}=qrA({id:a,data:z,attributes:{...ssA,...t},disabled:b.draggable}),O=OnA(V,q),k=!!j,X=k&&!v&&Ru(d)&&Ru(p),J=!h&&G,F=J&&X?Z:null,R=X?F??(o??P)({rects:m,activeNodeRect:E,activeIndex:d,overIndex:p,index:x}):null,tA=Ru(d)&&Ru(p)?s({id:a,items:u,activeIndex:d,overIndex:p}):x,K=j==null?void 0:j.id,$=y.useRef({activeId:K,items:u,newIndex:tA,containerId:f}),_=u!==$.current.items,U=e({active:j,containerId:f,isDragging:G,isSorting:k,id:a,index:x,items:u,newIndex:$.current.newIndex,previousItems:$.current.items,previousContainerId:$.current.containerId,transition:l,wasDragging:$.current.activeId!=null}),wA=asA({disabled:!U,index:x,node:M,rect:B});return y.useEffect(()=>{k&&$.current.newIndex!==tA&&($.current.newIndex=tA),f!==$.current.containerId&&($.current.containerId=f),u!==$.current.items&&($.current.items=u)},[k,tA,f,u]),y.useEffect(()=>{if(K===$.current.activeId)return;if(K!=null&&$.current.activeId==null){$.current.activeId=K;return}const CA=setTimeout(()=>{$.current.activeId=K},50);return()=>clearTimeout(CA)},[K]),{active:j,activeIndex:d,attributes:N,data:z,rect:B,index:x,newIndex:tA,items:u,isOver:Y,isSorting:k,isDragging:G,listeners:I,node:M,overIndex:p,over:H,setNodeRef:O,setActivatorNodeRef:T,setDroppableNodeRef:V,setDraggableNodeRef:q,transform:wA??R,transition:HA()};function HA(){if(wA||_&&$.current.newIndex===x)return rsA;if(!(J&&!O0(C)||!l)&&(k||U))return Gs.Transition.toString({...l,property:tj})}}function osA(A,e){var t,n;return typeof A=="boolean"?{draggable:A,droppable:!1}:{draggable:(t=A==null?void 0:A.draggable)!=null?t:e.draggable,droppable:(n=A==null?void 0:A.droppable)!=null?n:e.droppable}}function xd(A){if(!A)return!1;const e=A.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const isA=[oe.Down,oe.Right,oe.Up,oe.Left],gv=(A,e)=>{let{context:{active:t,collisionRect:n,droppableRects:r,droppableContainers:s,over:a,scrollableAncestors:o}}=e;if(isA.includes(A.code)){if(A.preventDefault(),!t||!n)return;const i=[];s.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const d=r.get(f.id);if(d)switch(A.code){case oe.Down:n.top<d.top&&i.push(f);break;case oe.Up:n.top>d.top&&i.push(f);break;case oe.Left:n.left>d.left&&i.push(f);break;case oe.Right:n.left<d.left&&i.push(f);break}});const l=JnA({collisionRect:n,droppableRects:r,droppableContainers:i});let u=X4(l,"id");if(u===(a==null?void 0:a.id)&&l.length>1&&(u=l[1].id),u!=null){const f=s.get(t.id),d=s.get(u),g=d?r.get(d.id):null,v=d==null?void 0:d.node.current;if(v&&g&&f&&d){const p=ov(v).some((D,B)=>o[B]!==D),h=nj(f,d),P=lsA(f,d),b=p||!h?{x:0,y:0}:{x:P?n.width-g.width:0,y:P?n.height-g.height:0},x={x:g.left,y:g.top};return b.x&&b.y?x:yc(x,b)}}}};function nj(A,e){return!xd(A)||!xd(e)?!1:A.data.current.sortable.containerId===e.data.current.sortable.containerId}function lsA(A,e){return!xd(A)||!xd(e)||!nj(A,e)?!1:A.data.current.sortable.index<e.data.current.sortable.index}const csA=({index:A,item:e,updateItem:t,removeItem:n})=>{var p;const r=y.useRef({});e.unit&&e.quantity&&!r.current[e.unit]&&(r.current[e.unit]=e.quantity);const{attributes:s,listeners:a,setNodeRef:o,transform:i,isDragging:l}=dv({id:e.id}),{inputGroupProps:u}=qn(),{showValue:f=!0,showQuantity:d=!0,isMultiple:g=!0,placeholder:v}=u||{},m={transform:Gs.Transform.toString(i)};return c.jsx("div",{ref:o,style:m,...s,className:"sortable-item",children:c.jsxs("div",{id:e.id,"data-id":e.id,className:S("grid grid-cols-22 gap-2 items-center group p-2 py-4",{"bg-accent/50 border border-b-4 border-accent":l,"grid-cols-12":!f||!d,"grid-cols-10":(!f||!d)&&!g,"p-0":!g}),"aria-disabled":!0,children:[g&&c.jsx("div",{className:"col-span-1 flex items-center justify-center ",...a,children:c.jsx("div",{className:S("cursor-grab active:cursor-grabbing rounded"),children:c.jsx(xh,{className:"h-6 w-7 text-muted-foreground "})})}),f&&c.jsx("div",{className:"col-span-10 ",children:c.jsx(hn,{placeholder:v||`Enter ${u==null?void 0:u.type}`,value:e.value,onChange:h=>t(A,"value",h.target.value),className:S("border bg-transparent","focus-visible:ring-0 focus-visible:ring-offset-0","transition-all duration-200",{"border-0 rounded-none ring-0":!g})})}),d&&c.jsxs("div",{className:"col-span-10 flex flex-1 items-stretch justify-items-stretch",children:[c.jsx(hn,{placeholder:e.unit==="Custom"?"Enter time with qualitative info (e.g., 10 mins plus overnight chilling)":e.unit==="N/A"?"":f?"Enter quantity":v,value:e.unit==="N/A"?"":e.quantity,disabled:e.unit==="N/A",onChange:h=>{const P=e.unit==="N/A"?null:h.target.value;t(A,"quantity",P),e.unit&&e.unit!=="N/A"&&P&&(r.current[e.unit]=P)},className:S("border bg-transparent rounded-r-none","focus-visible:ring-0 focus-visible:ring-offset-0","transition-all duration-200",{"border-0 border-r-1 rounded-none ring-0":!g},{"opacity-50 cursor-not-allowed":e.unit==="N/A"})}),(u==null?void 0:u.units)&&(typeof u.units=="string"||u.freeTextUnits?c.jsx(hn,{placeholder:u.unitsPlaceholder||"Enter unit",value:e.unit,onChange:h=>t(A,"unit",h.target.value),className:S("w-fit border border-l-0 bg-background h-9 rounded-l-none","focus-visible:ring-0 focus-visible:ring-offset-0","transition-all duration-200",{"border-0 rounded-none":!g})}):c.jsxs(li,{value:e.unit,defaultValue:(p=u.units[0])==null?void 0:p.value,onValueChange:h=>{if(e.unit&&e.unit!=="N/A"&&e.quantity&&e.quantity.trim()!==""&&(r.current[e.unit]=e.quantity),t(A,"unit",h),h==="N/A")t(A,"quantity",null);else{const P=r.current[h]||"";t(A,"quantity",P)}},children:[c.jsx(Ja,{className:S("w-fit border border-l-0 bg-muted h-9 rounded-l-none","focus:ring-0 focus:ring-offset-0","transition-all duration-200",{"border-0 rounded-none ":!g}),children:c.jsx(ci,{className:"capitalize"})}),c.jsx(qa,{children:u.units.map(h=>c.jsx(cr,{value:h.value,className:"capitalize",children:h.label},h.value))})]}))]}),g&&c.jsx("div",{className:"col-span-1 flex justify-end ",children:c.jsx(MA,{variant:"ghost",size:"sm",onClick:()=>n(A),className:S("h-6 w-6 p-0","transition-opacity duration-200","hover:bg-destructive/10"),children:c.jsx(Nn,{className:"h-3 w-3 text-destructive"})})})]},e.id)})},usA=()=>{const{state:A,dispatch:e,labelProps:t,inputGroupProps:n}=qn(),{showValue:r=!0,showQuantity:s=!0,isMultiple:a=!0}=n||{},{value:o}=A,i=w.useMemo(()=>Array.isArray(o)&&o.length>0?o:[{id:Date.now().toString(),value:"",quantity:"",unit:""}],[o,n==null?void 0:n.units]),l=m=>{e({type:"SET_VALUE",payload:m})},u=(m,p,h)=>{const P=[...i];P[m]&&(P[m][p]=h||""),l(P)},f=()=>{const m={id:Date.now().toString(),value:"",quantity:"",unit:""};l([...i,m])},d=m=>{const p=i.filter((h,P)=>P!==m);l(p)},g=sv(Is(Ui),Is(Ki,{coordinateGetter:gv}));function v(m){const{active:p,over:h}=m,P=[...i],b=i.findIndex(D=>D.id==(h==null?void 0:h.id)),x=i.findIndex(D=>D.id==(p==null?void 0:p.id)),z=i[x];z&&(P.splice(x,1),P.splice(b,0,z)),l(P)}return c.jsxs("div",{className:S("bg-background",n==null?void 0:n.className),children:[c.jsxs("div",{className:S("grid grid-cols-22 gap-2 px-2 py-2 text-sm text-muted-foreground bg-muted border text-muted-forground rounded rounded-b-none",t==null?void 0:t.className),children:[a&&c.jsx("span",{className:"col-span-1"}),r&&c.jsx("span",{className:"col-span-10 capitalize text-sm text-muted-foreground",children:n==null?void 0:n.type}),s&&c.jsx("span",{className:"col-span-10 capitalize text-sm text-muted-foreground",children:!r&&(n!=null&&n.type)?n==null?void 0:n.type:"Quantity"}),a&&c.jsx("span",{className:"col-span-1"})]}),c.jsx("div",{className:S("border border-t-0 rounded rounded-t-none"),children:c.jsx(cv,{sensors:g,collisionDetection:av,onDragEnd:v,children:c.jsx(fv,{items:i.map(m=>m.id),strategy:uv,children:i.map((m,p)=>c.jsx(csA,{item:m,removeItem:d,updateItem:u,index:p},m.id))})})}),a&&c.jsx("div",{className:"flex justify-end items-center gap-4 py-4 ",children:c.jsxs(MA,{variant:"outline",onClick:f,className:S("capitalize hover:bg-primary","transition-colors duration-200"),children:[c.jsx(Ao,{}),"Add another ",n==null?void 0:n.type]})})]})},fsA=({index:A,item:e,updateItem:t,removeItem:n})=>{const{attributes:r,listeners:s,setNodeRef:a,transform:o,isDragging:i}=dv({id:e.id}),{sortableGroupProps:l}=qn(),{isMultiple:u=!0}=l||{},f={transform:Gs.Transform.toString(o)};return c.jsx("div",{ref:a,style:f,...r,className:"sortable-item",children:c.jsxs("div",{id:e.id,"data-id":e.id,className:S("grid grid-cols-16 gap-2 items-center group p-2 py-4",{"bg-accent/50 border border-b-4 border-accent":i,"p-0":!u}),"aria-disabled":!0,children:[u&&c.jsx("div",{className:"col-span-1 flex items-center justify-center ",...s,children:c.jsx("div",{className:S("cursor-grab active:cursor-grabbing rounded"),children:c.jsx(xh,{className:"h-6 w-7 text-muted-foreground "})})}),c.jsx("div",{className:"col-span-14 ",children:c.jsx(st,{...l==null?void 0:l.itemProps,onChange:d=>t(A,"value",d)})}),u&&c.jsx("div",{className:"col-span-1 flex justify-end ",children:c.jsx(MA,{variant:"ghost",size:"sm",onClick:()=>n(A),className:S("h-6 w-6 p-0","transition-opacity duration-200","hover:bg-destructive/10"),children:c.jsx(Nn,{className:"h-3 w-3 text-destructive"})})})]},e.id)})},dsA=()=>{const{state:A,sortableGroupProps:e}=qn(),{isMultiple:t=!0}=e||{},{value:n}=A;console.log("SortableGroup value:",JSON.stringify(n));const r=w.useMemo(()=>Array.isArray(n)&&n.length>0?n:[{id:Date.now().toString(),value:""}],[n]),s=f=>{console.log("Updating items:",f)},a=(f,d,g)=>{const v=[...r];if(v[f])switch(d){case"value":v[f].value=g;break;case"id":v[f].id=g;break}s(v)},o=()=>{const f={id:Date.now().toString(),value:""};s([...r,f])},i=f=>{const d=r.filter((g,v)=>v!==f);s(d)},l=sv(Is(Ui),Is(Ki,{coordinateGetter:gv}));function u(f){const{active:d,over:g}=f,v=[...r],m=r.findIndex(P=>P.id==(g==null?void 0:g.id)),p=r.findIndex(P=>P.id==(d==null?void 0:d.id)),h=r[p];h&&(v.splice(p,1),v.splice(m,0,h)),s(v)}return c.jsxs("div",{className:S("bg-background",e==null?void 0:e.className),children:[c.jsx("div",{className:S("border border-t-0 rounded rounded-t-none"),children:c.jsx(cv,{sensors:l,collisionDetection:av,onDragEnd:u,children:c.jsx(fv,{items:r.map(f=>f.id),strategy:uv,children:r.map((f,d)=>c.jsx(fsA,{item:f,removeItem:i,updateItem:a,index:d},f.id))})})}),t&&c.jsx("div",{className:"flex justify-end items-center gap-4 py-4 ",children:c.jsxs(MA,{variant:"outline",onClick:o,className:S("capitalize hover:bg-primary","transition-colors duration-200"),children:[c.jsx(Ao,{}),"Add another ",e==null?void 0:e.type]})})]})},py=({className:A,inputProps:e,linkProps:t,textareaProps:n,wysiwygProps:r,switchProps:s,labelProps:a,label:o,selectProps:i,defaultValue:l,type:u="input",maxLetterCount:f,name:d=""})=>{const{state:g,dispatch:v,onChange:m,imageGalleryConfig:p,blogPostsConfig:h,error:P}=qn(),{value:b}=g,x=w.useRef(null),z=y.useCallback(E=>{v({type:"SET_VALUE",payload:E.target.value})},[v]),D=y.useCallback(E=>{v({type:"SET_VALUE",payload:E.target.value})},[v]),B=y.useCallback(E=>{v({type:"SET_VALUE",payload:E})},[v]),M=y.useCallback(E=>{v({type:"SET_VALUE",payload:E})},[v]),Y=y.useCallback(()=>{v({type:"TOGGLE_EDIT_LINK_MODAL"})},[v]),V=y.useMemo(()=>{var N,q;if(!f)return null;const E=((q=b==null?void 0:(N=b.toString()).trim)==null?void 0:q.call(N).length)||0;return{currentLength:E,isOverLimit:E>f}},[b,f]);function j(E){var N;try{const q=(N=x==null?void 0:x.current)==null?void 0:N.value;navigator.clipboard.writeText(`${E}${q}`)}catch(q){console.error("Failed to copy text: ",q)}}const C=()=>{switch(u){case"switch":return c.jsx(B9,{...s,checked:b,onCheckedChange:B});case"textarea":return c.jsxs("div",{className:"w-full flex gap-1 items-stretch",children:[(n==null?void 0:n.prefix)&&c.jsx("span",{className:S("flex items-center p-2 opacity-70 text-sm"),children:n.prefix}),c.jsx(zg,{defaultValue:l,...n,rows:3,value:b,onChange:E=>{D(E),m&&m(E.target.value)},className:S("p-2 h-fit !min-h-0 !text-sm rounded-none border-0 focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none focus-visible:outline-none bg-background",n==null?void 0:n.className)})]});case"optionslist":return i&&c.jsx(jnA,{});case"select":return i&&c.jsx(QtA,{});case"image":return c.jsx(GtA,{});case"blogposts":return c.jsx(DnA,{});case"video":return c.jsx(znA,{});case"inputgroup":return c.jsx(usA,{});case"sortablegroup":return c.jsx(dsA,{});case"wysiwyg":return c.jsx(xnA,{...r,imageGalleryConfig:(r==null?void 0:r.imageGalleryConfig)||p,blogPostsConfig:(r==null?void 0:r.blogPostsConfig)||h,initialValue:b,onChange:E=>{M(E),m&&m(E)},className:S(r==null?void 0:r.className),asChild:!0});case"link":return c.jsxs("div",{className:"w-full flex items-center gap-1 overflow-auto",children:[(t==null?void 0:t.prefix)&&c.jsx("span",{className:S("p-2 opacity-70 text-sm"),children:t.prefix}),c.jsxs("div",{className:"flex-1 w-fit flex items-center gap-1 bg-background p-2",children:[c.jsx(hn,{className:S("disabled:opacity-100 flex-1 w-10 underline text-sm truncate border-0 p-0 shadow-none",t==null?void 0:t.className),disabled:!0,ref:x,value:b.toString(),placeholder:t==null?void 0:t.placeholder}),c.jsx(he,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:Y,children:c.jsx(Xi,{})}),c.jsx(he,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>j(t==null?void 0:t.prefix),children:c.jsx(UtA,{className:"text-primary font-bold"})})]})]});case"input":default:return c.jsxs("div",{className:"w-full flex gap-1 items-stretch",children:[(e==null?void 0:e.prefix)&&c.jsx("span",{className:S("flex items-center p-2 opacity-70 text-sm"),children:e.prefix}),(e==null?void 0:e.type)=="date"?c.jsx(Wp,{defaultValue:l,onChange:E=>{const N=Me(E,"yyyy-MM-dd");v({type:"SET_VALUE",payload:N}),m&&m(N)}}):c.jsx(hn,{type:"text",defaultValue:l,...e,value:b,onChange:E=>{z(E),m&&m(E.target.value)},className:S("p-2 rounded-none bg-background border-0 focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none focus-visible:outline-none",e==null?void 0:e.className)})]})}};return c.jsxs("div",{className:S("waz_input_box w-full rounded border flex flex-col bg-muted text-[#101828]",{"flex-row justify-between items-center p-1 pr-4":u=="switch"},{"bg-background":u=="blogposts"||u=="wysiwyg"},{"border-none":u=="blogposts"||u=="inputgroup"},A),"data-testid":"input-box:"+d,children:[c.jsxs(Dz,{...a,className:S("waz_input_box_label p-2 border-b text-muted-foreground text-sm flex gap-2 items-center !opacity-100",{"border-none ":u=="switch"},{"hidden border-none":u=="blogposts"||u=="inputgroup"},{"bg-muted border-b-0 pb-0 ":u=="wysiwyg"},a==null?void 0:a.className),children:[o,P&&c.jsxs("span",{className:"flex items-center justify-center gap-1",children:[c.jsx(B0,{className:"text-destructive text-xl"}),c.jsx("span",{className:"capitalize text-xs text-muted-foreground",children:P==null?void 0:P.message})]})]}),C(),V&&c.jsx("div",{className:S("flex justify-end text-muted-foreground p-2 bg-background w-full text-sm",{"text-destructive font-bold":V.isOverLimit}),children:c.jsx("span",{className:"opacity-60",children:`${V.currentLength}/${f}`})}),u=="link"&&c.jsx(CnA,{})]})},hy=(A,e)=>e==="select"?Array.isArray(A)?A.every(t=>typeof t=="object"&&"label"in t&&"value"in t)?A:[]:typeof A=="object"&&A!==null&&"label"in A&&"value"in A?A:[]:e==="optionslist"?Array.isArray(A)?A.every(t=>typeof t=="object"&&"label"in t&&"value"in t)?A:[]:[]:e==="inputgroup"?Array.isArray(A)?A.every(t=>typeof t=="object"&&"id"in t)?A:[]:[]:e==="switch"?typeof A=="boolean"?A:A=="true":e==="image"?typeof A=="object"?A:{id:"",url:typeof A=="string"?A:"",title:"",caption:"",description:"",alternative_text:"",created_at:"",uuid:""}:e=="blogposts"?Array.isArray(A)?A:[]:typeof A=="number"?A:A==null?"":String(A),st=A=>{const e=hy(A.value,A.type),t=hy(A.defaultValue,A.type),n={defaultValue:e||t,onChange:A.onChange,imageGalleryConfig:A.imageGalleryConfig,blogPostsConfig:A.blogPostsConfig,selectProps:A.selectProps,apolloUri:A.apolloUri,validationError:A.validationError,label:A.label,linkProps:A.linkProps,error:A.error,inputGroupProps:A.inputGroupProps,sortableGroupProps:A.sortableGroupProps,className:A.className};if(A.apolloUri){let r;return A.type=="image"||A.type=="wysiwyg"?r=ns(A.apolloUri):r=na(A.apolloUri),c.jsx(EB,{client:r,children:c.jsx(dP,{...n,children:c.jsx(py,{...A})})})}return c.jsx(dP,{...n,children:c.jsx(py,{...A})})},gsA=Ne({filters:xl(Ne({column:iA(),operator:iA(),value:iA()}))});function vsA(){const[A,e]=w.useState(!1),[t,n]=w.useState(!1),r=[],[s,a]=w.useState(r);w.useEffect(()=>{n(!0)},[]);const{state:o,dispatch:i,filterFields:l=[]}=Aa(),{filter:{filters:u}}=o;w.useEffect(()=>{a(u.length?u:[{column:"",operator:"",value:"",label:""}])},[u]);function f(z){i({type:GA.SET_FILTER_FIELDS,payload:z})}function d(z,D,B){m(z,"value",B?[Me(D,"yyyy-MM-dd 00:00:00"),Me(B,"yyyy-MM-dd 00:00:00")]:Me(D,"yyyy-MM-dd 00:00:00"),{label:B?`${Me(D,"PPP")} and ${Me(B,"PPP")}`:Me(D,"PPP")})}function g(){s.length>=5||a([...s,{column:"",operator:"",value:"",label:""}])}function v(z){a(s.filter((D,B)=>B!==z))}function m(z,D,B,M){const Y=[...s],V=Y[z];V&&(D==="column"?Y[z]={...V,column:B,operator:"",value:"",label:"",rawValue:void 0,...M}:D==="operator"?Y[z]={...V,operator:B,value:"",label:"",...M}:Y[z]={...V,[D]:B,...M},a(Y))}function p(){const z=s.filter(D=>D.column&&D.operator&&(D.value||D.label));f(z),e(!1)}function h(){a(r)}const P=(z,D)=>{const B=s[z];if(!B)return;const M=l.find(C=>C.id===B.column);if(!M)return;const Y=Yp.includes((B==null?void 0:B.operator)??""),V=$q(D,M,B.operator);let j="";Y&&Array.isArray(D)?j=D.map(E=>E.label).join(", "):M.type===OA.SELECT&&typeof D=="object"&&D!==null?j=D.label:j=String(D||""),m(z,"value",V,{label:j,rawValue:D})},b=(z,D,B)=>{const M={label:"",value:z.rawValue,onChange:j=>P(D,j),className:"border border-border rounded overflow-hidden ",labelProps:{className:"hidden"}},Y=s[D],V=Yp.includes((Y==null?void 0:Y.operator)??"");if(V&&B.type!=OA.DATE)return c.jsx(st,{...M,type:"select",selectProps:{placeholder:"Select multiple...",searchPlaceholder:"Search options...",...B.selectProps,maximumLabelItems:1,multiple:!0}});switch(B==null?void 0:B.type){case OA.SELECT:return c.jsx(st,{...M,type:"select",selectProps:{placeholder:"Select value...",searchPlaceholder:"Search option...",...B.selectProps}});case OA.DATE:return c.jsxs("div",{className:"flex gap-2 flex-wrap lg:flex-nowrap items-center",children:[c.jsx(Wp,{defaultValue:V?z.value[1]:z.value,onChange:j=>d(D,j,V?new Date(z.value[1]||Date.now()):void 0)}),V&&c.jsxs(c.Fragment,{children:["and",c.jsx(Wp,{defaultValue:z.value[1],onChange:j=>d(D,new Date(z.value[0]||Date.now()),j)})]})]});case OA.NUMBER:default:return c.jsx(st,{...M,type:"input",inputProps:{type:B==null?void 0:B.type,placeholder:"Enter value...",className:"h-10"}})}},x=ug({resolver:Mg(gsA),defaultValues:{filters:r}});return t?c.jsxs(w9,{open:A,onOpenChange:e,children:[c.jsx(JD,{asChild:!0,children:c.jsx(MA,{variant:"ghost",className:"h-10 p-3 rounded-none bg-primary hover:bg-primary cursor-pointer",children:c.jsx(c3,{className:"text-xl"})})}),c.jsxs(P9,{className:"w-full sm:max-w-[95w] md:max-w-2xl p-0 rounded-l-xl border-0 overflow-auto flex flex-col",children:[c.jsxs(y9,{className:"flex flex-col items-start justify-start space-y-0 bg-secondary p-4",children:[c.jsx(b9,{children:c.jsx("h1",{className:"text-md",children:"Filter Options"})}),c.jsx(x9,{children:"Select your prefered options below"})]}),c.jsx(c9,{...x,children:c.jsxs("form",{onSubmit:x.handleSubmit(p),className:"grow flex flex-col justify-between p-4",children:[c.jsxs("div",{className:"space-y-4",children:[s.map((z,D)=>c.jsx(w.Fragment,{children:c.jsxs("div",{className:"space-y-3",children:[c.jsx(u9,{className:"flex gap-1 items-center text-base",htmlFor:`filter-${D}`,children:"Table Column"}),c.jsxs("div",{className:"grid grid-cols-[1fr_1fr_1fr_auto] gap-2 items-stretch",children:[c.jsx(fr,{children:c.jsxs(li,{value:z.column,onValueChange:B=>m(D,"column",B),children:[c.jsx(Ja,{className:"",children:c.jsx(ci,{placeholder:"Select column"})}),c.jsx(qa,{className:"!p-0",position:"popper",children:l.map(B=>c.jsx(cr,{value:B.id,className:"[&>span:first-child]:hidden p-4 border-b !m-0 w-full ",children:c.jsxs("div",{className:"flex items-center gap-4 ",children:[B.icon&&c.jsx("span",{className:"flex items-center justify-center",children:B.icon}),B.label]})},B.id))})]})}),c.jsx(fr,{children:c.jsxs(li,{value:z.operator,onValueChange:B=>m(D,"operator",B),children:[c.jsx(Ja,{children:c.jsx(ci,{placeholder:"Select operator"})}),c.jsx(qa,{children:AR(l.find(B=>B.id===z.column)).map(B=>c.jsx(cr,{value:B.id,className:"[&>span:first-child]:hidden p-2 text-sm",children:B.label},B.id))})]})}),c.jsx(fr,{children:b(z,D,l.find(B=>B.id===z.column))}),s.length>1&&c.jsx(MA,{type:"button",variant:"ghost",size:"icon",onClick:()=>v(D),children:c.jsx(Nn,{className:"h-4 w-4 text-destructive"})})]})]})},D)),c.jsxs(MA,{type:"button",variant:"outline",size:"sm",onClick:g,className:"flex items-center gap-2 rounded border mt-4 cursor-pointer",children:[c.jsx(Ao,{className:"h-4 w-4"}),"Add Filter"]})]}),c.jsxs(qD,{className:"w-full flex flex-row justify-between items-center mt-auto",children:[c.jsx(MA,{variant:"outline",type:"button",className:"rounded flex-1 border cursor-pointer h-10",onClick:h,children:"Clear all filters"}),c.jsx(MA,{className:"rounded flex-1 border cursor-pointer h-10",type:"submit",children:"Apply Filters"})]})]})})]})]}):c.jsx(MA,{variant:"ghost",className:"h-10 p-3 rounded-none bg-primary hover:bg-primary cursor-pointer",disabled:!0,children:c.jsx(c3,{className:"text-xl"})})}function msA(){const{filterFields:A,postType:e=""}=Aa();return A!=null&&A.length?c.jsxs("div",{className:"flex w-40 md:w-74 items-center gap-0 border rounded relative bg-background overflow-hidden",children:[c.jsx(hn,{placeholder:`Filter ${e}...`,className:"w-19 h-10 flex-1 text-xs px-3 rounded-none border-none bg-muted hover:bg-transparent disabled:opacity-100 focus:bg-transparent focus:rounded-r-none",disabled:!0}),c.jsx(vsA,{})]}):null}function psA(A){return UA({attr:{viewBox:"0 0 15 15",fill:"none"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M4.10876 14L9.46582 1H10.8178L5.46074 14H4.10876Z",fill:"currentColor"},child:[]}]})(A)}const H0=({url:A,pageTitle:e})=>{const t=A.split("/"),n=t.length;return c.jsx(Ez,{className:"bg-muted w-fit p-2 !m-0 rounded waz_shadow slight_border !border-[#E3E3E3]",children:c.jsx(Hz,{className:"md:gap-1",children:t.map((r,s)=>{if(s<n-1){const a=t.slice(0,s+1).join("/");return c.jsxs(y.Fragment,{children:[c.jsx(mp,{children:c.jsx(Nz,{asChild:!0,className:"hover:underline cursor-pointer",onClick:()=>window.location.href=a,children:c.jsx("span",{children:s?c.jsx("span",{className:"capitalize opacity-70 text-sm",children:r}):c.jsx(WtA,{className:"text-md text-muted-foreground"})})})}),c.jsx(Zz,{children:c.jsx(psA,{height:"10px",className:"text-3xl text-muted-foreground"})})]},s)}else return c.jsx(mp,{children:c.jsx(kz,{className:"capitalize text-sm text-[#4D4D4D]",children:e||r})},s)})})})},hsA={table:{sorting:[],columnFilters:[],columnVisibility:{},pagination:{pageIndex:0,pageSize:0}},view:"list",search:{inputValue:"",searchTerm:""},filter:{status:2,filters:[]},totals:{draft:0,published:0,all:0,pages:1},delete:{dialogOpen:!1},activePost:null,selection:{selectedPosts:[],tableRowSelection:{}}};function wsA({config:A,pagination:e,searchTerm:t,statusFilter:n,postFilters:r}){const s=Dt(),a=A.variables;return Lg({queryKey:[A.cacheKey||A.dataKey,(a==null?void 0:a.blog_uuid)||(a==null?void 0:a.site_uuid),e.pageIndex,e.pageSize,t,n,r],placeholderData:wU,staleTime:120*1e3,gcTime:600*1e3,refetchOnMount:!1,refetchOnWindowFocus:!1,queryFn:async()=>{const o={blog_uuid:{eq:a==null?void 0:a.blog_uuid}};n!==2&&(o.status={eq:n.toString()}),r!=null&&r.length&&r.forEach(d=>{o[d.column]?o[d.column]={...o[d.column],[d.operator]:d.value}:o[d.column]={[d.operator]:d.value}});const i={...a,page:e.pageIndex+1,first:e.pageSize,search:t,filter:o,sort:[{field:"UPDATED_AT",order:"DESC"}]},{data:l,error:u}=await s.query({query:A.query,variables:i,fetchPolicy:"network-only"});if(l&&!u){const d=l[A.dataKey];if(d){const{data:g,paginatorInfo:v}=d;return{tableData:g.map(p=>{var P;const h={totalPageViews:0,shares:0,isLoading:!1};if(p.metadata){const b=p.metadata,x=FT(typeof b=="string"?b:JSON.stringify(b));h.totalPageViews=(P=x==null?void 0:x.analytics)==null?void 0:P.totalPageViews}return{...p,statistics:h}}),pagination:v}}}if(u)throw u;const f=l[A.dataKey];return f?{tableData:f.data,pagination:f.paginatorInfo}:{tableData:[],pagination:{total:0,count:0,currentPage:1,hasMorePages:!1,lastPage:1,perPage:0}}}})}function PsA({config:A,fetchConfig:e,postTypeSng:t=""}){const n=ta(),r=Dt(),s=A==null?void 0:A.query,{showSuccess:a,showError:o}=$t();return ts({mutationFn:async i=>{if(s)return await r.mutate({mutation:s,variables:i});throw console.error("Invalid Query Configuration"),Error("Invalid Query Configuration")},onSuccess:i=>{i!=null&&i.data&&(n.invalidateQueries({queryKey:[(A==null?void 0:A.mutationInvalidateKey)||(e==null?void 0:e.cacheKey)||(e==null?void 0:e.dataKey)],refetchType:"all"}),a(`${t} Deleted`,`You have deleted the ${t} successfully`,{cancelText:"Done"}))},onError:i=>{console.log(i),n.invalidateQueries({queryKey:[(A==null?void 0:A.mutationInvalidateKey)||(e==null?void 0:e.cacheKey)||(e==null?void 0:e.dataKey)],refetchType:"all"}),o(`Failed to Delete ${t||"Post"}`,`An unexpected error occurred while deleting the ${t}.`,{confirmText:"Try Again",onAction:()=>{console.log("Retry create post")}})}})}const ysA={minItemsPerPage:6,maxItemsPerPage:50,tableHeaderHeight:20,tableRowHeight:80,gridCardHeight:300,gridGap:16,minCardWidth:288},bsA=A=>{const[e,t]=y.useState({width:1920,height:1080}),[n,r]=y.useState({tableRows:0,gridCards:0,cols:0,cardWidth:0}),s=y.useCallback((a,o)=>{const i={...ysA,...A};if(a===0||o===0)return{tableRows:0,gridCards:0,cols:0,cardWidth:0};const l=i.minCardWidth||290,u=i.gridGap||16,d=Math.ceil(Math.max(1,Math.floor(a/(l+u)))),g=Math.ceil(Math.max(1,o/(i.gridCardHeight+u))),v=d*u-u,m=a-v-d*l,p=l+Math.floor(m/d),h=Math.max(i.minItemsPerPage,Math.min(i.maxItemsPerPage,Math.floor((o-i.tableHeaderHeight)/i.tableRowHeight))),P=Math.max(i.minItemsPerPage,Math.min(i.maxItemsPerPage,d*g));return{tableRows:h,gridCards:P,cols:d,cardWidth:p}},[A]);return y.useEffect(()=>{if(typeof document>"u")return;const a=document.getElementById("blog-content-area");if(!a)return;const o=()=>{const{clientWidth:l,clientHeight:u}=a;t({width:l,height:u}),r(s(l,u))},i=new ResizeObserver(()=>o());return i.observe(a),()=>i.disconnect()},[s]),{...n,...e,getItemsPerPage:a=>a==="list"?n.tableRows:n.gridCards}};function wy({children:A,queryConfig:e,filterFields:t,postType:n,postTypeSng:r,isSelect:s,baseUrl:a="",defaultState:o,columns:i,onSave:l,onCreateClick:u,onEditClick:f,selectedPosts:d=[],gridCardHeight:g,tableRowHeight:v,gridCardWidth:m,authors:p}){const h=y.useRef(!1),[P,b]=y.useState(null),x=y.useRef(!0),z={};g&&(z.gridCardHeight=g),m&&(z.minCardWidth=m),v&&(z.tableRowHeight=v);const{getItemsPerPage:D,cardWidth:B,cols:M}=bsA(z),[Y,V]=y.useState(!1),j={...hsA,...o||{},view:Y?L7((o==null?void 0:o.view)||"list",n):(o==null?void 0:o.view)||"list"},C=D(j.view);C>0&&(j.table.pagination.pageSize=C);const[E,N]=y.useReducer(Kq,j),{table:{sorting:q,columnFilters:I,columnVisibility:G,pagination:H},search:{inputValue:T,searchTerm:Z},filter:{status:O,filters:k},selection:{selectedPosts:X,tableRowSelection:J},totals:F,view:eA}=E,R=typeof window<"u"?window.location:{search:"",pathname:""},tA=bA=>{typeof window<"u"&&window.history.replaceState({},"",bA)};y.useEffect(()=>{d&&d.length>0&&x.current&&(N({type:GA.SET_SELECTED_POSTS,payload:d}),x.current=!1)},[d]),y.useEffect(()=>{V(!0);const bA=L7((o==null?void 0:o.view)||"list",n);bA!==eA&&N({type:GA.SET_VIEW,payload:bA})},[]);const{data:K,isLoading:$,isFetching:_,error:U}=wsA({config:e.fetch,pagination:H,searchTerm:Z,statusFilter:O,postFilters:k}),wA=PsA({config:e.delete,fetchConfig:e.fetch,postTypeSng:r});function HA(bA){N({type:GA.SET_SORTING,payload:typeof bA=="function"?bA(q):bA})}function CA(bA){N({type:GA.SET_COLUMN_FILTERS,payload:typeof bA=="function"?bA(I):bA})}function SA(bA){N({type:GA.SET_COLUMN_VISIBILITY,payload:typeof bA=="function"?bA(G):bA})}function de(bA){const Je=typeof bA=="function"?bA(H):bA;N({type:GA.SET_PAGINATION,payload:Je})}function Bt(bA){N({type:GA.SET_VIEW,payload:bA}),Fq(bA,n)}const xe=y.useCallback(bA=>{N({type:GA.SET_ACTIVE_POST,payload:bA}),N({type:GA.SET_DELETE_DIALOG_OPEN,payload:!0})},[]),Q=y.useCallback(bA=>{N({type:GA.SET_ACTIVE_POST,payload:bA}),f?f(bA):window.location.href=`${a}/${bA.uuid}`},[f,a]);function AA(bA){N({type:GA.SET_DELETE_DIALOG_OPEN,payload:bA}),bA||N({type:GA.SET_ACTIVE_POST,payload:null})}async function nA(){var bA,Je;try{await wA.mutateAsync({uuid:((bA=E.activePost)==null?void 0:bA.uuid)||((Je=E.activePost)==null?void 0:Je.id)}),AA(!1)}catch(Be){console.error("Error deleting post:",Be)}}const fA=y.useCallback(bA=>{const Be=typeof bA=="function"?bA(J):bA;N({type:GA.SET_TABLE_ROW_SELECTION,payload:Be});const St=K!=null&&K.tableData.length?K==null?void 0:K.tableData:(K==null?void 0:K.tableData)||[],Mt=[...X];St.forEach((Ct,en)=>{const Xt=Be[en.toString()],Yt=Mt.findIndex(se=>se.uuid===Ct.uuid);Xt&&Yt===-1?Mt.push(Ct):!Xt&&Yt!==-1&&Mt.splice(Yt,1)}),N({type:GA.SET_SELECTED_POSTS,payload:Mt})},[X,J,K==null?void 0:K.tableData]);y.useEffect(()=>{s&&(K!=null&&K.tableData)&&N({type:GA.UPDATE_SELECTION_FROM_UUIDS,payload:{tableData:K.tableData}})},[K==null?void 0:K.tableData,X,s,K==null?void 0:K.tableData]);const cA=y.useMemo(()=>Uq({onEdit:Q,onDelete:xe,baseUrl:a}),[Q,xe,a]),lA=_q(),vA=gB({data:K!=null&&K.tableData&&K.tableData.length>0?K.tableData:(K==null?void 0:K.tableData)??[],columns:s?[lA,...i]:[...i,cA],pageCount:F.pages,getCoreRowModel:lB(),getPaginationRowModel:fB(),onSortingChange:HA,onColumnFiltersChange:CA,onColumnVisibilityChange:SA,onPaginationChange:de,getSortedRowModel:dB(),getFilteredRowModel:uB(),onRowSelectionChange:fA,state:{sorting:q,columnFilters:I,columnVisibility:G,pagination:H,rowSelection:J},manualPagination:!0,enableRowSelection:s,meta:{pageCount:F.pages}}),IA=()=>{l==null||l(X)},RA=()=>{u?u():window.location.href=a+"/new"},DA=()=>X.length,ge=()=>{N({type:GA.CLEAR_ALL_SELECTIONS})},ne=D(eA);y.useEffect(()=>{P||vA.setPageSize(ne)},[ne,v,g,m,e.fetch.dataKey,P,vA]),y.useEffect(()=>{if(K&&K.pagination&&K.pagination.lastPage!==void 0){const bA={draft:O===0?K.pagination.total:F.draft,published:O===1?K.pagination.total:F.published,all:O===2?K.pagination.total:F.all,pages:K.pagination.lastPage};N({type:GA.UPDATE_TOTALS,payload:bA}),vA&&bA.pages!==F.pages&&vA.resetPageIndex(),K.pagination.perPage!==H.pageSize&&N({type:GA.SET_PAGINATION,payload:{pageIndex:H.pageIndex,pageSize:K.pagination.perPage}})}},[K==null?void 0:K.pagination,O,F.all,F.draft,F.published,H.pageIndex,H.pageSize]),y.useEffect(()=>{if(!vA||h.current)return;const bA=new URLSearchParams(R.search),Je=[];let Be,St=0,Mt=0,Ct;bA.forEach((Xt,Yt)=>{if(Yt.startsWith("filter_")){const se=Yt.replace("filter_",""),[_e,...TA]=Xt.split(":"),ce=TA.join(":");if(se&&_e&&ce!==void 0){const ue=Sq(se,ce,t,p);Je.push({column:se,operator:_e,value:ce,label:ue})}}else if(Yt==="search")Be=Xt;else if(Yt==="page"){const se=parseInt(Xt);isNaN(se)||(St=Math.max(0,se-1))}else if(Yt==="pageSize"){const se=parseInt(Xt);isNaN(se)||(Mt=se,b(se))}else if(Yt==="status"){const se=parseInt(Xt,10);isNaN(se)||(Ct=se)}}),Mt===void 0&&b(null),Je.length>0&&N({type:GA.SET_FILTER_FIELDS,payload:Je}),N({type:GA.SET_SEARCH_TERM,payload:Be||""}),N({type:GA.SET_STATUS_FILTER,payload:Ct??2}),(()=>{if(vA&&vA.setPageIndex&&vA.setPageSize)if(St>0&&vA.setPageIndex(St),Mt)vA.setPageSize(Mt);else{const Xt=D(j.view);vA.setPageSize(Xt)}})(),h.current=!0},[]),y.useEffect(()=>{if(!h.current)return;const bA=new URLSearchParams;bA.set("page",String((H.pageIndex||0)+1)),bA.set("pageSize",String(H.pageSize)),bA.set("status",String(O)),T!=null&&T.trim()&&bA.set("search",T),Array.isArray(k)&&k.forEach(Be=>{Be!=null&&Be.column&&Be.value!==void 0&&Be.value!==null&&Be.value!==""&&bA.set(`filter_${Be.column}`,`${Be.operator}:${Be.value}`)});const Je=`${R.pathname}?${bA.toString()}`;Je!==R.pathname+R.search&&tA(Je)},[H.pageIndex,H.pageSize,O,T,k]);const Te={state:E,dispatch:N,queryConfig:e,filterFields:t,postType:n,postTypeSng:r,isSelect:s,baseUrl:a,table:vA,queryData:K,isLoading:$,isFetching:_,error:U,deleteMutation:wA,dynamicPageSize:ne,handleSortingChange:HA,handleColumnFiltersChange:CA,handleColumnVisibilityChange:SA,handlePaginationChange:de,handleViewChange:Bt,handleDeleteClick:xe,handleEditClick:Q,handleDeleteDialogClose:AA,handleSave:IA,handleCreate:RA,handleDeleteConfirm:nA,getSelectedPostsCount:DA,clearAllSelections:ge,authors:p||[],calculatedGridCardWidth:B,calculatedGridCardCols:M};return c.jsx(E5.Provider,{value:Te,children:A})}function xsA(A){return UA({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M.5 0a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-1 0V.5A.5.5 0 0 1 .5 0M2 1.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-4a.5.5 0 0 1-.5-.5zm2 4a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-7a.5.5 0 0 1-.5-.5zm2 4a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-6a.5.5 0 0 1-.5-.5zm2 4a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-7a.5.5 0 0 1-.5-.5z"},child:[]}]})(A)}function Na(A){return UA({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M6.445 12.688V7.354h-.633A13 13 0 0 0 4.5 8.16v.695c.375-.257.969-.62 1.258-.777h.012v4.61zm1.188-1.305c.047.64.594 1.406 1.703 1.406 1.258 0 2-1.066 2-2.871 0-1.934-.781-2.668-1.953-2.668-.926 0-1.797.672-1.797 1.809 0 1.16.824 1.77 1.676 1.77.746 0 1.23-.376 1.383-.79h.027c-.004 1.316-.461 2.164-1.305 2.164-.664 0-1.008-.45-1.05-.82zm2.953-2.317c0 .696-.559 1.18-1.184 1.18-.601 0-1.144-.383-1.144-1.2 0-.823.582-1.21 1.168-1.21.633 0 1.16.398 1.16 1.23"},child:[]},{tag:"path",attr:{d:"M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5M2 2a1 1 0 0 0-1 1v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1z"},child:[]},{tag:"path",attr:{d:"M2.5 4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5H3a.5.5 0 0 1-.5-.5z"},child:[]}]})(A)}function Fu(A){return UA({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3"},child:[]}]})(A)}function zsA(A){return UA({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M6 1H1v14h5zm9 0h-5v5h5zm0 9v5h-5v-5zM0 1a1 1 0 0 1 1-1h5a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1zm9 0a1 1 0 0 1 1-1h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1zm1 8a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1z"},child:[]}]})(A)}function Py({rootClassName:A,rowClassName:e,cardClassName:t,cellClassName:n,postBaseURL:r="",gridCard:s,toggleView:a=!0,showCTA:o=!0,tableRowHeight:i}){var Z,O,k,X,J,F;const{state:l,postType:u,postTypeSng:f="",isSelect:d,baseUrl:g,table:v,isLoading:m,isFetching:p,error:h,handleViewChange:P,handleDeleteClick:b,handleEditClick:x,handleDeleteDialogClose:z,handleSave:D,handleDeleteConfirm:B,deleteMutation:M,handleCreate:Y,getSelectedPostsCount:V,clearAllSelections:j,authors:C,calculatedGridCardWidth:E,calculatedGridCardCols:N,dynamicPageSize:q}=Aa(),{view:I,search:{searchTerm:G},delete:{dialogOpen:H}}=l,T=V();return c.jsxs("div",{className:S("relative h-screen flex flex-col overflow-auto bg-background",A),children:[c.jsxs("div",{className:S("flex flex-1 flex-col gap-y-5 p-4 overflow-auto h-full "),"data-testid":"blog-component",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsx("h1",{className:"text-3xl font-[UniversalFeature]","data-testid":"page-title",children:u||"Posts"}),g&&c.jsx(H0,{url:g,pageTitle:u})]}),c.jsxs("div",{className:"flex items-center justify-between w-full gap-4","data-testid":"blog-component-header",children:[c.jsx(Yq,{}),c.jsx("div",{className:"flex-1",children:c.jsx(msA,{})}),a&&c.jsxs("div",{className:"flex items-center p-1.5 px-2 slight_border rounded !border-[#efefef]","data-testid":"view-toggle",children:[c.jsx(he,{variant:"ghost",size:"icon",className:S("w-fit h-7 p-2 rounded group",{"bg-muted":I==="grid"}),onClick:()=>P("grid"),"data-testid":"grid-view-button",children:c.jsx(zsA,{className:S("group:hover:text-muted",{"text-muted-foreground":I==="grid"})})}),c.jsx(he,{variant:"ghost",size:"icon",className:S("w-fit h-7 p-2 rounded",{"bg-muted":I==="list"}),onClick:()=>P("list"),"data-testid":"list-view-button",children:c.jsx(zh,{className:S({"text-muted-foreground":I==="list"})})})]}),o&&c.jsxs("div",{className:"flex items-center gap-2",children:[d&&T>0&&c.jsx(he,{onClick:j,size:"lg",variant:"outline",className:"text-base rounded","data-testid":"clear-selections-button",children:"Clear"}),c.jsx("a",{href:d?void 0:`${g}/new`,onClick:eA=>eA.preventDefault(),children:c.jsxs(he,{onClick:d?D:Y,size:"lg",variant:"primary",className:"text-base rounded","data-testid":"action-button",children:[d?`Save${T>0?` (${T})`:""}`:"Create"," ",f]})})]})]}),c.jsx(eR,{}),c.jsxs("div",{className:"relative flex-1 h-0 overflow-auto",id:"blog-content-area","data-testid":"content-area",children:[(m||p||!q)&&c.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-secondary/10 backdrop-blur-sm","data-testid":"loading-overlay",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dh,{className:"w-6 h-6 animate-spin"}),c.jsx("span",{children:"Loading..."})]})}),h&&c.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/50 backdrop-blur-sm","data-testid":"error-overlay",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ts,{className:"w-6 h-6 animate-spin"}),c.jsxs("span",{children:["Error: ",h==null?void 0:h.message]})]})}),(O=(Z=v.getRowModel())==null?void 0:Z.rows)!=null&&O.length?I==="list"?c.jsx(kq,{table:v,cellClassName:n,rowClassName:S(e,{[`h-[${i}px]`]:i}),"data-testid":"data-table",onEdit:x}):c.jsx("div",{className:S("grid flex-1 gap-4 relative"),style:{gridTemplateColumns:`repeat(${N||0}, ${E||288}px)`},"data-testid":"grid-view",children:(X=(k=v.getRowModel())==null?void 0:k.rows)==null?void 0:X.map(eA=>{const R=eA.original,tA=C==null?void 0:C.find(K=>(K==null?void 0:K.uuid)==R.author_uuid);return s&&c.jsx(s,{data:{...R,author:tA},className:S("w-full",t),onDeleteClick:b,postBaseURL:r,blogBaseUrl:g,onEditClick:x,isSelect:d,selected:eA.getIsSelected(),onSelect:()=>eA.toggleSelected()},eA.id)})}):c.jsx(Xq,{search:G,filters:l.filter.filters})]})]}),(F=(J=v.getRowModel())==null?void 0:J.rows)!=null&&F.length?c.jsx(rq,{}):null,c.jsx(tR,{open:H,onOpenChange:z,onConfirm:B,pending:M.isPending})]})}function Cr(A){const{queryConfig:e,filterFields:t,postType:n,postTypeSng:r,isSelect:s,baseUrl:a,defaultState:o,columns:i,onSave:l,selectedPosts:u,gridCardHeight:f,gridCardWidth:d,tableRowHeight:g,onCreateClick:v,onEditClick:m,authors:p,...h}=A,[P]=y.useState(()=>new Ig),b={queryConfig:e,filterFields:t,postType:n,postTypeSng:r,isSelect:s,baseUrl:a,defaultState:o,columns:i,onSave:l,onCreateClick:v,onEditClick:m,selectedPosts:u,tableRowHeight:g,gridCardWidth:d,gridCardHeight:f,authors:p};if(A.apolloUri){const x=na(A.apolloUri);return c.jsx(Qg,{client:P,children:c.jsx(EB,{client:x,children:c.jsx(wc,{children:c.jsx(wy,{...b,children:c.jsx(Py,{...h,tableRowHeight:g})})})})})}return c.jsx(wc,{children:c.jsx(wy,{...b,children:c.jsx(Py,{...h,tableRowHeight:g})})})}var DsA=["date","verboseDate","tooltip","children"];function R2(){return R2=Object.assign||function(A){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(A[n]=t[n])}return A},R2.apply(this,arguments)}function BsA(A,e){if(A==null)return{};var t=MsA(A,e),n,r;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(A);for(r=0;r<s.length;r++)n=s[r],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(A,n)&&(t[n]=A[n])}return t}function MsA(A,e){if(A==null)return{};var t={},n=Object.keys(A),r,s;for(s=0;s<n.length;s++)r=n[s],!(e.indexOf(r)>=0)&&(t[r]=A[r]);return t}function zd(A,e){var t=A.date,n=A.verboseDate,r=A.tooltip,s=A.children,a=BsA(A,DsA),o=y.useMemo(function(){return t.toISOString()},[t]);return y.createElement("time",R2({ref:e},a,{dateTime:o,title:r?n:void 0}),s)}zd=y.forwardRef(zd);zd.propTypes={date:VA.instanceOf(Date).isRequired,verboseDate:VA.string,tooltip:VA.bool.isRequired,children:VA.string.isRequired};var yy=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function CsA(A,e){return!!(A===e||yy(A)&&yy(e))}function jsA(A,e){if(A.length!==e.length)return!1;for(var t=0;t<A.length;t++)if(!CsA(A[t],e[t]))return!1;return!0}function OsA(A,e){e===void 0&&(e=jsA);var t=null;function n(){for(var r=[],s=0;s<arguments.length;s++)r[s]=arguments[s];if(t&&t.lastThis===this&&e(r,t.lastArgs))return t.lastResult;var a=A.apply(this,r);return t={lastResult:a,lastArgs:r,lastThis:this},a}return n.clear=function(){t=null},n}function W2(A){"@babel/helpers - typeof";return W2=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},W2(A)}function TsA(A){if(rj())return Intl.DateTimeFormat.supportedLocalesOf(A)[0]}function rj(){var A=(typeof Intl>"u"?"undefined":W2(Intl))==="object";return A&&typeof Intl.DateTimeFormat=="function"}function Dd(A){"@babel/helpers - typeof";return Dd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dd(A)}function EsA(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}function HsA(A,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(A,n.key,n)}}function NsA(A,e,t){return e&&HsA(A.prototype,e),Object.defineProperty(A,"prototype",{writable:!1}),A}var sj=(function(){function A(){EsA(this,A),this.cache={}}return NsA(A,[{key:"get",value:function(){for(var t=this.cache,n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];for(var a=0,o=r;a<o.length;a++){var i=o[a];if(Dd(t)!=="object")return;t=t[i]}return t}},{key:"put",value:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var s=n.pop(),a=n.pop(),o=this.cache,i=0,l=n;i<l.length;i++){var u=l[i];Dd(o[u])!=="object"&&(o[u]={}),o=o[u]}return o[a]=s}}]),A})(),by=new sj,ksA=rj(),ZsA=function(e){return e.toString()};function VsA(A,e){if(!ksA)return ZsA;var t=XsA(A),n=JSON.stringify(e),r=by.get(String(t),n)||by.put(String(t),n,new Intl.DateTimeFormat(t,e));return function(s){return r.format(s)}}const SsA=OsA(VsA);var Gm={};function XsA(A){var e=A.toString();return Gm[e]?Gm[e]:Gm[e]=TsA(A)}function F2(A){"@babel/helpers - typeof";return F2=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},F2(A)}function YsA(A){return GsA(A)?A:new Date(A)}function GsA(A){return A instanceof Date||IsA(A)}function IsA(A){return F2(A)==="object"&&typeof A.getTime=="function"}var xy=new sj;function QsA(A,e){var t=e.polyfill,n=String(A)+":"+String(t);return xy.get(n)||xy.put(n,new Ie(A,{polyfill:t}))}var vl={exports:{}},ca={exports:{}},LsA=ca.exports,zy;function JsA(){return zy||(zy=1,(function(){var A,e,t,n,r,s;typeof performance<"u"&&performance!==null&&performance.now?ca.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(ca.exports=function(){return(A()-r)/1e6},e=process.hrtime,A=function(){var a;return a=e(),a[0]*1e9+a[1]},n=A(),s=process.uptime()*1e9,r=n-s):Date.now?(ca.exports=function(){return Date.now()-t},t=Date.now()):(ca.exports=function(){return new Date().getTime()-t},t=new Date().getTime())}).call(LsA)),ca.exports}var Dy;function qsA(){if(Dy)return vl.exports;Dy=1;for(var A=JsA(),e=typeof window>"u"?Mf:window,t=["moz","webkit"],n="AnimationFrame",r=e["request"+n],s=e["cancel"+n]||e["cancelRequest"+n],a=0;!r&&a<t.length;a++)r=e[t[a]+"Request"+n],s=e[t[a]+"Cancel"+n]||e[t[a]+"CancelRequest"+n];if(!r||!s){var o=0,i=0,l=[],u=1e3/60;r=function(f){if(l.length===0){var d=A(),g=Math.max(0,u-(d-o));o=g+d,setTimeout(function(){var v=l.slice(0);l.length=0;for(var m=0;m<v.length;m++)if(!v[m].cancelled)try{v[m].callback(o)}catch(p){setTimeout(function(){throw p},0)}},Math.round(g))}return l.push({handle:++i,callback:f,cancelled:!1}),i},s=function(f){for(var d=0;d<l.length;d++)l[d].handle===f&&(l[d].cancelled=!0)}}return vl.exports=function(f){return r.call(e,f)},vl.exports.cancel=function(){s.apply(e,arguments)},vl.exports.polyfill=function(f){f||(f=e),f.requestAnimationFrame=r,f.cancelAnimationFrame=s},vl.exports}var RsA=qsA();const By=jc(RsA);function WsA(A,e){if(A.length===0)return 0;for(var t=0,n=A.length-1,r;t<=n;){r=Math.floor((n+t)/2);var s=e(A[r]);if(s===0)return r;if(s<0){if(t=r+1,t>n)return t}else if(n=r-1,n<t)return t}}function FsA(A,e){return $sA(A)||_sA(A,e)||UsA(A,e)||KsA()}function KsA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
434
434
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function UsA(A,e){if(A){if(typeof A=="string")return My(A,e);var t=Object.prototype.toString.call(A).slice(8,-1);if(t==="Object"&&A.constructor&&(t=A.constructor.name),t==="Map"||t==="Set")return Array.from(A);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return My(A,e)}}function My(A,e){(e==null||e>A.length)&&(e=A.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=A[t];return n}function _sA(A,e){var t=A==null?null:typeof Symbol<"u"&&A[Symbol.iterator]||A["@@iterator"];if(t!=null){var n=[],r=!0,s=!1,a,o;try{for(t=t.call(A);!(r=(a=t.next()).done)&&(n.push(a.value),!(e&&n.length===e));r=!0);}catch(i){s=!0,o=i}finally{try{!r&&t.return!=null&&t.return()}finally{if(s)throw o}}return n}}function $sA(A){if(Array.isArray(A))return A}const AaA={instances:[],add:function(e){var t=this,n=this.instances.length===0;return aj(this.instances,e),n&&this.start(),{stop:function(){oj(t.instances,e),t.instances.length===0&&t.stop()},forceUpdate:function(){Cy(e,t.instances)}}},tick:function(){for(var e=Date.now();;){var t=this.instances[0];if(e>=t.nextUpdateTime)Cy(t,this.instances);else break}},scheduleNextTick:function(){var e=this;this.scheduledTick=By(function(){e.tick(),e.scheduleNextTick()})},start:function(){this.scheduleNextTick()},stop:function(){By.cancel(this.scheduledTick)}};function eaA(A){var e=A.getNextValue(),t=FsA(e,2),n=t[0],r=t[1];A.setValue(n),A.nextUpdateTime=r}function Cy(A,e){eaA(A),oj(e,A),aj(e,A)}function aj(A,e){var t=taA(A,e);A.splice(t,0,e)}function oj(A,e){var t=A.indexOf(e);A.splice(t,1)}function taA(A,e){var t=e.nextUpdateTime;return WsA(A,function(n){return n.nextUpdateTime===t?0:n.nextUpdateTime>t?1:-1})}function Ku(A,e){return aaA(A)||saA(A,e)||raA(A,e)||naA()}function naA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
435
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function raA(A,e){if(A){if(typeof A=="string")return jy(A,e);var t=Object.prototype.toString.call(A).slice(8,-1);if(t==="Object"&&A.constructor&&(t=A.constructor.name),t==="Map"||t==="Set")return Array.from(A);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return jy(A,e)}}function jy(A,e){(e==null||e>A.length)&&(e=A.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=A[t];return n}function saA(A,e){var t=A==null?null:typeof Symbol<"u"&&A[Symbol.iterator]||A["@@iterator"];if(t!=null){var n=[],r=!0,s=!1,a,o;try{for(t=t.call(A);!(r=(a=t.next()).done)&&(n.push(a.value),!(e&&n.length===e));r=!0);}catch(i){s=!0,o=i}finally{try{!r&&t.return!=null&&t.return()}finally{if(s)throw o}}return n}}function aaA(A){if(Array.isArray(A))return A}function oaA(A){var e=A.date,t=A.future,n=A.locale,r=A.locales,s=A.timeStyle,a=A.round,o=A.minTimeLeft,i=A.formatVerboseDate,l=A.verboseDateFormat,u=l===void 0?caA:l,f=A.updateInterval,d=A.tick,g=d===void 0?!0:d,v=A.now,m=A.timeOffset,p=m===void 0?0:m,h=A.polyfill,P=y.useMemo(function(){return n&&(r=[n]),r.concat(Ie.getDefaultLocale())},[n,r]),b=y.useMemo(function(){return QsA(P,{polyfill:h})},[P,h]);e=y.useMemo(function(){return YsA(e)},[e]);var x=y.useCallback(function(){var G=(v||Date.now())-p,H;if(t&&G>=e.getTime()&&(G=e.getTime(),H=!0),o!==void 0){var T=e.getTime()-o*1e3;G>T&&(G=T,H=!0)}var Z=b.format(e,s,{getTimeToNextUpdate:!0,now:G,future:t,round:a}),O=Ku(Z,2),k=O[0],X=O[1];return H?X=laA:X=f||X||60*1e3,[k,G+X]},[e,t,s,f,a,o,b,v]),z=y.useRef();z.current=x;var D=y.useMemo(x,[]),B=Ku(D,2),M=B[0],Y=B[1],V=y.useState(M),j=Ku(V,2),C=j[0],E=j[1],N=y.useRef();y.useEffect(function(){if(g)return N.current=AaA.add({getNextValue:function(){return z.current()},setValue:E,nextUpdateTime:Y}),function(){return N.current.stop()}},[g]),y.useEffect(function(){if(N.current)N.current.forceUpdate();else{var G=x(),H=Ku(G,1),T=H[0];E(T)}},[x]);var q=y.useMemo(function(){return SsA(P,u)},[P,u]),I=y.useMemo(function(){return i?i(e):q(e)},[e,i,q]);return{date:e,formattedDate:C,verboseDate:I}}var iaA=365*24*60*60*1e3,laA=1e3*iaA,caA={weekday:"long",day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"},K2=VA.oneOfType,Oy=VA.arrayOf,Oo=VA.string,Ty=VA.number,Ol=VA.shape,Uu=VA.func,uaA=K2([Ol({minTime:Ty,formatAs:Oo.isRequired}),Ol({test:Uu,formatAs:Oo.isRequired}),Ol({minTime:Ty,format:Uu.isRequired}),Ol({test:Uu,format:Uu.isRequired})]),faA=K2([Oo,Ol({steps:Oy(uaA).isRequired,labels:K2([Oo,Oy(Oo)]).isRequired,round:Oo})]),daA=["date","future","timeStyle","round","minTimeLeft","locale","locales","formatVerboseDate","verboseDateFormat","updateInterval","tick","now","timeOffset","polyfill","tooltip","component","container","wrapperComponent","wrapperProps"];function Bd(){return Bd=Object.assign||function(A){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(A[n]=t[n])}return A},Bd.apply(this,arguments)}function gaA(A,e){if(A==null)return{};var t=vaA(A,e),n,r;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(A);for(r=0;r<s.length;r++)n=s[r],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(A,n)&&(t[n]=A[n])}return t}function vaA(A,e){if(A==null)return{};var t={},n=Object.keys(A),r,s;for(s=0;s<n.length;s++)r=n[s],!(e.indexOf(r)>=0)&&(t[r]=A[r]);return t}function xc(A){var e=A.date,t=A.future,n=A.timeStyle,r=A.round,s=A.minTimeLeft,a=A.locale,o=A.locales,i=o===void 0?[]:o,l=A.formatVerboseDate,u=A.verboseDateFormat,f=A.updateInterval,d=A.tick,g=A.now,v=A.timeOffset,m=A.polyfill,p=A.tooltip,h=p===void 0?!0:p,P=A.component,b=P===void 0?zd:P,x=A.container,z=A.wrapperComponent,D=A.wrapperProps,B=gaA(A,daA),M=oaA({date:e,future:t,timeStyle:n,round:r,minTimeLeft:s,locale:a,locales:i,formatVerboseDate:l,verboseDateFormat:u,updateInterval:f,tick:d,now:g,timeOffset:v,polyfill:m}),Y=M.date,V=M.verboseDate,j=M.formattedDate,C=y.createElement(b,Bd({date:Y,verboseDate:V,tooltip:h},B),j),E=z||x;return E?y.createElement(E,Bd({},D,{verboseDate:V}),C):C}xc.propTypes={date:VA.oneOfType([VA.instanceOf(Date),VA.number]).isRequired,locale:VA.string,locales:VA.arrayOf(VA.string),future:VA.bool,timeStyle:faA,round:VA.string,minTimeLeft:VA.number,component:VA.elementType,tooltip:VA.bool,formatVerboseDate:VA.func,verboseDateFormat:VA.object,updateInterval:VA.oneOfType([VA.number,VA.arrayOf(VA.shape({threshold:VA.number,interval:VA.number.isRequired}))]),tick:VA.bool,now:VA.number,timeOffset:VA.number,polyfill:VA.bool,wrapperComponent:VA.elementType,wrapperProps:VA.object};xc=y.memo(xc);const vu=({categories:A=[],maxDisplay:e=2,badgeVariant:t="outline"})=>{const n=A.slice(0,e),r=A.length-n.length;return c.jsxs("div",{className:"gap-2 flex flex-row items-center",children:[!n.length&&c.jsx(at,{variant:t,className:"line-clamp-1 text-sm text-[#869DA5] p-1 px-3 truncate font-normal",children:"none"}),n.map((s,a)=>c.jsx("div",{className:S("p-1 rounded-full text-sm px-3 truncate font-normal max-w-20 xxl:max-w-24",{"bg-[#FDF2FA] text-[#C11574]":!((a+1)%2)},{"bg-[#EEF4FF] text-[#3538CD]":(a+1)%2}),children:s.name},s.uuid||a)),r>0&&c.jsxs("p",{className:"text-sm text-[#869DA5]",children:["+",r]})]})},_i=({tags:A=[],maxDisplay:e=2,badgeVariant:t="outline"})=>{const n=A.slice(0,e),r=A.length-n.length;return c.jsxs("div",{className:"gap-1 flex flex-row items-center",children:[!n.length&&c.jsx(at,{variant:t,className:"line-clamp-1 text-sm p-1 px-3 truncate font-normal text-[#869DA5]",children:"none"}),n.map((s,a)=>c.jsx(at,{variant:t,className:"line-clamp-1 text-[#869DA5] text-sm p-1 px-3 truncate font-normal max-w-20 xxl:max-w-24",children:s.name},s.uuid||a)),r>0&&c.jsxs("p",{className:"text-sm text-[#869DA5]",children:["+",r]})]})},mu=({statistics:A,className:e,isGrid:t})=>{const n=Eo((A==null?void 0:A.totalPageViews)??0);return A!=null&&A.isLoading?c.jsxs("div",{className:S("w-full flex flex-row gap-1 text-[#596970] justify-center items-center",{"justify-start":!t},e),children:[c.jsx(Dh,{size:12,className:"animate-spin"}),c.jsx("p",{className:"font-[UniversalFeature] text-xs",children:"Loading..."})]}):!(A!=null&&A.totalPageViews)&&!(A!=null&&A.shares)?c.jsx("p",{className:S("text-xs p-1",e),children:"No statistics"}):c.jsxs("div",{className:S(`w-full flex flex-row gap-3 text-[#596970] ${t?"justify-center":"justify-start"} items-center`,e),children:[c.jsxs("div",{className:"flex flex-row items-center justify-center gap-1",children:[c.jsx(IR,{className:"text-sm"}),c.jsx("p",{className:"font-[UniversalFeature] text-xs",children:n})]}),c.jsxs("div",{className:"flex flex-row items-center justify-center gap-1",children:[c.jsx(yAA,{className:"text-sm"}),c.jsx("p",{className:"font-[UniversalFeature] text-xs",children:"0"})]})]})};function N0({data:A,className:e,onDeleteClick:t,postBaseURL:n="",blogBaseUrl:r="",isSelect:s,selected:a,onSelect:o,onEditClick:i}){var u;let l={};try{l=JSON.parse(A==null?void 0:A.featured_image)}catch(f){console.log(f)}return c.jsxs(hr,{className:S("max-w-[450px] flex flex-col cursor-pointer group justify-between overflow-hidden rounded-md focus:border-accent focus:border focus:bg-[#BEFEF72B] hover:border-accent hover:border hover:bg-[#BEFEF72B] ",e),"data-testid":"post-card:"+A.uuid,onDoubleClick:()=>i==null?void 0:i(A),children:[c.jsxs("div",{className:"flex flex-col grow",children:[c.jsxs(Es,{className:"p-0 relative h-[178px]",children:[c.jsx(at,{variant:"outline",className:S("text-xs absolute z-10 top-2 left-2 bg-muted text-muted-foreground",{hidden:A.status}),children:"Draft"}),c.jsx(MA,{variant:"ghost",size:"icon","data-active":a,"data-testid":"post-select",className:S("rounded-md shadow-[0px_4.29px_12.86px_0px_#00000012] bg-background w-7 h-7 absolute top-2 right-2 z-10",{hidden:!s},{"bg-primary":a}),onClick:()=>o==null?void 0:o(A),children:c.jsx("div",{className:"flex items-center justify-center w-4 h-4 border-2 rounded-full border-foreground",children:a&&c.jsx("div",{className:"w-2 h-2 rounded-full bg-foreground"})})}),c.jsxs("div",{className:S("flex items-center gap-1 absolute top-2 right-2 z-10",{hidden:s}),children:[c.jsx("a",{href:`${r}/${A.uuid}`,onClick:f=>f.preventDefault(),className:"leading-0",children:c.jsx(MA,{variant:"ghost",size:"icon",className:"rounded-md shadow-[0px_4.29px_12.86px_0px_#00000012] bg-background w-7 h-7",onClick:()=>i==null?void 0:i(A),children:c.jsx(Xi,{size:"small",className:"text-accent-foreground"})})}),c.jsx(MA,{variant:"ghost",size:"icon",className:"rounded-md shadow-[0px_4.29px_12.86px_0px_#00000012] bg-background w-7 h-7",onClick:()=>t==null?void 0:t(A),children:c.jsx(tv,{size:"small",className:"text-destructive"})})]}),c.jsx(qi,{url:l==null?void 0:l.src,transformations:{height:178}}),c.jsx("div",{className:"absolute bottom-0 left-0 px-2 rounded-tr-[0.75rem] bg-white opacity-90",children:c.jsx(mu,{statistics:A.statistics,className:"h-7 p-2 text-[#101828]",isGrid:!0})})]}),c.jsxs(Hs,{className:"p-2 flex flex-col gap-1.5 grow justify-between align-top flex-1",children:[c.jsx("a",{className:"text-base leading-tight cursor-pointer group-hover:underline hover:underline line-clamp-3",href:n+A.slug,target:"_blank",rel:"noopener noreferrer",children:Wr(A.title)}),c.jsx("p",{className:"flex-1 my-auto text-sm leading-tight line-clamp-3",children:Wr(A.excerpt)})]})]}),c.jsxs(Fd,{className:"flex flex-row justify-between p-2 items-baseline-last ",children:[c.jsxs("div",{className:"flex flex-row items-start justify-between gap-2 text-muted-foreground",children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("p",{className:"text-[10px]",children:"Categories"}),c.jsx(vu,{categories:A.categories,maxDisplay:1})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("p",{className:"text-[10px]",children:"Tags"}),c.jsx(_i,{tags:A.tags,maxDisplay:1,badgeVariant:"outline"})]})]}),c.jsxs("div",{className:"flex items-center justify-between gap-2 text-muted-foreground",children:[c.jsx("div",{className:"flex items-center justify-center w-4.5 h-4.5 font-semi-bold rounded-full bg-secondary",children:c.jsx("p",{className:"text-[8px] text-black",children:Bi(((u=A.author)==null?void 0:u.name)||"")})}),c.jsx(xc,{date:new Date(A.updated_at||""),locale:"en-US",className:"text-xs"})]})]})]})}const maA=({onEdit:A,onDelete:e,editDisabled:t=!1,deleteDisabled:n=!1})=>c.jsxs("div",{className:"flex items-center",children:[c.jsx(MA,{variant:"ghost",size:"icon",onClick:A,disabled:t,children:c.jsx(qZ,{color:"gray",size:"small"})}),c.jsx(MA,{variant:"ghost",size:"icon",onClick:e,disabled:n,children:c.jsx(Nn,{color:"red",size:"small"})})]}),paA={theme:"system",setTheme:()=>null},ij=y.createContext(paA);function haA({children:A,defaultTheme:e="system",storageKey:t="vite-ui-theme",...n}){const[r,s]=y.useState(()=>typeof window<"u"&&window.localStorage.getItem(t)||e);y.useEffect(()=>{const o=window.document.documentElement;if(o.classList.remove("light","dark","brand"),r==="system"){const i=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";o.classList.add(i);return}o.classList.add(r)},[r]);const a={theme:r,setTheme:o=>{window.localStorage.setItem(t,o),s(o)}};return c.jsx(ij.Provider,{...n,value:a,children:A})}const waA=()=>{const A=y.useContext(ij);if(A===void 0)throw new Error("useTheme must be used within a ThemeProvider");return A},PaA=new Ig;function yaA({children:A}){return c.jsx(Qg,{client:PaA,children:A})}const baA=new Ig,xaA=A=>c.jsx(Qg,{client:baA,children:c.jsx(A,{})});function zaA(A,e){const t=Dt();return Lg({staleTime:12e4,gcTime:12e4,queryKey:[(A==null?void 0:A.cacheKey)||(A==null?void 0:A.dataKey),e],queryFn:async()=>{var n;if(A!=null&&A.query&&(A!=null&&A.variables)&&e){const r=A==null?void 0:A.query,s=A==null?void 0:A.variables,o=(await t.query({query:r,variables:{...s||{},uuid:e},fetchPolicy:"network-only"})).data[A.dataKey];if((n=o==null?void 0:o.config)!=null&&n.related_recipes_config)try{const i=JSON.parse(o.config.related_recipes_config);if(Array.isArray(i)&&i.length>0){const f=(i[0]==="AUTO"?i.slice(1):i).map(v=>t.query({query:r,variables:{uuid:v},fetchPolicy:"network-only"})),g=(await Promise.all(f)).map(v=>{var h;return(h=v.data)==null?void 0:h[A.dataKey]}).filter(v=>v!=null).map(v=>({uuid:v.uuid,value:v.uuid,title:v.title,label:v.title}));return{...o,_relatedRecipesData:g}}}catch(i){console.error("Error fetching related recipes:",i)}return o}else throw new Error("No query or variables provided")},refetchOnMount:!1,refetchOnWindowFocus:!1})}function DaA({config:A,baseUrl:e,postType:t,createMessage:n,showDescription:r=!0,onSuccess:s}){const a=ta(),o=Dt(),i=A==null?void 0:A.query,{showSuccess:l,showError:u}=$t();return ts({mutationFn:async f=>{if(i)return await o.mutate({mutation:i,variables:{...A.variables||{},...f}})},onSuccess:(f,d)=>{var P;const g=(P=f==null?void 0:f.data)==null?void 0:P[(A==null?void 0:A.dataKey)||"createPost"],v=(d==null?void 0:d.status)||(d==null?void 0:d.titleStatus)||!1,m=(d==null?void 0:d.showActionModals)??!0,p="You have published your article successfully.",h="You have saved your article as draft successfully. You can publish your article when ready!";if(a.invalidateQueries({queryKey:[A==null?void 0:A.mutationInvalidateKey],refetchType:"all"}),m&&l(n||`${t||"Article"} ${v?"Published":"Saved as draft"}`,r?v?p:h:void 0,{type:v?"action":"info",confirmText:`View ${t||"Article"}`,cancelText:"Done",onCancel:()=>{!v&&e||(e?window.location.href=e:window.history.back())},onAction:()=>{const b=`${e||"/blog/articles"}/${g==null?void 0:g.uuid}`;window.location.href=b}}),!v){const b=window.location.pathname,x=b.endsWith("/new")?b.replace("/new",`/${g==null?void 0:g.uuid}`):`${b}/${g==null?void 0:g.uuid}`;window.history.replaceState(null,"",x)}s==null||s(d,g==null?void 0:g.uuid)},onError:(f,d)=>{console.error(f),((d==null?void 0:d.showActionModals)??!0)&&u(`Failed to Create ${t||"Article"}`,f.message||"An unexpected error occurred while creating the post.",{confirmText:"Try Again",onAction:()=>{console.log("Retry create post")}})}})}function BaA({config:A,fetchConfig:e,postBaseUrl:t,baseUrl:n,updateMessage:r,postType:s="Article",showDescription:a=!0,onSuccess:o,user_config:i}){const l=ta(),u=Dt(),f=A==null?void 0:A.query,{showSuccess:d,showError:g}=$t(),v=lj(t,i);return ts({mutationFn:async m=>{if(f)return await u.mutate({mutation:f,variables:{...A.variables||{},...m}})},onSuccess:(m,p)=>{var D;const h=(p==null?void 0:p.showActionModals)??!0,P=(D=m==null?void 0:m.data)==null?void 0:D[(A==null?void 0:A.dataKey)||"updatePost"],b=(p==null?void 0:p.status)||(p==null?void 0:p.titleStatus)||!1,x="You have published your article successfully.",z="You have saved your article as draft successfully. You can publish your article when ready!";l.invalidateQueries({queryKey:[A==null?void 0:A.mutationInvalidateKey],refetchType:"all"}),l.invalidateQueries({queryKey:[(e==null?void 0:e.cacheKey)||(e==null?void 0:e.dataKey)],refetchType:"all"}),h&&d(r||`${s||"Article"} ${b?"Published":"Updated"} Successfully!`,a?b?x:z:void 0,{type:b?"action":"info",cancelText:"Done",confirmText:`View ${s||"Article"}`,onAction:()=>{const B=`${n||"/blog/articles"}/${P==null?void 0:P.uuid}`;window.location.href=B}}),o==null||o(p),console.log(p.updated_fields),v&&b&&v(P==null?void 0:P.slug,!!(p!=null&&p.is_autosave),p.updated_fields)},onError:(m,p)=>{console.error(m),((p==null?void 0:p.showActionModals)??!0)&&g(`Failed to Update ${s||"Article"}`,m.message||"An unexpected error occurred while updating the post.",{confirmText:"Retry",onAction:()=>{console.log("Retry update post")}})}})}const lj=(A,e)=>{A!=null&&A.length&&A.endsWith("/")&&(A=A.slice(0,-1));const{showError:t,showSuccess:n}=$t(),r=async(s,a,o,i=!1)=>{const l=A.includes("vt")?`${s}`:`${s?`/recipes${s}`:"/"}`;return await Xe.post(`${A}/api/revalidate`,{slug:l.trim(),username:`${e==null?void 0:e.name}${a?"-autosave":""}`,email:e==null?void 0:e.email,date:new Date().toLocaleString(),updated_fields:`${o}`.split(",").filter(u=>u),token:A.includes("vt")?re.NEXT_PUBLIC_REVALIDATION_VT_TOKEN:re.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN}).then(u=>(i&&n("Cache cleared sucessfully","",{type:"action",confirmText:"View Page",cancelText:"Done",onAction:()=>{var f;(f=window==null?void 0:window.open)==null||f.call(window,`${A}${l}`,"_blank")}}),u)).catch(u=>{throw t("Failed to revalidate cache",u.message,{}),u})};if(A)return r},MaA=({storageKey:A,form:e,enabled:t=!0,interval:n=6e4,onSave:r,onError:s})=>{const[a,o]=y.useState(null),[i,l]=y.useState(null),u=y.useRef(null),f=y.useRef(null),d=y.useRef(""),g=y.useCallback(()=>`autosave_enabled_${A}`,[A]),v=y.useCallback(()=>{if(typeof window>"u"||typeof localStorage>"u")return t;try{const B=localStorage.getItem(g());if(B!==null)return JSON.parse(B)}catch(B){console.error("Failed to load autosave enabled state from localStorage:",B)}return t},[g,t]),m=y.useCallback(B=>{if(!(typeof window>"u"||typeof localStorage>"u"))try{localStorage.setItem(g(),JSON.stringify(B))}catch(M){console.error("Failed to save autosave enabled state to localStorage:",M)}},[g]),[p,h]=y.useState(()=>v()),P=y.useCallback(B=>{h(B),m(B)},[m]),b=y.useCallback(async()=>{if(p)try{const B=e.getValues(),M=JSON.stringify(B),Y=new Date;await(r==null?void 0:r(B)),d.current=M,l(Y),o({status:"saved"})}catch(B){const M=B instanceof Error?B:new Error("Failed to save form data");console.error("Failed to save form data to sessionStorage:",M),o({status:"error",error:M}),s==null||s(M)}},[p,e,r,s]),x=y.useCallback(async()=>{await b()},[b]),z=y.useCallback(()=>{!p||!e.formState.isDirty||(a==null?void 0:a.status)=="error"||(o({status:"saving"}),f.current=setTimeout(()=>{b()},5e3))},[p,e.formState.isDirty,b,a]),D=()=>{const B=e.getValues("updated_at");B&&l(new Date(B))};return y.useEffect(()=>{if(!p||e.getValues("updated_at"))return;D();const B=e.watch((M,{values:Y,type:V})=>{const j=JSON.stringify(Y);if(V=="change"&&j!==d.current)try{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{z()},n),o({status:"pending"})}catch(C){console.error("Error in form watch subscription:",C)}});return()=>{console.log("Cleaning up autosave..."),u.current&&clearTimeout(u.current),f.current&&clearTimeout(f.current),B.unsubscribe()}},[p,n,e]),{state:a,saveNow:x,lastSaveDate:i,autoSaveEnabled:p,updateLastSave:D,toggleEnableAutoSave:P}},CaA={isDraft:!0,isCreate:!0,activeGroupId:"",formValues:{},sectionStates:{}},jaA=(A,e)=>{switch(e.type){case"SET_ACTIVE_GROUP":return{...A,activeGroupId:e.payload};case"SET_FORM_VALUES":return{...A,formValues:{...A.formValues,...e.payload}};case"TOGGLE_DRAFT":return{...A,isDraft:e.payload};case"PUBLISH_POST":return{...A,isDraft:!1,isCreate:!1};case"SAVE_DRAFT":return{...A,isDraft:!0,isCreate:!1};case"SET_UUID":return{...A,uuid:e.payload};default:return A}},cj=y.createContext(void 0),ao=()=>{const A=y.useContext(cj);if(A===void 0)throw new Error("useBlogPost must be used within a BlogPostProvider");return A},dt=[];for(let A=0;A<256;++A)dt.push((A+256).toString(16).slice(1));function OaA(A,e=0){return(dt[A[e+0]]+dt[A[e+1]]+dt[A[e+2]]+dt[A[e+3]]+"-"+dt[A[e+4]]+dt[A[e+5]]+"-"+dt[A[e+6]]+dt[A[e+7]]+"-"+dt[A[e+8]]+dt[A[e+9]]+"-"+dt[A[e+10]]+dt[A[e+11]]+dt[A[e+12]]+dt[A[e+13]]+dt[A[e+14]]+dt[A[e+15]]).toLowerCase()}let Im;const TaA=new Uint8Array(16);function EaA(){if(!Im){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Im=crypto.getRandomValues.bind(crypto)}return Im(TaA)}const HaA=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ey={randomUUID:HaA};function NaA(A,e,t){var r;if(Ey.randomUUID&&!A)return Ey.randomUUID();A=A||{};const n=A.random??((r=A.rng)==null?void 0:r.call(A))??EaA();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,OaA(n)}const kaA=({hasUnsavedChanges:A,onSave:e,onDiscard:t})=>{const[n,r]=y.useState(!1),[s,a]=y.useState("/new-page");y.useEffect(()=>{const u=d=>{if(A)return d.preventDefault(),!0},f=d=>{if(A)throw a(d),r(!0),"Route change aborted by user."};if(A&&(window.addEventListener("beforeunload",u),typeof window<"u")){try{const d=window.__NEXT_ROUTER__;d!=null&&d.events&&d.events.on("routeChangeStart",f)}catch{console.debug("Next.js router not available in standalone environment")}return()=>{window.removeEventListener("beforeunload",u);try{const d=window.__NEXT_ROUTER__;d!=null&&d.events&&d.events.off("routeChangeStart",f)}catch{console.debug("Next.js router cleanup not needed in standalone environment")}}}return()=>{window.removeEventListener("beforeunload",u)}},[A]);const o=async()=>{try{await(e==null?void 0:e()),r(!1),typeof window<"u"&&(window.location.href=s)}catch(u){console.error("Save failed:",u)}},i=()=>{t==null||t(),r(!1),typeof window<"u"&&(window.location.href=s)},l=()=>{r(!1)};return c.jsx(c.Fragment,{children:c.jsx(_t,{open:n,onOpenChange:l,children:c.jsxs(Vt,{className:"max-w-[500px] p-0 overflow-hidden gap-6",children:[c.jsx(Ln,{className:"bg-secondary p-5 py-5 items-start",children:c.jsx(Jn,{children:c.jsx("h1",{className:"text-md",children:"Unsaved Changes"})})}),c.jsx(Ag,{className:"px-5",children:"You have unsaved changes that will be lost"}),c.jsx("div",{className:"px-5",children:c.jsx("div",{className:"bg-muted rounded p-3 border border-bg-muted-foreground mb-4",children:c.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[c.jsx("span",{children:"Navigating to:"}),c.jsx("div",{className:"flex items-center space-x-1 bg-background p-2 rounded border-bg-muted-foreground border",children:c.jsx("span",{className:" ",children:s})})]})})}),c.jsxs(Dr,{className:"flex flex-row p-4 pt-0 gap-4 justify-end",children:[c.jsx(he,{variant:"outline",className:"rounded capitalize",onClick:o,children:"save and continue"}),c.jsx(he,{variant:"primary",className:"rounded capitalize",onClick:i,children:"Discard and continue"})]})]})})})},ZaA=({children:A,type:e,initialState:t={},validators:n,requiredDraftFields:r,postQueryConfig:s,formFieldsMapper:a,submitFieldsMapper:o,onBack:i,groups:l,mainForm:u,showTitle:f,baseUrl:d,postBaseUrl:g,isPopup:v,actionButtonTitle:m,showDraft:p,formTitle:h,createMessage:P,updateMessage:b,showDescriptionOnSubmit:x,autoSave:z=!1,onChange:D,user_config:B})=>{var tA;const M=t.uuid||((tA=t.formValues)==null?void 0:tA.uuid),Y=!M||M==="new",[V,j]=y.useReducer(jaA,{...CaA,...t,isCreate:Y}),C=ug({...n&&{resolver:Mg(n)},defaultValues:V.formValues,reValidateMode:"onChange",mode:"onChange"}),E=MaA({storageKey:`${e}_${V.uuid||"new"}`,form:C,enabled:z&&V.isDraft&&!V.isCreate,interval:3e4,onSave:async()=>{C.setValue("status",!V.isDraft),C.setValue("is_autosave",!0),await O(V.isCreate,!1),V.isCreate||await T({titleOnly:!1,showActionModals:!1}),C.setValue("is_autosave",!1)}}),N=zaA(s==null?void 0:s.fetch,V.uuid),q=(K,$)=>{j({type:C.getValues("status")?"PUBLISH_POST":"SAVE_DRAFT"}),$&&j({type:"SET_UUID",payload:$})},I=DaA({config:s==null?void 0:s.create,baseUrl:d,postType:e,createMessage:P,showDescription:x,onSuccess:q});let G=BaA({config:s==null?void 0:s.update,fetchConfig:s==null?void 0:s.fetch,postBaseUrl:g,baseUrl:d,postType:e,updateMessage:b,showDescription:x,onSuccess:q,user_config:B});s!=null&&s.update||(G=I);const{showError:H}=$t();async function T({titleOnly:K,showActionModals:$=!0}){try{const _=V.isCreate;let U=C.getValues("uuid");U||(U=_?NaA():V.uuid||M||"",C.setValue("uuid",U),j({type:"SET_UUID",payload:U}));const wA=C.getValues(),HA=Object.keys(C.formState.dirtyFields),CA=o?o(wA):wA;if(CA.showActionModals=$,CA.is_autosave=wA==null?void 0:wA.is_autosave,CA.updated_fields=HA.join(","),K){const SA={uuid:CA.uuid,blog_uuid:CA.blog_uuid,author_uuid:CA.author_uuid,slug:CA.slug,title:CA.title,titleStatus:!!CA.status,is_autosave:CA.is_autosave,updated_fields:CA.updated_fields};_?await I.mutateAsync(SA):await G.mutateAsync(SA)}else _?await I.mutateAsync(CA):await G.mutateAsync(CA);C.reset(wA)}catch(_){console.error(_);const U=_ instanceof Error?_.message:String(_);H("Error while saving article",U)}}const Z=y.useMemo(()=>{const K=l!=null&&l.length?l==null?void 0:l.flatMap(_=>_.sections.flatMap(U=>U.formItems)):[],$=u!=null&&u.sections?u==null?void 0:u.sections.flatMap(_=>_.formItems):[];return[...K,...$]},[l,u]),O=async(K=!1,$=!0)=>{const _=C.getValues("status");C.clearErrors();const U=await C.trigger(_?void 0:r),CA=`Validation error on field(s): ${Object.keys(C.formState.errors).map(SA=>SA).map(SA=>{const de=Z.find(Bt=>Bt.name==SA);return de?de.label:SA}).join(", ")}. Please fix all issues before submitting.`;if(!U){$&&H(`Failed to ${K?"Create":"Update"} ${e||"Article"}`,CA);const SA=new Error(CA);throw SA.cause="Form validation failed",SA.message=CA,SA}return U},k=async(K=!0)=>{C.setValue("status",!1),await O(V.isCreate),await T({titleOnly:!1,showActionModals:K})},X=async()=>{C.setValue("status",!0),C.setValue("published_at",new Date().toLocaleString()),await O(V.isCreate),await T({titleOnly:!1})},J=async()=>{C.setValue("status",!!C.getValues("status")),await O(V.isCreate),await T({titleOnly:!0})},F=()=>{i==null||i()},eA=()=>{if(!N.data)return;const K=a?a(N.data):N.data||Object.create(null);C.reset(K),E.updateLastSave(),j({type:K!=null&&K.status?"PUBLISH_POST":"SAVE_DRAFT"});const $=Object.entries(K).reduce((U,[wA,HA])=>({...U,[wA]:HA}),{});j({type:"SET_FORM_VALUES",payload:$});const _=C.getValues("status");E.toggleEnableAutoSave(!_)},R=()=>{eA()};return y.useEffect(()=>{var $,_;const K=()=>{const U=window.location.hash.replace("#","");U&&l&&l.some(wA=>wA.id===U)&&j({type:"SET_ACTIVE_GROUP",payload:U})};return!V.activeGroupId&&l&&l.length>0?(j({type:"SET_ACTIVE_GROUP",payload:($=l==null?void 0:l[0])==null?void 0:$.id}),window.location.hash=(_=l==null?void 0:l[0])==null?void 0:_.id):K(),window.addEventListener("hashchange",K),()=>{window.removeEventListener("hashchange",K)}},[V.activeGroupId,l,j]),y.useEffect(()=>{const K=C.watch(($,{name:_,values:U})=>{D==null||D(C,_,U)});return()=>K.unsubscribe()},[C,j,D]),y.useEffect(()=>{eA()},[N.isFetched]),c.jsxs(cj.Provider,{value:{state:V,initialState:t,type:e,dispatch:j,handleSaveDraft:k,handleSaveTitle:J,handlePublish:X,handleBack:F,form:C,postQuery:N,groups:l,mainForm:u,createMutation:I,updateMutation:G,showTitle:f,baseUrl:d,postBaseUrl:g,isPopup:v,formTitle:h,showDraft:p,actionButtonTitle:m,autosave:E,showAutoSave:z&&!V.isCreate&&V.isDraft},children:[A,c.jsx(kaA,{hasUnsavedChanges:C.formState.isDirty,onSave:C.getValues("status")?X:k,onDiscard:R})]})};function k0(A){return UA({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M170.718 216.482L141.6 245.6l93.6 93.6 208-208-29.118-29.118L235.2 279.918l-64.482-63.436zM422.4 256c0 91.518-74.883 166.4-166.4 166.4S89.6 347.518 89.6 256 164.482 89.6 256 89.6c15.6 0 31.2 2.082 45.764 6.241L334 63.6C310.082 53.2 284.082 48 256 48 141.6 48 48 141.6 48 256s93.6 208 208 208 208-93.6 208-208h-41.6z"},child:[]}]})(A)}const Z0=(A,e,t,n)=>{var l,u,f,d,g,v;const r=m=>{e.onChange?e.onChange(m,A):t.onChange(m)},s=t.value,a={...e,error:n.error,onChange:r,value:s,validationError:(l=n.error)==null?void 0:l.message},o=e.linkedField&&A.getValues(e.linkedField),i=()=>{o&&(s||A.setValue(e.name,o))};switch(e.type){case"switch":return c.jsx(st,{...a,className:S("w-full",e.className)});case"wysiwyg":return c.jsx(st,{...a,defaultValue:e.linkedField&&A.getValues(e.linkedField),className:S("w-full h-full",e.className),wysiwygProps:{...e.wysiwygProps,className:S("w-full p-0 bg-background border-none",(u=e.wysiwygProps)==null?void 0:u.className)}});case"custom":return(f=e.contentRender)==null?void 0:f.call(e,s);case"select":case"optionslist":case"image":case"blogposts":return c.jsx(st,{...a,className:S("w-full",e.className,{"[&_.waz-input-box-content]:opacity-30":!s&&o}),value:s||o});case"link":return c.jsx(st,{...a,className:S("w-full",e.className),linkProps:{...a.linkProps,placeholder:e.linkedField&&A.getValues(e.linkedField)||((d=a.linkProps)==null?void 0:d.placeholder),onFocus:o&&i,disabled:t.disabled}});case"textarea":return c.jsx(st,{...a,className:S("w-full",e.className),textareaProps:{...a.textareaProps,placeholder:o||((g=a.textareaProps)==null?void 0:g.placeholder),onFocus:o&&i,disabled:t.disabled}});default:return c.jsx(st,{...a,className:S("w-full",e.className),inputProps:{...a.inputProps,onKeyDown:m=>{var p;(p=e.onKeyDown)==null||p.call(e,m,A)},onFocus:o&&i,placeholder:o||((v=a.inputProps)==null?void 0:v.placeholder),disabled:t.disabled}})}},VaA=({section:A,item:e,itemIndex:t,form:n,onRemove:r,canRemove:s})=>{const[a,o]=y.useState(!0),i=()=>{o(!a)},{attributes:l,listeners:u,setNodeRef:f,transform:d,transition:g,isDragging:v}=dv({id:e.id}),m={transform:Gs.Transform.toString(d),transition:g};return c.jsxs("div",{ref:f,style:m,className:S("group relative border p-4 transition-all duration-200 rounded",{"bg-accent/50 border-2 border-accent shadow-lg":v}),children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[A.maxItems!==1&&c.jsx("div",{...l,...u,className:"cursor-grab active:cursor-grabbing p-1 rounded hover:bg-muted",children:c.jsx(xh,{className:"h-4 w-4 text-muted-foreground"})}),A.maxItems!==1?c.jsxs("p",{className:"",children:[c.jsxs("span",{className:"text-muted-foreground capitalize mr-1",children:[t+1,"."]}),c.jsxs("span",{className:"text-primary-foreground",children:[A.dynamicType," Group "]})]}):c.jsxs("span",{className:"text-primary-foreground",children:[A.dynamicType," "]})]}),c.jsxs("div",{className:"flex items-center",children:[s&&c.jsx(MA,{variant:"ghost",size:"sm",onClick:r,className:S("h-8 w-8 p-0 text-red-500 hover:text-red-700 hover:bg-red-50 transition-opacity","opacity-0 group-hover:opacity-100"),children:c.jsx(Nn,{className:"w-4 h-4"})}),A.collapsible&&c.jsx(MA,{variant:"ghost",size:"sm",onClick:i,className:S("h-8 w-8 p-0"),children:a?c.jsx(Ph,{}):c.jsx(Cz,{})})]})]}),c.jsx("div",{className:S("flex items-center flex-col gap-2",{hidden:!a},A.formItemsContainerClassName),children:A.formItems.map(p=>{const h=`${A.id}_${e.id}_${p.name}`;return c.jsx(eo,{control:n.control,name:h,render:({field:P,fieldState:b})=>{var x;return c.jsxs(fr,{className:S("flex flex-col w-full",p.containerClassname),children:[p.description&&c.jsx("p",{className:"text-muted-foreground w-full h-fit",children:p.description}),c.jsx(to,{className:"flex flex-1",children:Z0(n,p,P,b)}),b.error&&c.jsxs("div",{className:"flex items-center gap-2 mt-1 opacity-50",children:[c.jsx(hZ,{strokeWidth:2,className:"text-destructive"}),c.jsx("span",{className:"font-bold text-muted-foreground capitalize",children:(x=b.error)==null?void 0:x.message})]})]})}},h)})})]})};function uj(A){const e=/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)_(.+)$/,t=A.match(e);return t?{group_id:t[1],index:parseInt(t[2]||"0",10),fieldname:t[3]}:{group_id:"",index:0,fieldname:""}}function Qm(A=""){var n,r;if(!A||A.trim()==="")return{quantity:"",unit:""};if(A.includes("//")){const s=A.indexOf("//"),a=A.substring(0,s).trim(),o=A.substring(s).replace(/\/+/g,"").trim();return{quantity:a||"",unit:o}}const e=/^(\d+(?:\.\d+)?)\s*(.*)$/,t=A.match(e);if(t){const s=((n=t[2])==null?void 0:n.trim())||"";return{quantity:((r=t[1])==null?void 0:r.trim())||"",unit:s||"Custom"}}return{quantity:A.trim(),unit:"Custom"}}const SaA=({section:A})=>{const{form:e}=ao(),[t,n]=y.useState([{id:"0",values:A.template||{}}]);y.useEffect(()=>{const u=e.getValues(),f=A.formItems.map(g=>g.name),d=[];Object.entries(u).forEach(([g,v])=>{f.map(m=>{var p;if(g.includes(m)){const{index:h}=uj(g);d[h]?d[h]={id:h.toString(),values:{...(p=d[h])==null?void 0:p.values,[m]:v}}:d.push({id:h.toString(),values:{[m]:v}})}})}),d.length&&n(d)},[]);const r=u=>{const f=A.maxItems||1/0;if(t.length<f){const d={id:`${Date.now()}`,values:A.template||{}};if(u!==void 0&&u>=0&&u<=t.length){const g=[...t];g.splice(u+1,0,d);const v=g.map((m,p)=>({...m,id:p.toString()}));n(v)}else n([...t,d])}},s=u=>{const f=A.minItems||1;if(t.length>f){const g=t.filter(v=>v.id!==u).map((v,m)=>({...v,id:m.toString()}));n(g)}},a=sv(Is(Ui),Is(Ki,{coordinateGetter:gv}));function o(u){const{active:f,over:d}=u;if(f.id!==(d==null?void 0:d.id)&&(d!=null&&d.id)){const g=t.findIndex(z=>z.id===f.id),v=t.findIndex(z=>z.id===(d==null?void 0:d.id));if(g===-1||v===-1)return;const m=[...t],[p]=m.splice(g,1);if(!p)return;m.splice(v,0,p);const h=e.getValues(),P={...h},b=A.formItems.map(z=>z.name);Object.keys(h).forEach(z=>{b.forEach(D=>{z.includes(`${A.id}_`)&&z.includes(`_${D}`)&&delete P[z]})}),m.forEach((z,D)=>{b.forEach(B=>{const M=`${A.id}_${z.id}_${B}`,Y=`${A.id}_${D}_${B}`,V=h[M];V!==void 0&&(P[Y]=V)})});const x=m.map((z,D)=>({...z,id:D.toString()}));e.reset(P),n(x)}}const i=!A.maxItems||t.length<A.maxItems,l=t.length>(A.minItems||1);return c.jsxs(c.Fragment,{children:[A.description&&c.jsx("p",{className:"text-muted-foreground text-sm w-full",children:A.description}),c.jsx(cv,{sensors:a,collisionDetection:av,onDragEnd:o,children:c.jsx("div",{className:"relative space-y-2",children:c.jsx(fv,{items:t.map(u=>u.id),strategy:uv,children:t.map((u,f)=>c.jsxs("div",{children:[c.jsx(VaA,{section:A,item:u,itemIndex:f,form:e,onRemove:()=>s(u.id),canRemove:l}),i&&c.jsx("div",{className:S("group w-full min-h-1 hover:bg-muted hover:p-4",{" bg-muted p-4":f===t.length-1}),children:c.jsxs("div",{className:S("hidden group-hover:flex items-center justify-center gap-2 transition-all duration-200 text-xs",{flex:f===t.length-1}),children:[c.jsx(MA,{variant:"ghost",onClick:()=>r(f),size:"icon",className:"border border-primary bg-background rounded-full hover:bg-primary",children:c.jsx(Ao,{})}),"Add New Group"]})})]},u.id))})})})]})},XaA=({section:A})=>{const{form:e}=ao();return c.jsxs(c.Fragment,{children:[A.description&&c.jsx("p",{className:S("text-muted-foreground w-full h-fit",A.descriptionClassName),children:A.description}),A.formItems.map((t,n)=>c.jsx(eo,{control:e.control,name:t.name,render:({field:r,fieldState:s})=>c.jsxs(fr,{className:S("flex flex-col w-full",t.containerClassname),children:[t.description&&c.jsx("p",{className:"w-full h-fit leading-5",children:t.description}),c.jsx(to,{className:"flex flex-1",children:Z0(e,t,r,s)})]})},`${t.name}-${n}`))]})},YaA=({index:A,step:e,section:t,formField:n,disabled:r,onDelete:s})=>{var m;const{attributes:a,listeners:o,setNodeRef:i,transform:l,isDragging:u,isOver:f}=dv({id:e.id}),d={transform:Gs.Transform.toString(l)},{form:g}=ao(),v=(m=g.getValues(`${t.id}_${e.id}_${n==null?void 0:n.name}`))==null?void 0:m.toString();return c.jsx("div",{ref:i,style:d,...a,className:"sortable-item",children:c.jsxs("div",{className:S("group border-l-[2px] pt-4 pl-5 border-border bg-background relative z-10",{"border-primary-foreground":v==null?void 0:v.length,"bg-accent/50 border border-b-4 border-accent z-100":u,"z-1":f,"pt-0 ":!A}),children:[c.jsx("div",{...o,className:S("p-[7px] bg-background rounded-full absolute top-5 left-[-13px] z-10 cursor-grab active:cursor-grabbing",{"top-2":!A}),children:c.jsx("div",{className:S("p-[5px] rounded-full bg-primary-foreground",{"bg-background ":f})})}),c.jsx(eo,{control:g.control,name:`${t.id}_${e.id}_${n==null?void 0:n.name}`,disabled:r,render:({field:p,fieldState:h})=>c.jsx(fr,{className:S("flex flex-col w-full",n==null?void 0:n.containerClassname),children:c.jsx(to,{className:"flex flex-1",children:Z0(g,{...n,label:(n.label||"Step")+` ${A+1}`},p,h)})})}),c.jsx(MA,{variant:"ghost",size:"sm",onClick:s,className:S("hidden group-hover:flex absolute top-4 right-2 h-8 w-8 p-0 text-red-500 hover:text-red-700 hover:bg-transparent transition-opacity",{"top-0":!A}),children:c.jsx(Nn,{className:"w-4 h-4"})})]},e.id)})},GaA=({section:A})=>{const e=A.formItems[0],{form:t}=ao(),[n,r]=y.useState([]),s=()=>{const u={id:n.length.toString(),order:n.length,value:""};r([...n,u])},a=u=>{if(console.log(n,u),n.findIndex(m=>m.id===u)<=0)return;const g=n.filter(m=>m.id!==u).map((m,p)=>({...m,id:p.toString(),order:p}));r(g);const v=t.getValues();Object.keys(v).filter(m=>m.startsWith(`${A.id}_`)&&m.endsWith(`_${e==null?void 0:e.name}`)).forEach(m=>{t.unregister(m)}),g.forEach(m=>{t.setValue(`${A.id}_${m.id}_${e==null?void 0:e.name}`,m.value)})},o=sv(Is(Ui),Is(Ki,{coordinateGetter:gv}));function i(u){const{active:f,over:d}=u,g=[...n],v=n.findIndex(h=>h.id==(d==null?void 0:d.id)),m=n.findIndex(h=>h.id==(f==null?void 0:f.id)),p=n[m];p&&(g.splice(m,1),g.splice(v,0,p)),g.forEach((h,P)=>[t.setValue(`${A.id}_${P}_${e==null?void 0:e.name}`,h.value)])}const l=()=>{const u=t.getValues(),f=Object.keys(u).filter(d=>d.startsWith(`${A.id}_`)&&d.endsWith(`_${e==null?void 0:e.name}`)).sort();if(f.length===0){r([{id:"0",order:0,value:""}]);return}r(f.map((d,g)=>({id:g.toString(),order:g,value:u[d]||""})))};if(y.useEffect(()=>{l()},[]),y.useEffect(()=>{const u=t.watch((f,{name:d})=>{d!=null&&d.includes(A.id)&&l()});return()=>u.unsubscribe()},[t]),!!e)return c.jsxs("div",{className:"border-l-6 border-transparent",children:[c.jsx(cv,{sensors:o,collisionDetection:av,onDragEnd:i,children:c.jsx(fv,{items:n.map(u=>u.id),strategy:uv,children:n.map((u,f)=>{var d;return c.jsx(YaA,{index:f,step:u,section:A,formField:e,disabled:f?!((d=n[f-1])!=null&&d.value):!1,onDelete:()=>a(u.id)},u.id)})})}),c.jsx("div",{className:"relative py-2 pl-5 flex justify-start mt-2",children:c.jsxs(MA,{variant:"primary",onClick:s,children:[c.jsx(Ao,{className:"w-4 h-4"}),"Add another step"]})})]})},Hy=({main:A=!1,className:e=""})=>{var d,g,v,m;const{state:t,mainForm:n,groups:r}=ao(),{activeGroupId:s}=t,a=A?n:(d=r==null?void 0:r.find)==null?void 0:d.call(r,p=>p.id===s),[o,i]=y.useState(a?(v=(g=a==null?void 0:a.sections)==null?void 0:g[0])==null?void 0:v.id:""),l=a==null?void 0:a.sections,u=l?(m=l.filter)==null?void 0:m.call(l,p=>p.title):[];if(y.useEffect(()=>{var p;i(((p=l==null?void 0:l[0])==null?void 0:p.id)||"")},[a]),!a)return null;const f=p=>p.isDynamic&&p.dynamicType==="steps"?c.jsx(GaA,{section:p}):p.isDynamic?c.jsx(SaA,{section:p}):c.jsx(XaA,{section:p});return c.jsx("div",{className:S("w-full h-full overflow-auto flex p-4",e),children:c.jsxs(bg,{value:o,className:"flex flex-col w-0 flex-1 h-full no-scrollbar overflow-auto !p-0 gap-4",children:[c.jsx(Kc,{className:S("m-0 rounded-none bg-background h-fit gap-4 w-full overflow-x-auto justify-start shadow-none",{hidden:!u.length}),children:u.map(p=>p.title?c.jsxs(Uc,{className:"rounded-full flex gap-2 px-4 py-2 border border-primary opacity-50 data-[state=active]:opacity-100 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",value:p.id,onClick:()=>i(p.id),children:[p.icon&&c.jsx(MA,{variant:"ghost",disabled:!0,size:"icon",className:"h-5 w-5 p-0 disabled:opacity-100",children:p.icon}),p.title]},p.id):null)}),l==null?void 0:l.map(p=>c.jsx(xg,{value:p.id,className:S("flex flex-col max-w-full gap-4 h-0 overflow-auto flex-1 m-0",p.className),children:f(p)},p.id))]})})},IaA=(A=3)=>{const e=y.useRef(null);return y.useEffect(()=>{const t=e.current;if(!t)return;const{lineHeight:n}=getComputedStyle(t),r=parseFloat(n)*A,s=()=>{t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,r)}px`};return s(),t.addEventListener("input",s),t.addEventListener("focusin",s),()=>{t.removeEventListener("input",s),t.removeEventListener("focusin",s)}},[A]),e},QaA=()=>{var d,g,v,m,p,h,P,b,x,z,D,B,M,Y,V,j,C,E,N,q,I;const{autosave:A}=ao(),[e,t]=y.useState(!1);y.useEffect(()=>{t(!0)},[]);const n=()=>{A.toggleEnableAutoSave(!A.autoSaveEnabled)},[r,s]=y.useState(0),a=((d=A.state)==null?void 0:d.status)=="saving",o=((g=A.state)==null?void 0:g.status)=="pending",i=((v=A.state)==null?void 0:v.status)=="error",l=typeof((p=(m=A.state)==null?void 0:m.error)==null?void 0:p.cause)=="string"?(P=(h=A.state)==null?void 0:h.error)==null?void 0:P.cause:((x=(b=A.state)==null?void 0:b.error)==null?void 0:x.message)||"Autosave Error",{showError:u}=$t(),f=y.useCallback(()=>{var G,H;u(l,(H=(G=A.state)==null?void 0:G.error)==null?void 0:H.message)},[u,l,(D=(z=A.state)==null?void 0:z.error)==null?void 0:D.message]);return y.useEffect(()=>{s(G=>G+1)},[A.state]),e?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"group flex justify-end items-center min-w-70",children:[c.jsxs("div",{className:S("group-hover:hidden p-5 py-2 rounded-full border border-primary flex items-center text-sm gap-2",{"flex-wrap gap-y-0":a||o,hidden:!((B=A.state)!=null&&B.status)&&!A.lastSaveDate}),children:[c.jsx(qu,{className:"text-base"}),c.jsx("p",{className:S("hidden gap-1 items-center",{flex:!A.autoSaveEnabled}),children:"Autosave off"}),A.autoSaveEnabled&&c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:!((M=A.state)!=null&&M.status)&&A.lastSaveDate}),children:["Last Saved:",c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"dd-MM-yyyy")}),c.jsx(Fu,{className:"text-xs"}),c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"HH:mm:ss")})]}),c.jsxs("p",{className:S("hidden gap-1 items-center",{block:o||a}),children:["Autosave: ",a?"In Progress":"Waiting"]}),(a||o)&&c.jsx("div",{className:"relative h-[2px] w-full overflow-hidden rounded-full ",children:c.jsx("div",{className:"absolute inset-0 h-full w-full bg-primary",style:{animation:`wazui_progress_bar ${a?"5s":"30s"} ease-in-out`}})},`progress-${r}`),c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:((Y=A.state)==null?void 0:Y.status)=="saved"}),children:["Autosave Complete",c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"dd-mm-yyyy")}),c.jsx(Fu,{className:"text-xs"}),c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"HH:mm:ss")})]}),c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:i}),children:["Autosave",c.jsxs("span",{className:"text-destructive hover:underline max-w-50 truncate",onClick:f,children:["Error | ",l]})]})]})]}),c.jsxs("div",{className:S("hidden group-hover:invisible p-5 py-2 rounded-full border border-primary items-center text-sm gap-2",{"flex-wrap gap-y-0":a||o,flex:!((V=A.state)!=null&&V.status)&&!A.lastSaveDate&&!A.autoSaveEnabled}),children:[c.jsx(qu,{className:"text-base"}),c.jsx("p",{className:S("hidden gap-1 items-center",{flex:!A.autoSaveEnabled||!((j=A.state)!=null&&j.status)}),children:"Autosave off"}),A.autoSaveEnabled&&c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:!((C=A.state)!=null&&C.status)&&A.lastSaveDate}),children:["Last Saved:",c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"dd-MM-yyyy")}),c.jsx(Fu,{className:"text-xs"}),c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"HH:mm:ss")})]}),c.jsxs("p",{className:S("hidden gap-1 items-center",{block:o||a}),children:["Autosave: ",a?"In Progress":"Waiting"]}),(a||o)&&c.jsx("div",{className:"relative h-[2px] w-full overflow-hidden rounded-full ",children:c.jsx("div",{className:"absolute inset-0 h-full w-full bg-primary",style:{animation:`wazui_progress_bar ${a?"5s":"30s"} ease-in-out`}})},`progress-${r}`),c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:((E=A.state)==null?void 0:E.status)=="saved"}),children:["Autosave Complete",c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"dd-mm-yyyy")}),c.jsx(Fu,{className:"text-xs"}),c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"HH:mm:ss")})]}),c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:((N=A.state)==null?void 0:N.status)=="error"}),children:["Autosave",c.jsxs("span",{className:"text-destructive max-w-50 truncate",children:["Error | ",(I=(q=A.state)==null?void 0:q.error)==null?void 0:I.message]})]})]})]}),c.jsxs("div",{className:S("hidden group-hover:flex border cursor-pointer rounded-full p-4 py-2 text-xs items-center gap-2",{"border-destructive text-destructive ":A.autoSaveEnabled}),onClick:n,children:[c.jsx(qu,{className:"text-base"}),c.jsx("p",{children:A.autoSaveEnabled?"Disable Autosave":"Enable Autosave"})]})]}),i&&c.jsx(BnA,{className:"text-destructive text-md animate-bounce",onClick:f})]}):c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("div",{className:"group flex justify-end items-center min-w-70",children:c.jsxs("div",{className:"p-5 py-2 rounded-full border border-primary flex items-center text-sm gap-2",children:[c.jsx(qu,{className:"text-base"}),c.jsx("p",{className:"gap-1 items-center flex",children:"Loading..."})]})})})},LaA=()=>{var G,H;const{state:A,form:e,handlePublish:t,handleSaveDraft:n,handleSaveTitle:r,postQuery:{isLoading:s,error:a},type:o,mainForm:i,groups:l,createMutation:{isPending:u},updateMutation:{isPending:f},dispatch:d,showTitle:g,baseUrl:v,isPopup:m,formTitle:p,actionButtonTitle:h,showDraft:P,showAutoSave:b}=ao(),{activeGroupId:x}=A,z=e.getValues("uuid"),D=A.isDraft,B=e.formState.isDirty,[M,Y]=y.useState(!0),V=IaA(M?1:3),j=T=>{d({type:"SET_ACTIVE_GROUP",payload:T})},C=A.isCreate;let E=p,N=h;E||(C?E="Create "+o:E="Edit "+o),N||(C||D?N="Publish "+o:N="Update "+o);const q=async()=>{e.getValues("title")&&await r(),Y(!0)},I=T=>T>=75?"text-destructive":T>=65?"text-[#FFAA00]":T>=55?"text-[#229954]":T>=45?"text-[#FFAA00]":"text-muted-foreground";return c.jsx(c9,{...e,children:c.jsxs("form",{className:"w-full flex flex-col p-0",onSubmit:T=>T.preventDefault(),onKeyDown:T=>{T.key==="Enter"&&!(T.target instanceof HTMLButtonElement&&T.target.type==="submit")&&T.preventDefault()},children:[s&&!C&&!z&&c.jsx("div",{className:"absolute inset-0 bg-white/50 backdrop-blur-sm flex items-center justify-center z-10",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dh,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{children:"Loading..."})]})}),a&&!C&&!z&&c.jsx("div",{className:"absolute inset-0 bg-white/50 backdrop-blur-sm flex items-center justify-center z-10",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ts,{className:"h-6 w-6"}),c.jsxs("span",{children:["Error: ",a==null?void 0:a.message]})]})}),m&&c.jsx("h1",{className:S("text-md font-bold bg-[#FADDD3] w-full p-4"),children:E}),c.jsxs("div",{className:"w-full h-full flex overflow-auto gap-2 items-stretch","data-testid":"main-form",children:[c.jsxs("div",{className:S("flex-2/3 flex flex-col items-start justify-between gap-5 p-4",{"pb-0":!m}),children:[c.jsx("h1",{className:S("text-3xl font-bold font-[UniversalFeature] !m-0",{hidden:m}),children:E}),c.jsxs("div",{className:"w-full flex items-center justify-between flex-wrap gap-2 ",children:[v&&c.jsx(H0,{url:v,pageTitle:`${C?"Create":"Edit"} ${o}`}),b&&c.jsx(QaA,{})]}),g&&c.jsx(eo,{control:e.control,name:"title",render:({field:T,fieldState:Z})=>{var k,X,J;const O=(X=(k=T.value)==null?void 0:k.toString())==null?void 0:X.trim();return c.jsxs("div",{className:"w-full",children:[Z.error&&c.jsxs("span",{className:"flex items-center mb-1 gap-1",children:[c.jsx(B0,{className:"text-destructive text-xl"}),c.jsx("span",{className:" capitalize text-xs text-muted-foreground",children:(J=Z.error)==null?void 0:J.message})]}),c.jsxs("div",{className:S("flex items-center justify-center w-full gap-2"),children:[c.jsxs("div",{className:S("flex items-center justify-center w-full gap-2 slight_border border-secondary! p-1 px-2 rounded",{"border-primary!":!M}),children:[c.jsx(fr,{className:"flex-1",children:c.jsx(to,{className:"w-full",children:c.jsx(zg,{className:S("h-fit min-h-0 p-0 w-full placeholder:opacity-50 text-2xl! font-[UniversalFeature] no-scrollbar shadow-none flex-1 border-0 bg-transparent hover:bg-transparent focus:border-0 focus:outline-none focus:ring-0 focus:ring-offset-0 focus-visible:ring-0 focus-visible:ring-offset-0",{"opacity-50":M}),ref:V,placeholder:"Enter Title here","aria-disabled":M,value:T.value,onChange:T.onChange,rows:1,onBlur:()=>Y(!0),"data-testid":"title-input",onClick:()=>Y(!1)})})}),c.jsxs(MA,{variant:"outline",className:S("p-3 h-5 rounded-full border-secondary gap-1 hover:bg-transparent capitalize text-muted-foreground text-sm",{"border-primary":!M}),onClick:()=>M?Y(!1):q(),children:[M?c.jsx(Xi,{className:"text-sm"}):c.jsx(k0,{className:"text-sm text-primary"}),M?"edit":"save"]})]}),c.jsx("div",{className:S("flex",I(O==null?void 0:O.length)),"data-testid":"title-word-count",children:c.jsx("span",{className:"text-sm",children:`${(O==null?void 0:O.length)||0}/65`})}),c.jsx(at,{className:S("capitalize bg-muted w-fit p-2 py-1",{"border-[#229954] text-[#229954] bg-transparent":!D}),children:D?"draft":"published"})]})]})}},"title"),i&&c.jsx(Hy,{main:!0,className:"flex-1 grow w-full p-0 "})]}),(l==null?void 0:l.length)&&c.jsxs(bg,{defaultValue:(G=l[0])==null?void 0:G.id,value:x,className:"flex-1/3 flex flex-col h-full no-scrollbar overflow-auto p-0 flex-wrap",children:[c.jsx(Kc,{className:"rounded-none justify-start bg-black p-4 h-fit gap-4 w-full overflow-x-auto no-scrollbar",children:(l==null?void 0:l.length)&&l.map(T=>c.jsxs(Uc,{className:"rounded-full p-2 px-4 gap-1 slight_border text-[#9C9C9C] group data-[state=active]:text-primary-foreground data-[state=active]:bg-primary data-[state=active]:border-none cursor-pointer",value:T.id,onClick:Z=>{Z.preventDefault(),j(T.id)},children:[T.icon&&c.jsx("div",{className:"opacity-100 h-5 w-5 flex items-center justify-center",children:T.icon&&T.icon}),T.title]},T.id))}),c.jsx(xg,{className:"flex-1 h-0 m-0 border-l",value:x||((H=l[0])==null?void 0:H.id),children:c.jsx(Hy,{})})]})]}),c.jsxs("div",{className:S("flex gap-4 p-2 bg-muted w-full justify-end ",{hidden:m||!P}),children:[c.jsx(he,{className:S(" p-4 hidden waz_shadow bg-[#A9D3B8] font-bold text-base px-4 text-[#101828]",{flex:D||C}),onClick:()=>n(),type:"button",disabled:u||f,children:"Save as Draft"}),c.jsx(he,{className:S(" p-4 flex waz_shadow font-bold text-[#101828] text-base px-4 gap-1",{}),disabled:u||f,onClick:()=>t(),trailingIcon:c.jsx(ItA,{}),children:N})]}),(m||!P)&&c.jsx("div",{className:S("flex gap-4 p-2 w-full justify-end "),children:c.jsx(he,{className:S(" p-4 hidden waz_shadow font-bold text-[#101828] text-base px-4 gap-1",{flex:B||D}),disabled:u||f,onClick:t,children:N})})]})})},pu=({type:A="Post",showDraft:e=!0,formTitle:t,actionButtonTitle:n,showTitle:r=!0,isPopup:s=!1,baseUrl:a="",postBaseUrl:o,className:i,post_uuid:l="",groups:u,initialState:f={},mainForm:d,validators:g,requiredDraftFields:v,postQueryConfig:m,createMessage:p,updateMessage:h,formFieldsMapper:P,submitFieldsMapper:b,onBack:x,onSave:z,onChange:D,showDescriptionOnSubmit:B,autoSave:M,user_config:Y})=>{var V;return c.jsx(wc,{children:c.jsx(ZaA,{initialState:{...f,uuid:l,activeGroupId:u&&(u==null?void 0:u.length)>0?(V=u[0])==null?void 0:V.id:""},showTitle:r,showDraft:e,formTitle:t,createMessage:p,updateMessage:h,actionButtonTitle:n,baseUrl:a,postBaseUrl:o,type:A,postQueryConfig:m,validators:g,requiredDraftFields:v,formFieldsMapper:P,submitFieldsMapper:b,onBack:x,onSave:z,groups:u,onChange:D,mainForm:d,isPopup:s,showDescriptionOnSubmit:B,autoSave:M,user_config:Y,children:c.jsx("main",{className:S("w-full h-screen bg-background flex flex-1 overflow-y-auto p-0",i),children:c.jsx(LaA,{})})})})};function fj(A){return UA({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2"},child:[]},{tag:"path",attr:{d:"M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z"},child:[]},{tag:"path",attr:{d:"M9 12l.01 0"},child:[]},{tag:"path",attr:{d:"M13 12l2 0"},child:[]},{tag:"path",attr:{d:"M9 16l.01 0"},child:[]},{tag:"path",attr:{d:"M13 16l2 0"},child:[]}]})(A)}function bf(A){return UA({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M14 3v4a1 1 0 0 0 1 1h4"},child:[]},{tag:"path",attr:{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"},child:[]},{tag:"path",attr:{d:"M9 17h6"},child:[]},{tag:"path",attr:{d:"M9 13h6"},child:[]}]})(A)}const JaA=hA(`
|
|
435
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function raA(A,e){if(A){if(typeof A=="string")return jy(A,e);var t=Object.prototype.toString.call(A).slice(8,-1);if(t==="Object"&&A.constructor&&(t=A.constructor.name),t==="Map"||t==="Set")return Array.from(A);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return jy(A,e)}}function jy(A,e){(e==null||e>A.length)&&(e=A.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=A[t];return n}function saA(A,e){var t=A==null?null:typeof Symbol<"u"&&A[Symbol.iterator]||A["@@iterator"];if(t!=null){var n=[],r=!0,s=!1,a,o;try{for(t=t.call(A);!(r=(a=t.next()).done)&&(n.push(a.value),!(e&&n.length===e));r=!0);}catch(i){s=!0,o=i}finally{try{!r&&t.return!=null&&t.return()}finally{if(s)throw o}}return n}}function aaA(A){if(Array.isArray(A))return A}function oaA(A){var e=A.date,t=A.future,n=A.locale,r=A.locales,s=A.timeStyle,a=A.round,o=A.minTimeLeft,i=A.formatVerboseDate,l=A.verboseDateFormat,u=l===void 0?caA:l,f=A.updateInterval,d=A.tick,g=d===void 0?!0:d,v=A.now,m=A.timeOffset,p=m===void 0?0:m,h=A.polyfill,P=y.useMemo(function(){return n&&(r=[n]),r.concat(Ie.getDefaultLocale())},[n,r]),b=y.useMemo(function(){return QsA(P,{polyfill:h})},[P,h]);e=y.useMemo(function(){return YsA(e)},[e]);var x=y.useCallback(function(){var G=(v||Date.now())-p,H;if(t&&G>=e.getTime()&&(G=e.getTime(),H=!0),o!==void 0){var T=e.getTime()-o*1e3;G>T&&(G=T,H=!0)}var Z=b.format(e,s,{getTimeToNextUpdate:!0,now:G,future:t,round:a}),O=Ku(Z,2),k=O[0],X=O[1];return H?X=laA:X=f||X||60*1e3,[k,G+X]},[e,t,s,f,a,o,b,v]),z=y.useRef();z.current=x;var D=y.useMemo(x,[]),B=Ku(D,2),M=B[0],Y=B[1],V=y.useState(M),j=Ku(V,2),C=j[0],E=j[1],N=y.useRef();y.useEffect(function(){if(g)return N.current=AaA.add({getNextValue:function(){return z.current()},setValue:E,nextUpdateTime:Y}),function(){return N.current.stop()}},[g]),y.useEffect(function(){if(N.current)N.current.forceUpdate();else{var G=x(),H=Ku(G,1),T=H[0];E(T)}},[x]);var q=y.useMemo(function(){return SsA(P,u)},[P,u]),I=y.useMemo(function(){return i?i(e):q(e)},[e,i,q]);return{date:e,formattedDate:C,verboseDate:I}}var iaA=365*24*60*60*1e3,laA=1e3*iaA,caA={weekday:"long",day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"},K2=VA.oneOfType,Oy=VA.arrayOf,Oo=VA.string,Ty=VA.number,Ol=VA.shape,Uu=VA.func,uaA=K2([Ol({minTime:Ty,formatAs:Oo.isRequired}),Ol({test:Uu,formatAs:Oo.isRequired}),Ol({minTime:Ty,format:Uu.isRequired}),Ol({test:Uu,format:Uu.isRequired})]),faA=K2([Oo,Ol({steps:Oy(uaA).isRequired,labels:K2([Oo,Oy(Oo)]).isRequired,round:Oo})]),daA=["date","future","timeStyle","round","minTimeLeft","locale","locales","formatVerboseDate","verboseDateFormat","updateInterval","tick","now","timeOffset","polyfill","tooltip","component","container","wrapperComponent","wrapperProps"];function Bd(){return Bd=Object.assign||function(A){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(A[n]=t[n])}return A},Bd.apply(this,arguments)}function gaA(A,e){if(A==null)return{};var t=vaA(A,e),n,r;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(A);for(r=0;r<s.length;r++)n=s[r],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(A,n)&&(t[n]=A[n])}return t}function vaA(A,e){if(A==null)return{};var t={},n=Object.keys(A),r,s;for(s=0;s<n.length;s++)r=n[s],!(e.indexOf(r)>=0)&&(t[r]=A[r]);return t}function xc(A){var e=A.date,t=A.future,n=A.timeStyle,r=A.round,s=A.minTimeLeft,a=A.locale,o=A.locales,i=o===void 0?[]:o,l=A.formatVerboseDate,u=A.verboseDateFormat,f=A.updateInterval,d=A.tick,g=A.now,v=A.timeOffset,m=A.polyfill,p=A.tooltip,h=p===void 0?!0:p,P=A.component,b=P===void 0?zd:P,x=A.container,z=A.wrapperComponent,D=A.wrapperProps,B=gaA(A,daA),M=oaA({date:e,future:t,timeStyle:n,round:r,minTimeLeft:s,locale:a,locales:i,formatVerboseDate:l,verboseDateFormat:u,updateInterval:f,tick:d,now:g,timeOffset:v,polyfill:m}),Y=M.date,V=M.verboseDate,j=M.formattedDate,C=y.createElement(b,Bd({date:Y,verboseDate:V,tooltip:h},B),j),E=z||x;return E?y.createElement(E,Bd({},D,{verboseDate:V}),C):C}xc.propTypes={date:VA.oneOfType([VA.instanceOf(Date),VA.number]).isRequired,locale:VA.string,locales:VA.arrayOf(VA.string),future:VA.bool,timeStyle:faA,round:VA.string,minTimeLeft:VA.number,component:VA.elementType,tooltip:VA.bool,formatVerboseDate:VA.func,verboseDateFormat:VA.object,updateInterval:VA.oneOfType([VA.number,VA.arrayOf(VA.shape({threshold:VA.number,interval:VA.number.isRequired}))]),tick:VA.bool,now:VA.number,timeOffset:VA.number,polyfill:VA.bool,wrapperComponent:VA.elementType,wrapperProps:VA.object};xc=y.memo(xc);const vu=({categories:A=[],maxDisplay:e=2,badgeVariant:t="outline"})=>{const n=A.slice(0,e),r=A.length-n.length;return c.jsxs("div",{className:"gap-2 flex flex-row items-center",children:[!n.length&&c.jsx(at,{variant:t,className:"line-clamp-1 text-sm text-[#869DA5] p-1 px-3 truncate font-normal",children:"none"}),n.map((s,a)=>c.jsx("div",{className:S("p-1 rounded-full text-sm px-3 truncate font-normal max-w-20 xxl:max-w-24",{"bg-[#FDF2FA] text-[#C11574]":!((a+1)%2)},{"bg-[#EEF4FF] text-[#3538CD]":(a+1)%2}),children:s.name},s.uuid||a)),r>0&&c.jsxs("p",{className:"text-sm text-[#869DA5]",children:["+",r]})]})},_i=({tags:A=[],maxDisplay:e=2,badgeVariant:t="outline"})=>{const n=A.slice(0,e),r=A.length-n.length;return c.jsxs("div",{className:"gap-1 flex flex-row items-center",children:[!n.length&&c.jsx(at,{variant:t,className:"line-clamp-1 text-sm p-1 px-3 truncate font-normal text-[#869DA5]",children:"none"}),n.map((s,a)=>c.jsx(at,{variant:t,className:"line-clamp-1 text-[#869DA5] text-sm p-1 px-3 truncate font-normal max-w-20 xxl:max-w-24",children:s.name},s.uuid||a)),r>0&&c.jsxs("p",{className:"text-sm text-[#869DA5]",children:["+",r]})]})},mu=({statistics:A,className:e,isGrid:t})=>{const n=Eo((A==null?void 0:A.totalPageViews)??0);return A!=null&&A.isLoading?c.jsxs("div",{className:S("w-full flex flex-row gap-1 text-[#596970] justify-center items-center",{"justify-start":!t},e),children:[c.jsx(Dh,{size:12,className:"animate-spin"}),c.jsx("p",{className:"font-[UniversalFeature] text-xs",children:"Loading..."})]}):!(A!=null&&A.totalPageViews)&&!(A!=null&&A.shares)?c.jsx("p",{className:S("text-xs p-1",e),children:"No statistics"}):c.jsxs("div",{className:S(`w-full flex flex-row gap-3 text-[#596970] ${t?"justify-center":"justify-start"} items-center`,e),children:[c.jsxs("div",{className:"flex flex-row items-center justify-center gap-1",children:[c.jsx(IR,{className:"text-sm"}),c.jsx("p",{className:"font-[UniversalFeature] text-xs",children:n})]}),c.jsxs("div",{className:"flex flex-row items-center justify-center gap-1",children:[c.jsx(yAA,{className:"text-sm"}),c.jsx("p",{className:"font-[UniversalFeature] text-xs",children:"0"})]})]})};function N0({data:A,className:e,onDeleteClick:t,postBaseURL:n="",blogBaseUrl:r="",isSelect:s,selected:a,onSelect:o,onEditClick:i}){var u;let l={};try{l=JSON.parse(A==null?void 0:A.featured_image)}catch(f){console.log(f)}return c.jsxs(hr,{className:S("max-w-[450px] flex flex-col cursor-pointer group justify-between overflow-hidden rounded-md focus:border-accent focus:border focus:bg-[#BEFEF72B] hover:border-accent hover:border hover:bg-[#BEFEF72B] ",e),"data-testid":"post-card:"+A.uuid,onDoubleClick:()=>i==null?void 0:i(A),children:[c.jsxs("div",{className:"flex flex-col grow",children:[c.jsxs(Es,{className:"p-0 relative h-[178px]",children:[c.jsx(at,{variant:"outline",className:S("text-xs absolute z-10 top-2 left-2 bg-muted text-muted-foreground",{hidden:A.status}),children:"Draft"}),c.jsx(MA,{variant:"ghost",size:"icon","data-active":a,"data-testid":"post-select",className:S("rounded-md shadow-[0px_4.29px_12.86px_0px_#00000012] bg-background w-7 h-7 absolute top-2 right-2 z-10",{hidden:!s},{"bg-primary":a}),onClick:()=>o==null?void 0:o(A),children:c.jsx("div",{className:"flex items-center justify-center w-4 h-4 border-2 rounded-full border-foreground",children:a&&c.jsx("div",{className:"w-2 h-2 rounded-full bg-foreground"})})}),c.jsxs("div",{className:S("flex items-center gap-1 absolute top-2 right-2 z-10",{hidden:s}),children:[c.jsx("a",{href:`${r}/${A.uuid}`,onClick:f=>f.preventDefault(),className:"leading-0",children:c.jsx(MA,{variant:"ghost",size:"icon",className:"rounded-md shadow-[0px_4.29px_12.86px_0px_#00000012] bg-background w-7 h-7",onClick:()=>i==null?void 0:i(A),children:c.jsx(Xi,{size:"small",className:"text-accent-foreground"})})}),c.jsx(MA,{variant:"ghost",size:"icon",className:"rounded-md shadow-[0px_4.29px_12.86px_0px_#00000012] bg-background w-7 h-7",onClick:()=>t==null?void 0:t(A),children:c.jsx(tv,{size:"small",className:"text-destructive"})})]}),c.jsx(qi,{url:l==null?void 0:l.src,transformations:{height:178}}),c.jsx("div",{className:"absolute bottom-0 left-0 px-2 rounded-tr-[0.75rem] bg-white opacity-90",children:c.jsx(mu,{statistics:A.statistics,className:"h-7 p-2 text-[#101828]",isGrid:!0})})]}),c.jsxs(Hs,{className:"p-2 flex flex-col gap-1.5 grow justify-between align-top flex-1",children:[c.jsx("a",{className:"text-base leading-tight cursor-pointer group-hover:underline hover:underline line-clamp-3",href:n+A.slug,target:"_blank",rel:"noopener noreferrer",children:Wr(A.title)}),c.jsx("p",{className:"flex-1 my-auto text-sm leading-tight line-clamp-3",children:Wr(A.excerpt)})]})]}),c.jsxs(Fd,{className:"flex flex-row justify-between p-2 items-baseline-last ",children:[c.jsxs("div",{className:"flex flex-row items-start justify-between gap-2 text-muted-foreground",children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("p",{className:"text-[10px]",children:"Categories"}),c.jsx(vu,{categories:A.categories,maxDisplay:1})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("p",{className:"text-[10px]",children:"Tags"}),c.jsx(_i,{tags:A.tags,maxDisplay:1,badgeVariant:"outline"})]})]}),c.jsxs("div",{className:"flex items-center justify-between gap-2 text-muted-foreground",children:[c.jsx("div",{className:"flex items-center justify-center w-4.5 h-4.5 font-semi-bold rounded-full bg-secondary",children:c.jsx("p",{className:"text-[8px] text-black",children:Bi(((u=A.author)==null?void 0:u.name)||"")})}),c.jsx(xc,{date:new Date(A.updated_at||""),locale:"en-US",className:"text-xs"})]})]})]})}const maA=({onEdit:A,onDelete:e,editDisabled:t=!1,deleteDisabled:n=!1})=>c.jsxs("div",{className:"flex items-center",children:[c.jsx(MA,{variant:"ghost",size:"icon",onClick:A,disabled:t,children:c.jsx(qZ,{color:"gray",size:"small"})}),c.jsx(MA,{variant:"ghost",size:"icon",onClick:e,disabled:n,children:c.jsx(Nn,{color:"red",size:"small"})})]}),paA={theme:"system",setTheme:()=>null},ij=y.createContext(paA);function haA({children:A,defaultTheme:e="system",storageKey:t="vite-ui-theme",...n}){const[r,s]=y.useState(()=>typeof window<"u"&&window.localStorage.getItem(t)||e);y.useEffect(()=>{const o=window.document.documentElement;if(o.classList.remove("light","dark","brand"),r==="system"){const i=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";o.classList.add(i);return}o.classList.add(r)},[r]);const a={theme:r,setTheme:o=>{window.localStorage.setItem(t,o),s(o)}};return c.jsx(ij.Provider,{...n,value:a,children:A})}const waA=()=>{const A=y.useContext(ij);if(A===void 0)throw new Error("useTheme must be used within a ThemeProvider");return A},PaA=new Ig;function yaA({children:A}){return c.jsx(Qg,{client:PaA,children:A})}const baA=new Ig,xaA=A=>c.jsx(Qg,{client:baA,children:c.jsx(A,{})});function zaA(A,e){const t=Dt();return Lg({staleTime:12e4,gcTime:12e4,queryKey:[(A==null?void 0:A.cacheKey)||(A==null?void 0:A.dataKey),e],queryFn:async()=>{var n;if(A!=null&&A.query&&(A!=null&&A.variables)&&e){const r=A==null?void 0:A.query,s=A==null?void 0:A.variables,o=(await t.query({query:r,variables:{...s||{},uuid:e},fetchPolicy:"network-only"})).data[A.dataKey];if((n=o==null?void 0:o.config)!=null&&n.related_recipes_config)try{const i=JSON.parse(o.config.related_recipes_config);if(Array.isArray(i)&&i.length>0){const f=(i[0]==="AUTO"?i.slice(1):i).map(v=>t.query({query:r,variables:{uuid:v},fetchPolicy:"network-only"})),g=(await Promise.all(f)).map(v=>{var h;return(h=v.data)==null?void 0:h[A.dataKey]}).filter(v=>v!=null).map(v=>({uuid:v.uuid,value:v.uuid,title:v.title,label:v.title}));return{...o,_relatedRecipesData:g}}}catch(i){console.error("Error fetching related recipes:",i)}return o}else throw new Error("No query or variables provided")},refetchOnMount:!1,refetchOnWindowFocus:!1})}function DaA({config:A,baseUrl:e,postType:t,createMessage:n,showDescription:r=!0,onSuccess:s}){const a=ta(),o=Dt(),i=A==null?void 0:A.query,{showSuccess:l,showError:u}=$t();return ts({mutationFn:async f=>{if(i)return await o.mutate({mutation:i,variables:{...A.variables||{},...f}})},onSuccess:(f,d)=>{var P;const g=(P=f==null?void 0:f.data)==null?void 0:P[(A==null?void 0:A.dataKey)||"createPost"],v=(d==null?void 0:d.status)||(d==null?void 0:d.titleStatus)||!1,m=(d==null?void 0:d.showActionModals)??!0,p="You have published your article successfully.",h="You have saved your article as draft successfully. You can publish your article when ready!";if(a.invalidateQueries({queryKey:[A==null?void 0:A.mutationInvalidateKey],refetchType:"all"}),m&&l(n||`${t||"Article"} ${v?"Published":"Saved as draft"}`,r?v?p:h:void 0,{type:v?"action":"info",confirmText:`View ${t||"Article"}`,cancelText:"Done",onCancel:()=>{!v&&e||(e?window.location.href=e:window.history.back())},onAction:()=>{const b=`${e||"/blog/articles"}/${g==null?void 0:g.uuid}`;window.location.href=b}}),!v){const b=window.location.pathname,x=b.endsWith("/new")?b.replace("/new",`/${g==null?void 0:g.uuid}`):`${b}/${g==null?void 0:g.uuid}`;window.history.replaceState(null,"",x)}s==null||s(d,g==null?void 0:g.uuid)},onError:(f,d)=>{console.error(f),((d==null?void 0:d.showActionModals)??!0)&&u(`Failed to Create ${t||"Article"}`,f.message||"An unexpected error occurred while creating the post.",{confirmText:"Try Again",onAction:()=>{console.log("Retry create post")}})}})}function BaA({config:A,fetchConfig:e,postBaseUrl:t,baseUrl:n,updateMessage:r,postType:s="Article",showDescription:a=!0,onSuccess:o,user_config:i}){const l=ta(),u=Dt(),f=A==null?void 0:A.query,{showSuccess:d,showError:g}=$t(),v=lj(t,i);return ts({mutationFn:async m=>{if(f)return await u.mutate({mutation:f,variables:{...A.variables||{},...m}})},onSuccess:(m,p)=>{var D;const h=(p==null?void 0:p.showActionModals)??!0,P=(D=m==null?void 0:m.data)==null?void 0:D[(A==null?void 0:A.dataKey)||"updatePost"],b=(p==null?void 0:p.status)||(p==null?void 0:p.titleStatus)||!1,x="You have published your article successfully.",z="You have saved your article as draft successfully. You can publish your article when ready!";l.invalidateQueries({queryKey:[A==null?void 0:A.mutationInvalidateKey],refetchType:"all"}),l.invalidateQueries({queryKey:[(e==null?void 0:e.cacheKey)||(e==null?void 0:e.dataKey)],refetchType:"all"}),h&&d(r||`${s||"Article"} ${b?"Published":"Updated"} Successfully!`,a?b?x:z:void 0,{type:b?"action":"info",cancelText:"Done",confirmText:`View ${s||"Article"}`,onAction:()=>{const B=`${n||"/blog/articles"}/${P==null?void 0:P.uuid}`;window.location.href=B}}),o==null||o(p),console.log(p.updated_fields),v&&b&&v(P==null?void 0:P.slug,!!(p!=null&&p.is_autosave),p.updated_fields)},onError:(m,p)=>{console.error(m),((p==null?void 0:p.showActionModals)??!0)&&g(`Failed to Update ${s||"Article"}`,m.message||"An unexpected error occurred while updating the post.",{confirmText:"Retry",onAction:()=>{console.log("Retry update post")}})}})}const lj=(A,e)=>{A!=null&&A.length&&A.endsWith("/")&&(A=A.slice(0,-1));const{showError:t,showSuccess:n}=$t(),r=async(s,a,o,i=!1)=>{const l=A.includes("vt")?`${s}`:`${s?`/recipes${s}`:"/"}`;return await Xe.post(`${A}/api/revalidate`,{slug:l.trim(),username:`${e==null?void 0:e.name}${a?"-autosave":""}`,email:e==null?void 0:e.email,date:new Date().toLocaleString(),updated_fields:`${o}`.split(",").filter(u=>u),token:A.includes("vt")?re.NEXT_PUBLIC_REVALIDATION_VT_TOKEN:re.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN}).then(u=>(i&&n("Cache cleared sucessfully","",{type:"action",confirmText:"View Page",cancelText:"Done",onAction:()=>{var f;(f=window==null?void 0:window.open)==null||f.call(window,`${A}${l}`,"_blank")}}),u)).catch(u=>{throw t("Failed to revalidate cache",u.message,{}),u})};if(A)return r},MaA=({storageKey:A,form:e,enabled:t=!0,interval:n=6e4,onSave:r,onError:s})=>{const[a,o]=y.useState(null),[i,l]=y.useState(null),u=y.useRef(null),f=y.useRef(null),d=y.useRef(""),g=y.useCallback(()=>`autosave_enabled_${A}`,[A]),v=y.useCallback(()=>{if(typeof window>"u"||typeof localStorage>"u")return t;try{const B=localStorage.getItem(g());if(B!==null)return JSON.parse(B)}catch(B){console.error("Failed to load autosave enabled state from localStorage:",B)}return t},[g,t]),m=y.useCallback(B=>{if(!(typeof window>"u"||typeof localStorage>"u"))try{localStorage.setItem(g(),JSON.stringify(B))}catch(M){console.error("Failed to save autosave enabled state to localStorage:",M)}},[g]),[p,h]=y.useState(()=>v()),P=y.useCallback(B=>{h(B),m(B)},[m]),b=y.useCallback(async()=>{if(p)try{const B=e.getValues(),M=JSON.stringify(B),Y=new Date;await(r==null?void 0:r(B)),d.current=M,l(Y),o({status:"saved"})}catch(B){const M=B instanceof Error?B:new Error("Failed to save form data");console.error("Failed to save form data to sessionStorage:",M),o({status:"error",error:M}),s==null||s(M)}},[p,e,r,s]),x=y.useCallback(async()=>{await b()},[b]),z=y.useCallback(()=>{!p||!e.formState.isDirty||(a==null?void 0:a.status)=="error"||(o({status:"saving"}),f.current=setTimeout(()=>{b()},5e3))},[p,e.formState.isDirty,b,a]),D=()=>{const B=e.getValues("updated_at");B&&l(new Date(B))};return y.useEffect(()=>{if(!p||e.getValues("updated_at"))return;D();const B=e.watch((M,{values:Y,type:V})=>{const j=JSON.stringify(Y);if(V=="change"&&j!==d.current)try{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{z()},n),o({status:"pending"})}catch(C){console.error("Error in form watch subscription:",C)}});return()=>{console.log("Cleaning up autosave..."),u.current&&clearTimeout(u.current),f.current&&clearTimeout(f.current),B.unsubscribe()}},[p,n,e]),{state:a,saveNow:x,lastSaveDate:i,autoSaveEnabled:p,updateLastSave:D,toggleEnableAutoSave:P}},CaA={isDraft:!0,isCreate:!0,activeGroupId:"",formValues:{},sectionStates:{}},jaA=(A,e)=>{switch(e.type){case"SET_ACTIVE_GROUP":return{...A,activeGroupId:e.payload};case"SET_FORM_VALUES":return{...A,formValues:{...A.formValues,...e.payload}};case"TOGGLE_DRAFT":return{...A,isDraft:e.payload};case"PUBLISH_POST":return{...A,isDraft:!1,isCreate:!1};case"SAVE_DRAFT":return{...A,isDraft:!0,isCreate:!1};case"SET_UUID":return{...A,uuid:e.payload};default:return A}},cj=y.createContext(void 0),ao=()=>{const A=y.useContext(cj);if(A===void 0)throw new Error("useBlogPost must be used within a BlogPostProvider");return A},dt=[];for(let A=0;A<256;++A)dt.push((A+256).toString(16).slice(1));function OaA(A,e=0){return(dt[A[e+0]]+dt[A[e+1]]+dt[A[e+2]]+dt[A[e+3]]+"-"+dt[A[e+4]]+dt[A[e+5]]+"-"+dt[A[e+6]]+dt[A[e+7]]+"-"+dt[A[e+8]]+dt[A[e+9]]+"-"+dt[A[e+10]]+dt[A[e+11]]+dt[A[e+12]]+dt[A[e+13]]+dt[A[e+14]]+dt[A[e+15]]).toLowerCase()}let Im;const TaA=new Uint8Array(16);function EaA(){if(!Im){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Im=crypto.getRandomValues.bind(crypto)}return Im(TaA)}const HaA=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ey={randomUUID:HaA};function NaA(A,e,t){var r;if(Ey.randomUUID&&!A)return Ey.randomUUID();A=A||{};const n=A.random??((r=A.rng)==null?void 0:r.call(A))??EaA();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,OaA(n)}const kaA=({hasUnsavedChanges:A,onSave:e,onDiscard:t})=>{const[n,r]=y.useState(!1),[s,a]=y.useState("/new-page");y.useEffect(()=>{const u=d=>{if(A)return d.preventDefault(),!0},f=d=>{if(A)throw a(d),r(!0),"Route change aborted by user."};if(A&&(window.addEventListener("beforeunload",u),typeof window<"u")){try{const d=window.__NEXT_ROUTER__;d!=null&&d.events&&d.events.on("routeChangeStart",f)}catch{console.debug("Next.js router not available in standalone environment")}return()=>{window.removeEventListener("beforeunload",u);try{const d=window.__NEXT_ROUTER__;d!=null&&d.events&&d.events.off("routeChangeStart",f)}catch{console.debug("Next.js router cleanup not needed in standalone environment")}}}return()=>{window.removeEventListener("beforeunload",u)}},[A]);const o=async()=>{try{await(e==null?void 0:e()),r(!1),typeof window<"u"&&(window.location.href=s)}catch(u){console.error("Save failed:",u)}},i=()=>{t==null||t(),r(!1),typeof window<"u"&&(window.location.href=s)},l=()=>{r(!1)};return c.jsx(c.Fragment,{children:c.jsx(_t,{open:n,onOpenChange:l,children:c.jsxs(Vt,{className:"max-w-[500px] p-0 overflow-hidden gap-6",children:[c.jsx(Ln,{className:"bg-secondary p-5 py-5 items-start",children:c.jsx(Jn,{children:c.jsx("h1",{className:"text-md",children:"Unsaved Changes"})})}),c.jsx(Ag,{className:"px-5",children:"You have unsaved changes that will be lost"}),c.jsx("div",{className:"px-5",children:c.jsx("div",{className:"bg-muted rounded p-3 border border-bg-muted-foreground mb-4",children:c.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[c.jsx("span",{children:"Navigating to:"}),c.jsx("div",{className:"flex items-center space-x-1 bg-background p-2 rounded border-bg-muted-foreground border",children:c.jsx("span",{className:" ",children:s})})]})})}),c.jsxs(Dr,{className:"flex flex-row p-4 pt-0 gap-4 justify-end",children:[c.jsx(he,{variant:"outline",className:"rounded capitalize",onClick:o,children:"save and continue"}),c.jsx(he,{variant:"primary",className:"rounded capitalize",onClick:i,children:"Discard and continue"})]})]})})})},ZaA=({children:A,type:e,initialState:t={},validators:n,requiredDraftFields:r,postQueryConfig:s,formFieldsMapper:a,submitFieldsMapper:o,onBack:i,groups:l,mainForm:u,showTitle:f,baseUrl:d,postBaseUrl:g,isPopup:v,actionButtonTitle:m,showDraft:p,formTitle:h,createMessage:P,updateMessage:b,showDescriptionOnSubmit:x,autoSave:z=!1,onChange:D,user_config:B})=>{var tA;const M=t.uuid||((tA=t.formValues)==null?void 0:tA.uuid),Y=!M||M==="new",[V,j]=y.useReducer(jaA,{...CaA,...t,isCreate:Y}),C=ug({...n&&{resolver:Mg(n)},defaultValues:V.formValues,reValidateMode:"onChange",mode:"onChange"}),E=MaA({storageKey:`${e}_${V.uuid||"new"}`,form:C,enabled:z&&V.isDraft&&!V.isCreate,interval:3e4,onSave:async()=>{C.setValue("status",!V.isDraft),C.setValue("is_autosave",!0),await O(V.isCreate,!1),V.isCreate||await T({titleOnly:!1,showActionModals:!1}),C.setValue("is_autosave",!1)}}),N=zaA(s==null?void 0:s.fetch,V.uuid),q=(K,$)=>{j({type:C.getValues("status")?"PUBLISH_POST":"SAVE_DRAFT"}),$&&j({type:"SET_UUID",payload:$})},I=DaA({config:s==null?void 0:s.create,baseUrl:d,postType:e,createMessage:P,showDescription:x,onSuccess:q});let G=BaA({config:s==null?void 0:s.update,fetchConfig:s==null?void 0:s.fetch,postBaseUrl:g,baseUrl:d,postType:e,updateMessage:b,showDescription:x,onSuccess:q,user_config:B});s!=null&&s.update||(G=I);const{showError:H}=$t();async function T({titleOnly:K,showActionModals:$=!0}){try{const _=V.isCreate;let U=C.getValues("uuid");U||(U=_?NaA():V.uuid||M||"",C.setValue("uuid",U),j({type:"SET_UUID",payload:U}));const wA=C.getValues(),HA=Object.keys(C.formState.dirtyFields),CA=o?o(wA):wA;if(CA.showActionModals=$,CA.is_autosave=wA==null?void 0:wA.is_autosave,CA.updated_fields=HA.join(","),K){const SA={uuid:CA.uuid,blog_uuid:CA.blog_uuid,author_uuid:CA.author_uuid,slug:CA.slug,title:CA.title,titleStatus:!!CA.status,is_autosave:CA.is_autosave,updated_fields:CA.updated_fields};_?await I.mutateAsync(SA):await G.mutateAsync(SA)}else _?await I.mutateAsync(CA):await G.mutateAsync(CA);C.reset(wA)}catch(_){console.error(_);const U=_ instanceof Error?_.message:String(_);H("Error while saving article",U)}}const Z=y.useMemo(()=>{const K=l!=null&&l.length?l==null?void 0:l.flatMap(_=>_.sections.flatMap(U=>U.formItems)):[],$=u!=null&&u.sections?u==null?void 0:u.sections.flatMap(_=>_.formItems):[];return[...K,...$]},[l,u]),O=async(K=!1,$=!0)=>{const _=C.getValues("status");C.clearErrors();const U=await C.trigger(_?void 0:r),CA=`Validation error on field(s): ${Object.keys(C.formState.errors).map(SA=>SA).map(SA=>{const de=Z.find(Bt=>Bt.name==SA);return de?de.label:SA}).join(", ")}. Please fix all issues before submitting.`;if(!U){$&&H(`Failed to ${K?"Create":"Update"} ${e||"Article"}`,CA);const SA=new Error(CA);throw SA.cause="Form validation failed",SA.message=CA,SA}return U},k=async(K=!0)=>{C.setValue("status",!1),await O(V.isCreate),await T({titleOnly:!1,showActionModals:K})},X=async()=>{C.setValue("status",!0),C.setValue("published_at",new Date().toLocaleString()),await O(V.isCreate),await T({titleOnly:!1})},J=async()=>{C.setValue("status",!!C.getValues("status")),await O(V.isCreate),await T({titleOnly:!0})},F=()=>{i==null||i()},eA=()=>{if(!N.data)return;const K=a?a(N.data):N.data||Object.create(null);C.reset(K),E.updateLastSave(),j({type:K!=null&&K.status?"PUBLISH_POST":"SAVE_DRAFT"});const $=Object.entries(K).reduce((U,[wA,HA])=>({...U,[wA]:HA}),{});j({type:"SET_FORM_VALUES",payload:$});const _=C.getValues("status");E.toggleEnableAutoSave(!_)},R=()=>{eA()};return y.useEffect(()=>{var $,_;const K=()=>{const U=window.location.hash.replace("#","");U&&l&&l.some(wA=>wA.id===U)&&j({type:"SET_ACTIVE_GROUP",payload:U})};return!V.activeGroupId&&l&&l.length>0?(j({type:"SET_ACTIVE_GROUP",payload:($=l==null?void 0:l[0])==null?void 0:$.id}),window.location.hash=(_=l==null?void 0:l[0])==null?void 0:_.id):K(),window.addEventListener("hashchange",K),()=>{window.removeEventListener("hashchange",K)}},[V.activeGroupId,l,j]),y.useEffect(()=>{const K=C.watch(($,{name:_,values:U})=>{D==null||D(C,_,U)});return()=>K.unsubscribe()},[C,j,D]),y.useEffect(()=>{eA()},[N.isFetched]),c.jsxs(cj.Provider,{value:{state:V,initialState:t,type:e,dispatch:j,handleSaveDraft:k,handleSaveTitle:J,handlePublish:X,handleBack:F,form:C,postQuery:N,groups:l,mainForm:u,createMutation:I,updateMutation:G,showTitle:f,baseUrl:d,postBaseUrl:g,isPopup:v,formTitle:h,showDraft:p,actionButtonTitle:m,autosave:E,showAutoSave:z&&!V.isCreate&&V.isDraft},children:[A,c.jsx(kaA,{hasUnsavedChanges:C.formState.isDirty,onSave:C.getValues("status")?X:k,onDiscard:R})]})};function k0(A){return UA({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M170.718 216.482L141.6 245.6l93.6 93.6 208-208-29.118-29.118L235.2 279.918l-64.482-63.436zM422.4 256c0 91.518-74.883 166.4-166.4 166.4S89.6 347.518 89.6 256 164.482 89.6 256 89.6c15.6 0 31.2 2.082 45.764 6.241L334 63.6C310.082 53.2 284.082 48 256 48 141.6 48 48 141.6 48 256s93.6 208 208 208 208-93.6 208-208h-41.6z"},child:[]}]})(A)}const Z0=(A,e,t,n)=>{var l,u,f,d,g,v;const r=m=>{e.onChange?e.onChange(m,A):t.onChange(m)},s=t.value,a={...e,error:n.error,onChange:r,value:s,validationError:(l=n.error)==null?void 0:l.message},o=e.linkedField&&A.getValues(e.linkedField),i=()=>{o&&(s||A.setValue(e.name,o))};switch(e.type){case"switch":return c.jsx(st,{...a,className:S("w-full",e.className)});case"wysiwyg":return c.jsx(st,{...a,defaultValue:e.linkedField&&A.getValues(e.linkedField),className:S("w-full h-full",e.className),wysiwygProps:{...e.wysiwygProps,className:S("w-full p-0 bg-background border-none",(u=e.wysiwygProps)==null?void 0:u.className)}});case"custom":return(f=e.contentRender)==null?void 0:f.call(e,s);case"select":case"optionslist":case"image":case"blogposts":return c.jsx(st,{...a,className:S("w-full",e.className,{"[&_.waz-input-box-content]:opacity-30":!s&&o}),value:s||o});case"link":return c.jsx(st,{...a,className:S("w-full",e.className),linkProps:{...a.linkProps,placeholder:e.linkedField&&A.getValues(e.linkedField)||((d=a.linkProps)==null?void 0:d.placeholder),onFocus:o&&i,disabled:t.disabled}});case"textarea":return c.jsx(st,{...a,className:S("w-full",e.className),textareaProps:{...a.textareaProps,placeholder:o||((g=a.textareaProps)==null?void 0:g.placeholder),onFocus:o&&i,disabled:t.disabled}});default:return c.jsx(st,{...a,className:S("w-full",e.className),inputProps:{...a.inputProps,onKeyDown:m=>{var p;(p=e.onKeyDown)==null||p.call(e,m,A)},onFocus:o&&i,placeholder:o||((v=a.inputProps)==null?void 0:v.placeholder),disabled:t.disabled}})}},VaA=({section:A,item:e,itemIndex:t,form:n,onRemove:r,canRemove:s})=>{const[a,o]=y.useState(!0),i=()=>{o(!a)},{attributes:l,listeners:u,setNodeRef:f,transform:d,transition:g,isDragging:v}=dv({id:e.id}),m={transform:Gs.Transform.toString(d),transition:g};return c.jsxs("div",{ref:f,style:m,className:S("group relative border p-4 transition-all duration-200 rounded",{"bg-accent/50 border-2 border-accent shadow-lg":v}),children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[A.maxItems!==1&&c.jsx("div",{...l,...u,className:"cursor-grab active:cursor-grabbing p-1 rounded hover:bg-muted",children:c.jsx(xh,{className:"h-4 w-4 text-muted-foreground"})}),A.maxItems!==1?c.jsxs("p",{className:"",children:[c.jsxs("span",{className:"text-muted-foreground capitalize mr-1",children:[t+1,"."]}),c.jsxs("span",{className:"text-primary-foreground",children:[A.dynamicType," Group "]})]}):c.jsxs("span",{className:"text-primary-foreground",children:[A.dynamicType," "]})]}),c.jsxs("div",{className:"flex items-center",children:[s&&c.jsx(MA,{variant:"ghost",size:"sm",onClick:r,className:S("h-8 w-8 p-0 text-red-500 hover:text-red-700 hover:bg-red-50 transition-opacity","opacity-0 group-hover:opacity-100"),children:c.jsx(Nn,{className:"w-4 h-4"})}),A.collapsible&&c.jsx(MA,{variant:"ghost",size:"sm",onClick:i,className:S("h-8 w-8 p-0"),children:a?c.jsx(Ph,{}):c.jsx(Cz,{})})]})]}),c.jsx("div",{className:S("flex items-center flex-col gap-2",{hidden:!a},A.formItemsContainerClassName),children:A.formItems.map(p=>{const h=`${A.id}_${e.id}_${p.name}`;return c.jsx(eo,{control:n.control,name:h,render:({field:P,fieldState:b})=>{var x;return c.jsxs(fr,{className:S("flex flex-col w-full",p.containerClassname),children:[p.description&&c.jsx("p",{className:"text-muted-foreground w-full h-fit",children:p.description}),c.jsx(to,{className:"flex flex-1",children:Z0(n,p,P,b)}),b.error&&c.jsxs("div",{className:"flex items-center gap-2 mt-1 opacity-50",children:[c.jsx(hZ,{strokeWidth:2,className:"text-destructive"}),c.jsx("span",{className:"font-bold text-muted-foreground capitalize",children:(x=b.error)==null?void 0:x.message})]})]})}},h)})})]})};function uj(A){const e=/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)_(.+)$/,t=A.match(e);return t?{group_id:t[1],index:parseInt(t[2]||"0",10),fieldname:t[3]}:{group_id:"",index:0,fieldname:""}}function Qm(A=""){var n,r;if(!A||A.trim()==="")return{quantity:"",unit:""};if(A.includes("//")){const s=A.indexOf("//"),a=A.substring(0,s).trim(),o=A.substring(s).replace(/\/+/g,"").trim();return{quantity:a||"",unit:o}}const e=/^(\d+(?:\s+\d+\/\d+|\.\d+|\/\d+)?)\s*(.*)$/,t=A.match(e);if(console.log("numericMatch",t,A),t){const s=((n=t[2])==null?void 0:n.trim())||"";return{quantity:((r=t[1])==null?void 0:r.trim())||"",unit:s||""}}return{quantity:A.trim(),unit:""}}const SaA=({section:A})=>{const{form:e}=ao(),[t,n]=y.useState([{id:"0",values:A.template||{}}]);y.useEffect(()=>{const u=e.getValues(),f=A.formItems.map(g=>g.name),d=[];Object.entries(u).forEach(([g,v])=>{f.map(m=>{var p;if(g.includes(m)){const{index:h}=uj(g);d[h]?d[h]={id:h.toString(),values:{...(p=d[h])==null?void 0:p.values,[m]:v}}:d.push({id:h.toString(),values:{[m]:v}})}})}),d.length&&n(d)},[]);const r=u=>{const f=A.maxItems||1/0;if(t.length<f){const d={id:`${Date.now()}`,values:A.template||{}};if(u!==void 0&&u>=0&&u<=t.length){const g=[...t];g.splice(u+1,0,d);const v=g.map((m,p)=>({...m,id:p.toString()}));n(v)}else n([...t,d])}},s=u=>{const f=A.minItems||1;if(t.length>f){const g=t.filter(v=>v.id!==u).map((v,m)=>({...v,id:m.toString()}));n(g)}},a=sv(Is(Ui),Is(Ki,{coordinateGetter:gv}));function o(u){const{active:f,over:d}=u;if(f.id!==(d==null?void 0:d.id)&&(d!=null&&d.id)){const g=t.findIndex(z=>z.id===f.id),v=t.findIndex(z=>z.id===(d==null?void 0:d.id));if(g===-1||v===-1)return;const m=[...t],[p]=m.splice(g,1);if(!p)return;m.splice(v,0,p);const h=e.getValues(),P={...h},b=A.formItems.map(z=>z.name);Object.keys(h).forEach(z=>{b.forEach(D=>{z.includes(`${A.id}_`)&&z.includes(`_${D}`)&&delete P[z]})}),m.forEach((z,D)=>{b.forEach(B=>{const M=`${A.id}_${z.id}_${B}`,Y=`${A.id}_${D}_${B}`,V=h[M];V!==void 0&&(P[Y]=V)})});const x=m.map((z,D)=>({...z,id:D.toString()}));e.reset(P),n(x)}}const i=!A.maxItems||t.length<A.maxItems,l=t.length>(A.minItems||1);return c.jsxs(c.Fragment,{children:[A.description&&c.jsx("p",{className:"text-muted-foreground text-sm w-full",children:A.description}),c.jsx(cv,{sensors:a,collisionDetection:av,onDragEnd:o,children:c.jsx("div",{className:"relative space-y-2",children:c.jsx(fv,{items:t.map(u=>u.id),strategy:uv,children:t.map((u,f)=>c.jsxs("div",{children:[c.jsx(VaA,{section:A,item:u,itemIndex:f,form:e,onRemove:()=>s(u.id),canRemove:l}),i&&c.jsx("div",{className:S("group w-full min-h-1 hover:bg-muted hover:p-4",{" bg-muted p-4":f===t.length-1}),children:c.jsxs("div",{className:S("hidden group-hover:flex items-center justify-center gap-2 transition-all duration-200 text-xs",{flex:f===t.length-1}),children:[c.jsx(MA,{variant:"ghost",onClick:()=>r(f),size:"icon",className:"border border-primary bg-background rounded-full hover:bg-primary",children:c.jsx(Ao,{})}),"Add New Group"]})})]},u.id))})})})]})},XaA=({section:A})=>{const{form:e}=ao();return c.jsxs(c.Fragment,{children:[A.description&&c.jsx("p",{className:S("text-muted-foreground w-full h-fit",A.descriptionClassName),children:A.description}),A.formItems.map((t,n)=>c.jsx(eo,{control:e.control,name:t.name,render:({field:r,fieldState:s})=>c.jsxs(fr,{className:S("flex flex-col w-full",t.containerClassname),children:[t.description&&c.jsx("p",{className:"w-full h-fit leading-5",children:t.description}),c.jsx(to,{className:"flex flex-1",children:Z0(e,t,r,s)})]})},`${t.name}-${n}`))]})},YaA=({index:A,step:e,section:t,formField:n,disabled:r,onDelete:s})=>{var m;const{attributes:a,listeners:o,setNodeRef:i,transform:l,isDragging:u,isOver:f}=dv({id:e.id}),d={transform:Gs.Transform.toString(l)},{form:g}=ao(),v=(m=g.getValues(`${t.id}_${e.id}_${n==null?void 0:n.name}`))==null?void 0:m.toString();return c.jsx("div",{ref:i,style:d,...a,className:"sortable-item",children:c.jsxs("div",{className:S("group border-l-[2px] pt-4 pl-5 border-border bg-background relative z-10",{"border-primary-foreground":v==null?void 0:v.length,"bg-accent/50 border border-b-4 border-accent z-100":u,"z-1":f,"pt-0 ":!A}),children:[c.jsx("div",{...o,className:S("p-[7px] bg-background rounded-full absolute top-5 left-[-13px] z-10 cursor-grab active:cursor-grabbing",{"top-2":!A}),children:c.jsx("div",{className:S("p-[5px] rounded-full bg-primary-foreground",{"bg-background ":f})})}),c.jsx(eo,{control:g.control,name:`${t.id}_${e.id}_${n==null?void 0:n.name}`,disabled:r,render:({field:p,fieldState:h})=>c.jsx(fr,{className:S("flex flex-col w-full",n==null?void 0:n.containerClassname),children:c.jsx(to,{className:"flex flex-1",children:Z0(g,{...n,label:(n.label||"Step")+` ${A+1}`},p,h)})})}),c.jsx(MA,{variant:"ghost",size:"sm",onClick:s,className:S("hidden group-hover:flex absolute top-4 right-2 h-8 w-8 p-0 text-red-500 hover:text-red-700 hover:bg-transparent transition-opacity",{"top-0":!A}),children:c.jsx(Nn,{className:"w-4 h-4"})})]},e.id)})},GaA=({section:A})=>{const e=A.formItems[0],{form:t}=ao(),[n,r]=y.useState([]),s=()=>{const u={id:n.length.toString(),order:n.length,value:""};r([...n,u])},a=u=>{if(console.log(n,u),n.findIndex(m=>m.id===u)<=0)return;const g=n.filter(m=>m.id!==u).map((m,p)=>({...m,id:p.toString(),order:p}));r(g);const v=t.getValues();Object.keys(v).filter(m=>m.startsWith(`${A.id}_`)&&m.endsWith(`_${e==null?void 0:e.name}`)).forEach(m=>{t.unregister(m)}),g.forEach(m=>{t.setValue(`${A.id}_${m.id}_${e==null?void 0:e.name}`,m.value)})},o=sv(Is(Ui),Is(Ki,{coordinateGetter:gv}));function i(u){const{active:f,over:d}=u,g=[...n],v=n.findIndex(h=>h.id==(d==null?void 0:d.id)),m=n.findIndex(h=>h.id==(f==null?void 0:f.id)),p=n[m];p&&(g.splice(m,1),g.splice(v,0,p)),g.forEach((h,P)=>[t.setValue(`${A.id}_${P}_${e==null?void 0:e.name}`,h.value)])}const l=()=>{const u=t.getValues(),f=Object.keys(u).filter(d=>d.startsWith(`${A.id}_`)&&d.endsWith(`_${e==null?void 0:e.name}`)).sort();if(f.length===0){r([{id:"0",order:0,value:""}]);return}r(f.map((d,g)=>({id:g.toString(),order:g,value:u[d]||""})))};if(y.useEffect(()=>{l()},[]),y.useEffect(()=>{const u=t.watch((f,{name:d})=>{d!=null&&d.includes(A.id)&&l()});return()=>u.unsubscribe()},[t]),!!e)return c.jsxs("div",{className:"border-l-6 border-transparent",children:[c.jsx(cv,{sensors:o,collisionDetection:av,onDragEnd:i,children:c.jsx(fv,{items:n.map(u=>u.id),strategy:uv,children:n.map((u,f)=>{var d;return c.jsx(YaA,{index:f,step:u,section:A,formField:e,disabled:f?!((d=n[f-1])!=null&&d.value):!1,onDelete:()=>a(u.id)},u.id)})})}),c.jsx("div",{className:"relative py-2 pl-5 flex justify-start mt-2",children:c.jsxs(MA,{variant:"primary",onClick:s,children:[c.jsx(Ao,{className:"w-4 h-4"}),"Add another step"]})})]})},Hy=({main:A=!1,className:e=""})=>{var d,g,v,m;const{state:t,mainForm:n,groups:r}=ao(),{activeGroupId:s}=t,a=A?n:(d=r==null?void 0:r.find)==null?void 0:d.call(r,p=>p.id===s),[o,i]=y.useState(a?(v=(g=a==null?void 0:a.sections)==null?void 0:g[0])==null?void 0:v.id:""),l=a==null?void 0:a.sections,u=l?(m=l.filter)==null?void 0:m.call(l,p=>p.title):[];if(y.useEffect(()=>{var p;i(((p=l==null?void 0:l[0])==null?void 0:p.id)||"")},[a]),!a)return null;const f=p=>p.isDynamic&&p.dynamicType==="steps"?c.jsx(GaA,{section:p}):p.isDynamic?c.jsx(SaA,{section:p}):c.jsx(XaA,{section:p});return c.jsx("div",{className:S("w-full h-full overflow-auto flex p-4",e),children:c.jsxs(bg,{value:o,className:"flex flex-col w-0 flex-1 h-full no-scrollbar overflow-auto !p-0 gap-4",children:[c.jsx(Kc,{className:S("m-0 rounded-none bg-background h-fit gap-4 w-full overflow-x-auto justify-start shadow-none",{hidden:!u.length}),children:u.map(p=>p.title?c.jsxs(Uc,{className:"rounded-full flex gap-2 px-4 py-2 border border-primary opacity-50 data-[state=active]:opacity-100 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",value:p.id,onClick:()=>i(p.id),children:[p.icon&&c.jsx(MA,{variant:"ghost",disabled:!0,size:"icon",className:"h-5 w-5 p-0 disabled:opacity-100",children:p.icon}),p.title]},p.id):null)}),l==null?void 0:l.map(p=>c.jsx(xg,{value:p.id,className:S("flex flex-col max-w-full gap-4 h-0 overflow-auto flex-1 m-0",p.className),children:f(p)},p.id))]})})},IaA=(A=3)=>{const e=y.useRef(null);return y.useEffect(()=>{const t=e.current;if(!t)return;const{lineHeight:n}=getComputedStyle(t),r=parseFloat(n)*A,s=()=>{t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,r)}px`};return s(),t.addEventListener("input",s),t.addEventListener("focusin",s),()=>{t.removeEventListener("input",s),t.removeEventListener("focusin",s)}},[A]),e},QaA=()=>{var d,g,v,m,p,h,P,b,x,z,D,B,M,Y,V,j,C,E,N,q,I;const{autosave:A}=ao(),[e,t]=y.useState(!1);y.useEffect(()=>{t(!0)},[]);const n=()=>{A.toggleEnableAutoSave(!A.autoSaveEnabled)},[r,s]=y.useState(0),a=((d=A.state)==null?void 0:d.status)=="saving",o=((g=A.state)==null?void 0:g.status)=="pending",i=((v=A.state)==null?void 0:v.status)=="error",l=typeof((p=(m=A.state)==null?void 0:m.error)==null?void 0:p.cause)=="string"?(P=(h=A.state)==null?void 0:h.error)==null?void 0:P.cause:((x=(b=A.state)==null?void 0:b.error)==null?void 0:x.message)||"Autosave Error",{showError:u}=$t(),f=y.useCallback(()=>{var G,H;u(l,(H=(G=A.state)==null?void 0:G.error)==null?void 0:H.message)},[u,l,(D=(z=A.state)==null?void 0:z.error)==null?void 0:D.message]);return y.useEffect(()=>{s(G=>G+1)},[A.state]),e?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"group flex justify-end items-center min-w-70",children:[c.jsxs("div",{className:S("group-hover:hidden p-5 py-2 rounded-full border border-primary flex items-center text-sm gap-2",{"flex-wrap gap-y-0":a||o,hidden:!((B=A.state)!=null&&B.status)&&!A.lastSaveDate}),children:[c.jsx(qu,{className:"text-base"}),c.jsx("p",{className:S("hidden gap-1 items-center",{flex:!A.autoSaveEnabled}),children:"Autosave off"}),A.autoSaveEnabled&&c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:!((M=A.state)!=null&&M.status)&&A.lastSaveDate}),children:["Last Saved:",c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"dd-MM-yyyy")}),c.jsx(Fu,{className:"text-xs"}),c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"HH:mm:ss")})]}),c.jsxs("p",{className:S("hidden gap-1 items-center",{block:o||a}),children:["Autosave: ",a?"In Progress":"Waiting"]}),(a||o)&&c.jsx("div",{className:"relative h-[2px] w-full overflow-hidden rounded-full ",children:c.jsx("div",{className:"absolute inset-0 h-full w-full bg-primary",style:{animation:`wazui_progress_bar ${a?"5s":"30s"} ease-in-out`}})},`progress-${r}`),c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:((Y=A.state)==null?void 0:Y.status)=="saved"}),children:["Autosave Complete",c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"dd-mm-yyyy")}),c.jsx(Fu,{className:"text-xs"}),c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"HH:mm:ss")})]}),c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:i}),children:["Autosave",c.jsxs("span",{className:"text-destructive hover:underline max-w-50 truncate",onClick:f,children:["Error | ",l]})]})]})]}),c.jsxs("div",{className:S("hidden group-hover:invisible p-5 py-2 rounded-full border border-primary items-center text-sm gap-2",{"flex-wrap gap-y-0":a||o,flex:!((V=A.state)!=null&&V.status)&&!A.lastSaveDate&&!A.autoSaveEnabled}),children:[c.jsx(qu,{className:"text-base"}),c.jsx("p",{className:S("hidden gap-1 items-center",{flex:!A.autoSaveEnabled||!((j=A.state)!=null&&j.status)}),children:"Autosave off"}),A.autoSaveEnabled&&c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:!((C=A.state)!=null&&C.status)&&A.lastSaveDate}),children:["Last Saved:",c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"dd-MM-yyyy")}),c.jsx(Fu,{className:"text-xs"}),c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"HH:mm:ss")})]}),c.jsxs("p",{className:S("hidden gap-1 items-center",{block:o||a}),children:["Autosave: ",a?"In Progress":"Waiting"]}),(a||o)&&c.jsx("div",{className:"relative h-[2px] w-full overflow-hidden rounded-full ",children:c.jsx("div",{className:"absolute inset-0 h-full w-full bg-primary",style:{animation:`wazui_progress_bar ${a?"5s":"30s"} ease-in-out`}})},`progress-${r}`),c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:((E=A.state)==null?void 0:E.status)=="saved"}),children:["Autosave Complete",c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"dd-mm-yyyy")}),c.jsx(Fu,{className:"text-xs"}),c.jsx("span",{children:A.lastSaveDate&&Me(A.lastSaveDate,"HH:mm:ss")})]}),c.jsxs("p",{className:S("hidden gap-1 items-center",{flex:((N=A.state)==null?void 0:N.status)=="error"}),children:["Autosave",c.jsxs("span",{className:"text-destructive max-w-50 truncate",children:["Error | ",(I=(q=A.state)==null?void 0:q.error)==null?void 0:I.message]})]})]})]}),c.jsxs("div",{className:S("hidden group-hover:flex border cursor-pointer rounded-full p-4 py-2 text-xs items-center gap-2",{"border-destructive text-destructive ":A.autoSaveEnabled}),onClick:n,children:[c.jsx(qu,{className:"text-base"}),c.jsx("p",{children:A.autoSaveEnabled?"Disable Autosave":"Enable Autosave"})]})]}),i&&c.jsx(BnA,{className:"text-destructive text-md animate-bounce",onClick:f})]}):c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("div",{className:"group flex justify-end items-center min-w-70",children:c.jsxs("div",{className:"p-5 py-2 rounded-full border border-primary flex items-center text-sm gap-2",children:[c.jsx(qu,{className:"text-base"}),c.jsx("p",{className:"gap-1 items-center flex",children:"Loading..."})]})})})},LaA=()=>{var G,H;const{state:A,form:e,handlePublish:t,handleSaveDraft:n,handleSaveTitle:r,postQuery:{isLoading:s,error:a},type:o,mainForm:i,groups:l,createMutation:{isPending:u},updateMutation:{isPending:f},dispatch:d,showTitle:g,baseUrl:v,isPopup:m,formTitle:p,actionButtonTitle:h,showDraft:P,showAutoSave:b}=ao(),{activeGroupId:x}=A,z=e.getValues("uuid"),D=A.isDraft,B=e.formState.isDirty,[M,Y]=y.useState(!0),V=IaA(M?1:3),j=T=>{d({type:"SET_ACTIVE_GROUP",payload:T})},C=A.isCreate;let E=p,N=h;E||(C?E="Create "+o:E="Edit "+o),N||(C||D?N="Publish "+o:N="Update "+o);const q=async()=>{e.getValues("title")&&await r(),Y(!0)},I=T=>T>=75?"text-destructive":T>=65?"text-[#FFAA00]":T>=55?"text-[#229954]":T>=45?"text-[#FFAA00]":"text-muted-foreground";return c.jsx(c9,{...e,children:c.jsxs("form",{className:"w-full flex flex-col p-0",onSubmit:T=>T.preventDefault(),onKeyDown:T=>{T.key==="Enter"&&!(T.target instanceof HTMLButtonElement&&T.target.type==="submit")&&T.preventDefault()},children:[s&&!C&&!z&&c.jsx("div",{className:"absolute inset-0 bg-white/50 backdrop-blur-sm flex items-center justify-center z-10",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dh,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{children:"Loading..."})]})}),a&&!C&&!z&&c.jsx("div",{className:"absolute inset-0 bg-white/50 backdrop-blur-sm flex items-center justify-center z-10",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ts,{className:"h-6 w-6"}),c.jsxs("span",{children:["Error: ",a==null?void 0:a.message]})]})}),m&&c.jsx("h1",{className:S("text-md font-bold bg-[#FADDD3] w-full p-4"),children:E}),c.jsxs("div",{className:"w-full h-full flex overflow-auto gap-2 items-stretch","data-testid":"main-form",children:[c.jsxs("div",{className:S("flex-2/3 flex flex-col items-start justify-between gap-5 p-4",{"pb-0":!m}),children:[c.jsx("h1",{className:S("text-3xl font-bold font-[UniversalFeature] !m-0",{hidden:m}),children:E}),c.jsxs("div",{className:"w-full flex items-center justify-between flex-wrap gap-2 ",children:[v&&c.jsx(H0,{url:v,pageTitle:`${C?"Create":"Edit"} ${o}`}),b&&c.jsx(QaA,{})]}),g&&c.jsx(eo,{control:e.control,name:"title",render:({field:T,fieldState:Z})=>{var k,X,J;const O=(X=(k=T.value)==null?void 0:k.toString())==null?void 0:X.trim();return c.jsxs("div",{className:"w-full",children:[Z.error&&c.jsxs("span",{className:"flex items-center mb-1 gap-1",children:[c.jsx(B0,{className:"text-destructive text-xl"}),c.jsx("span",{className:" capitalize text-xs text-muted-foreground",children:(J=Z.error)==null?void 0:J.message})]}),c.jsxs("div",{className:S("flex items-center justify-center w-full gap-2"),children:[c.jsxs("div",{className:S("flex items-center justify-center w-full gap-2 slight_border border-secondary! p-1 px-2 rounded",{"border-primary!":!M}),children:[c.jsx(fr,{className:"flex-1",children:c.jsx(to,{className:"w-full",children:c.jsx(zg,{className:S("h-fit min-h-0 p-0 w-full placeholder:opacity-50 text-2xl! font-[UniversalFeature] no-scrollbar shadow-none flex-1 border-0 bg-transparent hover:bg-transparent focus:border-0 focus:outline-none focus:ring-0 focus:ring-offset-0 focus-visible:ring-0 focus-visible:ring-offset-0",{"opacity-50":M}),ref:V,placeholder:"Enter Title here","aria-disabled":M,value:T.value,onChange:T.onChange,rows:1,onBlur:()=>Y(!0),"data-testid":"title-input",onClick:()=>Y(!1)})})}),c.jsxs(MA,{variant:"outline",className:S("p-3 h-5 rounded-full border-secondary gap-1 hover:bg-transparent capitalize text-muted-foreground text-sm",{"border-primary":!M}),onClick:()=>M?Y(!1):q(),children:[M?c.jsx(Xi,{className:"text-sm"}):c.jsx(k0,{className:"text-sm text-primary"}),M?"edit":"save"]})]}),c.jsx("div",{className:S("flex",I(O==null?void 0:O.length)),"data-testid":"title-word-count",children:c.jsx("span",{className:"text-sm",children:`${(O==null?void 0:O.length)||0}/65`})}),c.jsx(at,{className:S("capitalize bg-muted w-fit p-2 py-1",{"border-[#229954] text-[#229954] bg-transparent":!D}),children:D?"draft":"published"})]})]})}},"title"),i&&c.jsx(Hy,{main:!0,className:"flex-1 grow w-full p-0 "})]}),(l==null?void 0:l.length)&&c.jsxs(bg,{defaultValue:(G=l[0])==null?void 0:G.id,value:x,className:"flex-1/3 flex flex-col h-full no-scrollbar overflow-auto p-0 flex-wrap",children:[c.jsx(Kc,{className:"rounded-none justify-start bg-black p-4 h-fit gap-4 w-full overflow-x-auto no-scrollbar",children:(l==null?void 0:l.length)&&l.map(T=>c.jsxs(Uc,{className:"rounded-full p-2 px-4 gap-1 slight_border text-[#9C9C9C] group data-[state=active]:text-primary-foreground data-[state=active]:bg-primary data-[state=active]:border-none cursor-pointer",value:T.id,onClick:Z=>{Z.preventDefault(),j(T.id)},children:[T.icon&&c.jsx("div",{className:"opacity-100 h-5 w-5 flex items-center justify-center",children:T.icon&&T.icon}),T.title]},T.id))}),c.jsx(xg,{className:"flex-1 h-0 m-0 border-l",value:x||((H=l[0])==null?void 0:H.id),children:c.jsx(Hy,{})})]})]}),c.jsxs("div",{className:S("flex gap-4 p-2 bg-muted w-full justify-end ",{hidden:m||!P}),children:[c.jsx(he,{className:S(" p-4 hidden waz_shadow bg-[#A9D3B8] font-bold text-base px-4 text-[#101828]",{flex:D||C}),onClick:()=>n(),type:"button",disabled:u||f,children:"Save as Draft"}),c.jsx(he,{className:S(" p-4 flex waz_shadow font-bold text-[#101828] text-base px-4 gap-1",{}),disabled:u||f,onClick:()=>t(),trailingIcon:c.jsx(ItA,{}),children:N})]}),(m||!P)&&c.jsx("div",{className:S("flex gap-4 p-2 w-full justify-end "),children:c.jsx(he,{className:S(" p-4 hidden waz_shadow font-bold text-[#101828] text-base px-4 gap-1",{flex:B||D}),disabled:u||f,onClick:t,children:N})})]})})},pu=({type:A="Post",showDraft:e=!0,formTitle:t,actionButtonTitle:n,showTitle:r=!0,isPopup:s=!1,baseUrl:a="",postBaseUrl:o,className:i,post_uuid:l="",groups:u,initialState:f={},mainForm:d,validators:g,requiredDraftFields:v,postQueryConfig:m,createMessage:p,updateMessage:h,formFieldsMapper:P,submitFieldsMapper:b,onBack:x,onSave:z,onChange:D,showDescriptionOnSubmit:B,autoSave:M,user_config:Y})=>{var V;return c.jsx(wc,{children:c.jsx(ZaA,{initialState:{...f,uuid:l,activeGroupId:u&&(u==null?void 0:u.length)>0?(V=u[0])==null?void 0:V.id:""},showTitle:r,showDraft:e,formTitle:t,createMessage:p,updateMessage:h,actionButtonTitle:n,baseUrl:a,postBaseUrl:o,type:A,postQueryConfig:m,validators:g,requiredDraftFields:v,formFieldsMapper:P,submitFieldsMapper:b,onBack:x,onSave:z,groups:u,onChange:D,mainForm:d,isPopup:s,showDescriptionOnSubmit:B,autoSave:M,user_config:Y,children:c.jsx("main",{className:S("w-full h-screen bg-background flex flex-1 overflow-y-auto p-0",i),children:c.jsx(LaA,{})})})})};function fj(A){return UA({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2"},child:[]},{tag:"path",attr:{d:"M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z"},child:[]},{tag:"path",attr:{d:"M9 12l.01 0"},child:[]},{tag:"path",attr:{d:"M13 12l2 0"},child:[]},{tag:"path",attr:{d:"M9 16l.01 0"},child:[]},{tag:"path",attr:{d:"M13 16l2 0"},child:[]}]})(A)}function bf(A){return UA({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M14 3v4a1 1 0 0 0 1 1h4"},child:[]},{tag:"path",attr:{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"},child:[]},{tag:"path",attr:{d:"M9 17h6"},child:[]},{tag:"path",attr:{d:"M9 13h6"},child:[]}]})(A)}const JaA=hA(`
|
|
436
436
|
query MyQuery(
|
|
437
437
|
$first: Int!
|
|
438
438
|
$blog_uuid: String
|
|
@@ -2104,5 +2104,5 @@ Please change the parent <Route path="${P}"> to <Route path="${P==="/"?"*":`${P}
|
|
|
2104
2104
|
}
|
|
2105
2105
|
}
|
|
2106
2106
|
}
|
|
2107
|
-
`;function EcA({searchValue:A,apolloUri:e}){const t=y.useMemo(()=>({query:TcA,variables:{first:350},dataKey:"users"}),[]),n=na(e),r=qg(A||"",300),s=y.useCallback(async({pageParam:a=1})=>{if(t!=null&&t.query){const o=t==null?void 0:t.query,i=t==null?void 0:t.variables,f=(await n.query({query:o,variables:{...i||{},search:r,page:a}})).data[t.dataKey];return{paginatorInfo:f.paginatorInfo||{currentPage:1,lastPage:1},data:f==null?void 0:f.data}}else throw console.error("Invalid Query Configuration"),Error("Invalid Query Configuration")},[n,t,r]);return Jg({queryKey:[t==null?void 0:t.dataKey,r],queryFn:s,getNextPageParam:a=>{var o,i;if(((o=a==null?void 0:a.paginatorInfo)==null?void 0:o.currentPage)<((i=a==null?void 0:a.paginatorInfo)==null?void 0:i.lastPage))return a.paginatorInfo.currentPage+1},initialPageParam:1,staleTime:300*1e3,gcTime:600*1e3,refetchOnMount:!1,refetchOnWindowFocus:!1})}const Yy={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_ATHENS_APP_ID:"ak_707d0dcd4ecff2cfd9361b2fed7bfb79",VITE_ATHENS_APP_SECRET:"sk_797fe529520c182ab5986999c35d8528ab12e543b5093190be91e4c871dbeb4f",VITE_BLOG_UUID:"2ee767d4-91bb-414b-b8c8-ac5105f94c55",VITE_COOKIE_SAMESITE:"lax",VITE_COOKIE_SECURE:"true",VITE_DOLOS_TRANSFORMATION_ENDPOINT:"https://images.twistedfood.co.uk",VITE_DOLOS_URL:"https://dolos.hivedeck.com/graphql",VITE_FALLBACK_APP_ID:"hogfort_athens_test",VITE_FALLBACK_APP_SECRET:"hogfort_athens_test",VITE_FALLBACK_SERVICE_ID:"hogfort_athens_test",VITE_GRAPHQL_URL:"https://devapi.junglecreations.com/graphql",VITE_GRAPH_QL_URL:"https://devapi.junglecreations.com/graphql",VITE_LOGIN_PASSWORD:"Testing123@",VITE_LOGIN_USERNAME:"jungle@junglecreations.com",VITE_MERCURY_TOKEN_ENDPOINT:"https://mercury.tiadara.com/project/token",VITE_MUSE_ENDPOINT:"https://muse.tiadara.com/graphql",VITE_MUSE_GRAPHQL_URL:"https://muse.tiadara.com/graphql",VITE_MUSE_TOKEN:"token",VITE_PHOENIX_ENDPOINT:"http://51.38.80.88:8001/graphql",VITE_PORTAL_GRAPHQL_ENDPOINT:"https://devapi.junglecreations.com/graphql",VITE_PROJECT_TOKEN:"token",VITE_PROJECT_UUID:"c26038a7-fc3b-4992-aa50-a4fdf8340aa3",VITE_RECIPES_ENDPOINT:"https://recipes-api.junglecreations.com/graphql",VITE_RECIPE_GRAPHQL_URL:"https://recipes-api.junglecreations.com/graphql",VITE_REST_URL:"https://devapi.junglecreations.com/",VITE_REVALIDATION_TWISTEDFOOD_TOKEN:"token",VITE_REVALIDATION_VT_TOKEN:"df870c4335ad9d4402dfccdf7000a3c9",VITE_TWISTEDFOOD_BLOG_UUID:"6b2693df-8bdb-4692-9dfb-9a8def92c7ff",VITE_TWISTED_FACEBOOK_APP_ID:"350747620164851",VITE_VT_FACEBOOK_APP_ID:"579652316548451"},eO=Ne({NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT:iA().default("https://localhost:3000/graphql"),NEXT_PUBLIC_DOLOS_URL:iA().default("https://localhost:3001"),NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT:iA().default("https://localhost:3001/transform"),NEXT_PUBLIC_MUSE_TOKEN:iA().default("dev-token"),NEXT_PUBLIC_MUSE_ENDPOINT:iA().default("https://localhost:3003"),NEXT_PUBLIC_RECIPES_ENDPOINT:iA().default("https://localhost:3002"),NEXT_PUBLIC_PHOENIX_ENDPOINT:iA().default("https://localhost:3004"),NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT:iA().default("https://localhost:3005/token"),NEXT_PUBLIC_ATHENS_APP_ID:iA().default("dev-athens-id"),NEXT_PUBLIC_ATHENS_APP_SECRET:iA().default("dev-athens-secret"),NEXT_PUBLIC_PROJECT_TOKEN:iA().default("dev-project-token"),NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN:iA().default("dev-revalidation-token"),NEXT_PUBLIC_REVALIDATION_VT_TOKEN:iA().default("dev-vt-token"),NEXT_PUBLIC_GRAPH_QL_URL:iA().optional(),NEXT_PUBLIC_MUSE_GRAPHQL_URL:iA().optional(),NEXT_PUBLIC_RECIPE_GRAPHQL_URL:iA().optional()});function R0(){var t,n,r,s;const A=typeof window<"u";if(typeof process<"u"&&((t=process.env)==null?void 0:t.NODE_ENV)==="test")return{NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT:process.env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_DOLOS_URL:process.env.NEXT_PUBLIC_DOLOS_URL||"https://fallback.test",NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT:process.env.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_MUSE_TOKEN:process.env.NEXT_PUBLIC_MUSE_TOKEN||"fallback-token",NEXT_PUBLIC_MUSE_ENDPOINT:process.env.NEXT_PUBLIC_MUSE_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_RECIPES_ENDPOINT:process.env.NEXT_PUBLIC_RECIPES_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_PHOENIX_ENDPOINT:process.env.NEXT_PUBLIC_PHOENIX_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT:process.env.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_ATHENS_APP_ID:process.env.NEXT_PUBLIC_ATHENS_APP_ID||"fallback-id",NEXT_PUBLIC_ATHENS_APP_SECRET:process.env.NEXT_PUBLIC_ATHENS_APP_SECRET||"fallback-secret",NEXT_PUBLIC_PROJECT_TOKEN:process.env.NEXT_PUBLIC_PROJECT_TOKEN||"fallback-token",NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN:process.env.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN||"fallback-token",NEXT_PUBLIC_REVALIDATION_VT_TOKEN:process.env.NEXT_PUBLIC_REVALIDATION_VT_TOKEN||"fallback-token",NEXT_PUBLIC_GRAPH_QL_URL:process.env.NEXT_PUBLIC_GRAPH_QL_URL||"",NEXT_PUBLIC_MUSE_GRAPHQL_URL:process.env.NEXT_PUBLIC_MUSE_GRAPHQL_URL||"",NEXT_PUBLIC_RECIPE_GRAPHQL_URL:process.env.NEXT_PUBLIC_RECIPE_GRAPHQL_URL||""};let e={};if(typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:xv&&xv.tagName.toUpperCase()==="SCRIPT"&&xv.src||new URL("index-e6grgv3t.cjs",document.baseURI).href}<"u"&&Yy)e=Yy;else if(typeof process<"u"&&process.env)e=process.env;else if(A&&typeof window<"u"){const a=window;(n=a.__NEXT_DATA__)!=null&&n.env?e=a.__NEXT_DATA__.env:(r=a.__NEXT_DATA__)!=null&&r.runtimeConfig?e=a.__NEXT_DATA__.runtimeConfig:(s=a.process)!=null&&s.env&&(e=a.process.env)}return{NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT:e.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT,NEXT_PUBLIC_DOLOS_URL:e.NEXT_PUBLIC_DOLOS_URL,NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT:e.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT,NEXT_PUBLIC_MUSE_TOKEN:e.NEXT_PUBLIC_MUSE_TOKEN,NEXT_PUBLIC_MUSE_ENDPOINT:e.NEXT_PUBLIC_MUSE_ENDPOINT,NEXT_PUBLIC_RECIPES_ENDPOINT:e.NEXT_PUBLIC_RECIPES_ENDPOINT,NEXT_PUBLIC_PHOENIX_ENDPOINT:e.NEXT_PUBLIC_PHOENIX_ENDPOINT,NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT:e.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT,NEXT_PUBLIC_ATHENS_APP_ID:e.NEXT_PUBLIC_ATHENS_APP_ID,NEXT_PUBLIC_ATHENS_APP_SECRET:e.NEXT_PUBLIC_ATHENS_APP_SECRET,NEXT_PUBLIC_PROJECT_TOKEN:e.NEXT_PUBLIC_PROJECT_TOKEN,NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN:e.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN,NEXT_PUBLIC_REVALIDATION_VT_TOKEN:e.NEXT_PUBLIC_REVALIDATION_VT_TOKEN,NEXT_PUBLIC_GRAPH_QL_URL:e.NEXT_PUBLIC_GRAPH_QL_URL,NEXT_PUBLIC_MUSE_GRAPHQL_URL:e.NEXT_PUBLIC_MUSE_GRAPHQL_URL,NEXT_PUBLIC_RECIPE_GRAPHQL_URL:e.NEXT_PUBLIC_RECIPE_GRAPHQL_URL}}const tO=y.createContext(null);function HcA({children:A,env:e}){const t=e||R0(),n=eO.parse(t);return c.jsx(tO.Provider,{value:n,children:A})}function NcA(){const A=y.useContext(tO);if(A)return A;const e=R0();return eO.parse(e)}Ie.addDefaultLocale(U6);Ie.addLocale(_6);exports.Alert=ZV;exports.AlertDescription=SV;exports.AlertTitle=VV;exports.Badge=at;exports.BlogCategoryContent=Pj;exports.BlogPostContentComponent=olA;exports.BlogPostsComponent=UaA;exports.BlogStatus=Rt;exports.BlogTagContent=Gj;exports.Breadcrumb=Ez;exports.BreadcrumbEllipsis=XV;exports.BreadcrumbItem=mp;exports.BreadcrumbLink=Nz;exports.BreadcrumbList=Hz;exports.BreadcrumbPage=kz;exports.BreadcrumbSeparator=Zz;exports.Button=MA;exports.Calendar=Wd;exports.Card=hr;exports.CardContent=Hs;exports.CardDescription=t8;exports.CardFooter=Fd;exports.CardHeader=Es;exports.CardTitle=oi;exports.CategoriesComponent=aoA;exports.Checkbox=c8;exports.ClearCacheHistory=ulA;exports.Collapsible=kY;exports.CollapsibleContent=VY;exports.CollapsibleTrigger=ZY;exports.ColumnFaceting=V5;exports.ColumnFiltering=q5;exports.ColumnGrouping=R5;exports.ColumnOrdering=F5;exports.ColumnPinning=K5;exports.ColumnSizing=U5;exports.ColumnVisibility=$5;exports.Command=Lc;exports.CommandDialog=CG;exports.CommandEmpty=ag;exports.CommandGroup=og;exports.CommandInput=A9;exports.CommandItem=ig;exports.CommandList=sg;exports.CommandSeparator=Y8;exports.CommandShortcut=G8;exports.ContextMenu=l1;exports.ContextMenuCheckboxItem=lI;exports.ContextMenuContent=u1;exports.ContextMenuGroup=nI;exports.ContextMenuItem=yp;exports.ContextMenuLabel=uI;exports.ContextMenuPortal=rI;exports.ContextMenuRadioGroup=aI;exports.ContextMenuRadioItem=cI;exports.ContextMenuSeparator=f1;exports.ContextMenuShortcut=d1;exports.ContextMenuSub=sI;exports.ContextMenuSubContent=iI;exports.ContextMenuSubTrigger=oI;exports.ContextMenuTrigger=c1;exports.Dialog=_t;exports.DialogClose=MG;exports.DialogContent=Vt;exports.DialogDescription=ki;exports.DialogFooter=Dr;exports.DialogHeader=Ln;exports.DialogOverlay=$h;exports.DialogPortal=X8;exports.DialogTitle=Jn;exports.DialogTrigger=BG;exports.DropdownMenu=PV;exports.DropdownMenuCheckboxItem=BV;exports.DropdownMenuContent=xV;exports.DropdownMenuGroup=zV;exports.DropdownMenuItem=DV;exports.DropdownMenuLabel=jV;exports.DropdownMenuPortal=yV;exports.DropdownMenuRadioGroup=MV;exports.DropdownMenuRadioItem=CV;exports.DropdownMenuSeparator=OV;exports.DropdownMenuShortcut=TV;exports.DropdownMenuSub=EV;exports.DropdownMenuSubContent=NV;exports.DropdownMenuSubTrigger=HV;exports.DropdownMenuTrigger=bV;exports.FilterFieldType=OA;exports.Form=c9;exports.FormControl=to;exports.FormDescription=j1;exports.FormField=eo;exports.FormItem=fr;exports.FormLabel=u9;exports.FormMessage=O1;exports.GlobalFaceting=AB;exports.GlobalFiltering=eB;exports.Headers=Z5;exports.Input=hn;exports.Label=fg;exports.PagesComponent=OcA;exports.Popover=Zi;exports.PopoverContent=no;exports.PopoverTrigger=Vi;exports.PurgeCache=ilA;exports.QueryProvider=yaA;exports.RadioGroup=g9;exports.RadioGroupItem=v9;exports.RecipeCategories=GlA;exports.RecipeContentComponent=PlA;exports.RecipeTags=OlA;exports.RecipesComponent=IiA;exports.RedirectsComponent=UiA;exports.RowExpanding=tB;exports.RowPagination=nB;exports.RowPinning=rB;exports.RowSelection=sB;exports.RowSorting=oB;exports.Select=li;exports.SelectContent=qa;exports.SelectGroup=LQ;exports.SelectItem=cr;exports.SelectLabel=YD;exports.SelectScrollDownButton=h9;exports.SelectScrollUpButton=p9;exports.SelectSeparator=GD;exports.SelectTrigger=Ja;exports.SelectValue=ci;exports.Separator=LD;exports.Sheet=w9;exports.SheetClose=sL;exports.SheetContent=P9;exports.SheetDescription=x9;exports.SheetFooter=qD;exports.SheetHeader=y9;exports.SheetTitle=b9;exports.SheetTrigger=JD;exports.Sidebar=ZL;exports.SidebarContent=LL;exports.SidebarFooter=IL;exports.SidebarGroup=JL;exports.SidebarGroupAction=RL;exports.SidebarGroupContent=WL;exports.SidebarGroupLabel=qL;exports.SidebarHeader=GL;exports.SidebarInput=YL;exports.SidebarInset=XL;exports.SidebarMenu=FL;exports.SidebarMenuAction=$L;exports.SidebarMenuBadge=AJ;exports.SidebarMenuButton=_L;exports.SidebarMenuItem=KL;exports.SidebarMenuSkeleton=eJ;exports.SidebarMenuSub=tJ;exports.SidebarMenuSubButton=rJ;exports.SidebarMenuSubItem=nJ;exports.SidebarProvider=kL;exports.SidebarRail=SL;exports.SidebarSeparator=QL;exports.SidebarTrigger=VL;exports.Skeleton=Rf;exports.Switch=B9;exports.Table=KJ;exports.TableBody=_J;exports.TableCaption=nq;exports.TableCell=tq;exports.TableFooter=$J;exports.TableHead=eq;exports.TableHeader=UJ;exports.TableRow=Aq;exports.Tabs=bg;exports.TabsContent=xg;exports.TabsList=Kc;exports.TabsTrigger=Uc;exports.TagsComponent=YiA;exports.Textarea=zg;exports.ThemeProvider=haA;exports.Toaster=FJ;exports.Toggle=O5;exports.ToggleGroup=Ff;exports.ToggleGroupItem=Kf;exports.Tooltip=Ca;exports.TooltipContent=Oa;exports.TooltipProvider=fi;exports.TooltipTrigger=ja;exports.WazUIBlogComponent=Cr;exports.WazUIBlogDashboard=xcA;exports.WazUIButton=he;exports.WazUIEnvironmentProvider=HcA;exports.WazUIPostActions=maA;exports.WazUIPostCategories=vu;exports.WazUIPostStatistics=mu;exports.WazUIPostTags=_i;exports.WazUiCreateBlogContent=pu;exports.WazUiGqlMediaLibrary=M4;exports.WazUiPostCard=N0;exports.WazuiActionModalProvider=wc;exports._getVisibleLeafColumns=Zo;exports.aggregationFns=rf;exports.badgeVariants=Tz;exports.buildHeaderGroups=Pl;exports.cleanHTML=Wr;exports.commonjsGlobal=Mf;exports.createCell=N5;exports.createColumn=k5;exports.createColumnHelper=sq;exports.createNextConfig=uC;exports.createRow=Au;exports.createTable=iB;exports.debugNextConfig=fC;exports.defaultColumnSizing=yl;exports.env=re;exports.expandRows=N9;exports.fetchMercuryToken=u0;exports.filterFns=$n;exports.flattenBy=T9;exports.flexRender=Vp;exports.functionalUpdate=Ir;exports.getAutoDetectedEnvironment=R0;exports.getCoreRowModel=lB;exports.getDefaultExportFromCjs=jc;exports.getEnv=dC;exports.getExpandedRowModel=zq;exports.getFacetedMinMaxValues=Dq;exports.getFacetedRowModel=Cq;exports.getFacetedUniqueValues=jq;exports.getFilteredRowModel=uB;exports.getGroupedRowModel=Oq;exports.getMemoOptions=ZA;exports.getPaginationRowModel=fB;exports.getSortedRowModel=dB;exports.isFunction=$c;exports.isNumberArray=H5;exports.isRowSelected=Bg;exports.isSubRowSelected=Uf;exports.makeStateUpdater=Kt;exports.memo=kA;exports.noop=aq;exports.orderColumns=W5;exports.passiveEventSupported=_5;exports.reSplitAlphaNumeric=_f;exports.selectRowsFn=sf;exports.shouldAutoRemoveFilter=Hp;exports.sortingFns=wo;exports.toggleVariants=O9;exports.useAuthors=EcA;exports.useFormField=qc;exports.useReactTable=gB;exports.useSidebar=Fc;exports.useTheme=waA;exports.useWazUIEnvironment=NcA;exports.withReactQuery=xaA;
|
|
2108
|
-
//# sourceMappingURL=index-
|
|
2107
|
+
`;function EcA({searchValue:A,apolloUri:e}){const t=y.useMemo(()=>({query:TcA,variables:{first:350},dataKey:"users"}),[]),n=na(e),r=qg(A||"",300),s=y.useCallback(async({pageParam:a=1})=>{if(t!=null&&t.query){const o=t==null?void 0:t.query,i=t==null?void 0:t.variables,f=(await n.query({query:o,variables:{...i||{},search:r,page:a}})).data[t.dataKey];return{paginatorInfo:f.paginatorInfo||{currentPage:1,lastPage:1},data:f==null?void 0:f.data}}else throw console.error("Invalid Query Configuration"),Error("Invalid Query Configuration")},[n,t,r]);return Jg({queryKey:[t==null?void 0:t.dataKey,r],queryFn:s,getNextPageParam:a=>{var o,i;if(((o=a==null?void 0:a.paginatorInfo)==null?void 0:o.currentPage)<((i=a==null?void 0:a.paginatorInfo)==null?void 0:i.lastPage))return a.paginatorInfo.currentPage+1},initialPageParam:1,staleTime:300*1e3,gcTime:600*1e3,refetchOnMount:!1,refetchOnWindowFocus:!1})}const Yy={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_ATHENS_APP_ID:"ak_707d0dcd4ecff2cfd9361b2fed7bfb79",VITE_ATHENS_APP_SECRET:"sk_797fe529520c182ab5986999c35d8528ab12e543b5093190be91e4c871dbeb4f",VITE_BLOG_UUID:"2ee767d4-91bb-414b-b8c8-ac5105f94c55",VITE_COOKIE_SAMESITE:"lax",VITE_COOKIE_SECURE:"true",VITE_DOLOS_TRANSFORMATION_ENDPOINT:"https://images.twistedfood.co.uk",VITE_DOLOS_URL:"https://dolos.hivedeck.com/graphql",VITE_FALLBACK_APP_ID:"hogfort_athens_test",VITE_FALLBACK_APP_SECRET:"hogfort_athens_test",VITE_FALLBACK_SERVICE_ID:"hogfort_athens_test",VITE_GRAPHQL_URL:"https://devapi.junglecreations.com/graphql",VITE_GRAPH_QL_URL:"https://devapi.junglecreations.com/graphql",VITE_LOGIN_PASSWORD:"Testing123@",VITE_LOGIN_USERNAME:"jungle@junglecreations.com",VITE_MERCURY_TOKEN_ENDPOINT:"https://mercury.tiadara.com/project/token",VITE_MUSE_ENDPOINT:"https://muse.tiadara.com/graphql",VITE_MUSE_GRAPHQL_URL:"https://muse.tiadara.com/graphql",VITE_MUSE_TOKEN:"token",VITE_PHOENIX_ENDPOINT:"http://51.38.80.88:8001/graphql",VITE_PORTAL_GRAPHQL_ENDPOINT:"https://devapi.junglecreations.com/graphql",VITE_PROJECT_TOKEN:"token",VITE_PROJECT_UUID:"c26038a7-fc3b-4992-aa50-a4fdf8340aa3",VITE_RECIPES_ENDPOINT:"https://recipes-api.junglecreations.com/graphql",VITE_RECIPE_GRAPHQL_URL:"https://recipes-api.junglecreations.com/graphql",VITE_REST_URL:"https://devapi.junglecreations.com/",VITE_REVALIDATION_TWISTEDFOOD_TOKEN:"token",VITE_REVALIDATION_VT_TOKEN:"df870c4335ad9d4402dfccdf7000a3c9",VITE_TWISTEDFOOD_BLOG_UUID:"6b2693df-8bdb-4692-9dfb-9a8def92c7ff",VITE_TWISTED_FACEBOOK_APP_ID:"350747620164851",VITE_VT_FACEBOOK_APP_ID:"579652316548451"},eO=Ne({NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT:iA().default("https://localhost:3000/graphql"),NEXT_PUBLIC_DOLOS_URL:iA().default("https://localhost:3001"),NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT:iA().default("https://localhost:3001/transform"),NEXT_PUBLIC_MUSE_TOKEN:iA().default("dev-token"),NEXT_PUBLIC_MUSE_ENDPOINT:iA().default("https://localhost:3003"),NEXT_PUBLIC_RECIPES_ENDPOINT:iA().default("https://localhost:3002"),NEXT_PUBLIC_PHOENIX_ENDPOINT:iA().default("https://localhost:3004"),NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT:iA().default("https://localhost:3005/token"),NEXT_PUBLIC_ATHENS_APP_ID:iA().default("dev-athens-id"),NEXT_PUBLIC_ATHENS_APP_SECRET:iA().default("dev-athens-secret"),NEXT_PUBLIC_PROJECT_TOKEN:iA().default("dev-project-token"),NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN:iA().default("dev-revalidation-token"),NEXT_PUBLIC_REVALIDATION_VT_TOKEN:iA().default("dev-vt-token"),NEXT_PUBLIC_GRAPH_QL_URL:iA().optional(),NEXT_PUBLIC_MUSE_GRAPHQL_URL:iA().optional(),NEXT_PUBLIC_RECIPE_GRAPHQL_URL:iA().optional()});function R0(){var t,n,r,s;const A=typeof window<"u";if(typeof process<"u"&&((t=process.env)==null?void 0:t.NODE_ENV)==="test")return{NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT:process.env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_DOLOS_URL:process.env.NEXT_PUBLIC_DOLOS_URL||"https://fallback.test",NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT:process.env.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_MUSE_TOKEN:process.env.NEXT_PUBLIC_MUSE_TOKEN||"fallback-token",NEXT_PUBLIC_MUSE_ENDPOINT:process.env.NEXT_PUBLIC_MUSE_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_RECIPES_ENDPOINT:process.env.NEXT_PUBLIC_RECIPES_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_PHOENIX_ENDPOINT:process.env.NEXT_PUBLIC_PHOENIX_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT:process.env.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT||"https://fallback.test",NEXT_PUBLIC_ATHENS_APP_ID:process.env.NEXT_PUBLIC_ATHENS_APP_ID||"fallback-id",NEXT_PUBLIC_ATHENS_APP_SECRET:process.env.NEXT_PUBLIC_ATHENS_APP_SECRET||"fallback-secret",NEXT_PUBLIC_PROJECT_TOKEN:process.env.NEXT_PUBLIC_PROJECT_TOKEN||"fallback-token",NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN:process.env.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN||"fallback-token",NEXT_PUBLIC_REVALIDATION_VT_TOKEN:process.env.NEXT_PUBLIC_REVALIDATION_VT_TOKEN||"fallback-token",NEXT_PUBLIC_GRAPH_QL_URL:process.env.NEXT_PUBLIC_GRAPH_QL_URL||"",NEXT_PUBLIC_MUSE_GRAPHQL_URL:process.env.NEXT_PUBLIC_MUSE_GRAPHQL_URL||"",NEXT_PUBLIC_RECIPE_GRAPHQL_URL:process.env.NEXT_PUBLIC_RECIPE_GRAPHQL_URL||""};let e={};if(typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:xv&&xv.tagName.toUpperCase()==="SCRIPT"&&xv.src||new URL("index-BM2sjY9N.cjs",document.baseURI).href}<"u"&&Yy)e=Yy;else if(typeof process<"u"&&process.env)e=process.env;else if(A&&typeof window<"u"){const a=window;(n=a.__NEXT_DATA__)!=null&&n.env?e=a.__NEXT_DATA__.env:(r=a.__NEXT_DATA__)!=null&&r.runtimeConfig?e=a.__NEXT_DATA__.runtimeConfig:(s=a.process)!=null&&s.env&&(e=a.process.env)}return{NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT:e.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT,NEXT_PUBLIC_DOLOS_URL:e.NEXT_PUBLIC_DOLOS_URL,NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT:e.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT,NEXT_PUBLIC_MUSE_TOKEN:e.NEXT_PUBLIC_MUSE_TOKEN,NEXT_PUBLIC_MUSE_ENDPOINT:e.NEXT_PUBLIC_MUSE_ENDPOINT,NEXT_PUBLIC_RECIPES_ENDPOINT:e.NEXT_PUBLIC_RECIPES_ENDPOINT,NEXT_PUBLIC_PHOENIX_ENDPOINT:e.NEXT_PUBLIC_PHOENIX_ENDPOINT,NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT:e.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT,NEXT_PUBLIC_ATHENS_APP_ID:e.NEXT_PUBLIC_ATHENS_APP_ID,NEXT_PUBLIC_ATHENS_APP_SECRET:e.NEXT_PUBLIC_ATHENS_APP_SECRET,NEXT_PUBLIC_PROJECT_TOKEN:e.NEXT_PUBLIC_PROJECT_TOKEN,NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN:e.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN,NEXT_PUBLIC_REVALIDATION_VT_TOKEN:e.NEXT_PUBLIC_REVALIDATION_VT_TOKEN,NEXT_PUBLIC_GRAPH_QL_URL:e.NEXT_PUBLIC_GRAPH_QL_URL,NEXT_PUBLIC_MUSE_GRAPHQL_URL:e.NEXT_PUBLIC_MUSE_GRAPHQL_URL,NEXT_PUBLIC_RECIPE_GRAPHQL_URL:e.NEXT_PUBLIC_RECIPE_GRAPHQL_URL}}const tO=y.createContext(null);function HcA({children:A,env:e}){const t=e||R0(),n=eO.parse(t);return c.jsx(tO.Provider,{value:n,children:A})}function NcA(){const A=y.useContext(tO);if(A)return A;const e=R0();return eO.parse(e)}Ie.addDefaultLocale(U6);Ie.addLocale(_6);exports.Alert=ZV;exports.AlertDescription=SV;exports.AlertTitle=VV;exports.Badge=at;exports.BlogCategoryContent=Pj;exports.BlogPostContentComponent=olA;exports.BlogPostsComponent=UaA;exports.BlogStatus=Rt;exports.BlogTagContent=Gj;exports.Breadcrumb=Ez;exports.BreadcrumbEllipsis=XV;exports.BreadcrumbItem=mp;exports.BreadcrumbLink=Nz;exports.BreadcrumbList=Hz;exports.BreadcrumbPage=kz;exports.BreadcrumbSeparator=Zz;exports.Button=MA;exports.Calendar=Wd;exports.Card=hr;exports.CardContent=Hs;exports.CardDescription=t8;exports.CardFooter=Fd;exports.CardHeader=Es;exports.CardTitle=oi;exports.CategoriesComponent=aoA;exports.Checkbox=c8;exports.ClearCacheHistory=ulA;exports.Collapsible=kY;exports.CollapsibleContent=VY;exports.CollapsibleTrigger=ZY;exports.ColumnFaceting=V5;exports.ColumnFiltering=q5;exports.ColumnGrouping=R5;exports.ColumnOrdering=F5;exports.ColumnPinning=K5;exports.ColumnSizing=U5;exports.ColumnVisibility=$5;exports.Command=Lc;exports.CommandDialog=CG;exports.CommandEmpty=ag;exports.CommandGroup=og;exports.CommandInput=A9;exports.CommandItem=ig;exports.CommandList=sg;exports.CommandSeparator=Y8;exports.CommandShortcut=G8;exports.ContextMenu=l1;exports.ContextMenuCheckboxItem=lI;exports.ContextMenuContent=u1;exports.ContextMenuGroup=nI;exports.ContextMenuItem=yp;exports.ContextMenuLabel=uI;exports.ContextMenuPortal=rI;exports.ContextMenuRadioGroup=aI;exports.ContextMenuRadioItem=cI;exports.ContextMenuSeparator=f1;exports.ContextMenuShortcut=d1;exports.ContextMenuSub=sI;exports.ContextMenuSubContent=iI;exports.ContextMenuSubTrigger=oI;exports.ContextMenuTrigger=c1;exports.Dialog=_t;exports.DialogClose=MG;exports.DialogContent=Vt;exports.DialogDescription=ki;exports.DialogFooter=Dr;exports.DialogHeader=Ln;exports.DialogOverlay=$h;exports.DialogPortal=X8;exports.DialogTitle=Jn;exports.DialogTrigger=BG;exports.DropdownMenu=PV;exports.DropdownMenuCheckboxItem=BV;exports.DropdownMenuContent=xV;exports.DropdownMenuGroup=zV;exports.DropdownMenuItem=DV;exports.DropdownMenuLabel=jV;exports.DropdownMenuPortal=yV;exports.DropdownMenuRadioGroup=MV;exports.DropdownMenuRadioItem=CV;exports.DropdownMenuSeparator=OV;exports.DropdownMenuShortcut=TV;exports.DropdownMenuSub=EV;exports.DropdownMenuSubContent=NV;exports.DropdownMenuSubTrigger=HV;exports.DropdownMenuTrigger=bV;exports.FilterFieldType=OA;exports.Form=c9;exports.FormControl=to;exports.FormDescription=j1;exports.FormField=eo;exports.FormItem=fr;exports.FormLabel=u9;exports.FormMessage=O1;exports.GlobalFaceting=AB;exports.GlobalFiltering=eB;exports.Headers=Z5;exports.Input=hn;exports.Label=fg;exports.PagesComponent=OcA;exports.Popover=Zi;exports.PopoverContent=no;exports.PopoverTrigger=Vi;exports.PurgeCache=ilA;exports.QueryProvider=yaA;exports.RadioGroup=g9;exports.RadioGroupItem=v9;exports.RecipeCategories=GlA;exports.RecipeContentComponent=PlA;exports.RecipeTags=OlA;exports.RecipesComponent=IiA;exports.RedirectsComponent=UiA;exports.RowExpanding=tB;exports.RowPagination=nB;exports.RowPinning=rB;exports.RowSelection=sB;exports.RowSorting=oB;exports.Select=li;exports.SelectContent=qa;exports.SelectGroup=LQ;exports.SelectItem=cr;exports.SelectLabel=YD;exports.SelectScrollDownButton=h9;exports.SelectScrollUpButton=p9;exports.SelectSeparator=GD;exports.SelectTrigger=Ja;exports.SelectValue=ci;exports.Separator=LD;exports.Sheet=w9;exports.SheetClose=sL;exports.SheetContent=P9;exports.SheetDescription=x9;exports.SheetFooter=qD;exports.SheetHeader=y9;exports.SheetTitle=b9;exports.SheetTrigger=JD;exports.Sidebar=ZL;exports.SidebarContent=LL;exports.SidebarFooter=IL;exports.SidebarGroup=JL;exports.SidebarGroupAction=RL;exports.SidebarGroupContent=WL;exports.SidebarGroupLabel=qL;exports.SidebarHeader=GL;exports.SidebarInput=YL;exports.SidebarInset=XL;exports.SidebarMenu=FL;exports.SidebarMenuAction=$L;exports.SidebarMenuBadge=AJ;exports.SidebarMenuButton=_L;exports.SidebarMenuItem=KL;exports.SidebarMenuSkeleton=eJ;exports.SidebarMenuSub=tJ;exports.SidebarMenuSubButton=rJ;exports.SidebarMenuSubItem=nJ;exports.SidebarProvider=kL;exports.SidebarRail=SL;exports.SidebarSeparator=QL;exports.SidebarTrigger=VL;exports.Skeleton=Rf;exports.Switch=B9;exports.Table=KJ;exports.TableBody=_J;exports.TableCaption=nq;exports.TableCell=tq;exports.TableFooter=$J;exports.TableHead=eq;exports.TableHeader=UJ;exports.TableRow=Aq;exports.Tabs=bg;exports.TabsContent=xg;exports.TabsList=Kc;exports.TabsTrigger=Uc;exports.TagsComponent=YiA;exports.Textarea=zg;exports.ThemeProvider=haA;exports.Toaster=FJ;exports.Toggle=O5;exports.ToggleGroup=Ff;exports.ToggleGroupItem=Kf;exports.Tooltip=Ca;exports.TooltipContent=Oa;exports.TooltipProvider=fi;exports.TooltipTrigger=ja;exports.WazUIBlogComponent=Cr;exports.WazUIBlogDashboard=xcA;exports.WazUIButton=he;exports.WazUIEnvironmentProvider=HcA;exports.WazUIPostActions=maA;exports.WazUIPostCategories=vu;exports.WazUIPostStatistics=mu;exports.WazUIPostTags=_i;exports.WazUiCreateBlogContent=pu;exports.WazUiGqlMediaLibrary=M4;exports.WazUiPostCard=N0;exports.WazuiActionModalProvider=wc;exports._getVisibleLeafColumns=Zo;exports.aggregationFns=rf;exports.badgeVariants=Tz;exports.buildHeaderGroups=Pl;exports.cleanHTML=Wr;exports.commonjsGlobal=Mf;exports.createCell=N5;exports.createColumn=k5;exports.createColumnHelper=sq;exports.createNextConfig=uC;exports.createRow=Au;exports.createTable=iB;exports.debugNextConfig=fC;exports.defaultColumnSizing=yl;exports.env=re;exports.expandRows=N9;exports.fetchMercuryToken=u0;exports.filterFns=$n;exports.flattenBy=T9;exports.flexRender=Vp;exports.functionalUpdate=Ir;exports.getAutoDetectedEnvironment=R0;exports.getCoreRowModel=lB;exports.getDefaultExportFromCjs=jc;exports.getEnv=dC;exports.getExpandedRowModel=zq;exports.getFacetedMinMaxValues=Dq;exports.getFacetedRowModel=Cq;exports.getFacetedUniqueValues=jq;exports.getFilteredRowModel=uB;exports.getGroupedRowModel=Oq;exports.getMemoOptions=ZA;exports.getPaginationRowModel=fB;exports.getSortedRowModel=dB;exports.isFunction=$c;exports.isNumberArray=H5;exports.isRowSelected=Bg;exports.isSubRowSelected=Uf;exports.makeStateUpdater=Kt;exports.memo=kA;exports.noop=aq;exports.orderColumns=W5;exports.passiveEventSupported=_5;exports.reSplitAlphaNumeric=_f;exports.selectRowsFn=sf;exports.shouldAutoRemoveFilter=Hp;exports.sortingFns=wo;exports.toggleVariants=O9;exports.useAuthors=EcA;exports.useFormField=qc;exports.useReactTable=gB;exports.useSidebar=Fc;exports.useTheme=waA;exports.useWazUIEnvironment=NcA;exports.withReactQuery=xaA;
|
|
2108
|
+
//# sourceMappingURL=index-BM2sjY9N.cjs.map
|