1import{q as tn,r as u,aq as V,a_ as Je,j as n,y as k,h as ce,ac as ar,ab as $,s as X,a$ as Wn,b0 as Gn,B as q,D as Vn,c as Kn,d as Jn,e as Zn,aO as Qn,W as es,J as ts}from"./index-BvsqCpEz.js";import{u as Ct}from"./use-auth-4OwtEfAA.js";import{I as le}from"./input-BedoGODD.js";import{P as Ae,a as ke,b as Me}from"./popover-BRjrXi5Z.js";import{o as Dt,C as rs,T as lr,L as ns,I as rn,P as ss,A as Xt,q as nn,a as qt,b as Wt,c as Gt,d as Vt,e as Kt,f as Jt,g as Zt}from"./MemberDashboard-Cs5Sf23a.js";import{u as os,o as is,p as as,q as ls,B as cs,I as ds,s as us}from"./index-DRca1m3k.js";import{S as Lt,a as Ot,b as zt,c as Bt,d as ye}from"./select-kTbLcfik.js";import{D as sn,a as on,b as an,c as ln}from"./dropdown-menu-DO9fT12w.js";import{v as fs,u as hs}from"./upload-rules-DzRXK9g4.js";import{p as ps}from"./prepare-image-upload-Bby_BZou.js";import{G as ms}from"./grip-vertical-DGhBJjzw.js";import{S as pt,U as gs,P as Mr}from"./underline--YO5QER8.js";import{L as xs}from"./list-D2ETVdUl.js";import{L as vs}from"./list-ordered-BY2yW7CF.js";import{R as cn}from"./refresh-cw-Dooswkp8.js";import{T as Ir}from"./type-BG3_SsVW.js";import{E as bs}from"./eye-C3LPJZA8.js";import{L as ys}from"./label-Csx6IcxK.js";import{S as ws}from"./switch-D7vhGPpr.js";import{C as js}from"./calendar-CAkD_jWe.js";import{S as Ss}from"./send-BxN84Q5l.js";import{f as Fe}from"./format-Dogvratb.js";import{A as cr}from"./arrow-left-DasGo8Zs.js";import{S as dn}from"./save-Db8rM-xy.js";import{S as Ns}from"./sparkles-C7PiRczy.js";import"./index-5yHiP4fM.js";import"./wind-DW6YfAyS.js";import"./calendar-BX6XEece.js";import"./user-DLmK3dAG.js";import"./check-B97Uezjq.js";import"./download-0HDG1NIG.js";import"./index-CcpP0lgF.js";import"./with-selector-DZPceweq.js";import"./chevron-right-CPI6eVSm.js";import"./startOfMonth-Bq5nWt2t.js";import"./subDays-C60P-3D1.js";import"./chevron-left-DdeOtDWg.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Tt=tn("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Cs=tn("MoveDown",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);function Ds(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return u.useMemo(()=>s=>{t.forEach(o=>o(s))},t)}const Et=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function He(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function dr(e){return"nodeType"in e}function K(e){var t,r;return e?He(e)?e:dr(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function ur(e){const{Document:t}=K(e);return e instanceof t}function at(e){return He(e)?!1:e instanceof K(e).HTMLElement}function un(e){return e instanceof K(e).SVGElement}function Ue(e){return e?He(e)?e.document:dr(e)?ur(e)?e:at(e)||un(e)?e.ownerDocument:document:document:document}const me=Et?u.useLayoutEffect:u.useEffect;function fr(e){const t=u.useRef(e);return me(()=>{t.current=e}),u.useCallback(function(){for(var r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return t.current==null?void 0:t.current(...s)},[])}function Ts(){const e=u.useRef(null),t=u.useCallback((s,o)=>{e.current=setInterval(s,o)},[]),r=u.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function rt(e,t){t===void 0&&(t=[e]);const r=u.useRef(e);return me(()=>{r.current!==e&&(r.current=e)},t),r}function lt(e,t){const r=u.useRef();return u.useMemo(()=>{const s=e(r.current);return r.current=s,s},[...t])}function wt(e){const t=fr(e),r=u.useRef(null),s=u.useCallback(o=>{o!==r.current&&(t==null||t(o,r.current)),r.current=o},[]);return[r,s]}function Qt(e){const t=u.useRef();return u.useEffect(()=>{t.current=e},[e]),t.current}let _t={};function ct(e,t){return u.useMemo(()=>
11{if(t)return t;const r=_t[e]==null?0:_t[e]+1;return _t[e]=r,e+"-"+r},[e,t])}function fn(e){return function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return s.reduce((i,a)=>{const l=Object.entries(a);for(const[d,c]of l){const p=i[d];p!=null&&(i[d]=p+e*c)}return i},{...t})}}const _e=fn(1),nt=fn(-1);function Es(e){return"clientX"in e&&"clientY"in e}function hr(e){if(!e)return!1;const{KeyboardEvent:t}=K(e.target);return t&&e instanceof t}function Rs(e){if(!e)return!1;const{TouchEvent:t}=K(e.target);return t&&e instanceof t}function er(e){if(Rs(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return Es(e)?{x:e.clientX,y:e.clientY}:null}const st=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[st.Translate.toString(e),st.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:s}=e;return t+" "+r+"ms "+s}}}),$r="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function As(e){return e.matches($r)?e:e.querySelector($r)}const ks={display:"none"};function Ms(e){let{id:t,value:r}=e;return V.createElement("div",{id:t,style:ks},r)}function Is(e){let{id:t,announcement:r,ariaLiveType:s="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return V.createElement("div",{id:t,style:o,role:"status","aria-live":s,"aria-atomic":!0},r)}function $s(){const[e,t]=u.useState("");return{announce:u.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const hn=u.createContext(null);function Ls(e){const t=u.useContext(hn);u.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Os(){const[e]=u.useState(()=>new Set),t=u.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[u.useCallback(s=>{let{type:o,event:i}=s;e.forEach(a=>{var l;return(l=a[o])==null?void 0:l.call(a,i)})},[e]),t]}const zs={draggable:` 12 To pick up a draggable item, press the space bar. 13 While dragging, use the arrow keys to move the item. 14 Press space again to drop the item in its new position, or press escape to cancel. 15 `},Bs={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function _s(e){let{announcements:t=Bs,container:r,hiddenTextDescribedById:s,screenReaderInstructions:o=zs}=e;const{announce:i,announcement:a}=$s(),l=ct("DndLiveRegion"),[d,c]=u.useState(!1);if(u.useEffect(()=>{c(!0)},[]),Ls(u.useMemo(()=>({onDragStart(h){let{active:m}=h;i(t.onDragStart({active:m}))},onDragMove(h){let{active:m,over:f}=h;t.onDragMove&&i(t.onDragMove({active:m,over:f}))},onDragOver(h){let{active:m,over:f}=h;i(t.onDragOver({active:m,over:f}))},onDragEnd(h){let{active:m,over:f}=h;i(t.onDragEnd({active:m,over:f}))},onDragCancel(h){let{active:m,over:f}=h;i(t.onDragCancel({active:m,over:f}))}}),[i,t])),!d)return null;const p=V.createElement(V.Fragment,null,V.createElement(Ms,{id:s,value:o.draggable}),V.createElement(Is,{id:l,announcement:a}));return r?Je.createPortal(p,r):p}var F;(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"})(F||(F={}));function jt(){}function Lr(e,t){return u.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Ps(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return u.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const de=Object.freeze({x:0,y:0});function pn(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function mn(e,t){let{data:{value:r}}=e,{data:{value:s}}=t;return r-s}
15function Fs(e,t){let{data:{value:r}}=e,{data:{value:s}}=t;return s-r}function Or(e){let{left:t,top:r,height:s,width:o}=e;return[{x:t,y:r},{x:t+o,y:r},{x:t,y:r+s},{x:t+o,y:r+s}]}function gn(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function zr(e,t,r){return t===void 0&&(t=e.left),r===void 0&&(r=e.top),{x:t+e.width*.5,y:r+e.height*.5}}const Hs=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const o=zr(t,t.left,t.top),i=[];for(const a of s){const{id:l}=a,d=r.get(l);if(d){const c=pn(zr(d),o);i.push({id:l,data:{droppableContainer:a,value:c}})}}return i.sort(mn)},Us=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const o=Or(t),i=[];for(const a of s){const{id:l}=a,d=r.get(l);if(d){const c=Or(d),p=o.reduce((m,f,g)=>m+pn(c[g],f),0),h=Number((p/4).toFixed(4));i.push({id:l,data:{droppableContainer:a,value:h}})}}return i.sort(mn)};function Ys(e,t){const r=Math.max(t.top,e.top),s=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-s,l=i-r;if(s<o&&r<i){const d=t.width*t.height,c=e.width*e.height,p=a*l,h=p/(d+c-p);return Number(h.toFixed(4))}return 0}const Xs=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const o=[];for(const i of s){const{id:a}=i,l=r.get(a);if(l){const d=Ys(l,t);d>0&&o.push({id:a,data:{droppableContainer:i,value:d}})}}return o.sort(Fs)};function qs(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function xn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:de}function Ws(e){return function(r){for(var s=arguments.length,o=new Array(s>1?s-1:0),i=1;i<s;i++)o[i-1]=arguments[i];return o.reduce((a,l)=>({...a,top:a.top+e*l.y,bottom:a.bottom+e*l.y,left:a.left+e*l.x,right:a.right+e*l.x}),{...r})}}const Gs=Ws(1);function Vs(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Ks(e,t,r){const s=Vs(t);if(!s)return e;const{scaleX:o,scaleY:i,x:a,y:l}=s,d=e.left-a-(1-o)*parseFloat(r),c=e.top-l-(1-i)*parseFloat(r.slice(r.indexOf(" ")+1)),p=o?e.width/o:e.width,h=i?e.height/i:e.height;return{width:p,height:h,top:c,right:d+p,bottom:c+h,left:d}}const Js={ignoreTransform:!1};function Ye(e,t){t===void 0&&(t=Js);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:p}=K(e).getComputedStyle(e);c&&(r=Ks(r,c,p))}const{top:s,left:o,width:i,height:a,bottom:l,right:d}=r;return{top:s,left:o,width:i,height:a,bottom:l,right:d}}function Br(e){return Ye(e,{ignoreTransform:!0})}function Zs(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function Qs(e,t){return t===void 0&&(t=K(e).getComputedStyle(e)),t.position==="fixed"}function eo(e,t){t===void 0&&(t=K(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?r.test(i):!1})}function Rt(e,t){const r=[];function s(o){if(t!=null&&r.length>=t||!o)return r;if(ur(o)&&o.scrollingElement!=null&&!r.includes(o.scrollingElement))return r.push(o.scrollingElement),r;if(!at(o)||un(o)||r.includes(o))return r;const i=K(e).getComputedStyle(o);return o!==e&&eo(o,i)&&r.push(o),Qs(o,i)?r:s(o.parentNode)}return e?s(e):r}function vn(e){const[t]=Rt(e,1);return t??null}function Pt(e){return!Et||!e?null:He(e)?e:dr(e)?ur(e)||e===Ue(e).scrollingElement?window:at(e)?e:null:null}function bn(e){return He(e)?e.scrollX:e.scrollLeft}function yn(e){return He(e)?e.scrollY:e.scrollTop}function tr(e){return{x:bn(e),y:yn(e)}}var H;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(H||(H={}));function wn(e){return!Et||!e?!1:e===document.scrollingElement}function jn(e){const t={x:0,y:0},r=wn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,a=e.scrollTop>=s.y,l=e.scrollLeft>=s.x;return{isTop:o,isLeft:i,isBottom:a,isRight:l,maxScroll:s,minScroll:t}}const to={x:.2,y:.2};function ro(e,t,r,s,o){let{top:i,left:a,right:l,bottom:d}=r;s===void 0&&(s=10),o===void 0&&(o=to);const{isTop:c,isBottom:p,isLeft:h,isRight:m}=jn(e),f={x:0,y:0},g={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!c&&i<=t.top+v.height?(f.y=H.Backward,g.y=s*Math.abs((t.top+v.height-i)/v.height)):!p&&d>=t.bottom-v.height&&(f.y=H.Forward,g.y=s*Math.abs((t.bottom-v.height-d)/v.height)),!m&&l>=t.right-v.width?(f.x=H.Forward,g.x=s*Math.abs((t.right-v.width-l)/v.width)):!h&&a<=t.left+v.width&&(f.x=H.Backward,g.x=s*Math.abs((t.left+v.width-a)/v.width)),{direction:f,speed:g}}function no(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:a}=window;return{top:0,left:0,right:i,bottom:a,width:i,height:a}}const{top:t,left:r,right:s,bottom:o}=e.getBoundingClientRect();return{top:t,left:r,right:s,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Sn(e){return e.reduce((t,r)=>_e(t,tr(r)),de)}function so(e){return e.reduce((t,r)=>
15t+bn(r),0)}function oo(e){return e.reduce((t,r)=>t+yn(r),0)}function io(e,t){if(t===void 0&&(t=Ye),!e)return;const{top:r,left:s,bottom:o,right:i}=t(e);vn(e)&&(o<=0||i<=0||r>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ao=[["x",["left","right"],so],["y",["top","bottom"],oo]];class pr{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=Rt(r),o=Sn(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,a,l]of ao)for(const d of a)Object.defineProperty(this,d,{get:()=>{const c=l(s),p=o[i]-c;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ze{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...r)})},this.target=t}add(t,r,s){var o;(o=this.target)==null||o.addEventListener(t,r,s),this.listeners.push([t,r,s])}}function lo(e){const{EventTarget:t}=K(e);return e instanceof t?e:Ue(e)}function Ft(e,t){const r=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+s**2)>t:"x"in t&&"y"in t?r>t.x&&s>t.y:"x"in t?r>t.x:"y"in t?s>t.y:!1}var ae;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ae||(ae={}));function _r(e){e.preventDefault()}function co(e){e.stopPropagation()}var C;(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"})(C||(C={}));const Nn={start:[C.Space,C.Enter],cancel:[C.Esc],end:[C.Space,C.Enter,C.Tab]},uo=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case C.Right:return{...r,x:r.x+25};case C.Left:return{...r,x:r.x-25};case C.Down:return{...r,y:r.y+25};case C.Up:return{...r,y:r.y-25}}};class mr{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new Ze(Ue(r)),this.windowListeners=new Ze(K(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ae.Resize,this.handleCancel),this.windowListeners.add(ae.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ae.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,s=t.node.current;s&&io(s),r(de)}handleKeyDown(t){if(hr(t)){const{active:r,context:s,options:o}=this.props,{keyboardCodes:i=Nn,coordinateGetter:a=uo,scrollBehavior:l="smooth"}=o,{code:d}=t;if(i.end.includes(d)){this.handleEnd(t);return}if(i.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:c}=s.current,p=c?{x:c.left,y:c.top}:de;this.referenceCoordinates||(this.referenceCoordinates=p);const h=a(t,{active:r,context:s.current,currentCoordinates:p});if(h){const m=nt(h,p),f={x:0,y:0},{scrollableAncestors:g}=s.current;for(const v of g){const x=t.code,{isTop:y,isRight:w,isLeft:b,isBottom:N,maxScroll:T,minScroll:D}=jn(v),S=no(v),j={x:Math.min(x===C.Right?S.right-S.width/2:S.right,Math.max(x===C.Right?S.left:S.left+S.width/2,h.x)),y:Math.min(x===C.Down?S.bottom-S.height/2:S.bottom,Math.max(x===C.Down?S.top:S.top+S.height/2,h.y))},I=x===C.Right&&!w||x===C.Left&&!b,_=x===C.Down&&!N||x===C.Up&&!y;if(I&&j.x!==h.x){const A=v.scrollLeft+m.x,J=x===C.Right&&A<=T.x||x===C.Left&&A>=D.x;if(J&&!m.y){v.scrollTo({left:A,behavior:l});return}J?f.x=v.scrollLeft-A:f.x=x===C.Right?v.scrollLeft-T.x:v.scrollLeft-D.x,f.x&&v.scrollBy({left:-f.x,behavior:l});break}else if(_&&j.y!==h.y){const A=v.scrollTop+m.y,J=x===C.Down&&A<=T.y||x===C.Up&&A>=D.y;if(J&&!m.x){v.scrollTo({top:A,behavior:l});return}J?f.y=v.scrollTop-A:f.y=x===C.Down?v.scrollTop-T.y:v.scrollTop-D.y,f.y&&v.scrollBy({top:-f.y,behavior:l});break}}this.handleMove(t,_e(nt(h,this.referenceCoordinates),f))}}}handleMove(t,r){const{onMove:s}=this.props;t.preventDefault(),s(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}mr.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:s=Nn,onActivation:o}=t,{active:i}=r;const{code:a}=e.nativeEvent;if(s.start.includes(a)){const l=i.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function Pr(e){return!!(e&&"distance"in e)}function Fr(e){return!!(e&&"delay"in e)}class gr{constructor(t,r,s){var o;s===void 0&&(s=lo(t.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=t,this.events=r;const{event:i}=t,{target:a}=i;this.props=t,this.events=r,this.document=Ue(a),this.documentListeners=new Ze(this.document),this.listeners=new Ze(s),this.windowListeners=new Ze(K(a)),this.initialCoordinates=(o=er(i))!=null?o:de,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(ae.Resize,this.handleCancel),this.windowListeners.add(ae.DragStart,_r),this.windowListeners.add(ae.VisibilityChange,this.handleCancel),this.windowListeners.add(ae.ContextMenu,_r),this.documentListeners.add(ae.Keydown,this.handleKeydown),r){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Fr(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Pr(r)){this.handlePending(r);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(t,r){const{active:s,onPending:o}=this.props;o(s,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(ae.Click,co,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ae.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:s,initialCoordinates:o,props:i}=this,{onMove:a,options:{activationConstraint:l}}=i;if(!o)return;const d=(r=er(t))!=null?r:de,c=nt(o,d);if(!s&&l){if(Pr(l)){if(l.tolerance!=null&&Ft(c,l.tolerance))return this.handleCancel();if(Ft(c,l.distance))return this.handleStart()}if(Fr(l)&&Ft(c,l.tolerance))return this.handleCancel();this.handlePending(l,c);return}t.cancelable&&t.preventDefault(),a(d)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===C.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const fo={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class xr extends gr{constructor(t){const{event:r}=t,s=Ue(r.target);super(t,fo,s)}}xr.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return!r.isPrimary||r.button!==0?!1:(s==null||s({event:r}),!0)}}];const ho={move:{name:"mousemove"},end:{name:"mouseup"}};var rr;(function(e){e[e.RightClick=2]="RightClick"})(rr||(rr={}));class po extends gr{constructor(t){super(t,ho,Ue(t.event.target))}}po.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return r.button===rr.RightClick?!1:(s==null||s({event:r}),!0)}}];const Ht={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class mo extends gr{constructor(t){super(t,Ht)}static setup(){return window.addEventListener(Ht.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Ht.move.name,t)};function t(){}}}mo.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;const{touches:o}=r;return o.length>1?!1:(s==null||s({event:r}),!0)}}];var Qe;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Qe||(Qe={}));var St;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="Rever
15sedTreeOrder"})(St||(St={}));function go(e){let{acceleration:t,activator:r=Qe.Pointer,canScroll:s,draggingRect:o,enabled:i,interval:a=5,order:l=St.TreeOrder,pointerCoordinates:d,scrollableAncestors:c,scrollableAncestorRects:p,delta:h,threshold:m}=e;const f=vo({delta:h,disabled:!i}),[g,v]=Ts(),x=u.useRef({x:0,y:0}),y=u.useRef({x:0,y:0}),w=u.useMemo(()=>{switch(r){case Qe.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case Qe.DraggableRect:return o}},[r,o,d]),b=u.useRef(null),N=u.useCallback(()=>{const D=b.current;if(!D)return;const S=x.current.x*y.current.x,j=x.current.y*y.current.y;D.scrollBy(S,j)},[]),T=u.useMemo(()=>l===St.TreeOrder?[...c].reverse():c,[l,c]);u.useEffect(()=>{if(!i||!c.length||!w){v();return}for(const D of T){if((s==null?void 0:s(D))===!1)continue;const S=c.indexOf(D),j=p[S];if(!j)continue;const{direction:I,speed:_}=ro(D,j,w,t,m);for(const A of["x","y"])f[A][I[A]]||(_[A]=0,I[A]=0);if(_.x>0||_.y>0){v(),b.current=D,g(N,a),x.current=_,y.current=I;return}}x.current={x:0,y:0},y.current={x:0,y:0},v()},[t,N,s,v,i,a,JSON.stringify(w),JSON.stringify(f),g,c,T,p,JSON.stringify(m)])}const xo={x:{[H.Backward]:!1,[H.Forward]:!1},y:{[H.Backward]:!1,[H.Forward]:!1}};function vo(e){let{delta:t,disabled:r}=e;const s=Qt(t);return lt(o=>{if(r||!s||!o)return xo;const i={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[H.Backward]:o.x[H.Backward]||i.x===-1,[H.Forward]:o.x[H.Forward]||i.x===1},y:{[H.Backward]:o.y[H.Backward]||i.y===-1,[H.Forward]:o.y[H.Forward]||i.y===1}}},[r,t,s])}function bo(e,t){const r=t!=null?e.get(t):void 0,s=r?r.node.current:null;return lt(o=>{var i;return t==null?null:(i=s??o)!=null?i:null},[s,t])}function yo(e,t){return u.useMemo(()=>e.reduce((r,s)=>{const{sensor:o}=s,i=o.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,s)}));return[...r,...i]},[]),[e,t])}var ot;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ot||(ot={}));var nr;(function(e){e.Optimized="optimized"})(nr||(nr={}));const Hr=new Map;function wo(e,t){let{dragging:r,dependencies:s,config:o}=t;const[i,a]=u.useState(null),{frequency:l,measure:d,strategy:c}=o,p=u.useRef(e),h=x(),m=rt(h),f=u.useCallback(function(y){y===void 0&&(y=[]),!m.current&&a(w=>w===null?y:w.concat(y.filter(b=>!w.includes(b))))},[m]),g=u.useRef(null),v=lt(y=>{if(h&&!r)return Hr;if(!y||y===Hr||p.current!==e||i!=null){const w=new Map;for(let b of e){if(!b)continue;if(i&&i.length>0&&!i.includes(b.id)&&b.rect.current){w.set(b.id,b.rect.current);continue}const N=b.node.current,T=N?new pr(d(N),N):null;b.rect.current=T,T&&w.set(b.id,T)}return w}return y},[e,i,r,h,d]);return u.useEffect(()=>{p.current=e},[e]),u.useEffect(()=>{h||f()},[r,h]),u.useEffect(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),u.useEffect(()=>{h||typeof l!="number"||g.current!==null||(g.current=setTimeout(()=>{f(),g.current=null},l))},[l,h,f,...s]),{droppableRects:v,measureDroppableContainers:f,measuringScheduled:i!=null};function x(){switch(c){case ot.Always:return!1;case ot.BeforeDragging:return r;default:return!r}}}function Cn(e,t){return lt(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function jo(e,t){return Cn(e,t)}function So(e){let{callback:t,disabled:r}=e;const s=fr(t),o=u.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(s)},[s,r]);return u.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function At(e){let{callback:t,disabled:r}=e;const s=fr(t),o=u.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(s)},[r]);return u.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function No(e){return new pr(Ye(e),e)}function Ur(e,t,r){t===void 0&&(t=No);const[s,o]=u.useState(null);function i(){o(d=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=d??r)!=null?c:null}const p=t(e);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const a=So({callback(d){if(e)for(const c of d){const{type:p,target:h}=c;if(p==="childList"&&h instanceof HTMLElement&&h.contains(e)){i();break}}}}),l=At({callback:i});return me(()=>{i(),e?(l==null||l.observe(e),a==null||a.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),a==null||a.disconnect())},[e]),s}function Co(e){const t=Cn(e);return xn(e,t)}const Yr=[];function Do(e){const t=u.useRef(e),r=lt(s=>e?s&&s!==Yr&&e&&t.current&&e.parentNode===t.current.parentNode?s:Rt(e):Yr,[e]);return u.useEffect(()=>{t.current=e},[e]),r}function To(e){const[t,r]=u.useState(null),s=u.useRef(e),o=u.useCallback(i=>{const a=Pt(i.target);a&&r(l=>l?(l.set(a,tr(a)),new Map(l)):null)},[]);return u.useEffect(()=>{const i=s.current;if(e!==i){a(i);const l=e.map(d=>{const c=Pt(d);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,tr(c)]):null}).filter(d=>d!=null);r(l.length?new Map(l):null),s.current=e}return()=>{a(e),a(i)};function a(l){l.forEach(d=>{const c=Pt(d);c==null||c.removeEventListener("scroll",o)})}},[o,e]),u.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,a)=>_e(i,a),de):Sn(e):de,[e,t])}function Xr(e,t){t===void 0&&(t=[]);const r=u.useRef(null);return u.useEffect(()=>{r.current=null},t),u.useEffect(()=>{const s=e!==de;s&&!r.current&&(r.current=e),!s&&r.current&&(r.current=null)},[e]),r.current?nt(e,r.current):de}function Eo(e){u.useEffect(()=>{if(!Et)return;const t=e.map(r=>{let{sensor:s}=r;return s.setup==null?void 0:s.setup()});return()=>{for(const r of t)r==null||r()}},e.map(t=>{let{sensor:r}=t;return r}))}function Ro(e,t){return u.useMemo(()=>e.reduce((r,s)=>{let{eventName:o,handler:i}=s;return r[o]=a=>{i(a,t)},r},{}),[e,t])}function Dn(e){return u.useMemo(()=>e?Zs(e):null,[e])}const qr=[];function Ao(e,t){t===void 0&&(t=Ye);const[r]=e,s=Dn(r?K(r):null),[o,i]=u.useState(qr);function a(){i(()=>e.length?e.map(d=>wn(d)?s:new pr(t(d),d)):qr)}const l=At({callback:a});return me(()=>{l==null||l.disconnect(),a(),e.forEach(d=>l==null?void 0:l.observe(d))},[e]),o}function ko(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return at(t)?t:e}function Mo(e){let{measure:t}=e;const[r,s]=u.useState(null),o=u.useCallback(c=>{for(const{target:p}of c)if(at(p)){s(h=>{const m=t(p);return h?{...h,width:m.width,height:m.height}:m});break}},[t]),i=At({callback:o}),a=u.useCallback(c=>{const p=ko(c);i==null||i.disconnect(),p&&(i==null||i.observe(p)),s(p?t(p):null)},[t,i]),[l,d]=wt(a);return u.useMemo(()=>({nodeRef:l,rect:r,setRef:d}),[r,l,d])}const Io=[{sensor:xr,options:{}},{sensor:mr,options:{}}],$o={current:{}},yt={draggable:{measure:Br},droppable:{measure:Br,strategy:ot.WhileDragging,frequency:nr.Optimized},dragOverlay:{measure:Ye}};class et extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,s;return(r=(s=this.get(t))==null?void 0:s.node.current)!=null?r:void 0}}const Lo={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new et,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:jt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:yt,measureDroppableContainers:jt,windowRect:null,measuringScheduled:!1},Oo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:jt,draggableNodes:new Map,over:null,measureDroppableContainers:jt},kt=u.createContext(Oo),Tn=u.createContext(Lo);function zo(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new et}}}function Bo(e,t){switch(t.type){case F.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case F.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 F.DragEnd:case F.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case F.RegisterDroppable:{const{element:r}=t,{id:s}
15=r,o=new et(e.droppable.containers);return o.set(s,r),{...e,droppable:{...e.droppable,containers:o}}}case F.SetDroppableDisabled:{const{id:r,key:s,disabled:o}=t,i=e.droppable.containers.get(r);if(!i||s!==i.key)return e;const a=new et(e.droppable.containers);return a.set(r,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case F.UnregisterDroppable:{const{id:r,key:s}=t,o=e.droppable.containers.get(r);if(!o||s!==o.key)return e;const i=new et(e.droppable.containers);return i.delete(r),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function _o(e){let{disabled:t}=e;const{active:r,activatorEvent:s,draggableNodes:o}=u.useContext(kt),i=Qt(s),a=Qt(r==null?void 0:r.id);return u.useEffect(()=>{if(!t&&!s&&i&&a!=null){if(!hr(i)||document.activeElement===i.target)return;const l=o.get(a);if(!l)return;const{activatorNode:d,node:c}=l;if(!d.current&&!c.current)return;requestAnimationFrame(()=>{for(const p of[d.current,c.current]){if(!p)continue;const h=As(p);if(h){h.focus();break}}})}},[s,t,o,a,i]),null}function Po(e,t){let{transform:r,...s}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...s}),r):r}function Fo(e){return u.useMemo(()=>({draggable:{...yt.draggable,...e==null?void 0:e.draggable},droppable:{...yt.droppable,...e==null?void 0:e.droppable},dragOverlay:{...yt.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function Ho(e){let{activeNode:t,measure:r,initialRect:s,config:o=!0}=e;const i=u.useRef(!1),{x:a,y:l}=typeof o=="boolean"?{x:o,y:o}:o;me(()=>{if(!a&&!l||!t){i.current=!1;return}if(i.current||!s)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const p=r(c),h=xn(p,s);if(a||(h.x=0),l||(h.y=0),i.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const m=vn(c);m&&m.scrollBy({top:h.y,left:h.x})}},[t,a,l,s,r])}const En=u.createContext({...de,scaleX:1,scaleY:1});var Te;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Te||(Te={}));const Uo=u.memo(function(t){var r,s,o,i;let{id:a,accessibility:l,autoScroll:d=!0,children:c,sensors:p=Io,collisionDetection:h=Xs,measuring:m,modifiers:f,...g}=t;const v=u.useReducer(Bo,void 0,zo),[x,y]=v,[w,b]=Os(),[N,T]=u.useState(Te.Uninitialized),D=N===Te.Initialized,{draggable:{active:S,nodes:j,translate:I},droppable:{containers:_}}=x,A=S!=null?j.get(S):null,J=u.useRef({initial:null,translated:null}),Z=u.useMemo(()=>{var Y;return S!=null?{id:S,data:(Y=A==null?void 0:A.data)!=null?Y:$o,rect:J}:null},[S,A]),R=u.useRef(null),[Q,se]=u.useState(null),[L,W]=u.useState(null),O=rt(g,Object.values(g)),ue=ct("DndDescribedBy",a),dt=u.useMemo(()=>_.getEnabled(),[_]),G=Fo(m),{droppableRects:ge,measureDroppableContainers:Re,measuringScheduled:Xe}=wo(dt,{dragging:D,dependencies:[I.x,I.y],config:G.droppable}),oe=bo(j,S),ut=u.useMemo(()=>L?er(L):null,[L]),we=qn(),xe=jo(oe,G.draggable.measure);Ho({activeNode:S!=null?j.get(S):null,config:we.layoutShiftCompensation,initialRect:xe,measure:G.draggable.measure});const E=Ur(oe,G.draggable.measure,xe),qe=Ur(oe?oe.parentElement:null),fe=u.useRef({activatorEvent:null,active:null,activeNode:oe,collisionRect:null,collisions:null,droppableRects:ge,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:_,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ie=_.getNodeFor((r=fe.current.over)==null?void 0:r.id),ve=Mo({measure:G.dragOverlay.measure}),$e=(s=ve.nodeRef.current)!=null?s:oe,Le=D?(o=ve.rect)!=null?o:E:null,Nr=!!(ve.nodeRef.current&&ve.rect),Cr=Co(Nr?null:E),Mt=Dn($e?K($e):null),je=Do(D?Ie??oe:null),ft=Ao(je),ht=Po(f,{transform:{x:I.x-Cr.x,y:I.y-Cr.y,scaleX:1,scaleY:1},activatorEvent:L,active:Z,activeNodeRect:E,containerNodeRect:qe,draggingNodeRect:Le,over:fe.current.over,overlayNodeRect:ve.rect,scrollableAncestors:je,scrollableAncestorRects:ft,windowRect:Mt}),Dr=ut?_e(ut,I):null,Tr=To(je),_n=Xr(Tr),Pn=Xr(Tr,[E]),Oe=_e(ht,_n),ze=Le?Gs(Le,ht):null,We=Z&&ze?h({active:Z,collisionRect:ze,droppableRects:ge,droppableContainers:dt,pointerCoordinates:Dr}):null,Er=gn(We,"id"),[Se,Rr]=u.useState(null),Fn=Nr?ht:_e(ht,Pn),Hn=qs(Fn,(i=Se==null?void 0:Se.rect)!=null?i:null,E),It=u.useRef(null),Ar=u.useCallback((Y,ee)=>{let{sensor:te,options:Ne}=ee;if(R.current==null)return;const ie=j.get(R.current);if(!ie)return;const re=Y.nativeEvent,he=new te({active:R.current,activeNode:ie,event:re,options:Ne,context:fe,onAbort(U){if(!j.get(U))return;const{onDragAbort:pe}=O.current,be={id:U};pe==null||pe(be),w({type:"onDragAbort",event:be})},onPending(U,Ce,pe,be){if(!j.get(U))return;const{onDragPending:Ve}=O.current,De={id:U,constraint:Ce,initialCoordinates:pe,offset:be};Ve==null||Ve(De),w({type:"onDragPending",event:De})},onStart(U){const Ce=R.current;if(Ce==null)return;const pe=j.get(Ce);if(!pe)return;const{onDragStart:be}=O.current,Ge={activatorEvent:re,active:{id:Ce,data:pe.data,rect:J}};Je.unstable_batchedUpdates(()=>{be==null||be(Ge),T(Te.Initializing),y({type:F.DragStart,initialCoordinates:U,active:Ce}),w({type:"onDragStart",event:Ge}),se(It.current),W(re)})},onMove(U){y({type:F.DragMove,coordinates:U})},onEnd:Be(F.DragEnd),onCancel:Be(F.DragCancel)});It.current=he;function Be(U){return async function(){const{active:pe,collisions:be,over:Ge,scrollAdjustedTranslate:Ve}=fe.current;let De=null;if(pe&&Ve){const{cancelDrop:Ke}=O.current;De={activatorEvent:re,active:pe,collisions:be,delta:Ve,over:Ge},U===F.DragEnd&&typeof Ke=="function"&&await Promise.resolve(Ke(De))&&(U=F.DragCancel)}R.current=null,Je.unstable_batchedUpdates(()=>{y({type:U}),T(Te.Uninitialized),Rr(null),se(null),W(null),It.current=null;const Ke=U===F.DragEnd?"onDragEnd":"onDragCancel";if(De){const $t=O.current[Ke];$t==null||$t(De),w({type:Ke,event:De})}})}}},[j]),Un=u.useCallback((Y,ee)=>(te,Ne)=>{const ie=te.nativeEvent,re=j.get(Ne);if(R.current!==null||!re||ie.dndKit||ie.defaultPrevented)return;const he={active:re};Y(te,ee.options,he)===!0&&(ie.dndKit={capturedBy:ee.sensor},R.current=Ne,Ar(te,ee))},[j,Ar]),kr=yo(p,Un);Eo(p),me(()=>{E&&N===Te.Initializing&&T(Te.Initialized)},[E,N]),u.useEffect(()=>{const{onDragMove:Y}=O.current,{active:ee,activatorEvent:te,collisions:Ne,over:ie}=fe.current;if(!ee||!te)return;const re={active:ee,activatorEvent:te,collisions:Ne,delta:{x:Oe.x,y:Oe.y},over:ie};Je.unstable_batchedUpdates(()=>{Y==null||Y(re),w({type:"onDragMove",event:re})})},[Oe.x,Oe.y]),u.useEffect(()=>{const{active:Y,activatorEvent:ee,collisions:te,droppableContainers:Ne,scrollAdjustedTranslate:ie}=fe.current;if(!Y||R.current==null||!ee||!ie)return;const{onDragOver:re}=O.current,he=Ne.get(Er),Be=he&&he.rect.current?{id:he.id,rect:he.rect.current,data:he.data,disabled:he.disabled}:null,U={active:Y,activatorEvent:ee,collisions:te,delta:{x:ie.x,y:ie.y},over:Be};Je.unstable_batchedUpdates(()=>
15{Rr(Be),re==null||re(U),w({type:"onDragOver",event:U})})},[Er]),me(()=>{fe.current={activatorEvent:L,active:Z,activeNode:oe,collisionRect:ze,collisions:We,droppableRects:ge,draggableNodes:j,draggingNode:$e,draggingNodeRect:Le,droppableContainers:_,over:Se,scrollableAncestors:je,scrollAdjustedTranslate:Oe},J.current={initial:Le,translated:ze}},[Z,oe,We,ze,j,$e,Le,ge,_,Se,je,Oe]),go({...we,delta:I,draggingRect:ze,pointerCoordinates:Dr,scrollableAncestors:je,scrollableAncestorRects:ft});const Yn=u.useMemo(()=>({active:Z,activeNode:oe,activeNodeRect:E,activatorEvent:L,collisions:We,containerNodeRect:qe,dragOverlay:ve,draggableNodes:j,droppableContainers:_,droppableRects:ge,over:Se,measureDroppableContainers:Re,scrollableAncestors:je,scrollableAncestorRects:ft,measuringConfiguration:G,measuringScheduled:Xe,windowRect:Mt}),[Z,oe,E,L,We,qe,ve,j,_,ge,Se,Re,je,ft,G,Xe,Mt]),Xn=u.useMemo(()=>({activatorEvent:L,activators:kr,active:Z,activeNodeRect:E,ariaDescribedById:{draggable:ue},dispatch:y,draggableNodes:j,over:Se,measureDroppableContainers:Re}),[L,kr,Z,E,y,ue,j,Se,Re]);return V.createElement(hn.Provider,{value:b},V.createElement(kt.Provider,{value:Xn},V.createElement(Tn.Provider,{value:Yn},V.createElement(En.Provider,{value:Hn},c)),V.createElement(_o,{disabled:(l==null?void 0:l.restoreFocus)===!1})),V.createElement(_s,{...l,hiddenTextDescribedById:ue}));function qn(){const Y=(Q==null?void 0:Q.autoScrollEnabled)===!1,ee=typeof d=="object"?d.enabled===!1:d===!1,te=D&&!Y&&!ee;return typeof d=="object"?{...d,enabled:te}:{enabled:te}}}),Yo=u.createContext(null),Wr="button",Xo="Draggable";function qo(e){let{id:t,data:r,disabled:s=!1,attributes:o}=e;const i=ct(Xo),{activators:a,activatorEvent:l,active:d,activeNodeRect:c,ariaDescribedById:p,draggableNodes:h,over:m}=u.useContext(kt),{role:f=Wr,roleDescription:g="draggable",tabIndex:v=0}=o??{},x=(d==null?void 0:d.id)===t,y=u.useContext(x?En:Yo),[w,b]=wt(),[N,T]=wt(),D=Ro(a,t),S=rt(r);me(()=>(h.set(t,{id:t,key:i,node:w,activatorNode:N,data:S}),()=>{const I=h.get(t);I&&I.key===i&&h.delete(t)}),[h,t]);const j=u.useMemo(()=>({role:f,tabIndex:v,"aria-disabled":s,"aria-pressed":x&&f===Wr?!0:void 0,"aria-roledescription":g,"aria-describedby":p.draggable}),[s,f,v,x,g,p.draggable]);return{active:d,activatorEvent:l,activeNodeRect:c,attributes:j,isDragging:x,listeners:s?void 0:D,node:w,over:m,setNodeRef:b,setActivatorNodeRef:T,transform:y}}function Wo(){return u.useContext(Tn)}const Go="Droppable",Vo={timeout:25};function Ko(e){let{data:t,disabled:r=!1,id:s,resizeObserverConfig:o}=e;const i=ct(Go),{active:a,dispatch:l,over:d,measureDroppableContainers:c}=u.useContext(kt),p=u.useRef({disabled:r}),h=u.useRef(!1),m=u.useRef(null),f=u.useRef(null),{disabled:g,updateMeasurementsFor:v,timeout:x}={...Vo,...o},y=rt(v??s),w=u.useCallback(()=>{if(!h.current){h.current=!0;return}f.current!=null&&clearTimeout(f.current),f.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),f.current=null},x)},[x]),b=At({callback:w,disabled:g||!a}),N=u.useCallback((j,I)=>{b&&(I&&(b.unobserve(I),h.current=!1),j&&b.observe(j))},[b]),[T,D]=wt(N),S=rt(t);return u.useEffect(()=>{!b||!T.current||(b.disconnect(),h.current=!1,b.observe(T.current))},[T,b]),u.useEffect(()=>(l({type:F.RegisterDroppable,element:{id:s,key:i,disabled:r,node:T,rect:m,data:S}}),()=>l({type:F.UnregisterDroppable,key:i,id:s})),[s]),u.useEffect(()=>{r!==p.current.disabled&&(l({type:F.SetDroppableDisabled,id:s,key:i,disabled:r}),p.current.disabled=r)},[s,i,r,l]),{active:a,rect:m,isOver:(d==null?void 0:d.id)===s,node:T,over:d,setNodeRef:D}}function vr(e,t,r){const s=e.slice();return s.splice(r<0?s.length+r:r,0,s.splice(t,1)[0]),s}function Jo(e,t){return e.reduce((r,s,o)=>{const i=t.get(s);return i&&(r[o]=i),r},Array(e.length))}function mt(e){return e!==null&&e>=0}function Zo(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function Qo(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Rn=e=>{let{rects:t,activeIndex:r,overIndex:s,index:o}=e;const i=vr(t,s,r),a=t[o],l=i[o];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},gt={scaleX:1,scaleY:1},ei=e=>{var t;let{activeIndex:r,activeNodeRect:s,index:o,rects:i,overIndex:a}=e;const l=(t=i[r])!=null?t:s;if(!l)return null;if(o===r){const c=i[a];return c?{x:0,y:r<a?c.top+c.height-(l.top+l.height):c.top-l.top,...gt}:null}const d=ti(i,o,r);return o>r&&o<=a?{x:0,y:-l.height-d,...gt}:o<r&&o>
15=a?{x:0,y:l.height+d,...gt}:{x:0,y:0,...gt}};function ti(e,t,r){const s=e[t],o=e[t-1],i=e[t+1];return s?r<t?o?s.top-(o.top+o.height):i?i.top-(s.top+s.height):0:i?i.top-(s.top+s.height):o?s.top-(o.top+o.height):0:0}const An="Sortable",kn=V.createContext({activeIndex:-1,containerId:An,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Rn,disabled:{draggable:!1,droppable:!1}});function ri(e){let{children:t,id:r,items:s,strategy:o=Rn,disabled:i=!1}=e;const{active:a,dragOverlay:l,droppableRects:d,over:c,measureDroppableContainers:p}=Wo(),h=ct(An,r),m=l.rect!==null,f=u.useMemo(()=>s.map(D=>typeof D=="object"&&"id"in D?D.id:D),[s]),g=a!=null,v=a?f.indexOf(a.id):-1,x=c?f.indexOf(c.id):-1,y=u.useRef(f),w=!Zo(f,y.current),b=x!==-1&&v===-1||w,N=Qo(i);me(()=>{w&&g&&p(f)},[w,f,g,p]),u.useEffect(()=>{y.current=f},[f]);const T=u.useMemo(()=>({activeIndex:v,containerId:h,disabled:N,disableTransforms:b,items:f,overIndex:x,useDragOverlay:m,sortedRects:Jo(f,d),strategy:o}),[v,h,N.draggable,N.droppable,b,f,x,d,m,o]);return V.createElement(kn.Provider,{value:T},t)}const ni=e=>{let{id:t,items:r,activeIndex:s,overIndex:o}=e;return vr(r,s,o).indexOf(t)},si=e=>{let{containerId:t,isSorting:r,wasDragging:s,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:d,transition:c}=e;return!c||!s||l!==i&&o===a?!1:r?!0:a!==o&&t===d},oi={duration:200,easing:"ease"},Mn="transform",ii=st.Transition.toString({property:Mn,duration:0,easing:"linear"}),ai={roleDescription:"sortable"};function li(e){let{disabled:t,index:r,node:s,rect:o}=e;const[i,a]=u.useState(null),l=u.useRef(r);return me(()=>{if(!t&&r!==l.current&&s.current){const d=o.current;if(d){const c=Ye(s.current,{ignoreTransform:!0}),p={x:d.left-c.left,y:d.top-c.top,scaleX:d.width/c.width,scaleY:d.height/c.height};(p.x||p.y)&&a(p)}}r!==l.current&&(l.current=r)},[t,r,s,o]),u.useEffect(()=>{i&&a(null)},[i]),i}function ci(e){let{animateLayoutChanges:t=si,attributes:r,disabled:s,data:o,getNewIndex:i=ni,id:a,strategy:l,resizeObserverConfig:d,transition:c=oi}=e;const{items:p,containerId:h,activeIndex:m,disabled:f,disableTransforms:g,sortedRects:v,overIndex:x,useDragOverlay:y,strategy:w}=u.useContext(kn),b=di(s,f),N=p.indexOf(a),T=u.useMemo(()=>({sortable:{containerId:h,index:N,items:p},...o}),[h,o,N,p]),D=u.useMemo(()=>p.slice(p.indexOf(a)),[p,a]),{rect:S,node:j,isOver:I,setNodeRef:_}=Ko({id:a,data:T,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:D,...d}}),{active:A,activatorEvent:J,activeNodeRect:Z,attributes:R,setNodeRef:Q,listeners:se,isDragging:L,over:W,setActivatorNodeRef:O,transform:ue}=qo({id:a,data:T,attributes:{...ai,...r},disabled:b.draggable}),dt=Ds(_,Q),G=!!A,ge=G&&!g&&mt(m)&&mt(x),Re=!y&&L,Xe=Re&&ge?ue:null,ut=ge?Xe??(l??w)({rects:v,activeNodeRect:Z,activeIndex:m,overIndex:x,index:N}):null,we=mt(m)&&mt(x)?i({id:a,items:p,activeIndex:m,overIndex:x}):N,xe=A==null?void 0:A.id,E=u.useRef({activeId:xe,items:p,newIndex:we,containerId:h}),qe=p!==E.current.items,fe=t({active:A,containerId:h,isDragging:L,isSorting:G,id:a,index:N,items:p,newIndex:E.current.newIndex,previousItems:E.current.items,previousContainerId:E.current.containerId,transition:c,wasDragging:E.current.activeId!=null}),Ie=li({disabled:!fe,index:N,node:j,rect:S});return u.useEffect(()=>{G&&E.current.newIndex!==we&&(E.current.newIndex=we),h!==E.current.containerId&&(E.current.containerId=h),p!==E.current.items&&(E.current.items=p)},[G,we,h,p]),u.useEffect(()=>{if(xe===E.current.activeId)return;if(xe!=null&&E.current.activeId==null){E.current.activeId=xe;return}const $e=setTimeout(()=>{E.current.activeId=xe},50);return()=>clearTimeout($e)},[xe]),{active:A,activeIndex:m,attributes:R,data:T,rect:S,index:N,newIndex:we,items:p,isOver:I,isSorting:G,isDragging:L,listeners:se,node:j,overIndex:x,over:W,setNodeRef:dt,setActivatorNodeRef:O,setDroppableNodeRef:_,setDraggableNodeRef:Q,transform:Ie??ut,transition:ve()};function ve(){if(Ie||qe&&E.current.newIndex===N)return ii;if(!(Re&&!hr(J)||!c)&&(G||fe))return st.Transition.toString({...c,property:Mn})}}function di(e,t){var r,s;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:t.draggable,droppable:(s=e==null?void 0:e.droppable)!=null?s:t.droppable}}function Nt(e){if(!e)return!1;const 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)}const ui=[C.Down,C.Right,C.Up,C.Left],fi=(e,t)=>{let{context:{active:r,collisionRect:s,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:l}}=t;if(ui.includes(e.code)){if(e.preventDefault(),!r||!s)return;const d=[];
15i.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const m=o.get(h.id);if(m)switch(e.code){case C.Down:s.top<m.top&&d.push(h);break;case C.Up:s.top>m.top&&d.push(h);break;case C.Left:s.left>m.left&&d.push(h);break;case C.Right:s.left<m.left&&d.push(h);break}});const c=Us({active:r,collisionRect:s,droppableRects:o,droppableContainers:d,pointerCoordinates:null});let p=gn(c,"id");if(p===(a==null?void 0:a.id)&&c.length>1&&(p=c[1].id),p!=null){const h=i.get(r.id),m=i.get(p),f=m?o.get(m.id):null,g=m==null?void 0:m.node.current;if(g&&f&&h&&m){const x=Rt(g).some((D,S)=>l[S]!==D),y=In(h,m),w=hi(h,m),b=x||!y?{x:0,y:0}:{x:w?s.width-f.width:0,y:w?s.height-f.height:0},N={x:f.left,y:f.top};return b.x&&b.y?N:nt(N,b)}}}};function In(e,t){return!Nt(e)||!Nt(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function hi(e,t){return!Nt(e)||!Nt(t)||!In(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const pi={blocks:[]},sr="Airwaves",or="Newsletter of Southern Community Broadcasters Inc. - 88.3 Southern FM",br="#DA1629",yr="#00438F",it="#ffffff",Gr={red:br,darkBlue:yr,navy:"#001752",blue:"#007EC7",green:"#2FAE66",purple:"#8A63D2",peach:"#F0954B"},Vr={white:it,navy:"#001752",dark:"#111827",red:"#DA1629"},tt={header:"Header image",heading:"Heading",text:"Text",image:"Image",gallery:"Two photos side by side",gallery4:"Four photos (grid)",button:"Button",list:"List",quote:"Quote",divider:"Divider",highlight:"Highlight box"},wr={landscape:"3/2",square:"1/1"},jr={square:"1/1",landscape:"4/3",portrait:"3/4"},mi=100,gi=300,xi=100,Kr={headerBanner:"https://cimrcpciedxnvqjodikd.supabase.co/storage/v1/object/public/site-photos/gallery_global_extra_b6fb693f-1788003738048-gq3ejc.jpeg",studioInterview:"https://cimrcpciedxnvqjodikd.supabase.co/storage/v1/object/public/site-photos/gallery_global_extra_be8932bd-1788003691359-7o3crj.jpeg"},M={navy:"#001752",darkBlue:"#00438F",body:"#3a3a3a",muted:"#9aa5b8",border:"#e6e9ef",red:"#DA1629"},ne={red:"#DA1629",navy:"#001752",blue:"#007EC7",green:"#2FAE66",purple:"#8A63D2",peach:"#F0954B"},Pe={blue:{bg:"#DDF1FA",border:"#B7E2F5"},yellow:{bg:"#FCE8A8",border:"#F0D876"},green:{bg:"#DCF5E3",border:"#B8E8C5"},pink:{bg:"#FBE1EC",border:"#F3C2D9"},purple:{bg:"#EAE1FB",border:"#D3C2F3"},peach:{bg:"#FDE6D2",border:"#F8CBA0"}},z=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`b_${Date.now()}_${Math.random().toString(36).slice(2)}`;function vi(e){const t=z();switch(e){case"header":return{id:t,type:e,url:"",alt:"",caption:"",focalX:50,focalY:50};case"heading":return{id:t,type:e,text:"",level:2};case"text":return{id:t,type:e,html:""};case"image":return{id:t,type:e,url:"",alt:"",caption:"",aspect:"auto",focalX:50,focalY:50};case"gallery":return{id:t,type:e,images:[{url:"",alt:"",focalX:50,focalY:50},{url:"",alt:"",focalX:50,focalY:50}]};case"gallery4":return{id:t,type:e,images:[{url:"",alt:"",focalX:50,focalY:50},{url:"",alt:"",focalX:50,focalY:50},{url:"",alt:"",focalX:50,focalY:50},{url:"",alt:"",focalX:50,focalY:50}],aspect:"square"};case"button":return{id:t,type:e,label:"",url:"",style:"primary",align:"center"};case"list":return{id:t,type:e,style:"unordered",items:[""]};case"quote":return{id:t,type:e,text:"",caption:""};case"divider":return{id:t,type:e,color:"red"};case"highlight":return{id:t,type:e,heading:"",html:"",tone:"blue"}}}function Sr(){return{blocks:[{id:z(),type:"header",url:Kr.headerBanner,alt:"Southern FM presenters at an outside broadcast",caption:""},{id:z(),type:"highlight",tone:"blue",heading:"Welcome to our new members",html:"<p>Thank you for joining Southern FM. Your commitment and support is very much appreciated - it's a great way to keep the community connected.</p>"},{id:z(),type:"heading",text:"From the Studio",level:2},{id:z(),type:"text",html:"<p>A quick welcome from the team - what's been happening at Southern FM this quarter.</p>"},{id:z(),type:"divider",color:"red"},{id:z(),type:"heading",text:"Member & Community News",level:2},{id:z(),type:"text",html:"<p>New members, board updates, life memberships, and anything else worth celebrating.</p>"},{id:z(),type:"divider",color:"red"},{id:z(),type:"heading",text:"Show Spotlight",level:2},{id:z(),type:"text",html:"<p>Feature a show, presenter, or segment - swap in your own photo when you have one.</p>"},{id:z(),type:"image",url:Kr.studioInterview,alt:"A presenter interviewing a guest in the Southern FM studio",caption:""},{id:z(),type:"divider",color:"red"},{id:z(),type:"heading",text:"Upcoming Events",level:2},{id:z(),type:"list",style:"unordered",items:["Outside broadcast - date, location","Community event - date, location"]},{id:z(),type:"divider",color:"red"},{id:z(),type:"highlight",tone:"yellow",heading:"Get Involved",html:"<p>Southern FM runs on volunteers - presenting, technical support, admin, and more.</p>"},{id:z(),type:"button",label:"See how to get involved",url:"https://www.southernfm.com.au/get-involved",style:"primary",align:"center"},{id:z(),type:"divider",color:"red"},{id:z(),type:"heading",text:"Thanks to Our Sponsors",level:2},{id:z(),type:"text",html:"<p>A note of thanks to the local businesses supporting the station.</p>"}]}}const $n=({src:e,alt:t,aspectRatio:r,focalX:s,focalY:o,onChange:i,zoom:a,onZoomChange:l,rounded:d=14})=>{const c=u.useRef(null),p=u.useRef(!1),h=a??xi,m=(f,g)=>{const v=c.current;if(!v)return;const x=v.getBoundingClientRect();if(x.width===0||x.height===0)return;const y=Math.min(100,Math.max(0,(f-x.left)/x.width*100)),w=Math.min(100,Math.max(0,(g-x.top)/x.height*100));i(Math.round(y),Math.round(w))};return n.jsxs("div",{className:"relative w-full group/focal",style:{aspectRatio:r,borderRadius:d,overflow:"hidden"},children:[n.jsxs("div",{ref:c,className:"relative w-full h-full overflow-hidden cursor-move select-none touch-none",title:"Drag to reposition",onPointerDown:f=>{f.preventDefault(),f.stopPropagation(),p.current=!0,f.currentTarget.setPointerCapture(f.pointerId),m(f.clientX,f.clientY)},onPointerMove:f=>{p.current&&(f.stopPropagation(),m(f.clientX,f.clientY))},onPointerUp:f=>{f.stopPropagation(),p.current=!1},children:[n.jsx("img",{src:e,alt:t,className:"w-full h-full block pointer-events-none",style:{objectFit:"cover",objectPosition:`${s}% ${o}%`,transform:h!==100?`scale(${h/100})`:void 0,transformOrigin:`${s}% ${o}%`},draggable:!1}),n.jsx("div",{className:"absolute h-5 w-5 rounded-full pointer-events-none",style:{left:`${s}%`,top:`${o}%`,transform:"translate(-50%, -50%)",background:"rgba(218,22,41,0.85)",border:"2px s
15olid #fff",boxShadow:"0 1px 4px rgba(0,0,0,0.4)"}})]}),l&&n.jsxs("div",{className:"absolute left-2 right-2 bottom-2 flex items-center gap-1.5 rounded-full bg-black/55 backdrop-blur-sm px-2.5 py-1 opacity-0 group-hover/focal:opacity-100 focus-within:opacity-100 transition-opacity",onPointerDown:f=>f.stopPropagation(),onClick:f=>f.stopPropagation(),children:[n.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider text-white/70 shrink-0",children:"Zoom"}),n.jsx("input",{type:"range",min:mi,max:gi,step:5,value:h,onChange:f=>l(Number(f.target.value)),className:"h-1 w-full accent-white cursor-pointer",title:"Resize (zoom)"})]})]})};async function Ln(e){const t=fs("post-images",e);if(t)throw new Error(t);const r=await ps(e),s=e.name.split(".").pop()||"bin",o=`newsletter/${crypto.randomUUID()}.${s}`,{error:i}=await X.storage.from("post-images").upload(o,r,{contentType:r.type||void 0,upsert:!1});if(i)throw new Error(hs("post-images",i,e));const{data:a}=X.storage.from("post-images").getPublicUrl(o);return a.publicUrl}const Ee="w-full min-w-0 bg-transparent border-0 outline-none focus:outline-none focus-visible:ring-0 p-0 h-auto placeholder:text-muted-foreground/40";function Jr(e){e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}const bi=({content:e,onChange:t,readOnly:r})=>{const s=e.blocks,[o,i]=u.useState(null),a=Ps(Lr(xr,{activationConstraint:{distance:4}}),Lr(mr,{coordinateGetter:fi})),l=f=>t({blocks:f}),d=(f,g)=>{l(s.map(v=>v.id===f?{...v,...g}:v))},c=f=>l(s.filter(g=>g.id!==f)),p=f=>{const g=s.findIndex(x=>x.id===f);if(g<0)return;const v={...s[g],id:crypto.randomUUID()};l([...s.slice(0,g+1),v,...s.slice(g+1)])},h=(f,g)=>{const v=vi(f);if(!g){l([...s,v]),i(v.id);return}const x=s.findIndex(y=>y.id===g);x<0?l([...s,v]):l([...s.slice(0,x+1),v,...s.slice(x+1)]),i(v.id)},m=f=>{const{active:g,over:v}=f;if(!v||g.id===v.id)return;const x=s.findIndex(w=>w.id===g.id),y=s.findIndex(w=>w.id===v.id);x<0||y<0||l(vr(s,x,y))};return r?n.jsx("div",{className:"px-7 py-8 max-w-[640px] mx-auto",style:{fontFamily:"Montserrat, Arial, sans-serif"},children:s.map(f=>n.jsx(Ri,{block:f},f.id))}):n.jsx("div",{className:"px-5 py-6 sm:px-7",children:n.jsxs("div",{className:"max-w-[640px] mx-auto",style:{fontFamily:"Montserrat, Arial, sans-serif"},children:[n.jsx(Uo,{sensors:a,collisionDetection:Hs,onDragEnd:m,children:n.jsx(ri,{items:s.map(f=>f.id),strategy:ei,children:s.map(f=>n.jsx(wi,{block:f,selected:o===f.id,onSelect:()=>i(f.id),onChange:g=>d(f.id,g),onDelete:()=>c(f.id),onDuplicate:()=>p(f.id),onInsertAfter:g=>h(g,f.id)},f.id))})}),s.length===0&&n.jsx("div",{className:"rounded-2xl border border-dashed border-border p-8 text-center text-sm text-muted-foreground",children:"No blocks yet - add one below."}),n.jsx("div",{className:"mt-2",children:n.jsx(yi,{onAdd:f=>h(f,null)})})]})})},yi=({onAdd:e})=>n.jsxs(sn,{children:[n.jsx(on,{asChild:!0,children:n.jsxs("button",{type:"button",className:"w-full h-10 rounded-xl border border-dashed border-border text-sm font-medium text-muted-foreground hover:text-foreground hover:border-primary/40 hover:bg-muted/40 transition-colors inline-flex items-center justify-center gap-1.5",children:[n.jsx(Dt,{className:"h-4 w-4"}),"Add block"]})}),n.jsx(an,{align:"center",className:"w-48",children:Object.keys(tt).map(t=>n.jsx(ln,{onClick:()=>e(t),children:tt[t]},t))})]}),Zr=({title:e,onClick:t,danger:r,children:s})=>n.jsx("button",{type:"button",title:e,onClick:t,className:k("h-6 w-6 flex items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",r&&"hover:bg-destructive/10 hover:text-destructive"),children:s}),wi=({block:e,selected:t,onSelect:r,onChange:s,onDelete:o,onDuplicate:i,onInsertAfter:a})=>{const{attributes:l,listeners:d,setNodeRef:c,transform:p,transition:h,isDragging:m}=ci({id:e.id}),f={transform:st.Transform.toString(p),transition:h};return n.jsxs("div",{ref:c,style:f,onClick:r,className:k("group relative rounded-xl border transition-colors",t?"border-primary/50 bg-primary/[0.03]":"border-transparent hover:border-border",m&&"opacity-50 shadow-lg z-10 bg-card"),children:[n.jsxs("div",{className:"flex items-start gap-1.5 pl-1 pr-1 py-1.5",children:[n.jsx("button",{type:"button",className:k("mt
15-1 shrink-0 h-6 w-5 flex items-center justify-center rounded text-muted-foreground/0 group-hover:text-muted-foreground/50 hover:!text-muted-foreground hover:bg-muted cursor-grab active:cursor-grabbing touch-none transition-colors",t&&"text-muted-foreground/50"),title:"Drag to reorder",...l,...d,children:n.jsx(ms,{className:"h-4 w-4"})}),n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx(Si,{block:e,onChange:s})})]}),n.jsxs("div",{className:k("absolute top-1 right-1 flex items-center gap-1 rounded-full bg-card/95 backdrop-blur-sm px-1.5 py-1 border border-border/60 shadow-sm opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 focus-within:opacity-100 transition-opacity",t&&"opacity-100"),onClick:g=>g.stopPropagation(),children:[n.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider text-muted-foreground/50 mr-0.5",children:tt[e.type]}),n.jsx(ji,{block:e,onChange:s}),n.jsx(Zr,{title:"Duplicate",onClick:i,children:n.jsx(rs,{className:"h-3.5 w-3.5"})}),n.jsx(Zr,{title:"Delete",onClick:o,danger:!0,children:n.jsx(lr,{className:"h-3.5 w-3.5"})})]}),t&&n.jsx("div",{className:"px-2 pb-1.5 pl-8",children:n.jsxs(sn,{children:[n.jsx(on,{asChild:!0,children:n.jsxs("button",{type:"button",className:"text-[11px] font-medium text-muted-foreground hover:text-foreground inline-flex items-center gap-1",onClick:g=>g.stopPropagation(),children:[n.jsx(Cs,{className:"h-3 w-3"}),"Insert block below"]})}),n.jsx(an,{align:"start",className:"w-48",children:Object.keys(tt).map(g=>n.jsx(ln,{onClick:()=>a(g),children:tt[g]},g))})]})})]})};function ji({block:e,onChange:t}){switch(e.type){case"heading":{const r=e.uppercase!==!1;return n.jsxs("div",{className:"flex items-center gap-1 mr-0.5",children:[n.jsx("div",{className:"flex items-center rounded-full border border-border overflow-hidden",children:[2,3].map(s=>n.jsxs("button",{type:"button",onClick:()=>t({level:s}),className:k("h-6 w-6 text-[10px] font-bold flex items-center justify-center",e.level===s?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:["H",s]},s))}),n.jsxs(Ae,{children:[n.jsx(ke,{asChild:!0,children:n.jsx("button",{type:"button",title:"Heading style",className:"h-6 w-6 flex items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground",children:n.jsx(pt,{className:"h-3.5 w-3.5"})})}),n.jsxs(Me,{align:"end",className:"w-64 space-y-3",onClick:s=>s.stopPropagation(),children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Case"}),n.jsxs("div",{className:"flex items-center rounded-md border border-border overflow-hidden w-full",children:[n.jsx("button",{type:"button",onClick:()=>t({uppercase:!0}),className:k("flex-1 h-7 text-xs font-semibold",r?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:"UPPERCASE"}),n.jsx("button",{type:"button",onClick:()=>t({uppercase:!1}),className:k("flex-1 h-7 text-xs font-semibold",r?"text-muted-foreground hover:bg-muted":"bg-primary text-primary-foreground"),children:"As typed"})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Text color"}),n.jsx("div",{className:"flex items-center gap-1.5",children:Object.keys(ne).map(s=>n.jsx("button",{type:"button",title:s,onClick:()=>t({color:ne[s]}),className:k("h-6 w-6 rounded-full border-2",e.color===ne[s]?"border-foreground":"border-transparent"),style:{backgroundColor:ne[s]}},s))})]}),e.level===2&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Line color"}),n.jsx("div",{className:"flex items-center gap-1.5",children:Object.keys(ne).map(s=>n.jsx("button",{type:"button",title:s,onClick:()=>t({lineColor:ne[s]}),className:k("h-6 w-6 rounded-full border-2",e.lineColor===ne[s]?"border-foreground":"border-transparent"),style:{backgroundColor:ne[s]}},s))})]})]})]})]})}case"list":return n.jsxs("div",{className:"flex items-center rounded-full border border-border overflow-hidden mr-0.5",children:[n.jsx("button",{type:"button",title:"Bulleted",onClick:()=>t({style:"unordered"}),className:k("h-6 w-6 flex items-center justify-center",e.style==="unordered"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:n.jsx(xs,{className:"h-3 w-3"})}),n.jsx("button",{type:"button",title:"Numbered",onClick:()=>t({style:"ordered"}),className:k("h-6 w-6 flex items-center justify-center",e.style==="ordered"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:n.jsx(vs,{className:"h-3 w-3"})})]});case"divider":return n.jsx("div",{className:"flex items-center gap-1 mr-0.5",children:Object.keys(ne).map(r=>n.jsx("button",{type:"button",title:r,onClick:()=>t({color:r}
15),className:k("h-4 w-4 rounded-full border-2",e.color===r?"border-foreground":"border-transparent"),style:{backgroundColor:ne[r]}},r))});case"highlight":return n.jsx("div",{className:"flex items-center gap-1 mr-0.5",children:Object.keys(Pe).map(r=>n.jsx("button",{type:"button",title:r,onClick:()=>t({tone:r}),className:k("h-4 w-4 rounded-full border-2",e.tone===r?"border-foreground":"border-transparent"),style:{backgroundColor:Pe[r].bg,borderColor:e.tone===r?void 0:Pe[r].border}},r))});case"button":return n.jsxs(Ae,{children:[n.jsx(ke,{asChild:!0,children:n.jsx("button",{type:"button",title:"Button settings",className:"h-6 w-6 flex items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground mr-0.5",children:n.jsx(pt,{className:"h-3.5 w-3.5"})})}),n.jsxs(Me,{align:"end",className:"w-72 space-y-3",onClick:r=>r.stopPropagation(),children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Link URL"}),n.jsx(le,{value:e.url,onChange:r=>t({url:r.target.value}),placeholder:"https://â¦"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Style"}),n.jsxs(Lt,{value:e.style,onValueChange:r=>t({style:r}),children:[n.jsx(Ot,{className:"h-8 text-xs",children:n.jsx(zt,{})}),n.jsxs(Bt,{children:[n.jsx(ye,{value:"primary",children:"Primary"}),n.jsx(ye,{value:"secondary",children:"Secondary"}),n.jsx(ye,{value:"outline",children:"Outline"})]})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Align"}),n.jsxs(Lt,{value:e.align,onValueChange:r=>t({align:r}),children:[n.jsx(Ot,{className:"h-8 text-xs",children:n.jsx(zt,{})}),n.jsxs(Bt,{children:[n.jsx(ye,{value:"left",children:"Left"}),n.jsx(ye,{value:"center",children:"Center"}),n.jsx(ye,{value:"right",children:"Right"})]})]})]})]})]})]});case"header":return e.url?n.jsxs(Ae,{children:[n.jsx(ke,{asChild:!0,children:n.jsx("button",{type:"button",title:"Alt text",className:"h-6 w-6 flex items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground mr-0.5",children:n.jsx(pt,{className:"h-3.5 w-3.5"})})}),n.jsx(Me,{align:"end",className:"w-72",onClick:r=>r.stopPropagation(),children:n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Alt text (for screen readers)"}),n.jsx(le,{value:e.alt,onChange:r=>t({alt:r.target.value}),placeholder:"Describe the image"})]})})]}):null;case"gallery4":return n.jsx("div",{className:"flex items-center rounded-full border border-border overflow-hidden mr-0.5",children:["square","landscape","portrait"].map(r=>n.jsx("button",{type:"button",title:r,onClick:()=>t({aspect:r}),className:k("h-6 px-2 text-[9px] font-bold uppercase tracking-wide flex items-center justify-center",e.aspect===r?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:r==="square"?"1:1":r==="landscape"?"4:3":"3:4"},r))});case"image":return e.url?n.jsxs(Ae,{children:[n.jsx(ke,{asChild:!0,children:n.jsx("button",{type:"button",title:"Image settings",className:"h-6 w-6 flex items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground mr-0.5",children:n.jsx(pt,{className:"h-3.5 w-3.5"})})}),n.jsxs(Me,{align:"end",className:"w-72 space-y-3",onClick:r=>r.stopPropagation(),children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Crop"}),n.jsxs(Lt,{value:e.aspect??"auto",onValueChange:r=>t({aspect:r}),children:[n.jsx(Ot,{className:"h-8 text-xs",children:n.jsx(zt,{})}),n.jsxs(Bt,{children:[n.jsx(ye,{value:"auto",children:"Natural (no crop)"}),n.jsx(ye,{value:"landscape",children:"Landscape (3:2)"}),n.jsx(ye,{value:"square",children:"Square (1:1)"})]})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Alt text (for screen readers)"}),n.jsx(le,{value:e.alt,onChange:r=>t({alt:r.target.value}),placeholder:"Describe the image"})]})]})]}):null;default:return null}}function Si({block:e,onChange:t}){switch(e.type){case"header":return n.jsx(Qr,{block:e,onChange:t,variant:"banner"});case"heading":{const r=e.uppercase===!1?"none":"uppercase",s=e.color||M.navy;return e.level===3?n.jsx("input",{value:e.text,onChange:o=>t({text:o.target.value}),placeholder:"Sub-heading",className:Ee,style:{fontWeight:700,fontSize:15,letterSpacing:"0.04em",textTransform:r,lineHeight:1.3,color:s,margin:"10px 0 4px"}}):n.jsxs("div",{style:{margin:"16px 0 6px"}
15,children:[n.jsx("div",{style:{width:34,height:4,borderRadius:2,background:e.lineColor||M.red,marginBottom:10}}),n.jsx("input",{value:e.text,onChange:o=>t({text:o.target.value}),placeholder:"Section heading",className:Ee,style:{fontWeight:800,fontSize:21,letterSpacing:"0.02em",textTransform:r,lineHeight:1.3,color:s}})]})}case"text":return n.jsx(On,{html:e.html,onChange:r=>t({html:r})});case"image":return n.jsx(Qr,{block:e,onChange:t});case"gallery":return n.jsx(Ni,{block:e,onChange:t});case"gallery4":return n.jsx(Ci,{block:e,onChange:t});case"button":return n.jsx(Di,{block:e,onChange:t});case"list":return n.jsx(Ti,{block:e,onChange:t});case"quote":return n.jsxs("div",{style:{borderLeft:`3px solid ${M.border}`,paddingLeft:14,margin:"4px 0"},children:[n.jsx("textarea",{value:e.text,onChange:r=>t({text:r.target.value}),placeholder:"Quote text",rows:2,className:k(Ee,"resize-none"),style:{fontStyle:"italic",fontSize:15,lineHeight:1.7,color:M.muted}}),n.jsx("input",{value:e.caption,onChange:r=>t({caption:r.target.value}),placeholder:"Attribution (optional)",className:Ee,style:{fontSize:12,color:M.muted,marginTop:6}})]});case"divider":return n.jsx("div",{className:"my-1.5",style:{height:4,borderRadius:2,background:ne[e.color]}});case"highlight":return n.jsx(Ei,{block:e,onChange:t})}}const Ut=({active:e,onClick:t,title:r,children:s})=>n.jsx("button",{type:"button",title:r,onMouseDown:o=>o.preventDefault(),onClick:t,className:k("h-6 w-6 flex items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground",e&&"bg-primary/10 text-primary"),children:s});function On({html:e,onChange:t,textStyle:r}){const[s,o]=u.useState(!1),[i,a]=u.useState(!1),[l,d]=u.useState(""),c=os({extensions:[is.configure({heading:!1}),as.configure({openOnClick:!1,HTMLAttributes:{class:"underline underline-offset-2"}}),ls],content:e,editorProps:{attributes:{class:"focus:outline-none [&_p]:m-0"}},onUpdate:({editor:h})=>t(h.getHTML()),onFocus:()=>o(!0),onBlur:()=>o(!1)});if(!c)return null;const p=s||i;return n.jsxs("div",{children:[p&&n.jsxs("div",{className:"flex items-center gap-0.5 mb-1 -ml-1",children:[n.jsx(Ut,{title:"Bold",active:c.isActive("bold"),onClick:()=>c.chain().focus().toggleBold().run(),children:n.jsx(cs,{className:"h-3.5 w-3.5"})}),n.jsx(Ut,{title:"Italic",active:c.isActive("italic"),onClick:()=>c.chain().focus().toggleItalic().run(),children:n.jsx(ds,{className:"h-3.5 w-3.5"})}),n.jsx(Ut,{title:"Underline",active:c.isActive("underline"),onClick:()=>c.chain().focus().toggleUnderline().run(),children:n.jsx(gs,{className:"h-3.5 w-3.5"})}),n.jsxs(Ae,{open:i,onOpenChange:h=>{a(h),h&&d(c.getAttributes("link").href??"")},children:[n.jsx(ke,{asChild:!0,children:n.jsx("button",{type:"button",title:"Link",onMouseDown:h=>h.preventDefault(),className:k("h-6 w-6 flex items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground",c.isActive("link")&&"bg-primary/10 text-primary"),children:n.jsx(ns,{className:"h-3.5 w-3.5"})})}),n.jsx(Me,{align:"start",className:"w-72 p-3",onClick:h=>h.stopPropagation(),children:n.jsxs("form",{onSubmit:h=>{h.preventDefault();const m=l.trim();m?c.chain().focus().setLink({href:m}).run():c.chain().focus().unsetLink().run(),a(!1)},children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Link URL"}),n.jsxs("div",{className:"flex gap-1.5",children:[n.jsx(le,{autoFocus:!0,value:l,onChange:h=>d(h.target.value),placeholder:"https://â¦",className:"h-8 text-sm"}),n.jsx("button",{type:"submit",className:"h-8 px-3 rounded-md bg-primary text-primary-foreground text-xs font-semibold shrink-0",children:"Apply"})]}),c.isActive("link")&&n.jsx("button",{type:"button",onClick:()=>{c.chain().focus().unsetLink().run(),a(!1)},className:"text-xs text-destructive mt-2 hover:underline",children:"Remove link"})]})})]})]}),n.jsx("div",{style:{fontSize:15,lineHeight:1.7,color:M.body,margin:"0 0 4px",...r},children:n.jsx(us,{editor:c})})]})}function Qr({block:e,onChange:t,variant:r="inline"}){const[s,o]=u.useState(!1),i=u.useRef(null),a=async c=>{var h;const p=(h=c.target.files)==null?void 0:h[0];if(p){o(!0);try{const m=await Ln(p);t({url:m})}catch(m){$.error("Upload failed",{description:m instanceof Error?m.message:String(m)})}finally{o(!1),i.current&&(i.current.value="")}}}
15,l=r==="banner",d=l?"16/7":e.type==="image"&&e.aspect&&e.aspect!=="auto"?wr[e.aspect]:null;return n.jsxs("div",{style:{margin:l?"0 0 20px":"10px 0"},children:[e.url?n.jsxs("div",{className:"relative group/img",onClick:c=>c.stopPropagation(),children:[d?n.jsx($n,{src:e.url,alt:e.alt,aspectRatio:d,focalX:e.focalX??50,focalY:e.focalY??50,onChange:(c,p)=>t({focalX:c,focalY:p}),zoom:e.zoom,onZoomChange:c=>t({zoom:c}),rounded:l?14:12}):n.jsx("img",{src:e.url,alt:e.alt,className:"w-full block",style:{borderRadius:12}}),n.jsxs("div",{className:"absolute top-2 right-2 flex items-center gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity",children:[n.jsx("button",{type:"button",onClick:()=>{var c;return(c=i.current)==null?void 0:c.click()},title:"Replace image",className:"h-7 w-7 rounded-full bg-background/90 border border-border flex items-center justify-center text-muted-foreground hover:text-foreground",children:s?n.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(cn,{className:"h-3.5 w-3.5"})}),n.jsx("button",{type:"button",onClick:()=>t({url:""}),title:"Remove image",className:"h-7 w-7 rounded-full bg-background/90 border border-border flex items-center justify-center text-muted-foreground hover:text-destructive",children:n.jsx(ar,{className:"h-3.5 w-3.5"})})]})]}):n.jsxs("button",{type:"button",onClick:c=>{var p;c.stopPropagation(),(p=i.current)==null||p.click()},disabled:s,className:k("w-full rounded-xl border border-dashed border-border flex flex-col items-center justify-center gap-1.5 text-muted-foreground hover:bg-muted/40 hover:border-primary/40 transition-colors",l?"h-40":"h-28"),children:[s?n.jsx(ce,{className:"h-5 w-5 animate-spin"}):n.jsx(rn,{className:"h-5 w-5"}),n.jsx("span",{className:"text-xs",children:s?"Uploadingâ¦":l?"Click to upload a header banner image":"Click to upload an image"})]}),n.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:a}),e.url&&n.jsx("textarea",{ref:Jr,value:e.caption,onChange:c=>{t({caption:c.target.value}),Jr(c.currentTarget)},placeholder:"Add a caption (optional)",onClick:c=>c.stopPropagation(),rows:1,className:k(Ee,"text-center mt-1.5 resize-none overflow-hidden block"),style:{fontSize:12,color:M.muted}})]})}function ir({image:e,onChange:t,aspectRatio:r="1/1"}){const[s,o]=u.useState(!1),i=u.useRef(null),a=async l=>{var c;const d=(c=l.target.files)==null?void 0:c[0];if(d){o(!0);try{const p=await Ln(d);t({url:p})}catch(p){$.error("Upload failed",{description:p instanceof Error?p.message:String(p)})}finally{o(!1),i.current&&(i.current.value="")}}};return n.jsxs("div",{className:"min-w-0 flex-1",children:[e.url?n.jsxs("div",{className:"relative group/img",onClick:l=>l.stopPropagation(),children:[n.jsx($n,{src:e.url,alt:e.alt,aspectRatio:r,focalX:e.focalX,focalY:e.focalY,onChange:(l,d)=>t({focalX:l,focalY:d}),zoom:e.zoom,onZoomChange:l=>t({zoom:l}),rounded:12}),n.jsxs("div",{className:"absolute top-1.5 right-1.5 flex items-center gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity",children:[n.jsx("button",{type:"button",onClick:()=>{var l;return(l=i.current)==null?void 0:l.click()},title:"Replace image",className:"h-6 w-6 rounded-full bg-background/90 border border-border flex items-center justify-center text-muted-foreground hover:text-foreground",children:s?n.jsx(ce,{className:"h-3 w-3 animate-spin"}):n.jsx(cn,{className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:()=>t({url:""}),title:"Remove image",className:"h-6 w-6 rounded-full bg-background/90 border border-border flex items-center justify-center text-muted-foreground hover:text-destructive",children:n.jsx(ar,{className:"h-3 w-3"})})]})]}):n.jsxs("button",{type:"button",onClick:l=>{var d;l.stopPropagation(),(d=i.current)==null||d.click()},disabled:s,className:"w-full rounded-xl border border-dashed border-border flex flex-col items-center justify-center gap-1.5 text-muted-foreground hover:bg-muted/40 hover:border-primary/40 transition-colors",style:{aspectRatio:r},children:[s?n.jsx(ce,{className:"h-5 w-5 animate-spin"}):n.jsx(rn,{className:"h-5 w-5"}),n.jsx("span",{className:"text-xs",children:s?"Uploadingâ¦":"Upload"})]}),n.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:a})]})}function Ni({block:e,onChange:t}){const r=(s,o)=>{const i=[...e.images];i[s]={...i[s],...o},t({images:i})};return n.jsxs("div",{className:"flex gap-2",style:{margin:"10px 0"},children:[n.jsx(ir,{image:e.images[0],onChange:s=>r(0,s)}),n.jsx(ir,{image:e.images[1],onChange:s=>r(1,s)})]})}function Ci({block:e,onChange:t}){const r=jr[e.aspect],s=(o,i)=>{const a=[...e.images];a[o]={...a[o],...i},t({images:a})};return n.jsx("div",{className:"grid grid-cols-2 gap-2",style:{margin:"10px 0"},children:e.images.map((o,i)=>n.jsx(ir,{image:o,aspectRatio:r,onChange:a=>s(i,a)},i))})}const zn={primary:{background:M.red,color:"#ffffff"},secondary:{background:M.navy,color:"#ffffff"},outline:{background:"#ffffff",color:M.red,border:`2px solid ${M.red}`}};function Di({block:e,onChange:t}){const r=e.align==="left"?"flex-start":e.align==="right"?"flex-end":"center";return n.jsx("div",{style:{display:"flex",justifyContent:r,margin:"10px 0"},children:n.jsx("input",{value:e.label,onChange:s=>t({label:s.target.value}),placeholder:"Button label",onClick:s=>s.stopPropagation(),className:k(Ee,"text-center rounded-full"),style:{...zn[e.style],padding:"12px 26px",fontWeight:700,fontSize:14,width:`${Math.max((e.label||"Button label").length+2,12)}ch`}})})}function Ti({block:e,onChange:t}){const r=o=>t({items:o}),s=e.style==="ordered"?"ol":"ul";return n.jsxs(s,{style:{margin:"0 0 6px",paddingLeft:22,fontSize:15,lineHeight:1.7,color:M.body,listStyleType:e.style==="ordered"?"decimal":"disc"},children:[e.items.map((o,i)=>n.jsxs("li",{className:"group/item flex items-center gap-1.5",children:[n.jsx("input",{value:o,onChange:a=>{const l=[...e.items];l[i]=a.target.value,r(l)},placeholder:`Item ${i+1}`,onClick:a=>a.stopPropagation(),className:Ee,style:{fontSize:15,lineHeight:1.7,color:M.body}}),n.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),r(e.items.filter((l,d)=>d!==i))},className:"h-5 w-5 shrink-0 flex items-center justify-center rounded text-muted-foreground
15/0 group-hover/item:text-muted-foreground/60 hover:!text-destructive",children:n.jsx(ar,{className:"h-3 w-3"})})]},i)),n.jsx("li",{className:"list-none -ml-[22px]",children:n.jsxs("button",{type:"button",onClick:o=>{o.stopPropagation(),r([...e.items,""])},className:"text-xs font-medium text-muted-foreground hover:text-foreground inline-flex items-center gap-1 mt-0.5",children:[n.jsx(Dt,{className:"h-3 w-3"}),"Add item"]})})]})}function Ei({block:e,onChange:t}){const r=Pe[e.tone];return n.jsxs("div",{style:{background:r.bg,border:`1px solid ${r.border}`,borderRadius:14,padding:"18px 20px",margin:"8px 0"},children:[n.jsx("input",{value:e.heading,onChange:s=>t({heading:s.target.value}),placeholder:"Box heading",onClick:s=>s.stopPropagation(),className:Ee,style:{fontWeight:800,fontSize:14,letterSpacing:"0.04em",textTransform:"uppercase",color:M.red,marginBottom:6}}),n.jsx(On,{html:e.html,onChange:s=>t({html:s})})]})}function xt(e,t,r){return!e||e===100?{}:{transform:`scale(${e/100})`,transformOrigin:`${t}% ${r}%`}}function Ri({block:e}){switch(e.type){case"header":return e.url?n.jsxs("figure",{style:{margin:"0 0 20px",overflow:"hidden",borderRadius:14},children:[n.jsx("img",{src:e.url,alt:e.alt,style:{width:"100%",aspectRatio:"16/7",objectFit:"cover",objectPosition:`${e.focalX??50}% ${e.focalY??50}%`,display:"block",...xt(e.zoom,e.focalX??50,e.focalY??50)}}),e.caption&&n.jsx("figcaption",{style:{fontSize:12,color:M.muted,textAlign:"center",marginTop:6},children:e.caption})]}):null;case"heading":{const t=e.uppercase===!1?"none":"uppercase",r=e.color||M.navy;return e.level===3?n.jsx("div",{style:{fontWeight:700,fontSize:15,letterSpacing:"0.04em",textTransform:t,lineHeight:1.3,color:r,margin:"22px 0 8px"},children:e.text}):n.jsxs("div",{style:{margin:"32px 0 12px"},children:[n.jsx("div",{style:{width:34,height:4,borderRadius:2,background:e.lineColor||M.red,marginBottom:10}}),n.jsx("div",{style:{fontWeight:800,fontSize:21,letterSpacing:"0.02em",textTransform:t,lineHeight:1.3,color:r},children:e.text})]})}case"text":return n.jsx("div",{style:{fontSize:15,lineHeight:1.7,color:M.body,margin:"0 0 14px"},dangerouslySetInnerHTML:{__html:e.html}});case"image":{if(!e.url)return null;const t=e.aspect&&e.aspect!=="auto"?wr[e.aspect]:null;return n.jsxs("figure",{style:{margin:"10px 0"},children:[n.jsx("div",{style:{overflow:"hidden",borderRadius:12},children:n.jsx("img",{src:e.url,alt:e.alt,style:t?{width:"100%",aspectRatio:t,objectFit:"cover",objectPosition:`${e.focalX??50}% ${e.focalY??50}%`,display:"block",...xt(e.zoom,e.focalX??50,e.focalY??50)}:{width:"100%",display:"block"}})}),e.caption&&n.jsx("figcaption",{style:{fontSize:12,color:M.muted,textAlign:"center",marginTop:6},children:e.caption})]})}case"gallery":return n.jsx("div",{style:{display:"flex",gap:10,margin:"10px 0"},children:e.images.map((t,r)=>t.url?n.jsx("div",{style:{width:"50%",aspectRatio:"1/1",overflow:"hidden",borderRadius:12},children:n.jsx("img",{src:t.url,alt:t.alt,style:{width:"100%",height:"100%",objectFit:"cover",objectPosition:`${t.focalX}% ${t.focalY}%`,display:"block",...xt(t.zoom,t.focalX,t.focalY)}})},r):n.jsx("div",{style:{width:"50%"}},r))});case"gallery4":{const t=jr[e.aspect];return n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,margin:"10px 0"},children:e.images.map((r,s)=>r.url?n.jsx("div",{style:{aspectRatio:t,overflow:"hidden",borderRadius:12},children:n.jsx("img",{src:r.url,alt:r.alt,style:{width:"100%",height:"100%",objectFit:"cover",objectPosition:`${r.focalX}% ${r.focalY}%`,display:"block",...xt(r.zoom,r.focalX,r.focalY)}})},s):n.jsx("div",{style:{aspectRatio:t}},s))})}case"button":{const t=e.align==="left"?"flex-start":e.align==="right"?"flex-end":"center";return n.jsx("div",{style:{display:"flex",justifyContent:t,margin:"14px 0"},children:n.jsx("span",{style:{...zn[e.style],padding:"12px 26px",borderRadius:999,fontWeight:700,fontSize:14},children:e.label||"Button"})})}case"list":{const t=e.style==="ordered"?"ol":"ul";return n.jsx(t,{style:{margin:"0 0 14px",paddingLeft:22,fontSize:15,lineHeight:1.7,color:M.body}
15,children:e.items.filter(Boolean).map((r,s)=>n.jsx("li",{children:r},s))})}case"quote":return n.jsxs("blockquote",{style:{borderLeft:`3px solid ${M.border}`,paddingLeft:14,color:M.muted,fontStyle:"italic",fontSize:15,lineHeight:1.7,margin:"0 0 14px"},children:[e.text,e.caption&&n.jsxs("div",{style:{fontSize:12,marginTop:6},children:["- ",e.caption]})]});case"divider":return n.jsx("div",{style:{height:4,borderRadius:2,background:ne[e.color],margin:"26px 0"}});case"highlight":{const t=Pe[e.tone];return n.jsxs("div",{style:{background:t.bg,border:`1px solid ${t.border}`,borderRadius:14,padding:"20px 22px",margin:"0 0 14px"},children:[e.heading&&n.jsx("div",{style:{fontWeight:800,fontSize:14,letterSpacing:"0.04em",textTransform:"uppercase",color:M.red,marginBottom:8},children:e.heading}),n.jsx("div",{style:{fontSize:14,lineHeight:1.7,color:M.body},dangerouslySetInnerHTML:{__html:e.html}})]})}}}const Ai="https://www.southernfm.com.au/images/sfm-logo-white.svg",ki="https://www.southernfm.com.au/images/so-local-logo-mono-white.svg",Mi="https://www.southernfm.com.au/images/so-local-logo-red.svg",Yt="w-full min-w-0 bg-transparent border-0 outline-none focus:outline-none p-0 h-auto text-center",vt=({icon:e,label:t,value:r,options:s,onChange:o})=>n.jsxs(Ae,{children:[n.jsx(ke,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i=>i.stopPropagation(),className:"h-6 w-6 rounded-full grid place-items-center bg-white/15 hover:bg-white/25 transition-colors shrink-0",title:t,children:e})}),n.jsxs(Me,{align:"end",className:"w-auto p-2",onClick:i=>i.stopPropagation(),children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1.5 px-0.5",children:t}),n.jsx("div",{className:"flex gap-1.5",children:Object.entries(s).map(([i,a])=>n.jsx("button",{type:"button",onClick:()=>o(a),className:"h-6 w-6 rounded-full border-2 transition-transform hover:scale-110",style:{background:a,borderColor:r===a?"#111827":"transparent"},title:i},i))})]})]}),Ii=({title:e,issueLabel:t,onIssueLabelChange:r,mastheadTitle:s,mastheadTagline:o,mastheadRedColor:i,mastheadBlueColor:a,mastheadRedTextColor:l,mastheadBlueTextColor:d,onMastheadChange:c,readOnly:p})=>{const h=!p,m=t,f=s||sr,g=o||or,v=i||br,x=a||yr,y=l||it,w=d||it;return n.jsxs("div",{children:[n.jsxs("div",{style:{background:v,padding:h&&c?"6px 24px 20px":"20px 24px"},children:[h&&c&&n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:4,marginBottom:4},children:[n.jsx(vt,{icon:n.jsx(Ir,{className:"h-3.5 w-3.5 text-white"}),label:"Text color",value:y,options:Vr,onChange:b=>c({mastheadRedTextColor:b})}),n.jsx(vt,{icon:n.jsx(Mr,{className:"h-3.5 w-3.5 text-white"}),label:"Band color",value:v,options:Gr,onChange:b=>c({mastheadRedColor:b})})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[n.jsx("img",{src:Ai,alt:"Southern FM",width:40,style:{display:"block",flexShrink:0}}),n.jsxs("div",{style:{flex:1,minWidth:0,textAlign:"center"},children:[h&&c?n.jsx("input",{value:s??"",onChange:b=>c({mastheadTitle:b.target.value}),placeholder:sr,onClick:b=>b.stopPropagation(),className:k(Yt,"placeholder:text-[var(--mh-color)] placeholder:opacity-100"),style:{fontWeight:900,fontSize:26,lineHeight:1.1,letterSpacing:"0.06em",textTransform:"uppercase",color:y,"--mh-color":y}}):n.jsx("div",{style:{fontWeight:900,fontSize:26,lineHeight:1.1,letterSpacing:"0.06em",textTransform:"uppercase",color:y},children:f}),h&&r?n.jsx("input",{value:t,onChange:b=>r(b.target.value),placeholder:e||"Issue label, e.g. September 2026",onClick:b=>b.stopPropagation(),className:Yt,style:{fontWeight:700,fontSize:12,letterSpacing:"0.14em",textTransform:"uppercase",color:y,opacity:.85,marginTop:6}}):m&&n.jsx("div",{style:{fontWeight:700,fontSize:12,letterSpacing:"0.14em",textTransform:"uppercase",color:y,opacity:.85,marginTop:6},children:m})]}),n.jsx("img",{src:ki,alt:"So Local",width:48,style:{display:"block",flexShrink:0}})]})]}),n.jsxs("div",{style:{background:x,padding:h&&c?"6px 24px 9px":"9px 24px"},children:[h&&c&&n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:4,marginBottom:2},children:[n.jsx(vt,{icon:n.jsx(Ir,{className:"h-3.5 w-3.5 text-white"}),label:"Text color",value:w,options:Vr,onChange:b=>c({mastheadBlueTextColor:b})}),n.jsx(vt,{icon:n.jsx(Mr,{className:"h-3.5 w-3.5 text-white"}),label:"Band color",value:x,options:Gr,onChange:b=>c({mastheadBlueColor:b})})]}),h&&c?n.jsx("input",{value:o??"",onChange:b=>c({mastheadTagline:b.target.value}),placeholder:or,onClick:b=>b.stopPropagation(),className:k(Yt,"placeholder:text-[var(--mh-color)] placeholder:opacity-100"),style:{fontSize:11,letterSpacing:"0.02em",color:w,opacity:.85,"--mh-color":w}}):n.jsx("div",{style:{fontSize:11,letterSpacing:"0.02em",color:w,opacity:.85,textAlign:"center"},children:g})]})]})},$i=[["President","[email protected]"],["Treasurer","[email protected]"],["Program Director","[email protected]"],["Sponsorship Manager","[email protected]"],["Membership","[email protected]"],["Music Director","[email protected]"],["Outside Broadcasts","[email protected]"],["Fundraising","[email protected]"],["Volunteers","[email protected]"],["Airwaves Editor","[email protected]"]],Li=()=>n.jsxs("div",{style:{padding:"24px 30px 30px",textAlign:"center",borderTop:"1px solid #ececec",marginTop:10},children:[n.jsx("div",{style:{fontWeight:800,fontSize:13,letterSpacing:"0.04em",textTransform:"uppercase",color:"#001752",marginBottom:4},children:"Contacts"}),n.jsx("div",{style:{fontSize:12,color:"#9aa5b8",marginBottom:10},children:"If you need to get in touch with us, please email:"}),n.jsx("div",{style:{fontSize:12,color:"#3a3a3a",lineHeight:1.9},children:$i.map(([e,t])=>n.jsxs("div",{children:[n.jsx("strong",{style:{color:"#001752"},children:e})," - ",n.jsx("a",{href:`mailto:${t}`,style:{color:"#007EC7",textDecoration:"none"},children:t})]},e))}),n.jsx("img",{src:Mi,alt:"So Local",width:56,style:{display:"block",margin:"22px auto 14px"}}),n.jsxs("div",{style:{marginBottom:12,fontSize:12},children:[n.jsx("a",{href:"https://facebook.com/southernfm",style:{color:"#007EC7",textDecoration:"none",marginRight:16},children:"Facebook"}),n.jsx("a",{href:"https://instagram.com/southernfm",style:{color:"#007EC7",textDecoration:"none"},children:"Instagram"})]}),n.jsxs("div",{style:{fontSize:11,color:"#9aa5b8",lineHeight:1.7},children:["Southern FM · PO Box 5083, Bentleigh East VIC 3165",n.jsx("br",{}),"© ",new Date().getFullYear()," Southern Community Broadcasters Inc. All rights reserved."]}),n.jsx("div",{style:{marginTop:10,fontSize:11,color:"#9aa5b8"},children:"You're receiving this because you're a member of 88.3 Southern FM. To opt out of Airwaves, reply to this email with OPT OUT in the subject line."})]}),B=M;function P(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Oi(e,t,r){const s=t,o=(r==null?void 0:r.mastheadTitle)||sr,i=(r==null?void 0:r.mastheadTagline)||or,a=(r==null?void 0:r.mastheadRedColor)||br,l=(r==null?void 0:r.mastheadBlueColor)||yr,d=(r==null?void 0:r.mastheadRedTextColor)||it,c=(r==null?void 0:r.mastheadBlueTextColor)||it;return`<div style="background:${a}
15;padding:20px 24px;"><table role="presentation" width="100%" cellpadding="0" cellspacing="0"><tr><td width="40" style="vertical-align:middle;"><img src="https://www.southernfm.com.au/images/sfm-logo-white.svg" alt="Southern FM" width="40" style="display:block;" /></td><td style="text-align:center;vertical-align:middle;"><div style="font-weight:900;font-size:26px;line-height:1.1;letter-spacing:0.06em;text-transform:uppercase;color:${d};">${P(o)}</div>`+(s?`<div style="font-weight:700;font-size:12px;letter-spacing:0.14em;text-transform:uppercase;color:${d};opacity:0.85;margin-top:6px;">${P(s)}</div>`:"")+`</td><td width="48" style="vertical-align:middle;text-align:right;"><img src="https://www.southernfm.com.au/images/so-local-logo-mono-white.svg" alt="So Local" width="48" style="display:inline-block;" /></td></tr></table></div><div style="background:${l};padding:9px 24px;text-align:center;"><div style="font-size:11px;letter-spacing:0.02em;color:${c};opacity:0.85;">${P(i)}</div></div>`}const zi=[["President","[email protected]"],["Treasurer","[email protected]"],["Program Director","[email protected]"],["Sponsorship Manager","[email protected]"],["Membership","[email protected]"],["Music Director","[email protected]"],["Outside Broadcasts","[email protected]"],["Fundraising","[email protected]"],["Volunteers","[email protected]"],["Airwaves Editor","[email protected]"]];function Bi(){const e=zi.map(([t,r])=>`<div><strong style="color:${B.navy};">${t}</strong> - <a href="mailto:${r}" style="color:#007EC7;text-decoration:none;">${r}</a></div>`).join("");return`<div style="padding:24px 30px 30px;text-align:center;border-top:1px solid #ececec;margin-top:10px;"><div style="font-weight:800;font-size:13px;letter-spacing:0.04em;text-transform:uppercase;color:${B.navy};margin-bottom:4px;">Contacts</div><div style="font-size:12px;color:${B.muted};margin-bottom:10px;">If you need to get in touch with us, please email:</div><div style="font-size:12px;color:${B.body};line-height:1.9;">${e}</div><img src="https://www.southernfm.com.au/images/so-local-logo-red.svg" alt="So Local" width="56" style="display:block;margin:22px auto 14px;" /><div style="margin-bottom:12px;font-size:12px;"><a href="https://facebook.com/southernfm" style="color:#007EC7;text-decoration:none;margin-right:16px;">Facebook</a><a href="https://instagram.com/southernfm" style="color:#007EC7;text-decoration:none;">Instagram</a></div><div style="font-size:11px;color:${B.muted};line-height:1.7;">Southern FM · PO Box 5083, Bentleigh East VIC 3165<br/>© ${new Date().getFullYear()} Southern Community Broadcasters Inc. All rights reserved.</div><div style="margin-top:10px;font-size:11px;color:${B.muted};">You're receiving this because you're a member of 88.3 Southern FM. To opt out of Airwaves, reply to this email with OPT OUT in the subject line.</div></div>`}function bt(e,t,r){return!e||e===100?"":`transform:scale(${e/100});transform-origin:${t}% ${r}%;`}function _i(e){switch(e.type){case"header":{if(!e.url)return"";const t=e.caption?`<div style="font-size:12px;color:${B.muted};text-align:center;margin-top:6px;">${P(e.caption)}</div>`:"",r=e.focalX??50,s=e.focalY??50;return`<div style="overflow:hidden;border-radius:14px;margin:0 0 20px;"><img src="${P(e.url)}" alt="${P(e.alt)}" width="100%" style="width:100%;max-width:100%;height:auto;aspect-ratio:16/7;object-fit:cover;object-position:${r}% ${s}%;display:block;${bt(e.zoom,r,s)}" /></div>${t}`}case"heading":{const t=e.uppercase===!1?"none":"uppercase",r=e.color||B.navy;return e.level===3?`<h3 style="margin:22px 0 8px;font-size:15px;line-height:1.3;font-weight:700;letter-spacing:0.04em;text-transform:${t};color:${r};">${e.text}</h3>`:`<div style="margin:32px 0 12px;"><div style="width:34px;height:4px;border-radius:2px;background:${e.lineColor||B.red};margin:0 0 10px;"></div><h2 style="margin:0;font-size:21px;line-height:1.3;font-weight:800;letter-spacing:0.02em;text-transform:${t};color:${r};">${e.text}</h2></div>`}case"text":return`<div style="margin:0 0 14px;font-size:15px;line-height:1.7;color:${B.body}
15;">${e.html}</div>`;case"list":{const t=e.style==="ordered"?"ol":"ul",r=e.items.filter(s=>s.trim()).map(s=>`<li style="margin:0 0 6px;">${s}</li>`).join("");return`<${t} style="margin:0 0 14px;padding-left:22px;font-size:15px;line-height:1.7;color:${B.body};">${r}</${t}>`}case"quote":{const t=e.caption?`<div style="font-size:12px;color:${B.muted};margin-top:6px;">- ${P(e.caption)}</div>`:"";return`<blockquote style="margin:0 0 14px;padding-left:14px;border-left:3px solid ${B.border};color:${B.muted};font-style:italic;font-size:15px;line-height:1.7;">${e.text}${t}</blockquote>`}case"divider":return`<div style="height:4px;line-height:4px;font-size:0;background:${ne[e.color??"red"]};border-radius:2px;margin:26px 0;"> </div>`;case"highlight":{const t=Pe[e.tone??"blue"],r=e.heading?`<div style="font-weight:800;font-size:14px;letter-spacing:0.04em;text-transform:uppercase;color:${B.red};margin:0 0 8px;">${P(e.heading)}</div>`:"";return`<div style="background:${t.bg};border:1px solid ${t.border};border-radius:14px;padding:20px 22px;margin:0 0 14px;">${r}<div style="font-size:14px;line-height:1.7;color:${B.body};">${e.html}</div></div>`}case"image":{if(!e.url)return"";const t=e.caption?`<div style="font-size:12px;color:${B.muted};text-align:center;margin-top:6px;">${P(e.caption)}</div>`:"",r=e.aspect&&e.aspect!=="auto"?wr[e.aspect]:null;if(!r)return`<img src="${P(e.url)}" alt="${P(e.alt)}" width="100%" style="max-width:100%;height:auto;border-radius:12px;display:block;margin:10px 0;" />${t}`;const s=e.focalX??50,o=e.focalY??50;return`<div style="overflow:hidden;border-radius:12px;margin:10px 0;"><img src="${P(e.url)}" alt="${P(e.alt)}" width="100%" style="width:100%;aspect-ratio:${r};object-fit:cover;object-position:${s}% ${o}%;display:block;${bt(e.zoom,s,o)}" /></div>${t}`}case"gallery":{const t=e.images.map(r=>r.url?`<td width="50%" style="padding:0;"><div style="overflow:hidden;border-radius:12px;"><img src="${P(r.url)}" alt="${P(r.alt)}" width="100%" style="width:100%;aspect-ratio:1/1;object-fit:cover;object-position:${r.focalX}% ${r.focalY}%;display:block;${bt(r.zoom,r.focalX,r.focalY)}" /></div></td>`:'<td width="50%" style="padding:0;"></td>');return`<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:10px 0;"><tr>${t[0]}<td width="10" style="padding:0;"> </td>${t[1]}</tr></table>`}case"gallery4":{const t=jr[e.aspect],r=s=>s.url?`<div style="overflow:hidden;border-radius:12px;"><img src="${P(s.url)}" alt="${P(s.alt)}" width="100%" style="width:100%;aspect-ratio:${t};object-fit:cover;object-position:${s.focalX}% ${s.focalY}%;display:block;${bt(s.zoom,s.focalX,s.focalY)}" /></div>`:"";return`<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:10px 0;"><tr><td width="50%" style="padding:0;">${r(e.images[0])}</td><td width="10" style="padding:0;"> </td><td width="50%" style="padding:0;">${r(e.images[1])}</td></tr><tr><td colspan="3" height="10" style="padding:0;line-height:10px;font-size:0;"> </td></tr><tr><td width="50%" style="padding:0;">${r(e.images[2])}</td><td width="10" style="padding:0;"> </td><td width="50%" style="padding:0;">${r(e.images[3])}</td></tr></table>`}case"button":{const t=e.label||"Learn more",r=e.url||"#",s=e.style==="outline",o=e.style==="secondary",i=s?"#ffffff":o?B.navy:B.red,a=s?B.red:"#ffffff",l=s?`border:2px solid ${B.red};`:"";return`<table role="presentation" cellpadding="0" cellspacing="0" style="margin:${e.align==="center"?"14px auto":e.align==="right"?"14px 0 14px auto":"14px 0"};"><tr><td><a href="${P(r)}" style="display:inline-block;padding:12px 26px;border-radius:999px;background:${i};color:${a};${l}text-decoration:none;font-weight:700;font-size:14px;">${P(t)}</a></td></tr></table>`}}}function Pi(e){return((e==null?void 0:e.blocks)??[]).map(_i).filter(Boolean).join(` 16`)}const Fi=(e,t,r)=>`<!doctype html> 17<html><head><meta name="viewport" content="width=device-width, initial-scale=1" /> 18<style> 19 body { margin:0; background:#ffffff; font-family:Montserrat,Arial,sans-serif; }
20 .content { padding:28px 30px 10px; } 21</style></head> 22<body>${e}<div class="content">${t}</div>${r}</body></html>`,Hi=({title:e,issueLabel:t,content:r})=>{const s=u.useMemo(()=>Fi(Oi(e,t,r),Pi(r),Bi()),[e,t,r]);return n.jsx("iframe",{title:e||"Newsletter preview",srcDoc:s,className:"w-full h-full block",style:{border:"none"}})},Ui={mobile:390,desktop:680},en=({value:e,options:t,onChange:r})=>n.jsx("div",{className:"inline-flex items-center gap-0.5 rounded-full bg-card border border-border p-1 shadow-sm",children:t.map(s=>n.jsxs("button",{type:"button",onClick:()=>r(s.value),className:k("h-8 rounded-full px-3 text-xs font-semibold inline-flex items-center gap-1.5 transition-colors",e===s.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"),children:[s.icon,s.label]},s.value))}),Bn=({title:e,issueLabel:t,onIssueLabelChange:r,content:s,onChange:o,readOnly:i})=>{const[a,l]=u.useState("edit"),[d,c]=u.useState("desktop"),p=i?"view":a,h=m=>o({...s,...m});return n.jsxs("div",{className:"rounded-[28px] p-4 sm:p-8",style:{background:"linear-gradient(180deg, hsl(var(--sfm-light-blue) / 0.14), hsl(var(--muted)) 55%)"},children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-4",children:[i?n.jsx("div",{}):n.jsx(en,{value:a,onChange:m=>l(m),options:[{value:"edit",label:"Edit",icon:n.jsx(ss,{className:"h-3.5 w-3.5"})},{value:"view",label:"Preview",icon:n.jsx(bs,{className:"h-3.5 w-3.5"})}]}),p==="view"&&n.jsx(en,{value:d,onChange:m=>c(m),options:[{value:"mobile",icon:n.jsx(Wn,{className:"h-3.5 w-3.5"})},{value:"desktop",icon:n.jsx(Gn,{className:"h-3.5 w-3.5"})}]})]}),n.jsx("div",{className:"mx-auto rounded-2xl bg-card border border-border/60 shadow-[0_1px_2px_rgba(16,24,40,0.04),0_16px_32px_-12px_rgba(16,24,40,0.16)] overflow-hidden transition-[max-width] duration-200 ease-out",style:{maxWidth:p==="view"?Ui[d]:720},children:p==="edit"?n.jsxs(n.Fragment,{children:[n.jsx(Ii,{title:e,issueLabel:t,onIssueLabelChange:r,mastheadTitle:s.mastheadTitle,mastheadTagline:s.mastheadTagline,mastheadRedColor:s.mastheadRedColor,mastheadBlueColor:s.mastheadBlueColor,mastheadRedTextColor:s.mastheadRedTextColor,mastheadBlueTextColor:s.mastheadBlueTextColor,onMastheadChange:i?void 0:h,readOnly:i}),n.jsx(bi,{content:s,onChange:o,readOnly:i}),n.jsx(Li,{})]}):n.jsx("div",{className:"h-[60vh] sm:h-[70vh] max-h-[780px] min-h-[420px]",children:n.jsx(Hi,{title:e,issueLabel:t,content:s})})})]})},Yi=({sendTo:e,onSendToChange:t,scheduledAt:r,onScheduledAtChange:s,readOnly:o,isSent:i,sentAt:a,sentTo:l,s
22aving:d,sending:c,onSaveDraft:p,onSend:h,onSendTest:m,testing:f})=>n.jsxs("div",{className:"rounded-2xl border border-border bg-card p-5 space-y-5 lg:sticky lg:top-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-bold text-foreground",children:"Send settings"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:i?"This issue has already been sent.":"How this issue goes out, once it's ready."})]}),i?n.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 px-3 py-2.5 text-xs text-green-800",children:["Sent ",a&&Fe(new Date(a),"d MMM yyyy, h:mm a"),l&&` to ${l}`,"."]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Send to"}),n.jsx(le,{type:"email",value:e,onChange:g=>t(g.target.value),placeholder:"Distribution list (default)",disabled:o}),n.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Leave blank to use the station's usual distribution list."})]}),n.jsxs("div",{className:"space-y-1.5 pt-1 border-t border-border",children:[n.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground pt-3 block",children:"Send a test"}),n.jsx(Xi,{onSendTest:m,testing:f,disabled:o||d||c}),n.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Emails just this address a copy. The issue stays a draft."})]}),n.jsxs("div",{className:"pt-1 border-t border-border",children:[n.jsx(qi,{value:r,onChange:s,readOnly:o}),n.jsx("p",{className:"text-[11px] text-muted-foreground mt-2",children:'Saved with the draft, but not wired up to send automatically yet - "Send to members" below still sends right away.'})]})]}),!o&&n.jsxs("div",{className:"space-y-2 pt-1 border-t border-border",children:[n.jsxs(q,{variant:"outline",className:"w-full mt-4",onClick:p,disabled:d||c,children:[d?n.jsx(ce,{className:"h-4 w-4 mr-1.5 animate-spin"}):null,"Save draft"]}),n.jsxs(q,{className:"w-full",onClick:h,disabled:d||c,children:[c?n.jsx(ce,{className:"h-4 w-4 mr-1.5 animate-spin"}):n.jsx(Ss,{className:"h-4 w-4 mr-1.5"}),"Send to members"]})]})]});function Xi({onSendTest:e,testing:t,disabled:r}){const[s,o]=u.useState("");return n.jsxs("div",{className:"flex gap-2",children:[n.jsx(le,{type:"email",value:s,onChange:i=>o(i.target.value),placeholder:"[email protected]",disabled:r||t}),n.jsx(q,{variant:"outline",size:"sm",className:"shrink-0",disabled:r||t||!s.trim(),onClick:()=>e(s.trim()),children:t?n.jsx(ce,{className:"h-4 w-4 animate-spin"}):"Test"})]})}function qi({value:e,onChange:t,readOnly:r}){const[s,o]=u.useState(!1),i=e!==null,a=e??new Date,l=f=>{const g=new Date(a);g.setFullYear(f.getFullYear(),f.getMonth(),f.getDate()),t(g)},d=(f,g,v)=>{const x=f%12+(v?12:0),y=new Date(a);y.setHours(x,g,0,0),t(y)},c=a.getHours(),p=a.getMinutes(),h=c>=12,m=(c+11)%12+1;return n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Schedule"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[11px] text-muted-foreground",children:i?"Scheduled":"Send immediately"}),n.jsx(ws,{checked:i,disabled:r,onCheckedChange:f=>{f?(t(new Date),o(!0)):(t(null),o(!1))}})]})]}),i&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:n.jsx("span",{className:"font-medium text-foreground",children:Fe(a,"d MMM yyyy 'at' HH:mm")})}),!r&&n.jsx(q,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>o(f=>!f),children:s?"Done":"Edit"})]}),s&&!r&&n.jsxs("div",{className:"pt-1 space-y-3",children:[n.jsx("div",{className:"flex justify-center -mx-1 overflow-x-auto",children:n.jsx(js,{mode:"single",selected:a,onSelect:f=>f&&l(f),className:"p-3 pointer-events-auto"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(ys,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Time"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"flex items-center bg-muted/40 rounded-xl border border-border px-2 h-9",children:[n.jsx(le,{type:"number",min:1,max:12,value:m,onChange:f=>{const g=Math.max(1,Math.min(12,parseInt(f.target.value)||1));d(g,p,h)},className:"h-7 w-9 text-sm text-center border-0 bg-transparent p-0 focus-visible:ring-0 focus-visible:ring-offset-0"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:":"}),n.jsx(le,{type:"number",min:0,max:59,value:String(p).padStart(2,"0"),onChange:f=>{const g=Math.max(0,Math.min(59,parseInt(f.target.value)||0));d(m,g,h)},className:"h-7 w-9 text-sm text-center border-0 bg-transparent p-0 focus-visible:ring-0 focus-visible:ring-offset-0"})]}),n.jsxs("div",{className:"flex rounded-xl border border-border overflow-hidden h-9",children:[n.jsx("button",{type:"button",onClick:()=>d(m,p,!1),className:k("px-3 text-xs font-medium transition-colors",h?"bg-background hover:bg-muted text-muted-foreground":"bg-primary text-primary-foreground"),children:"AM"}),n.jsx("button",{type:"button",onClick:()=>d(m,p,!0),className:k("px-3 text-xs font-medium transition-colors",h?"bg-primary text-primary-foreground":"bg-background hover:bg-muted text-muted-foreground"),children:"PM"})]}),n.jsx(q,{type:"button",variant:"outline",size:"sm",className:"h-9 px-3 text-xs font-medium rounded-xl ml-auto",onClick:()=>t(new Date),children:"Now"})]})]})]})]})]})}const Wi="id, name, content, created_at, updated_at",Gi=({canEdit:e,onBack:t})=>{const[r,s]=u.useState([]),[o,i]=u.useState(!0),[a,l]=u.useState(null),d=async()=>{i(!0);const{data:c,error:p}=await X.from("newsletter_templates").select(Wi).order("updated_at",{ascending:!1});p&&$.error("Failed to load templates",{description:p.message}),s(c??[]),i(!1)};return u.useEffect(()=>{d()},[]),a?n.jsx(Vi,{template:a==="new"?null:a,canEdit:e,onBack:()=>{l(null),d()}},a==="new"?"new":a.id):n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(q,{variant:"ghost",size:"sm",onClick:t,children:[n.jsx(cr,{className:"h-4 w-4 mr-1.5"}),"Back"]}),n.jsx("div",{className:"flex-1"}),e&&n.jsxs(q,{onClick:()=>l("new"),children:[n.jsx(Dt,{className:"h-4 w-4 mr-1.5"}),"New template"]})]}),n.jsxs("div",{children:[n.jsx("h2",{className:"font-display text-2xl font-bold text-foreground",children:"Newsletter templates"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Reusable starting points offered when someone starts a new issue."})]}),o?n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx(ce,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r.length===0?n.jsxs("div",{className:"rounded-2xl border border-dashed border-border p-8 text-center text-sm text-muted-foreground",children:["No templates yet",e?" - create one here, or save an issue as a template while editing it.":"."]}):n.jsx("div",{className:"rounded-2xl border border-border divide-y divide-border overflow-hidden",children:r.map(c=>n.jsxs("button",{type:"button",onClick:()=>l(c),className:"w-full flex items-center gap-4 px-5 py-4 text-left hover:bg-muted/60 transition-colors",children:[n.jsx(Tt,{className:"h-4 w-4 text-primary shrink-0"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm font-semibold text-foreground truncate",children:c.name}),n.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:["Last edited ",Fe(new Date(c.updated_at),"d MMM yyyy, h:mm a")]})]})]},c.id))})]})},Vi=({template:e,canEdit:t,onBack:r})=>{const{user:s}=Ct(),[o,i]=u.useState((e==null?void 0:e.name)??""),[a,l]=u.useState((e==null?void 0:e.content)??Sr()),[d,c]=u.useState(!1),p=async()=>
22{if(!o.trim()){$.error("Give this template a name first.");return}c(!0);try{const f={name:o.trim(),content:a,updated_by:(s==null?void 0:s.id)??null};if(e){const{error:g}=await X.from("newsletter_templates").update(f).eq("id",e.id);if(g)return $.error("Failed to save",{description:g.message}),!1}else{const{error:g}=await X.from("newsletter_templates").insert({...f,created_by:(s==null?void 0:s.id)??null});if(g)return $.error("Failed to create",{description:g.message}),!1}return $.success("Template saved"),!0}finally{c(!1)}},h=async()=>{await p()&&r()},m=async()=>{if(!e)return;const{error:f}=await X.from("newsletter_templates").delete().eq("id",e.id);if(f){$.error("Failed to delete",{description:f.message});return}$.success("Template deleted"),r()};return n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(q,{variant:"ghost",size:"sm",onClick:r,children:[n.jsx(cr,{className:"h-4 w-4 mr-1.5"}),"Back"]}),n.jsx("div",{className:"flex-1"}),t&&n.jsxs(q,{size:"sm",onClick:h,disabled:d,children:[d?n.jsx(ce,{className:"h-4 w-4 mr-1.5 animate-spin"}):n.jsx(dn,{className:"h-4 w-4 mr-1.5"}),"Save template"]}),e&&t&&n.jsxs(Xt,{children:[n.jsx(nn,{asChild:!0,children:n.jsx(q,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",title:"Delete this template",children:n.jsx(lr,{className:"h-4 w-4"})})}),n.jsxs(qt,{children:[n.jsxs(Wt,{children:[n.jsx(Gt,{children:"Delete this template?"}),n.jsx(Vt,{children:"This can't be undone. Issues already created from it won't be affected."})]}),n.jsxs(Kt,{children:[n.jsx(Jt,{children:"Cancel"}),n.jsx(Zt,{onClick:m,children:"Delete"})]})]})]})]}),n.jsxs("div",{className:"max-w-sm",children:[n.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5 block",children:"Template name"}),n.jsx(le,{value:o,onChange:f=>i(f.target.value),placeholder:"Standard issue",disabled:!t})]}),n.jsx(Bn,{title:o||"Untitled template",issueLabel:"",content:a,onChange:l,readOnly:!t})]})},Ki=({open:e,onOpenChange:t,onPick:r})=>{const[s,o]=u.useState([]),[i,a]=u.useState(!0);u.useEffect(()=>{e&&(a(!0),X.from("newsletter_templates").select("id, name, content").order("name").then(({data:d,error:c})=>{c&&$.error("Failed to load templates",{description:c.message}),o(d??[]),a(!1)}))},[e]);const l=d=>{t(!1),r(d)};return n.jsx(Vn,{open:e,onOpenChange:t,children:n.jsxs(Kn,{className:"sm:max-w-md",children:[n.jsxs(Jn,{children:[n.jsx(Zn,{children:"Start a new issue"}),n.jsx(Qn,{children:"Pick a starting point - you can change everything afterwards."})]}),n.jsxs("div",{className:"space-y-1.5 max-h-80 overflow-y-auto -mx-1 px-1",children:[n.jsxs("button",{type:"button",onClick:()=>l(pi),className:"w-full flex items-center gap-3 rounded-xl border border-border px-4 py-3 text-left hover:bg-muted/60 transition-colors",children:[n.jsx(Ns,{className:"h-4 w-4 text-primary shrink-0"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Start from scratch"}),n.jsx("div",{className:"text-xs text-muted-foreground",children:"A blank canvas - add whatever elements you need"})]})]}),n.jsxs("button",{type:"button",onClick:()=>l(Sr()),className:"w-full flex items-center gap-3 rounded-xl border border-border px-4 py-3 text-left hover:bg-muted/60 transition-colors",children:[n.jsx(es,{className:"h-4 w-4 text-primary shrink-0"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Default starter"}),n.jsx("div",{className:"text-xs text-muted-foreground",children:"The usual Airwaves section layout"})]})]}),i?n.jsx("div",{className:"flex items-center justify-center py-6",children:n.jsx(ce,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):s.map(d=>n.jsxs("button",{type:"button",onClick:()=>l(d.content),className:"w-full flex items-center gap-3 rounded-xl border border-border px-4 py-3 text-left hover:bg-muted/60 transition-colors",children:[n.jsx(Tt,{className:"h-4 w-4 text-primary shrink-0"}),n.jsx("div",{className:"min-w-0",children:n.jsx("div",{className:"text-sm font-semibold text-foreground truncate",children:d.name})})]},d.id))]})]})})},Ji="id, title, issue_label, content, status, sent_at, sent_to, send_to_override, scheduled_at, created_at, updated_at",za=()=>{const{isAdmin:e,hasPermission:t}=Ct(),r=e||t("manage_newsletter"),[s,o]=u.useState([]),[i,a]=u.useState(!0),[l,d]=u.useState(null),[c,p]=u.useState(!1),[h,m]=u.useState(!1),[f,g]=u.useState(null),v=async()=>{a(!0);const{data:x,error:y}=await X.from("newsletters").select(Ji).order("updated_at",{ascending:!1});y&&$.error("Failed to load newsletters",{description:y.message}),o(x??[]),a(!1)};return u.useEffect(()=>
22{v()},[]),c?n.jsx(Gi,{canEdit:r,onBack:()=>p(!1)}):l?n.jsx(Zi,{newsletter:l==="new"?null:l,initialContent:l==="new"?f:null,canEdit:r,onBack:()=>{d(null),g(null),v()}},l==="new"?"new":l.id):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"font-display text-2xl font-bold text-foreground",children:"Comms"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:'Build and send the "Airwaves" member newsletter.'})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(q,{variant:"outline",onClick:()=>p(!0),children:[n.jsx(Tt,{className:"h-4 w-4 mr-1.5"}),"Templates"]}),r&&n.jsxs(q,{onClick:()=>m(!0),children:[n.jsx(Dt,{className:"h-4 w-4 mr-1.5"}),"New issue"]})]})]}),n.jsx(Ki,{open:h,onOpenChange:m,onPick:x=>{g(x),d("new")}}),i?n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx(ce,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):s.length===0?n.jsx("div",{className:"rounded-2xl border border-dashed border-border p-8 text-center text-sm text-muted-foreground",children:r?"No issues yet - create the first one.":"No newsletters have been sent yet."}):n.jsx("div",{className:"rounded-2xl border border-border divide-y divide-border overflow-hidden",children:s.map(x=>n.jsxs("button",{type:"button",onClick:()=>d(x),className:"w-full flex items-center gap-4 px-5 py-4 text-left hover:bg-muted/60 transition-colors",children:[n.jsx(ts,{className:"h-4 w-4 text-primary shrink-0"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm font-semibold text-foreground truncate",children:x.title}),n.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[x.issue_label?`${x.issue_label} · `:"",x.status==="sent"&&x.sent_at?`Sent ${Fe(new Date(x.sent_at),"d MMM yyyy, h:mm a")}`:`Last edited ${Fe(new Date(x.updated_at),"d MMM yyyy, h:mm a")}`]})]}),n.jsx("span",{className:k("text-[10px] font-bold uppercase tracking-wider px-2.5 py-1 rounded-full shrink-0",x.status==="sent"?"bg-green-100 text-green-700":"bg-muted text-muted-foreground"),children:x.status})]},x.id))})]})},Zi=({newsletter:e,initialContent:t,canEdit:r,onBack:s})=>{const{user:o}=Ct(),[i,a]=u.useState((e==null?void 0:e.title)??""),[l,d]=u.useState((e==null?void 0:e.issue_label)??""),[c,p]=u.useState((e==null?void 0:e.content)??t??Sr()),[h,m]=u.useState((e==null?void 0:e.send_to_override)??""),[f,g]=u.useState(e!=null&&e.scheduled_at?new Date(e.scheduled_at):null),[v,x]=u.useState(!1),[y,w]=u.useState(!1),[b,N]=u.useState(!1),[T,D]=u.useState(!1),S=(e==null?void 0:e.status)==="sent",j=!r||S,I=async()=>{if(!i.trim())return $.error("Give this issue a title first."),null;x(!0);try{const R={title:i.trim(),issue_label:l.trim()||null,content:c,send_to_override:h.trim()||null,scheduled_at:f?f.toISOString():null,updated_by:(o==null?void 0:o.id)??null};if(e){const{error:L}=await X.from("newsletters").update(R).eq("id",e.id);return L?($.error("Failed to save",{description:L.message}),null):e.id}const{data:Q,error:se}=await X.from("newsletters").insert({...R,created_by:(o==null?void 0:o.id)??null}).select("id").single();return se?($.error("Failed to create",{description:se.message}),null):($.success("Draft created"),Q.id)}finally{x(!1)}},_=async()=>{await I()&&($.success("Draft saved"),s())},A=async()=>{var Q;N(!1);const R=await I();if(R){w(!0);try{const{data:se}=await X.auth.getSession(),L=(Q=se.session)==null?void 0:Q.access_token,{data:W,error:O}=await X.functions.invoke("send-newsletter",{body:{newsletterId:R},headers:L?{Authorization:`Bearer ${L}`}:void 0});if(O||W!=null&&W.error){$.error("Send failed",{description:(W==null?void 0:W.error)??(O==null?void 0:O.message)});return}$.success("Newsletter sent"),s()}finally{w(!1)}}},J=async R=>{var se;const Q=await I();if(Q){D(!0);try{const{data:L}=await X.auth.getSession(),W=(se=L.session)==null?void 0:se.access_token,{data:O,error:ue}=await X.functions.invoke("send-newsletter",{body:{newsletterId:Q,testTo:R},headers:W?{Authorization:`Bearer ${W}`}:void 0});if(ue||O!=null&&O.error){$.error("Test send failed",{description:(O==null?void 0:O.error)??(ue==null?void 0:ue.message)});return}$.success(`Test sent to ${R}`)}finally{D(!1)}}},Z=async()=>
22{if(!e)return;const{error:R}=await X.from("newsletters").delete().eq("id",e.id);if(R){$.error("Failed to delete",{description:R.message});return}$.success("Draft deleted"),s()};return n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(q,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(cr,{className:"h-4 w-4 mr-1.5"}),"Back"]}),n.jsx("div",{className:"flex-1"}),r&&n.jsx(Qi,{defaultName:i,content:c}),!j&&e&&n.jsxs(Xt,{children:[n.jsx(nn,{asChild:!0,children:n.jsx(q,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",title:"Delete this draft",children:n.jsx(lr,{className:"h-4 w-4"})})}),n.jsxs(qt,{children:[n.jsxs(Wt,{children:[n.jsx(Gt,{children:"Delete this draft?"}),n.jsx(Vt,{children:"This can't be undone."})]}),n.jsxs(Kt,{children:[n.jsx(Jt,{children:"Cancel"}),n.jsx(Zt,{onClick:Z,children:"Delete"})]})]})]})]}),S&&n.jsxs("div",{className:"rounded-xl border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-800",children:["Sent ",(e==null?void 0:e.sent_at)&&Fe(new Date(e.sent_at),"d MMM yyyy, h:mm a"),(e==null?void 0:e.sent_to)&&` to ${e.sent_to}`,". Sent issues can't be edited."]}),n.jsxs("div",{className:"grid lg:grid-cols-[1fr_280px] gap-6 items-start",children:[n.jsxs("div",{className:"min-w-0 space-y-5",children:[n.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5 block",children:"Title"}),n.jsx(le,{value:i,onChange:R=>a(R.target.value),placeholder:"Airwaves - September 2026",disabled:j})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5 block",children:"Issue label (optional)"}),n.jsx(le,{value:l,onChange:R=>d(R.target.value),placeholder:"September 2026",disabled:j})]})]}),n.jsx(Bn,{title:i,issueLabel:l,onIssueLabelChange:d,content:c,onChange:p,readOnly:j})]}),n.jsx(Yi,{sendTo:h,onSendToChange:m,scheduledAt:f,onScheduledAtChange:g,readOnly:j,isSent:S,sentAt:e==null?void 0:e.sent_at,sentTo:e==null?void 0:e.sent_to,saving:v,sending:y,onSaveDraft:_,onSend:()=>N(!0),onSendTest:J,testing:T})]}),n.jsx(Xt,{open:b,onOpenChange:N,children:n.jsxs(qt,{children:[n.jsxs(Wt,{children:[n.jsx(Gt,{children:"Send this issue to all members?"}),n.jsx(Vt,{children:"This emails the station's O365 distribution list once, which fans it out to every member on that list. This can't be undone - double-check the content first."})]}),n.jsxs(Kt,{children:[n.jsx(Jt,{children:"Keep editing"}),n.jsx(Zt,{onClick:A,children:"Send now"})]})]})})]})};function Qi({defaultName:e,content:t}){const{user:r}=Ct(),[s,o]=u.useState(!1),[i,a]=u.useState(e),[l,d]=u.useState(!1);return n.jsxs(Ae,{open:s,onOpenChange:c=>{o(c),c&&a(e)},children:[n.jsx(ke,{asChild:!0,children:n.jsxs(q,{variant:"ghost",size:"sm",title:"Save this content as a reusable template",children:[n.jsx(Tt,{className:"h-4 w-4 mr-1.5"}),"Save as template"]})}),n.jsx(Me,{align:"end",className:"w-72 space-y-3",onClick:c=>c.stopPropagation(),children:n.jsxs("form",{onSubmit:async c=>{if(c.preventDefault(),!!i.trim()){d(!0);try{const{error:p}=await X.from("newsletter_templates").insert({name:i.trim(),content:t,created_by:(r==null?void 0:r.id)??null,updated_by:(r==null?void 0:r.id)??null});if(p){$.error("Failed to save template",{description:p.message});return}$.success("Template saved"),o(!1)}finally{d(!1)}}},children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Template name"}),n.jsxs("div",{className:"flex gap-1.5",children:[n.jsx(le,{autoFocus:!0,value:i,onChange:c=>a(c.target.value),placeholder:"Standard issue",className:"h-8 text-sm"}),n.jsx(q,{type:"submit",size:"sm",className:"h-8 shrink-0",disabled:l||!i.trim(),children:l?n.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(dn,{className:"h-3.5 w-3.5"})})]})]})})]})}export{za as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.