@one-million-lines/email-builder 0.4.0 → 0.5.0

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.
@@ -78,6 +78,5 @@ ${a}
78
78
  To pick up a draggable item, press the space bar.
79
79
  While dragging, use the arrow keys to move the item.
80
80
  Press space again to drop the item in its new position, or press escape to cancel.
81
- `},Ut={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function Wt(e){let{announcements:t=Ut,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Ht}=e,{announce:a,announcement:o}=Rt(),s=wt(`DndLiveRegion`),[c,u]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{u(!0)},[]),Bt((0,l.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let d=l.default.createElement(l.default.Fragment,null,l.default.createElement(It,{id:r,value:i.draggable}),l.default.createElement(Lt,{id:s,announcement:o}));return n?(0,m.createPortal)(d,n):d}var q;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(q||={});function Gt(){}function Kt(e,t){return(0,l.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function qt(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,l.useMemo)(()=>[...t].filter(e=>e!=null),[...t])}var Jt=Object.freeze({x:0,y:0});function Yt(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Xt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Zt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Qt(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function $t(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function en(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var tn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=en(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Yt(en(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(Xt)},nn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Qt(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Qt(r),o=i.reduce((e,t,r)=>e+Yt(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(Xt)};function rn(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var an=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=rn(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Zt)};function on(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function sn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Jt}function cn(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var ln=cn(1);function un(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function dn(e,t,n){let r=un(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var fn={ignoreTransform:!1};function pn(e,t){t===void 0&&(t=fn);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=K(e).getComputedStyle(e);t&&(n=dn(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function mn(e){return pn(e,{ignoreTransform:!0})}function hn(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function gn(e,t){return t===void 0&&(t=K(e).getComputedStyle(e)),t.position===`fixed`}function _n(e,t){t===void 0&&(t=K(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function vn(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(ft(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!pt(i)||mt(i)||n.includes(i))return n;let a=K(e).getComputedStyle(i);return i!==e&&_n(i,a)&&n.push(i),gn(i,a)?n:r(i.parentNode)}return e?r(e):n}function yn(e){let[t]=vn(e,1);return t??null}function bn(e){return!lt||!e?null:ut(e)?e:dt(e)?ft(e)||e===ht(e).scrollingElement?window:pt(e)?e:null:null}function xn(e){return ut(e)?e.scrollX:e.scrollLeft}function Sn(e){return ut(e)?e.scrollY:e.scrollTop}function Cn(e){return{x:xn(e),y:Sn(e)}}var J;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(J||={});function wn(e){return!lt||!e?!1:e===document.scrollingElement}function Tn(e){let t={x:0,y:0},n=wn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var En={x:.2,y:.2};function Dn(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=En);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Tn(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=J.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=J.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=J.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=J.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function On(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function kn(e){return e.reduce((e,t)=>Et(e,Cn(t)),Jt)}function An(e){return e.reduce((e,t)=>e+xn(t),0)}function jn(e){return e.reduce((e,t)=>e+Sn(t),0)}function Mn(e,t){if(t===void 0&&(t=pn),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);yn(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Nn=[[`x`,[`left`,`right`],An],[`y`,[`top`,`bottom`],jn]],Pn=class{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;let n=vn(t),r=kn(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Nn)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Fn=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},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 In(e){let{EventTarget:t}=K(e);return e instanceof t?e:ht(e)}function Ln(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Rn;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Rn||={});function zn(e){e.preventDefault()}function Bn(e){e.stopPropagation()}var Y;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(Y||={});var Vn={start:[Y.Space,Y.Enter],cancel:[Y.Esc],end:[Y.Space,Y.Enter,Y.Tab]},Hn=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Y.Right:return{...n,x:n.x+25};case Y.Left:return{...n,x:n.x-25};case Y.Down:return{...n,y:n.y+25};case Y.Up:return{...n,y:n.y-25}}},Un=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Fn(ht(t)),this.windowListeners=new Fn(K(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rn.Resize,this.handleCancel),this.windowListeners.add(Rn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rn.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Mn(n),t(Jt)}handleKeyDown(e){if(kt(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Vn,coordinateGetter:a=Hn,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:Jt;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Dt(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Tn(n),p=On(n),m={x:Math.min(i===Y.Right?p.right-p.width/2:p.right,Math.max(i===Y.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Y.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Y.Down?p.top:p.top+p.height/2,u.y))},h=i===Y.Right&&!s||i===Y.Left&&!c,g=i===Y.Down&&!l||i===Y.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Y.Right&&e<=d.x||i===Y.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Y.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===Y.Down&&e<=d.y||i===Y.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Y.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Et(Dt(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Un.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Vn,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Wn(e){return!!(e&&`distance`in e)}function Gn(e){return!!(e&&`delay`in e)}var Kn=class{constructor(e,t,n){n===void 0&&(n=In(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;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=ht(i),this.documentListeners=new Fn(this.document),this.listeners=new Fn(n),this.windowListeners=new Fn(K(i)),this.initialCoordinates=jt(r)??Jt,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(){let{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(Rn.Resize,this.handleCancel),this.windowListeners.add(Rn.DragStart,zn),this.windowListeners.add(Rn.VisibilityChange,this.handleCancel),this.windowListeners.add(Rn.ContextMenu,zn),this.documentListeners.add(Rn.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Gn(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Wn(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){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Rn.Click,Bn,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rn.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=jt(e)??Jt,s=Dt(n,o);if(!t&&a){if(Wn(a)){if(a.tolerance!=null&&Ln(s,a.tolerance))return this.handleCancel();if(Ln(s,a.distance))return this.handleStart()}if(Gn(a)&&Ln(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Y.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},qn={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Jn=class extends Kn{constructor(e){let{event:t}=e,n=ht(t.target);super(e,qn,n)}};Jn.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Yn={move:{name:`mousemove`},end:{name:`mouseup`}},Xn;(function(e){e[e.RightClick=2]=`RightClick`})(Xn||={});var Zn=class extends Kn{constructor(e){super(e,Yn,ht(e.event.target))}};Zn.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Xn.RightClick?!1:(r?.({event:n}),!0)}}];var Qn={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},$n=class extends Kn{constructor(e){super(e,Qn)}static setup(){return window.addEventListener(Qn.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Qn.move.name,e)};function e(){}}};$n.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var er;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(er||={});var tr;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(tr||={});function nr(e){let{acceleration:t,activator:n=er.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=tr.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:p}=e,m=ir({delta:f,disabled:!a}),[h,g]=vt(),_=(0,l.useRef)({x:0,y:0}),v=(0,l.useRef)({x:0,y:0}),y=(0,l.useMemo)(()=>{switch(n){case er.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case er.DraggableRect:return i}},[n,i,c]),b=(0,l.useRef)(null),x=(0,l.useCallback)(()=>{let e=b.current;if(!e)return;let t=_.current.x*v.current.x,n=_.current.y*v.current.y;e.scrollBy(t,n)},[]),S=(0,l.useMemo)(()=>s===tr.TreeOrder?[...u].reverse():u,[s,u]);(0,l.useEffect)(()=>{if(!a||!u.length||!y){g();return}for(let e of S){if(r?.(e)===!1)continue;let n=u.indexOf(e),i=d[n];if(!i)continue;let{direction:a,speed:s}=Dn(e,i,y,t,p);for(let e of[`x`,`y`])m[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){g(),b.current=e,h(x,o),_.current=s,v.current=a;return}}_.current={x:0,y:0},v.current={x:0,y:0},g()},[t,x,r,g,a,o,JSON.stringify(y),JSON.stringify(m),h,u,S,d,JSON.stringify(p)])}var rr={x:{[J.Backward]:!1,[J.Forward]:!1},y:{[J.Backward]:!1,[J.Forward]:!1}};function ir(e){let{delta:t,disabled:n}=e,r=St(t);return bt(e=>{if(n||!r||!e)return rr;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[J.Backward]:e.x[J.Backward]||i.x===-1,[J.Forward]:e.x[J.Forward]||i.x===1},y:{[J.Backward]:e.y[J.Backward]||i.y===-1,[J.Forward]:e.y[J.Forward]||i.y===1}}},[n,t,r])}function ar(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return bt(e=>t==null?null:r??e??null,[r,t])}function or(e,t){return(0,l.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var sr;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(sr||={});var cr;(function(e){e.Optimized=`optimized`})(cr||={});var lr=new Map;function ur(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,l.useState)(null),{frequency:s,measure:c,strategy:u}=i,d=(0,l.useRef)(e),f=_(),p=yt(f),m=(0,l.useCallback)(function(e){e===void 0&&(e=[]),!p.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[p]),h=(0,l.useRef)(null),g=bt(t=>{if(f&&!n)return lr;if(!t||t===lr||d.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Pn(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,f,c]);return(0,l.useEffect)(()=>{d.current=e},[e]),(0,l.useEffect)(()=>{f||m()},[n,f]),(0,l.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,l.useEffect)(()=>{f||typeof s!=`number`||h.current!==null||(h.current=setTimeout(()=>{m(),h.current=null},s))},[s,f,m,...r]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:a!=null};function _(){switch(u){case sr.Always:return!1;case sr.BeforeDragging:return n;default:return!n}}}function dr(e,t){return bt(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function fr(e,t){return dr(e,t)}function pr(e){let{callback:t,disabled:n}=e,r=_t(t),i=(0,l.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,l.useEffect)(()=>()=>i?.disconnect(),[i]),i}function mr(e){let{callback:t,disabled:n}=e,r=_t(t),i=(0,l.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,l.useEffect)(()=>()=>i?.disconnect(),[i]),i}function hr(e){return new Pn(pn(e),e)}function gr(e,t,n){t===void 0&&(t=hr);let[r,i]=(0,l.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=pr({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=mr({callback:a});return gt(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function _r(e){return sn(e,dr(e))}var vr=[];function yr(e){let t=(0,l.useRef)(e),n=bt(n=>e?n&&n!==vr&&e&&t.current&&e.parentNode===t.current.parentNode?n:vn(e):vr,[e]);return(0,l.useEffect)(()=>{t.current=e},[e]),n}function br(e){let[t,n]=(0,l.useState)(null),r=(0,l.useRef)(e),i=(0,l.useCallback)(e=>{let t=bn(e.target);t&&n(e=>e?(e.set(t,Cn(t)),new Map(e)):null)},[]);return(0,l.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=bn(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Cn(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{bn(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,l.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Et(e,t),Jt):kn(e):Jt,[e,t])}function xr(e,t){t===void 0&&(t=[]);let n=(0,l.useRef)(null);return(0,l.useEffect)(()=>{n.current=null},t),(0,l.useEffect)(()=>{let t=e!==Jt;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Dt(e,n.current):Jt}function Sr(e){(0,l.useEffect)(()=>{if(!lt)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Cr(e,t){return(0,l.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function wr(e){return(0,l.useMemo)(()=>e?hn(e):null,[e])}var Tr=[];function Er(e,t){t===void 0&&(t=pn);let[n]=e,r=wr(n?K(n):null),[i,a]=(0,l.useState)(Tr);function o(){a(()=>e.length?e.map(e=>wn(e)?r:new Pn(t(e),e)):Tr)}let s=mr({callback:o});return gt(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Dr(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return pt(t)?t:e}function Or(e){let{measure:t}=e,[n,r]=(0,l.useState)(null),i=mr({callback:(0,l.useCallback)(e=>{for(let{target:n}of e)if(pt(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=xt((0,l.useCallback)(e=>{let n=Dr(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,l.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var kr=[{sensor:Jn,options:{}},{sensor:Un,options:{}}],Ar={current:{}},jr={draggable:{measure:mn},droppable:{measure:mn,strategy:sr.WhileDragging,frequency:cr.Optimized},dragOverlay:{measure:pn}},Mr=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Nr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Mr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Gt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:jr,measureDroppableContainers:Gt,windowRect:null,measuringScheduled:!1},Pr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Gt,draggableNodes:new Map,over:null,measureDroppableContainers:Gt},Fr=(0,l.createContext)(Pr),Ir=(0,l.createContext)(Nr);function Lr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Mr}}}function Rr(e,t){switch(t.type){case q.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case q.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case q.DragEnd:case q.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case q.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Mr(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case q.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Mr(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case q.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Mr(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function zr(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,l.useContext)(Fr),a=St(r),o=St(n?.id);return(0,l.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!kt(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Pt(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Br(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Vr(e){return(0,l.useMemo)(()=>({draggable:{...jr.draggable,...e?.draggable},droppable:{...jr.droppable,...e?.droppable},dragOverlay:{...jr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Hr(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,l.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;gt(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=sn(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=yn(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Ur=(0,l.createContext)({...Jt,scaleX:1,scaleY:1}),Wr;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Wr||={});var Gr=(0,l.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=kr,collisionDetection:o=an,measuring:s,modifiers:c,...u}=e,[d,f]=(0,l.useReducer)(Rr,void 0,Lr),[p,h]=Vt(),[g,_]=(0,l.useState)(Wr.Uninitialized),v=g===Wr.Initialized,{draggable:{active:y,nodes:b,translate:x},droppable:{containers:S}}=d,C=y==null?null:b.get(y),w=(0,l.useRef)({initial:null,translated:null}),T=(0,l.useMemo)(()=>y==null?null:{id:y,data:C?.data??Ar,rect:w},[y,C]),ee=(0,l.useRef)(null),[te,E]=(0,l.useState)(null),[D,ne]=(0,l.useState)(null),re=yt(u,Object.values(u)),ie=wt(`DndDescribedBy`,t),ae=(0,l.useMemo)(()=>S.getEnabled(),[S]),oe=Vr(s),{droppableRects:se,measureDroppableContainers:ce,measuringScheduled:le}=ur(ae,{dragging:v,dependencies:[x.x,x.y],config:oe.droppable}),O=ar(b,y),ue=(0,l.useMemo)(()=>D?jt(D):null,[D]),k=Te(),de=fr(O,oe.draggable.measure);Hr({activeNode:y==null?null:b.get(y),config:k.layoutShiftCompensation,initialRect:de,measure:oe.draggable.measure});let A=gr(O,oe.draggable.measure,de),fe=gr(O?O.parentElement:null),j=(0,l.useRef)({activatorEvent:null,active:null,activeNode:O,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:b,draggingNode:null,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),M=S.getNodeFor(j.current.over?.id),pe=Or({measure:oe.dragOverlay.measure}),me=pe.nodeRef.current??O,he=v?pe.rect??A:null,ge=!!(pe.nodeRef.current&&pe.rect),_e=_r(ge?null:A),N=wr(me?K(me):null),P=yr(v?M??O:null),ve=Er(P),ye=Br(c,{transform:{x:x.x-_e.x,y:x.y-_e.y,scaleX:1,scaleY:1},activatorEvent:D,active:T,activeNodeRect:A,containerNodeRect:fe,draggingNodeRect:he,over:j.current.over,overlayNodeRect:pe.rect,scrollableAncestors:P,scrollableAncestorRects:ve,windowRect:N}),F=ue?Et(ue,x):null,I=br(P),L=xr(I),R=xr(I,[A]),z=Et(ye,L),B=he?ln(he,ye):null,V=T&&B?o({active:T,collisionRect:B,droppableRects:se,droppableContainers:ae,pointerCoordinates:F}):null,H=$t(V,`id`),[U,be]=(0,l.useState)(null),W=on(ge?ye:Et(ye,R),U?.rect??null,A),xe=(0,l.useRef)(null),G=(0,l.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(ee.current==null)return;let i=b.get(ee.current);if(!i)return;let a=e.nativeEvent,o=new n({active:ee.current,activeNode:i,event:a,options:r,context:j,onAbort(e){if(!b.get(e))return;let{onDragAbort:t}=re.current,n={id:e};t?.(n),p({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!b.get(e))return;let{onDragPending:i}=re.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),p({type:`onDragPending`,event:a})},onStart(e){let t=ee.current;if(t==null)return;let n=b.get(t);if(!n)return;let{onDragStart:r}=re.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:w}};(0,m.unstable_batchedUpdates)(()=>{r?.(i),_(Wr.Initializing),f({type:q.DragStart,initialCoordinates:e,active:t}),p({type:`onDragStart`,event:i}),E(xe.current),ne(a)})},onMove(e){f({type:q.DragMove,coordinates:e})},onEnd:s(q.DragEnd),onCancel:s(q.DragCancel)});xe.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=j.current,o=null;if(t&&i){let{cancelDrop:s}=re.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===q.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=q.DragCancel)}ee.current=null,(0,m.unstable_batchedUpdates)(()=>{f({type:e}),_(Wr.Uninitialized),be(null),E(null),ne(null),xe.current=null;let t=e===q.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=re.current[t];e?.(o),p({type:t,event:o})}})}}},[b]),Se=or(a,(0,l.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=b.get(r);if(ee.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},ee.current=r,G(n,t))},[b,G]));Sr(a),gt(()=>{A&&g===Wr.Initializing&&_(Wr.Initialized)},[A,g]),(0,l.useEffect)(()=>{let{onDragMove:e}=re.current,{active:t,activatorEvent:n,collisions:r,over:i}=j.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:z.x,y:z.y},over:i};(0,m.unstable_batchedUpdates)(()=>{e?.(a),p({type:`onDragMove`,event:a})})},[z.x,z.y]),(0,l.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=j.current;if(!e||ee.current==null||!t||!i)return;let{onDragOver:a}=re.current,o=r.get(H),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,m.unstable_batchedUpdates)(()=>{be(s),a?.(c),p({type:`onDragOver`,event:c})})},[H]),gt(()=>{j.current={activatorEvent:D,active:T,activeNode:O,collisionRect:B,collisions:V,droppableRects:se,draggableNodes:b,draggingNode:me,draggingNodeRect:he,droppableContainers:S,over:U,scrollableAncestors:P,scrollAdjustedTranslate:z},w.current={initial:he,translated:B}},[T,O,V,B,b,me,he,se,S,U,P,z]),nr({...k,delta:x,draggingRect:B,pointerCoordinates:F,scrollableAncestors:P,scrollableAncestorRects:ve});let Ce=(0,l.useMemo)(()=>({active:T,activeNode:O,activeNodeRect:A,activatorEvent:D,collisions:V,containerNodeRect:fe,dragOverlay:pe,draggableNodes:b,droppableContainers:S,droppableRects:se,over:U,measureDroppableContainers:ce,scrollableAncestors:P,scrollableAncestorRects:ve,measuringConfiguration:oe,measuringScheduled:le,windowRect:N}),[T,O,A,D,V,fe,pe,b,S,se,U,ce,P,ve,oe,le,N]),we=(0,l.useMemo)(()=>({activatorEvent:D,activators:Se,active:T,activeNodeRect:A,ariaDescribedById:{draggable:ie},dispatch:f,draggableNodes:b,over:U,measureDroppableContainers:ce}),[D,Se,T,A,f,ie,b,U,ce]);return l.default.createElement(zt.Provider,{value:h},l.default.createElement(Fr.Provider,{value:we},l.default.createElement(Ir.Provider,{value:Ce},l.default.createElement(Ur.Provider,{value:W},i)),l.default.createElement(zr,{disabled:n?.restoreFocus===!1})),l.default.createElement(Wt,{...n,hiddenTextDescribedById:ie}));function Te(){let e=te?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=v&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Kr=(0,l.createContext)(null),qr=`button`,Jr=`Draggable`;function Yr(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=wt(Jr),{activators:o,activatorEvent:s,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:p}=(0,l.useContext)(Fr),{role:m=qr,roleDescription:h=`draggable`,tabIndex:g=0}=i??{},_=c?.id===t,v=(0,l.useContext)(_?Ur:Kr),[y,b]=xt(),[x,S]=xt(),C=Cr(o,t),w=yt(n);return gt(()=>(f.set(t,{id:t,key:a,node:y,activatorNode:x,data:w}),()=>{let e=f.get(t);e&&e.key===a&&f.delete(t)}),[f,t]),{active:c,activatorEvent:s,activeNodeRect:u,attributes:(0,l.useMemo)(()=>({role:m,tabIndex:g,"aria-disabled":r,"aria-pressed":_&&m===qr?!0:void 0,"aria-roledescription":h,"aria-describedby":d.draggable}),[r,m,g,_,h,d.draggable]),isDragging:_,listeners:r?void 0:C,node:y,over:p,setNodeRef:b,setActivatorNodeRef:S,transform:v}}function Xr(){return(0,l.useContext)(Ir)}var Zr=`Droppable`,Qr={timeout:25};function $r(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=wt(Zr),{active:o,dispatch:s,over:c,measureDroppableContainers:u}=(0,l.useContext)(Fr),d=(0,l.useRef)({disabled:n}),f=(0,l.useRef)(!1),p=(0,l.useRef)(null),m=(0,l.useRef)(null),{disabled:h,updateMeasurementsFor:g,timeout:_}={...Qr,...i},v=yt(g??r),y=mr({callback:(0,l.useCallback)(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),m.current=null},_)},[_]),disabled:h||!o}),[b,x]=xt((0,l.useCallback)((e,t)=>{y&&(t&&(y.unobserve(t),f.current=!1),e&&y.observe(e))},[y])),S=yt(t);return(0,l.useEffect)(()=>{!y||!b.current||(y.disconnect(),f.current=!1,y.observe(b.current))},[b,y]),(0,l.useEffect)(()=>(s({type:q.RegisterDroppable,element:{id:r,key:a,disabled:n,node:b,rect:p,data:S}}),()=>s({type:q.UnregisterDroppable,key:a,id:r})),[r]),(0,l.useEffect)(()=>{n!==d.current.disabled&&(s({type:q.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,s]),{active:o,rect:p,isOver:c?.id===r,node:b,over:c,setNodeRef:x}}function ei(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function ti(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function ni(e){return e!==null&&e>=0}function ri(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ii(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var ai=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=ei(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},oi={scaleX:1,scaleY:1},si=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...oi}:null}let s=ci(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...oi}:r<t&&r>=a?{x:0,y:o.height+s,...oi}:{x:0,y:0,...oi}};function ci(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var li=`Sortable`,ui=l.default.createContext({activeIndex:-1,containerId:li,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:ai,disabled:{draggable:!1,droppable:!1}});function di(e){let{children:t,id:n,items:r,strategy:i=ai,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:u,measureDroppableContainers:d}=Xr(),f=wt(li,n),p=s.rect!==null,m=(0,l.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),h=o!=null,g=o?m.indexOf(o.id):-1,_=u?m.indexOf(u.id):-1,v=(0,l.useRef)(m),y=!ri(m,v.current),b=_!==-1&&g===-1||y,x=ii(a);gt(()=>{y&&h&&d(m)},[y,m,h,d]),(0,l.useEffect)(()=>{v.current=m},[m]);let S=(0,l.useMemo)(()=>({activeIndex:g,containerId:f,disabled:x,disableTransforms:b,items:m,overIndex:_,useDragOverlay:p,sortedRects:ti(m,c),strategy:i}),[g,f,x.draggable,x.droppable,b,m,_,c,p,i]);return l.default.createElement(ui.Provider,{value:S},t)}var fi=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return ei(n,r,i).indexOf(t)},pi=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},mi={duration:200,easing:`ease`},hi=`transform`,gi=Mt.Transition.toString({property:hi,duration:0,easing:`linear`}),_i={roleDescription:`sortable`};function vi(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,l.useState)(null),s=(0,l.useRef)(n);return gt(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=pn(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,l.useEffect)(()=>{a&&o(null)},[a]),a}function yi(e){let{animateLayoutChanges:t=pi,attributes:n,disabled:r,data:i,getNewIndex:a=fi,id:o,strategy:s,resizeObserverConfig:c,transition:u=mi}=e,{items:d,containerId:f,activeIndex:p,disabled:m,disableTransforms:h,sortedRects:g,overIndex:_,useDragOverlay:v,strategy:y}=(0,l.useContext)(ui),b=bi(r,m),x=d.indexOf(o),S=(0,l.useMemo)(()=>({sortable:{containerId:f,index:x,items:d},...i}),[f,i,x,d]),C=(0,l.useMemo)(()=>d.slice(d.indexOf(o)),[d,o]),{rect:w,node:T,isOver:ee,setNodeRef:te}=$r({id:o,data:S,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:E,activatorEvent:D,activeNodeRect:ne,attributes:re,setNodeRef:ie,listeners:ae,isDragging:oe,over:se,setActivatorNodeRef:ce,transform:le}=Yr({id:o,data:S,attributes:{..._i,...n},disabled:b.draggable}),O=ct(te,ie),ue=!!E,k=ue&&!h&&ni(p)&&ni(_),de=!v&&oe,A=k?(de&&k?le:null)??(s??y)({rects:g,activeNodeRect:ne,activeIndex:p,overIndex:_,index:x}):null,fe=ni(p)&&ni(_)?a({id:o,items:d,activeIndex:p,overIndex:_}):x,j=E?.id,M=(0,l.useRef)({activeId:j,items:d,newIndex:fe,containerId:f}),pe=d!==M.current.items,me=t({active:E,containerId:f,isDragging:oe,isSorting:ue,id:o,index:x,items:d,newIndex:M.current.newIndex,previousItems:M.current.items,previousContainerId:M.current.containerId,transition:u,wasDragging:M.current.activeId!=null}),he=vi({disabled:!me,index:x,node:T,rect:w});return(0,l.useEffect)(()=>{ue&&M.current.newIndex!==fe&&(M.current.newIndex=fe),f!==M.current.containerId&&(M.current.containerId=f),d!==M.current.items&&(M.current.items=d)},[ue,fe,f,d]),(0,l.useEffect)(()=>{if(j===M.current.activeId)return;if(j!=null&&M.current.activeId==null){M.current.activeId=j;return}let e=setTimeout(()=>{M.current.activeId=j},50);return()=>clearTimeout(e)},[j]),{active:E,activeIndex:p,attributes:re,data:S,rect:w,index:x,newIndex:fe,items:d,isOver:ee,isSorting:ue,isDragging:oe,listeners:ae,node:T,overIndex:_,over:se,setNodeRef:O,setActivatorNodeRef:ce,setDroppableNodeRef:te,setDraggableNodeRef:ie,transform:he??A,transition:ge()};function ge(){if(he||pe&&M.current.newIndex===x)return gi;if(!(de&&!kt(D)||!u)&&(ue||me))return Mt.Transition.toString({...u,property:hi})}}function bi(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function xi(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var Si=[Y.Down,Y.Right,Y.Up,Y.Left],Ci=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(Si.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case Y.Down:r.top<a.top&&t.push(n);break;case Y.Up:r.top>a.top&&t.push(n);break;case Y.Left:r.left>a.left&&t.push(n);break;case Y.Right:r.left<a.left&&t.push(n);break}});let c=nn({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=$t(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=vn(c).some((e,t)=>s[t]!==e),i=wi(e,t),a=Ti(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:Dt(u,l)}}}};function wi(e,t){return!xi(e)||!xi(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Ti(e,t){return!xi(e)||!xi(t)||!wi(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var Ei=375;function Di(e){let t=e.replace(`#`,``);if(t.length!==3&&t.length!==6)return e===`white`||e===`#fff`||e===`#ffffff`;let n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255;return .2126*r+.7152*i+.0722*a>.82}function Oi(e,t){let n=e??{};if(t!==`mobile`)return n;let r=n.mobile??{};return{...n,...r}}function ki(){let{doc:e,selection:t,setSelection:n,reorderModules:r,deleteModule:i,duplicateModule:a,deleteElement:o,moveElement:s,viewMode:c}=N(),u=qt(Kt(Jn,{activationConstraint:{distance:5}}),Kt(Un,{coordinateGetter:Ci})),d=t=>{let{active:n,over:i}=t;if(!i||n.id===i.id)return;let a=e.modules.findIndex(e=>e.id===n.id),o=e.modules.findIndex(e=>e.id===i.id);a===-1||o===-1||r(a,o)};(0,l.useEffect)(()=>{let e=e=>{if(e.key!==`Delete`&&e.key!==`Backspace`)return;let n=e.target;n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable||(t?.kind===`module`?i(t.moduleId):t?.kind===`element`&&o(t.moduleId,t.elementId))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i,o]);let f=x(e.settings.backgroundColor,e.theme),m=x(e.settings.contentBackgroundColor,e.theme),h=e.modules.map(e=>e.id),g=c===`mobile`?Ei:e.settings.width;return(0,p.jsx)(`div`,{className:`flex-1 overflow-y-auto`,style:{background:f},onClick:()=>n({kind:`email`}),children:(0,p.jsx)(`div`,{className:`py-8 flex justify-center`,children:(0,p.jsxs)(`div`,{className:`shadow-lg transition-all duration-200 ${c===`mobile`?`rounded-[28px] border-[10px] border-gray-800`:``}`,style:{width:g,background:m,minHeight:300},onClick:e=>e.stopPropagation(),children:[e.modules.length===0&&(0,p.jsx)(`div`,{className:`p-12 text-center text-gray-400 text-sm`,children:`Add modules from the left sidebar to start building your email.`}),(0,p.jsx)(Gr,{sensors:u,collisionDetection:tn,onDragEnd:d,children:(0,p.jsx)(di,{items:h,strategy:si,children:e.modules.map((r,o)=>(0,p.jsx)(Ai,{mod:r,index:o,viewMode:c,selected:t?.kind===`module`&&t.moduleId===r.id,selectionEl:t?.kind===`element`&&t.moduleId===r.id?t.elementId:null,theme:e.theme,onSelectModule:()=>n({kind:`module`,moduleId:r.id}),onSelectElement:e=>n({kind:`element`,moduleId:r.id,elementId:e}),onDuplicate:()=>a(r.id),onDelete:()=>i(r.id)},r.id))})})]})})})}function Ai(e){let{attributes:t,listeners:n,setNodeRef:r,transform:i,transition:a,isDragging:o}=yi({id:e.mod.id});return(0,p.jsx)(`div`,{ref:r,style:{transform:Mt.Transform.toString(i),transition:a,opacity:o?.5:1,position:`relative`,zIndex:e.selected?10:`auto`},children:(0,p.jsx)(ji,{mod:e.mod,viewMode:e.viewMode,selected:e.selected,selectionEl:e.selectionEl,theme:e.theme,onSelectModule:e.onSelectModule,onSelectElement:e.onSelectElement,onDuplicate:e.onDuplicate,onDelete:e.onDelete,dragHandle:(0,p.jsx)(`button`,{...t,...n,className:`bg-blue-600 text-white p-1 rounded cursor-grab active:cursor-grabbing`,title:`Drag to reorder`,onClick:e=>e.stopPropagation(),children:(0,p.jsx)(f.GripVertical,{size:14})})})})}function ji({mod:e,viewMode:t,selected:n,selectionEl:r,theme:i,onSelectModule:a,onSelectElement:o,onDuplicate:s,onDelete:c,dragHandle:u}){let d=e.style??{};if(d.hideOn===t)return null;let m=S(Oi(d,t),i),[h,g]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{style:{backgroundColor:m.backgroundColor,paddingTop:m.paddingTop??0,paddingBottom:m.paddingBottom??0,paddingLeft:m.paddingLeft??0,paddingRight:m.paddingRight??0,borderRadius:m.borderRadius,position:`relative`,outline:n?`2px solid #2563eb`:h?`1px dashed #93c5fd`:`1px dashed transparent`,outlineOffset:-2,cursor:`pointer`},onClick:e=>{e.stopPropagation(),a()},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[!n&&h&&(0,p.jsxs)(`div`,{className:`absolute top-0 right-0 z-10 bg-blue-600 text-white text-[10px] px-1.5 py-0.5 rounded-bl pointer-events-none`,children:[`Click to select: `,e.name]}),n&&(0,p.jsxs)(`div`,{className:`absolute top-0 left-0 z-20 flex items-center gap-1 p-1 rounded-br bg-blue-600 shadow-md`,onClick:e=>e.stopPropagation(),children:[u,(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s()},className:`text-white p-1 rounded hover:bg-blue-700`,title:`Duplicate`,children:(0,p.jsx)(f.Copy,{size:14})}),(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c()},className:`text-white p-1 rounded hover:bg-red-600`,title:`Delete`,children:(0,p.jsx)(f.Trash2,{size:14})}),(0,p.jsx)(`span`,{className:`text-white text-[10px] font-medium px-1.5 py-0.5`,children:e.name})]}),e.children.map((s,c)=>(0,p.jsx)(Mi,{el:s,index:c,totalElements:e.children.length,viewMode:t,theme:i,moduleId:e.id,moduleSelected:n,selected:r===s.id,onSelect:()=>o(s.id),onSelectModule:a},s.id))]})}function Mi({el:e,index:t,totalElements:n,viewMode:r,theme:i,moduleId:a,moduleSelected:o,selected:s,onSelect:c,onSelectModule:l}){let u=N(e=>e.moveElement),d=N(e=>e.deleteElement);if(e.style?.hideOn===r)return null;let m={outline:s?`2px solid #f59e0b`:`1px dashed rgba(0,0,0,0.08)`,outlineOffset:-1,position:`relative`},h=e=>{if(e.stopPropagation(),!o&&!s){l();return}c()},g=s&&(0,p.jsxs)(`div`,{className:`absolute top-0 right-0 z-20 flex items-center gap-1 p-1 rounded-bl bg-amber-500 shadow-md`,onClick:e=>e.stopPropagation(),children:[(0,p.jsx)(`button`,{onClick:()=>l(),className:`text-white p-1 rounded hover:bg-amber-600`,title:`Select parent block`,children:(0,p.jsx)(f.MousePointer2,{size:12})}),(0,p.jsx)(`button`,{disabled:t===0,onClick:()=>u(a,e.id,-1),className:`text-white p-1 rounded disabled:opacity-40 hover:bg-amber-600`,title:`Move up`,children:(0,p.jsx)(f.ArrowUp,{size:12})}),(0,p.jsx)(`button`,{disabled:t===n-1,onClick:()=>u(a,e.id,1),className:`text-white p-1 rounded disabled:opacity-40 hover:bg-amber-600`,title:`Move down`,children:(0,p.jsx)(f.ArrowDown,{size:12})}),(0,p.jsx)(`button`,{onClick:()=>d(a,e.id),className:`text-white p-1 rounded hover:bg-red-600`,title:`Delete element`,children:(0,p.jsx)(f.Trash2,{size:12})}),(0,p.jsx)(`span`,{className:`text-white text-[10px] font-medium px-1 py-0.5`,children:e.type})]}),_=e=>(0,p.jsxs)(`div`,{style:m,onClick:h,children:[g,e]});switch(e.type){case`text`:return _((0,p.jsx)(Ni,{el:e,viewMode:r,theme:i,moduleId:a}));case`image`:return _((0,p.jsx)(Pi,{el:e,viewMode:r,theme:i}));case`button`:return _((0,p.jsx)(Fi,{el:e,viewMode:r,theme:i}));case`spacer`:return _((0,p.jsx)(Ii,{el:e}));case`divider`:return _((0,p.jsx)(Li,{el:e,viewMode:r,theme:i}));case`productGrid`:return _((0,p.jsx)(Ri,{el:e,viewMode:r,theme:i}))}}function Ni({el:e,viewMode:t,theme:n,moduleId:r}){let i=N(e=>e.updateElement),a=S(Oi(e.style,t),n),o=a.color??`#000000`,s=Di(o);return(0,p.jsx)(`div`,{style:{fontFamily:a.fontFamily,fontSize:a.fontSize,lineHeight:a.lineHeight,letterSpacing:a.letterSpacing,fontWeight:a.fontWeight,color:o,textAlign:a.align,paddingTop:a.paddingTop??8,paddingBottom:a.paddingBottom??8,paddingLeft:a.paddingLeft??16,paddingRight:a.paddingRight??16,margin:0,minHeight:`1.5em`,...s?{textShadow:`0 0 8px rgba(0,0,0,0.55), 0 1px 2px rgba(0,0,0,0.45)`}:void 0},contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>{let n=t.currentTarget.innerHTML;n!==e.content&&i(r,e.id,{content:n})},dangerouslySetInnerHTML:{__html:e.content}})}function Pi({el:e,viewMode:t,theme:n}){let r=S(Oi(e.style,t),n),i={textAlign:r.align??`center`,paddingTop:r.paddingTop??0,paddingBottom:r.paddingBottom??0,paddingLeft:r.paddingLeft??0,paddingRight:r.paddingRight??0},a={display:`inline-block`,maxWidth:`100%`,width:r.width,height:r.height||`auto`,borderRadius:r.borderRadius};return(0,p.jsx)(`div`,{style:i,children:(0,p.jsx)(`img`,{src:e.src,alt:e.alt??``,style:a})})}function Fi({el:e,viewMode:t,theme:n}){let r=S(Oi(e.style,t),n);return(0,p.jsx)(`div`,{style:{textAlign:r.align??`center`,paddingTop:r.paddingTop??12,paddingBottom:r.paddingBottom??12,paddingLeft:r.paddingLeft??16,paddingRight:r.paddingRight??16},children:(0,p.jsx)(`span`,{style:{display:`inline-block`,backgroundColor:r.backgroundColor??`#3A7D52`,color:r.color??`#fff`,fontFamily:r.fontFamily,fontSize:r.fontSize??16,fontWeight:r.fontWeight??`bold`,borderRadius:r.borderRadius??6,padding:`12px 24px`,textDecoration:`none`},children:e.label})})}function Ii({el:e}){return(0,p.jsx)(`div`,{style:{height:e.height,background:`rgba(0,0,0,0.02)`}})}function Li({el:e,viewMode:t,theme:n}){let r=S(Oi(e.style,t),n);return(0,p.jsx)(`div`,{style:{paddingTop:r.paddingTop??8,paddingBottom:r.paddingBottom??8},children:(0,p.jsx)(`hr`,{style:{border:0,borderTop:`${r.thickness??1}px solid ${r.color??`#E5E7EB`}`,margin:0}})})}function Ri({el:e,viewMode:t,theme:n}){let r=S(Oi(e.style,t),n),i=t===`mobile`,a=e.columns,o=r.cardBackgroundColor??r.backgroundColor??`transparent`,s=r.nameColor??`#111827`,c=r.finalPriceColor??`#3A7D52`,l=r.oldPriceColor??`#9CA3AF`,u=r.buttonBackgroundColor??`#3A7D52`,d=r.buttonColor??`#FFFFFF`,f=r.borderRadius??0;return(0,p.jsx)(`div`,{style:{paddingTop:r.paddingTop??16,paddingBottom:r.paddingBottom??16,paddingLeft:r.paddingLeft??16,paddingRight:r.paddingRight??16,display:`flex`,flexWrap:`wrap`,gap:8},children:e.products.map(t=>(0,p.jsxs)(`div`,{style:{width:i?`100%`:`calc(${100/a}% - 8px)`,background:o,borderRadius:f,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:[(0,p.jsx)(`img`,{src:t.image,alt:t.imageAlt??t.name,style:{display:`block`,width:`100%`,height:`auto`,borderRadius:f}}),(0,p.jsx)(`div`,{style:{padding:`12px 12px 4px 12px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:15,fontWeight:`bold`,color:s,lineHeight:1.3},children:t.name}),e.showStars&&t.stars!=null&&(0,p.jsx)(`div`,{className:`stars`,style:{padding:`0 12px 4px 12px`,color:`#F5A623`,fontSize:15,letterSpacing:1},"aria-label":`${t.stars} out of 5 stars`,children:te(t.stars)}),(0,p.jsxs)(`div`,{style:{padding:`0 12px 8px 12px`,fontFamily:`Arial, Helvetica, sans-serif`},children:[e.showOldPrice&&t.oldPrice&&(0,p.jsx)(`span`,{className:`old_price`,style:{color:l,textDecoration:`line-through`,fontSize:14,marginRight:8},children:t.oldPrice}),(0,p.jsx)(`span`,{className:`final_price`,style:{color:c,fontWeight:`bold`,fontSize:18},children:t.finalPrice})]}),e.showDescription&&t.description&&(0,p.jsx)(`div`,{style:{padding:`0 12px 8px 12px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:13,color:`#6B7280`,lineHeight:1.5},children:t.description}),e.showButton&&(0,p.jsx)(`div`,{style:{padding:`4px 12px 12px 12px`,textAlign:`center`,marginTop:`auto`},children:(0,p.jsx)(`span`,{style:{display:`inline-block`,padding:`10px 18px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:13,fontWeight:`bold`,color:d,backgroundColor:u,borderRadius:6},children:t.buttonLabel??e.buttonLabel??`Shop now`})})]},t.id))})}var zi=null,Bi=new Set,Vi=0;function Hi(){Vi+=1;for(let e of Bi)e()}function Ui(e){zi!==e&&(zi=e,Hi())}function Wi(){return zi}var Gi=e=>(Bi.add(e),()=>{Bi.delete(e)}),Ki=()=>Vi,qi=null,Ji={status:`idle`,vouchers:[]},Yi=null,Xi=new Set,Zi=0;function Qi(){Zi+=1;for(let e of Xi)e()}function $i(e){qi!==e&&(qi=e,Ji={status:`idle`,vouchers:[]},Yi=null,Qi())}function ea(){return qi}function ta(){return Ji}function na(e=!1){if(!qi)return Promise.resolve([]);if(!e&&Ji.status===`loaded`)return Promise.resolve(Ji.vouchers);if(Yi)return Yi;Ji={status:`loading`,vouchers:Ji.vouchers},Qi();let t=qi.list().then(e=>(Ji={status:`loaded`,vouchers:Array.isArray(e)?e:[]},Yi=null,Qi(),Ji.vouchers)).catch(e=>(Ji={status:`error`,vouchers:[],error:e instanceof Error?e.message:String(e)},Yi=null,Qi(),[]));return Yi=t,t}var ra=e=>(Xi.add(e),()=>{Xi.delete(e)}),ia=()=>Zi,aa=(0,d.create)(e=>({mergeTags:[],setMergeTags:t=>e({mergeTags:t})}));function oa(e){aa.getState().setMergeTags(e)}var sa=[],ca=null,la={registerModule:e=>Ie.register(e),registerTheme:e=>sa.push(e),registerAssetProvider:e=>{ca=e},registerProductProvider:e=>{Ui(e)},registerVoucherProvider:e=>{$i(e)},setAIProvider:e=>{He(e)},registerMergeTags:e=>oa(e)};function ua(e){e.setup(la)}function da(){return ca}var fa={key:`days`,label:`Time window`,type:`select`,default:7,options:[{value:7,label:`Last 7 days`},{value:14,label:`Last 14 days`},{value:30,label:`Last 30 days`}]},pa=[{id:`abandoned-cart`,label:`Abandoned basket products`,group:`behavioral`},{id:`bestseller-conversion`,label:`Best seller by Conversion`,group:`catalog`,params:[fa]},{id:`bestseller-units`,label:`Best seller by Units`,group:`catalog`,params:[fa]},{id:`new-products`,label:`New items added`,group:`catalog`,params:[fa]},{id:`cross-sell`,label:`Products Cross-Sell`,group:`contextual`},{id:`upsell`,label:`Products Upsell`,group:`contextual`},{id:`viewed-categories`,label:`Items from viewed categories`,group:`behavioral`},{id:`viewed-items`,label:`Items viewed`,group:`behavioral`},{id:`similar-basket`,label:`Similar to basket items`,group:`behavioral`},{id:`bought-together`,label:`Items bought together`,group:`contextual`},{id:`best-discount`,label:`Items with the best discount`,group:`catalog`},{id:`match-data`,label:`Items matching specific attributes`,group:`catalog`},{id:`last-purchased`,label:`Last purchased items`,group:`personal`},{id:`similar-to-purchased`,label:`Similar to last purchase`,group:`personal`},{id:`cross-sell-purchased`,label:`Cross-sell to last purchase`,group:`personal`},{id:`similar-items`,label:`Similar items`,group:`contextual`}],ma=Object.fromEntries(pa.map(e=>[e.id,e])),ha=[{value:`smart-reccs`,label:`Smart Recommendations`,description:`Best generic algorithm — recommended default.`},{value:`random`,label:`Random items (strict filters)`,description:`Random items that still pass include/exclude filters.`},{value:`ignore`,label:`Ignore position`,description:`Skip the slot if no items found.`},{value:`stop`,label:`Don't display`,description:`Don't render the email if the slot can't be filled.`}];function ga(e=2){return{mode:`recommender`,noProducts:e,sourceFeed:``,manualProducts:[],stack:[{algorithm:`abandoned-cart`}],fallback:`smart-reccs`,filters:{includeProducts:[],excludeProducts:[],includeCategories:[],excludeCategories:[],minStock:0,minPrice:0,mainOnly:!1,higherPrice:!1,salesPrice:!1,sameCategory:!1,matchTitle:!1,sameField:``}}}function _a(e){if(!e)return null;let t=e.recommendations;return!t||typeof t!=`object`?null:t}function va(e){return e?.children?e.children.some(e=>e.type===`productGrid`):!1}function ya(e){if(!e?.children)return 0;let t=0;for(let n of e.children)n.type===`productGrid`&&(t+=n.products.length);return t}function ba(e){return{params:{selection:e.mode===`manual`?`manual`:`recommender`,include:{item:e.filters.includeProducts,category:e.filters.includeCategories},exclude:{item:e.filters.excludeProducts,category:e.filters.excludeCategories},higherPrice:e.filters.higherPrice??!1,salesPrice:e.filters.salesPrice??!1,sameCategory:e.filters.sameCategory??!1,matchTitle:e.filters.matchTitle??!1,sameField:e.filters.sameField??``,mainOnly:e.filters.mainOnly??!1},noProducts:String(e.noProducts),fallback:e.fallback,stack:e.mode===`manual`?[]:e.stack,minStock:String(e.filters.minStock??0),minPrice:String(e.filters.minPrice??0),sourceFeed:e.sourceFeed??``,manualProducts:e.manualProducts}}function xa({mod:e}){let t=N(e=>e.updateModule),n=ya(e)||2,r=_a(e.data)??ga(n),i=n=>{let i={...r,...n};t(e.id,{data:{...e.data??{},recommendations:i}})};return(0,p.jsxs)(`div`,{className:`border border-blue-200 rounded-lg bg-blue-50/40 mt-4 overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 border-b border-blue-200 bg-blue-50`,children:[(0,p.jsx)(f.Sparkles,{size:14,className:`text-blue-700`}),(0,p.jsx)(`div`,{className:`text-xs font-semibold text-blue-900 uppercase tracking-wide`,children:`Products Source`})]}),(0,p.jsx)(`div`,{className:`p-3 bg-white border-b border-blue-100`,children:(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Ta,{active:r.mode===`manual`,title:`Select Items`,subtitle:`Hand-pick from a feed`,onClick:()=>i({mode:`manual`})}),(0,p.jsx)(Ta,{active:r.mode===`recommender`,title:`Recommender`,subtitle:`Algorithms + filters`,onClick:()=>i({mode:`recommender`})})]})}),(0,p.jsxs)(`div`,{className:`p-3 bg-white space-y-3`,children:[(0,p.jsxs)(Da,{label:`Number of products`,children:[(0,p.jsx)(`input`,{type:`number`,min:1,max:20,value:r.noProducts,onChange:e=>i({noProducts:Number(e.target.value)||1}),className:wa}),(0,p.jsxs)(`div`,{className:`text-[11px] text-gray-500 mt-1`,children:[`Block has `,n,` slot`,n===1?``:`s`,` in the design.`]})]}),r.mode===`manual`?(0,p.jsx)(Sa,{logic:r,update:i}):(0,p.jsx)(Ca,{logic:r,update:i,updateFilters:e=>i({filters:{...r.filters,...e}})}),(0,p.jsxs)(`details`,{className:`border border-gray-200 rounded`,children:[(0,p.jsx)(`summary`,{className:`px-2 py-1.5 text-[11px] font-medium text-gray-600 cursor-pointer select-none`,children:`View saved JSON`}),(0,p.jsx)(`pre`,{className:`text-[10px] bg-gray-900 text-gray-100 p-2 overflow-auto max-h-60 leading-tight`,children:JSON.stringify(r,null,2)})]})]})]})}function Sa({logic:e,update:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Da,{label:`Source feed`,children:(0,p.jsx)(`input`,{type:`text`,placeholder:`e.g. main-catalog`,value:e.sourceFeed??``,onChange:e=>t({sourceFeed:e.target.value}),className:wa})}),(0,p.jsx)(Da,{label:`Items to include (product IDs / SKUs)`,children:(0,p.jsx)(Ma,{value:e.manualProducts,onChange:e=>t({manualProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(`div`,{className:`text-[11px] text-gray-500`,children:`Items are sent to the renderer as-is in the order shown.`})]})}function Ca({logic:e,update:t,updateFilters:n}){let[r,i]=(0,l.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,p.jsxs)(`label`,{className:`text-xs font-medium text-gray-700`,children:[`Algorithms (max `,3,`)`]}),(0,p.jsx)(ja,{disabled:e.stack.length>=3,existing:e.stack.map(e=>e.algorithm),onPick:n=>t({stack:[...e.stack,{algorithm:n}]})})]}),(0,p.jsx)(Aa,{stack:e.stack,onChange:e=>t({stack:e})})]}),(0,p.jsxs)(Da,{label:`Fallback`,children:[(0,p.jsx)(`select`,{value:e.fallback,onChange:e=>t({fallback:e.target.value}),className:wa,children:ha.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,p.jsx)(`div`,{className:`text-[11px] text-gray-500 mt-1`,children:ha.find(t=>t.value===e.fallback)?.description})]}),(0,p.jsx)(Ea,{title:`Include & Exclude filters`,right:(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(Oa,{active:!r,onClick:()=>i(!1),children:`Basic`}),(0,p.jsx)(Oa,{active:r,onClick:()=>i(!0),children:`Advanced`})]})}),(0,p.jsx)(Da,{label:`Exclude products`,children:(0,p.jsx)(Ma,{value:e.filters.excludeProducts,onChange:e=>n({excludeProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(Da,{label:`Include products`,children:(0,p.jsx)(Ma,{value:e.filters.includeProducts,onChange:e=>n({includeProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(Da,{label:`Exclude categories`,children:(0,p.jsx)(Ma,{value:e.filters.excludeCategories,onChange:e=>n({excludeCategories:e}),placeholder:`Add category`})}),(0,p.jsx)(Da,{label:`Include categories`,children:(0,p.jsx)(Ma,{value:e.filters.includeCategories,onChange:e=>n({includeCategories:e}),placeholder:`Add category`})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Da,{label:`Minimum stock`,children:(0,p.jsx)(`input`,{type:`number`,min:0,value:e.filters.minStock??0,onChange:e=>n({minStock:Number(e.target.value)||0}),className:wa})}),(0,p.jsx)(Da,{label:`Minimum price`,children:(0,p.jsx)(`input`,{type:`number`,min:0,value:e.filters.minPrice??0,onChange:e=>n({minPrice:Number(e.target.value)||0}),className:wa})})]}),(0,p.jsx)(ka,{label:`Only main items`,checked:!!e.filters.mainOnly,onChange:e=>n({mainOnly:e})}),(0,p.jsx)(ka,{label:`Higher price than current item (upsell)`,checked:!!e.filters.higherPrice,onChange:e=>n({higherPrice:e})}),(0,p.jsx)(ka,{label:`On sale only`,checked:!!e.filters.salesPrice,onChange:e=>n({salesPrice:e})}),(0,p.jsx)(ka,{label:`Same category as current`,checked:!!e.filters.sameCategory,onChange:e=>n({sameCategory:e})}),(0,p.jsx)(ka,{label:`Match title keywords`,checked:!!e.filters.matchTitle,onChange:e=>n({matchTitle:e})}),(0,p.jsx)(Da,{label:`Match same fields (comma-separated)`,children:(0,p.jsx)(`input`,{type:`text`,placeholder:`brand, color`,value:e.filters.sameField??``,onChange:e=>n({sameField:e.target.value}),className:wa})}),r&&(0,p.jsx)(Da,{label:`Advanced JSON overrides`,children:(0,p.jsx)(Na,{value:e.filters.advanced??{},onChange:e=>n({advanced:e})})})]})}var wa=`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`;function Ta({active:e,icon:t,title:n,subtitle:r,onClick:i}){return(0,p.jsxs)(`button`,{onClick:i,className:`flex flex-col items-start gap-0.5 p-2.5 rounded border text-left transition `+(e?`border-teal-600 bg-teal-50 ring-1 ring-teal-600`:`border-gray-200 bg-white hover:border-gray-300`),children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 `+(e?`text-teal-700`:`text-gray-700`),children:[t,(0,p.jsx)(`span`,{className:`text-xs font-semibold`,children:n})]}),(0,p.jsx)(`span`,{className:`text-[10px] text-gray-500`,children:r})]})}function Ea({title:e,right:t}){return(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-200 pt-3 mt-3`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-gray-600`,children:e}),t]})}function Da({label:e,children:t}){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-gray-700 mb-1`,children:e}),t]})}function Oa({active:e,onClick:t,children:n}){return(0,p.jsx)(`button`,{onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide `+(e?`bg-teal-600 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`),children:n})}function ka({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center justify-between gap-2 text-xs text-gray-700 py-1`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked),className:`h-4 w-4 accent-teal-600`})]})}function Aa({stack:e,onChange:t}){if(e.length===0)return(0,p.jsxs)(`div`,{className:`text-[11px] text-gray-500 italic border border-dashed border-gray-300 rounded px-2 py-3 text-center`,children:[`No algorithms yet. Click `,(0,p.jsx)(`b`,{children:`Add algorithm`}),` to start.`]});let n=(n,r)=>{let i=n+r;if(i<0||i>=e.length)return;let a=e.slice();[a[n],a[i]]=[a[i],a[n]],t(a)},r=n=>t(e.filter((e,t)=>t!==n)),i=(n,r,i)=>{let a=e.slice();a[n]={...a[n],params:{...a[n].params??{},[r]:i}},t(a)};return(0,p.jsx)(`div`,{className:`space-y-1.5`,children:e.map((t,a)=>{let o=ma[t.algorithm];return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded px-2 py-1.5 bg-white flex flex-col gap-1`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(`span`,{className:`flex-1 text-xs text-gray-800 truncate`,children:o?.label??t.algorithm}),(0,p.jsx)(`button`,{title:`Move up`,onClick:()=>n(a,-1),disabled:a===0,className:`p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30`,children:(0,p.jsx)(f.ChevronUp,{size:13})}),(0,p.jsx)(`button`,{title:`Move down`,onClick:()=>n(a,1),disabled:a===e.length-1,className:`p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30`,children:(0,p.jsx)(f.ChevronDown,{size:13})}),(0,p.jsx)(`button`,{title:`Remove`,onClick:()=>r(a),className:`p-1 text-gray-400 hover:text-red-600`,children:(0,p.jsx)(f.Trash2,{size:13})})]}),o?.params?.map(e=>(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`text-[10px] text-gray-500 w-20 shrink-0`,children:e.label}),e.type===`select`?(0,p.jsx)(`select`,{value:String(t.params?.[e.key]??e.default??``),onChange:t=>i(a,e.key,t.target.value),className:`flex-1 text-xs border border-gray-200 rounded px-1.5 py-1 bg-white`,children:e.options?.map(e=>(0,p.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))}):(0,p.jsx)(`input`,{type:e.type===`number`?`number`:`text`,value:String(t.params?.[e.key]??e.default??``),onChange:t=>i(a,e.key,e.type===`number`?Number(t.target.value):t.target.value),className:`flex-1 text-xs border border-gray-200 rounded px-1.5 py-1`})]},e.key))]},a)})})}function ja({disabled:e,existing:t,onPick:n}){let[r,i]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsxs)(`button`,{disabled:e,onClick:()=>i(e=>!e),className:`flex items-center gap-1 px-2 py-1 rounded text-[11px] font-semibold uppercase `+(e?`bg-gray-200 text-gray-400 cursor-not-allowed`:`bg-teal-600 text-white hover:bg-teal-700`),children:[(0,p.jsx)(f.Plus,{size:12}),` Add`]}),r&&!e&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>i(!1)}),(0,p.jsx)(`div`,{className:`absolute right-0 top-full mt-1 w-64 max-h-80 overflow-auto bg-white border border-gray-200 rounded shadow-lg z-20`,children:pa.map(e=>{let r=t.includes(e.id);return(0,p.jsxs)(`button`,{disabled:r,onClick:()=>{n(e.id),i(!1)},className:`block w-full text-left px-2.5 py-1.5 text-xs `+(r?`text-gray-400 cursor-not-allowed`:`text-gray-700 hover:bg-teal-50 hover:text-teal-700`),children:[e.label,r&&(0,p.jsx)(`span`,{className:`ml-1 text-[10px]`,children:`· added`})]},e.id)})})]})]})}function Ma({value:e,onChange:t,placeholder:n}){let[r,i]=(0,l.useState)(``),a=()=>{let n=r.trim();n&&(e.includes(n)||(t([...e,n]),i(``)))};return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded bg-white p-1 flex flex-wrap items-center gap-1 focus-within:border-blue-500`,children:[e.map(n=>(0,p.jsxs)(`span`,{className:`inline-flex items-center gap-1 bg-gray-100 text-gray-800 text-[11px] rounded px-1.5 py-0.5`,children:[n,(0,p.jsx)(`button`,{onClick:()=>t(e.filter(e=>e!==n)),className:`text-gray-500 hover:text-red-600`,children:(0,p.jsx)(f.X,{size:10})})]},n)),(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`||n.key===`,`?(n.preventDefault(),a()):n.key===`Backspace`&&!r&&e.length&&t(e.slice(0,-1))},onBlur:a,placeholder:e.length===0?n:``,className:`flex-1 min-w-20 outline-none text-xs bg-transparent px-1 py-0.5`})]})}function Na({value:e,onChange:t}){let[n,r]=(0,l.useState)(()=>JSON.stringify(e,null,2)),[i,a]=(0,l.useState)(null);return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`textarea`,{value:n,onChange:e=>{let n=e.target.value;r(n);try{let e=JSON.parse(n||`{}`);a(null),t(e)}catch(e){a(String(e.message))}},rows:6,spellCheck:!1,className:`w-full font-mono text-[11px] border border-gray-200 rounded p-2 bg-gray-50 focus:border-blue-500 focus:outline-none`}),i&&(0,p.jsx)(`div`,{className:`text-[10px] text-red-600 mt-1`,children:i})]})}function Pa(){(0,l.useSyncExternalStore)(ra,ia,ia);let e=ea()!==null,t=ta();return(0,l.useEffect)(()=>{e&&t.status===`idle`&&na()},[e,t.status]),{available:e,status:t.status,vouchers:t.vouchers,error:t.error,reload:()=>void na(!0)}}function Fa(e){return e?.children?.find(e=>e.type===`text`&&e.role===`voucherCode`)}function Ia(e){return!!Fa(e)}function La(e){let t=e?.data?.voucher;return t&&typeof t==`object`&&`code`in t?t:null}function Ra(e){return{id:e.id,title:e.title,code:e.code}}function za({mod:e}){let t=N(e=>e.updateElement),n=N(e=>e.updateModule),{available:r,status:i,vouchers:a,error:o,reload:s}=Pa(),c=Fa(e),l=La(e),u=l&&a.some(e=>e.id===l.id)?l.id:``,d=r=>{if(!r){n(e.id,{data:{...e.data??{},voucher:void 0}});return}c&&t(e.id,c.id,{content:r.code}),n(e.id,{data:{...e.data??{},voucher:Ra(r)}})};return(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:[(0,p.jsx)(f.Ticket,{size:13,className:`text-blue-600`}),` Voucher`]}),r&&(0,p.jsxs)(`button`,{type:`button`,onClick:s,disabled:i===`loading`,className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded disabled:opacity-50`,title:`Reload vouchers`,children:[i===`loading`?(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}):(0,p.jsx)(f.RefreshCw,{size:12}),`Reload`]})]}),r?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`label`,{className:`block mb-2`,children:[(0,p.jsx)(`span`,{className:`block text-xs text-gray-600 mb-1`,children:`Select voucher`}),(0,p.jsxs)(`select`,{value:u,disabled:i===`loading`&&a.length===0,onChange:e=>{let t=a.find(t=>t.id===e.target.value)??null;d(t)},className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded bg-white focus:border-blue-500 focus:outline-none disabled:bg-gray-50`,children:[(0,p.jsx)(`option`,{value:``,children:i===`loading`&&a.length===0?`Loading vouchers…`:`Please select a voucher…`}),a.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),i===`error`&&(0,p.jsxs)(`p`,{className:`flex items-start gap-1 text-[11px] text-red-600 mb-2`,children:[(0,p.jsx)(f.AlertTriangle,{size:12,className:`mt-0.5 shrink-0`}),o??`Failed to load vouchers.`]}),i===`loaded`&&a.length===0&&(0,p.jsx)(`p`,{className:`text-[11px] text-gray-400 mb-2`,children:`No vouchers found.`}),l&&(0,p.jsxs)(`div`,{className:`rounded border border-green-200 bg-green-50 px-2.5 py-2 text-[12px] text-green-800`,children:[`Voucher code: `,(0,p.jsx)(`span`,{className:`font-semibold`,children:l.code})]})]}):(0,p.jsxs)(`p`,{className:`text-[11px] text-gray-400`,children:[`Register a voucher provider (`,(0,p.jsx)(`code`,{children:`voucherPlugin`}),`) to pick codes from your catalog. You can still edit the code text directly.`]})]})}function Ba({open:e,onClose:t,onSave:n,initialQuery:r,title:i}){let[a,o]=(0,l.useState)(r??``),[s,c]=(0,l.useState)(!1),[u,d]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),[g,_]=(0,l.useState)(!1),v=(0,l.useRef)(null);if((0,l.useEffect)(()=>{if(!e)return;o(r??``),h(null),d(null),_(!1);let n=setTimeout(()=>v.current?.focus(),40),i=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,i),()=>{clearTimeout(n),window.removeEventListener(`keydown`,i)}},[e,r,t]),!e)return null;let y=async()=>{let e=Wi(),t=a.trim();if(!(!e||!t||s)){c(!0),d(null),h(null),_(!0);try{let n=await e.search(t);h(n)}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1)}}};return(0,p.jsx)(`div`,{className:`fixed inset-0 z-50 flex bg-black/60 backdrop-blur-sm p-4`,children:(0,p.jsxs)(`div`,{className:`m-auto flex max-h-[90vh] w-full max-w-lg flex-col overflow-hidden rounded-2xl bg-white shadow-2xl`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-200 px-5 py-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(f.PackageSearch,{size:18,className:`text-blue-600`}),(0,p.jsx)(`h2`,{className:`text-base font-semibold text-neutral-900`,children:i??`Find a product`})]}),(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg p-1.5 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900`,"aria-label":`Close`,children:(0,p.jsx)(f.X,{size:18})})]}),(0,p.jsx)(`div`,{className:`border-b border-neutral-100 px-5 py-3`,children:(0,p.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,p.jsxs)(`div`,{className:`relative flex-1`,children:[(0,p.jsx)(f.Search,{size:15,className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-neutral-400`}),(0,p.jsx)(`input`,{ref:v,value:a,onChange:e=>o(e.target.value),placeholder:`Search your catalog by name or SKU…`,className:`w-full rounded-lg border border-neutral-200 bg-white py-2 pl-9 pr-3 text-sm outline-none focus:border-blue-500`})]}),(0,p.jsxs)(`button`,{type:`submit`,disabled:s||!a.trim(),className:`flex shrink-0 items-center gap-1.5 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:bg-neutral-300`,children:[s?(0,p.jsx)(f.Loader2,{size:15,className:`animate-spin`}):(0,p.jsx)(f.Search,{size:15}),`Search`]})]})}),(0,p.jsxs)(`div`,{className:`min-h-[220px] flex-1 overflow-y-auto p-5`,children:[s&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-sm text-neutral-500`,children:[(0,p.jsx)(f.Loader2,{size:22,className:`animate-spin`}),`Searching…`]}),!s&&u&&(0,p.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700`,children:u}),!s&&!u&&g&&!m&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-center text-sm text-neutral-500`,children:[(0,p.jsx)(f.PackageSearch,{size:22,className:`text-neutral-300`}),`No product matched “`,a.trim(),`”. Try another name or SKU.`]}),!s&&!u&&!g&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-center text-sm text-neutral-400`,children:[(0,p.jsx)(f.PackageSearch,{size:22,className:`text-neutral-300`}),`Search your catalog, then preview and save the product.`]}),!s&&m&&(0,p.jsx)(Va,{result:m})]}),(0,p.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-neutral-200 px-5 py-3`,children:[(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg px-4 py-2 text-sm font-medium text-neutral-600 hover:bg-neutral-100`,children:`Cancel`}),(0,p.jsxs)(`button`,{onClick:()=>{m&&(n(m),t())},disabled:!m,className:`flex items-center gap-1.5 rounded-lg bg-green-600 px-4 py-2 text-sm font-medium text-white hover:bg-green-700 disabled:bg-neutral-300`,children:[(0,p.jsx)(f.Check,{size:15}),` Save product`]})]})]})})}function Va({result:e}){return(0,p.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-neutral-200`,children:[(0,p.jsx)(`div`,{className:`aspect-video w-full overflow-hidden bg-neutral-100`,children:e.image?(0,p.jsx)(`img`,{src:e.image,alt:e.imageAlt??e.name,className:`h-full w-full object-contain`}):(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-xs text-neutral-400`,children:`No image`})}),(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-neutral-900`,children:e.name}),e.stars!=null&&(0,p.jsxs)(`div`,{className:`flex items-center gap-0.5`,"aria-label":`${e.stars} out of 5`,children:[Array.from({length:5}).map((t,n)=>(0,p.jsx)(f.Star,{size:14,className:n<Math.round(e.stars??0)?`fill-amber-400 text-amber-400`:`text-neutral-300`},n)),(0,p.jsx)(`span`,{className:`ml-1 text-xs text-neutral-500`,children:e.stars})]}),(0,p.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[e.oldPrice&&(0,p.jsx)(`span`,{className:`text-sm text-neutral-400 line-through`,children:e.oldPrice}),(0,p.jsx)(`span`,{className:`text-lg font-bold text-blue-600`,children:e.finalPrice})]}),e.description&&(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-neutral-600`,children:e.description}),e.link&&(0,p.jsxs)(`a`,{href:e.link,target:`_blank`,rel:`noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs text-blue-600 hover:underline`,children:[(0,p.jsx)(f.ExternalLink,{size:12}),` View source`]})]})]})}function Ha(){return(0,l.useSyncExternalStore)(Gi,Ki,Ki),Wi()!==null}function Ua(){let{selection:e,doc:t,viewMode:n}=N(),[r,i]=(0,l.useState)(!0);return r?(0,p.jsxs)(`div`,{className:`w-72 bg-white border-l border-gray-200 shrink-0 overflow-y-auto flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 text-[11px] flex items-center gap-1.5 border-b shrink-0 ${n===`mobile`?`bg-amber-50 text-amber-800 border-amber-200`:`bg-blue-50 text-blue-800 border-blue-100`}`,children:[n===`mobile`?(0,p.jsx)(f.Smartphone,{size:12}):(0,p.jsx)(f.Monitor,{size:12}),(0,p.jsxs)(`span`,{className:`flex-1`,children:[`Editing `,n,` styles`]}),(0,p.jsx)(`button`,{onClick:()=>i(!1),title:`Hide properties`,className:`ml-auto p-0.5 rounded hover:bg-black/10 transition-colors ${n===`mobile`?`text-amber-700 hover:text-amber-900`:`text-blue-700 hover:text-blue-900`}`,children:(0,p.jsx)(f.PanelRightClose,{size:13})})]}),(0,p.jsx)(`div`,{className:`p-4 flex-1`,children:!e||e.kind===`email`?(0,p.jsx)(eo,{}):e.kind===`module`?(()=>{let n=t.modules.find(t=>t.id===e.moduleId);return n?(0,p.jsx)(ro,{mod:n}):(0,p.jsx)(Wa,{})})():(()=>{let n=t.modules.find(t=>t.id===e.moduleId),r=n?.children.find(t=>t.id===e.elementId);return n&&r?(0,p.jsx)(io,{mod:n,el:r}):(0,p.jsx)(Wa,{})})()})]}):(0,p.jsx)(`div`,{className:`flex flex-col items-center w-6 bg-white border-l border-gray-200 shrink-0`,children:(0,p.jsx)(`button`,{onClick:()=>i(!0),title:`Show properties`,className:`flex items-center justify-center w-full py-3 text-gray-400 hover:text-gray-600 hover:bg-gray-50 transition-colors`,children:(0,p.jsx)(f.PanelRightOpen,{size:14})})})}function Wa(){return(0,p.jsx)(`div`,{className:`text-xs text-gray-400`,children:`Nothing selected.`})}function Ga(e,t){if(t!==`mobile`)return e;let n=e.mobile??{};return{...e,...n}}function Ka(e,t,n){if(n!==`mobile`)return{...e,...t};let r=e.mobile??{};return{...e,mobile:{...r,...t}}}function qa({overridden:e}){return e?(0,p.jsx)(`span`,{className:`ml-1 text-[9px] uppercase tracking-wide bg-amber-100 text-amber-800 px-1 rounded`,children:`mobile`}):null}function Ja({hideOn:e,onChange:t}){return(0,p.jsx)(X,{label:`Visibility`,children:(0,p.jsxs)(Za,{value:e??``,onChange:e=>{let n=e.target.value;t(n===``?void 0:n)},children:[(0,p.jsx)(`option`,{value:``,children:`Show on all`}),(0,p.jsx)(`option`,{value:`mobile`,children:`Hide on mobile`}),(0,p.jsx)(`option`,{value:`desktop`,children:`Hide on desktop`})]})})}function Ya({children:e}){return(0,p.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500 mb-3`,children:e})}function X({label:e,children:t}){return(0,p.jsxs)(`label`,{className:`block mb-3`,children:[(0,p.jsx)(`span`,{className:`flex items-center text-xs text-gray-600 mb-1`,children:e}),t]})}function Z(e){return(0,p.jsx)(`input`,{...e,className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none`})}function Q(e){return(0,p.jsx)(Z,{type:`number`,...e})}function Xa({value:e,onChange:t,onAlt:n}){let r=da(),i=(0,l.useRef)(null),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(null),u=async e=>{if(r){o(!0),c(null);try{let i=await r.upload(e);t(i.url),i.alt&&n&&n(i.alt)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1),i.current&&(i.current.value=``)}}};return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex gap-1`,children:[(0,p.jsx)(Z,{value:e??``,onChange:e=>t(e.target.value)}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&u(t)}}),(0,p.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>i.current?.click(),className:`shrink-0 px-2 py-1.5 text-xs border border-gray-200 rounded hover:bg-gray-50 disabled:opacity-50 flex items-center gap-1`,title:`Upload image`,children:a?(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}):(0,p.jsx)(f.Upload,{size:12})})]})]}),s&&(0,p.jsx)(`p`,{className:`text-[10px] text-red-600 mt-1`,children:s}),!r&&(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:`Tip: register an image uploader plugin to enable file uploads.`})]})}function $({value:e,onChange:t,defaultValue:n}){let r=N(e=>e.doc.theme),i=typeof e==`string`&&e.startsWith(`{`),a=(0,l.useRef)(n&&n.startsWith(`{`)?n:i?e:void 0);(0,l.useEffect)(()=>{i?a.current=e:n&&n.startsWith(`{`)&&(a.current=n)},[e,i,n]);let o=(()=>{let t=x(e,r);return typeof t==`string`&&/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)?t.length===4?`#`+t.slice(1).split(``).map(e=>e+e).join(``):t:`#000000`})(),s=n??a.current,c=!!s&&s!==e,[u,d]=(0,l.useState)(e??``);return(0,l.useEffect)(()=>d(e??``),[e]),(0,p.jsxs)(`div`,{className:`flex gap-1 items-center`,children:[(0,p.jsxs)(`label`,{className:`relative w-9 h-8 border border-gray-200 rounded cursor-pointer overflow-hidden shrink-0`,title:i?`Token → ${o} (click to override)`:`Pick color`,style:{background:o},children:[(0,p.jsx)(`input`,{type:`color`,value:o,onChange:e=>t(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer`}),i&&(0,p.jsx)(`span`,{className:`absolute inset-0 pointer-events-none border-2 border-dashed rounded`,style:{borderColor:`rgba(255,255,255,0.6)`}})]}),(0,p.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),onBlur:()=>u!==e&&t(u),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`}),c&&(0,p.jsx)(`button`,{type:`button`,onClick:()=>t(s),className:`shrink-0 p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded`,title:`Reset to ${s}`,children:(0,p.jsx)(f.RotateCcw,{size:12})})]})}function Za(e){return(0,p.jsx)(`select`,{...e,className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`})}function Qa({linkType:e,onChangeLinkType:t,onChangeLink:n}){return(0,p.jsxs)(X,{label:`Link role`,children:[(0,p.jsxs)(Za,{value:e??``,onChange:e=>{let r=e.target.value;r===``?t(void 0):(t(r),n(ye[r]))},children:[(0,p.jsx)(`option`,{value:``,children:`— None —`}),(0,p.jsx)(`option`,{value:`unsubscribe`,children:`Unsubscribe`}),(0,p.jsx)(`option`,{value:`view_in_browser`,children:`View in browser`}),(0,p.jsx)(`option`,{value:`manage_preferences`,children:`Manage preferences`}),(0,p.jsx)(`option`,{value:`user_profile`,children:`User profile`})]}),e&&(0,p.jsxs)(`p`,{className:`text-[10px] text-blue-600 mt-1 flex items-center gap-1`,children:[(0,p.jsx)(f.Tag,{size:10}),`Placeholder: `,(0,p.jsx)(`code`,{className:`font-mono`,children:ye[e]})]})]})}function $a({onInsert:e}){let t=aa(e=>e.mergeTags);return t.length===0?null:(0,p.jsxs)(X,{label:`Insert merge tag`,children:[(0,p.jsx)(`div`,{className:`flex gap-1`,children:(0,p.jsxs)(Za,{defaultValue:``,onChange:t=>{t.target.value&&(e(`{${t.target.value}}`),t.target.value=``)},children:[(0,p.jsx)(`option`,{value:``,children:`— Pick a tag —`}),t.map(e=>(0,p.jsx)(`option`,{value:e.attribute,children:e.title},e.attribute))]})}),(0,p.jsxs)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:[`Inserts `,(0,p.jsx)(`code`,{className:`font-mono`,children:`{attribute}`}),` into the text.`]})]})}function eo(){let{doc:e,updateMeta:t,updateSettings:n}=N();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ya,{children:`Email`}),(0,p.jsx)(X,{label:`Name`,children:(0,p.jsx)(Z,{value:e.meta.name,onChange:e=>t({name:e.target.value})})}),(0,p.jsx)(X,{label:`Preview text`,children:(0,p.jsx)(Z,{value:e.meta.previewText,onChange:e=>t({previewText:e.target.value})})}),(0,p.jsx)(X,{label:`Width (px)`,children:(0,p.jsx)(Q,{value:e.settings.width,onChange:e=>n({width:Number(e.target.value)||600})})}),(0,p.jsx)(X,{label:`Background color`,children:(0,p.jsx)($,{value:e.settings.backgroundColor,onChange:e=>n({backgroundColor:e})})}),(0,p.jsx)(X,{label:`Content background color`,children:(0,p.jsx)($,{value:e.settings.contentBackgroundColor,onChange:e=>n({contentBackgroundColor:e})})}),(0,p.jsx)(`div`,{className:`mt-6 pt-4 border-t border-gray-100`,children:(0,p.jsx)(to,{})})]})}function to(){let{doc:e,themes:t,applyTheme:n}=N(),r=e.theme,i=t.find(e=>e.id===r.id),a=i!=null&&Object.entries(r.tokens.colors).some(([e,t])=>i.tokens.colors[e]!==t),o=(e,t)=>{n({...r,tokens:{...r.tokens,colors:{...r.tokens.colors,[e]:t}}})};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsx)(Ya,{children:`Theme`}),a&&(0,p.jsx)(`button`,{onClick:()=>i&&n(i),className:`text-[10px] text-blue-600 hover:underline mb-3`,title:`Discard color changes and restore the preset`,children:`Reset to preset`})]}),(0,p.jsx)(`div`,{className:`flex flex-col gap-1.5 mb-4`,children:t.map(e=>{let t=e.id===r.id;return(0,p.jsxs)(`button`,{onClick:()=>n(e),title:e.name,className:`flex items-center gap-2 px-2.5 py-2 rounded border text-xs transition-colors ${t?`border-blue-500 bg-blue-50 text-blue-700`:`border-gray-200 bg-white hover:border-gray-300 text-gray-700`}`,children:[(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.primary}}),(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.background}}),(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.text}}),(0,p.jsx)(`span`,{className:`flex-1 text-left`,children:e.name}),t&&(0,p.jsx)(f.Check,{size:12,className:`text-blue-600 shrink-0`})]},e.id)})}),(0,p.jsxs)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500 mb-2`,children:[`Colors`,a&&(0,p.jsx)(`span`,{className:`ml-2 normal-case font-normal text-[10px] bg-amber-100 text-amber-700 px-1.5 py-0.5 rounded`,children:`customised`})]}),(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:Object.entries(r.tokens.colors).map(([e,t])=>(0,p.jsx)(no,{label:e,value:t,onChange:t=>o(e,t)},e))})]})}function no({label:e,value:t,onChange:n}){let[r,i]=(0,l.useState)(t);(0,l.useEffect)(()=>i(t),[t]);let a=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)?t.length===4?`#`+t.slice(1).split(``).map(e=>e+e).join(``):t:`#000000`,o=e=>{let t=e.trim();t&&n(t)};return(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`text-xs text-gray-500 w-28 shrink-0 truncate`,title:e,children:e}),(0,p.jsx)(`label`,{className:`relative w-7 h-7 rounded border border-gray-200 cursor-pointer overflow-hidden shrink-0`,style:{background:a},title:`Pick ${e} color`,children:(0,p.jsx)(`input`,{type:`color`,value:a,onChange:e=>n(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full`})}),(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onBlur:()=>o(r),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},className:`flex-1 min-w-0 px-2 py-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`,spellCheck:!1})]})}function ro({mod:e}){let t=N(e=>e.updateModule),n=N(e=>e.viewMode),r=e.style??{},i=Ga(r,n),a=new Set(Object.keys(r.mobile??{})),o=i=>t(e.id,{style:Ka(r,i,n)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ya,{children:e.name}),(0,p.jsx)(X,{label:(0,p.jsxs)(p.Fragment,{children:[`Background color`,(0,p.jsx)(qa,{overridden:a.has(`backgroundColor`)})]}),children:(0,p.jsx)($,{value:i.backgroundColor??``,onChange:e=>o({backgroundColor:e})})}),(0,p.jsx)(ao,{style:i,mobileKeys:a,onSet:o}),(0,p.jsx)(X,{label:(0,p.jsxs)(p.Fragment,{children:[`Border radius`,(0,p.jsx)(qa,{overridden:a.has(`borderRadius`)})]}),children:(0,p.jsx)(Q,{value:i.borderRadius??0,onChange:e=>o({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(Ja,{hideOn:r.hideOn,onChange:n=>t(e.id,{style:{...r,hideOn:n}})}),va(e)&&(0,p.jsx)(xa,{mod:e}),Ia(e)&&(0,p.jsx)(za,{mod:e})]})}function io({mod:e,el:t}){switch(t.type){case`text`:return(0,p.jsx)(so,{mod:e,el:t});case`image`:return(0,p.jsx)(co,{mod:e,el:t});case`button`:return(0,p.jsx)(lo,{mod:e,el:t});case`spacer`:return(0,p.jsx)(uo,{mod:e,el:t});case`divider`:return(0,p.jsx)(fo,{mod:e,el:t});case`productGrid`:return(0,p.jsx)(mo,{mod:e,el:t})}}function ao({style:e,mobileKeys:t,onSet:n}){return(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2 mb-3`,children:[`paddingTop`,`paddingBottom`,`paddingLeft`,`paddingRight`].map(r=>(0,p.jsx)(X,{label:(0,p.jsxs)(p.Fragment,{children:[r.replace(`padding`,`Pad `),(0,p.jsx)(qa,{overridden:!!t?.has(r)})]}),children:(0,p.jsx)(Q,{value:e[r]??0,onChange:e=>n({[r]:Number(e.target.value)})})},r))})}function oo(e,t){let n=N(e=>e.updateElement);return r=>n(e.id,t.id,r)}function so({mod:e,el:t}){let n=oo(e,t),r=N(e=>e.viewMode),i=t.style??{},a=Ga(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:Ka(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ya,{children:`Text`}),(0,p.jsx)(X,{label:`Content`,children:(0,p.jsx)(`textarea`,{value:t.content.replace(/<br\s*\/?>/g,`
82
- `),onChange:e=>n({content:e.target.value.replace(/\n/g,`<br/>`)}),rows:3,className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none`})}),(0,p.jsx)(X,{label:`Font family`,children:(0,p.jsx)(Z,{value:a.fontFamily??``,onChange:e=>s({fontFamily:e.target.value})})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(X,{label:`Font size`,children:(0,p.jsx)(Q,{value:a.fontSize??16,onChange:e=>s({fontSize:Number(e.target.value)})})}),(0,p.jsx)(X,{label:`Weight`,children:(0,p.jsx)(Z,{value:String(a.fontWeight??``),onChange:e=>s({fontWeight:e.target.value||void 0})})}),(0,p.jsx)(X,{label:`Line height`,children:(0,p.jsx)(Q,{step:.1,value:a.lineHeight??1.5,onChange:e=>s({lineHeight:Number(e.target.value)})})}),(0,p.jsx)(X,{label:`Letter spacing`,children:(0,p.jsx)(Q,{value:a.letterSpacing??0,onChange:e=>s({letterSpacing:Number(e.target.value)})})})]}),(0,p.jsx)(X,{label:`Color`,children:(0,p.jsx)($,{value:a.color??`#000000`,onChange:e=>s({color:e})})}),(0,p.jsx)(X,{label:`Align`,children:(0,p.jsxs)(Za,{value:a.align??`left`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsx)(X,{label:`Link URL`,children:(0,p.jsx)(Z,{value:a.link??``,onChange:e=>s({link:e.target.value})})}),(0,p.jsx)(Qa,{linkType:i.linkType,onChangeLinkType:e=>s({linkType:e}),onChangeLink:e=>s({link:e})}),(0,p.jsx)($a,{onInsert:e=>n({content:t.content+e})}),(0,p.jsx)(ao,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(Ja,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})}),(0,p.jsx)(`button`,{onClick:()=>n({content:`${t.content} ✨`}),className:`w-full mt-2 px-3 py-2 text-xs bg-purple-50 text-purple-700 border border-purple-200 rounded hover:bg-purple-100`,children:`✨ AI rewrite (mock)`})]})}function co({mod:e,el:t}){let n=oo(e,t),r=N(e=>e.viewMode),i=t.style??{},a=Ga(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:Ka(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ya,{children:`Image`}),(0,p.jsx)(X,{label:`Image URL`,children:(0,p.jsx)(Xa,{value:t.src,onChange:e=>n({src:e}),onAlt:e=>n({alt:e})})}),(0,p.jsx)(X,{label:`Alt text`,children:(0,p.jsx)(Z,{value:t.alt??``,onChange:e=>n({alt:e.target.value})})}),(0,p.jsx)(X,{label:`Link`,children:(0,p.jsx)(Z,{value:t.link??``,onChange:e=>n({link:e.target.value})})}),(0,p.jsx)(Qa,{linkType:t.linkType,onChangeLinkType:e=>n({linkType:e}),onChangeLink:e=>n({link:e})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(X,{label:(0,p.jsxs)(p.Fragment,{children:[`Width`,(0,p.jsx)(qa,{overridden:o.has(`width`)})]}),children:(0,p.jsx)(Q,{value:a.width??0,onChange:e=>s({width:Number(e.target.value)})})}),(0,p.jsx)(X,{label:(0,p.jsxs)(p.Fragment,{children:[`Height`,(0,p.jsx)(qa,{overridden:o.has(`height`)})]}),children:(0,p.jsx)(Q,{value:a.height??0,onChange:e=>s({height:Number(e.target.value)||void 0})})})]}),(0,p.jsx)(X,{label:`Border radius`,children:(0,p.jsx)(Q,{value:a.borderRadius??0,onChange:e=>s({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(X,{label:`Align`,children:(0,p.jsxs)(Za,{value:a.align??`center`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsx)(ao,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(Ja,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function lo({mod:e,el:t}){let n=oo(e,t),r=N(e=>e.viewMode),i=t.style??{},a=Ga(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:Ka(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ya,{children:`Button`}),(0,p.jsx)(X,{label:`Label`,children:(0,p.jsx)(Z,{value:t.label,onChange:e=>n({label:e.target.value})})}),(0,p.jsx)(X,{label:`Link`,children:(0,p.jsx)(Z,{value:t.link,onChange:e=>n({link:e.target.value})})}),(0,p.jsx)(Qa,{linkType:t.linkType,onChangeLinkType:e=>n({linkType:e}),onChangeLink:e=>n({link:e})}),(0,p.jsx)(X,{label:`Background color`,children:(0,p.jsx)($,{value:a.backgroundColor??``,onChange:e=>s({backgroundColor:e})})}),(0,p.jsx)(X,{label:`Text color`,children:(0,p.jsx)($,{value:a.color??`#FFFFFF`,onChange:e=>s({color:e})})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(X,{label:`Font size`,children:(0,p.jsx)(Q,{value:a.fontSize??16,onChange:e=>s({fontSize:Number(e.target.value)})})}),(0,p.jsx)(X,{label:`Border radius`,children:(0,p.jsx)(Q,{value:a.borderRadius??6,onChange:e=>s({borderRadius:Number(e.target.value)})})})]}),(0,p.jsx)(X,{label:`Align`,children:(0,p.jsxs)(Za,{value:a.align??`center`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsx)(ao,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(Ja,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function uo({mod:e,el:t}){let n=oo(e,t);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ya,{children:`Spacer`}),(0,p.jsx)(X,{label:`Height (px)`,children:(0,p.jsx)(Q,{value:t.height,onChange:e=>n({height:Number(e.target.value)||0})})})]})}function fo({mod:e,el:t}){let n=oo(e,t),r=N(e=>e.viewMode),i=t.style??{},a=Ga(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:Ka(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ya,{children:`Divider`}),(0,p.jsx)(X,{label:`Color`,children:(0,p.jsx)($,{value:a.color??`#E5E7EB`,onChange:e=>s({color:e})})}),(0,p.jsx)(X,{label:`Thickness`,children:(0,p.jsx)(Q,{value:a.thickness??1,onChange:e=>s({thickness:Number(e.target.value)})})}),(0,p.jsx)(ao,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(Ja,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function po(e=0){let t=e+1;return{id:`p_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,image:`https://placehold.co/400x400?text=Product+${t}`,imageAlt:`Product ${t}`,name:`Product ${t}`,oldPrice:`$59`,finalPrice:`$39`,description:`Short product description.`,link:`#`}}function mo({mod:e,el:t}){let n=oo(e,t),r=N(e=>e.viewMode),i=t.style??{},a=Ga(i,r),o=e=>n({style:Ka(i,e,r)}),s=e=>n({products:e}),c=e=>{let r=e,i=t.products.slice();if(i.length<r)for(;i.length<r;)i.push(po(i.length));n({columns:e,products:i})},u=Ha(),[d,m]=(0,l.useState)(null);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ya,{children:`Product Grid`}),(0,p.jsxs)(X,{label:`Columns (desktop)`,children:[(0,p.jsx)(`div`,{className:`inline-flex bg-gray-100 rounded p-0.5 w-full`,children:[1,2,3].map(e=>(0,p.jsxs)(`button`,{onClick:()=>c(e),className:`flex-1 px-2 py-1 text-xs rounded ${t.columns===e?`bg-white shadow text-gray-900`:`text-gray-500 hover:text-gray-700`}`,children:[e,` `,e===1?`col`:`cols`]},e))}),(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:`Always stacks to 1 column on mobile.`})]}),(0,p.jsx)(go,{label:`Show old price`,checked:t.showOldPrice,onChange:e=>n({showOldPrice:e})}),(0,p.jsx)(go,{label:`Show description`,checked:t.showDescription,onChange:e=>n({showDescription:e})}),(0,p.jsx)(go,{label:`Show stars`,checked:t.showStars??!1,onChange:e=>n({showStars:e})}),(0,p.jsx)(go,{label:`Show button`,checked:t.showButton,onChange:e=>n({showButton:e})}),(0,p.jsx)(X,{label:`Default button label`,children:(0,p.jsx)(Z,{value:t.buttonLabel??``,placeholder:`Shop now`,onChange:e=>n({buttonLabel:e.target.value})})}),(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(Ya,{children:[`Products (`,t.products.length,`)`]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u&&(0,p.jsxs)(`button`,{onClick:()=>m({index:null,query:``}),className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded`,title:`Find a product from your catalog`,children:[(0,p.jsx)(f.Search,{size:12}),` Find`]}),(0,p.jsxs)(`button`,{onClick:()=>s([...t.products,po(t.products.length)]),className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded`,title:`Add product`,children:[(0,p.jsx)(f.Plus,{size:12}),` Add`]})]})]}),t.products.map((e,n)=>(0,p.jsx)(_o,{index:n,product:e,canSearch:u,onSearch:()=>m({index:n,query:e.name}),onChange:e=>{let r=[...t.products];r[n]=e,s(r)},onDelete:()=>s(t.products.filter((e,t)=>t!==n))},e.id))]}),(0,p.jsx)(Ba,{open:d!==null,initialQuery:d?.query,title:d?.index==null?`Add product from search`:`Replace product`,onClose:()=>m(null),onSave:e=>{let r=G({name:e.name,finalPrice:e.finalPrice,oldPrice:e.oldPrice,description:e.description,link:e.link,image:e.image,imageAlt:e.imageAlt,stars:e.stars}),i={};e.oldPrice&&!t.showOldPrice&&(i.showOldPrice=!0),e.description&&!t.showDescription&&(i.showDescription=!0),e.stars!=null&&!t.showStars&&(i.showStars=!0);let a=t.products.slice();if(d?.index!=null){let e=a[d.index];a[d.index]={...r,id:e.id,buttonLabel:e.buttonLabel}}else a.push(r);n({products:a,...i})}}),(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsx)(Ya,{children:`Style`}),(0,p.jsx)(X,{label:`Card background`,children:(0,p.jsx)($,{value:a.cardBackgroundColor??``,onChange:e=>o({cardBackgroundColor:e})})}),(0,p.jsx)(X,{label:`Name color`,children:(0,p.jsx)($,{value:a.nameColor??``,onChange:e=>o({nameColor:e})})}),(0,p.jsx)(X,{label:`Final price color`,children:(0,p.jsx)($,{value:a.finalPriceColor??``,onChange:e=>o({finalPriceColor:e})})}),(0,p.jsx)(X,{label:`Old price color`,children:(0,p.jsx)($,{value:a.oldPriceColor??``,onChange:e=>o({oldPriceColor:e})})}),(0,p.jsx)(X,{label:`Button background`,children:(0,p.jsx)($,{value:a.buttonBackgroundColor??``,onChange:e=>o({buttonBackgroundColor:e})})}),(0,p.jsx)(X,{label:`Button text color`,children:(0,p.jsx)($,{value:a.buttonColor??``,onChange:e=>o({buttonColor:e})})}),(0,p.jsx)(X,{label:`Card radius`,children:(0,p.jsx)(Q,{value:a.borderRadius??0,onChange:e=>o({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(ao,{style:a,onSet:o})]})]})}function ho({checked:e,onChange:t}){return(0,p.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:n=>{n.preventDefault(),n.stopPropagation(),t(!e)},className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ${e?`bg-blue-600`:`bg-gray-300`}`,children:(0,p.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?`translate-x-4`:`translate-x-0.5`}`})})}function go({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`span`,{className:`text-xs text-gray-600`,children:e}),(0,p.jsx)(ho,{checked:t,onChange:n})]})}function _o({index:e,product:t,canSearch:n,onSearch:r,onChange:i,onDelete:a}){let o=e=>i({...t,...e});return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded p-2 mb-2 bg-gray-50`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-600`,children:[`#`,e+1]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n&&(0,p.jsx)(`button`,{type:`button`,onClick:r,className:`text-gray-400 hover:text-blue-600`,title:`Replace from product search`,children:(0,p.jsx)(f.Search,{size:12})}),(0,p.jsx)(`button`,{type:`button`,onClick:a,className:`text-gray-400 hover:text-red-600`,title:`Remove product`,children:(0,p.jsx)(f.Trash2,{size:12})})]})]}),(0,p.jsx)(X,{label:`Name`,children:(0,p.jsx)(Z,{value:t.name,onChange:e=>o({name:e.target.value})})}),(0,p.jsx)(X,{label:`Image URL`,children:(0,p.jsx)(Xa,{value:t.image,onChange:e=>o({image:e}),onAlt:e=>o({imageAlt:e})})}),(0,p.jsx)(X,{label:`Link`,children:(0,p.jsx)(Z,{value:t.link??``,onChange:e=>o({link:e.target.value})})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(X,{label:`Final price`,children:(0,p.jsx)(Z,{value:t.finalPrice,onChange:e=>o({finalPrice:e.target.value})})}),(0,p.jsx)(X,{label:`Old price`,children:(0,p.jsx)(Z,{value:t.oldPrice??``,placeholder:`Optional`,onChange:e=>o({oldPrice:e.target.value||void 0})})})]}),(0,p.jsx)(X,{label:`Description`,children:(0,p.jsx)(Z,{value:t.description??``,onChange:e=>o({description:e.target.value||void 0})})}),(0,p.jsx)(X,{label:`Stars (0–5, optional)`,children:(0,p.jsx)(Q,{value:t.stars??``,min:0,max:5,step:.5,placeholder:`e.g. 4.5`,onChange:e=>o({stars:e.target.value===``?void 0:Number(e.target.value)})})}),(0,p.jsx)(X,{label:`Button label (override)`,children:(0,p.jsx)(Z,{value:t.buttonLabel??``,placeholder:`Inherit default`,onChange:e=>o({buttonLabel:e.target.value||void 0})})})]})}var vo=[{type:`basic.text`,category:`basic`,name:`Text Block`,description:`Single editable paragraph of body copy. Use for short notes, intros, or filler text between sections.`,tags:[`text`,`paragraph`,`body`],create:()=>B(`basic.text`,`Text Block`,[F(`Write your text here.`,{role:`body`})])},{type:`basic.heading`,category:`basic`,name:`Heading`,description:`Bold standalone heading using the theme heading font. Use to introduce a section without other elements.`,tags:[`heading`,`title`,`section`],create:()=>B(`basic.heading`,`Heading`,[F(`A clear section heading`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingTop:16,paddingBottom:8,lineHeight:1.25})])},{type:`basic.image`,category:`basic`,name:`Image`,description:`Single full-width image, centered. Use for hero photography, illustrations, or screenshots.`,tags:[`image`,`media`,`photo`],create:()=>B(`basic.image`,`Image`,[I(W(600,300),`Placeholder`)])},{type:`basic.image_caption`,category:`basic`,name:`Image with Caption`,description:`Image followed by a small italicized caption underneath. Editorial style for newsletters.`,tags:[`image`,`caption`,`editorial`],create:()=>B(`basic.image_caption`,`Image + Caption`,[I(W(600,360),`Photo`),F(`Photo: caption goes here.`,{color:`{colors.muted}`,fontSize:13,align:`center`,paddingTop:4,paddingBottom:16})])},{type:`basic.spacer`,category:`basic`,name:`Spacer`,description:`Empty vertical space. Use to separate modules with breathing room.`,tags:[`spacer`,`spacing`,`gap`],create:()=>B(`basic.spacer`,`Spacer`,[R(32)])},{type:`basic.divider`,category:`basic`,name:`Divider`,description:`Thin horizontal rule across the email. Use to visually separate sections.`,tags:[`divider`,`separator`,`rule`],create:()=>B(`basic.divider`,`Divider`,[z()])}],yo=[{type:`header.logo`,category:`header`,name:`Logo Centered`,description:`Centered brand logo. The simplest header used at the top of almost every newsletter.`,tags:[`logo`,`brand`,`centered`],create:()=>B(`header.logo`,`Logo Header`,[I(W(180,56,`LOGO`),`Logo`,{width:180,paddingTop:24,paddingBottom:24})])},{type:`header.logo_left_date_right`,category:`header`,name:`Logo Left + Date Right`,description:`Two-column header with logo on the left and a date or issue label on the right. Common for periodical newsletters and digests.`,tags:[`logo`,`date`,`issue`,`publication`,`newsletter`],create:()=>B(`header.logo_left_date_right`,`Logo + Date`,[I(W(140,36,`LOGO`),`Logo`,{width:140,align:`left`,paddingTop:16,paddingBottom:16}),F(`Issue #128 · April 29, 2026`,{color:`{colors.muted}`,fontSize:13,align:`right`,paddingTop:0,paddingBottom:16}),z({paddingTop:0,paddingBottom:0})])},{type:`header.publication`,category:`header`,name:`Publication Masthead`,description:`Editorial masthead with publication name in serif type, tagline, and a divider. Mimics print magazine and newspaper newsletters.`,tags:[`masthead`,`publication`,`editorial`,`serif`,`newspaper`,`magazine`],create:()=>B(`header.publication`,`Masthead`,[F(`THE WEEKLY`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,letterSpacing:6,paddingTop:32,paddingBottom:4}),F(`Curated reading for thoughtful people`,{color:`{colors.muted}`,align:`center`,fontSize:13,paddingBottom:16}),z({paddingTop:0,paddingBottom:0})])},{type:`header.hero`,category:`header`,name:`Hero with Headline & Image`,description:`Big headline, subtitle and a wide hero image. Use for the lead story or campaign announcement.`,tags:[`hero`,`headline`,`image`,`lead`,`feature`],create:()=>B(`header.hero`,`Hero`,[F(`Steps Towards a Greener World`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,paddingTop:32,lineHeight:1.2}),F(`Small actions, big impact.`,{color:`{colors.muted}`,align:`center`,paddingBottom:16}),I(W(560,280,`Hero`),`Hero`,{width:560})])},{type:`header.hero_text_only`,category:`header`,name:`Hero Text Only`,description:`Centered eyebrow + large headline + supporting paragraph, no image. Editorial intro for opinion or essay newsletters.`,tags:[`hero`,`text`,`essay`,`editorial`,`minimal`],create:()=>B(`header.hero_text_only`,`Hero Text`,[F(`ESSAY · ISSUE 42`,{fontSize:12,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:3,align:`center`,paddingTop:32,paddingBottom:8}),F(`On building things slowly`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:40,fontWeight:`bold`,align:`center`,lineHeight:1.15,paddingBottom:8}),F(`Why patience and craft still win in a world of shortcuts.`,{color:`{colors.muted}`,align:`center`,fontSize:16,paddingBottom:32})])},{type:`header.announcement`,category:`header`,name:`Announcement Bar`,description:`Thin colored top bar with a single line of promotional text. Use for free shipping, sales, or alerts.`,tags:[`announcement`,`bar`,`promo`,`alert`],create:()=>B(`header.announcement`,`Announcement`,[F(`✨ Free shipping on orders over $50`,{color:`{colors.buttonText}`,align:`center`,fontSize:14,paddingTop:12,paddingBottom:12})],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`header.logo_with_view_browser`,category:`header`,name:`Logo + View in Browser`,description:`Logo with a small 'View in browser' link above it. Standard for marketing newsletters that may render poorly.`,tags:[`logo`,`view-in-browser`,`marketing`,`preheader`],create:()=>B(`header.logo_with_view_browser`,`Logo + Browser Link`,[F(`View in browser`,{color:`{colors.muted}`,fontSize:11,align:`right`,paddingTop:8,paddingBottom:0,link:`#`}),I(W(160,48,`LOGO`),`Logo`,{width:160,paddingTop:8,paddingBottom:16})])},{type:`header.welcome`,category:`header`,name:`Welcome Header`,description:`Friendly greeting with first name placeholder, used at the top of welcome and onboarding emails.`,tags:[`welcome`,`onboarding`,`greeting`,`personalized`],create:()=>B(`header.welcome`,`Welcome`,[F(`👋 Welcome aboard, {{first_name}}`,{fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,align:`center`,paddingTop:32,paddingBottom:8}),F(`We're glad you're here. Here's what to do next.`,{color:`{colors.muted}`,align:`center`,paddingBottom:16})])},{type:`header.logo_with_tagline`,category:`header`,name:`Logo + Tagline`,description:`Centered logo above a one-line tagline. Friendly brand-forward header.`,tags:[`logo`,`tagline`,`brand`],create:()=>B(`header.logo_with_tagline`,`Logo + Tagline`,[I(W(160,48,`LOGO`),`Logo`,{width:160,paddingTop:24,paddingBottom:4}),F(`Newsletters that respect your time.`,{align:`center`,color:`{colors.muted}`,fontSize:14,paddingBottom:24})])},{type:`header.story_label`,category:`header`,name:`Story Label Header`,description:`Small category label (e.g. 'Top story', 'Deep dive') above the masthead. Used by The Hustle, Morning Brew style newsletters.`,tags:[`label`,`category`,`story`,`newsletter`,`topic`],create:()=>B(`header.story_label`,`Story Label`,[F(`TODAY'S TOP STORY`,{color:`{colors.primary}`,fontSize:12,fontWeight:`bold`,letterSpacing:3,align:`center`,paddingTop:24,paddingBottom:4}),F(`AI editing tools come for the inbox`,{fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,align:`center`,paddingBottom:16,lineHeight:1.2})])}],bo=[{type:`menu.horizontal`,category:`menu`,name:`Horizontal Nav`,description:`Horizontal menu with 3-5 inline links separated by dots. Common publication navigation under the masthead.`,tags:[`menu`,`nav`,`horizontal`,`publication`],create:()=>B(`menu.horizontal`,`Horizontal Menu`,[F(`Home · Articles · Podcast · About · Subscribe`,{align:`center`,color:`{colors.text}`,fontSize:13,paddingTop:12,paddingBottom:12})])},{type:`menu.sections`,category:`menu`,name:`Section Tabs`,description:`Linked section labels representing the contents of today's issue (e.g. News · Markets · Tech · Culture). Used by daily digests.`,tags:[`menu`,`sections`,`tabs`,`digest`,`daily`],create:()=>B(`menu.sections`,`Section Tabs`,[z({paddingTop:0,paddingBottom:8}),F(`NEWS · MARKETS · TECH · CULTURE · WEEKEND`,{align:`center`,color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,paddingTop:0,paddingBottom:8}),z({paddingTop:0,paddingBottom:8})])},{type:`menu.in_this_issue`,category:`menu`,name:`In This Issue`,description:`Table-of-contents box listing the items in this newsletter issue with anchor links. Helps readers scan long emails.`,tags:[`toc`,`menu`,`issue`,`summary`,`table of contents`],create:()=>B(`menu.in_this_issue`,`In This Issue`,[F(`IN THIS ISSUE`,{fontSize:11,fontWeight:`bold`,color:`{colors.muted}`,letterSpacing:2,paddingTop:16,paddingBottom:8}),F(`→ Lead story: AI in the inbox`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#lead`}),F(`→ 3 things worth your time`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#picks`}),F(`→ Reader question of the week`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#qa`}),F(`→ Upcoming events`,{fontSize:14,paddingTop:2,paddingBottom:16,link:`#events`})],{backgroundColor:`{colors.background}`,paddingTop:8,paddingBottom:8,paddingLeft:16,paddingRight:16})},{type:`menu.cta_strip`,category:`menu`,name:`Linked Action Strip`,description:`Three short text actions in a row (e.g. 'Read · Share · Reply'). Light alternative to a button bar.`,tags:[`menu`,`actions`,`links`,`strip`],create:()=>B(`menu.cta_strip`,`Action Strip`,[F(`Read online · Share · Reply with feedback`,{align:`center`,color:`{colors.primary}`,fontSize:13,paddingTop:12,paddingBottom:12})])}],xo=[{type:`content.headline_body`,category:`content`,name:`Headline + Body`,description:`Section title with one paragraph of body text. The most generic written content block.`,tags:[`headline`,`body`,`paragraph`,`article`],create:()=>B(`content.headline_body`,`Headline + Body`,[V(`A compelling headline`,{paddingTop:24}),F(`Tell your story with a clear, concise paragraph. Keep readers engaged with short sentences and meaningful detail.`,{paddingBottom:24})])},{type:`content.lead_story`,category:`content`,name:`Lead Story`,description:`Top story of the issue: eyebrow label, big headline, hero image, lead paragraph and a 'Continue reading' link. Used by news and editorial newsletters.`,tags:[`lead`,`story`,`feature`,`news`,`editorial`,`long-form`],create:()=>B(`content.lead_story`,`Lead Story`,[H(`Lead story`),V(`Inside the new wave of indie publishers`,{level:1,paddingBottom:4}),U(`By Jane Doe · 6 min read`,{fontSize:13}),I(W(560,320,`Lead`),`Lead`,{width:560,paddingTop:12}),F(`A growing group of writers are leaving big media to build their own readerships, betting that quality and a direct relationship beat scale.`,{paddingTop:16}),F(`Continue reading →`,{color:`{colors.primary}`,fontWeight:`bold`,paddingTop:4,paddingBottom:24,link:`#`})])},{type:`content.article_summary`,category:`content`,name:`Article Summary Card`,description:`Compact link-out card: image on top, category label, title, one-line summary, and 'Read more'. Use repeatedly to list secondary articles.`,tags:[`article`,`summary`,`card`,`link-out`,`newsletter`],create:()=>B(`content.article_summary`,`Article Card`,[I(W(560,280,`Article`),`Article`,{width:560}),F(`CULTURE`,{color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,paddingTop:12,paddingBottom:4}),V(`How long-form writing made a comeback`,{paddingTop:0,paddingBottom:4}),F(`Why subscribers are paying for slower, deeper coverage — and what it means for publishers.`,{paddingBottom:8}),F(`Read more →`,{color:`{colors.primary}`,fontWeight:`bold`,paddingBottom:24,link:`#`})])},{type:`content.image_text`,category:`content`,name:`Image + Text Beside`,description:`Image with article title and short summary stacked below. Standard editorial card.`,tags:[`image`,`text`,`article`,`stacked`],create:()=>B(`content.image_text`,`Image + Text`,[I(W(560,300,`Article`),`Article`,{width:560}),V(`Article title`,{paddingTop:16,paddingBottom:4}),F(`A short summary of the article goes here, two or three lines is plenty.`)])},{type:`content.two_column_articles`,category:`content`,name:`Two Column Stories`,description:`Two short article previews shown side-by-side as stacked blocks (renders as full-width on mobile). Use to tease two related stories.`,tags:[`two-column`,`articles`,`side-by-side`,`preview`],create:()=>B(`content.two_column_articles`,`Two Stories`,[H(`More to read`),I(W(272,180,`Story A`),`Story A`,{width:272}),F(`Story A title`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),F(`One sentence about story A.`,{fontSize:14,paddingBottom:16}),I(W(272,180,`Story B`),`Story B`,{width:272}),F(`Story B title`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),F(`One sentence about story B.`,{fontSize:14,paddingBottom:16})])},{type:`content.three_picks`,category:`content`,name:`Three Picks (Numbered)`,description:`Numbered list of three short recommendations or links. Used by curators ('3 things to read this week').`,tags:[`list`,`picks`,`curated`,`links`,`recommendations`],create:()=>B(`content.three_picks`,`Three Picks`,[H(`Three picks`),F(`01 / How to stay focused in 2026`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),U(`Notes on attention, deep work, and the slow internet.`,{fontSize:14}),z({paddingTop:12,paddingBottom:8}),F(`02 / The case for boring software`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),U(`Why teams are returning to simpler, predictable tools.`,{fontSize:14}),z({paddingTop:12,paddingBottom:8}),F(`03 / A short history of the inbox`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),U(`From memos to MIME, and what comes next.`,{fontSize:14,paddingBottom:24})])},{type:`content.quote`,category:`content`,name:`Pull Quote`,description:`Centered serif pull quote with attribution. Adds rhythm to long editorial newsletters.`,tags:[`quote`,`pull-quote`,`editorial`,`attribution`],create:()=>B(`content.quote`,`Pull Quote`,[F(`“The best way to predict the future is to create it.”`,{fontFamily:`{fonts.heading}`,fontSize:22,align:`center`,paddingTop:24,lineHeight:1.4}),F(`— Peter Drucker`,{color:`{colors.muted}`,align:`center`,paddingBottom:24})])},{type:`content.author_byline`,category:`content`,name:`Author Byline`,description:`Round avatar + author name + role on one line. Drop above or below an article body for personal newsletters.`,tags:[`author`,`byline`,`avatar`,`personal`],create:()=>B(`content.author_byline`,`Byline`,[I(W(64,64,`👤`),`Author`,{width:64,borderRadius:32,paddingTop:16,paddingBottom:0}),F(`Jane Doe`,{align:`center`,fontWeight:`bold`,paddingTop:8,paddingBottom:0}),U(`Editor, The Weekly`,{align:`center`,fontSize:13}),R(16)])},{type:`content.editor_note`,category:`content`,name:`Editor's Note`,description:`Personal letter-style block: 'Hi {{first_name}}', a few paragraphs and a sign-off. Ideal for newsletters with a strong author voice.`,tags:[`editor`,`note`,`letter`,`personal`,`voice`],create:()=>B(`content.editor_note`,`Editor's Note`,[F(`Hi {{first_name}},`,{paddingTop:24,paddingBottom:8}),F(`This week I've been thinking about what makes a newsletter feel like a letter rather than a broadcast. Spoiler: it's not the format, it's the tone.`,{paddingBottom:8,lineHeight:1.7}),F(`Let me know what you think — just hit reply.`,{paddingBottom:8,lineHeight:1.7}),F(`— Jane`,{fontFamily:`{fonts.heading}`,paddingBottom:24})])},{type:`content.tip_box`,category:`content`,name:`Tip / Callout Box`,description:`Highlighted background box with an icon, short title and one-paragraph tip. Use for 'pro tips', notes, and warnings.`,tags:[`tip`,`callout`,`box`,`highlight`,`note`],create:()=>B(`content.tip_box`,`Tip Box`,[F(`💡 PRO TIP`,{color:`{colors.primary}`,fontSize:12,fontWeight:`bold`,letterSpacing:2,paddingTop:16,paddingBottom:4}),F(`Always preview your email on mobile before sending — most opens happen there.`,{paddingBottom:16})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16})},{type:`content.numbered_list`,category:`content`,name:`Numbered List`,description:`Vertical numbered list of 4-5 short items with optional sub-text. Use for tutorials, checklists and 'how-to' newsletters.`,tags:[`list`,`numbered`,`tutorial`,`checklist`,`how-to`],create:()=>B(`content.numbered_list`,`Numbered List`,[V(`How to do it in 4 steps`,{paddingTop:16,paddingBottom:12}),F(`1. Define the goal`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),U(`Write down the outcome in one sentence.`),F(`2. List constraints`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`Time, budget, scope. Be specific.`),F(`3. Plan the smallest version`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`What can you ship this week?`),F(`4. Ship it`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`Refine after real feedback.`,{fontSize:14}),R(16)])},{type:`content.bullet_list`,category:`content`,name:`Bullet List`,description:`Simple unordered list of takeaways or facts. Concise summary block.`,tags:[`list`,`bullets`,`takeaways`,`summary`],create:()=>B(`content.bullet_list`,`Bullets`,[V(`Key takeaways`,{paddingTop:16,paddingBottom:8}),F(`• Newsletters are growing 20% YoY`,{paddingTop:2,paddingBottom:2}),F(`• Mobile opens crossed 70%`,{paddingTop:2,paddingBottom:2}),F(`• Plain-text emails outperform image-heavy ones in B2B`,{paddingTop:2,paddingBottom:2}),F(`• Personalization drives 2x click-through`,{paddingTop:2,paddingBottom:16})])},{type:`content.qa`,category:`content`,name:`Q&A Block`,description:`Question in bold followed by an answer paragraph. Use for FAQ, reader mailbags, or AMAs.`,tags:[`qa`,`faq`,`ama`,`mailbag`,`reader-questions`],create:()=>B(`content.qa`,`Q&A`,[H(`Reader question`),F(`Q: How do I get my first 100 subscribers?`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:4,paddingBottom:8,lineHeight:1.3}),F(`A: Tell ten people who already know you. Then ask each of them to forward to one friend. The first 100 don't come from algorithms — they come from your network.`,{paddingBottom:24,lineHeight:1.7})])},{type:`content.stats_row`,category:`content`,name:`Stat Row`,description:`Big numbers with short labels (e.g. '12k readers · 4.8★ rating · 96% open rate'). Used for impact summaries and social proof.`,tags:[`stats`,`numbers`,`metrics`,`social-proof`],create:()=>B(`content.stats_row`,`Stat Row`,[H(`By the numbers`,{align:`center`}),F(`12,400`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,color:`{colors.primary}`,paddingTop:4,paddingBottom:0}),U(`active readers this month`,{align:`center`,fontSize:13}),R(8),F(`96% · 4.8★ · 32 issues shipped`,{align:`center`,color:`{colors.text}`,fontSize:14,paddingBottom:24})])},{type:`content.timeline`,category:`content`,name:`Timeline / What Happened`,description:`Chronological list of recent events with dates. Used by news roundups and changelog newsletters.`,tags:[`timeline`,`changelog`,`news`,`events`,`what-happened`],create:()=>B(`content.timeline`,`Timeline`,[H(`This week`),F(`Mon · Acme launches plan B`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`After 6 months of beta testing.`,{fontSize:14}),F(`Wed · New funding round announced`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`$24M Series A led by Foundry.`,{fontSize:14}),F(`Fri · Industry report drops`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`Open rates up across the board.`,{fontSize:14,paddingBottom:24})])},{type:`content.podcast_episode`,category:`content`,name:`Podcast Episode`,description:`Episode artwork, episode number, title, short description and a 'Listen' button. For shows that announce episodes by email.`,tags:[`podcast`,`episode`,`audio`,`listen`,`show`],create:()=>B(`content.podcast_episode`,`Podcast Episode`,[I(W(220,220,`Cover`),`Cover`,{width:220,borderRadius:12}),F(`EPISODE 042`,{color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,align:`center`,paddingTop:12,paddingBottom:4}),V(`Why publishers are betting on email`,{align:`center`,paddingTop:0,paddingBottom:4}),U(`With Jane Doe · 38 min`,{align:`center`,fontSize:13}),L(`Listen now`,`https://example.com`),R(16)])},{type:`content.video_thumbnail`,category:`content`,name:`Video Thumbnail`,description:`Video thumbnail with overlay-feeling play button (image only, links to a hosted player). Title and duration below.`,tags:[`video`,`thumbnail`,`watch`,`play`,`media`],create:()=>B(`content.video_thumbnail`,`Video`,[I(W(560,315,`▶ Watch`),`Video`,{width:560,link:`#`,borderRadius:8}),V(`Watch: a guided tour of our 2026 launches`,{paddingTop:12,paddingBottom:4}),U(`4 min watch`,{fontSize:13,paddingBottom:16})])},{type:`content.event_card`,category:`content`,name:`Event Card`,description:`Date badge with event title, location, time and an RSVP button. For event-driven newsletters and community digests.`,tags:[`event`,`rsvp`,`community`,`date`,`card`],create:()=>B(`content.event_card`,`Event`,[F(`MAY`,{align:`center`,color:`{colors.buttonText}`,fontSize:12,fontWeight:`bold`,letterSpacing:2,paddingTop:12,paddingBottom:0}),F(`12`,{align:`center`,color:`{colors.buttonText}`,fontSize:36,fontWeight:`bold`,paddingTop:0,paddingBottom:12})],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`content.code_block`,category:`content`,name:`Code Snippet`,description:`Monospaced code block on a tinted background. For developer newsletters and changelog excerpts.`,tags:[`code`,`snippet`,`developer`,`monospace`,`changelog`],create:()=>B(`content.code_block`,`Code`,[F(`npm install @one-million-lines/email-builder`,{fontFamily:`Menlo, Consolas, monospace`,fontSize:13,color:`{colors.text}`,paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16})}],So=[{type:`feature.list`,category:`feature`,name:`Checkmark Feature List`,description:`Centered title with 3-4 short checkmarked benefits. Good for product newsletters and onboarding emails.`,tags:[`features`,`benefits`,`checkmarks`,`list`],create:()=>B(`feature.list`,`Feature List`,[V(`Why people love it`,{align:`center`,paddingTop:24}),F(`✓ Fast and reliable`,{align:`center`}),F(`✓ Beautiful out of the box`,{align:`center`}),F(`✓ Backed by humans, not bots`,{align:`center`,paddingBottom:24})])},{type:`feature.icon_three`,category:`feature`,name:`Three Icon Features`,description:`Three stacked feature blocks with an emoji/icon, short title and one-line description. Use to highlight 3 product capabilities.`,tags:[`features`,`icons`,`three-up`,`product`],create:()=>B(`feature.icon_three`,`Three Features`,[F(`⚡`,{align:`center`,fontSize:32,paddingTop:24,paddingBottom:4}),F(`Fast`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),U(`Built to render in milliseconds.`,{align:`center`,fontSize:14}),R(16),F(`🧩`,{align:`center`,fontSize:32,paddingBottom:4}),F(`Modular`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),U(`Compose any layout from blocks.`,{align:`center`,fontSize:14}),R(16),F(`🤖`,{align:`center`,fontSize:32,paddingBottom:4}),F(`AI-ready`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),U(`Edit emails as JSON, not HTML.`,{align:`center`,fontSize:14,paddingBottom:24})])},{type:`feature.before_after`,category:`feature`,name:`Before / After`,description:`Two stacked images labeled 'Before' and 'After'. For product transformations, redesigns and case studies.`,tags:[`before-after`,`comparison`,`case-study`,`transformation`],create:()=>B(`feature.before_after`,`Before / After`,[H(`Before`),I(W(560,280,`Before`),`Before`,{width:560}),R(8),H(`After`),I(W(560,280,`After`),`After`,{width:560}),R(16)])},{type:`feature.benefit_pair`,category:`feature`,name:`Image + Benefit Pair`,description:`Repeat-use block: one supporting image plus a title and benefit paragraph beside it. Stack 2-3 of these for a feature tour.`,tags:[`benefit`,`feature`,`image-text`,`pair`],create:()=>B(`feature.benefit_pair`,`Benefit Pair`,[I(W(560,240,`Feature`),`Feature`,{width:560,paddingTop:16}),V(`Send 10x faster`,{paddingTop:12,paddingBottom:4}),F(`Reusable modules and theme tokens let teams ship campaigns in minutes, not days.`,{paddingBottom:24})])},{type:`feature.testimonial`,category:`feature`,name:`Testimonial`,description:`Customer quote in large type with avatar and attribution. Social proof block.`,tags:[`testimonial`,`review`,`social-proof`,`customer`],create:()=>B(`feature.testimonial`,`Testimonial`,[F(`“This cut our email production from a week to an afternoon.”`,{fontFamily:`{fonts.heading}`,fontSize:22,align:`center`,paddingTop:24,paddingBottom:12,lineHeight:1.4}),I(W(56,56,`👤`),`Customer`,{width:56,borderRadius:28}),F(`Alex Kim · Head of Lifecycle, Acme`,{align:`center`,color:`{colors.muted}`,fontSize:13,paddingTop:4,paddingBottom:24})])},{type:`feature.logo_strip`,category:`feature`,name:`Customer Logo Strip`,description:`Small horizontal row implying customer logos for credibility ('Trusted by'). Logos shown as a placeholder image.`,tags:[`logos`,`trusted-by`,`social-proof`,`strip`],create:()=>B(`feature.logo_strip`,`Logo Strip`,[U(`TRUSTED BY`,{align:`center`,fontSize:11}),I(W(520,60,`LOGOS`),`Customer logos`,{width:520,paddingTop:8,paddingBottom:16})])},{type:`feature.gradient_hero`,category:`feature`,name:`Gradient Hero CTA`,description:`Bold centered hero with an eyebrow, oversized headline and a primary CTA button. Great for launch announcements and campaign openers.`,tags:[`hero`,`launch`,`cta`,`bold`,`announcement`],create:()=>B(`feature.gradient_hero`,`Gradient Hero CTA`,[H(`Introducing`,{align:`center`}),V(`Something new is here`,{level:1,align:`center`,paddingTop:4,paddingBottom:8}),F(`A fresh way to reach your audience — crafted for the inbox.`,{align:`center`,color:`{colors.muted}`,fontSize:16,paddingBottom:20}),L(`Explore now`,`#`,{align:`center`})],{backgroundColor:`{colors.surface}`,paddingTop:40,paddingBottom:40})},{type:`feature.pull_quote`,category:`feature`,name:`Pull Quote`,description:`Large centered quotation with an attribution line. Use to highlight a testimonial or a memorable line.`,tags:[`quote`,`testimonial`,`highlight`,`pull-quote`],create:()=>B(`feature.pull_quote`,`Pull Quote`,[F(`“This is the fastest we’ve ever shipped a campaign.”`,{fontFamily:`{fonts.heading}`,fontSize:24,align:`center`,lineHeight:1.4,paddingTop:28,paddingBottom:8}),U(`— A very happy customer`,{align:`center`,paddingBottom:28})])},{type:`feature.stat_row`,category:`feature`,name:`Stat Row`,description:`Three short number + label pairs in a row. Use to show traction, metrics or highlights.`,tags:[`stats`,`metrics`,`numbers`,`row`,`kpi`],create:()=>B(`feature.stat_row`,`Stat Row`,[V(`By the numbers`,{align:`center`,paddingTop:24}),F(`<b>10k+</b> subscribers &nbsp;·&nbsp; <b>98%</b> delivery &nbsp;·&nbsp; <b>4.9★</b> rating`,{align:`center`,color:`{colors.muted}`,paddingBottom:24})])},{type:`feature.single_product_spotlight`,category:`feature`,name:`Single Product Spotlight`,description:`One product with image, name, price and buy button. Use to feature a hero product in a feature-focused email.`,tags:[`product`,`spotlight`,`single`,`buy`,`shop`,`ecommerce`],create:()=>B(`feature.single_product_spotlight`,`Product Spotlight`,[Se([G({name:`The Signature Bag`,finalPrice:`$129`,oldPrice:`$159`,description:`Handmade, built to last.`,image:W(520,520,`Product`)})],{columns:1,showDescription:!0,buttonLabel:`Buy now`})])},{type:`feature.pill_nav`,category:`feature`,name:`Pill Navigation`,description:`Centered row of navigation links with a divider below. Compact feature nav block for use inside email content sections.`,tags:[`menu`,`nav`,`links`,`pill`],create:()=>B(`feature.pill_nav`,`Pill Navigation`,[I(W(120,32,`LOGO`),`Logo`,{width:120,paddingBottom:8}),F(`<a href="#">Shop</a> &nbsp; <a href="#">New</a> &nbsp; <a href="#">Sale</a> &nbsp; <a href="#">About</a>`,{align:`center`,color:`{colors.primary}`,paddingBottom:8}),z({paddingTop:4,paddingBottom:0})])}],Co=[{type:`cta.simple`,category:`call_to_action`,name:`Simple CTA`,description:`Centered headline + body + primary button. The default call-to-action block for any newsletter or promo.`,tags:[`cta`,`primary`,`centered`,`button`],create:()=>B(`cta.simple`,`Simple CTA`,[V(`Ready to get started?`,{align:`center`,paddingTop:24}),U(`Create better emails faster.`,{align:`center`}),L(`Start now`,`https://example.com`),R(16)])},{type:`cta.banner`,category:`call_to_action`,name:`Colored Banner CTA`,description:`Full-width colored band with eyebrow, big headline and a contrasting button. Use to draw attention to sales or launches.`,tags:[`cta`,`banner`,`colored`,`promo`,`sale`],create:()=>B(`cta.banner`,`CTA Banner`,[F(`Limited time offer`,{color:`{colors.buttonText}`,align:`center`,fontSize:14,paddingTop:24,paddingBottom:4}),F(`Save 30% this week only`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingBottom:16}),L(`Shop the sale`),R(24)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`cta.button_only`,category:`call_to_action`,name:`Button Only`,description:`Single primary button on a clean background. Use as a follow-up CTA after a content block.`,tags:[`cta`,`button`,`minimal`],create:()=>B(`cta.button_only`,`Button`,[L(`Click here`,`https://example.com`)])},{type:`cta.dual_button`,category:`call_to_action`,name:`Two Button Choice`,description:`Two side-by-side actions: a primary and a ghost-styled secondary. Use when offering 'Learn more' vs 'Get started'.`,tags:[`cta`,`buttons`,`two-options`,`choice`],create:()=>B(`cta.dual_button`,`Two Buttons`,[V(`Pick your path`,{align:`center`,paddingTop:24}),U(`Choose what fits your team.`,{align:`center`}),L(`Get started`,`https://example.com`),L(`Learn more`,`https://example.com`,{backgroundColor:`transparent`,color:`{colors.primary}`}),R(16)])},{type:`cta.image_overlay`,category:`call_to_action`,name:`Image + Overlay CTA`,description:`Lead image with a headline, supporting text, and a button immediately below. Strong visual call to action.`,tags:[`cta`,`image`,`visual`,`hero`],create:()=>B(`cta.image_overlay`,`Image CTA`,[I(W(560,280,`Visual`),`Visual`,{width:560,paddingTop:16}),V(`Stop guessing. Start measuring.`,{align:`center`,paddingTop:16}),U(`Free for 14 days. No credit card.`,{align:`center`}),L(`Try it free`),R(16)])},{type:`cta.subscribe`,category:`call_to_action`,name:`Subscribe / Forward`,description:`Friendly 'Was this forwarded? Subscribe' block that grows the list virally. Common at the end of newsletters.`,tags:[`cta`,`subscribe`,`forward`,`growth`,`newsletter`],create:()=>B(`cta.subscribe`,`Subscribe`,[H(`Was this forwarded?`,{align:`center`}),V(`Get the next issue in your inbox`,{align:`center`,paddingTop:0,paddingBottom:8}),L(`Subscribe free`),R(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})},{type:`cta.referral`,category:`call_to_action`,name:`Referral / Share`,description:`Encourages readers to share the newsletter with a unique referral link. Includes a 'Share' button and a personalized URL.`,tags:[`cta`,`referral`,`share`,`viral`,`growth`],create:()=>B(`cta.referral`,`Referral`,[H(`Tell a friend`,{align:`center`}),V(`Share & earn perks`,{align:`center`,paddingTop:0,paddingBottom:8}),U(`Refer 3 friends and unlock the bonus issue.`,{align:`center`}),F(`yourname.com/r/abc123`,{align:`center`,color:`{colors.primary}`,fontFamily:`Menlo, Consolas, monospace`,fontSize:14,paddingTop:8,paddingBottom:8}),L(`Share now`),R(16)])},{type:`cta.upgrade`,category:`call_to_action`,name:`Upgrade / Paid`,description:`Conversion block that promotes a paid plan or premium tier. Includes price, benefits and an upgrade button.`,tags:[`cta`,`upgrade`,`paid`,`premium`,`conversion`],create:()=>B(`cta.upgrade`,`Upgrade`,[H(`Become a member`,{align:`center`}),V(`$5 / month`,{align:`center`,level:1}),U(`Unlock the archive, weekly bonus and member chat.`,{align:`center`,fontSize:14}),L(`Upgrade`),R(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})},{type:`cta.feedback`,category:`call_to_action`,name:`Feedback Reply`,description:`Asks the reader to reply with feedback ('Hit reply and let me know'). Personal, no button.`,tags:[`cta`,`feedback`,`reply`,`personal`],create:()=>B(`cta.feedback`,`Feedback`,[F(`How did this issue land for you? Just hit reply — I read every message.`,{align:`center`,paddingTop:24,paddingBottom:24,lineHeight:1.6})])}],wo=[{type:`ecom.product_single`,category:`ecommerce`,name:`Single Product`,description:`One product with image, title, price, short description and Buy button. Use to feature a hero product. Supports old/final price and per-product link.`,tags:[`product`,`single`,`buy`,`hero`],create:()=>B(`ecom.product_single`,`Single Product`,[Se([G({name:`Linen Tote Bag`,image:W(560,400,`Product`),oldPrice:`$59.00`,finalPrice:`$39.00`,description:`Heavyweight natural linen, made in Portugal.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`Buy now`})])},{type:`ecom.product_grid_2`,category:`ecommerce`,name:`Product Grid (2 up)`,description:`Two products side-by-side on desktop, stacked on mobile. Each card has image, name, old/final price, optional description and Shop button. Curated picks layout.`,tags:[`product`,`grid`,`two-up`,`curated`,`responsive`],create:()=>B(`ecom.product_grid_2`,`Product Grid 2`,[Se([G({name:`Product A`,finalPrice:`$29`,oldPrice:`$39`}),G({name:`Product B`,finalPrice:`$34`,oldPrice:`$45`})],{columns:2,showOldPrice:!0})])},{type:`ecom.product_grid_3`,category:`ecommerce`,name:`Product Grid (3 up)`,description:`Three product cards in a row on desktop, stacked on mobile. Use for 'New arrivals' or 'Bestsellers' rows.`,tags:[`product`,`grid`,`three-up`,`bestsellers`,`new-arrivals`,`responsive`],create:()=>B(`ecom.product_grid_3`,`Product Grid 3`,[H(`New arrivals`,{align:`center`}),Se([G({name:`Product 1`,finalPrice:`$19`}),G({name:`Product 2`,finalPrice:`$24`}),G({name:`Product 3`,finalPrice:`$32`})],{columns:3,showOldPrice:!1})])},{type:`ecom.collection_banner`,category:`ecommerce`,name:`Collection Banner`,description:`Wide collection banner with title and 'Shop the collection' button overlaying or under an image. Use for category drops.`,tags:[`collection`,`banner`,`category`,`drop`],create:()=>B(`ecom.collection_banner`,`Collection`,[I(W(560,300,`Collection`),`Collection`,{width:560}),V(`Spring Collection 2026`,{align:`center`,paddingTop:16}),U(`Lighter fabrics, brighter colors.`,{align:`center`}),L(`Shop the collection`),R(16)])},{type:`ecom.discount`,category:`ecommerce`,name:`Discount Code`,description:`Big discount code in monospaced caps with 'Your code' label and a Redeem button.`,tags:[`discount`,`promo`,`code`,`coupon`],create:()=>B(`ecom.discount`,`Discount Code`,[U(`Your code`,{align:`center`}),F(`SAVE20`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,color:`{colors.primary}`,letterSpacing:4,paddingTop:4,paddingBottom:16}),L(`Redeem`),R(24)])},{type:`ecom.voucher`,category:`ecommerce`,name:`Voucher Code`,description:`Personalized voucher block: 'Your code' label, a large voucher code and a Redeem button. With the voucher-select plugin, pick a code from your backend catalog; otherwise edit the code text directly.`,tags:[`voucher`,`coupon`,`discount`,`code`,`promo`,`redeem`],create:()=>B(`ecom.voucher`,`Voucher Code`,[U(`Your code`,{align:`center`}),be(`SAVE20`),L(`Redeem`),R(24)])},{type:`ecom.flash_sale`,category:`ecommerce`,name:`Flash Sale Banner`,description:`Urgency-driven banner with countdown-style copy ('Ends in 24h'), discount value and a shop button.`,tags:[`flash-sale`,`urgency`,`promo`,`banner`,`countdown`],create:()=>B(`ecom.flash_sale`,`Flash Sale`,[F(`⏰ FLASH SALE — ENDS IN 24H`,{color:`{colors.buttonText}`,align:`center`,fontWeight:`bold`,letterSpacing:2,paddingTop:16,paddingBottom:4}),F(`Up to 50% off everything`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingBottom:12}),L(`Shop now`,`#`,{backgroundColor:`{colors.surface}`,color:`{colors.primary}`}),R(16)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`ecom.abandoned_cart`,category:`ecommerce`,name:`Abandoned Cart Reminder`,description:`Friendly reminder showing the items left in the cart with a return-to-cart button. For cart recovery automations.`,tags:[`abandoned-cart`,`recovery`,`automation`,`reminder`],create:()=>B(`ecom.abandoned_cart`,`Abandoned Cart`,[V(`You left something behind`,{align:`center`,paddingTop:16}),U(`Pick up where you left off.`,{align:`center`}),R(8),Se([G({name:`Linen Tote Bag`,image:W(400,400,`Item`),finalPrice:`$39`,oldPrice:`$49`})],{columns:1,showOldPrice:!0,buttonLabel:`Return to cart`})])},{type:`ecom.review_request`,category:`ecommerce`,name:`Review Request`,description:`Post-purchase block asking for a 1-5 star rating with stacked star buttons. For review-collection emails.`,tags:[`review`,`rating`,`post-purchase`,`feedback`],create:()=>B(`ecom.review_request`,`Review`,[V(`How did we do?`,{align:`center`,paddingTop:24}),U(`Tap a star to leave a quick review.`,{align:`center`}),F(`☆ ☆ ☆ ☆ ☆`,{align:`center`,fontSize:32,color:`{colors.primary}`,paddingTop:12,paddingBottom:24,link:`#`})])},{type:`ecom.gift_guide`,category:`ecommerce`,name:`Gift Guide Pick`,description:`Editorial gift-guide pick: persona eyebrow + a single product card with full details (image, name, old/final price, description, CTA).`,tags:[`gift-guide`,`curated`,`editorial`,`holiday`],create:()=>B(`ecom.gift_guide`,`Gift Pick`,[H(`For the home cook`),Se([G({name:`Cast Iron Skillet`,image:W(560,300,`Pick`),oldPrice:`$119`,finalPrice:`$89`,description:`Pre-seasoned, lifetime-guarantee. Made in USA.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`View product`})])},{type:`ecom.bestseller_list`,category:`ecommerce`,name:`Bestseller Grid`,description:`Top products grid (3 up) with old/final prices. Used by retailers for weekly bestsellers.`,tags:[`bestsellers`,`grid`,`ranking`,`top`],create:()=>B(`ecom.bestseller_list`,`Bestsellers`,[H(`Top 3 this week`),Se([G({name:`Linen Tote`,finalPrice:`$39`,oldPrice:`$49`}),G({name:`Ceramic Mug`,finalPrice:`$24`}),G({name:`Brass Lamp`,finalPrice:`$129`,oldPrice:`$149`})],{columns:3,showOldPrice:!0})])}],To=[{type:`tx.order_summary`,category:`transactional`,name:`Order Summary`,description:`Order confirmation summary: order number, line items with thumbnails and totals row. Used in post-purchase emails.`,tags:[`order`,`summary`,`receipt`,`post-purchase`,`ecommerce`],create:()=>B(`tx.order_summary`,`Order Summary`,[H(`Order #1024`),V(`Thanks for your order`,{paddingTop:0}),U(`We'll email you again when it ships.`),z({paddingTop:16,paddingBottom:8}),F(`Linen Tote Bag · 1 × $39.00`,{paddingTop:4,paddingBottom:4}),F(`Ceramic Mug · 2 × $24.00`,{paddingTop:4,paddingBottom:4}),z({paddingTop:8,paddingBottom:8}),F(`Subtotal: $87.00`,{paddingTop:2,paddingBottom:2}),F(`Shipping: $5.00`,{paddingTop:2,paddingBottom:2}),F(`Total: $92.00`,{fontWeight:`bold`,paddingTop:2,paddingBottom:16})])},{type:`tx.shipping_update`,category:`transactional`,name:`Shipping Update`,description:`Shipping confirmation with tracking number, carrier, expected delivery date and a Track button.`,tags:[`shipping`,`tracking`,`delivery`,`post-purchase`],create:()=>B(`tx.shipping_update`,`Shipping Update`,[F(`📦`,{align:`center`,fontSize:40,paddingTop:24}),V(`Your order is on the way`,{align:`center`,paddingTop:8}),U(`Carrier: USPS · Expected: May 4, 2026`,{align:`center`}),F(`Tracking: 9400 1108 ...`,{align:`center`,color:`{colors.muted}`,fontFamily:`Menlo, Consolas, monospace`,fontSize:13}),L(`Track package`),R(16)])},{type:`tx.invoice`,category:`transactional`,name:`Invoice`,description:`Itemized invoice with billing period, services and totals. Used by SaaS and B2B billing emails.`,tags:[`invoice`,`billing`,`saas`,`b2b`,`receipt`],create:()=>B(`tx.invoice`,`Invoice`,[H(`Invoice INV-2026-04`),V(`April 2026 invoice`),U(`Billed to: Acme Inc · Period: Apr 1 – Apr 30`),z({paddingTop:16,paddingBottom:8}),F(`Pro plan · $49.00`,{paddingTop:4,paddingBottom:4}),F(`Add-on seats (3) · $36.00`,{paddingTop:4,paddingBottom:4}),z({paddingTop:8,paddingBottom:8}),F(`Total due: $85.00`,{fontWeight:`bold`,paddingBottom:16}),L(`Download invoice (PDF)`),R(16)])},{type:`tx.password_reset`,category:`transactional`,name:`Password Reset`,description:`Authentication email with a reset button and a fallback link. Includes 'expires in X minutes' notice.`,tags:[`auth`,`password`,`reset`,`security`],create:()=>B(`tx.password_reset`,`Password Reset`,[V(`Reset your password`,{align:`center`,paddingTop:16}),F(`Click the button below to set a new password. This link expires in 30 minutes.`,{align:`center`,paddingBottom:16}),L(`Reset password`),U(`If the button doesn't work, paste this link in your browser:`,{align:`center`,fontSize:12}),F(`https://example.com/reset/abc123`,{align:`center`,color:`{colors.primary}`,fontSize:12,paddingBottom:24})])},{type:`tx.verify_email`,category:`transactional`,name:`Verify Email`,description:`Single-purpose 'verify your email' transactional with one centered button.`,tags:[`auth`,`verify`,`email-confirmation`],create:()=>B(`tx.verify_email`,`Verify Email`,[V(`One last step`,{align:`center`,paddingTop:16}),F(`Confirm your email address to activate your account.`,{align:`center`,paddingBottom:8}),L(`Verify email`),R(24)])},{type:`tx.appointment`,category:`transactional`,name:`Appointment Confirmation`,description:`Booking/meeting confirmation with date, time, location and add-to-calendar links.`,tags:[`appointment`,`booking`,`calendar`,`meeting`],create:()=>B(`tx.appointment`,`Appointment`,[H(`Confirmed`,{align:`center`}),V(`Your appointment is set`,{align:`center`,paddingTop:0}),F(`Tuesday, May 12 · 10:00 AM`,{align:`center`,fontWeight:`bold`,paddingTop:8}),U(`123 Main St, Suite 4 · Brooklyn, NY`,{align:`center`}),L(`Add to calendar`),R(16)])}],Eo=[{type:`social.icons`,category:`social`,name:`Social Icons Row`,description:`Centered 'Follow us' label with text-link icons in a row. Light footer-style social block.`,tags:[`social`,`follow`,`icons`,`row`],create:()=>B(`social.icons`,`Social Icons`,[U(`Follow us`,{align:`center`}),F(`Twitter · Instagram · LinkedIn · YouTube`,{align:`center`,color:`{colors.primary}`,paddingBottom:16})])},{type:`social.share`,category:`social`,name:`Share This Email`,description:`'Share this email' bar with Forward · Tweet · Share text links. Used at the end of newsletters.`,tags:[`social`,`share`,`forward`,`viral`],create:()=>B(`social.share`,`Share Bar`,[F(`Share this email`,{align:`center`,paddingTop:8}),F(`Forward · Tweet · Share`,{align:`center`,color:`{colors.primary}`,paddingBottom:8})])},{type:`social.featured_post`,category:`social`,name:`Featured Social Post`,description:`Embed-style preview of a single social post: avatar, name, post text and a link to view it on the platform.`,tags:[`social`,`post`,`embed`,`twitter`,`instagram`],create:()=>B(`social.featured_post`,`Social Post`,[H(`From the community`),I(W(48,48,`👤`),`Avatar`,{width:48,borderRadius:24}),F(`@maker · 2h`,{color:`{colors.muted}`,fontSize:13,paddingTop:4,paddingBottom:4}),F(`"Just shipped my newsletter using OpenPostcards. Honestly the smoothest email build I've ever done."`,{paddingBottom:8,lineHeight:1.6}),F(`View on Twitter →`,{color:`{colors.primary}`,paddingBottom:16,link:`#`})])},{type:`social.instagram_grid`,category:`social`,name:`Instagram Grid`,description:`3 small square thumbnails in a row representing recent Instagram posts, with handle and link.`,tags:[`social`,`instagram`,`grid`,`thumbnails`],create:()=>B(`social.instagram_grid`,`IG Grid`,[U(`@youraccount on Instagram`,{align:`center`}),I(W(180,180,`1`),`Post 1`,{width:180}),I(W(180,180,`2`),`Post 2`,{width:180}),I(W(180,180,`3`),`Post 3`,{width:180}),F(`View profile →`,{align:`center`,color:`{colors.primary}`,paddingTop:8,paddingBottom:16,link:`#`})])},{type:`social.community_stats`,category:`social`,name:`Community Stats`,description:`Short '12k Twitter · 4k IG · 2k YT' style row used to show following sizes.`,tags:[`social`,`stats`,`community`,`following`],create:()=>B(`social.community_stats`,`Community Stats`,[H(`Join the community`,{align:`center`}),F(`12k Twitter · 4k Instagram · 2k YouTube`,{align:`center`,paddingBottom:16}),R(8)])}],Do={backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0},Oo=[{type:`footer.simple`,category:`footer`,name:`Simple Footer`,description:`Minimal footer with copyright, address and unsubscribe links. The default for any newsletter.`,tags:[`footer`,`simple`,`copyright`,`unsubscribe`],create:()=>B(`footer.simple`,`Simple Footer`,[U(`© 2026 Your Company. All rights reserved.`,{align:`center`,fontSize:12}),U(`123 Main St · City · Country`,{align:`center`,fontSize:12}),Ce([{label:`Unsubscribe`,type:`unsubscribe`},{label:`View in browser`,type:`view_in_browser`}])],{...Do,paddingTop:24})},{type:`footer.social`,category:`footer`,name:`Footer with Social`,description:`Footer with social links row above the legal text.`,tags:[`footer`,`social`,`links`],create:()=>B(`footer.social`,`Social Footer`,[F(`Follow us`,{align:`center`,paddingTop:24}),F(`Twitter · Instagram · LinkedIn`,{align:`center`,color:`{colors.primary}`,paddingBottom:12}),z(),U(`© 2026 Your Company`,{align:`center`,fontSize:12}),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Do)},{type:`footer.legal`,category:`footer`,name:`Legal Footer`,description:`Long-form footer with explanation of why the user is receiving the email plus privacy/terms/unsubscribe links. Used by enterprise and finance newsletters.`,tags:[`footer`,`legal`,`compliance`,`enterprise`],create:()=>B(`footer.legal`,`Legal Footer`,[F(`You are receiving this email because you signed up for our newsletter. If you no longer wish to receive emails, you can unsubscribe at any time.`,{align:`center`,color:`{colors.muted}`,fontSize:11,lineHeight:1.6,paddingTop:24}),Ce([{label:`Privacy Policy`,type:`user_profile`},{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Do)},{type:`footer.publisher`,category:`footer`,name:`Publisher Footer`,description:`Magazine-style sign-off with logo, publication name, masthead credits, address and links.`,tags:[`footer`,`publisher`,`magazine`,`masthead`,`editorial`],create:()=>B(`footer.publisher`,`Publisher Footer`,[I(W(120,36,`LOGO`),`Logo`,{width:120,paddingTop:24,paddingBottom:8}),F(`THE WEEKLY`,{align:`center`,fontFamily:`{fonts.heading}`,fontWeight:`bold`,letterSpacing:4,paddingTop:0,paddingBottom:4}),U(`Editor: Jane Doe · Producer: Alex Kim`,{align:`center`,fontSize:12}),z({paddingTop:12,paddingBottom:12}),U(`© 2026 The Weekly · 350 Madison Ave · NY 10017`,{align:`center`,fontSize:11}),Ce([{label:`Manage preferences`,type:`manage_preferences`},{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Do)},{type:`footer.app_links`,category:`footer`,name:`Footer with App Store Badges`,description:`Footer including 'Get the app' app-store and play-store badge images. For consumer brand newsletters.`,tags:[`footer`,`app`,`download`,`ios`,`android`],create:()=>B(`footer.app_links`,`App Footer`,[F(`Get the app`,{align:`center`,fontWeight:`bold`,paddingTop:24,paddingBottom:8}),I(W(135,40,`App Store`),`App Store`,{width:135,align:`center`,paddingTop:0,paddingBottom:4}),I(W(135,40,`Google Play`),`Google Play`,{width:135,align:`center`,paddingTop:0,paddingBottom:16}),z(),U(`© 2026 Your Brand`,{align:`center`,fontSize:11}),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Do)},{type:`footer.address_only`,category:`footer`,name:`Address Only`,description:`Just a centered postal address line — required for CAN-SPAM compliance when other footers are minimal.`,tags:[`footer`,`address`,`compliance`,`can-spam`],create:()=>B(`footer.address_only`,`Address`,[U(`Your Company · 123 Main St · Brooklyn, NY 11201 · USA`,{align:`center`,fontSize:11}),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:16})],{...Do,paddingTop:16})},{type:`footer.preferences`,category:`footer`,name:`Manage Preferences`,description:`Footer that emphasizes preference management ('Update your preferences', 'Send less often'). Reduces unsubscribes.`,tags:[`footer`,`preferences`,`frequency`,`retention`],create:()=>B(`footer.preferences`,`Preferences`,[F(`Getting too many emails?`,{align:`center`,paddingTop:24,paddingBottom:4}),Ce([{label:`Update your preferences`,type:`manage_preferences`},{label:`Unsubscribe`,type:`unsubscribe`}],{color:`{colors.primary}`,fontSize:13,paddingTop:4,paddingBottom:16}),z(),U(`© 2026 Your Company`,{align:`center`,fontSize:11}),F(` `,{align:`center`,paddingBottom:24})],Do)},{type:`footer.signature`,category:`footer`,name:`Signature Sign-off`,description:`Personal hand-signed style sign-off with author name and tiny legal block. For solo creator newsletters.`,tags:[`footer`,`signature`,`personal`,`creator`,`sign-off`],create:()=>B(`footer.signature`,`Signature`,[F(`Until next week,`,{paddingTop:24,paddingBottom:4}),F(`— Jane`,{fontFamily:`{fonts.heading}`,fontSize:22,paddingBottom:16}),z(),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{align:`left`,fontSize:11,paddingTop:4,paddingBottom:24,separator:` · `})],{...Do,paddingTop:0})}],ko=[...vo,...yo,...bo,...xo,...So,...Co,...wo,...To,...Eo,...Oo],Ao=!1;function jo(){if(!Ao){for(let e of ko)Ie.register(e);Ao=!0}}jo();function Mo(){let{doc:e,addModule:t,loadFromLocalStorage:n}=N();return(0,l.useEffect)(()=>{if(n(),N.getState().doc.modules.length===0){for(let e of[`header.hero`,`content.headline_body`,`cta.simple`,`footer.simple`]){let n=Ie.get(e);n&&t(n.create())}N.setState({selection:{kind:`email`},past:[],future:[]})}},[]),(0,l.useEffect)(()=>{let e=setTimeout(()=>N.getState().saveToLocalStorage(),500);return()=>clearTimeout(e)},[e]),(0,p.jsxs)(`div`,{className:`oml-email-builder h-full w-full flex flex-col bg-gray-100`,children:[(0,p.jsx)(je,{}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsx)(ot,{}),(0,p.jsx)(ki,{}),(0,p.jsx)(Ua,{})]})]})}var No=e=>{if(e&&typeof e==`object`)return e;throw Error(`AI server returned a non-object response.`)};function Po(e){let t=e.transformResponse??No,n=e.timeoutMs??6e4;return{async generate(r){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{let n=await fetch(e.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,body:JSON.stringify(r),signal:i.signal}),a=null,o=await n.text();try{a=o?JSON.parse(o):null}catch{}if(!n.ok){let e=(a&&typeof a==`object`&&`error`in a&&typeof a.error==`string`?a.error:null)??`AI request failed (HTTP ${n.status})`;throw Error(e)}return t(a)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`AI request timed out after ${n}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(a)}}}}function Fo(e){let t=Po(e);return{name:`ai-assistant`,type:`ai-provider`,setup(e){e.setAIProvider(t)}}}function Io(e){if(e==null)return null;if(Array.isArray(e))return Io(e[0]);if(typeof e!=`object`)return null;let t=e;for(let e of[`product`,`item`,`data`])if(t[e]&&typeof t[e]==`object`&&!Array.isArray(t[e]))return t[e];for(let e of[`results`,`products`,`items`,`hits`])if(Array.isArray(t[e]))return Io(t[e]);return t}function Lo(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t;if(typeof t==`number`)return String(t)}}function Ro(e,t){for(let n of t){let t=e[n];if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`&&t.trim()!==``&&!Number.isNaN(Number(t)))return Number(t)}}var zo=e=>{let t=Io(e);if(!t)return null;let n=Lo(t,[`name`,`title`,`product_name`,`productName`]),r=Lo(t,[`finalPrice`,`final_price`,`price`,`sale_price`,`salePrice`]);return!n||r==null?null:{name:n,finalPrice:r,oldPrice:Lo(t,[`oldPrice`,`old_price`,`compare_at_price`,`compareAtPrice`,`list_price`,`listPrice`]),description:Lo(t,[`description`,`desc`,`summary`]),link:Lo(t,[`link`,`url`,`product_url`,`productUrl`,`permalink`]),image:Lo(t,[`image`,`image_url`,`imageUrl`,`thumbnail`,`img`]),imageAlt:Lo(t,[`imageAlt`,`image_alt`,`alt`]),stars:Ro(t,[`stars`,`rating`,`review_score`,`reviewScore`,`score`]),sku:Lo(t,[`sku`,`id`,`product_id`,`productId`])}};function Bo(e){let t=e.method??`GET`,n=e.queryParam??`q`,r=e.bodyParam??`query`,i=e.timeoutMs??15e3,a=e.transformResponse??zo;return{async search(o){let s=o.trim();if(!s)return null;let c=new AbortController,l=setTimeout(()=>c.abort(),i);try{let i=e.endpoint,o={method:t,headers:{...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,signal:c.signal};if(t===`GET`){let t=typeof location<`u`?location.href:void 0,r=new URL(e.endpoint,t);r.searchParams.set(n,s),i=r.toString()}else o.headers[`Content-Type`]=`application/json`,o.body=JSON.stringify({[r]:s});let l=await fetch(i,o),u=null,d=await l.text();try{u=d?JSON.parse(d):null}catch{}if(!l.ok){let e=(u&&typeof u==`object`&&`error`in u&&typeof u.error==`string`?u.error:null)??`Product search failed (HTTP ${l.status})`;throw Error(e)}return a(u)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`Product search timed out after ${i}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(l)}}}}function Vo(e){let t=Bo(e);return{name:`product-search`,type:`product-provider`,setup(e){e.registerProductProvider(t)}}}function Ho(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let t=e;for(let e of[`vouchers`,`results`,`items`,`data`,`coupons`])if(Array.isArray(t[e]))return t[e]}return[]}function Uo(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t;if(typeof t==`number`)return String(t)}}var Wo=e=>{let t=[];for(let n of Ho(e)){if(!n||typeof n!=`object`)continue;let e=n,r=Uo(e,[`code`,`voucher_code`,`voucherCode`,`coupon`,`coupon_code`,`couponCode`,`value`]),i=Uo(e,[`id`,`voucher_id`,`voucherId`,`uid`])??r;if(!i&&!r)continue;let a=Uo(e,[`title`,`name`,`label`])??r??i??`Voucher`;t.push({id:i??a,title:a,code:r??i??a,description:Uo(e,[`description`,`desc`,`summary`])})}return t};function Go(e){let t=e.method??`GET`,n=e.timeoutMs??15e3,r=e.transformResponse??Wo;return{async list(){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{let n=await fetch(e.endpoint,{method:t,headers:{...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,signal:i.signal}),a=null,o=await n.text();try{a=o?JSON.parse(o):null}catch{}if(!n.ok){let e=(a&&typeof a==`object`&&`error`in a&&typeof a.error==`string`?a.error:null)??`Voucher request failed (HTTP ${n.status})`;throw Error(e)}return r(a)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`Voucher request timed out after ${n}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(a)}}}}function Ko(e){let t=Go(e);return{name:`voucher-select`,type:`voucher-provider`,setup(n){n.registerVoucherProvider(t),e.preload&&na()}}}var qo=e=>{if(e&&typeof e==`object`&&`url`in e&&typeof e.url==`string`){let t=e;return{url:t.url,alt:typeof t.alt==`string`?t.alt:void 0}}throw Error(`Server response missing "url" string field.`)};function Jo(e){let t=e.fieldName??`file`,n=(e.maxSizeMB??10)*1024*1024,r=e.transformResponse??qo;return{upload(i){return i.type.startsWith(`image/`)?i.size>n?Promise.reject(Error(`File too large: ${(i.size/1024/1024).toFixed(2)} MB > ${e.maxSizeMB??10} MB`)):new Promise((n,a)=>{let o=new XMLHttpRequest,s=new FormData;if(s.append(t,i,i.name),o.open(`POST`,e.endpoint,!0),o.withCredentials=!!e.withCredentials,e.headers)for(let[t,n]of Object.entries(e.headers))o.setRequestHeader(t,n);e.onProgress&&o.upload&&(o.upload.onprogress=t=>{t.lengthComputable&&e.onProgress(Math.round(t.loaded/t.total*100))}),o.onload=()=>{let e=o.status>=200&&o.status<300,t=null;try{t=o.responseText?JSON.parse(o.responseText):null}catch{}if(!e){let e=(t&&typeof t==`object`&&`error`in t&&typeof t.error==`string`?t.error:null)??`Upload failed (HTTP ${o.status})`;return a(Error(e))}try{n(r(t))}catch(e){a(e instanceof Error?e:Error(String(e)))}},o.onerror=()=>a(Error(`Network error during upload`)),o.onabort=()=>a(Error(`Upload aborted`)),o.send(s)}):Promise.reject(Error(`Not an image: ${i.type||`unknown`}`))}}}function Yo(e){return{name:`image-uploader`,type:`asset-provider`,setup(t){t.registerAssetProvider(Jo(e))}}}function Xo(e){return(0,l.useEffect)(()=>{if(jo(),e.modules)for(let t of e.modules)Ie.register(t);if(e.themes&&N.setState({themes:e.themes}),e.aiProvider)la.setAIProvider(e.aiProvider);else if(e.aiEndpoint){let t=typeof e.aiEndpoint==`string`?{endpoint:e.aiEndpoint}:e.aiEndpoint;la.setAIProvider(Po(t))}if(e.productProvider)la.registerProductProvider(e.productProvider);else if(e.productEndpoint){let t=typeof e.productEndpoint==`string`?{endpoint:e.productEndpoint}:e.productEndpoint;la.registerProductProvider(Bo(t))}if(e.voucherProvider)la.registerVoucherProvider(e.voucherProvider);else if(e.voucherEndpoint){let t=typeof e.voucherEndpoint==`string`?{endpoint:e.voucherEndpoint}:e.voucherEndpoint;la.registerVoucherProvider(Go(t)),typeof e.voucherEndpoint!=`string`&&e.voucherEndpoint.preload&&na()}if(e.mergeTags&&la.registerMergeTags(e.mergeTags),e.initialDocument){let t=b.safeParse(e.initialDocument);t.success&&N.getState().applyDoc(t.data,!1)}let t=N.subscribe((t,n)=>{t.doc!==n.doc&&e.onChange?.(t.doc)});return()=>t()},[]),(0,l.useEffect)(()=>{if(e.onExportHtml)return N.subscribe((t,n)=>{t.doc!==n.doc&&e.onExportHtml?.(A(t.doc))})},[e.onExportHtml]),(0,l.createElement)(Mo)}function Zo(e){let t=(0,c.createRoot)(e.container);return t.render((0,l.createElement)(Xo,e)),{destroy:()=>t.unmount(),getDocument:()=>N.getState().doc,exportHtml:()=>N.getState().exportHtml(),exportJson:()=>N.getState().exportJson()}}exports.ALGORITHMS=pa,exports.ALGORITHM_BY_ID=ma,exports.EmailBuilder=Xo,exports.FALLBACK_OPTIONS=ha,exports.TEMPLATE_CATEGORY_LABELS=ve,exports.aiAssistantPlugin=Fo,exports.applyAIActions=qe,exports.applyAIResponse=et,exports.buildCatalog=Ke,exports.createEmailBuilder=Zo,exports.createHttpAIProvider=Po,exports.createProductSearchProvider=Bo,exports.createVoucherProvider=Go,exports.defaultRecommendationsLogic=ga,exports.documentSchema=b,exports.getActiveProductProvider=Wi,exports.getActiveVoucherProvider=ea,exports.imageUploaderPlugin=Yo,exports.isVoucherAware=Ia,exports.mockAIProvider=Xe,exports.productSearchPlugin=Vo,exports.readRecommendationsLogic=_a,exports.recommendationsToLegacyShape=ba,exports.registerPlugin=ua,exports.renderEmailHtml=A,exports.setActiveProductProvider=Ui,exports.setActiveVoucherProvider=$i,exports.templateRegistry=P,exports.validateAIDocument=Ye,exports.voucherPlugin=Ko;
81
+ `},Ut={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function Wt(e){let{announcements:t=Ut,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Ht}=e,{announce:a,announcement:o}=Rt(),s=wt(`DndLiveRegion`),[c,u]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{u(!0)},[]),Bt((0,l.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let d=l.default.createElement(l.default.Fragment,null,l.default.createElement(It,{id:r,value:i.draggable}),l.default.createElement(Lt,{id:s,announcement:o}));return n?(0,m.createPortal)(d,n):d}var q;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(q||={});function Gt(){}function Kt(e,t){return(0,l.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function qt(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,l.useMemo)(()=>[...t].filter(e=>e!=null),[...t])}var Jt=Object.freeze({x:0,y:0});function Yt(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Xt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Zt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Qt(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function $t(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function en(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var tn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=en(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Yt(en(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(Xt)},nn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Qt(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Qt(r),o=i.reduce((e,t,r)=>e+Yt(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(Xt)};function rn(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var an=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=rn(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Zt)};function on(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function sn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Jt}function cn(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var ln=cn(1);function un(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function dn(e,t,n){let r=un(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var fn={ignoreTransform:!1};function pn(e,t){t===void 0&&(t=fn);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=K(e).getComputedStyle(e);t&&(n=dn(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function mn(e){return pn(e,{ignoreTransform:!0})}function hn(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function gn(e,t){return t===void 0&&(t=K(e).getComputedStyle(e)),t.position===`fixed`}function _n(e,t){t===void 0&&(t=K(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function vn(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(ft(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!pt(i)||mt(i)||n.includes(i))return n;let a=K(e).getComputedStyle(i);return i!==e&&_n(i,a)&&n.push(i),gn(i,a)?n:r(i.parentNode)}return e?r(e):n}function yn(e){let[t]=vn(e,1);return t??null}function bn(e){return!lt||!e?null:ut(e)?e:dt(e)?ft(e)||e===ht(e).scrollingElement?window:pt(e)?e:null:null}function xn(e){return ut(e)?e.scrollX:e.scrollLeft}function Sn(e){return ut(e)?e.scrollY:e.scrollTop}function Cn(e){return{x:xn(e),y:Sn(e)}}var J;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(J||={});function wn(e){return!lt||!e?!1:e===document.scrollingElement}function Tn(e){let t={x:0,y:0},n=wn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var En={x:.2,y:.2};function Dn(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=En);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Tn(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=J.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=J.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=J.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=J.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function On(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function kn(e){return e.reduce((e,t)=>Et(e,Cn(t)),Jt)}function An(e){return e.reduce((e,t)=>e+xn(t),0)}function jn(e){return e.reduce((e,t)=>e+Sn(t),0)}function Mn(e,t){if(t===void 0&&(t=pn),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);yn(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Nn=[[`x`,[`left`,`right`],An],[`y`,[`top`,`bottom`],jn]],Pn=class{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;let n=vn(t),r=kn(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Nn)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Fn=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},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 In(e){let{EventTarget:t}=K(e);return e instanceof t?e:ht(e)}function Ln(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Rn;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Rn||={});function zn(e){e.preventDefault()}function Bn(e){e.stopPropagation()}var Y;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(Y||={});var Vn={start:[Y.Space,Y.Enter],cancel:[Y.Esc],end:[Y.Space,Y.Enter,Y.Tab]},Hn=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Y.Right:return{...n,x:n.x+25};case Y.Left:return{...n,x:n.x-25};case Y.Down:return{...n,y:n.y+25};case Y.Up:return{...n,y:n.y-25}}},Un=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Fn(ht(t)),this.windowListeners=new Fn(K(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rn.Resize,this.handleCancel),this.windowListeners.add(Rn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rn.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Mn(n),t(Jt)}handleKeyDown(e){if(kt(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Vn,coordinateGetter:a=Hn,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:Jt;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Dt(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Tn(n),p=On(n),m={x:Math.min(i===Y.Right?p.right-p.width/2:p.right,Math.max(i===Y.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Y.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Y.Down?p.top:p.top+p.height/2,u.y))},h=i===Y.Right&&!s||i===Y.Left&&!c,g=i===Y.Down&&!l||i===Y.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Y.Right&&e<=d.x||i===Y.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Y.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===Y.Down&&e<=d.y||i===Y.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Y.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Et(Dt(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Un.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Vn,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Wn(e){return!!(e&&`distance`in e)}function Gn(e){return!!(e&&`delay`in e)}var Kn=class{constructor(e,t,n){n===void 0&&(n=In(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;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=ht(i),this.documentListeners=new Fn(this.document),this.listeners=new Fn(n),this.windowListeners=new Fn(K(i)),this.initialCoordinates=jt(r)??Jt,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(){let{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(Rn.Resize,this.handleCancel),this.windowListeners.add(Rn.DragStart,zn),this.windowListeners.add(Rn.VisibilityChange,this.handleCancel),this.windowListeners.add(Rn.ContextMenu,zn),this.documentListeners.add(Rn.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Gn(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Wn(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){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Rn.Click,Bn,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rn.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=jt(e)??Jt,s=Dt(n,o);if(!t&&a){if(Wn(a)){if(a.tolerance!=null&&Ln(s,a.tolerance))return this.handleCancel();if(Ln(s,a.distance))return this.handleStart()}if(Gn(a)&&Ln(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Y.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},qn={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Jn=class extends Kn{constructor(e){let{event:t}=e,n=ht(t.target);super(e,qn,n)}};Jn.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Yn={move:{name:`mousemove`},end:{name:`mouseup`}},Xn;(function(e){e[e.RightClick=2]=`RightClick`})(Xn||={});var Zn=class extends Kn{constructor(e){super(e,Yn,ht(e.event.target))}};Zn.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Xn.RightClick?!1:(r?.({event:n}),!0)}}];var Qn={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},$n=class extends Kn{constructor(e){super(e,Qn)}static setup(){return window.addEventListener(Qn.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Qn.move.name,e)};function e(){}}};$n.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var er;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(er||={});var tr;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(tr||={});function nr(e){let{acceleration:t,activator:n=er.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=tr.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:p}=e,m=ir({delta:f,disabled:!a}),[h,g]=vt(),_=(0,l.useRef)({x:0,y:0}),v=(0,l.useRef)({x:0,y:0}),y=(0,l.useMemo)(()=>{switch(n){case er.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case er.DraggableRect:return i}},[n,i,c]),b=(0,l.useRef)(null),x=(0,l.useCallback)(()=>{let e=b.current;if(!e)return;let t=_.current.x*v.current.x,n=_.current.y*v.current.y;e.scrollBy(t,n)},[]),S=(0,l.useMemo)(()=>s===tr.TreeOrder?[...u].reverse():u,[s,u]);(0,l.useEffect)(()=>{if(!a||!u.length||!y){g();return}for(let e of S){if(r?.(e)===!1)continue;let n=u.indexOf(e),i=d[n];if(!i)continue;let{direction:a,speed:s}=Dn(e,i,y,t,p);for(let e of[`x`,`y`])m[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){g(),b.current=e,h(x,o),_.current=s,v.current=a;return}}_.current={x:0,y:0},v.current={x:0,y:0},g()},[t,x,r,g,a,o,JSON.stringify(y),JSON.stringify(m),h,u,S,d,JSON.stringify(p)])}var rr={x:{[J.Backward]:!1,[J.Forward]:!1},y:{[J.Backward]:!1,[J.Forward]:!1}};function ir(e){let{delta:t,disabled:n}=e,r=St(t);return bt(e=>{if(n||!r||!e)return rr;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[J.Backward]:e.x[J.Backward]||i.x===-1,[J.Forward]:e.x[J.Forward]||i.x===1},y:{[J.Backward]:e.y[J.Backward]||i.y===-1,[J.Forward]:e.y[J.Forward]||i.y===1}}},[n,t,r])}function ar(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return bt(e=>t==null?null:r??e??null,[r,t])}function or(e,t){return(0,l.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var sr;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(sr||={});var cr;(function(e){e.Optimized=`optimized`})(cr||={});var lr=new Map;function ur(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,l.useState)(null),{frequency:s,measure:c,strategy:u}=i,d=(0,l.useRef)(e),f=_(),p=yt(f),m=(0,l.useCallback)(function(e){e===void 0&&(e=[]),!p.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[p]),h=(0,l.useRef)(null),g=bt(t=>{if(f&&!n)return lr;if(!t||t===lr||d.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Pn(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,f,c]);return(0,l.useEffect)(()=>{d.current=e},[e]),(0,l.useEffect)(()=>{f||m()},[n,f]),(0,l.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,l.useEffect)(()=>{f||typeof s!=`number`||h.current!==null||(h.current=setTimeout(()=>{m(),h.current=null},s))},[s,f,m,...r]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:a!=null};function _(){switch(u){case sr.Always:return!1;case sr.BeforeDragging:return n;default:return!n}}}function dr(e,t){return bt(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function fr(e,t){return dr(e,t)}function pr(e){let{callback:t,disabled:n}=e,r=_t(t),i=(0,l.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,l.useEffect)(()=>()=>i?.disconnect(),[i]),i}function mr(e){let{callback:t,disabled:n}=e,r=_t(t),i=(0,l.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,l.useEffect)(()=>()=>i?.disconnect(),[i]),i}function hr(e){return new Pn(pn(e),e)}function gr(e,t,n){t===void 0&&(t=hr);let[r,i]=(0,l.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=pr({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=mr({callback:a});return gt(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function _r(e){return sn(e,dr(e))}var vr=[];function yr(e){let t=(0,l.useRef)(e),n=bt(n=>e?n&&n!==vr&&e&&t.current&&e.parentNode===t.current.parentNode?n:vn(e):vr,[e]);return(0,l.useEffect)(()=>{t.current=e},[e]),n}function br(e){let[t,n]=(0,l.useState)(null),r=(0,l.useRef)(e),i=(0,l.useCallback)(e=>{let t=bn(e.target);t&&n(e=>e?(e.set(t,Cn(t)),new Map(e)):null)},[]);return(0,l.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=bn(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Cn(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{bn(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,l.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Et(e,t),Jt):kn(e):Jt,[e,t])}function xr(e,t){t===void 0&&(t=[]);let n=(0,l.useRef)(null);return(0,l.useEffect)(()=>{n.current=null},t),(0,l.useEffect)(()=>{let t=e!==Jt;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Dt(e,n.current):Jt}function Sr(e){(0,l.useEffect)(()=>{if(!lt)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Cr(e,t){return(0,l.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function wr(e){return(0,l.useMemo)(()=>e?hn(e):null,[e])}var Tr=[];function Er(e,t){t===void 0&&(t=pn);let[n]=e,r=wr(n?K(n):null),[i,a]=(0,l.useState)(Tr);function o(){a(()=>e.length?e.map(e=>wn(e)?r:new Pn(t(e),e)):Tr)}let s=mr({callback:o});return gt(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Dr(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return pt(t)?t:e}function Or(e){let{measure:t}=e,[n,r]=(0,l.useState)(null),i=mr({callback:(0,l.useCallback)(e=>{for(let{target:n}of e)if(pt(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=xt((0,l.useCallback)(e=>{let n=Dr(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,l.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var kr=[{sensor:Jn,options:{}},{sensor:Un,options:{}}],Ar={current:{}},jr={draggable:{measure:mn},droppable:{measure:mn,strategy:sr.WhileDragging,frequency:cr.Optimized},dragOverlay:{measure:pn}},Mr=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Nr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Mr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Gt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:jr,measureDroppableContainers:Gt,windowRect:null,measuringScheduled:!1},Pr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Gt,draggableNodes:new Map,over:null,measureDroppableContainers:Gt},Fr=(0,l.createContext)(Pr),Ir=(0,l.createContext)(Nr);function Lr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Mr}}}function Rr(e,t){switch(t.type){case q.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case q.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case q.DragEnd:case q.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case q.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Mr(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case q.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Mr(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case q.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Mr(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function zr(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,l.useContext)(Fr),a=St(r),o=St(n?.id);return(0,l.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!kt(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Pt(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Br(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Vr(e){return(0,l.useMemo)(()=>({draggable:{...jr.draggable,...e?.draggable},droppable:{...jr.droppable,...e?.droppable},dragOverlay:{...jr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Hr(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,l.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;gt(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=sn(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=yn(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Ur=(0,l.createContext)({...Jt,scaleX:1,scaleY:1}),Wr;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Wr||={});var Gr=(0,l.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=kr,collisionDetection:o=an,measuring:s,modifiers:c,...u}=e,[d,f]=(0,l.useReducer)(Rr,void 0,Lr),[p,h]=Vt(),[g,_]=(0,l.useState)(Wr.Uninitialized),v=g===Wr.Initialized,{draggable:{active:y,nodes:b,translate:x},droppable:{containers:S}}=d,C=y==null?null:b.get(y),w=(0,l.useRef)({initial:null,translated:null}),T=(0,l.useMemo)(()=>y==null?null:{id:y,data:C?.data??Ar,rect:w},[y,C]),ee=(0,l.useRef)(null),[te,E]=(0,l.useState)(null),[D,ne]=(0,l.useState)(null),re=yt(u,Object.values(u)),ie=wt(`DndDescribedBy`,t),ae=(0,l.useMemo)(()=>S.getEnabled(),[S]),oe=Vr(s),{droppableRects:se,measureDroppableContainers:ce,measuringScheduled:le}=ur(ae,{dragging:v,dependencies:[x.x,x.y],config:oe.droppable}),O=ar(b,y),ue=(0,l.useMemo)(()=>D?jt(D):null,[D]),k=Te(),de=fr(O,oe.draggable.measure);Hr({activeNode:y==null?null:b.get(y),config:k.layoutShiftCompensation,initialRect:de,measure:oe.draggable.measure});let A=gr(O,oe.draggable.measure,de),fe=gr(O?O.parentElement:null),j=(0,l.useRef)({activatorEvent:null,active:null,activeNode:O,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:b,draggingNode:null,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),M=S.getNodeFor(j.current.over?.id),pe=Or({measure:oe.dragOverlay.measure}),me=pe.nodeRef.current??O,he=v?pe.rect??A:null,ge=!!(pe.nodeRef.current&&pe.rect),_e=_r(ge?null:A),N=wr(me?K(me):null),P=yr(v?M??O:null),ve=Er(P),ye=Br(c,{transform:{x:x.x-_e.x,y:x.y-_e.y,scaleX:1,scaleY:1},activatorEvent:D,active:T,activeNodeRect:A,containerNodeRect:fe,draggingNodeRect:he,over:j.current.over,overlayNodeRect:pe.rect,scrollableAncestors:P,scrollableAncestorRects:ve,windowRect:N}),F=ue?Et(ue,x):null,I=br(P),L=xr(I),R=xr(I,[A]),z=Et(ye,L),B=he?ln(he,ye):null,V=T&&B?o({active:T,collisionRect:B,droppableRects:se,droppableContainers:ae,pointerCoordinates:F}):null,H=$t(V,`id`),[U,be]=(0,l.useState)(null),W=on(ge?ye:Et(ye,R),U?.rect??null,A),xe=(0,l.useRef)(null),G=(0,l.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(ee.current==null)return;let i=b.get(ee.current);if(!i)return;let a=e.nativeEvent,o=new n({active:ee.current,activeNode:i,event:a,options:r,context:j,onAbort(e){if(!b.get(e))return;let{onDragAbort:t}=re.current,n={id:e};t?.(n),p({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!b.get(e))return;let{onDragPending:i}=re.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),p({type:`onDragPending`,event:a})},onStart(e){let t=ee.current;if(t==null)return;let n=b.get(t);if(!n)return;let{onDragStart:r}=re.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:w}};(0,m.unstable_batchedUpdates)(()=>{r?.(i),_(Wr.Initializing),f({type:q.DragStart,initialCoordinates:e,active:t}),p({type:`onDragStart`,event:i}),E(xe.current),ne(a)})},onMove(e){f({type:q.DragMove,coordinates:e})},onEnd:s(q.DragEnd),onCancel:s(q.DragCancel)});xe.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=j.current,o=null;if(t&&i){let{cancelDrop:s}=re.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===q.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=q.DragCancel)}ee.current=null,(0,m.unstable_batchedUpdates)(()=>{f({type:e}),_(Wr.Uninitialized),be(null),E(null),ne(null),xe.current=null;let t=e===q.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=re.current[t];e?.(o),p({type:t,event:o})}})}}},[b]),Se=or(a,(0,l.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=b.get(r);if(ee.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},ee.current=r,G(n,t))},[b,G]));Sr(a),gt(()=>{A&&g===Wr.Initializing&&_(Wr.Initialized)},[A,g]),(0,l.useEffect)(()=>{let{onDragMove:e}=re.current,{active:t,activatorEvent:n,collisions:r,over:i}=j.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:z.x,y:z.y},over:i};(0,m.unstable_batchedUpdates)(()=>{e?.(a),p({type:`onDragMove`,event:a})})},[z.x,z.y]),(0,l.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=j.current;if(!e||ee.current==null||!t||!i)return;let{onDragOver:a}=re.current,o=r.get(H),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,m.unstable_batchedUpdates)(()=>{be(s),a?.(c),p({type:`onDragOver`,event:c})})},[H]),gt(()=>{j.current={activatorEvent:D,active:T,activeNode:O,collisionRect:B,collisions:V,droppableRects:se,draggableNodes:b,draggingNode:me,draggingNodeRect:he,droppableContainers:S,over:U,scrollableAncestors:P,scrollAdjustedTranslate:z},w.current={initial:he,translated:B}},[T,O,V,B,b,me,he,se,S,U,P,z]),nr({...k,delta:x,draggingRect:B,pointerCoordinates:F,scrollableAncestors:P,scrollableAncestorRects:ve});let Ce=(0,l.useMemo)(()=>({active:T,activeNode:O,activeNodeRect:A,activatorEvent:D,collisions:V,containerNodeRect:fe,dragOverlay:pe,draggableNodes:b,droppableContainers:S,droppableRects:se,over:U,measureDroppableContainers:ce,scrollableAncestors:P,scrollableAncestorRects:ve,measuringConfiguration:oe,measuringScheduled:le,windowRect:N}),[T,O,A,D,V,fe,pe,b,S,se,U,ce,P,ve,oe,le,N]),we=(0,l.useMemo)(()=>({activatorEvent:D,activators:Se,active:T,activeNodeRect:A,ariaDescribedById:{draggable:ie},dispatch:f,draggableNodes:b,over:U,measureDroppableContainers:ce}),[D,Se,T,A,f,ie,b,U,ce]);return l.default.createElement(zt.Provider,{value:h},l.default.createElement(Fr.Provider,{value:we},l.default.createElement(Ir.Provider,{value:Ce},l.default.createElement(Ur.Provider,{value:W},i)),l.default.createElement(zr,{disabled:n?.restoreFocus===!1})),l.default.createElement(Wt,{...n,hiddenTextDescribedById:ie}));function Te(){let e=te?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=v&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Kr=(0,l.createContext)(null),qr=`button`,Jr=`Draggable`;function Yr(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=wt(Jr),{activators:o,activatorEvent:s,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:p}=(0,l.useContext)(Fr),{role:m=qr,roleDescription:h=`draggable`,tabIndex:g=0}=i??{},_=c?.id===t,v=(0,l.useContext)(_?Ur:Kr),[y,b]=xt(),[x,S]=xt(),C=Cr(o,t),w=yt(n);return gt(()=>(f.set(t,{id:t,key:a,node:y,activatorNode:x,data:w}),()=>{let e=f.get(t);e&&e.key===a&&f.delete(t)}),[f,t]),{active:c,activatorEvent:s,activeNodeRect:u,attributes:(0,l.useMemo)(()=>({role:m,tabIndex:g,"aria-disabled":r,"aria-pressed":_&&m===qr?!0:void 0,"aria-roledescription":h,"aria-describedby":d.draggable}),[r,m,g,_,h,d.draggable]),isDragging:_,listeners:r?void 0:C,node:y,over:p,setNodeRef:b,setActivatorNodeRef:S,transform:v}}function Xr(){return(0,l.useContext)(Ir)}var Zr=`Droppable`,Qr={timeout:25};function $r(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=wt(Zr),{active:o,dispatch:s,over:c,measureDroppableContainers:u}=(0,l.useContext)(Fr),d=(0,l.useRef)({disabled:n}),f=(0,l.useRef)(!1),p=(0,l.useRef)(null),m=(0,l.useRef)(null),{disabled:h,updateMeasurementsFor:g,timeout:_}={...Qr,...i},v=yt(g??r),y=mr({callback:(0,l.useCallback)(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),m.current=null},_)},[_]),disabled:h||!o}),[b,x]=xt((0,l.useCallback)((e,t)=>{y&&(t&&(y.unobserve(t),f.current=!1),e&&y.observe(e))},[y])),S=yt(t);return(0,l.useEffect)(()=>{!y||!b.current||(y.disconnect(),f.current=!1,y.observe(b.current))},[b,y]),(0,l.useEffect)(()=>(s({type:q.RegisterDroppable,element:{id:r,key:a,disabled:n,node:b,rect:p,data:S}}),()=>s({type:q.UnregisterDroppable,key:a,id:r})),[r]),(0,l.useEffect)(()=>{n!==d.current.disabled&&(s({type:q.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,s]),{active:o,rect:p,isOver:c?.id===r,node:b,over:c,setNodeRef:x}}function ei(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function ti(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function ni(e){return e!==null&&e>=0}function ri(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ii(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var ai=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=ei(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},oi={scaleX:1,scaleY:1},si=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...oi}:null}let s=ci(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...oi}:r<t&&r>=a?{x:0,y:o.height+s,...oi}:{x:0,y:0,...oi}};function ci(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var li=`Sortable`,ui=l.default.createContext({activeIndex:-1,containerId:li,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:ai,disabled:{draggable:!1,droppable:!1}});function di(e){let{children:t,id:n,items:r,strategy:i=ai,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:u,measureDroppableContainers:d}=Xr(),f=wt(li,n),p=s.rect!==null,m=(0,l.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),h=o!=null,g=o?m.indexOf(o.id):-1,_=u?m.indexOf(u.id):-1,v=(0,l.useRef)(m),y=!ri(m,v.current),b=_!==-1&&g===-1||y,x=ii(a);gt(()=>{y&&h&&d(m)},[y,m,h,d]),(0,l.useEffect)(()=>{v.current=m},[m]);let S=(0,l.useMemo)(()=>({activeIndex:g,containerId:f,disabled:x,disableTransforms:b,items:m,overIndex:_,useDragOverlay:p,sortedRects:ti(m,c),strategy:i}),[g,f,x.draggable,x.droppable,b,m,_,c,p,i]);return l.default.createElement(ui.Provider,{value:S},t)}var fi=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return ei(n,r,i).indexOf(t)},pi=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},mi={duration:200,easing:`ease`},hi=`transform`,gi=Mt.Transition.toString({property:hi,duration:0,easing:`linear`}),_i={roleDescription:`sortable`};function vi(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,l.useState)(null),s=(0,l.useRef)(n);return gt(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=pn(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,l.useEffect)(()=>{a&&o(null)},[a]),a}function yi(e){let{animateLayoutChanges:t=pi,attributes:n,disabled:r,data:i,getNewIndex:a=fi,id:o,strategy:s,resizeObserverConfig:c,transition:u=mi}=e,{items:d,containerId:f,activeIndex:p,disabled:m,disableTransforms:h,sortedRects:g,overIndex:_,useDragOverlay:v,strategy:y}=(0,l.useContext)(ui),b=bi(r,m),x=d.indexOf(o),S=(0,l.useMemo)(()=>({sortable:{containerId:f,index:x,items:d},...i}),[f,i,x,d]),C=(0,l.useMemo)(()=>d.slice(d.indexOf(o)),[d,o]),{rect:w,node:T,isOver:ee,setNodeRef:te}=$r({id:o,data:S,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:E,activatorEvent:D,activeNodeRect:ne,attributes:re,setNodeRef:ie,listeners:ae,isDragging:oe,over:se,setActivatorNodeRef:ce,transform:le}=Yr({id:o,data:S,attributes:{..._i,...n},disabled:b.draggable}),O=ct(te,ie),ue=!!E,k=ue&&!h&&ni(p)&&ni(_),de=!v&&oe,A=k?(de&&k?le:null)??(s??y)({rects:g,activeNodeRect:ne,activeIndex:p,overIndex:_,index:x}):null,fe=ni(p)&&ni(_)?a({id:o,items:d,activeIndex:p,overIndex:_}):x,j=E?.id,M=(0,l.useRef)({activeId:j,items:d,newIndex:fe,containerId:f}),pe=d!==M.current.items,me=t({active:E,containerId:f,isDragging:oe,isSorting:ue,id:o,index:x,items:d,newIndex:M.current.newIndex,previousItems:M.current.items,previousContainerId:M.current.containerId,transition:u,wasDragging:M.current.activeId!=null}),he=vi({disabled:!me,index:x,node:T,rect:w});return(0,l.useEffect)(()=>{ue&&M.current.newIndex!==fe&&(M.current.newIndex=fe),f!==M.current.containerId&&(M.current.containerId=f),d!==M.current.items&&(M.current.items=d)},[ue,fe,f,d]),(0,l.useEffect)(()=>{if(j===M.current.activeId)return;if(j!=null&&M.current.activeId==null){M.current.activeId=j;return}let e=setTimeout(()=>{M.current.activeId=j},50);return()=>clearTimeout(e)},[j]),{active:E,activeIndex:p,attributes:re,data:S,rect:w,index:x,newIndex:fe,items:d,isOver:ee,isSorting:ue,isDragging:oe,listeners:ae,node:T,overIndex:_,over:se,setNodeRef:O,setActivatorNodeRef:ce,setDroppableNodeRef:te,setDraggableNodeRef:ie,transform:he??A,transition:ge()};function ge(){if(he||pe&&M.current.newIndex===x)return gi;if(!(de&&!kt(D)||!u)&&(ue||me))return Mt.Transition.toString({...u,property:hi})}}function bi(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function xi(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var Si=[Y.Down,Y.Right,Y.Up,Y.Left],Ci=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(Si.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case Y.Down:r.top<a.top&&t.push(n);break;case Y.Up:r.top>a.top&&t.push(n);break;case Y.Left:r.left>a.left&&t.push(n);break;case Y.Right:r.left<a.left&&t.push(n);break}});let c=nn({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=$t(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=vn(c).some((e,t)=>s[t]!==e),i=wi(e,t),a=Ti(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:Dt(u,l)}}}};function wi(e,t){return!xi(e)||!xi(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Ti(e,t){return!xi(e)||!xi(t)||!wi(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var Ei=(0,d.create)(e=>({activeEl:null,setActiveEl:t=>e({activeEl:t})})),Di=(0,d.create)(e=>({mergeTags:[],setMergeTags:t=>e({mergeTags:t})}));function Oi(e){Di.getState().setMergeTags(e)}var ki=[{label:`Default`,value:``},{label:`Arial`,value:`Arial, Helvetica, sans-serif`},{label:`Georgia`,value:`Georgia, 'Times New Roman', serif`},{label:`Tahoma`,value:`Tahoma, Geneva, sans-serif`},{label:`Trebuchet MS`,value:`'Trebuchet MS', Helvetica, sans-serif`},{label:`Verdana`,value:`Verdana, Geneva, sans-serif`},{label:`Courier New`,value:`'Courier New', Courier, monospace`},{label:`Times New Roman`,value:`'Times New Roman', Times, serif`}],Ai=[`10`,`11`,`12`,`13`,`14`,`15`,`16`,`18`,`20`,`22`,`24`,`28`,`32`,`36`,`48`],ji=[`#111827`,`#374151`,`#6B7280`,`#9CA3AF`,`#D1D5DB`,`#F3F4F6`,`#FFFFFF`,`#DC2626`,`#F97316`,`#EAB308`,`#22C55E`,`#3B82F6`,`#8B5CF6`,`#EC4899`,`#B91C1C`,`#C2410C`,`#A16207`,`#15803D`,`#1D4ED8`,`#6D28D9`,`#BE185D`],Mi=`😀.😊.😍.🥰.😎.🤩.👋.🙌.👍.💪.❤️.💙.💚.💛.🧡.💜.🎉.🔥.✨.⭐.🏆.🥇.🎁.🎯.🚀.💡.📧.💌.📱.💻.✅.❌.⚠️.🔔.📊.📈.💰.💳.🛒.🏷️.📍.🗓️.⚡.🌟`.split(`.`),Ni={unsubscribe:`Unsubscribe`,view_in_browser:`View in browser`,manage_preferences:`Manage preferences`,user_profile:`User profile`};function Pi(){let e=window.getSelection();if(!e||e.isCollapsed||e.rangeCount===0)return``;let t=e.getRangeAt(0).cloneContents(),n=document.createElement(`div`);return n.appendChild(t),n.innerHTML}function Fi(e,t){document.execCommand(e,!1,t)}function Ii(e){document.execCommand(`insertHTML`,!1,e)}function Li(e,t){let n=Pi();n&&Ii(`<span style="${e}:${t}">${n}</span>`)}function Ri(){let e=window.getSelection();return!e||e.rangeCount===0?null:e.getRangeAt(0).cloneRange()}function zi(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e))}function Bi({title:e,active:t,disabled:n,onMouseDown:r,children:i}){return(0,p.jsx)(`button`,{title:e,disabled:n,onMouseDown:r,className:`flex items-center justify-center w-7 h-7 rounded text-xs transition-colors ${t?`bg-blue-600 text-white`:`text-gray-700 hover:bg-gray-100 disabled:opacity-30`}`,children:i})}function Vi(){return(0,p.jsx)(`div`,{className:`w-px h-5 bg-gray-200 mx-0.5 shrink-0`})}function Hi({savedRange:e,onClose:t}){let[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),o=(0,l.useRef)(null);(0,l.useEffect)(()=>{setTimeout(()=>o.current?.focus(),30)},[]);let s=()=>{if(!n&&!i){t();return}let r=i?ye[i]:n;if(!r){t();return}let a=e?(()=>{let t=document.createElement(`div`),n=e.cloneContents();return t.appendChild(n),t.innerHTML||t.textContent||r})():r;if(e){zi(e);let t=window.getSelection();t&&t.isCollapsed}Ii(`<a href="${r}"${i?` data-link-type="${i}"`:``} style="color:inherit;text-decoration:underline">${a}</a>`),t()};return(0,p.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-3 w-80`,onMouseDown:e=>e.stopPropagation(),children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsx)(`span`,{className:`text-xs font-semibold text-gray-700`,children:`Insert link`}),(0,p.jsx)(`button`,{onClick:t,className:`text-gray-400 hover:text-gray-600 p-0.5 rounded`,children:(0,p.jsx)(f.X,{size:13})})]}),(0,p.jsx)(`input`,{ref:o,type:`url`,placeholder:`https://example.com`,value:n,onChange:e=>{r(e.target.value),e.target.value&&a(``)},className:`w-full px-2 py-1.5 text-xs border border-gray-200 rounded mb-2 focus:border-blue-500 focus:outline-none`,onKeyDown:e=>{e.key===`Enter`&&s(),e.key===`Escape`&&t()}}),(0,p.jsxs)(`div`,{className:`mb-2`,children:[(0,p.jsx)(`div`,{className:`text-[10px] text-gray-500 mb-1`,children:`Or use a special link`}),(0,p.jsxs)(`select`,{value:i,onChange:e=>{a(e.target.value),e.target.value&&r(``)},className:`w-full px-2 py-1.5 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`,children:[(0,p.jsx)(`option`,{value:``,children:`— none —`}),Object.keys(Ni).map(e=>(0,p.jsx)(`option`,{value:e,children:Ni[e]},e))]})]}),i&&(0,p.jsxs)(`p`,{className:`text-[10px] text-blue-600 mb-2`,children:[`Placeholder: `,(0,p.jsx)(`code`,{children:ye[i]})]}),(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsx)(`button`,{onClick:s,className:`flex-1 px-3 py-1.5 bg-blue-600 text-white text-xs rounded hover:bg-blue-700`,children:`Apply`}),(0,p.jsx)(`button`,{onClick:t,className:`px-3 py-1.5 text-xs border border-gray-200 rounded hover:bg-gray-50`,children:`Cancel`})]})]})}function Ui({onClose:e}){let[t,n]=(0,l.useState)(``),r=t=>{document.execCommand(`styleWithCSS`,!1,`true`),document.execCommand(`foreColor`,!1,t),e()};return(0,p.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-3`,style:{width:196},onMouseDown:e=>e.stopPropagation(),children:[(0,p.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-2`,children:ji.map(e=>(0,p.jsx)(`button`,{title:e,onClick:()=>r(e),className:`w-6 h-6 rounded border border-gray-200 hover:scale-110 transition-transform shrink-0`,style:{background:e}},e))}),(0,p.jsxs)(`div`,{className:`flex gap-1`,children:[(0,p.jsx)(`input`,{type:`text`,placeholder:`#hex or color`,value:t,onChange:e=>n(e.target.value),onKeyDown:n=>{n.key===`Enter`&&t&&r(t),n.key===`Escape`&&e()},className:`flex-1 px-2 py-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`}),(0,p.jsx)(`button`,{onClick:()=>t&&r(t),className:`px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700`,children:`✓`})]})]})}function Wi({onClose:e}){let t=t=>{Ii(t),e()};return(0,p.jsx)(`div`,{className:`absolute top-full right-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-2`,style:{width:260},onMouseDown:e=>e.stopPropagation(),children:(0,p.jsx)(`div`,{className:`flex flex-wrap gap-0.5`,children:Mi.map(e=>(0,p.jsx)(`button`,{onClick:()=>t(e),className:`w-8 h-8 text-lg hover:bg-gray-100 rounded flex items-center justify-center`,children:e},e))})})}function Gi({onClose:e}){let t=Di(e=>e.mergeTags),n=t=>{Ii(`{${t}}`),e()};return t.length===0?null:(0,p.jsx)(`div`,{className:`absolute top-full right-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl py-1`,style:{minWidth:200},onMouseDown:e=>e.stopPropagation(),children:t.map(e=>(0,p.jsxs)(`button`,{onClick:()=>n(e.attribute),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-blue-50 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`span`,{children:e.title}),(0,p.jsx)(`code`,{className:`text-[10px] text-gray-400`,children:`{${e.attribute}}`})]},e.attribute))})}function Ki(){let e=Ei(e=>e.activeEl),t=Di(e=>e.mergeTags),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)({top:0,left:0}),[o,s]=(0,l.useState)({bold:!1,italic:!1,underline:!1}),[c,u]=(0,l.useState)(null),[d,m]=(0,l.useState)(null),h=(0,l.useRef)(null),g=(0,l.useRef)(null),_=(0,l.useCallback)(()=>u(null),[]),v=(0,l.useCallback)(()=>{let t=window.getSelection();if(!t)return;let n=null;if(!t.isCollapsed&&t.rangeCount>0?n=t.getRangeAt(0).getBoundingClientRect():e&&(n=e.getBoundingClientRect()),!n||n.width===0&&n.height===0)return;let r=h.current?.offsetWidth??480,i=n.top-40-6+window.scrollY,o=n.left+n.width/2-r/2+window.scrollX;i<8&&(i=n.bottom+6+window.scrollY),o<8&&(o=8),o+r>window.innerWidth-8&&(o=window.innerWidth-r-8),a({top:i,left:o})},[e]),y=(0,l.useCallback)(()=>{s({bold:document.queryCommandState(`bold`),italic:document.queryCommandState(`italic`),underline:document.queryCommandState(`underline`)})},[]);if((0,l.useEffect)(()=>{if(!e){g.current&&clearTimeout(g.current),g.current=setTimeout(()=>r(!1),150);return}g.current&&clearTimeout(g.current),r(!0),v(),y()},[e,v,y]),(0,l.useEffect)(()=>{let t=()=>{e&&(v(),y())};return document.addEventListener(`selectionchange`,t),()=>document.removeEventListener(`selectionchange`,t)},[e,v,y]),(0,l.useEffect)(()=>{let e=e=>{h.current&&!h.current.contains(e.target)&&_()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[_]),!n||!e)return null;let b=e=>t=>{t.preventDefault(),e()},x=e=>{u(t=>t===e?null:e),e===`link`&&m(Ri())},S=()=>{let e=window.getSelection();return e&&!e.isCollapsed};return(0,p.jsxs)(`div`,{ref:h,"data-rich-toolbar":`true`,className:`fixed z-[9999] flex items-center gap-0.5 bg-white border border-gray-200 rounded-lg shadow-lg px-1.5 py-1 select-none`,style:{top:i.top,left:i.left},onMouseDown:e=>e.preventDefault(),children:[(0,p.jsx)(Bi,{title:`Bold (Ctrl+B)`,active:o.bold,onMouseDown:b(()=>Fi(`bold`)),children:(0,p.jsx)(f.Bold,{size:13})}),(0,p.jsx)(Bi,{title:`Italic (Ctrl+I)`,active:o.italic,onMouseDown:b(()=>Fi(`italic`)),children:(0,p.jsx)(f.Italic,{size:13})}),(0,p.jsx)(Bi,{title:`Underline (Ctrl+U)`,active:o.underline,onMouseDown:b(()=>Fi(`underline`)),children:(0,p.jsx)(f.Underline,{size:13})}),(0,p.jsx)(Vi,{}),(0,p.jsx)(`select`,{title:`Font family`,className:`h-7 px-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white max-w-[110px]`,defaultValue:``,onMouseDown:e=>e.stopPropagation(),onChange:t=>{let n=t.target.value;if(n){if(!S()){e?.focus();return}Li(`font-family`,n),e?.focus()}},children:ki.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.label))}),(0,p.jsxs)(`select`,{title:`Font size`,className:`h-7 px-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white w-14`,defaultValue:``,onMouseDown:e=>e.stopPropagation(),onChange:t=>{let n=t.target.value;if(n){if(!S()){e?.focus();return}Li(`font-size`,`${n}px`),e?.focus()}},children:[(0,p.jsx)(`option`,{value:``,children:`Size`}),Ai.map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))]}),(0,p.jsx)(Vi,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(Bi,{title:`Text color`,onMouseDown:b(()=>x(`color`)),children:(0,p.jsxs)(`span`,{className:`flex flex-col items-center gap-0.5`,children:[(0,p.jsx)(`span`,{className:`text-xs font-bold leading-none`,style:{fontFamily:`serif`},children:`A`}),(0,p.jsx)(`span`,{className:`w-4 h-1 rounded-sm bg-current`})]})}),c===`color`&&(0,p.jsx)(Ui,{onClose:_})]}),(0,p.jsx)(Vi,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(Bi,{title:`Insert link`,onMouseDown:b(()=>x(`link`)),children:(0,p.jsx)(f.Link2,{size:13})}),c===`link`&&(0,p.jsx)(Hi,{savedRange:d,onClose:_})]}),(0,p.jsx)(Vi,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(Bi,{title:`Insert emoji`,onMouseDown:b(()=>x(`emoji`)),children:(0,p.jsx)(f.Smile,{size:13})}),c===`emoji`&&(0,p.jsx)(Wi,{onClose:_})]}),t.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Vi,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(Bi,{title:`Insert merge tag`,onMouseDown:b(()=>x(`mergeTag`)),children:(0,p.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] font-mono`,children:[(0,p.jsx)(f.Tag,{size:11}),(0,p.jsx)(f.ChevronDown,{size:10})]})}),c===`mergeTag`&&(0,p.jsx)(Gi,{onClose:_})]})]})]})}var qi=375;function Ji(e){let t=e.replace(`#`,``);if(t.length!==3&&t.length!==6)return e===`white`||e===`#fff`||e===`#ffffff`;let n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255;return .2126*r+.7152*i+.0722*a>.82}function Yi(e,t){let n=e??{};if(t!==`mobile`)return n;let r=n.mobile??{};return{...n,...r}}function Xi(){let{doc:e,selection:t,setSelection:n,reorderModules:r,deleteModule:i,duplicateModule:a,deleteElement:o,moveElement:s,viewMode:c}=N(),u=qt(Kt(Jn,{activationConstraint:{distance:5}}),Kt(Un,{coordinateGetter:Ci})),d=t=>{let{active:n,over:i}=t;if(!i||n.id===i.id)return;let a=e.modules.findIndex(e=>e.id===n.id),o=e.modules.findIndex(e=>e.id===i.id);a===-1||o===-1||r(a,o)};(0,l.useEffect)(()=>{let e=e=>{if(e.key!==`Delete`&&e.key!==`Backspace`)return;let n=e.target;n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable||(t?.kind===`module`?i(t.moduleId):t?.kind===`element`&&o(t.moduleId,t.elementId))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i,o]);let f=x(e.settings.backgroundColor,e.theme),m=x(e.settings.contentBackgroundColor,e.theme),h=e.modules.map(e=>e.id),g=c===`mobile`?qi:e.settings.width;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ki,{}),(0,p.jsx)(`div`,{className:`flex-1 overflow-y-auto`,style:{background:f},onClick:()=>n({kind:`email`}),children:(0,p.jsx)(`div`,{className:`py-8 flex justify-center`,children:(0,p.jsxs)(`div`,{className:`shadow-lg transition-all duration-200 ${c===`mobile`?`rounded-[28px] border-[10px] border-gray-800`:``}`,style:{width:g,background:m,minHeight:300},onClick:e=>e.stopPropagation(),children:[e.modules.length===0&&(0,p.jsx)(`div`,{className:`p-12 text-center text-gray-400 text-sm`,children:`Add modules from the left sidebar to start building your email.`}),(0,p.jsx)(Gr,{sensors:u,collisionDetection:tn,onDragEnd:d,children:(0,p.jsx)(di,{items:h,strategy:si,children:e.modules.map((r,o)=>(0,p.jsx)(Zi,{mod:r,index:o,viewMode:c,selected:t?.kind===`module`&&t.moduleId===r.id,selectionEl:t?.kind===`element`&&t.moduleId===r.id?t.elementId:null,theme:e.theme,onSelectModule:()=>n({kind:`module`,moduleId:r.id}),onSelectElement:e=>n({kind:`element`,moduleId:r.id,elementId:e}),onDuplicate:()=>a(r.id),onDelete:()=>i(r.id)},r.id))})})]})})})]})}function Zi(e){let{attributes:t,listeners:n,setNodeRef:r,transform:i,transition:a,isDragging:o}=yi({id:e.mod.id});return(0,p.jsx)(`div`,{ref:r,style:{transform:Mt.Transform.toString(i),transition:a,opacity:o?.5:1,position:`relative`,zIndex:e.selected?10:`auto`},children:(0,p.jsx)(Qi,{mod:e.mod,viewMode:e.viewMode,selected:e.selected,selectionEl:e.selectionEl,theme:e.theme,onSelectModule:e.onSelectModule,onSelectElement:e.onSelectElement,onDuplicate:e.onDuplicate,onDelete:e.onDelete,dragHandle:(0,p.jsx)(`button`,{...t,...n,className:`bg-blue-600 text-white p-1 rounded cursor-grab active:cursor-grabbing`,title:`Drag to reorder`,onClick:e=>e.stopPropagation(),children:(0,p.jsx)(f.GripVertical,{size:14})})})})}function Qi({mod:e,viewMode:t,selected:n,selectionEl:r,theme:i,onSelectModule:a,onSelectElement:o,onDuplicate:s,onDelete:c,dragHandle:u}){let d=e.style??{};if(d.hideOn===t)return null;let m=S(Yi(d,t),i),[h,g]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{style:{backgroundColor:m.backgroundColor,paddingTop:m.paddingTop??0,paddingBottom:m.paddingBottom??0,paddingLeft:m.paddingLeft??0,paddingRight:m.paddingRight??0,borderRadius:m.borderRadius,position:`relative`,outline:n?`2px solid #2563eb`:h?`1px dashed #93c5fd`:`1px dashed transparent`,outlineOffset:-2,cursor:`pointer`},onClick:e=>{e.stopPropagation(),a()},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[!n&&h&&(0,p.jsxs)(`div`,{className:`absolute top-0 right-0 z-10 bg-blue-600 text-white text-[10px] px-1.5 py-0.5 rounded-bl pointer-events-none`,children:[`Click to select: `,e.name]}),n&&(0,p.jsxs)(`div`,{className:`absolute top-0 left-0 z-20 flex items-center gap-1 p-1 rounded-br bg-blue-600 shadow-md`,onClick:e=>e.stopPropagation(),children:[u,(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s()},className:`text-white p-1 rounded hover:bg-blue-700`,title:`Duplicate`,children:(0,p.jsx)(f.Copy,{size:14})}),(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c()},className:`text-white p-1 rounded hover:bg-red-600`,title:`Delete`,children:(0,p.jsx)(f.Trash2,{size:14})}),(0,p.jsx)(`span`,{className:`text-white text-[10px] font-medium px-1.5 py-0.5`,children:e.name})]}),e.children.map((s,c)=>(0,p.jsx)($i,{el:s,index:c,totalElements:e.children.length,viewMode:t,theme:i,moduleId:e.id,moduleSelected:n,selected:r===s.id,onSelect:()=>o(s.id),onSelectModule:a},s.id))]})}function $i({el:e,index:t,totalElements:n,viewMode:r,theme:i,moduleId:a,moduleSelected:o,selected:s,onSelect:c,onSelectModule:l}){let u=N(e=>e.moveElement),d=N(e=>e.deleteElement);if(e.style?.hideOn===r)return null;let m={outline:s?`2px solid #f59e0b`:`1px dashed rgba(0,0,0,0.08)`,outlineOffset:-1,position:`relative`},h=e=>{if(e.stopPropagation(),!o&&!s){l();return}c()},g=s&&(0,p.jsxs)(`div`,{className:`absolute top-0 right-0 z-20 flex items-center gap-1 p-1 rounded-bl bg-amber-500 shadow-md`,onClick:e=>e.stopPropagation(),children:[(0,p.jsx)(`button`,{onClick:()=>l(),className:`text-white p-1 rounded hover:bg-amber-600`,title:`Select parent block`,children:(0,p.jsx)(f.MousePointer2,{size:12})}),(0,p.jsx)(`button`,{disabled:t===0,onClick:()=>u(a,e.id,-1),className:`text-white p-1 rounded disabled:opacity-40 hover:bg-amber-600`,title:`Move up`,children:(0,p.jsx)(f.ArrowUp,{size:12})}),(0,p.jsx)(`button`,{disabled:t===n-1,onClick:()=>u(a,e.id,1),className:`text-white p-1 rounded disabled:opacity-40 hover:bg-amber-600`,title:`Move down`,children:(0,p.jsx)(f.ArrowDown,{size:12})}),(0,p.jsx)(`button`,{onClick:()=>d(a,e.id),className:`text-white p-1 rounded hover:bg-red-600`,title:`Delete element`,children:(0,p.jsx)(f.Trash2,{size:12})}),(0,p.jsx)(`span`,{className:`text-white text-[10px] font-medium px-1 py-0.5`,children:e.type})]}),_=e=>(0,p.jsxs)(`div`,{style:m,onClick:h,children:[g,e]});switch(e.type){case`text`:return _((0,p.jsx)(ea,{el:e,viewMode:r,theme:i,moduleId:a}));case`image`:return _((0,p.jsx)(ta,{el:e,viewMode:r,theme:i}));case`button`:return _((0,p.jsx)(na,{el:e,viewMode:r,theme:i}));case`spacer`:return _((0,p.jsx)(ra,{el:e}));case`divider`:return _((0,p.jsx)(ia,{el:e,viewMode:r,theme:i}));case`productGrid`:return _((0,p.jsx)(aa,{el:e,viewMode:r,theme:i}))}}function ea({el:e,viewMode:t,theme:n,moduleId:r}){let i=N(e=>e.updateElement),a=Ei(e=>e.setActiveEl),o=(0,l.useRef)(!1),s=S(Yi(e.style,t),n),c=s.color??`#000000`,u=Ji(c);return(0,p.jsx)(`div`,{"data-email-text":`true`,style:{fontFamily:s.fontFamily,fontSize:s.fontSize,lineHeight:s.lineHeight,letterSpacing:s.letterSpacing,fontWeight:s.fontWeight,color:c,textAlign:s.align,paddingTop:s.paddingTop??8,paddingBottom:s.paddingBottom??8,paddingLeft:s.paddingLeft??16,paddingRight:s.paddingRight??16,margin:0,minHeight:`1.5em`,outline:`none`,...u?{textShadow:`0 0 8px rgba(0,0,0,0.55), 0 1px 2px rgba(0,0,0,0.45)`}:void 0},contentEditable:!0,suppressContentEditableWarning:!0,onFocus:e=>{o.current=!0,a(e.currentTarget)},onBlur:t=>{o.current=!1,t.relatedTarget?.closest(`[data-rich-toolbar]`)||a(null);let n=t.currentTarget.innerHTML;n!==e.content&&i(r,e.id,{content:n})},onClick:e=>{o.current&&e.stopPropagation()},dangerouslySetInnerHTML:{__html:e.content}})}function ta({el:e,viewMode:t,theme:n}){let r=S(Yi(e.style,t),n),i={textAlign:r.align??`center`,paddingTop:r.paddingTop??0,paddingBottom:r.paddingBottom??0,paddingLeft:r.paddingLeft??0,paddingRight:r.paddingRight??0},a={display:`inline-block`,maxWidth:`100%`,width:r.width,height:r.height||`auto`,borderRadius:r.borderRadius};return(0,p.jsx)(`div`,{style:i,children:(0,p.jsx)(`img`,{src:e.src,alt:e.alt??``,style:a})})}function na({el:e,viewMode:t,theme:n}){let r=S(Yi(e.style,t),n);return(0,p.jsx)(`div`,{style:{textAlign:r.align??`center`,paddingTop:r.paddingTop??12,paddingBottom:r.paddingBottom??12,paddingLeft:r.paddingLeft??16,paddingRight:r.paddingRight??16},children:(0,p.jsx)(`span`,{style:{display:`inline-block`,backgroundColor:r.backgroundColor??`#3A7D52`,color:r.color??`#fff`,fontFamily:r.fontFamily,fontSize:r.fontSize??16,fontWeight:r.fontWeight??`bold`,borderRadius:r.borderRadius??6,padding:`12px 24px`,textDecoration:`none`},children:e.label})})}function ra({el:e}){return(0,p.jsx)(`div`,{style:{height:e.height,background:`rgba(0,0,0,0.02)`}})}function ia({el:e,viewMode:t,theme:n}){let r=S(Yi(e.style,t),n);return(0,p.jsx)(`div`,{style:{paddingTop:r.paddingTop??8,paddingBottom:r.paddingBottom??8},children:(0,p.jsx)(`hr`,{style:{border:0,borderTop:`${r.thickness??1}px solid ${r.color??`#E5E7EB`}`,margin:0}})})}function aa({el:e,viewMode:t,theme:n}){let r=S(Yi(e.style,t),n),i=t===`mobile`,a=e.columns,o=r.cardBackgroundColor??r.backgroundColor??`transparent`,s=r.nameColor??`#111827`,c=r.finalPriceColor??`#3A7D52`,l=r.oldPriceColor??`#9CA3AF`,u=r.buttonBackgroundColor??`#3A7D52`,d=r.buttonColor??`#FFFFFF`,f=r.borderRadius??0;return(0,p.jsx)(`div`,{style:{paddingTop:r.paddingTop??16,paddingBottom:r.paddingBottom??16,paddingLeft:r.paddingLeft??16,paddingRight:r.paddingRight??16,display:`flex`,flexWrap:`wrap`,gap:8},children:e.products.map(t=>(0,p.jsxs)(`div`,{style:{width:i?`100%`:`calc(${100/a}% - 8px)`,background:o,borderRadius:f,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:[(0,p.jsx)(`img`,{src:t.image,alt:t.imageAlt??t.name,style:{display:`block`,width:`100%`,height:`auto`,borderRadius:f}}),(0,p.jsx)(`div`,{style:{padding:`12px 12px 4px 12px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:15,fontWeight:`bold`,color:s,lineHeight:1.3},children:t.name}),e.showStars&&t.stars!=null&&(0,p.jsx)(`div`,{className:`stars`,style:{padding:`0 12px 4px 12px`,color:`#F5A623`,fontSize:15,letterSpacing:1},"aria-label":`${t.stars} out of 5 stars`,children:te(t.stars)}),(0,p.jsxs)(`div`,{style:{padding:`0 12px 8px 12px`,fontFamily:`Arial, Helvetica, sans-serif`},children:[e.showOldPrice&&t.oldPrice&&(0,p.jsx)(`span`,{className:`old_price`,style:{color:l,textDecoration:`line-through`,fontSize:14,marginRight:8},children:t.oldPrice}),(0,p.jsx)(`span`,{className:`final_price`,style:{color:c,fontWeight:`bold`,fontSize:18},children:t.finalPrice})]}),e.showDescription&&t.description&&(0,p.jsx)(`div`,{style:{padding:`0 12px 8px 12px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:13,color:`#6B7280`,lineHeight:1.5},children:t.description}),e.showButton&&(0,p.jsx)(`div`,{style:{padding:`4px 12px 12px 12px`,textAlign:`center`,marginTop:`auto`},children:(0,p.jsx)(`span`,{style:{display:`inline-block`,padding:`10px 18px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:13,fontWeight:`bold`,color:d,backgroundColor:u,borderRadius:6},children:t.buttonLabel??e.buttonLabel??`Shop now`})})]},t.id))})}var oa=null,sa=new Set,ca=0;function la(){ca+=1;for(let e of sa)e()}function ua(e){oa!==e&&(oa=e,la())}function da(){return oa}var fa=e=>(sa.add(e),()=>{sa.delete(e)}),pa=()=>ca,ma=null,ha={status:`idle`,vouchers:[]},ga=null,_a=new Set,va=0;function ya(){va+=1;for(let e of _a)e()}function ba(e){ma!==e&&(ma=e,ha={status:`idle`,vouchers:[]},ga=null,ya())}function xa(){return ma}function Sa(){return ha}function Ca(e=!1){if(!ma)return Promise.resolve([]);if(!e&&ha.status===`loaded`)return Promise.resolve(ha.vouchers);if(ga)return ga;ha={status:`loading`,vouchers:ha.vouchers},ya();let t=ma.list().then(e=>(ha={status:`loaded`,vouchers:Array.isArray(e)?e:[]},ga=null,ya(),ha.vouchers)).catch(e=>(ha={status:`error`,vouchers:[],error:e instanceof Error?e.message:String(e)},ga=null,ya(),[]));return ga=t,t}var wa=e=>(_a.add(e),()=>{_a.delete(e)}),Ta=()=>va,Ea=[],Da=null,Oa={registerModule:e=>Ie.register(e),registerTheme:e=>Ea.push(e),registerAssetProvider:e=>{Da=e},registerProductProvider:e=>{ua(e)},registerVoucherProvider:e=>{ba(e)},setAIProvider:e=>{He(e)},registerMergeTags:e=>Oi(e)};function ka(e){e.setup(Oa)}function Aa(){return Da}var ja={key:`days`,label:`Time window`,type:`select`,default:7,options:[{value:7,label:`Last 7 days`},{value:14,label:`Last 14 days`},{value:30,label:`Last 30 days`}]},Ma=[{id:`abandoned-cart`,label:`Abandoned basket products`,group:`behavioral`},{id:`bestseller-conversion`,label:`Best seller by Conversion`,group:`catalog`,params:[ja]},{id:`bestseller-units`,label:`Best seller by Units`,group:`catalog`,params:[ja]},{id:`new-products`,label:`New items added`,group:`catalog`,params:[ja]},{id:`cross-sell`,label:`Products Cross-Sell`,group:`contextual`},{id:`upsell`,label:`Products Upsell`,group:`contextual`},{id:`viewed-categories`,label:`Items from viewed categories`,group:`behavioral`},{id:`viewed-items`,label:`Items viewed`,group:`behavioral`},{id:`similar-basket`,label:`Similar to basket items`,group:`behavioral`},{id:`bought-together`,label:`Items bought together`,group:`contextual`},{id:`best-discount`,label:`Items with the best discount`,group:`catalog`},{id:`match-data`,label:`Items matching specific attributes`,group:`catalog`},{id:`last-purchased`,label:`Last purchased items`,group:`personal`},{id:`similar-to-purchased`,label:`Similar to last purchase`,group:`personal`},{id:`cross-sell-purchased`,label:`Cross-sell to last purchase`,group:`personal`},{id:`similar-items`,label:`Similar items`,group:`contextual`}],Na=Object.fromEntries(Ma.map(e=>[e.id,e])),Pa=[{value:`smart-reccs`,label:`Smart Recommendations`,description:`Best generic algorithm — recommended default.`},{value:`random`,label:`Random items (strict filters)`,description:`Random items that still pass include/exclude filters.`},{value:`ignore`,label:`Ignore position`,description:`Skip the slot if no items found.`},{value:`stop`,label:`Don't display`,description:`Don't render the email if the slot can't be filled.`}];function Fa(e=2){return{mode:`recommender`,noProducts:e,sourceFeed:``,manualProducts:[],stack:[{algorithm:`abandoned-cart`}],fallback:`smart-reccs`,filters:{includeProducts:[],excludeProducts:[],includeCategories:[],excludeCategories:[],minStock:0,minPrice:0,mainOnly:!1,higherPrice:!1,salesPrice:!1,sameCategory:!1,matchTitle:!1,sameField:``}}}function Ia(e){if(!e)return null;let t=e.recommendations;return!t||typeof t!=`object`?null:t}function La(e){return e?.children?e.children.some(e=>e.type===`productGrid`):!1}function Ra(e){if(!e?.children)return 0;let t=0;for(let n of e.children)n.type===`productGrid`&&(t+=n.products.length);return t}function za(e){return{params:{selection:e.mode===`manual`?`manual`:`recommender`,include:{item:e.filters.includeProducts,category:e.filters.includeCategories},exclude:{item:e.filters.excludeProducts,category:e.filters.excludeCategories},higherPrice:e.filters.higherPrice??!1,salesPrice:e.filters.salesPrice??!1,sameCategory:e.filters.sameCategory??!1,matchTitle:e.filters.matchTitle??!1,sameField:e.filters.sameField??``,mainOnly:e.filters.mainOnly??!1},noProducts:String(e.noProducts),fallback:e.fallback,stack:e.mode===`manual`?[]:e.stack,minStock:String(e.filters.minStock??0),minPrice:String(e.filters.minPrice??0),sourceFeed:e.sourceFeed??``,manualProducts:e.manualProducts}}function Ba({mod:e}){let t=N(e=>e.updateModule),n=Ra(e)||2,r=Ia(e.data)??Fa(n),i=n=>{let i={...r,...n};t(e.id,{data:{...e.data??{},recommendations:i}})};return(0,p.jsxs)(`div`,{className:`border border-blue-200 rounded-lg bg-blue-50/40 mt-4 overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 border-b border-blue-200 bg-blue-50`,children:[(0,p.jsx)(f.Sparkles,{size:14,className:`text-blue-700`}),(0,p.jsx)(`div`,{className:`text-xs font-semibold text-blue-900 uppercase tracking-wide`,children:`Products Source`})]}),(0,p.jsx)(`div`,{className:`p-3 bg-white border-b border-blue-100`,children:(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Wa,{active:r.mode===`manual`,title:`Select Items`,subtitle:`Hand-pick from a feed`,onClick:()=>i({mode:`manual`})}),(0,p.jsx)(Wa,{active:r.mode===`recommender`,title:`Recommender`,subtitle:`Algorithms + filters`,onClick:()=>i({mode:`recommender`})})]})}),(0,p.jsxs)(`div`,{className:`p-3 bg-white space-y-3`,children:[(0,p.jsxs)(X,{label:`Number of products`,children:[(0,p.jsx)(`input`,{type:`number`,min:1,max:20,value:r.noProducts,onChange:e=>i({noProducts:Number(e.target.value)||1}),className:Ua}),(0,p.jsxs)(`div`,{className:`text-[11px] text-gray-500 mt-1`,children:[`Block has `,n,` slot`,n===1?``:`s`,` in the design.`]})]}),r.mode===`manual`?(0,p.jsx)(Va,{logic:r,update:i}):(0,p.jsx)(Ha,{logic:r,update:i,updateFilters:e=>i({filters:{...r.filters,...e}})}),(0,p.jsxs)(`details`,{className:`border border-gray-200 rounded`,children:[(0,p.jsx)(`summary`,{className:`px-2 py-1.5 text-[11px] font-medium text-gray-600 cursor-pointer select-none`,children:`View saved JSON`}),(0,p.jsx)(`pre`,{className:`text-[10px] bg-gray-900 text-gray-100 p-2 overflow-auto max-h-60 leading-tight`,children:JSON.stringify(r,null,2)})]})]})]})}function Va({logic:e,update:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(X,{label:`Source feed`,children:(0,p.jsx)(`input`,{type:`text`,placeholder:`e.g. main-catalog`,value:e.sourceFeed??``,onChange:e=>t({sourceFeed:e.target.value}),className:Ua})}),(0,p.jsx)(X,{label:`Items to include (product IDs / SKUs)`,children:(0,p.jsx)(Xa,{value:e.manualProducts,onChange:e=>t({manualProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(`div`,{className:`text-[11px] text-gray-500`,children:`Items are sent to the renderer as-is in the order shown.`})]})}function Ha({logic:e,update:t,updateFilters:n}){let[r,i]=(0,l.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,p.jsxs)(`label`,{className:`text-xs font-medium text-gray-700`,children:[`Algorithms (max `,3,`)`]}),(0,p.jsx)(Ya,{disabled:e.stack.length>=3,existing:e.stack.map(e=>e.algorithm),onPick:n=>t({stack:[...e.stack,{algorithm:n}]})})]}),(0,p.jsx)(Ja,{stack:e.stack,onChange:e=>t({stack:e})})]}),(0,p.jsxs)(X,{label:`Fallback`,children:[(0,p.jsx)(`select`,{value:e.fallback,onChange:e=>t({fallback:e.target.value}),className:Ua,children:Pa.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,p.jsx)(`div`,{className:`text-[11px] text-gray-500 mt-1`,children:Pa.find(t=>t.value===e.fallback)?.description})]}),(0,p.jsx)(Ga,{title:`Include & Exclude filters`,right:(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(Ka,{active:!r,onClick:()=>i(!1),children:`Basic`}),(0,p.jsx)(Ka,{active:r,onClick:()=>i(!0),children:`Advanced`})]})}),(0,p.jsx)(X,{label:`Exclude products`,children:(0,p.jsx)(Xa,{value:e.filters.excludeProducts,onChange:e=>n({excludeProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(X,{label:`Include products`,children:(0,p.jsx)(Xa,{value:e.filters.includeProducts,onChange:e=>n({includeProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(X,{label:`Exclude categories`,children:(0,p.jsx)(Xa,{value:e.filters.excludeCategories,onChange:e=>n({excludeCategories:e}),placeholder:`Add category`})}),(0,p.jsx)(X,{label:`Include categories`,children:(0,p.jsx)(Xa,{value:e.filters.includeCategories,onChange:e=>n({includeCategories:e}),placeholder:`Add category`})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(X,{label:`Minimum stock`,children:(0,p.jsx)(`input`,{type:`number`,min:0,value:e.filters.minStock??0,onChange:e=>n({minStock:Number(e.target.value)||0}),className:Ua})}),(0,p.jsx)(X,{label:`Minimum price`,children:(0,p.jsx)(`input`,{type:`number`,min:0,value:e.filters.minPrice??0,onChange:e=>n({minPrice:Number(e.target.value)||0}),className:Ua})})]}),(0,p.jsx)(qa,{label:`Only main items`,checked:!!e.filters.mainOnly,onChange:e=>n({mainOnly:e})}),(0,p.jsx)(qa,{label:`Higher price than current item (upsell)`,checked:!!e.filters.higherPrice,onChange:e=>n({higherPrice:e})}),(0,p.jsx)(qa,{label:`On sale only`,checked:!!e.filters.salesPrice,onChange:e=>n({salesPrice:e})}),(0,p.jsx)(qa,{label:`Same category as current`,checked:!!e.filters.sameCategory,onChange:e=>n({sameCategory:e})}),(0,p.jsx)(qa,{label:`Match title keywords`,checked:!!e.filters.matchTitle,onChange:e=>n({matchTitle:e})}),(0,p.jsx)(X,{label:`Match same fields (comma-separated)`,children:(0,p.jsx)(`input`,{type:`text`,placeholder:`brand, color`,value:e.filters.sameField??``,onChange:e=>n({sameField:e.target.value}),className:Ua})}),r&&(0,p.jsx)(X,{label:`Advanced JSON overrides`,children:(0,p.jsx)(Za,{value:e.filters.advanced??{},onChange:e=>n({advanced:e})})})]})}var Ua=`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`;function Wa({active:e,icon:t,title:n,subtitle:r,onClick:i}){return(0,p.jsxs)(`button`,{onClick:i,className:`flex flex-col items-start gap-0.5 p-2.5 rounded border text-left transition `+(e?`border-teal-600 bg-teal-50 ring-1 ring-teal-600`:`border-gray-200 bg-white hover:border-gray-300`),children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 `+(e?`text-teal-700`:`text-gray-700`),children:[t,(0,p.jsx)(`span`,{className:`text-xs font-semibold`,children:n})]}),(0,p.jsx)(`span`,{className:`text-[10px] text-gray-500`,children:r})]})}function Ga({title:e,right:t}){return(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-200 pt-3 mt-3`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-gray-600`,children:e}),t]})}function X({label:e,children:t}){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-gray-700 mb-1`,children:e}),t]})}function Ka({active:e,onClick:t,children:n}){return(0,p.jsx)(`button`,{onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide `+(e?`bg-teal-600 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`),children:n})}function qa({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center justify-between gap-2 text-xs text-gray-700 py-1`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked),className:`h-4 w-4 accent-teal-600`})]})}function Ja({stack:e,onChange:t}){if(e.length===0)return(0,p.jsxs)(`div`,{className:`text-[11px] text-gray-500 italic border border-dashed border-gray-300 rounded px-2 py-3 text-center`,children:[`No algorithms yet. Click `,(0,p.jsx)(`b`,{children:`Add algorithm`}),` to start.`]});let n=(n,r)=>{let i=n+r;if(i<0||i>=e.length)return;let a=e.slice();[a[n],a[i]]=[a[i],a[n]],t(a)},r=n=>t(e.filter((e,t)=>t!==n)),i=(n,r,i)=>{let a=e.slice();a[n]={...a[n],params:{...a[n].params??{},[r]:i}},t(a)};return(0,p.jsx)(`div`,{className:`space-y-1.5`,children:e.map((t,a)=>{let o=Na[t.algorithm];return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded px-2 py-1.5 bg-white flex flex-col gap-1`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(`span`,{className:`flex-1 text-xs text-gray-800 truncate`,children:o?.label??t.algorithm}),(0,p.jsx)(`button`,{title:`Move up`,onClick:()=>n(a,-1),disabled:a===0,className:`p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30`,children:(0,p.jsx)(f.ChevronUp,{size:13})}),(0,p.jsx)(`button`,{title:`Move down`,onClick:()=>n(a,1),disabled:a===e.length-1,className:`p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30`,children:(0,p.jsx)(f.ChevronDown,{size:13})}),(0,p.jsx)(`button`,{title:`Remove`,onClick:()=>r(a),className:`p-1 text-gray-400 hover:text-red-600`,children:(0,p.jsx)(f.Trash2,{size:13})})]}),o?.params?.map(e=>(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`text-[10px] text-gray-500 w-20 shrink-0`,children:e.label}),e.type===`select`?(0,p.jsx)(`select`,{value:String(t.params?.[e.key]??e.default??``),onChange:t=>i(a,e.key,t.target.value),className:`flex-1 text-xs border border-gray-200 rounded px-1.5 py-1 bg-white`,children:e.options?.map(e=>(0,p.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))}):(0,p.jsx)(`input`,{type:e.type===`number`?`number`:`text`,value:String(t.params?.[e.key]??e.default??``),onChange:t=>i(a,e.key,e.type===`number`?Number(t.target.value):t.target.value),className:`flex-1 text-xs border border-gray-200 rounded px-1.5 py-1`})]},e.key))]},a)})})}function Ya({disabled:e,existing:t,onPick:n}){let[r,i]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsxs)(`button`,{disabled:e,onClick:()=>i(e=>!e),className:`flex items-center gap-1 px-2 py-1 rounded text-[11px] font-semibold uppercase `+(e?`bg-gray-200 text-gray-400 cursor-not-allowed`:`bg-teal-600 text-white hover:bg-teal-700`),children:[(0,p.jsx)(f.Plus,{size:12}),` Add`]}),r&&!e&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>i(!1)}),(0,p.jsx)(`div`,{className:`absolute right-0 top-full mt-1 w-64 max-h-80 overflow-auto bg-white border border-gray-200 rounded shadow-lg z-20`,children:Ma.map(e=>{let r=t.includes(e.id);return(0,p.jsxs)(`button`,{disabled:r,onClick:()=>{n(e.id),i(!1)},className:`block w-full text-left px-2.5 py-1.5 text-xs `+(r?`text-gray-400 cursor-not-allowed`:`text-gray-700 hover:bg-teal-50 hover:text-teal-700`),children:[e.label,r&&(0,p.jsx)(`span`,{className:`ml-1 text-[10px]`,children:`· added`})]},e.id)})})]})]})}function Xa({value:e,onChange:t,placeholder:n}){let[r,i]=(0,l.useState)(``),a=()=>{let n=r.trim();n&&(e.includes(n)||(t([...e,n]),i(``)))};return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded bg-white p-1 flex flex-wrap items-center gap-1 focus-within:border-blue-500`,children:[e.map(n=>(0,p.jsxs)(`span`,{className:`inline-flex items-center gap-1 bg-gray-100 text-gray-800 text-[11px] rounded px-1.5 py-0.5`,children:[n,(0,p.jsx)(`button`,{onClick:()=>t(e.filter(e=>e!==n)),className:`text-gray-500 hover:text-red-600`,children:(0,p.jsx)(f.X,{size:10})})]},n)),(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`||n.key===`,`?(n.preventDefault(),a()):n.key===`Backspace`&&!r&&e.length&&t(e.slice(0,-1))},onBlur:a,placeholder:e.length===0?n:``,className:`flex-1 min-w-20 outline-none text-xs bg-transparent px-1 py-0.5`})]})}function Za({value:e,onChange:t}){let[n,r]=(0,l.useState)(()=>JSON.stringify(e,null,2)),[i,a]=(0,l.useState)(null);return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`textarea`,{value:n,onChange:e=>{let n=e.target.value;r(n);try{let e=JSON.parse(n||`{}`);a(null),t(e)}catch(e){a(String(e.message))}},rows:6,spellCheck:!1,className:`w-full font-mono text-[11px] border border-gray-200 rounded p-2 bg-gray-50 focus:border-blue-500 focus:outline-none`}),i&&(0,p.jsx)(`div`,{className:`text-[10px] text-red-600 mt-1`,children:i})]})}function Qa(){(0,l.useSyncExternalStore)(wa,Ta,Ta);let e=xa()!==null,t=Sa();return(0,l.useEffect)(()=>{e&&t.status===`idle`&&Ca()},[e,t.status]),{available:e,status:t.status,vouchers:t.vouchers,error:t.error,reload:()=>void Ca(!0)}}function $a(e){return e?.children?.find(e=>e.type===`text`&&e.role===`voucherCode`)}function eo(e){return!!$a(e)}function to(e){let t=e?.data?.voucher;return t&&typeof t==`object`&&`code`in t?t:null}function no(e){return{id:e.id,title:e.title,code:e.code}}function ro({mod:e}){let t=N(e=>e.updateElement),n=N(e=>e.updateModule),{available:r,status:i,vouchers:a,error:o,reload:s}=Qa(),c=$a(e),l=to(e),u=l&&a.some(e=>e.id===l.id)?l.id:``,d=r=>{if(!r){n(e.id,{data:{...e.data??{},voucher:void 0}});return}c&&t(e.id,c.id,{content:r.code}),n(e.id,{data:{...e.data??{},voucher:no(r)}})};return(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:[(0,p.jsx)(f.Ticket,{size:13,className:`text-blue-600`}),` Voucher`]}),r&&(0,p.jsxs)(`button`,{type:`button`,onClick:s,disabled:i===`loading`,className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded disabled:opacity-50`,title:`Reload vouchers`,children:[i===`loading`?(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}):(0,p.jsx)(f.RefreshCw,{size:12}),`Reload`]})]}),r?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`label`,{className:`block mb-2`,children:[(0,p.jsx)(`span`,{className:`block text-xs text-gray-600 mb-1`,children:`Select voucher`}),(0,p.jsxs)(`select`,{value:u,disabled:i===`loading`&&a.length===0,onChange:e=>{let t=a.find(t=>t.id===e.target.value)??null;d(t)},className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded bg-white focus:border-blue-500 focus:outline-none disabled:bg-gray-50`,children:[(0,p.jsx)(`option`,{value:``,children:i===`loading`&&a.length===0?`Loading vouchers…`:`Please select a voucher…`}),a.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),i===`error`&&(0,p.jsxs)(`p`,{className:`flex items-start gap-1 text-[11px] text-red-600 mb-2`,children:[(0,p.jsx)(f.AlertTriangle,{size:12,className:`mt-0.5 shrink-0`}),o??`Failed to load vouchers.`]}),i===`loaded`&&a.length===0&&(0,p.jsx)(`p`,{className:`text-[11px] text-gray-400 mb-2`,children:`No vouchers found.`}),l&&(0,p.jsxs)(`div`,{className:`rounded border border-green-200 bg-green-50 px-2.5 py-2 text-[12px] text-green-800`,children:[`Voucher code: `,(0,p.jsx)(`span`,{className:`font-semibold`,children:l.code})]})]}):(0,p.jsxs)(`p`,{className:`text-[11px] text-gray-400`,children:[`Register a voucher provider (`,(0,p.jsx)(`code`,{children:`voucherPlugin`}),`) to pick codes from your catalog. You can still edit the code text directly.`]})]})}function io({open:e,onClose:t,onSave:n,initialQuery:r,title:i}){let[a,o]=(0,l.useState)(r??``),[s,c]=(0,l.useState)(!1),[u,d]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),[g,_]=(0,l.useState)(!1),v=(0,l.useRef)(null);if((0,l.useEffect)(()=>{if(!e)return;o(r??``),h(null),d(null),_(!1);let n=setTimeout(()=>v.current?.focus(),40),i=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,i),()=>{clearTimeout(n),window.removeEventListener(`keydown`,i)}},[e,r,t]),!e)return null;let y=async()=>{let e=da(),t=a.trim();if(!(!e||!t||s)){c(!0),d(null),h(null),_(!0);try{let n=await e.search(t);h(n)}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1)}}};return(0,p.jsx)(`div`,{className:`fixed inset-0 z-50 flex bg-black/60 backdrop-blur-sm p-4`,children:(0,p.jsxs)(`div`,{className:`m-auto flex max-h-[90vh] w-full max-w-lg flex-col overflow-hidden rounded-2xl bg-white shadow-2xl`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-200 px-5 py-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(f.PackageSearch,{size:18,className:`text-blue-600`}),(0,p.jsx)(`h2`,{className:`text-base font-semibold text-neutral-900`,children:i??`Find a product`})]}),(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg p-1.5 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900`,"aria-label":`Close`,children:(0,p.jsx)(f.X,{size:18})})]}),(0,p.jsx)(`div`,{className:`border-b border-neutral-100 px-5 py-3`,children:(0,p.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,p.jsxs)(`div`,{className:`relative flex-1`,children:[(0,p.jsx)(f.Search,{size:15,className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-neutral-400`}),(0,p.jsx)(`input`,{ref:v,value:a,onChange:e=>o(e.target.value),placeholder:`Search your catalog by name or SKU…`,className:`w-full rounded-lg border border-neutral-200 bg-white py-2 pl-9 pr-3 text-sm outline-none focus:border-blue-500`})]}),(0,p.jsxs)(`button`,{type:`submit`,disabled:s||!a.trim(),className:`flex shrink-0 items-center gap-1.5 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:bg-neutral-300`,children:[s?(0,p.jsx)(f.Loader2,{size:15,className:`animate-spin`}):(0,p.jsx)(f.Search,{size:15}),`Search`]})]})}),(0,p.jsxs)(`div`,{className:`min-h-[220px] flex-1 overflow-y-auto p-5`,children:[s&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-sm text-neutral-500`,children:[(0,p.jsx)(f.Loader2,{size:22,className:`animate-spin`}),`Searching…`]}),!s&&u&&(0,p.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700`,children:u}),!s&&!u&&g&&!m&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-center text-sm text-neutral-500`,children:[(0,p.jsx)(f.PackageSearch,{size:22,className:`text-neutral-300`}),`No product matched “`,a.trim(),`”. Try another name or SKU.`]}),!s&&!u&&!g&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-center text-sm text-neutral-400`,children:[(0,p.jsx)(f.PackageSearch,{size:22,className:`text-neutral-300`}),`Search your catalog, then preview and save the product.`]}),!s&&m&&(0,p.jsx)(ao,{result:m})]}),(0,p.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-neutral-200 px-5 py-3`,children:[(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg px-4 py-2 text-sm font-medium text-neutral-600 hover:bg-neutral-100`,children:`Cancel`}),(0,p.jsxs)(`button`,{onClick:()=>{m&&(n(m),t())},disabled:!m,className:`flex items-center gap-1.5 rounded-lg bg-green-600 px-4 py-2 text-sm font-medium text-white hover:bg-green-700 disabled:bg-neutral-300`,children:[(0,p.jsx)(f.Check,{size:15}),` Save product`]})]})]})})}function ao({result:e}){return(0,p.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-neutral-200`,children:[(0,p.jsx)(`div`,{className:`aspect-video w-full overflow-hidden bg-neutral-100`,children:e.image?(0,p.jsx)(`img`,{src:e.image,alt:e.imageAlt??e.name,className:`h-full w-full object-contain`}):(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-xs text-neutral-400`,children:`No image`})}),(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-neutral-900`,children:e.name}),e.stars!=null&&(0,p.jsxs)(`div`,{className:`flex items-center gap-0.5`,"aria-label":`${e.stars} out of 5`,children:[Array.from({length:5}).map((t,n)=>(0,p.jsx)(f.Star,{size:14,className:n<Math.round(e.stars??0)?`fill-amber-400 text-amber-400`:`text-neutral-300`},n)),(0,p.jsx)(`span`,{className:`ml-1 text-xs text-neutral-500`,children:e.stars})]}),(0,p.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[e.oldPrice&&(0,p.jsx)(`span`,{className:`text-sm text-neutral-400 line-through`,children:e.oldPrice}),(0,p.jsx)(`span`,{className:`text-lg font-bold text-blue-600`,children:e.finalPrice})]}),e.description&&(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-neutral-600`,children:e.description}),e.link&&(0,p.jsxs)(`a`,{href:e.link,target:`_blank`,rel:`noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs text-blue-600 hover:underline`,children:[(0,p.jsx)(f.ExternalLink,{size:12}),` View source`]})]})]})}function oo(){return(0,l.useSyncExternalStore)(fa,pa,pa),da()!==null}function so(){let{selection:e,doc:t,viewMode:n}=N(),[r,i]=(0,l.useState)(!0);return r?(0,p.jsxs)(`div`,{className:`w-72 bg-white border-l border-gray-200 shrink-0 overflow-y-auto flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 text-[11px] flex items-center gap-1.5 border-b shrink-0 ${n===`mobile`?`bg-amber-50 text-amber-800 border-amber-200`:`bg-blue-50 text-blue-800 border-blue-100`}`,children:[n===`mobile`?(0,p.jsx)(f.Smartphone,{size:12}):(0,p.jsx)(f.Monitor,{size:12}),(0,p.jsxs)(`span`,{className:`flex-1`,children:[`Editing `,n,` styles`]}),(0,p.jsx)(`button`,{onClick:()=>i(!1),title:`Hide properties`,className:`ml-auto p-0.5 rounded hover:bg-black/10 transition-colors ${n===`mobile`?`text-amber-700 hover:text-amber-900`:`text-blue-700 hover:text-blue-900`}`,children:(0,p.jsx)(f.PanelRightClose,{size:13})})]}),(0,p.jsx)(`div`,{className:`p-4 flex-1`,children:!e||e.kind===`email`?(0,p.jsx)(yo,{}):e.kind===`module`?(()=>{let n=t.modules.find(t=>t.id===e.moduleId);return n?(0,p.jsx)(So,{mod:n}):(0,p.jsx)(co,{})})():(()=>{let n=t.modules.find(t=>t.id===e.moduleId),r=n?.children.find(t=>t.id===e.elementId);return n&&r?(0,p.jsx)(Co,{mod:n,el:r}):(0,p.jsx)(co,{})})()})]}):(0,p.jsx)(`div`,{className:`flex flex-col items-center w-6 bg-white border-l border-gray-200 shrink-0`,children:(0,p.jsx)(`button`,{onClick:()=>i(!0),title:`Show properties`,className:`flex items-center justify-center w-full py-3 text-gray-400 hover:text-gray-600 hover:bg-gray-50 transition-colors`,children:(0,p.jsx)(f.PanelRightOpen,{size:14})})})}function co(){return(0,p.jsx)(`div`,{className:`text-xs text-gray-400`,children:`Nothing selected.`})}function lo(e,t){if(t!==`mobile`)return e;let n=e.mobile??{};return{...e,...n}}function uo(e,t,n){if(n!==`mobile`)return{...e,...t};let r=e.mobile??{};return{...e,mobile:{...r,...t}}}function fo({overridden:e}){return e?(0,p.jsx)(`span`,{className:`ml-1 text-[9px] uppercase tracking-wide bg-amber-100 text-amber-800 px-1 rounded`,children:`mobile`}):null}function po({hideOn:e,onChange:t}){return(0,p.jsx)(Z,{label:`Visibility`,children:(0,p.jsxs)(_o,{value:e??``,onChange:e=>{let n=e.target.value;t(n===``?void 0:n)},children:[(0,p.jsx)(`option`,{value:``,children:`Show on all`}),(0,p.jsx)(`option`,{value:`mobile`,children:`Hide on mobile`}),(0,p.jsx)(`option`,{value:`desktop`,children:`Hide on desktop`})]})})}function mo({children:e}){return(0,p.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500 mb-3`,children:e})}function Z({label:e,children:t}){return(0,p.jsxs)(`label`,{className:`block mb-3`,children:[(0,p.jsx)(`span`,{className:`flex items-center text-xs text-gray-600 mb-1`,children:e}),t]})}function Q(e){return(0,p.jsx)(`input`,{...e,className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none`})}function $(e){return(0,p.jsx)(Q,{type:`number`,...e})}function ho({value:e,onChange:t,onAlt:n}){let r=Aa(),i=(0,l.useRef)(null),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(null),u=async e=>{if(r){o(!0),c(null);try{let i=await r.upload(e);t(i.url),i.alt&&n&&n(i.alt)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1),i.current&&(i.current.value=``)}}};return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex gap-1`,children:[(0,p.jsx)(Q,{value:e??``,onChange:e=>t(e.target.value)}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&u(t)}}),(0,p.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>i.current?.click(),className:`shrink-0 px-2 py-1.5 text-xs border border-gray-200 rounded hover:bg-gray-50 disabled:opacity-50 flex items-center gap-1`,title:`Upload image`,children:a?(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}):(0,p.jsx)(f.Upload,{size:12})})]})]}),s&&(0,p.jsx)(`p`,{className:`text-[10px] text-red-600 mt-1`,children:s}),!r&&(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:`Tip: register an image uploader plugin to enable file uploads.`})]})}function go({value:e,onChange:t,defaultValue:n}){let r=N(e=>e.doc.theme),i=typeof e==`string`&&e.startsWith(`{`),a=(0,l.useRef)(n&&n.startsWith(`{`)?n:i?e:void 0);(0,l.useEffect)(()=>{i?a.current=e:n&&n.startsWith(`{`)&&(a.current=n)},[e,i,n]);let o=(()=>{let t=x(e,r);return typeof t==`string`&&/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)?t.length===4?`#`+t.slice(1).split(``).map(e=>e+e).join(``):t:`#000000`})(),s=n??a.current,c=!!s&&s!==e,[u,d]=(0,l.useState)(e??``);return(0,l.useEffect)(()=>d(e??``),[e]),(0,p.jsxs)(`div`,{className:`flex gap-1 items-center`,children:[(0,p.jsxs)(`label`,{className:`relative w-9 h-8 border border-gray-200 rounded cursor-pointer overflow-hidden shrink-0`,title:i?`Token → ${o} (click to override)`:`Pick color`,style:{background:o},children:[(0,p.jsx)(`input`,{type:`color`,value:o,onChange:e=>t(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer`}),i&&(0,p.jsx)(`span`,{className:`absolute inset-0 pointer-events-none border-2 border-dashed rounded`,style:{borderColor:`rgba(255,255,255,0.6)`}})]}),(0,p.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),onBlur:()=>u!==e&&t(u),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`}),c&&(0,p.jsx)(`button`,{type:`button`,onClick:()=>t(s),className:`shrink-0 p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded`,title:`Reset to ${s}`,children:(0,p.jsx)(f.RotateCcw,{size:12})})]})}function _o(e){return(0,p.jsx)(`select`,{...e,className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`})}function vo({linkType:e,onChangeLinkType:t,onChangeLink:n}){return(0,p.jsxs)(Z,{label:`Link role`,children:[(0,p.jsxs)(_o,{value:e??``,onChange:e=>{let r=e.target.value;r===``?t(void 0):(t(r),n(ye[r]))},children:[(0,p.jsx)(`option`,{value:``,children:`— None —`}),(0,p.jsx)(`option`,{value:`unsubscribe`,children:`Unsubscribe`}),(0,p.jsx)(`option`,{value:`view_in_browser`,children:`View in browser`}),(0,p.jsx)(`option`,{value:`manage_preferences`,children:`Manage preferences`}),(0,p.jsx)(`option`,{value:`user_profile`,children:`User profile`})]}),e&&(0,p.jsxs)(`p`,{className:`text-[10px] text-blue-600 mt-1 flex items-center gap-1`,children:[(0,p.jsx)(f.Tag,{size:10}),`Placeholder: `,(0,p.jsx)(`code`,{className:`font-mono`,children:ye[e]})]})]})}function yo(){let{doc:e,updateMeta:t,updateSettings:n}=N();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Email`}),(0,p.jsx)(Z,{label:`Name`,children:(0,p.jsx)(Q,{value:e.meta.name,onChange:e=>t({name:e.target.value})})}),(0,p.jsx)(Z,{label:`Preview text`,children:(0,p.jsx)(Q,{value:e.meta.previewText,onChange:e=>t({previewText:e.target.value})})}),(0,p.jsx)(Z,{label:`Width (px)`,children:(0,p.jsx)($,{value:e.settings.width,onChange:e=>n({width:Number(e.target.value)||600})})}),(0,p.jsx)(Z,{label:`Background color`,children:(0,p.jsx)(go,{value:e.settings.backgroundColor,onChange:e=>n({backgroundColor:e})})}),(0,p.jsx)(Z,{label:`Content background color`,children:(0,p.jsx)(go,{value:e.settings.contentBackgroundColor,onChange:e=>n({contentBackgroundColor:e})})}),(0,p.jsx)(`div`,{className:`mt-6 pt-4 border-t border-gray-100`,children:(0,p.jsx)(bo,{})})]})}function bo(){let{doc:e,themes:t,applyTheme:n}=N(),r=e.theme,i=t.find(e=>e.id===r.id),a=i!=null&&Object.entries(r.tokens.colors).some(([e,t])=>i.tokens.colors[e]!==t),o=(e,t)=>{n({...r,tokens:{...r.tokens,colors:{...r.tokens.colors,[e]:t}}})};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsx)(mo,{children:`Theme`}),a&&(0,p.jsx)(`button`,{onClick:()=>i&&n(i),className:`text-[10px] text-blue-600 hover:underline mb-3`,title:`Discard color changes and restore the preset`,children:`Reset to preset`})]}),(0,p.jsx)(`div`,{className:`flex flex-col gap-1.5 mb-4`,children:t.map(e=>{let t=e.id===r.id;return(0,p.jsxs)(`button`,{onClick:()=>n(e),title:e.name,className:`flex items-center gap-2 px-2.5 py-2 rounded border text-xs transition-colors ${t?`border-blue-500 bg-blue-50 text-blue-700`:`border-gray-200 bg-white hover:border-gray-300 text-gray-700`}`,children:[(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.primary}}),(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.background}}),(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.text}}),(0,p.jsx)(`span`,{className:`flex-1 text-left`,children:e.name}),t&&(0,p.jsx)(f.Check,{size:12,className:`text-blue-600 shrink-0`})]},e.id)})}),(0,p.jsxs)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500 mb-2`,children:[`Colors`,a&&(0,p.jsx)(`span`,{className:`ml-2 normal-case font-normal text-[10px] bg-amber-100 text-amber-700 px-1.5 py-0.5 rounded`,children:`customised`})]}),(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:Object.entries(r.tokens.colors).map(([e,t])=>(0,p.jsx)(xo,{label:e,value:t,onChange:t=>o(e,t)},e))})]})}function xo({label:e,value:t,onChange:n}){let[r,i]=(0,l.useState)(t);(0,l.useEffect)(()=>i(t),[t]);let a=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)?t.length===4?`#`+t.slice(1).split(``).map(e=>e+e).join(``):t:`#000000`,o=e=>{let t=e.trim();t&&n(t)};return(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`text-xs text-gray-500 w-28 shrink-0 truncate`,title:e,children:e}),(0,p.jsx)(`label`,{className:`relative w-7 h-7 rounded border border-gray-200 cursor-pointer overflow-hidden shrink-0`,style:{background:a},title:`Pick ${e} color`,children:(0,p.jsx)(`input`,{type:`color`,value:a,onChange:e=>n(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full`})}),(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onBlur:()=>o(r),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},className:`flex-1 min-w-0 px-2 py-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`,spellCheck:!1})]})}function So({mod:e}){let t=N(e=>e.updateModule),n=N(e=>e.viewMode),r=e.style??{},i=lo(r,n),a=new Set(Object.keys(r.mobile??{})),o=i=>t(e.id,{style:uo(r,i,n)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:e.name}),(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Background color`,(0,p.jsx)(fo,{overridden:a.has(`backgroundColor`)})]}),children:(0,p.jsx)(go,{value:i.backgroundColor??``,onChange:e=>o({backgroundColor:e})})}),(0,p.jsx)(wo,{style:i,mobileKeys:a,onSet:o}),(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Border radius`,(0,p.jsx)(fo,{overridden:a.has(`borderRadius`)})]}),children:(0,p.jsx)($,{value:i.borderRadius??0,onChange:e=>o({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(po,{hideOn:r.hideOn,onChange:n=>t(e.id,{style:{...r,hideOn:n}})}),La(e)&&(0,p.jsx)(Ba,{mod:e}),eo(e)&&(0,p.jsx)(ro,{mod:e})]})}function Co({mod:e,el:t}){switch(t.type){case`text`:return(0,p.jsx)(Eo,{mod:e,el:t});case`image`:return(0,p.jsx)(Do,{mod:e,el:t});case`button`:return(0,p.jsx)(Oo,{mod:e,el:t});case`spacer`:return(0,p.jsx)(ko,{mod:e,el:t});case`divider`:return(0,p.jsx)(Ao,{mod:e,el:t});case`productGrid`:return(0,p.jsx)(Mo,{mod:e,el:t})}}function wo({style:e,mobileKeys:t,onSet:n}){return(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2 mb-3`,children:[`paddingTop`,`paddingBottom`,`paddingLeft`,`paddingRight`].map(r=>(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[r.replace(`padding`,`Pad `),(0,p.jsx)(fo,{overridden:!!t?.has(r)})]}),children:(0,p.jsx)($,{value:e[r]??0,onChange:e=>n({[r]:Number(e.target.value)})})},r))})}function To(e,t){let n=N(e=>e.updateElement);return r=>n(e.id,t.id,r)}function Eo({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:uo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Text block`}),(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mb-3 leading-relaxed`,children:`Click the text in the canvas to edit it inline. Select words to apply bold, italic, colour, links and more using the floating toolbar.`}),(0,p.jsx)(Z,{label:`Default align`,children:(0,p.jsxs)(_o,{value:a.align??`left`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:`Line height`,children:(0,p.jsx)($,{step:.1,value:a.lineHeight??1.5,onChange:e=>s({lineHeight:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Letter spacing`,children:(0,p.jsx)($,{value:a.letterSpacing??0,onChange:e=>s({letterSpacing:Number(e.target.value)})})})]}),(0,p.jsx)(wo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(po,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function Do({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:uo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Image`}),(0,p.jsx)(Z,{label:`Image URL`,children:(0,p.jsx)(ho,{value:t.src,onChange:e=>n({src:e}),onAlt:e=>n({alt:e})})}),(0,p.jsx)(Z,{label:`Alt text`,children:(0,p.jsx)(Q,{value:t.alt??``,onChange:e=>n({alt:e.target.value})})}),(0,p.jsx)(Z,{label:`Link`,children:(0,p.jsx)(Q,{value:t.link??``,onChange:e=>n({link:e.target.value})})}),(0,p.jsx)(vo,{linkType:t.linkType,onChangeLinkType:e=>n({linkType:e}),onChangeLink:e=>n({link:e})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Width`,(0,p.jsx)(fo,{overridden:o.has(`width`)})]}),children:(0,p.jsx)($,{value:a.width??0,onChange:e=>s({width:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Height`,(0,p.jsx)(fo,{overridden:o.has(`height`)})]}),children:(0,p.jsx)($,{value:a.height??0,onChange:e=>s({height:Number(e.target.value)||void 0})})})]}),(0,p.jsx)(Z,{label:`Border radius`,children:(0,p.jsx)($,{value:a.borderRadius??0,onChange:e=>s({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Align`,children:(0,p.jsxs)(_o,{value:a.align??`center`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsx)(wo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(po,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function Oo({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:uo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Button`}),(0,p.jsx)(Z,{label:`Label`,children:(0,p.jsx)(Q,{value:t.label,onChange:e=>n({label:e.target.value})})}),(0,p.jsx)(Z,{label:`Link`,children:(0,p.jsx)(Q,{value:t.link,onChange:e=>n({link:e.target.value})})}),(0,p.jsx)(vo,{linkType:t.linkType,onChangeLinkType:e=>n({linkType:e}),onChangeLink:e=>n({link:e})}),(0,p.jsx)(Z,{label:`Background color`,children:(0,p.jsx)(go,{value:a.backgroundColor??``,onChange:e=>s({backgroundColor:e})})}),(0,p.jsx)(Z,{label:`Text color`,children:(0,p.jsx)(go,{value:a.color??`#FFFFFF`,onChange:e=>s({color:e})})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:`Font size`,children:(0,p.jsx)($,{value:a.fontSize??16,onChange:e=>s({fontSize:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Border radius`,children:(0,p.jsx)($,{value:a.borderRadius??6,onChange:e=>s({borderRadius:Number(e.target.value)})})})]}),(0,p.jsx)(Z,{label:`Align`,children:(0,p.jsxs)(_o,{value:a.align??`center`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsx)(wo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(po,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function ko({mod:e,el:t}){let n=To(e,t);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Spacer`}),(0,p.jsx)(Z,{label:`Height (px)`,children:(0,p.jsx)($,{value:t.height,onChange:e=>n({height:Number(e.target.value)||0})})})]})}function Ao({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:uo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Divider`}),(0,p.jsx)(Z,{label:`Color`,children:(0,p.jsx)(go,{value:a.color??`#E5E7EB`,onChange:e=>s({color:e})})}),(0,p.jsx)(Z,{label:`Thickness`,children:(0,p.jsx)($,{value:a.thickness??1,onChange:e=>s({thickness:Number(e.target.value)})})}),(0,p.jsx)(wo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(po,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function jo(e=0){let t=e+1;return{id:`p_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,image:`https://placehold.co/400x400?text=Product+${t}`,imageAlt:`Product ${t}`,name:`Product ${t}`,oldPrice:`$59`,finalPrice:`$39`,description:`Short product description.`,link:`#`}}function Mo({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=e=>n({style:uo(i,e,r)}),s=e=>n({products:e}),c=e=>{let r=e,i=t.products.slice();if(i.length<r)for(;i.length<r;)i.push(jo(i.length));n({columns:e,products:i})},u=oo(),[d,m]=(0,l.useState)(null);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Product Grid`}),(0,p.jsxs)(Z,{label:`Columns (desktop)`,children:[(0,p.jsx)(`div`,{className:`inline-flex bg-gray-100 rounded p-0.5 w-full`,children:[1,2,3].map(e=>(0,p.jsxs)(`button`,{onClick:()=>c(e),className:`flex-1 px-2 py-1 text-xs rounded ${t.columns===e?`bg-white shadow text-gray-900`:`text-gray-500 hover:text-gray-700`}`,children:[e,` `,e===1?`col`:`cols`]},e))}),(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:`Always stacks to 1 column on mobile.`})]}),(0,p.jsx)(Po,{label:`Show old price`,checked:t.showOldPrice,onChange:e=>n({showOldPrice:e})}),(0,p.jsx)(Po,{label:`Show description`,checked:t.showDescription,onChange:e=>n({showDescription:e})}),(0,p.jsx)(Po,{label:`Show stars`,checked:t.showStars??!1,onChange:e=>n({showStars:e})}),(0,p.jsx)(Po,{label:`Show button`,checked:t.showButton,onChange:e=>n({showButton:e})}),(0,p.jsx)(Z,{label:`Default button label`,children:(0,p.jsx)(Q,{value:t.buttonLabel??``,placeholder:`Shop now`,onChange:e=>n({buttonLabel:e.target.value})})}),(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(mo,{children:[`Products (`,t.products.length,`)`]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u&&(0,p.jsxs)(`button`,{onClick:()=>m({index:null,query:``}),className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded`,title:`Find a product from your catalog`,children:[(0,p.jsx)(f.Search,{size:12}),` Find`]}),(0,p.jsxs)(`button`,{onClick:()=>s([...t.products,jo(t.products.length)]),className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded`,title:`Add product`,children:[(0,p.jsx)(f.Plus,{size:12}),` Add`]})]})]}),t.products.map((e,n)=>(0,p.jsx)(Fo,{index:n,product:e,canSearch:u,onSearch:()=>m({index:n,query:e.name}),onChange:e=>{let r=[...t.products];r[n]=e,s(r)},onDelete:()=>s(t.products.filter((e,t)=>t!==n))},e.id))]}),(0,p.jsx)(io,{open:d!==null,initialQuery:d?.query,title:d?.index==null?`Add product from search`:`Replace product`,onClose:()=>m(null),onSave:e=>{let r=G({name:e.name,finalPrice:e.finalPrice,oldPrice:e.oldPrice,description:e.description,link:e.link,image:e.image,imageAlt:e.imageAlt,stars:e.stars}),i={};e.oldPrice&&!t.showOldPrice&&(i.showOldPrice=!0),e.description&&!t.showDescription&&(i.showDescription=!0),e.stars!=null&&!t.showStars&&(i.showStars=!0);let a=t.products.slice();if(d?.index!=null){let e=a[d.index];a[d.index]={...r,id:e.id,buttonLabel:e.buttonLabel}}else a.push(r);n({products:a,...i})}}),(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsx)(mo,{children:`Style`}),(0,p.jsx)(Z,{label:`Card background`,children:(0,p.jsx)(go,{value:a.cardBackgroundColor??``,onChange:e=>o({cardBackgroundColor:e})})}),(0,p.jsx)(Z,{label:`Name color`,children:(0,p.jsx)(go,{value:a.nameColor??``,onChange:e=>o({nameColor:e})})}),(0,p.jsx)(Z,{label:`Final price color`,children:(0,p.jsx)(go,{value:a.finalPriceColor??``,onChange:e=>o({finalPriceColor:e})})}),(0,p.jsx)(Z,{label:`Old price color`,children:(0,p.jsx)(go,{value:a.oldPriceColor??``,onChange:e=>o({oldPriceColor:e})})}),(0,p.jsx)(Z,{label:`Button background`,children:(0,p.jsx)(go,{value:a.buttonBackgroundColor??``,onChange:e=>o({buttonBackgroundColor:e})})}),(0,p.jsx)(Z,{label:`Button text color`,children:(0,p.jsx)(go,{value:a.buttonColor??``,onChange:e=>o({buttonColor:e})})}),(0,p.jsx)(Z,{label:`Card radius`,children:(0,p.jsx)($,{value:a.borderRadius??0,onChange:e=>o({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(wo,{style:a,onSet:o})]})]})}function No({checked:e,onChange:t}){return(0,p.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:n=>{n.preventDefault(),n.stopPropagation(),t(!e)},className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ${e?`bg-blue-600`:`bg-gray-300`}`,children:(0,p.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?`translate-x-4`:`translate-x-0.5`}`})})}function Po({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`span`,{className:`text-xs text-gray-600`,children:e}),(0,p.jsx)(No,{checked:t,onChange:n})]})}function Fo({index:e,product:t,canSearch:n,onSearch:r,onChange:i,onDelete:a}){let o=e=>i({...t,...e});return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded p-2 mb-2 bg-gray-50`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-600`,children:[`#`,e+1]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n&&(0,p.jsx)(`button`,{type:`button`,onClick:r,className:`text-gray-400 hover:text-blue-600`,title:`Replace from product search`,children:(0,p.jsx)(f.Search,{size:12})}),(0,p.jsx)(`button`,{type:`button`,onClick:a,className:`text-gray-400 hover:text-red-600`,title:`Remove product`,children:(0,p.jsx)(f.Trash2,{size:12})})]})]}),(0,p.jsx)(Z,{label:`Name`,children:(0,p.jsx)(Q,{value:t.name,onChange:e=>o({name:e.target.value})})}),(0,p.jsx)(Z,{label:`Image URL`,children:(0,p.jsx)(ho,{value:t.image,onChange:e=>o({image:e}),onAlt:e=>o({imageAlt:e})})}),(0,p.jsx)(Z,{label:`Link`,children:(0,p.jsx)(Q,{value:t.link??``,onChange:e=>o({link:e.target.value})})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:`Final price`,children:(0,p.jsx)(Q,{value:t.finalPrice,onChange:e=>o({finalPrice:e.target.value})})}),(0,p.jsx)(Z,{label:`Old price`,children:(0,p.jsx)(Q,{value:t.oldPrice??``,placeholder:`Optional`,onChange:e=>o({oldPrice:e.target.value||void 0})})})]}),(0,p.jsx)(Z,{label:`Description`,children:(0,p.jsx)(Q,{value:t.description??``,onChange:e=>o({description:e.target.value||void 0})})}),(0,p.jsx)(Z,{label:`Stars (0–5, optional)`,children:(0,p.jsx)($,{value:t.stars??``,min:0,max:5,step:.5,placeholder:`e.g. 4.5`,onChange:e=>o({stars:e.target.value===``?void 0:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Button label (override)`,children:(0,p.jsx)(Q,{value:t.buttonLabel??``,placeholder:`Inherit default`,onChange:e=>o({buttonLabel:e.target.value||void 0})})})]})}var Io=[{type:`basic.text`,category:`basic`,name:`Text Block`,description:`Single editable paragraph of body copy. Use for short notes, intros, or filler text between sections.`,tags:[`text`,`paragraph`,`body`],create:()=>B(`basic.text`,`Text Block`,[F(`Write your text here.`,{role:`body`})])},{type:`basic.heading`,category:`basic`,name:`Heading`,description:`Bold standalone heading using the theme heading font. Use to introduce a section without other elements.`,tags:[`heading`,`title`,`section`],create:()=>B(`basic.heading`,`Heading`,[F(`A clear section heading`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingTop:16,paddingBottom:8,lineHeight:1.25})])},{type:`basic.image`,category:`basic`,name:`Image`,description:`Single full-width image, centered. Use for hero photography, illustrations, or screenshots.`,tags:[`image`,`media`,`photo`],create:()=>B(`basic.image`,`Image`,[I(W(600,300),`Placeholder`)])},{type:`basic.image_caption`,category:`basic`,name:`Image with Caption`,description:`Image followed by a small italicized caption underneath. Editorial style for newsletters.`,tags:[`image`,`caption`,`editorial`],create:()=>B(`basic.image_caption`,`Image + Caption`,[I(W(600,360),`Photo`),F(`Photo: caption goes here.`,{color:`{colors.muted}`,fontSize:13,align:`center`,paddingTop:4,paddingBottom:16})])},{type:`basic.spacer`,category:`basic`,name:`Spacer`,description:`Empty vertical space. Use to separate modules with breathing room.`,tags:[`spacer`,`spacing`,`gap`],create:()=>B(`basic.spacer`,`Spacer`,[R(32)])},{type:`basic.divider`,category:`basic`,name:`Divider`,description:`Thin horizontal rule across the email. Use to visually separate sections.`,tags:[`divider`,`separator`,`rule`],create:()=>B(`basic.divider`,`Divider`,[z()])}],Lo=[{type:`header.logo`,category:`header`,name:`Logo Centered`,description:`Centered brand logo. The simplest header used at the top of almost every newsletter.`,tags:[`logo`,`brand`,`centered`],create:()=>B(`header.logo`,`Logo Header`,[I(W(180,56,`LOGO`),`Logo`,{width:180,paddingTop:24,paddingBottom:24})])},{type:`header.logo_left_date_right`,category:`header`,name:`Logo Left + Date Right`,description:`Two-column header with logo on the left and a date or issue label on the right. Common for periodical newsletters and digests.`,tags:[`logo`,`date`,`issue`,`publication`,`newsletter`],create:()=>B(`header.logo_left_date_right`,`Logo + Date`,[I(W(140,36,`LOGO`),`Logo`,{width:140,align:`left`,paddingTop:16,paddingBottom:16}),F(`Issue #128 · April 29, 2026`,{color:`{colors.muted}`,fontSize:13,align:`right`,paddingTop:0,paddingBottom:16}),z({paddingTop:0,paddingBottom:0})])},{type:`header.publication`,category:`header`,name:`Publication Masthead`,description:`Editorial masthead with publication name in serif type, tagline, and a divider. Mimics print magazine and newspaper newsletters.`,tags:[`masthead`,`publication`,`editorial`,`serif`,`newspaper`,`magazine`],create:()=>B(`header.publication`,`Masthead`,[F(`THE WEEKLY`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,letterSpacing:6,paddingTop:32,paddingBottom:4}),F(`Curated reading for thoughtful people`,{color:`{colors.muted}`,align:`center`,fontSize:13,paddingBottom:16}),z({paddingTop:0,paddingBottom:0})])},{type:`header.hero`,category:`header`,name:`Hero with Headline & Image`,description:`Big headline, subtitle and a wide hero image. Use for the lead story or campaign announcement.`,tags:[`hero`,`headline`,`image`,`lead`,`feature`],create:()=>B(`header.hero`,`Hero`,[F(`Steps Towards a Greener World`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,paddingTop:32,lineHeight:1.2}),F(`Small actions, big impact.`,{color:`{colors.muted}`,align:`center`,paddingBottom:16}),I(W(560,280,`Hero`),`Hero`,{width:560})])},{type:`header.hero_text_only`,category:`header`,name:`Hero Text Only`,description:`Centered eyebrow + large headline + supporting paragraph, no image. Editorial intro for opinion or essay newsletters.`,tags:[`hero`,`text`,`essay`,`editorial`,`minimal`],create:()=>B(`header.hero_text_only`,`Hero Text`,[F(`ESSAY · ISSUE 42`,{fontSize:12,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:3,align:`center`,paddingTop:32,paddingBottom:8}),F(`On building things slowly`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:40,fontWeight:`bold`,align:`center`,lineHeight:1.15,paddingBottom:8}),F(`Why patience and craft still win in a world of shortcuts.`,{color:`{colors.muted}`,align:`center`,fontSize:16,paddingBottom:32})])},{type:`header.announcement`,category:`header`,name:`Announcement Bar`,description:`Thin colored top bar with a single line of promotional text. Use for free shipping, sales, or alerts.`,tags:[`announcement`,`bar`,`promo`,`alert`],create:()=>B(`header.announcement`,`Announcement`,[F(`✨ Free shipping on orders over $50`,{color:`{colors.buttonText}`,align:`center`,fontSize:14,paddingTop:12,paddingBottom:12})],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`header.logo_with_view_browser`,category:`header`,name:`Logo + View in Browser`,description:`Logo with a small 'View in browser' link above it. Standard for marketing newsletters that may render poorly.`,tags:[`logo`,`view-in-browser`,`marketing`,`preheader`],create:()=>B(`header.logo_with_view_browser`,`Logo + Browser Link`,[F(`View in browser`,{color:`{colors.muted}`,fontSize:11,align:`right`,paddingTop:8,paddingBottom:0,link:`#`}),I(W(160,48,`LOGO`),`Logo`,{width:160,paddingTop:8,paddingBottom:16})])},{type:`header.welcome`,category:`header`,name:`Welcome Header`,description:`Friendly greeting with first name placeholder, used at the top of welcome and onboarding emails.`,tags:[`welcome`,`onboarding`,`greeting`,`personalized`],create:()=>B(`header.welcome`,`Welcome`,[F(`👋 Welcome aboard, {{first_name}}`,{fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,align:`center`,paddingTop:32,paddingBottom:8}),F(`We're glad you're here. Here's what to do next.`,{color:`{colors.muted}`,align:`center`,paddingBottom:16})])},{type:`header.logo_with_tagline`,category:`header`,name:`Logo + Tagline`,description:`Centered logo above a one-line tagline. Friendly brand-forward header.`,tags:[`logo`,`tagline`,`brand`],create:()=>B(`header.logo_with_tagline`,`Logo + Tagline`,[I(W(160,48,`LOGO`),`Logo`,{width:160,paddingTop:24,paddingBottom:4}),F(`Newsletters that respect your time.`,{align:`center`,color:`{colors.muted}`,fontSize:14,paddingBottom:24})])},{type:`header.story_label`,category:`header`,name:`Story Label Header`,description:`Small category label (e.g. 'Top story', 'Deep dive') above the masthead. Used by The Hustle, Morning Brew style newsletters.`,tags:[`label`,`category`,`story`,`newsletter`,`topic`],create:()=>B(`header.story_label`,`Story Label`,[F(`TODAY'S TOP STORY`,{color:`{colors.primary}`,fontSize:12,fontWeight:`bold`,letterSpacing:3,align:`center`,paddingTop:24,paddingBottom:4}),F(`AI editing tools come for the inbox`,{fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,align:`center`,paddingBottom:16,lineHeight:1.2})])}],Ro=[{type:`menu.horizontal`,category:`menu`,name:`Horizontal Nav`,description:`Horizontal menu with 3-5 inline links separated by dots. Common publication navigation under the masthead.`,tags:[`menu`,`nav`,`horizontal`,`publication`],create:()=>B(`menu.horizontal`,`Horizontal Menu`,[F(`Home · Articles · Podcast · About · Subscribe`,{align:`center`,color:`{colors.text}`,fontSize:13,paddingTop:12,paddingBottom:12})])},{type:`menu.sections`,category:`menu`,name:`Section Tabs`,description:`Linked section labels representing the contents of today's issue (e.g. News · Markets · Tech · Culture). Used by daily digests.`,tags:[`menu`,`sections`,`tabs`,`digest`,`daily`],create:()=>B(`menu.sections`,`Section Tabs`,[z({paddingTop:0,paddingBottom:8}),F(`NEWS · MARKETS · TECH · CULTURE · WEEKEND`,{align:`center`,color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,paddingTop:0,paddingBottom:8}),z({paddingTop:0,paddingBottom:8})])},{type:`menu.in_this_issue`,category:`menu`,name:`In This Issue`,description:`Table-of-contents box listing the items in this newsletter issue with anchor links. Helps readers scan long emails.`,tags:[`toc`,`menu`,`issue`,`summary`,`table of contents`],create:()=>B(`menu.in_this_issue`,`In This Issue`,[F(`IN THIS ISSUE`,{fontSize:11,fontWeight:`bold`,color:`{colors.muted}`,letterSpacing:2,paddingTop:16,paddingBottom:8}),F(`→ Lead story: AI in the inbox`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#lead`}),F(`→ 3 things worth your time`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#picks`}),F(`→ Reader question of the week`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#qa`}),F(`→ Upcoming events`,{fontSize:14,paddingTop:2,paddingBottom:16,link:`#events`})],{backgroundColor:`{colors.background}`,paddingTop:8,paddingBottom:8,paddingLeft:16,paddingRight:16})},{type:`menu.cta_strip`,category:`menu`,name:`Linked Action Strip`,description:`Three short text actions in a row (e.g. 'Read · Share · Reply'). Light alternative to a button bar.`,tags:[`menu`,`actions`,`links`,`strip`],create:()=>B(`menu.cta_strip`,`Action Strip`,[F(`Read online · Share · Reply with feedback`,{align:`center`,color:`{colors.primary}`,fontSize:13,paddingTop:12,paddingBottom:12})])}],zo=[{type:`content.headline_body`,category:`content`,name:`Headline + Body`,description:`Section title with one paragraph of body text. The most generic written content block.`,tags:[`headline`,`body`,`paragraph`,`article`],create:()=>B(`content.headline_body`,`Headline + Body`,[V(`A compelling headline`,{paddingTop:24}),F(`Tell your story with a clear, concise paragraph. Keep readers engaged with short sentences and meaningful detail.`,{paddingBottom:24})])},{type:`content.lead_story`,category:`content`,name:`Lead Story`,description:`Top story of the issue: eyebrow label, big headline, hero image, lead paragraph and a 'Continue reading' link. Used by news and editorial newsletters.`,tags:[`lead`,`story`,`feature`,`news`,`editorial`,`long-form`],create:()=>B(`content.lead_story`,`Lead Story`,[H(`Lead story`),V(`Inside the new wave of indie publishers`,{level:1,paddingBottom:4}),U(`By Jane Doe · 6 min read`,{fontSize:13}),I(W(560,320,`Lead`),`Lead`,{width:560,paddingTop:12}),F(`A growing group of writers are leaving big media to build their own readerships, betting that quality and a direct relationship beat scale.`,{paddingTop:16}),F(`Continue reading →`,{color:`{colors.primary}`,fontWeight:`bold`,paddingTop:4,paddingBottom:24,link:`#`})])},{type:`content.article_summary`,category:`content`,name:`Article Summary Card`,description:`Compact link-out card: image on top, category label, title, one-line summary, and 'Read more'. Use repeatedly to list secondary articles.`,tags:[`article`,`summary`,`card`,`link-out`,`newsletter`],create:()=>B(`content.article_summary`,`Article Card`,[I(W(560,280,`Article`),`Article`,{width:560}),F(`CULTURE`,{color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,paddingTop:12,paddingBottom:4}),V(`How long-form writing made a comeback`,{paddingTop:0,paddingBottom:4}),F(`Why subscribers are paying for slower, deeper coverage — and what it means for publishers.`,{paddingBottom:8}),F(`Read more →`,{color:`{colors.primary}`,fontWeight:`bold`,paddingBottom:24,link:`#`})])},{type:`content.image_text`,category:`content`,name:`Image + Text Beside`,description:`Image with article title and short summary stacked below. Standard editorial card.`,tags:[`image`,`text`,`article`,`stacked`],create:()=>B(`content.image_text`,`Image + Text`,[I(W(560,300,`Article`),`Article`,{width:560}),V(`Article title`,{paddingTop:16,paddingBottom:4}),F(`A short summary of the article goes here, two or three lines is plenty.`)])},{type:`content.two_column_articles`,category:`content`,name:`Two Column Stories`,description:`Two short article previews shown side-by-side as stacked blocks (renders as full-width on mobile). Use to tease two related stories.`,tags:[`two-column`,`articles`,`side-by-side`,`preview`],create:()=>B(`content.two_column_articles`,`Two Stories`,[H(`More to read`),I(W(272,180,`Story A`),`Story A`,{width:272}),F(`Story A title`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),F(`One sentence about story A.`,{fontSize:14,paddingBottom:16}),I(W(272,180,`Story B`),`Story B`,{width:272}),F(`Story B title`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),F(`One sentence about story B.`,{fontSize:14,paddingBottom:16})])},{type:`content.three_picks`,category:`content`,name:`Three Picks (Numbered)`,description:`Numbered list of three short recommendations or links. Used by curators ('3 things to read this week').`,tags:[`list`,`picks`,`curated`,`links`,`recommendations`],create:()=>B(`content.three_picks`,`Three Picks`,[H(`Three picks`),F(`01 / How to stay focused in 2026`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),U(`Notes on attention, deep work, and the slow internet.`,{fontSize:14}),z({paddingTop:12,paddingBottom:8}),F(`02 / The case for boring software`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),U(`Why teams are returning to simpler, predictable tools.`,{fontSize:14}),z({paddingTop:12,paddingBottom:8}),F(`03 / A short history of the inbox`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),U(`From memos to MIME, and what comes next.`,{fontSize:14,paddingBottom:24})])},{type:`content.quote`,category:`content`,name:`Pull Quote`,description:`Centered serif pull quote with attribution. Adds rhythm to long editorial newsletters.`,tags:[`quote`,`pull-quote`,`editorial`,`attribution`],create:()=>B(`content.quote`,`Pull Quote`,[F(`“The best way to predict the future is to create it.”`,{fontFamily:`{fonts.heading}`,fontSize:22,align:`center`,paddingTop:24,lineHeight:1.4}),F(`— Peter Drucker`,{color:`{colors.muted}`,align:`center`,paddingBottom:24})])},{type:`content.author_byline`,category:`content`,name:`Author Byline`,description:`Round avatar + author name + role on one line. Drop above or below an article body for personal newsletters.`,tags:[`author`,`byline`,`avatar`,`personal`],create:()=>B(`content.author_byline`,`Byline`,[I(W(64,64,`👤`),`Author`,{width:64,borderRadius:32,paddingTop:16,paddingBottom:0}),F(`Jane Doe`,{align:`center`,fontWeight:`bold`,paddingTop:8,paddingBottom:0}),U(`Editor, The Weekly`,{align:`center`,fontSize:13}),R(16)])},{type:`content.editor_note`,category:`content`,name:`Editor's Note`,description:`Personal letter-style block: 'Hi {{first_name}}', a few paragraphs and a sign-off. Ideal for newsletters with a strong author voice.`,tags:[`editor`,`note`,`letter`,`personal`,`voice`],create:()=>B(`content.editor_note`,`Editor's Note`,[F(`Hi {{first_name}},`,{paddingTop:24,paddingBottom:8}),F(`This week I've been thinking about what makes a newsletter feel like a letter rather than a broadcast. Spoiler: it's not the format, it's the tone.`,{paddingBottom:8,lineHeight:1.7}),F(`Let me know what you think — just hit reply.`,{paddingBottom:8,lineHeight:1.7}),F(`— Jane`,{fontFamily:`{fonts.heading}`,paddingBottom:24})])},{type:`content.tip_box`,category:`content`,name:`Tip / Callout Box`,description:`Highlighted background box with an icon, short title and one-paragraph tip. Use for 'pro tips', notes, and warnings.`,tags:[`tip`,`callout`,`box`,`highlight`,`note`],create:()=>B(`content.tip_box`,`Tip Box`,[F(`💡 PRO TIP`,{color:`{colors.primary}`,fontSize:12,fontWeight:`bold`,letterSpacing:2,paddingTop:16,paddingBottom:4}),F(`Always preview your email on mobile before sending — most opens happen there.`,{paddingBottom:16})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16})},{type:`content.numbered_list`,category:`content`,name:`Numbered List`,description:`Vertical numbered list of 4-5 short items with optional sub-text. Use for tutorials, checklists and 'how-to' newsletters.`,tags:[`list`,`numbered`,`tutorial`,`checklist`,`how-to`],create:()=>B(`content.numbered_list`,`Numbered List`,[V(`How to do it in 4 steps`,{paddingTop:16,paddingBottom:12}),F(`1. Define the goal`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),U(`Write down the outcome in one sentence.`),F(`2. List constraints`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`Time, budget, scope. Be specific.`),F(`3. Plan the smallest version`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`What can you ship this week?`),F(`4. Ship it`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`Refine after real feedback.`,{fontSize:14}),R(16)])},{type:`content.bullet_list`,category:`content`,name:`Bullet List`,description:`Simple unordered list of takeaways or facts. Concise summary block.`,tags:[`list`,`bullets`,`takeaways`,`summary`],create:()=>B(`content.bullet_list`,`Bullets`,[V(`Key takeaways`,{paddingTop:16,paddingBottom:8}),F(`• Newsletters are growing 20% YoY`,{paddingTop:2,paddingBottom:2}),F(`• Mobile opens crossed 70%`,{paddingTop:2,paddingBottom:2}),F(`• Plain-text emails outperform image-heavy ones in B2B`,{paddingTop:2,paddingBottom:2}),F(`• Personalization drives 2x click-through`,{paddingTop:2,paddingBottom:16})])},{type:`content.qa`,category:`content`,name:`Q&A Block`,description:`Question in bold followed by an answer paragraph. Use for FAQ, reader mailbags, or AMAs.`,tags:[`qa`,`faq`,`ama`,`mailbag`,`reader-questions`],create:()=>B(`content.qa`,`Q&A`,[H(`Reader question`),F(`Q: How do I get my first 100 subscribers?`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:4,paddingBottom:8,lineHeight:1.3}),F(`A: Tell ten people who already know you. Then ask each of them to forward to one friend. The first 100 don't come from algorithms — they come from your network.`,{paddingBottom:24,lineHeight:1.7})])},{type:`content.stats_row`,category:`content`,name:`Stat Row`,description:`Big numbers with short labels (e.g. '12k readers · 4.8★ rating · 96% open rate'). Used for impact summaries and social proof.`,tags:[`stats`,`numbers`,`metrics`,`social-proof`],create:()=>B(`content.stats_row`,`Stat Row`,[H(`By the numbers`,{align:`center`}),F(`12,400`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,color:`{colors.primary}`,paddingTop:4,paddingBottom:0}),U(`active readers this month`,{align:`center`,fontSize:13}),R(8),F(`96% · 4.8★ · 32 issues shipped`,{align:`center`,color:`{colors.text}`,fontSize:14,paddingBottom:24})])},{type:`content.timeline`,category:`content`,name:`Timeline / What Happened`,description:`Chronological list of recent events with dates. Used by news roundups and changelog newsletters.`,tags:[`timeline`,`changelog`,`news`,`events`,`what-happened`],create:()=>B(`content.timeline`,`Timeline`,[H(`This week`),F(`Mon · Acme launches plan B`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`After 6 months of beta testing.`,{fontSize:14}),F(`Wed · New funding round announced`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`$24M Series A led by Foundry.`,{fontSize:14}),F(`Fri · Industry report drops`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`Open rates up across the board.`,{fontSize:14,paddingBottom:24})])},{type:`content.podcast_episode`,category:`content`,name:`Podcast Episode`,description:`Episode artwork, episode number, title, short description and a 'Listen' button. For shows that announce episodes by email.`,tags:[`podcast`,`episode`,`audio`,`listen`,`show`],create:()=>B(`content.podcast_episode`,`Podcast Episode`,[I(W(220,220,`Cover`),`Cover`,{width:220,borderRadius:12}),F(`EPISODE 042`,{color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,align:`center`,paddingTop:12,paddingBottom:4}),V(`Why publishers are betting on email`,{align:`center`,paddingTop:0,paddingBottom:4}),U(`With Jane Doe · 38 min`,{align:`center`,fontSize:13}),L(`Listen now`,`https://example.com`),R(16)])},{type:`content.video_thumbnail`,category:`content`,name:`Video Thumbnail`,description:`Video thumbnail with overlay-feeling play button (image only, links to a hosted player). Title and duration below.`,tags:[`video`,`thumbnail`,`watch`,`play`,`media`],create:()=>B(`content.video_thumbnail`,`Video`,[I(W(560,315,`▶ Watch`),`Video`,{width:560,link:`#`,borderRadius:8}),V(`Watch: a guided tour of our 2026 launches`,{paddingTop:12,paddingBottom:4}),U(`4 min watch`,{fontSize:13,paddingBottom:16})])},{type:`content.event_card`,category:`content`,name:`Event Card`,description:`Date badge with event title, location, time and an RSVP button. For event-driven newsletters and community digests.`,tags:[`event`,`rsvp`,`community`,`date`,`card`],create:()=>B(`content.event_card`,`Event`,[F(`MAY`,{align:`center`,color:`{colors.buttonText}`,fontSize:12,fontWeight:`bold`,letterSpacing:2,paddingTop:12,paddingBottom:0}),F(`12`,{align:`center`,color:`{colors.buttonText}`,fontSize:36,fontWeight:`bold`,paddingTop:0,paddingBottom:12})],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`content.code_block`,category:`content`,name:`Code Snippet`,description:`Monospaced code block on a tinted background. For developer newsletters and changelog excerpts.`,tags:[`code`,`snippet`,`developer`,`monospace`,`changelog`],create:()=>B(`content.code_block`,`Code`,[F(`npm install @one-million-lines/email-builder`,{fontFamily:`Menlo, Consolas, monospace`,fontSize:13,color:`{colors.text}`,paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16})}],Bo=[{type:`feature.list`,category:`feature`,name:`Checkmark Feature List`,description:`Centered title with 3-4 short checkmarked benefits. Good for product newsletters and onboarding emails.`,tags:[`features`,`benefits`,`checkmarks`,`list`],create:()=>B(`feature.list`,`Feature List`,[V(`Why people love it`,{align:`center`,paddingTop:24}),F(`✓ Fast and reliable`,{align:`center`}),F(`✓ Beautiful out of the box`,{align:`center`}),F(`✓ Backed by humans, not bots`,{align:`center`,paddingBottom:24})])},{type:`feature.icon_three`,category:`feature`,name:`Three Icon Features`,description:`Three stacked feature blocks with an emoji/icon, short title and one-line description. Use to highlight 3 product capabilities.`,tags:[`features`,`icons`,`three-up`,`product`],create:()=>B(`feature.icon_three`,`Three Features`,[F(`⚡`,{align:`center`,fontSize:32,paddingTop:24,paddingBottom:4}),F(`Fast`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),U(`Built to render in milliseconds.`,{align:`center`,fontSize:14}),R(16),F(`🧩`,{align:`center`,fontSize:32,paddingBottom:4}),F(`Modular`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),U(`Compose any layout from blocks.`,{align:`center`,fontSize:14}),R(16),F(`🤖`,{align:`center`,fontSize:32,paddingBottom:4}),F(`AI-ready`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),U(`Edit emails as JSON, not HTML.`,{align:`center`,fontSize:14,paddingBottom:24})])},{type:`feature.before_after`,category:`feature`,name:`Before / After`,description:`Two stacked images labeled 'Before' and 'After'. For product transformations, redesigns and case studies.`,tags:[`before-after`,`comparison`,`case-study`,`transformation`],create:()=>B(`feature.before_after`,`Before / After`,[H(`Before`),I(W(560,280,`Before`),`Before`,{width:560}),R(8),H(`After`),I(W(560,280,`After`),`After`,{width:560}),R(16)])},{type:`feature.benefit_pair`,category:`feature`,name:`Image + Benefit Pair`,description:`Repeat-use block: one supporting image plus a title and benefit paragraph beside it. Stack 2-3 of these for a feature tour.`,tags:[`benefit`,`feature`,`image-text`,`pair`],create:()=>B(`feature.benefit_pair`,`Benefit Pair`,[I(W(560,240,`Feature`),`Feature`,{width:560,paddingTop:16}),V(`Send 10x faster`,{paddingTop:12,paddingBottom:4}),F(`Reusable modules and theme tokens let teams ship campaigns in minutes, not days.`,{paddingBottom:24})])},{type:`feature.testimonial`,category:`feature`,name:`Testimonial`,description:`Customer quote in large type with avatar and attribution. Social proof block.`,tags:[`testimonial`,`review`,`social-proof`,`customer`],create:()=>B(`feature.testimonial`,`Testimonial`,[F(`“This cut our email production from a week to an afternoon.”`,{fontFamily:`{fonts.heading}`,fontSize:22,align:`center`,paddingTop:24,paddingBottom:12,lineHeight:1.4}),I(W(56,56,`👤`),`Customer`,{width:56,borderRadius:28}),F(`Alex Kim · Head of Lifecycle, Acme`,{align:`center`,color:`{colors.muted}`,fontSize:13,paddingTop:4,paddingBottom:24})])},{type:`feature.logo_strip`,category:`feature`,name:`Customer Logo Strip`,description:`Small horizontal row implying customer logos for credibility ('Trusted by'). Logos shown as a placeholder image.`,tags:[`logos`,`trusted-by`,`social-proof`,`strip`],create:()=>B(`feature.logo_strip`,`Logo Strip`,[U(`TRUSTED BY`,{align:`center`,fontSize:11}),I(W(520,60,`LOGOS`),`Customer logos`,{width:520,paddingTop:8,paddingBottom:16})])},{type:`feature.gradient_hero`,category:`feature`,name:`Gradient Hero CTA`,description:`Bold centered hero with an eyebrow, oversized headline and a primary CTA button. Great for launch announcements and campaign openers.`,tags:[`hero`,`launch`,`cta`,`bold`,`announcement`],create:()=>B(`feature.gradient_hero`,`Gradient Hero CTA`,[H(`Introducing`,{align:`center`}),V(`Something new is here`,{level:1,align:`center`,paddingTop:4,paddingBottom:8}),F(`A fresh way to reach your audience — crafted for the inbox.`,{align:`center`,color:`{colors.muted}`,fontSize:16,paddingBottom:20}),L(`Explore now`,`#`,{align:`center`})],{backgroundColor:`{colors.surface}`,paddingTop:40,paddingBottom:40})},{type:`feature.pull_quote`,category:`feature`,name:`Pull Quote`,description:`Large centered quotation with an attribution line. Use to highlight a testimonial or a memorable line.`,tags:[`quote`,`testimonial`,`highlight`,`pull-quote`],create:()=>B(`feature.pull_quote`,`Pull Quote`,[F(`“This is the fastest we’ve ever shipped a campaign.”`,{fontFamily:`{fonts.heading}`,fontSize:24,align:`center`,lineHeight:1.4,paddingTop:28,paddingBottom:8}),U(`— A very happy customer`,{align:`center`,paddingBottom:28})])},{type:`feature.stat_row`,category:`feature`,name:`Stat Row`,description:`Three short number + label pairs in a row. Use to show traction, metrics or highlights.`,tags:[`stats`,`metrics`,`numbers`,`row`,`kpi`],create:()=>B(`feature.stat_row`,`Stat Row`,[V(`By the numbers`,{align:`center`,paddingTop:24}),F(`<b>10k+</b> subscribers &nbsp;·&nbsp; <b>98%</b> delivery &nbsp;·&nbsp; <b>4.9★</b> rating`,{align:`center`,color:`{colors.muted}`,paddingBottom:24})])},{type:`feature.single_product_spotlight`,category:`feature`,name:`Single Product Spotlight`,description:`One product with image, name, price and buy button. Use to feature a hero product in a feature-focused email.`,tags:[`product`,`spotlight`,`single`,`buy`,`shop`,`ecommerce`],create:()=>B(`feature.single_product_spotlight`,`Product Spotlight`,[Se([G({name:`The Signature Bag`,finalPrice:`$129`,oldPrice:`$159`,description:`Handmade, built to last.`,image:W(520,520,`Product`)})],{columns:1,showDescription:!0,buttonLabel:`Buy now`})])},{type:`feature.pill_nav`,category:`feature`,name:`Pill Navigation`,description:`Centered row of navigation links with a divider below. Compact feature nav block for use inside email content sections.`,tags:[`menu`,`nav`,`links`,`pill`],create:()=>B(`feature.pill_nav`,`Pill Navigation`,[I(W(120,32,`LOGO`),`Logo`,{width:120,paddingBottom:8}),F(`<a href="#">Shop</a> &nbsp; <a href="#">New</a> &nbsp; <a href="#">Sale</a> &nbsp; <a href="#">About</a>`,{align:`center`,color:`{colors.primary}`,paddingBottom:8}),z({paddingTop:4,paddingBottom:0})])}],Vo=[{type:`cta.simple`,category:`call_to_action`,name:`Simple CTA`,description:`Centered headline + body + primary button. The default call-to-action block for any newsletter or promo.`,tags:[`cta`,`primary`,`centered`,`button`],create:()=>B(`cta.simple`,`Simple CTA`,[V(`Ready to get started?`,{align:`center`,paddingTop:24}),U(`Create better emails faster.`,{align:`center`}),L(`Start now`,`https://example.com`),R(16)])},{type:`cta.banner`,category:`call_to_action`,name:`Colored Banner CTA`,description:`Full-width colored band with eyebrow, big headline and a contrasting button. Use to draw attention to sales or launches.`,tags:[`cta`,`banner`,`colored`,`promo`,`sale`],create:()=>B(`cta.banner`,`CTA Banner`,[F(`Limited time offer`,{color:`{colors.buttonText}`,align:`center`,fontSize:14,paddingTop:24,paddingBottom:4}),F(`Save 30% this week only`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingBottom:16}),L(`Shop the sale`),R(24)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`cta.button_only`,category:`call_to_action`,name:`Button Only`,description:`Single primary button on a clean background. Use as a follow-up CTA after a content block.`,tags:[`cta`,`button`,`minimal`],create:()=>B(`cta.button_only`,`Button`,[L(`Click here`,`https://example.com`)])},{type:`cta.dual_button`,category:`call_to_action`,name:`Two Button Choice`,description:`Two side-by-side actions: a primary and a ghost-styled secondary. Use when offering 'Learn more' vs 'Get started'.`,tags:[`cta`,`buttons`,`two-options`,`choice`],create:()=>B(`cta.dual_button`,`Two Buttons`,[V(`Pick your path`,{align:`center`,paddingTop:24}),U(`Choose what fits your team.`,{align:`center`}),L(`Get started`,`https://example.com`),L(`Learn more`,`https://example.com`,{backgroundColor:`transparent`,color:`{colors.primary}`}),R(16)])},{type:`cta.image_overlay`,category:`call_to_action`,name:`Image + Overlay CTA`,description:`Lead image with a headline, supporting text, and a button immediately below. Strong visual call to action.`,tags:[`cta`,`image`,`visual`,`hero`],create:()=>B(`cta.image_overlay`,`Image CTA`,[I(W(560,280,`Visual`),`Visual`,{width:560,paddingTop:16}),V(`Stop guessing. Start measuring.`,{align:`center`,paddingTop:16}),U(`Free for 14 days. No credit card.`,{align:`center`}),L(`Try it free`),R(16)])},{type:`cta.subscribe`,category:`call_to_action`,name:`Subscribe / Forward`,description:`Friendly 'Was this forwarded? Subscribe' block that grows the list virally. Common at the end of newsletters.`,tags:[`cta`,`subscribe`,`forward`,`growth`,`newsletter`],create:()=>B(`cta.subscribe`,`Subscribe`,[H(`Was this forwarded?`,{align:`center`}),V(`Get the next issue in your inbox`,{align:`center`,paddingTop:0,paddingBottom:8}),L(`Subscribe free`),R(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})},{type:`cta.referral`,category:`call_to_action`,name:`Referral / Share`,description:`Encourages readers to share the newsletter with a unique referral link. Includes a 'Share' button and a personalized URL.`,tags:[`cta`,`referral`,`share`,`viral`,`growth`],create:()=>B(`cta.referral`,`Referral`,[H(`Tell a friend`,{align:`center`}),V(`Share & earn perks`,{align:`center`,paddingTop:0,paddingBottom:8}),U(`Refer 3 friends and unlock the bonus issue.`,{align:`center`}),F(`yourname.com/r/abc123`,{align:`center`,color:`{colors.primary}`,fontFamily:`Menlo, Consolas, monospace`,fontSize:14,paddingTop:8,paddingBottom:8}),L(`Share now`),R(16)])},{type:`cta.upgrade`,category:`call_to_action`,name:`Upgrade / Paid`,description:`Conversion block that promotes a paid plan or premium tier. Includes price, benefits and an upgrade button.`,tags:[`cta`,`upgrade`,`paid`,`premium`,`conversion`],create:()=>B(`cta.upgrade`,`Upgrade`,[H(`Become a member`,{align:`center`}),V(`$5 / month`,{align:`center`,level:1}),U(`Unlock the archive, weekly bonus and member chat.`,{align:`center`,fontSize:14}),L(`Upgrade`),R(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})},{type:`cta.feedback`,category:`call_to_action`,name:`Feedback Reply`,description:`Asks the reader to reply with feedback ('Hit reply and let me know'). Personal, no button.`,tags:[`cta`,`feedback`,`reply`,`personal`],create:()=>B(`cta.feedback`,`Feedback`,[F(`How did this issue land for you? Just hit reply — I read every message.`,{align:`center`,paddingTop:24,paddingBottom:24,lineHeight:1.6})])}],Ho=[{type:`ecom.product_single`,category:`ecommerce`,name:`Single Product`,description:`One product with image, title, price, short description and Buy button. Use to feature a hero product. Supports old/final price and per-product link.`,tags:[`product`,`single`,`buy`,`hero`],create:()=>B(`ecom.product_single`,`Single Product`,[Se([G({name:`Linen Tote Bag`,image:W(560,400,`Product`),oldPrice:`$59.00`,finalPrice:`$39.00`,description:`Heavyweight natural linen, made in Portugal.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`Buy now`})])},{type:`ecom.product_grid_2`,category:`ecommerce`,name:`Product Grid (2 up)`,description:`Two products side-by-side on desktop, stacked on mobile. Each card has image, name, old/final price, optional description and Shop button. Curated picks layout.`,tags:[`product`,`grid`,`two-up`,`curated`,`responsive`],create:()=>B(`ecom.product_grid_2`,`Product Grid 2`,[Se([G({name:`Product A`,finalPrice:`$29`,oldPrice:`$39`}),G({name:`Product B`,finalPrice:`$34`,oldPrice:`$45`})],{columns:2,showOldPrice:!0})])},{type:`ecom.product_grid_3`,category:`ecommerce`,name:`Product Grid (3 up)`,description:`Three product cards in a row on desktop, stacked on mobile. Use for 'New arrivals' or 'Bestsellers' rows.`,tags:[`product`,`grid`,`three-up`,`bestsellers`,`new-arrivals`,`responsive`],create:()=>B(`ecom.product_grid_3`,`Product Grid 3`,[H(`New arrivals`,{align:`center`}),Se([G({name:`Product 1`,finalPrice:`$19`}),G({name:`Product 2`,finalPrice:`$24`}),G({name:`Product 3`,finalPrice:`$32`})],{columns:3,showOldPrice:!1})])},{type:`ecom.collection_banner`,category:`ecommerce`,name:`Collection Banner`,description:`Wide collection banner with title and 'Shop the collection' button overlaying or under an image. Use for category drops.`,tags:[`collection`,`banner`,`category`,`drop`],create:()=>B(`ecom.collection_banner`,`Collection`,[I(W(560,300,`Collection`),`Collection`,{width:560}),V(`Spring Collection 2026`,{align:`center`,paddingTop:16}),U(`Lighter fabrics, brighter colors.`,{align:`center`}),L(`Shop the collection`),R(16)])},{type:`ecom.discount`,category:`ecommerce`,name:`Discount Code`,description:`Big discount code in monospaced caps with 'Your code' label and a Redeem button.`,tags:[`discount`,`promo`,`code`,`coupon`],create:()=>B(`ecom.discount`,`Discount Code`,[U(`Your code`,{align:`center`}),F(`SAVE20`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,color:`{colors.primary}`,letterSpacing:4,paddingTop:4,paddingBottom:16}),L(`Redeem`),R(24)])},{type:`ecom.voucher`,category:`ecommerce`,name:`Voucher Code`,description:`Personalized voucher block: 'Your code' label, a large voucher code and a Redeem button. With the voucher-select plugin, pick a code from your backend catalog; otherwise edit the code text directly.`,tags:[`voucher`,`coupon`,`discount`,`code`,`promo`,`redeem`],create:()=>B(`ecom.voucher`,`Voucher Code`,[U(`Your code`,{align:`center`}),be(`SAVE20`),L(`Redeem`),R(24)])},{type:`ecom.flash_sale`,category:`ecommerce`,name:`Flash Sale Banner`,description:`Urgency-driven banner with countdown-style copy ('Ends in 24h'), discount value and a shop button.`,tags:[`flash-sale`,`urgency`,`promo`,`banner`,`countdown`],create:()=>B(`ecom.flash_sale`,`Flash Sale`,[F(`⏰ FLASH SALE — ENDS IN 24H`,{color:`{colors.buttonText}`,align:`center`,fontWeight:`bold`,letterSpacing:2,paddingTop:16,paddingBottom:4}),F(`Up to 50% off everything`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingBottom:12}),L(`Shop now`,`#`,{backgroundColor:`{colors.surface}`,color:`{colors.primary}`}),R(16)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`ecom.abandoned_cart`,category:`ecommerce`,name:`Abandoned Cart Reminder`,description:`Friendly reminder showing the items left in the cart with a return-to-cart button. For cart recovery automations.`,tags:[`abandoned-cart`,`recovery`,`automation`,`reminder`],create:()=>B(`ecom.abandoned_cart`,`Abandoned Cart`,[V(`You left something behind`,{align:`center`,paddingTop:16}),U(`Pick up where you left off.`,{align:`center`}),R(8),Se([G({name:`Linen Tote Bag`,image:W(400,400,`Item`),finalPrice:`$39`,oldPrice:`$49`})],{columns:1,showOldPrice:!0,buttonLabel:`Return to cart`})])},{type:`ecom.review_request`,category:`ecommerce`,name:`Review Request`,description:`Post-purchase block asking for a 1-5 star rating with stacked star buttons. For review-collection emails.`,tags:[`review`,`rating`,`post-purchase`,`feedback`],create:()=>B(`ecom.review_request`,`Review`,[V(`How did we do?`,{align:`center`,paddingTop:24}),U(`Tap a star to leave a quick review.`,{align:`center`}),F(`☆ ☆ ☆ ☆ ☆`,{align:`center`,fontSize:32,color:`{colors.primary}`,paddingTop:12,paddingBottom:24,link:`#`})])},{type:`ecom.gift_guide`,category:`ecommerce`,name:`Gift Guide Pick`,description:`Editorial gift-guide pick: persona eyebrow + a single product card with full details (image, name, old/final price, description, CTA).`,tags:[`gift-guide`,`curated`,`editorial`,`holiday`],create:()=>B(`ecom.gift_guide`,`Gift Pick`,[H(`For the home cook`),Se([G({name:`Cast Iron Skillet`,image:W(560,300,`Pick`),oldPrice:`$119`,finalPrice:`$89`,description:`Pre-seasoned, lifetime-guarantee. Made in USA.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`View product`})])},{type:`ecom.bestseller_list`,category:`ecommerce`,name:`Bestseller Grid`,description:`Top products grid (3 up) with old/final prices. Used by retailers for weekly bestsellers.`,tags:[`bestsellers`,`grid`,`ranking`,`top`],create:()=>B(`ecom.bestseller_list`,`Bestsellers`,[H(`Top 3 this week`),Se([G({name:`Linen Tote`,finalPrice:`$39`,oldPrice:`$49`}),G({name:`Ceramic Mug`,finalPrice:`$24`}),G({name:`Brass Lamp`,finalPrice:`$129`,oldPrice:`$149`})],{columns:3,showOldPrice:!0})])}],Uo=[{type:`tx.order_summary`,category:`transactional`,name:`Order Summary`,description:`Order confirmation summary: order number, line items with thumbnails and totals row. Used in post-purchase emails.`,tags:[`order`,`summary`,`receipt`,`post-purchase`,`ecommerce`],create:()=>B(`tx.order_summary`,`Order Summary`,[H(`Order #1024`),V(`Thanks for your order`,{paddingTop:0}),U(`We'll email you again when it ships.`),z({paddingTop:16,paddingBottom:8}),F(`Linen Tote Bag · 1 × $39.00`,{paddingTop:4,paddingBottom:4}),F(`Ceramic Mug · 2 × $24.00`,{paddingTop:4,paddingBottom:4}),z({paddingTop:8,paddingBottom:8}),F(`Subtotal: $87.00`,{paddingTop:2,paddingBottom:2}),F(`Shipping: $5.00`,{paddingTop:2,paddingBottom:2}),F(`Total: $92.00`,{fontWeight:`bold`,paddingTop:2,paddingBottom:16})])},{type:`tx.shipping_update`,category:`transactional`,name:`Shipping Update`,description:`Shipping confirmation with tracking number, carrier, expected delivery date and a Track button.`,tags:[`shipping`,`tracking`,`delivery`,`post-purchase`],create:()=>B(`tx.shipping_update`,`Shipping Update`,[F(`📦`,{align:`center`,fontSize:40,paddingTop:24}),V(`Your order is on the way`,{align:`center`,paddingTop:8}),U(`Carrier: USPS · Expected: May 4, 2026`,{align:`center`}),F(`Tracking: 9400 1108 ...`,{align:`center`,color:`{colors.muted}`,fontFamily:`Menlo, Consolas, monospace`,fontSize:13}),L(`Track package`),R(16)])},{type:`tx.invoice`,category:`transactional`,name:`Invoice`,description:`Itemized invoice with billing period, services and totals. Used by SaaS and B2B billing emails.`,tags:[`invoice`,`billing`,`saas`,`b2b`,`receipt`],create:()=>B(`tx.invoice`,`Invoice`,[H(`Invoice INV-2026-04`),V(`April 2026 invoice`),U(`Billed to: Acme Inc · Period: Apr 1 – Apr 30`),z({paddingTop:16,paddingBottom:8}),F(`Pro plan · $49.00`,{paddingTop:4,paddingBottom:4}),F(`Add-on seats (3) · $36.00`,{paddingTop:4,paddingBottom:4}),z({paddingTop:8,paddingBottom:8}),F(`Total due: $85.00`,{fontWeight:`bold`,paddingBottom:16}),L(`Download invoice (PDF)`),R(16)])},{type:`tx.password_reset`,category:`transactional`,name:`Password Reset`,description:`Authentication email with a reset button and a fallback link. Includes 'expires in X minutes' notice.`,tags:[`auth`,`password`,`reset`,`security`],create:()=>B(`tx.password_reset`,`Password Reset`,[V(`Reset your password`,{align:`center`,paddingTop:16}),F(`Click the button below to set a new password. This link expires in 30 minutes.`,{align:`center`,paddingBottom:16}),L(`Reset password`),U(`If the button doesn't work, paste this link in your browser:`,{align:`center`,fontSize:12}),F(`https://example.com/reset/abc123`,{align:`center`,color:`{colors.primary}`,fontSize:12,paddingBottom:24})])},{type:`tx.verify_email`,category:`transactional`,name:`Verify Email`,description:`Single-purpose 'verify your email' transactional with one centered button.`,tags:[`auth`,`verify`,`email-confirmation`],create:()=>B(`tx.verify_email`,`Verify Email`,[V(`One last step`,{align:`center`,paddingTop:16}),F(`Confirm your email address to activate your account.`,{align:`center`,paddingBottom:8}),L(`Verify email`),R(24)])},{type:`tx.appointment`,category:`transactional`,name:`Appointment Confirmation`,description:`Booking/meeting confirmation with date, time, location and add-to-calendar links.`,tags:[`appointment`,`booking`,`calendar`,`meeting`],create:()=>B(`tx.appointment`,`Appointment`,[H(`Confirmed`,{align:`center`}),V(`Your appointment is set`,{align:`center`,paddingTop:0}),F(`Tuesday, May 12 · 10:00 AM`,{align:`center`,fontWeight:`bold`,paddingTop:8}),U(`123 Main St, Suite 4 · Brooklyn, NY`,{align:`center`}),L(`Add to calendar`),R(16)])}],Wo=[{type:`social.icons`,category:`social`,name:`Social Icons Row`,description:`Centered 'Follow us' label with text-link icons in a row. Light footer-style social block.`,tags:[`social`,`follow`,`icons`,`row`],create:()=>B(`social.icons`,`Social Icons`,[U(`Follow us`,{align:`center`}),F(`Twitter · Instagram · LinkedIn · YouTube`,{align:`center`,color:`{colors.primary}`,paddingBottom:16})])},{type:`social.share`,category:`social`,name:`Share This Email`,description:`'Share this email' bar with Forward · Tweet · Share text links. Used at the end of newsletters.`,tags:[`social`,`share`,`forward`,`viral`],create:()=>B(`social.share`,`Share Bar`,[F(`Share this email`,{align:`center`,paddingTop:8}),F(`Forward · Tweet · Share`,{align:`center`,color:`{colors.primary}`,paddingBottom:8})])},{type:`social.featured_post`,category:`social`,name:`Featured Social Post`,description:`Embed-style preview of a single social post: avatar, name, post text and a link to view it on the platform.`,tags:[`social`,`post`,`embed`,`twitter`,`instagram`],create:()=>B(`social.featured_post`,`Social Post`,[H(`From the community`),I(W(48,48,`👤`),`Avatar`,{width:48,borderRadius:24}),F(`@maker · 2h`,{color:`{colors.muted}`,fontSize:13,paddingTop:4,paddingBottom:4}),F(`"Just shipped my newsletter using OpenPostcards. Honestly the smoothest email build I've ever done."`,{paddingBottom:8,lineHeight:1.6}),F(`View on Twitter →`,{color:`{colors.primary}`,paddingBottom:16,link:`#`})])},{type:`social.instagram_grid`,category:`social`,name:`Instagram Grid`,description:`3 small square thumbnails in a row representing recent Instagram posts, with handle and link.`,tags:[`social`,`instagram`,`grid`,`thumbnails`],create:()=>B(`social.instagram_grid`,`IG Grid`,[U(`@youraccount on Instagram`,{align:`center`}),I(W(180,180,`1`),`Post 1`,{width:180}),I(W(180,180,`2`),`Post 2`,{width:180}),I(W(180,180,`3`),`Post 3`,{width:180}),F(`View profile →`,{align:`center`,color:`{colors.primary}`,paddingTop:8,paddingBottom:16,link:`#`})])},{type:`social.community_stats`,category:`social`,name:`Community Stats`,description:`Short '12k Twitter · 4k IG · 2k YT' style row used to show following sizes.`,tags:[`social`,`stats`,`community`,`following`],create:()=>B(`social.community_stats`,`Community Stats`,[H(`Join the community`,{align:`center`}),F(`12k Twitter · 4k Instagram · 2k YouTube`,{align:`center`,paddingBottom:16}),R(8)])}],Go={backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0},Ko=[{type:`footer.simple`,category:`footer`,name:`Simple Footer`,description:`Minimal footer with copyright, address and unsubscribe links. The default for any newsletter.`,tags:[`footer`,`simple`,`copyright`,`unsubscribe`],create:()=>B(`footer.simple`,`Simple Footer`,[U(`© 2026 Your Company. All rights reserved.`,{align:`center`,fontSize:12}),U(`123 Main St · City · Country`,{align:`center`,fontSize:12}),Ce([{label:`Unsubscribe`,type:`unsubscribe`},{label:`View in browser`,type:`view_in_browser`}])],{...Go,paddingTop:24})},{type:`footer.social`,category:`footer`,name:`Footer with Social`,description:`Footer with social links row above the legal text.`,tags:[`footer`,`social`,`links`],create:()=>B(`footer.social`,`Social Footer`,[F(`Follow us`,{align:`center`,paddingTop:24}),F(`Twitter · Instagram · LinkedIn`,{align:`center`,color:`{colors.primary}`,paddingBottom:12}),z(),U(`© 2026 Your Company`,{align:`center`,fontSize:12}),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Go)},{type:`footer.legal`,category:`footer`,name:`Legal Footer`,description:`Long-form footer with explanation of why the user is receiving the email plus privacy/terms/unsubscribe links. Used by enterprise and finance newsletters.`,tags:[`footer`,`legal`,`compliance`,`enterprise`],create:()=>B(`footer.legal`,`Legal Footer`,[F(`You are receiving this email because you signed up for our newsletter. If you no longer wish to receive emails, you can unsubscribe at any time.`,{align:`center`,color:`{colors.muted}`,fontSize:11,lineHeight:1.6,paddingTop:24}),Ce([{label:`Privacy Policy`,type:`user_profile`},{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Go)},{type:`footer.publisher`,category:`footer`,name:`Publisher Footer`,description:`Magazine-style sign-off with logo, publication name, masthead credits, address and links.`,tags:[`footer`,`publisher`,`magazine`,`masthead`,`editorial`],create:()=>B(`footer.publisher`,`Publisher Footer`,[I(W(120,36,`LOGO`),`Logo`,{width:120,paddingTop:24,paddingBottom:8}),F(`THE WEEKLY`,{align:`center`,fontFamily:`{fonts.heading}`,fontWeight:`bold`,letterSpacing:4,paddingTop:0,paddingBottom:4}),U(`Editor: Jane Doe · Producer: Alex Kim`,{align:`center`,fontSize:12}),z({paddingTop:12,paddingBottom:12}),U(`© 2026 The Weekly · 350 Madison Ave · NY 10017`,{align:`center`,fontSize:11}),Ce([{label:`Manage preferences`,type:`manage_preferences`},{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Go)},{type:`footer.app_links`,category:`footer`,name:`Footer with App Store Badges`,description:`Footer including 'Get the app' app-store and play-store badge images. For consumer brand newsletters.`,tags:[`footer`,`app`,`download`,`ios`,`android`],create:()=>B(`footer.app_links`,`App Footer`,[F(`Get the app`,{align:`center`,fontWeight:`bold`,paddingTop:24,paddingBottom:8}),I(W(135,40,`App Store`),`App Store`,{width:135,align:`center`,paddingTop:0,paddingBottom:4}),I(W(135,40,`Google Play`),`Google Play`,{width:135,align:`center`,paddingTop:0,paddingBottom:16}),z(),U(`© 2026 Your Brand`,{align:`center`,fontSize:11}),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Go)},{type:`footer.address_only`,category:`footer`,name:`Address Only`,description:`Just a centered postal address line — required for CAN-SPAM compliance when other footers are minimal.`,tags:[`footer`,`address`,`compliance`,`can-spam`],create:()=>B(`footer.address_only`,`Address`,[U(`Your Company · 123 Main St · Brooklyn, NY 11201 · USA`,{align:`center`,fontSize:11}),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:16})],{...Go,paddingTop:16})},{type:`footer.preferences`,category:`footer`,name:`Manage Preferences`,description:`Footer that emphasizes preference management ('Update your preferences', 'Send less often'). Reduces unsubscribes.`,tags:[`footer`,`preferences`,`frequency`,`retention`],create:()=>B(`footer.preferences`,`Preferences`,[F(`Getting too many emails?`,{align:`center`,paddingTop:24,paddingBottom:4}),Ce([{label:`Update your preferences`,type:`manage_preferences`},{label:`Unsubscribe`,type:`unsubscribe`}],{color:`{colors.primary}`,fontSize:13,paddingTop:4,paddingBottom:16}),z(),U(`© 2026 Your Company`,{align:`center`,fontSize:11}),F(` `,{align:`center`,paddingBottom:24})],Go)},{type:`footer.signature`,category:`footer`,name:`Signature Sign-off`,description:`Personal hand-signed style sign-off with author name and tiny legal block. For solo creator newsletters.`,tags:[`footer`,`signature`,`personal`,`creator`,`sign-off`],create:()=>B(`footer.signature`,`Signature`,[F(`Until next week,`,{paddingTop:24,paddingBottom:4}),F(`— Jane`,{fontFamily:`{fonts.heading}`,fontSize:22,paddingBottom:16}),z(),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{align:`left`,fontSize:11,paddingTop:4,paddingBottom:24,separator:` · `})],{...Go,paddingTop:0})}],qo=[...Io,...Lo,...Ro,...zo,...Bo,...Vo,...Ho,...Uo,...Wo,...Ko],Jo=!1;function Yo(){if(!Jo){for(let e of qo)Ie.register(e);Jo=!0}}Yo();function Xo(){let{doc:e,addModule:t,loadFromLocalStorage:n}=N();return(0,l.useEffect)(()=>{if(n(),N.getState().doc.modules.length===0){for(let e of[`header.hero`,`content.headline_body`,`cta.simple`,`footer.simple`]){let n=Ie.get(e);n&&t(n.create())}N.setState({selection:{kind:`email`},past:[],future:[]})}},[]),(0,l.useEffect)(()=>{let e=setTimeout(()=>N.getState().saveToLocalStorage(),500);return()=>clearTimeout(e)},[e]),(0,p.jsxs)(`div`,{className:`oml-email-builder h-full w-full flex flex-col bg-gray-100`,children:[(0,p.jsx)(je,{}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsx)(ot,{}),(0,p.jsx)(Xi,{}),(0,p.jsx)(so,{})]})]})}var Zo=e=>{if(e&&typeof e==`object`)return e;throw Error(`AI server returned a non-object response.`)};function Qo(e){let t=e.transformResponse??Zo,n=e.timeoutMs??6e4;return{async generate(r){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{let n=await fetch(e.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,body:JSON.stringify(r),signal:i.signal}),a=null,o=await n.text();try{a=o?JSON.parse(o):null}catch{}if(!n.ok){let e=(a&&typeof a==`object`&&`error`in a&&typeof a.error==`string`?a.error:null)??`AI request failed (HTTP ${n.status})`;throw Error(e)}return t(a)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`AI request timed out after ${n}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(a)}}}}function $o(e){let t=Qo(e);return{name:`ai-assistant`,type:`ai-provider`,setup(e){e.setAIProvider(t)}}}function es(e){if(e==null)return null;if(Array.isArray(e))return es(e[0]);if(typeof e!=`object`)return null;let t=e;for(let e of[`product`,`item`,`data`])if(t[e]&&typeof t[e]==`object`&&!Array.isArray(t[e]))return t[e];for(let e of[`results`,`products`,`items`,`hits`])if(Array.isArray(t[e]))return es(t[e]);return t}function ts(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t;if(typeof t==`number`)return String(t)}}function ns(e,t){for(let n of t){let t=e[n];if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`&&t.trim()!==``&&!Number.isNaN(Number(t)))return Number(t)}}var rs=e=>{let t=es(e);if(!t)return null;let n=ts(t,[`name`,`title`,`product_name`,`productName`]),r=ts(t,[`finalPrice`,`final_price`,`price`,`sale_price`,`salePrice`]);return!n||r==null?null:{name:n,finalPrice:r,oldPrice:ts(t,[`oldPrice`,`old_price`,`compare_at_price`,`compareAtPrice`,`list_price`,`listPrice`]),description:ts(t,[`description`,`desc`,`summary`]),link:ts(t,[`link`,`url`,`product_url`,`productUrl`,`permalink`]),image:ts(t,[`image`,`image_url`,`imageUrl`,`thumbnail`,`img`]),imageAlt:ts(t,[`imageAlt`,`image_alt`,`alt`]),stars:ns(t,[`stars`,`rating`,`review_score`,`reviewScore`,`score`]),sku:ts(t,[`sku`,`id`,`product_id`,`productId`])}};function is(e){let t=e.method??`GET`,n=e.queryParam??`q`,r=e.bodyParam??`query`,i=e.timeoutMs??15e3,a=e.transformResponse??rs;return{async search(o){let s=o.trim();if(!s)return null;let c=new AbortController,l=setTimeout(()=>c.abort(),i);try{let i=e.endpoint,o={method:t,headers:{...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,signal:c.signal};if(t===`GET`){let t=typeof location<`u`?location.href:void 0,r=new URL(e.endpoint,t);r.searchParams.set(n,s),i=r.toString()}else o.headers[`Content-Type`]=`application/json`,o.body=JSON.stringify({[r]:s});let l=await fetch(i,o),u=null,d=await l.text();try{u=d?JSON.parse(d):null}catch{}if(!l.ok){let e=(u&&typeof u==`object`&&`error`in u&&typeof u.error==`string`?u.error:null)??`Product search failed (HTTP ${l.status})`;throw Error(e)}return a(u)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`Product search timed out after ${i}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(l)}}}}function as(e){let t=is(e);return{name:`product-search`,type:`product-provider`,setup(e){e.registerProductProvider(t)}}}function os(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let t=e;for(let e of[`vouchers`,`results`,`items`,`data`,`coupons`])if(Array.isArray(t[e]))return t[e]}return[]}function ss(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t;if(typeof t==`number`)return String(t)}}var cs=e=>{let t=[];for(let n of os(e)){if(!n||typeof n!=`object`)continue;let e=n,r=ss(e,[`code`,`voucher_code`,`voucherCode`,`coupon`,`coupon_code`,`couponCode`,`value`]),i=ss(e,[`id`,`voucher_id`,`voucherId`,`uid`])??r;if(!i&&!r)continue;let a=ss(e,[`title`,`name`,`label`])??r??i??`Voucher`;t.push({id:i??a,title:a,code:r??i??a,description:ss(e,[`description`,`desc`,`summary`])})}return t};function ls(e){let t=e.method??`GET`,n=e.timeoutMs??15e3,r=e.transformResponse??cs;return{async list(){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{let n=await fetch(e.endpoint,{method:t,headers:{...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,signal:i.signal}),a=null,o=await n.text();try{a=o?JSON.parse(o):null}catch{}if(!n.ok){let e=(a&&typeof a==`object`&&`error`in a&&typeof a.error==`string`?a.error:null)??`Voucher request failed (HTTP ${n.status})`;throw Error(e)}return r(a)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`Voucher request timed out after ${n}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(a)}}}}function us(e){let t=ls(e);return{name:`voucher-select`,type:`voucher-provider`,setup(n){n.registerVoucherProvider(t),e.preload&&Ca()}}}var ds=e=>{if(e&&typeof e==`object`&&`url`in e&&typeof e.url==`string`){let t=e;return{url:t.url,alt:typeof t.alt==`string`?t.alt:void 0}}throw Error(`Server response missing "url" string field.`)};function fs(e){let t=e.fieldName??`file`,n=(e.maxSizeMB??10)*1024*1024,r=e.transformResponse??ds;return{upload(i){return i.type.startsWith(`image/`)?i.size>n?Promise.reject(Error(`File too large: ${(i.size/1024/1024).toFixed(2)} MB > ${e.maxSizeMB??10} MB`)):new Promise((n,a)=>{let o=new XMLHttpRequest,s=new FormData;if(s.append(t,i,i.name),o.open(`POST`,e.endpoint,!0),o.withCredentials=!!e.withCredentials,e.headers)for(let[t,n]of Object.entries(e.headers))o.setRequestHeader(t,n);e.onProgress&&o.upload&&(o.upload.onprogress=t=>{t.lengthComputable&&e.onProgress(Math.round(t.loaded/t.total*100))}),o.onload=()=>{let e=o.status>=200&&o.status<300,t=null;try{t=o.responseText?JSON.parse(o.responseText):null}catch{}if(!e){let e=(t&&typeof t==`object`&&`error`in t&&typeof t.error==`string`?t.error:null)??`Upload failed (HTTP ${o.status})`;return a(Error(e))}try{n(r(t))}catch(e){a(e instanceof Error?e:Error(String(e)))}},o.onerror=()=>a(Error(`Network error during upload`)),o.onabort=()=>a(Error(`Upload aborted`)),o.send(s)}):Promise.reject(Error(`Not an image: ${i.type||`unknown`}`))}}}function ps(e){return{name:`image-uploader`,type:`asset-provider`,setup(t){t.registerAssetProvider(fs(e))}}}function ms(e){return(0,l.useEffect)(()=>{if(Yo(),e.modules)for(let t of e.modules)Ie.register(t);if(e.themes&&N.setState({themes:e.themes}),e.aiProvider)Oa.setAIProvider(e.aiProvider);else if(e.aiEndpoint){let t=typeof e.aiEndpoint==`string`?{endpoint:e.aiEndpoint}:e.aiEndpoint;Oa.setAIProvider(Qo(t))}if(e.productProvider)Oa.registerProductProvider(e.productProvider);else if(e.productEndpoint){let t=typeof e.productEndpoint==`string`?{endpoint:e.productEndpoint}:e.productEndpoint;Oa.registerProductProvider(is(t))}if(e.voucherProvider)Oa.registerVoucherProvider(e.voucherProvider);else if(e.voucherEndpoint){let t=typeof e.voucherEndpoint==`string`?{endpoint:e.voucherEndpoint}:e.voucherEndpoint;Oa.registerVoucherProvider(ls(t)),typeof e.voucherEndpoint!=`string`&&e.voucherEndpoint.preload&&Ca()}if(e.mergeTags&&Oa.registerMergeTags(e.mergeTags),e.initialDocument){let t=b.safeParse(e.initialDocument);t.success&&N.getState().applyDoc(t.data,!1)}let t=N.subscribe((t,n)=>{t.doc!==n.doc&&e.onChange?.(t.doc)});return()=>t()},[]),(0,l.useEffect)(()=>{if(e.onExportHtml)return N.subscribe((t,n)=>{t.doc!==n.doc&&e.onExportHtml?.(A(t.doc))})},[e.onExportHtml]),(0,l.createElement)(Xo)}function hs(e){let t=(0,c.createRoot)(e.container);return t.render((0,l.createElement)(ms,e)),{destroy:()=>t.unmount(),getDocument:()=>N.getState().doc,exportHtml:()=>N.getState().exportHtml(),exportJson:()=>N.getState().exportJson()}}exports.ALGORITHMS=Ma,exports.ALGORITHM_BY_ID=Na,exports.EmailBuilder=ms,exports.FALLBACK_OPTIONS=Pa,exports.TEMPLATE_CATEGORY_LABELS=ve,exports.aiAssistantPlugin=$o,exports.applyAIActions=qe,exports.applyAIResponse=et,exports.buildCatalog=Ke,exports.createEmailBuilder=hs,exports.createHttpAIProvider=Qo,exports.createProductSearchProvider=is,exports.createVoucherProvider=ls,exports.defaultRecommendationsLogic=Fa,exports.documentSchema=b,exports.getActiveProductProvider=da,exports.getActiveVoucherProvider=xa,exports.imageUploaderPlugin=ps,exports.isVoucherAware=eo,exports.mockAIProvider=Xe,exports.productSearchPlugin=as,exports.readRecommendationsLogic=Ia,exports.recommendationsToLegacyShape=za,exports.registerPlugin=ka,exports.renderEmailHtml=A,exports.setActiveProductProvider=ua,exports.setActiveVoucherProvider=ba,exports.templateRegistry=P,exports.validateAIDocument=Ye,exports.voucherPlugin=us;
83
82
  //# sourceMappingURL=email-builder.cjs.map