@embedreach/components 0.2.69 → 0.2.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -111,7 +111,7 @@ function H6(e,a){return e?function(e){return"function"==typeof e&&(()=>{const a=
111
111
  *
112
112
  * This source code is licensed under the MIT license found in the
113
113
  * LICENSE file in the root directory of this source tree.
114
- */Jpe.exports="production"===process.env.NODE_ENV?function(){if(Vpe)return Upe;Vpe=1;var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},n=a.useState,t=a.useEffect,i=a.useLayoutEffect,r=a.useDebugValue;function o(a){var n=a.getSnapshot;a=a.value;try{var t=n();return!e(a,t)}catch(i){return!0}}var s="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,a){return a()}:function(e,a){var s=a(),l=n({inst:{value:s,getSnapshot:a}}),u=l[0].inst,c=l[1];return i((function(){u.value=s,u.getSnapshot=a,o(u)&&c({inst:u})}),[e,s,a]),t((function(){return o(u)&&c({inst:u}),e((function(){o(u)&&c({inst:u})}))}),[e]),r(s),s};return Upe.useSyncExternalStore=void 0!==a.useSyncExternalStore?a.useSyncExternalStore:s,Upe}():(Wpe||(Wpe=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var a=e.getSnapshot;e=e.value;try{var n=a();return!t(e,n)}catch(i){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=a,t="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},i=n.useState,r=n.useEffect,o=n.useLayoutEffect,s=n.useDebugValue,l=!1,u=!1,c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,a){return a()}:function(a,c){l||void 0===n.startTransition||(l=!0);var d=c();if(!u){var m=c();t(d,m)||(u=!0)}var h=(m=i({inst:{value:d,getSnapshot:c}}))[0].inst,p=m[1];return o((function(){h.value=d,h.getSnapshot=c,e(h)&&p({inst:h})}),[a,d,c]),r((function(){return e(h)&&p({inst:h}),a((function(){e(h)&&p({inst:h})}))}),[a]),s(d),d};qpe.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),qpe);var Zpe=Jpe.exports,$pe='[cmdk-group=""]',Ype='[cmdk-group-items=""]',Qpe='[cmdk-item=""]',Xpe=`${Qpe}:not([aria-disabled="true"])`,ege="cmdk-item-select",age="data-value",nge=(e,a,n)=>Fpe(e,a,n),tge=r.createContext(void 0),ige=()=>r.useContext(tge),rge=r.createContext(void 0),oge=()=>r.useContext(rge),sge=r.createContext(void 0),lge=r.forwardRef(((e,a)=>{let n=Age((()=>{var a,n;return{search:"",value:null!=(n=null!=(a=e.value)?a:e.defaultValue)?n:"",filtered:{count:0,items:new Map,groups:new Set}}})),t=Age((()=>new Set)),i=Age((()=>new Map)),o=Age((()=>new Map)),s=Age((()=>new Set)),l=bge(e),{label:u,children:c,value:d,onValueChange:m,filter:h,shouldFilter:p,loop:g,disablePointerSelection:v=!1,vimBindings:f=!0,...y}=e,k=E8(),b=E8(),S=E8(),A=r.useRef(null),w=Tge();Sge((()=>{if(void 0!==d){let e=d.trim();n.current.value=e,C.emit()}}),[d]),Sge((()=>{w(6,_)}),[]);let C=r.useMemo((()=>({subscribe:e=>(s.current.add(e),()=>s.current.delete(e)),snapshot:()=>n.current,setState:(e,a,t)=>{var i,r,o;if(!Object.is(n.current[e],a)){if(n.current[e]=a,"search"===e)N(),E(),w(1,x);else if("value"===e&&(t||w(5,_),void 0!==(null==(i=l.current)?void 0:i.value))){return void(null==(o=(r=l.current).onValueChange)||o.call(r,null!=a?a:""))}C.emit()}},emit:()=>{s.current.forEach((e=>e()))}})),[]),M=r.useMemo((()=>({value:(e,a,t)=>{var i;a!==(null==(i=o.current.get(e))?void 0:i.value)&&(o.current.set(e,{value:a,keywords:t}),n.current.filtered.items.set(e,T(a,t)),w(2,(()=>{E(),C.emit()})))},item:(e,a)=>(t.current.add(e),a&&(i.current.has(a)?i.current.get(a).add(e):i.current.set(a,new Set([e]))),w(3,(()=>{N(),E(),n.current.value||x(),C.emit()})),()=>{o.current.delete(e),t.current.delete(e),n.current.filtered.items.delete(e);let a=P();w(4,(()=>{N(),(null==a?void 0:a.getAttribute("id"))===e&&x(),C.emit()}))}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{o.current.delete(e),i.current.delete(e)}),filter:()=>l.current.shouldFilter,label:u||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:k,inputId:S,labelId:b,listInnerRef:A})),[]);function T(e,a){var t,i;let r=null!=(i=null==(t=l.current)?void 0:t.filter)?i:nge;return e?r(e,n.current.search,a):0}function E(){if(!n.current.search||!1===l.current.shouldFilter)return;let e=n.current.filtered.items,a=[];n.current.filtered.groups.forEach((n=>{let t=i.current.get(n),r=0;t.forEach((a=>{let n=e.get(a);r=Math.max(n,r)})),a.push([n,r])}));let t=A.current;L().sort(((a,n)=>{var t,i;let r=a.getAttribute("id"),o=n.getAttribute("id");return(null!=(t=e.get(o))?t:0)-(null!=(i=e.get(r))?i:0)})).forEach((e=>{let a=e.closest(Ype);a?a.appendChild(e.parentElement===a?e:e.closest(`${Ype} > *`)):t.appendChild(e.parentElement===t?e:e.closest(`${Ype} > *`))})),a.sort(((e,a)=>a[1]-e[1])).forEach((e=>{var a;let n=null==(a=A.current)?void 0:a.querySelector(`${$pe}[${age}="${encodeURIComponent(e[0])}"]`);null==n||n.parentElement.appendChild(n)}))}function x(){let e=L().find((e=>"true"!==e.getAttribute("aria-disabled"))),a=null==e?void 0:e.getAttribute(age);C.setState("value",a||void 0)}function N(){var e,a,r,s;if(!n.current.search||!1===l.current.shouldFilter)return void(n.current.filtered.count=t.current.size);n.current.filtered.groups=new Set;let u=0;for(let i of t.current){let t=T(null!=(a=null==(e=o.current.get(i))?void 0:e.value)?a:"",null!=(s=null==(r=o.current.get(i))?void 0:r.keywords)?s:[]);n.current.filtered.items.set(i,t),t>0&&u++}for(let[t,o]of i.current)for(let e of o)if(n.current.filtered.items.get(e)>0){n.current.filtered.groups.add(t);break}n.current.filtered.count=u}function _(){var e,a,n;let t=P();t&&((null==(e=t.parentElement)?void 0:e.firstChild)===t&&(null==(n=null==(a=t.closest($pe))?void 0:a.querySelector('[cmdk-group-heading=""]'))||n.scrollIntoView({block:"nearest"})),t.scrollIntoView({block:"nearest"}))}function P(){var e;return null==(e=A.current)?void 0:e.querySelector(`${Qpe}[aria-selected="true"]`)}function L(){var e;return Array.from((null==(e=A.current)?void 0:e.querySelectorAll(Xpe))||[])}function j(e){let a=L()[e];a&&C.setState("value",a.getAttribute(age))}function B(e){var a;let n=P(),t=L(),i=t.findIndex((e=>e===n)),r=t[i+e];null!=(a=l.current)&&a.loop&&(r=i+e<0?t[t.length-1]:i+e===t.length?t[0]:t[i+e]),r&&C.setState("value",r.getAttribute(age))}function R(e){let a,n=P(),t=null==n?void 0:n.closest($pe);for(;t&&!a;)t=e>0?yge(t,$pe):kge(t,$pe),a=null==t?void 0:t.querySelector(Xpe);a?C.setState("value",a.getAttribute(age)):B(e)}let z=()=>j(L().length-1),D=e=>{e.preventDefault(),e.metaKey?z():e.altKey?R(1):B(1)},K=e=>{e.preventDefault(),e.metaKey?j(0):e.altKey?R(-1):B(-1)};return r.createElement(Y6.div,{ref:a,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:e=>{var a;if(null==(a=y.onKeyDown)||a.call(y,e),!e.defaultPrevented)switch(e.key){case"n":case"j":f&&e.ctrlKey&&D(e);break;case"ArrowDown":D(e);break;case"p":case"k":f&&e.ctrlKey&&K(e);break;case"ArrowUp":K(e);break;case"Home":e.preventDefault(),j(0);break;case"End":e.preventDefault(),z();break;case"Enter":if(!e.nativeEvent.isComposing&&229!==e.keyCode){e.preventDefault();let a=P();if(a){let e=new Event(ege);a.dispatchEvent(e)}}}}},r.createElement("label",{"cmdk-label":"",htmlFor:M.inputId,id:M.labelId,style:xge},u),Ege(e,(e=>r.createElement(rge.Provider,{value:C},r.createElement(tge.Provider,{value:M},e)))))})),uge=r.forwardRef(((e,a)=>{var n,t;let i=E8(),o=r.useRef(null),s=r.useContext(sge),l=ige(),u=bge(e),c=null!=(t=null==(n=u.current)?void 0:n.forceMount)?t:null==s?void 0:s.forceMount;Sge((()=>{if(!c)return l.item(i,null==s?void 0:s.id)}),[c]);let d=Mge(i,o,[e.value,e.children,o],e.keywords),m=oge(),h=Cge((e=>e.value&&e.value===d.current)),p=Cge((e=>!(!c&&!1!==l.filter())||(!e.search||e.filtered.items.get(i)>0)));function g(){var e,a;v(),null==(a=(e=u.current).onSelect)||a.call(e,d.current)}function v(){m.setState("value",d.current,!0)}if(r.useEffect((()=>{let a=o.current;if(a&&!e.disabled)return a.addEventListener(ege,g),()=>a.removeEventListener(ege,g)}),[p,e.onSelect,e.disabled]),!p)return null;let{disabled:f,value:y,onSelect:k,forceMount:b,keywords:S,...A}=e;return r.createElement(Y6.div,{ref:wge([o,a]),...A,id:i,"cmdk-item":"",role:"option","aria-disabled":!!f,"aria-selected":!!h,"data-disabled":!!f,"data-selected":!!h,onPointerMove:f||l.getDisablePointerSelection()?void 0:v,onClick:f?void 0:g},e.children)})),cge=r.forwardRef(((e,a)=>{let{heading:n,children:t,forceMount:i,...o}=e,s=E8(),l=r.useRef(null),u=r.useRef(null),c=E8(),d=ige(),m=Cge((e=>!(!i&&!1!==d.filter())||(!e.search||e.filtered.groups.has(s))));Sge((()=>d.group(s)),[]),Mge(s,l,[e.value,e.heading,u]);let h=r.useMemo((()=>({id:s,forceMount:i})),[i]);return r.createElement(Y6.div,{ref:wge([l,a]),...o,"cmdk-group":"",role:"presentation",hidden:!m||void 0},n&&r.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Ege(e,(e=>r.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},r.createElement(sge.Provider,{value:h},e)))))})),dge=r.forwardRef(((e,a)=>{let{alwaysRender:n,...t}=e,i=r.useRef(null),o=Cge((e=>!e.search));return n||o?r.createElement(Y6.div,{ref:wge([i,a]),...t,"cmdk-separator":"",role:"separator"}):null})),mge=r.forwardRef(((e,a)=>{let{onValueChange:n,...t}=e,i=null!=e.value,o=oge(),s=Cge((e=>e.search)),l=Cge((e=>e.value)),u=ige(),c=r.useMemo((()=>{var e;let a=null==(e=u.listInnerRef.current)?void 0:e.querySelector(`${Qpe}[${age}="${encodeURIComponent(l)}"]`);return null==a?void 0:a.getAttribute("id")}),[]);return r.useEffect((()=>{null!=e.value&&o.setState("search",e.value)}),[e.value]),r.createElement(Y6.input,{ref:a,...t,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":c,id:u.inputId,type:"text",value:i?e.value:s,onChange:e=>{i||o.setState("search",e.target.value),null==n||n(e.target.value)}})})),hge=r.forwardRef(((e,a)=>{let{children:n,label:t="Suggestions",...i}=e,o=r.useRef(null),s=r.useRef(null),l=ige();return r.useEffect((()=>{if(s.current&&o.current){let e,a=s.current,n=o.current,t=new ResizeObserver((()=>{e=requestAnimationFrame((()=>{n.style.setProperty("--cmdk-list-height",a.offsetHeight.toFixed(1)+"px")}))}));return t.observe(a),()=>{cancelAnimationFrame(e),t.unobserve(a)}}}),[]),r.createElement(Y6.div,{ref:wge([o,a]),...i,"cmdk-list":"",role:"listbox","aria-label":t,id:l.listId},Ege(e,(e=>r.createElement("div",{ref:wge([s,l.listInnerRef]),"cmdk-list-sizer":""},e))))})),pge=r.forwardRef(((e,a)=>{let{open:n,onOpenChange:t,overlayClassName:i,contentClassName:o,container:s,...l}=e;return r.createElement(C$,{open:n,onOpenChange:t},r.createElement(M$,{container:s},r.createElement(T$,{"cmdk-overlay":"",className:i}),r.createElement(E$,{"aria-label":e.label,"cmdk-dialog":"",className:o},r.createElement(lge,{ref:a,...l}))))})),gge=r.forwardRef(((e,a)=>Cge((e=>0===e.filtered.count))?r.createElement(Y6.div,{ref:a,...e,"cmdk-empty":"",role:"presentation"}):null)),vge=r.forwardRef(((e,a)=>{let{progress:n,children:t,label:i="Loading...",...o}=e;return r.createElement(Y6.div,{ref:a,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Ege(e,(e=>r.createElement("div",{"aria-hidden":!0},e))))})),fge=Object.assign(lge,{List:hge,Item:uge,Input:mge,Group:cge,Separator:dge,Dialog:pge,Empty:gge,Loading:vge});function yge(e,a){let n=e.nextElementSibling;for(;n;){if(n.matches(a))return n;n=n.nextElementSibling}}function kge(e,a){let n=e.previousElementSibling;for(;n;){if(n.matches(a))return n;n=n.previousElementSibling}}function bge(e){let a=r.useRef(e);return Sge((()=>{a.current=e})),a}var Sge="undefined"==typeof window?r.useEffect:r.useLayoutEffect;function Age(e){let a=r.useRef();return void 0===a.current&&(a.current=e()),a}function wge(e){return a=>{e.forEach((e=>{"function"==typeof e?e(a):null!=e&&(e.current=a)}))}}function Cge(e){let a=oge(),n=()=>e(a.snapshot());return Zpe.useSyncExternalStore(a.subscribe,n,n)}function Mge(e,a,n,t=[]){let i=r.useRef(),o=ige();return Sge((()=>{var r;let s=(()=>{var e;for(let a of n){if("string"==typeof a)return a.trim();if("object"==typeof a&&"current"in a)return a.current?null==(e=a.current.textContent)?void 0:e.trim():i.current}})(),l=t.map((e=>e.trim()));o.value(e,s,l),null==(r=a.current)||r.setAttribute(age,s),i.current=s})),i}var Tge=()=>{let[e,a]=r.useState(),n=Age((()=>new Map));return Sge((()=>{n.current.forEach((e=>e())),n.current=new Map}),[e]),(e,t)=>{n.current.set(e,t),a({})}};function Ege({asChild:e,children:a},n){return e&&r.isValidElement(a)?r.cloneElement(function(e){let a=e.type;return"function"==typeof a?a(e.props):"render"in a?a.render(e.props):e}(a),{ref:a.ref},n(a.props.children)):n(a)}var xge={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Nge=r.forwardRef((({className:e,...a},t)=>n.jsx(fge,{ref:t,className:vm("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a})));Nge.displayName=fge.displayName;const _ge=r.forwardRef((({className:e,searchIcon:a,...t},i)=>n.jsxs("div",{className:"flex items-center border-b px-3",children:[a||n.jsx(ud,{className:"mr-2 h-4 w-4 shrink-0 opacity-50 "}),n.jsx(fge.Input,{ref:i,className:vm("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})));_ge.displayName=fge.Input.displayName;const Pge=r.forwardRef((({className:e,...a},t)=>n.jsx(fge.List,{ref:t,className:vm("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a})));Pge.displayName=fge.List.displayName;const Lge=r.forwardRef(((e,a)=>n.jsx(fge.Empty,{ref:a,className:"py-6 text-center text-sm",...e})));Lge.displayName=fge.Empty.displayName;const jge=r.forwardRef((({className:e,...a},t)=>n.jsx(fge.Group,{ref:t,className:vm("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...a})));jge.displayName=fge.Group.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(fge.Separator,{ref:t,className:vm("-mx-1 h-px bg-border",e),...a}))).displayName=fge.Separator.displayName;const Bge=r.forwardRef((({className:e,...a},t)=>n.jsx(fge.Item,{ref:t,className:vm("relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...a})));function Rge(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function zge(...e){return a=>{let n=!1;const t=e.map((e=>{const t=Rge(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():Rge(e[a],null)}}}}function Dge(...e){return r.useCallback(zge(...e),e)}function Kge(e){const a=Oge(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Ige);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function Oge(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{const a=r(...e);return i(...e),a}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?zge(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}Bge.displayName=fge.Item.displayName;var Hge=Symbol("radix.slottable");function Ige(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Hge}var Gge=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=Kge(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),Fge=globalThis?.document?r.useLayoutEffect:()=>{};var Vge=e=>{const{present:a,children:n}=e,t=function(e){const[a,n]=r.useState(),t=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,n)=>a[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=Jge(t.current);o.current="mounted"===l?e:"none"}),[l]),Fge((()=>{const a=t.current,n=i.current;if(n!==e){const t=o.current,r=Jge(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(n&&t!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),Fge((()=>{if(a){let e;const n=a.ownerDocument.defaultView??window,r=r=>{const o=Jge(t.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const t=a.style.animationFillMode;a.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=t)}))}},s=e=>{e.target===a&&(o.current=Jge(t.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{n.clearTimeout(e),a.removeEventListener("animationstart",s),a.removeEventListener("animationcancel",r),a.removeEventListener("animationend",r)}}u("ANIMATION_END")}),[a,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{t.current=e?getComputedStyle(e):null,n(e)}),[])}}(a),i="function"==typeof n?n({present:t.isPresent}):r.Children.only(n),o=Dge(t.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||t.isPresent?r.cloneElement(i,{ref:o}):null};function Jge(e){return e?.animationName||"none"}function Uge(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function Wge(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}Vge.displayName="Presence";var qge=r.createContext(void 0);function Zge(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}var $ge="ScrollArea",[Yge,Qge]=function(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},Uge(i,...a)]}($ge),[Xge,eve]=Yge($ge),ave=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,type:i="hover",dir:o,scrollHideDelay:s=600,...l}=e,[u,c]=r.useState(null),[d,m]=r.useState(null),[h,p]=r.useState(null),[g,v]=r.useState(null),[f,y]=r.useState(null),[k,b]=r.useState(0),[S,A]=r.useState(0),[w,C]=r.useState(!1),[M,T]=r.useState(!1),E=Dge(a,(e=>c(e))),x=function(e){const a=r.useContext(qge);return e||a||"ltr"}(o);return n.jsx(Xge,{scope:t,type:i,dir:x,scrollHideDelay:s,scrollArea:u,viewport:d,onViewportChange:m,content:h,onContentChange:p,scrollbarX:g,onScrollbarXChange:v,scrollbarXEnabled:w,onScrollbarXEnabledChange:C,scrollbarY:f,onScrollbarYChange:y,scrollbarYEnabled:M,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:A,children:n.jsx(Gge.div,{dir:x,...l,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})}));ave.displayName=$ge;var nve="ScrollAreaViewport",tve=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,children:i,nonce:o,...s}=e,l=eve(nve,t),u=Dge(a,r.useRef(null),l.onViewportChange);return n.jsxs(n.Fragment,{children:[n.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),n.jsx(Gge.div,{"data-radix-scroll-area-viewport":"",...s,ref:u,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})}));tve.displayName=nve;var ive="ScrollAreaScrollbar",rve=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=eve(ive,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:l}=o,u="horizontal"===e.orientation;return r.useEffect((()=>(u?s(!0):l(!0),()=>{u?s(!1):l(!1)})),[u,s,l]),"hover"===o.type?n.jsx(ove,{...i,ref:a,forceMount:t}):"scroll"===o.type?n.jsx(sve,{...i,ref:a,forceMount:t}):"auto"===o.type?n.jsx(lve,{...i,ref:a,forceMount:t}):"always"===o.type?n.jsx(uve,{...i,ref:a}):null}));rve.displayName=ive;var ove=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=eve(ive,e.__scopeScrollArea),[s,l]=r.useState(!1);return r.useEffect((()=>{const e=o.scrollArea;let a=0;if(e){const n=()=>{window.clearTimeout(a),l(!0)},t=()=>{a=window.setTimeout((()=>l(!1)),o.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",t),()=>{window.clearTimeout(a),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",t)}}}),[o.scrollArea,o.scrollHideDelay]),n.jsx(Vge,{present:t||s,children:n.jsx(lve,{"data-state":s?"visible":"hidden",...i,ref:a})})})),sve=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=eve(ive,e.__scopeScrollArea),s="horizontal"===e.orientation,l=xve((()=>c("SCROLL_END")),100),[u,c]=(d={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},r.useReducer(((e,a)=>d[e][a]??e),"hidden"));var d;return r.useEffect((()=>{if("idle"===u){const e=window.setTimeout((()=>c("HIDE")),o.scrollHideDelay);return()=>window.clearTimeout(e)}}),[u,o.scrollHideDelay,c]),r.useEffect((()=>{const e=o.viewport,a=s?"scrollLeft":"scrollTop";if(e){let n=e[a];const t=()=>{const t=e[a];n!==t&&(c("SCROLL"),l()),n=t};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}}),[o.viewport,s,c,l]),n.jsx(Vge,{present:t||"hidden"!==u,children:n.jsx(uve,{"data-state":"hidden"===u?"hidden":"visible",...i,ref:a,onPointerEnter:Zge(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:Zge(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),lve=r.forwardRef(((e,a)=>{const t=eve(ive,e.__scopeScrollArea),{forceMount:i,...o}=e,[s,l]=r.useState(!1),u="horizontal"===e.orientation,c=xve((()=>{if(t.viewport){l(u?t.viewport.offsetWidth<t.viewport.scrollWidth:t.viewport.offsetHeight<t.viewport.scrollHeight)}}),10);return Nve(t.viewport,c),Nve(t.content,c),n.jsx(Vge,{present:i||s,children:n.jsx(uve,{"data-state":s?"visible":"hidden",...o,ref:a})})})),uve=r.forwardRef(((e,a)=>{const{orientation:t="vertical",...i}=e,o=eve(ive,e.__scopeScrollArea),s=r.useRef(null),l=r.useRef(0),[u,c]=r.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Ave(u.viewport,u.content),m={...i,sizes:u,onSizesChange:c,hasThumb:Boolean(d>0&&d<1),onThumbChange:e=>s.current=e,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:e=>l.current=e};function h(e,a){return function(e,a,n,t="ltr"){const i=wve(n),r=i/2,o=a||r,s=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-(i-o),u=n.content-n.viewport,c="ltr"===t?[0,u]:[-1*u,0];return Mve([s,l],c)(e)}(e,l.current,u,a)}return"horizontal"===t?n.jsx(cve,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=Cve(o.viewport.scrollLeft,u,o.dir);s.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollLeft=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollLeft=h(e,o.dir))}}):"vertical"===t?n.jsx(dve,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=Cve(o.viewport.scrollTop,u);s.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollTop=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollTop=h(e))}}):null})),cve=r.forwardRef(((e,a)=>{const{sizes:t,onSizesChange:i,...o}=e,s=eve(ive,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=Dge(a,c,s.onScrollbarXChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),n.jsx(pve,{"data-orientation":"horizontal",...o,ref:d,sizes:t,style:{bottom:0,left:"rtl"===s.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===s.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":wve(t)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.x),onDragScroll:a=>e.onDragScroll(a.x),onWheelScroll:(a,n)=>{if(s.viewport){const t=s.viewport.scrollLeft+a.deltaX;e.onWheelScroll(t),Tve(t,n)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Sve(l.paddingLeft),paddingEnd:Sve(l.paddingRight)}})}})})),dve=r.forwardRef(((e,a)=>{const{sizes:t,onSizesChange:i,...o}=e,s=eve(ive,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=Dge(a,c,s.onScrollbarYChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),n.jsx(pve,{"data-orientation":"vertical",...o,ref:d,sizes:t,style:{top:0,right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":wve(t)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.y),onDragScroll:a=>e.onDragScroll(a.y),onWheelScroll:(a,n)=>{if(s.viewport){const t=s.viewport.scrollTop+a.deltaY;e.onWheelScroll(t),Tve(t,n)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Sve(l.paddingTop),paddingEnd:Sve(l.paddingBottom)}})}})})),[mve,hve]=Yge(ive),pve=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,sizes:i,hasThumb:o,onThumbChange:s,onThumbPointerUp:l,onThumbPointerDown:u,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:m,onResize:h,...p}=e,g=eve(ive,t),[v,f]=r.useState(null),y=Dge(a,(e=>f(e))),k=r.useRef(null),b=r.useRef(""),S=g.viewport,A=i.content-i.viewport,w=Wge(m),C=Wge(c),M=xve(h,10);function T(e){if(k.current){d({x:e.clientX-k.current.left,y:e.clientY-k.current.top})}}return r.useEffect((()=>{const e=e=>{const a=e.target,n=v?.contains(a);n&&w(e,A)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[S,v,A,w]),r.useEffect(C,[i,C]),Nve(v,M),Nve(g.content,M),n.jsx(mve,{scope:t,scrollbar:v,hasThumb:o,onThumbChange:Wge(s),onThumbPointerUp:Wge(l),onThumbPositionChange:C,onThumbPointerDown:Wge(u),children:n.jsx(Gge.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Zge(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),k.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(e)}})),onPointerMove:Zge(e.onPointerMove,T),onPointerUp:Zge(e.onPointerUp,(e=>{const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=b.current,g.viewport&&(g.viewport.style.scrollBehavior=""),k.current=null}))})})})),gve="ScrollAreaThumb",vve=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,r=hve(gve,e.__scopeScrollArea);return n.jsx(Vge,{present:t||r.hasThumb,children:n.jsx(fve,{ref:a,...i})})})),fve=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,style:i,...o}=e,s=eve(gve,t),l=hve(gve,t),{onThumbPositionChange:u}=l,c=Dge(a,(e=>l.onThumbChange(e))),d=r.useRef(void 0),m=xve((()=>{d.current&&(d.current(),d.current=void 0)}),100);return r.useEffect((()=>{const e=s.viewport;if(e){const a=()=>{if(m(),!d.current){const a=Eve(e,u);d.current=a,u()}};return u(),e.addEventListener("scroll",a),()=>e.removeEventListener("scroll",a)}}),[s.viewport,m,u]),n.jsx(Gge.div,{"data-state":l.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:Zge(e.onPointerDownCapture,(e=>{const a=e.target.getBoundingClientRect();l.onThumbPointerDown({x:e.clientX-a.left,y:e.clientY-a.top})})),onPointerUp:Zge(e.onPointerUp,l.onThumbPointerUp)})}));vve.displayName=gve;var yve="ScrollAreaCorner",kve=r.forwardRef(((e,a)=>{const t=eve(yve,e.__scopeScrollArea),i=Boolean(t.scrollbarX&&t.scrollbarY);return"scroll"!==t.type&&i?n.jsx(bve,{...e,ref:a}):null}));kve.displayName=yve;var bve=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,...i}=e,o=eve(yve,t),[s,l]=r.useState(0),[u,c]=r.useState(0),d=Boolean(s&&u);return Nve(o.scrollbarX,(()=>{const e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),c(e)})),Nve(o.scrollbarY,(()=>{const e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),l(e)})),d?n.jsx(Gge.div,{...i,ref:a,style:{width:s,height:u,position:"absolute",right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:0,...e.style}}):null}));function Sve(e){return e?parseInt(e,10):0}function Ave(e,a){const n=e/a;return isNaN(n)?0:n}function wve(e){const a=Ave(e.viewport,e.content);return Math.max((e.scrollbar.size-(e.scrollbar.paddingStart+e.scrollbar.paddingEnd))*a,18)}function Cve(e,a,n="ltr"){const t=wve(a),i=a.content-a.viewport,r=a.scrollbar.size-(a.scrollbar.paddingStart+a.scrollbar.paddingEnd)-t,o=function(e,[a,n]){return Math.min(n,Math.max(a,e))}(e,"ltr"===n?[0,i]:[-1*i,0]);return Mve([0,i],[0,r])(o)}function Mve(e,a){return n=>{if(e[0]===e[1]||a[0]===a[1])return a[0];return a[0]+(a[1]-a[0])/(e[1]-e[0])*(n-e[0])}}function Tve(e,a){return e>0&&e<a}var Eve=(e,a=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},t=0;return function i(){const r={left:e.scrollLeft,top:e.scrollTop};(n.left!==r.left||n.top!==r.top)&&a(),n=r,t=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(t)};function xve(e,a){const n=Wge(e),t=r.useRef(0);return r.useEffect((()=>()=>window.clearTimeout(t.current)),[]),r.useCallback((()=>{window.clearTimeout(t.current),t.current=window.setTimeout(n,a)}),[n,a])}function Nve(e,a){const n=Wge(a);Fge((()=>{let a=0;if(e){const t=new ResizeObserver((()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(n)}));return t.observe(e),()=>{window.cancelAnimationFrame(a),t.unobserve(e)}}}),[e,n])}var _ve=ave,Pve=tve,Lve=kve;const jve=r.forwardRef((({className:e,children:a,...t},i)=>n.jsxs(_ve,{ref:i,className:P$("relative overflow-hidden",e),...t,children:[n.jsx(Pve,{className:"h-full w-full rounded-[inherit]",children:a}),n.jsx(Bve,{}),n.jsx(Lve,{})]})));jve.displayName=_ve.displayName;const Bve=r.forwardRef((({className:e,orientation:a="vertical",...t},i)=>n.jsx(rve,{ref:i,orientation:a,className:P$("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...t,children:n.jsx(vve,{className:"relative flex-1 rounded-full bg-border"})})));Bve.displayName=rve.displayName;var Rve=r.forwardRef(((e,a)=>{const{children:t,...i}=e,o=r.Children.toArray(t),s=o.find(Kve);if(s){const e=s.props.children,t=o.map((a=>a===s?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(zve,{...i,ref:a,children:r.isValidElement(e)?r.cloneElement(e,void 0,t):null})}return n.jsx(zve,{...i,ref:a,children:t})}));Rve.displayName="Slot";var zve=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?aq(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));zve.displayName="SlotClone";var Dve=({children:e})=>n.jsx(n.Fragment,{children:e});function Kve(e){return r.isValidElement(e)&&e.type===Dve}var Ove=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,a)=>{const t=r.forwardRef(((e,t)=>{const{asChild:i,...r}=e,o=i?Rve:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(o,{...r,ref:t})}));return t.displayName=`Primitive.${a}`,{...e,[a]:t}}),{}),Hve="horizontal",Ive=["horizontal","vertical"],Gve=r.forwardRef(((e,a)=>{const{decorative:t,orientation:i=Hve,...r}=e,o=function(e){return Ive.includes(e)}(i)?i:Hve;return n.jsx(Ove.div,{"data-orientation":o,...t?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...r,ref:a})}));Gve.displayName="Separator";var Fve=Gve;const Vve=r.forwardRef((({className:e,orientation:a="horizontal",decorative:t=!0,...i},r)=>n.jsx(Fve,{ref:r,decorative:t,orientation:a,className:vm("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...i})));function Jve({options:e,onValueChange:a,selectedValues:t,setSelectedValues:i,maxCount:o,placeholder:s="Select options",title:l="Select Items",searchPlaceholder:u="Search items...",emptyMessage:c="No items found",extraCommandItems:d=[],canOpen:m=!0,singleSelect:h=!1}){const[p,g]=r.useState(!1),[v,f]=r.useState(""),[y,k]=r.useState(t),b=r.useMemo((()=>Array.from(new Map([...e].filter((e=>e&&"string"==typeof e.value&&"string"==typeof e.label&&""!==e.value.trim()&&""!==e.label.trim())).map((e=>[e.value,e]))).values())),[e]),S=r.useMemo((()=>{if(!v)return b;return[...b.filter((e=>y.includes(e.value))),...b.filter((e=>!y.includes(e.value))).filter((e=>e.label.toLowerCase().includes(v.toLowerCase())))]}),[b,v,y]),A=r.useCallback((()=>t.map((a=>{const n=e.find((e=>e.value===a));return{value:a,label:n?.label||a}}))),[t,e]),w=e=>{if(h)return k([e]),a([e]),i([e]),void g(!1);k((a=>a.includes(e)?a.filter((a=>a!==e)):o&&a.length>=o?a:[...a,e]))};r.useEffect((()=>{p&&(k(t),f(""))}),[p,t]);const C=y.length,M=S.filter((e=>y.includes(e.value))).length,T=A(),E=!o||y.length<o,x=r.useMemo((()=>S.filter((e=>y.includes(e.value)))),[S,y]),N=r.useMemo((()=>S.filter((e=>!y.includes(e.value)))),[S,y]);return n.jsxs(L$,{open:p&&m,onOpenChange:m?g:void 0,children:[n.jsx(j$,{asChild:!0,children:n.jsxs(k5,{variant:"outline",disabled:!m,className:vm("w-full justify-between text-left font-normal h-9 p-3",!m&&"opacity-50 cursor-not-allowed"),children:[n.jsx("div",{className:"flex flex-nowrap items-center gap-1 max-w-[70%]",children:0===T.length?n.jsx("span",{className:"text-muted-foreground",children:s}):h?n.jsx(B5,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label}):T.length<=2?T.map((e=>n.jsx(B5,{variant:"secondary",className:"text-xs whitespace-nowrap",children:e.label},e.value))):n.jsxs(n.Fragment,{children:[n.jsx(B5,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label},T[0].value),n.jsxs(B5,{variant:"secondary",className:"text-xs whitespace-nowrap",children:["+",T.length-1," more"]})]})}),n.jsx(w5.DropdownMenuTrigger,{className:"h-4 w-4 opacity-50 ml-2 flex-shrink-0"})]})}),n.jsxs(z$,{className:"max-w-md w-full max-h-[80vh] p-0",children:[n.jsx(D$,{className:"p-6 pb-4",children:n.jsxs(O$,{className:"flex items-center gap-2 text-xl",children:[n.jsx(w5.UsersIcon,{className:"h-5 w-5 text-primary"}),l]})}),n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"relative",children:[n.jsx(w5.SearchIcon,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(qae,{placeholder:u,value:v,onChange:e=>f(e.target.value),className:"pl-10 h-11"})]})}),!h&&n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"flex items-center justify-between text-sm",children:[n.jsxs("span",{className:"text-muted-foreground",children:[C," of ",b.length," selected",o&&` (max ${o})`]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(k5,{variant:"ghost",size:"sm",onClick:()=>{const e=S.filter((e=>!y.includes(e.value))),a=o?e.slice(0,o-y.length):e;k((e=>[...e,...a.map((e=>e.value))]))},disabled:!E||M===S.length,className:"h-8 text-xs",children:"Select All"}),n.jsx(k5,{variant:"ghost",size:"sm",onClick:()=>{const e=new Set(S.map((e=>e.value)));k((a=>a.filter((a=>!e.has(a)))))},disabled:0===M,className:"h-8 text-xs",children:"Clear All"})]})]})}),n.jsx(Vve,{}),n.jsx(jve,{className:"flex-1 max-h-[300px]",children:n.jsx(Nge,{className:"rounded-none border-none",children:n.jsxs(jge,{children:[d.length>0&&n.jsxs(n.Fragment,{children:[d.map(((e,a)=>n.jsx("div",{className:"px-3 py-2",children:e(g)},`extra-command-${a}`))),n.jsx(Vve,{className:"my-2"})]}),0===S.length?n.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[n.jsx(w5.SearchIcon,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{children:c})]}):n.jsxs(n.Fragment,{children:[!h&&x.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:["Selected (",x.length,")"]}),x.map((e=>n.jsxs(Bge,{onSelect:()=>w(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors hover:bg-muted/50 cursor-pointer",children:[n.jsx(Rpe,{checked:!0,disabled:!1,onChange:()=>w(e.value),className:"flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),n.jsx(w5.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value))),n.jsx(Vve,{className:"my-2"})]}),n.jsx("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:h?"Options":`Available (${N.length})`}),N.map((e=>{const a=y.includes(e.value),t=!h&&!E;return n.jsxs(Bge,{onSelect:()=>!t&&w(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors "+(t?"opacity-50 cursor-not-allowed":"hover:bg-muted/50 cursor-pointer"),children:[!h&&n.jsx(Rpe,{checked:a,disabled:t,onChange:()=>!t&&w(e.value),className:"flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),a&&n.jsx(w5.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value)}))]})]})})}),!h&&n.jsxs(n.Fragment,{children:[n.jsx(Vve,{}),n.jsx("div",{className:"p-6 pt-4",children:n.jsxs("div",{className:"flex gap-3",children:[n.jsx(k5,{variant:"outline",onClick:()=>{k(t),f(""),g(!1)},className:"flex-1",children:"Cancel"}),n.jsxs(k5,{onClick:()=>{a(y),i(y),g(!1)},className:"flex-1 bg-primary hover:bg-primary/90",children:["Apply (",C,")"]})]})})]})]})]})}Vve.displayName=Fve.displayName;const Uve=r.forwardRef((({className:e,...a},t)=>n.jsx("textarea",{className:vm("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:t,...a})));Uve.displayName="Textarea";const Wve=e=>{const{companyName:a,smsBody:n}=e;return a&&n?`${a}:\n${n}`:n??""},qve=({body:e,imageUrls:a})=>n.jsx("div",{className:"sms-preview-outer @container",children:n.jsxs("div",{className:"sms-phone-mockup",children:[n.jsx("div",{className:"sms-phone-notch"}),n.jsxs("div",{className:"sms-phone-inner",children:[a&&a.length>0&&a.map(((e,a)=>n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:n.jsx("img",{src:e,alt:"MMS attachment",className:"sms-message-image",loading:"lazy"})})},e+a))),n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:e})})]}),n.jsx("div",{className:"sms-phone-home-indicator"})]})}),Zve=({mergeFieldsResponse:e})=>{const t=1500,i=d5(),r=m5(),{data:o}=Sre(),s=a.useCallback((()=>{const e=i?.actionData?.find((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId===r?.id));return e?.actionMetadata.communicationGroupId}),[i?.actionData,r?.id]),{channelSenders:l}=fre(),{data:u,isLoading:c}=ype(),{channelAccounts:d}=pre(),{toast:m}=Ge(),{updateCommunicationGroup:h,isUpdating:p}=$e(),[g,v]=a.useState(null),[f,y]=a.useState(!1),[k,b]=a.useState(null),[S,A]=a.useState(null),[w,C]=a.useState([]),[M,T]=a.useState(null),[E,x]=a.useState(!1),[N,_]=a.useState(!1),P=a.useRef(null),L=a.useRef(null),[j,B]=a.useState(null),[R,z]=a.useState(null),[D,K]=a.useState(!1),O=a.useMemo((()=>ale({channelSenders:l?.results??[],channelAccounts:d?.results??[],smsApplication:o})),[l,d,o]);a.useEffect((()=>{E&&(null===M&&T(S),w.length>0&&!j&&!D&&B(w[0]))}),[E,S,w,j,D,M]),a.useEffect((()=>{E||(B(w.length>0?w[0]:null),z(null),K(!1))}),[E,w]);a.useEffect((()=>{r&&(null===g&&v(r.smsChannelSenderId),null===S&&A(r.smsMessageBody),r.textMessageCompanyName&&null===k&&b(r.textMessageCompanyName),r.textMessageMediaUrls&&0===w.length&&C(r.textMessageMediaUrls),_(!0))}),[r,g,S,k,w]);a.useEffect((()=>{void 0!==l&&N&&(g?g&&r?.id&&h({groupId:r.id,params:{smsChannelSenderId:g}}):O?.[0]&&(v(O[0].channelSender.id),r?.id&&h({groupId:r.id,params:{smsChannelSenderId:O[0].channelSender.id}})))}),[l,g,r?.id,h,o,d?.results,r?.emailChannelSenderId,O,N]),a.useEffect((()=>{k||!u?.name||f||(y(!0),b(u.branding?.brandName?u.branding?.brandName:u.name))}),[k,u?.name,f,u?.branding?.brandName]);return d&&l&&!c&&void 0!==O&&void 0!==o?0===O?.length&&o?.status!==ele.PENDING?n.jsx(gpe,{}):n.jsxs("div",{children:[n.jsx(L$,{open:E,onOpenChange:x,children:n.jsxs(z$,{hideCloseButton:!0,className:"max-w-[50vw]",children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"SMS Editor"}),n.jsx(H$,{children:"Learn more about the SMS editor and how to use it to create your SMS."})]}),n.jsxs("div",{className:"",children:[j&&n.jsx("div",{className:"flex justify-center mb-6",children:n.jsxs("div",{className:"relative group w-fit",children:[n.jsx("img",{src:j,alt:"SMS attachment preview",className:"max-h-48 max-w-xs rounded-xl shadow-lg border border-gray-200 object-contain bg-white transition-transform duration-200 group-hover:scale-105",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.08)"}}),n.jsx(k5,{variant:"ghost",size:"icon",className:"absolute -top-3 -right-3 bg-white/80 hover:bg-red-100 text-gray-500 hover:text-red-500 shadow-md border border-gray-200 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{B(null),z(null),K(!1),L.current&&(L.current.value="")},style:{boxShadow:"0 2px 8px 0 rgba(0,0,0,0.10)"},children:n.jsx(Ad,{className:"h-4 w-4"})})]})}),n.jsx(Uve,{ref:P,className:"min-h-[300px]",placeholder:"Text message content...",value:M??"",onChange:e=>{T(e.target.value)},maxLength:t-(k?.length||0)}),n.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Jve,{options:e?.mergeFields?.flatMap((e=>e.entries.map((e=>({label:e.label,value:e.value})))))??[],selectedValues:[],setSelectedValues:()=>{},onValueChange:e=>{if(e.length>0){const a=P.current,n=M||"",t=a?.selectionStart??n.length,i=a?.selectionEnd??n.length,r=n.slice(0,t)+e[0]+n.slice(i);T(r),setTimeout((()=>{const n=t+e[0].length;a?.focus(),a?.setSelectionRange(n,n)}),0)}},placeholder:"Add merge field",title:"Merge Fields",searchPlaceholder:"Search merge fields...",emptyMessage:"No merge fields found",singleSelect:!0}),n.jsx(pue,{title:"Dynamic content is a way to insert dynamic content into your messages such as the customer's name, email, or other details."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("input",{type:"file",ref:L,onChange:async e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{try{const a=await async function(e){if(!bpe)throw new Error("Image conversion is only supported in browser environments");return new Promise(((a,n)=>{try{const t=new window.Image;t.crossOrigin="anonymous",t.onload=()=>{try{const e=document.createElement("canvas");e.width=t.naturalWidth,e.height=t.naturalHeight;const i=e.getContext("2d");if(!i)return void n(new Error("Failed to get canvas context"));i.drawImage(t,0,0);const r=e.toDataURL("image/png",1);a(r)}catch(e){n(e)}},t.onerror=()=>{n(new Error("Failed to load image"))},t.src=e}catch(t){n(t)}}))}(e.result),n=function(e){if(!e.startsWith("data:"))throw new Error('Invalid data URL: must start with "data:"');const a=e.split(",");if(2!==a.length)throw new Error("Invalid data URL format: missing base64 data");if(!a[0].includes(";base64"))throw new Error("Invalid data URL format: missing base64 encoding");return a[1]}(a);z(n),B(a),K(!1)}catch(a){m({title:"Error converting image",description:"Failed to convert image to PNG format",variant:"destructive"})}},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),n.jsx(k5,{variant:"outline",onClick:()=>{L.current?.click()},className:"px-4",disabled:w.length>=1||D||null!==R,children:"Add Image"}),n.jsx(k5,{variant:"outline",onClick:()=>{T(S),x(!1),B(w.length>0?w[0]:null),z(null),K(!1)},className:"px-4",children:"Cancel"}),n.jsx(k5,{onClick:()=>{if(M&&M.length>t)return void m({title:"SMS is too long",description:"Please shorten your message"});A(M);const e=s();e&&h({groupId:e,params:{smsChannelSenderId:g,smsMessageBody:M,textMessageCompanyName:k,textMessageMedia:R?[R]:D?[]:void 0}},{onSuccess:()=>{x(!1),B(null),z(null),K(!1)},onError:()=>{m({title:"Error updating SMS",description:"Please contact your administrator"})}})},className:"px-4",disabled:p,children:"Save Changes"})]})]}),n.jsxs("div",{className:"flex justify-end mt-2 text-sm transition-colors duration-300 items-center gap-2 "+(M&&M.length>320?M.length>=t?"text-red-500":"text-amber-500":"text-gray-500"),children:[M?M.length:0,"/",t-(k?.length||0)," characters",M&&M.length>320&&n.jsx(pue,{title:"The best delivery rates are achieved when the message is 320 characters or less.",onClick:()=>{window.open("https://help.twilio.com/articles/360033806753-Maximum-Message-Length-with-Twilio-Programmable-Messaging","_blank")},link:{url:"https://help.twilio.com/articles/360033806753-Maximum-Message-Length-with-Twilio-Programmable-Messaging",text:"The maximum number of characters for an SMS is 1500. This includes the company name, if you have one, and the merge fields. The recommended limit is 320 characters for best delivery rates. Click to learn more"}})]})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(Eue,{className:"text-foreground",children:"From Number"}),n.jsxs(nme,{onValueChange:e=>{v(e)},value:g??void 0,children:[n.jsx(rme,{children:n.jsx(ime,{placeholder:"Select number",children:g?(H=g,O?.find((e=>e.channelSender.id===H))?.channelSender.channelSenderMetadata.friendlyName??O?.find((e=>e.channelSender.id===H))?.channelSender.channelSenderMetadata.from??H):"Select number"})}),n.jsx(lme,{children:O?.map((e=>n.jsx(ume,{value:e.channelSender.id,children:e.channelSender.channelSenderMetadata.friendlyName??e.channelSender.channelSenderMetadata.from??"Select number"},e.channelSender.id)))})]})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 py-1",children:[n.jsx(Eue,{className:"text-foreground",children:"Company Name"}),n.jsx(pue,{title:"Adding your company name can help customers identify who they are talking to"})]}),n.jsx(qae,{placeholder:"Enter company name",value:k??"",onChange:e=>{const a=e.target.value;a.length>100?m({title:"Oops",description:"Company name cannot exceed 100 characters",variant:"destructive"}):b(a??null)},disabled:!g&&!o})]})]}),n.jsxs("div",{className:"border rounded-lg p-4",children:[n.jsxs("div",{className:"flex justify-between items-center mb-4",children:[n.jsx("h3",{className:"font-medium",children:"Preview"}),n.jsx("div",{children:n.jsx(k5,{onClick:()=>x(!0),className:"text-sm px-3 py-1 rounded ",disabled:0===(O?.length??0)&&void 0===o,children:"Edit"})})]}),n.jsx("div",{children:o?g||o?n.jsx(n.Fragment,{children:S?n.jsx(qve,{body:Wve({companyName:k??void 0,smsBody:S}),imageUrls:w}):n.jsx(cme,{type:"sms"})}):n.jsx(hme,{type:"sms"}):n.jsx("div",{children:"Submit an application"})})]})]})]}):n.jsx("div",{children:n.jsx(v5,{text:["Loading..."]})});var H},$ve=()=>{const e=m5(),{getMergeFields:a,isGetting:t}=Ye(e?.id??void 0);return t||!a?n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(v5,{text:["Fetching Content..."]})}):n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[n.jsx(Ame,{title:"SMS Campaign",type:"sms"}),n.jsx(Zve,{mergeFieldsResponse:a})]})},Yve=e=>e.friendlyName||e.from||e.messageServiceSid||"Unknown Sender";function Qve(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}function Xve(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},efe(i,...a)]}function efe(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function afe(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function nfe(...e){return a=>{let n=!1;const t=e.map((e=>{const t=afe(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():afe(e[a],null)}}}}function tfe(...e){return r.useCallback(nfe(...e),e)}function ife(e){const a=rfe(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(sfe);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function rfe(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?nfe(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var ofe=Symbol("radix.slottable");function sfe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===ofe}var lfe=globalThis?.document?r.useLayoutEffect:()=>{},ufe=r[" useId ".trim().toString()]||(()=>{}),cfe=0;function dfe(e){const[a,n]=r.useState(ufe());return lfe((()=>{n((e=>e??String(cfe++)))}),[e]),e||(a?`radix-${a}`:"")}var mfe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=ife(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});var hfe=r[" useInsertionEffect ".trim().toString()]||lfe;function pfe({prop:e,defaultProp:a,onChange:n=()=>{},caller:t}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[n,t]=r.useState(e),i=r.useRef(n),o=r.useRef(a);return hfe((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==n&&(o.current?.(n),i.current=n)}),[n,i]),[n,t,o]}({defaultProp:a,onChange:n}),l=void 0!==e,u=l?e:i;{const a=r.useRef(void 0!==e);r.useEffect((()=>{const e=a.current;if(e!==l){}a.current=l}),[l,t])}const c=r.useCallback((a=>{if(l){const n=function(e){return"function"==typeof e}(a)?a(e):a;n!==e&&s.current?.(n)}else o(a)}),[l,e,o,s]);return[u,c]}var gfe=r.createContext(void 0);function vfe(e){const a=r.useContext(gfe);return e||a||"ltr"}var ffe="rovingFocusGroup.onEntryFocus",yfe={bubbles:!1,cancelable:!0},kfe="RovingFocusGroup",[bfe,Sfe,Afe]=function(e){const t=e+"CollectionProvider",[i,r]=Xve(t),[o,s]=i(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:t,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return n.jsx(o,{scope:t,itemMap:s,collectionRef:r,children:i})};l.displayName=t;const u=e+"CollectionSlot",c=ife(u),d=a.forwardRef(((e,a)=>{const{scope:t,children:i}=e,r=tfe(a,s(u,t).collectionRef);return n.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=ife(m),g=a.forwardRef(((e,t)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=tfe(t,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),n.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(n){const t=s(e+"CollectionConsumer",n);return a.useCallback((()=>{const e=t.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(t.itemMap.values()).sort(((e,n)=>a.indexOf(e.ref.current)-a.indexOf(n.ref.current)))}),[t.collectionRef,t.itemMap])},r]}(kfe),[wfe,Cfe]=Xve(kfe,[Afe]),[Mfe,Tfe]=wfe(kfe),Efe=r.forwardRef(((e,a)=>n.jsx(bfe.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(bfe.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(xfe,{...e,ref:a})})})));Efe.displayName=kfe;var xfe=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:t,orientation:i,loop:o=!1,dir:s,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:m=!1,...h}=e,p=r.useRef(null),g=tfe(a,p),v=vfe(s),[f,y]=pfe({prop:l,defaultProp:u??null,onChange:c,caller:kfe}),[k,b]=r.useState(!1),S=function(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}(d),A=Sfe(t),w=r.useRef(!1),[C,M]=r.useState(0);return r.useEffect((()=>{const e=p.current;if(e)return e.addEventListener(ffe,S),()=>e.removeEventListener(ffe,S)}),[S]),n.jsx(Mfe,{scope:t,orientation:i,dir:v,loop:o,currentTabStopId:f,onItemFocus:r.useCallback((e=>y(e)),[y]),onItemShiftTab:r.useCallback((()=>b(!0)),[]),onFocusableItemAdd:r.useCallback((()=>M((e=>e+1))),[]),onFocusableItemRemove:r.useCallback((()=>M((e=>e-1))),[]),children:n.jsx(mfe.div,{tabIndex:k||0===C?-1:0,"data-orientation":i,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:Qve(e.onMouseDown,(()=>{w.current=!0})),onFocus:Qve(e.onFocus,(e=>{if(e.target===e.currentTarget&&!w.current&&!k){const a=new CustomEvent(ffe,yfe);if(e.currentTarget.dispatchEvent(a),!a.defaultPrevented){const e=A().filter((e=>e.focusable));Lfe([e.find((e=>e.active)),e.find((e=>e.id===f)),...e].filter(Boolean).map((e=>e.ref.current)),m)}}w.current=!1})),onBlur:Qve(e.onBlur,(()=>b(!1)))})})})),Nfe="RovingFocusGroupItem",_fe=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:o=!1,tabStopId:s,children:l,...u}=e,c=dfe(),d=s||c,m=Tfe(Nfe,t),h=m.currentTabStopId===d,p=Sfe(t),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:f}=m;return r.useEffect((()=>{if(i)return g(),()=>v()}),[i,g,v]),n.jsx(bfe.ItemSlot,{scope:t,id:d,focusable:i,active:o,children:n.jsx(mfe.span,{tabIndex:h?0:-1,"data-orientation":m.orientation,...u,ref:a,onMouseDown:Qve(e.onMouseDown,(e=>{i?m.onItemFocus(d):e.preventDefault()})),onFocus:Qve(e.onFocus,(()=>m.onItemFocus(d))),onKeyDown:Qve(e.onKeyDown,(e=>{if("Tab"===e.key&&e.shiftKey)return void m.onItemShiftTab();if(e.target!==e.currentTarget)return;const a=function(e,a,n){const t=function(e,a){return"rtl"!==a?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,n);return"vertical"===a&&["ArrowLeft","ArrowRight"].includes(t)||"horizontal"===a&&["ArrowUp","ArrowDown"].includes(t)?void 0:Pfe[t]}(e,m.orientation,m.dir);if(void 0!==a){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=p().filter((e=>e.focusable)).map((e=>e.ref.current));if("last"===a)i.reverse();else if("prev"===a||"next"===a){"prev"===a&&i.reverse();const r=i.indexOf(e.currentTarget);i=m.loop?(t=r+1,(n=i).map(((e,a)=>n[(t+a)%n.length]))):i.slice(r+1)}setTimeout((()=>Lfe(i)))}var n,t})),children:"function"==typeof l?l({isCurrentTabStop:h,hasTabStop:null!=f}):l})})}));_fe.displayName=Nfe;var Pfe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Lfe(e,a=!1){const n=document.activeElement;for(const t of e){if(t===n)return;if(t.focus({preventScroll:a}),document.activeElement!==n)return}}var jfe=Efe,Bfe=_fe;var Rfe=e=>{const{present:a,children:n}=e,t=function(e){const[a,n]=r.useState(),t=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,n)=>a[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=zfe(t.current);o.current="mounted"===l?e:"none"}),[l]),lfe((()=>{const a=t.current,n=i.current;if(n!==e){const t=o.current,r=zfe(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(n&&t!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),lfe((()=>{if(a){let e;const n=a.ownerDocument.defaultView??window,r=r=>{const o=zfe(t.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const t=a.style.animationFillMode;a.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=t)}))}},s=e=>{e.target===a&&(o.current=zfe(t.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{n.clearTimeout(e),a.removeEventListener("animationstart",s),a.removeEventListener("animationcancel",r),a.removeEventListener("animationend",r)}}u("ANIMATION_END")}),[a,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{t.current=e?getComputedStyle(e):null,n(e)}),[])}}(a),i="function"==typeof n?n({present:t.isPresent}):r.Children.only(n),o=tfe(t.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||t.isPresent?r.cloneElement(i,{ref:o}):null};function zfe(e){return e?.animationName||"none"}Rfe.displayName="Presence";var Dfe="Tabs",[Kfe,Ofe]=Xve(Dfe,[Cfe]),Hfe=Cfe(),[Ife,Gfe]=Kfe(Dfe),Ffe=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,onValueChange:r,defaultValue:o,orientation:s="horizontal",dir:l,activationMode:u="automatic",...c}=e,d=vfe(l),[m,h]=pfe({prop:i,onChange:r,defaultProp:o??"",caller:Dfe});return n.jsx(Ife,{scope:t,baseId:dfe(),value:m,onValueChange:h,orientation:s,dir:d,activationMode:u,children:n.jsx(mfe.div,{dir:d,"data-orientation":s,...c,ref:a})})}));Ffe.displayName=Dfe;var Vfe="TabsList",Jfe=r.forwardRef(((e,a)=>{const{__scopeTabs:t,loop:i=!0,...r}=e,o=Gfe(Vfe,t),s=Hfe(t);return n.jsx(jfe,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:i,children:n.jsx(mfe.div,{role:"tablist","aria-orientation":o.orientation,...r,ref:a})})}));Jfe.displayName=Vfe;var Ufe="TabsTrigger",Wfe=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,disabled:r=!1,...o}=e,s=Gfe(Ufe,t),l=Hfe(t),u=$fe(s.baseId,i),c=Yfe(s.baseId,i),d=i===s.value;return n.jsx(Bfe,{asChild:!0,...l,focusable:!r,active:d,children:n.jsx(mfe.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:u,...o,ref:a,onMouseDown:Qve(e.onMouseDown,(e=>{r||0!==e.button||!1!==e.ctrlKey?e.preventDefault():s.onValueChange(i)})),onKeyDown:Qve(e.onKeyDown,(e=>{[" ","Enter"].includes(e.key)&&s.onValueChange(i)})),onFocus:Qve(e.onFocus,(()=>{d||r||!("manual"!==s.activationMode)||s.onValueChange(i)}))})})}));Wfe.displayName=Ufe;var qfe="TabsContent",Zfe=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,forceMount:o,children:s,...l}=e,u=Gfe(qfe,t),c=$fe(u.baseId,i),d=Yfe(u.baseId,i),m=i===u.value,h=r.useRef(m);return r.useEffect((()=>{const e=requestAnimationFrame((()=>h.current=!1));return()=>cancelAnimationFrame(e)}),[]),n.jsx(Rfe,{present:o||m,children:({present:t})=>n.jsx(mfe.div,{"data-state":m?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":c,hidden:!t,id:d,tabIndex:0,...l,ref:a,style:{...e.style,animationDuration:h.current?"0s":void 0},children:t&&s})})}));function $fe(e,a){return`${e}-trigger-${a}`}function Yfe(e,a){return`${e}-content-${a}`}Zfe.displayName=qfe;var Qfe=Jfe,Xfe=Wfe,eye=Zfe;const aye=Ffe,nye=r.forwardRef((({className:e,...a},t)=>n.jsx(Qfe,{ref:t,className:vm("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...a})));nye.displayName=Qfe.displayName;const tye=r.forwardRef((({className:e,...a},t)=>n.jsx(Xfe,{ref:t,className:vm("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...a})));tye.displayName=Xfe.displayName;const iye=r.forwardRef((({className:e,...a},t)=>n.jsx(eye,{ref:t,className:vm("ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a})));iye.displayName=eye.displayName;const rye=({onOpenChange:e})=>n.jsx("div",{role:"button",tabIndex:0,"aria-label":"Close dialog",onClick:()=>e(!1),onKeyDown:a=>{"Enter"!==a.key&&" "!==a.key||e(!1)},className:"absolute top-3 right-3 z-20 rounded-full p-2 bg-white/80 shadow-lg border border-gray-200 hover:bg-primary/90 hover:text-white active:bg-primary/95 transition-all duration-200 focus:outline-none focus:ring-4 focus:ring-primary/30 focus:ring-offset-2 group cursor-pointer",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)"},children:n.jsx(w5.CloseButton,{className:"w-5 h-5 text-primary group-hover:text-primary-foreground group-active:text-primary-foreground transition-colors duration-200"})}),oye=({selectedChannels:e,setSelectedChannels:a,hasEmailChannelSenders:t,hasSmsChannelSenders:i,automationType:r})=>{const{toast:o}=Ge(),s=[...t?[{label:"Email",value:"email",icon:w5.EmailIcon,checked:e.includes("email")}]:[],...i?[{label:"SMS",value:"sms",icon:w5.SmsIcon,checked:e.includes("sms")}]:[]];return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-xl font-medium text-foreground",children:"Message Types"}),n.jsxs("p",{className:"text-muted-foreground mb-2 text-sm",children:["Select the channels you want to use in this"," ",r===sa.ONE_TIME?_h("engage:broadcast").toLowerCase():_h("engage:automation").toLowerCase()]})]}),n.jsx("div",{className:"w-full grid grid-cols-2 gap-3",children:s.map((t=>n.jsxs(jpe,{checked:t.checked,onCheckedChange:()=>{"email"===t.value?e.includes("email")?e.includes("sms")?a(["sms"]):o({title:"Cant Remove Email",description:`At least one channel is required for an ${r===sa.ONE_TIME?_h("engage:broadcast").toLowerCase():_h("engage:automation").toLowerCase()}`,variant:"destructive"}):a([...e,"email"]):e.includes("sms")?e.includes("email")?a(["email"]):o({title:"Cant Remove SMS",description:`At least one channel is required for an ${r===sa.ONE_TIME?_h("engage:broadcast").toLowerCase():_h("engage:automation").toLowerCase()}`,variant:"destructive"}):a([...e,"sms"])},className:"relative ring-[1px] ring-border rounded-lg px-4 py-3 text-start text-muted-foreground data-[state=checked]:ring-2 data-[state=checked]:ring-primary data-[state=checked]:font-medium",children:[n.jsx(t.icon,{className:"mb-3",size:20}),n.jsx("span",{className:"font-medium tracking-tight",children:t.label}),n.jsx(Bpe,{className:"absolute top-2 right-2",children:n.jsx(Kc,{className:"fill-primary text-primary-foreground"})})]},t.value)))})]})},sye=({getExtraMergeFields:e})=>{const[t,i]=a.useState(null),r=a.useRef(null),{toast:o}=Ge(),s=m5(),{channelSenders:l}=fre(),{channelAccounts:u}=pre(),{updateCommunicationGroup:c}=$e(),d=d5(),{data:m}=Sre(),{setSelectedSubStepType:h}=a.useContext(Q4),{getMergeFields:p,isGetting:g}=Ye(s?.id??void 0),[v,f]=a.useState(void 0);a.useEffect((()=>{const e=s?.id;e&&t&&(t.includes("email")||null===s?.emailChannelSenderId||c({groupId:e,params:{emailChannelSenderId:null}}),t.includes("sms")||null===s?.smsChannelSenderId||c({groupId:e,params:{smsChannelSenderId:null}}),1===t.length&&("email"===t[0]&&h(Sme.EMAIL),"sms"===t[0]&&h(Sme.SMS)))}),[t,c,s,m,h]),a.useEffect((()=>{const e=s?.id;e||0!==t?.length||i(["email"])}),[d,s,t]);const y=a.useCallback((e=>{const a=[];e.emailChannelSenderId&&a.push("email"),e.smsChannelSenderId&&a.push("sms"),0===a.length&&a.push("email"),i(a)}),[]);a.useEffect((()=>{s&&!t&&y(s)}),[s,y,t]),a.useEffect((()=>{g||void 0===v&&(e?e().then((e=>{s?.id&&(y(s),c({groupId:s?.id,params:{extraMergeFields:e}},{onSuccess:async()=>{try{const e=await Ve(s?.id);f(e)}catch{o({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}},onError:e=>{o({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}}))})):f(p))}),[e,c,s,o,g,p,v,y]);const k=a.useMemo((()=>wme({channelSenders:l?.results??[],channelAccounts:u?.results??[]})),[l?.results,u?.results]),b=a.useMemo((()=>ale({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:m})),[l?.results,u?.results,m]);if(!t||g||!v||!k||!b)return n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(v5,{text:["Fetching Content..."]})});const S=k.length>0,A=b.length>0;return n.jsxs("div",{className:"flex flex-col gap-4 flex-shrink-0",children:[n.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(oye,{automationType:d?.triggerMetadata?.triggerType,selectedChannels:t,setSelectedChannels:i,hasEmailChannelSenders:S,hasSmsChannelSenders:A})}),t.includes("email")&&n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",ref:r,children:[n.jsx(Ame,{title:"Email Campaign",type:"email"}),n.jsx(yme,{mergeFieldsResponse:v,emailChannelSendersWithChannelAccounts:k})]}),t.includes("sms")&&n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[n.jsx(Ame,{title:"SMS Campaign",type:"sms"}),n.jsx(Zve,{mergeFieldsResponse:v})]})]})},lye=({open:e,onOpenChange:a})=>n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"max-w-[75vw] min-h-[75vh] overflow-y-auto max-h-[90vh] po",hideCloseButton:!0,children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Edit Campaign Content"}),n.jsx(H$,{children:"Edit the content of the campaign"})]}),n.jsx(rye,{onOpenChange:a}),n.jsx(sye,{})]})}),uye=()=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"}),n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"}),n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"})]}),cye=({children:e,actionButtons:a})=>n.jsxs("div",{className:"flex-1 w-full relative overflow-hidden max-w-screen-lg mx-auto",children:[n.jsxs("div",{className:"h-full relative w-full rounded-2xl bg-white border border-zinc-200 overflow-hidden min-h-[500px] flex flex-col",style:{containerType:"inline-size"},children:[n.jsxs("div",{className:"flex items-center space-x-3 pt-3 px-4 z-10 w-full justify-between",children:[n.jsx(uye,{}),a&&n.jsx("div",{className:"flex items-center space-x-2",children:a})]}),e]}),n.jsx("div",{className:"text-center text-sm text-muted-foreground mt-4",children:n.jsx("p",{children:"These previews show exactly how your messages will appear to your customers"})})]}),dye=()=>{const e=d5(),t=m5(),{channelSenders:i}=fre(),{channelAccounts:r}=pre(),o=a.useMemo((()=>i?.results?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=r?.results?.find((a=>a.id===e.channelAccountId));return a&&a.channelAccountMetadata.type===gre.REACH_MANAGED?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,channelSenderMetadata:e.channelSenderMetadata}]:[]}))||[]),[i?.results,r?.results]),s=t?.emailChannelSenderId;if(!(e&&t&&o&&s))return null;const l=o.find((e=>e.channelSenderId===s)),u=l?.fullDomain,c=l?.channelSenderMetadata.emailReplyTo,d=t.emailSubject,m=t.emailPreviewText,h=l?.channelSenderMetadata.emailFromName;return n.jsxs("div",{className:"space-y-1 overflow-hidden",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"From"}),n.jsxs("div",{className:"text-base font-medium",children:[u,h&&n.jsxs("span",{className:"text-muted-foreground",children:["<",h,">"]})]})]}),c&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Reply-To"}),n.jsx("div",{className:"text-base font-medium",children:c})]}),d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Subject"}),n.jsx("div",{className:"text-base font-medium",children:d})]}),m&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Preview Text"}),n.jsx("div",{className:"text-sm font-medium line-clamp-2",children:m})]})]})},mye=({emailBody:e})=>{const[t,i]=a.useState({width:0,height:0}),r=a.useRef(null);return a.useEffect((()=>{const e=()=>{r.current&&requestAnimationFrame((()=>{i({width:r.current?r.current.offsetWidth-75:0,height:r.current?r.current.offsetHeight-75:0})}))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[r]),n.jsxs(cye,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(dye,{})})}),n.jsx("div",{className:"rounded-lg p-6 bg-white flex-1 min-h-0 flex items-center justify-center",ref:r,children:n.jsx(dme,{html:e,height:t.height,width:t.width})})]})},hye=({expandDialogContent:e})=>{const[t,i]=a.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(L$,{open:t,onOpenChange:i,children:n.jsxs(z$,{hideCloseButton:!0,className:"w-[80vw] h-[80vh] max-h-none bg-transparent border-none max-w-screen-lg ",children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Expanded Preview"}),n.jsx(H$,{children:"Expanded view of communication content"})]}),n.jsxs("div",{className:"h-full flex flex-col overflow-hidden rounded-xl",children:[n.jsx(rye,{onOpenChange:i}),e]})]})}),n.jsx(k5,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 flex items-center gap-2 shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>i(!0),children:n.jsx(w5.ExpandIcon,{className:"w-4 h-4 text-muted-foreground"})})]})},pye=({type:e,disablePreviewSubtext:a=!1})=>{const t="sms"===e?"SMS":"Email";return n.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center",children:n.jsxs("div",{className:"flex flex-col items-center justify-center bg-zinc-50/80 border border-zinc-100 rounded-2xl shadow-md px-6 py-12 max-w-[90vw] w-full sm:max-w-md mx-auto text-center",style:{containerType:"inline-size"},children:[n.jsx("sms"===e?w5.SmsIcon:w5.EmailIcon,{className:"w-12 h-12 text-zinc-500 mb-4"}),n.jsxs("h2",{className:"text-xl font-semibold text-zinc-800 mb-2",children:["No ",t," Content Yet"]}),!a&&n.jsxs("p",{className:"text-zinc-500 text-base mb-1",children:["Click"," ",n.jsx("span",{className:"font-medium text-zinc-700",children:"Edit content"})," to start crafting your ",t," message."]})]})})},gye=a.forwardRef((({onClick:e},a)=>n.jsxs(k5,{ref:a,variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 flex items-center gap-2 shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:e,children:[n.jsx(w5.PreviewButton,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium text-sm",children:"Test"})]})));gye.displayName="PreviewButton";const vye=e=>/^[^\s@.]+(?:\.[^\s@.]+)*@[^\s@.]+(?:\.[^\s@.]+)+$/.test(e),fye=e=>{if(!/^[0-9\s()+.-]+$/.test(e))return!1;const a=e.replace(/\D/g,"");return e.startsWith("+")?a.length>=10&&a.length<=15:10===a.length||!(11!==a.length||!a.startsWith("1"))},yye=e=>{const a=e.replace(/\D/g,"");if(10===a.length)return`(${a.slice(0,3)}) ${a.slice(3,6)}-${a.slice(6)}`;if(11===a.length&&a.startsWith("1"))return`+1 (${a.slice(1,4)}) ${a.slice(4,7)}-${a.slice(7)}`;if(a.length>0){const n=e.startsWith("+")?"+":"",t=a.slice((e.startsWith("+"),0));return`${n}${t.match(/.{1,4}/g)?.join("-")||t}`}return e},kye=({automation:e,type:t,setOpenSendPreviewPopup:i,open:r})=>{const[o,s]=a.useState(""),[l,u]=a.useState(""),[c,d]=a.useState(null),[m,h]=a.useState(!1),[p,g]=a.useState(""),[v,f]=a.useState(!1),{sendTestCommunication:y,sendError:k,isSendSuccess:b}=Qe(),{toast:S}=Ge(),A=e.actionData?.find((e=>"send_communication"===e.actionType)),w=A?.actionMetadata.communicationGroupId,{communicationGroup:C,isGetting:M}=Ze(w??void 0),{data:T}=i5({includeSegments:e.includeSegmentIds,excludeSegments:e.excludeSegmentIds,automationId:e.id}),E=a.useRef(null),x=a.useMemo((()=>[...T?.recipients??[]].filter((e=>!(!e.firstName||!e.lastName)&&(!("email"===t&&!e.email)&&!("sms"===t&&!e.phone))))),[T?.recipients,t]),N=a.useCallback((()=>{if(!w)return Promise.resolve(null);if(!C)return Promise.reject(new Error("Communication group not loaded"));switch(t){case"email":return Promise.resolve(C.emailChannelSenderId);case"sms":return Promise.resolve(C.smsChannelSenderId);default:return Promise.reject(new Error(`Unsupported type: ${t}`))}}),[C,t,w]);a.useEffect((()=>{(async()=>{try{const e=await N();d(e)}catch(e){d(null)}finally{h(!0)}})()}),[N]),a.useEffect((()=>{b&&(S({title:"Success",description:`Preview ${"email"===t?"email":"SMS"} sent successfully!`}),i(!1))}),[b,t,i,S]),a.useEffect((()=>{k&&(S({title:"Error",description:`Failed to send preview: ${k.message}`,variant:"destructive"}),i(!1))}),[k,S,i]),a.useEffect((()=>{r&&(s(""),u(""),g(""),f(!1))}),[r]),a.useEffect((()=>{!r&&v&&setTimeout((()=>{document.body.style.pointerEvents=""}),0)}),[r,v]);return m&&!M&&T?c?n.jsxs("div",{className:"",ref:E,children:[n.jsxs("h3",{className:"text-xl font-semibold text-gray-900 mb-4",children:["Send Test ","email"===t?"Email":"Text"]}),n.jsx(qae,{type:"email"===t?"email":"tel",placeholder:"email"===t?"Enter email address":"Enter phone number",value:o,onChange:e=>{s(e.target.value),u("")},className:"w-full px-3 py-3 border border-gray-300 rounded-lg text-base \n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\n placeholder-gray-400"}),n.jsxs("p",{className:"text-sm text-muted-foreground mt-1.5",children:["Enter a valid ","email"===t?"email address":"phone number"," to send a test to that recipient."]}),n.jsx("div",{className:"my-4 border-t border-gray-200"}),n.jsxs("div",{className:"mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(nme,{value:p,onValueChange:e=>{g(e)},onOpenChange:e=>{f(e),!e&&E.current&&E.current.focus()},children:[n.jsx(rme,{className:"w-full bg-white border border-gray-300 rounded-lg text-base\n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:n.jsx(ime,{children:p?T?.recipients.find((e=>e.id===p))?.firstName+" "+T?.recipients.find((e=>e.id===p))?.lastName:"Preview as"})}),n.jsx(lme,{position:"popper",className:"z-[100]",children:n.jsx(tme,{children:x.map((e=>n.jsx(ume,{value:e.id,className:"cursor-pointer hover:bg-gray-50",children:n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("span",{className:"font-medium",children:[e.firstName," ",e.lastName]}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:[e.email&&`Email: ${e.email}`,e.email&&e.phone&&" • ",e.phone&&`Phone: ${e.phone}`]})]})},`${e.firstName}-${e.lastName}`)))})})]}),p&&n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>g(""),className:"h-10 w-10 rounded-lg hover:bg-gray-100",title:"Clear selection",children:n.jsx(w5.CloseButton,{className:"h-4 w-4 text-gray-500"})})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1.5",children:"Optional: Test as a specific recipient to see how the message will appear with their data. If not selected, raw merge tags will be used."})]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"my-4 border-t border-gray-200"}),n.jsx("p",{className:"text-red-500 text-sm mb-4 -mt-2",children:l})]}),n.jsx(k5,{onClick:()=>{if(!("email"===t?vye(o):fye(o)))return void u("Please enter a valid "+("email"===t?"email address":"phone number"));if(!c)return void u("No sender found, please update the automation first!");const a=e.actionData?.find((e=>"send_communication"===e.actionType)),n=a?.actionMetadata.communicationGroupId;if(!n)return Promise.resolve(null);y({id:n,params:"email"===t?{emailAddress:o,previewAsRecipientId:p}:{phoneNumber:o,previewAsRecipientId:p}})},disabled:!o,className:"w-full disabled:cursor-not-allowed",children:"Send Test"})]}):n.jsx("div",{className:"flex justify-center items-center h-full",children:n.jsxs("div",{className:"text-center flex flex-col justify-center items-center gap-2",children:[n.jsx(w5.AlertCircleIcon,{className:"h-12 w-12 text-gray-400 mb-4"}),n.jsx("h3",{className:"text-lg font-semibold text-gray-700 mb-2",children:"No sender found"}),n.jsx("p",{className:"text-gray-500",children:"Please update the automation to include a sender for this type"})]})}):n.jsx("div",{className:"flex justify-center items-center h-full",children:n.jsx(v5,{text:["Fetching sender data","Fetching recipients"]})})},bye=({open:e,onOpenChange:a,automation:t})=>n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Send Preview Email"}),n.jsx(H$,{children:"Send a preview email to the automation."})]}),n.jsx(kye,{automation:t,type:"email",setOpenSendPreviewPopup:a,open:e})]})}),Sye=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1})=>{const r=d5(),o=m5(),{channelSenders:s}=fre(),{channelAccounts:l}=pre(),[u,c]=a.useState({width:0,height:0}),[d,m]=a.useState(!1),[h,p]=a.useState(!1),g=a.useRef(null);if(a.useEffect((()=>{const e=()=>{g.current&&requestAnimationFrame((()=>{c({width:g.current?g.current.offsetWidth-75:0,height:g.current?g.current.offsetHeight-75:0})}))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[g]),!r||!o||void 0===s||void 0===l)return null;const v=o?.emailHtmlBody||"",f=o?.emailChannelSenderId&&v.length>0,y=wme({channelSenders:s?.results??[],channelAccounts:l?.results??[]});let k=null;return o?.emailChannelSenderId||(k="Please first select an email sender"),o?.emailSubject||(k="Please first ensure you have an email subject"),o?.emailHtmlBody||(k="Please first ensure you have an email content"),n.jsxs("div",{className:"flex-1 flex flex-col items-center w-full",children:[n.jsx(lye,{open:h,onOpenChange:p}),y.length>0&&n.jsx(bye,{open:d,onOpenChange:m,automation:r}),n.jsx(cye,{actionButtons:n.jsx(n.Fragment,{children:n.jsxs("div",{className:"flex items-center space-x-2",children:[!e&&f&&(k?n.jsx(pue,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!0,children:n.jsx(gye,{onClick:()=>m(!0)})}):n.jsx(gye,{onClick:()=>m(!0)})),!t&&r.status===da.DRAFT&&n.jsx(k5,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 font-medium text-sm shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>p(!0),children:"Edit content"}),f&&n.jsx(hye,{expandDialogContent:n.jsx(mye,{emailBody:v})})]})}),children:f?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(dye,{})})}),n.jsx("div",{className:"w-full h-[1.5px] bg-zinc-200 my-2"}),n.jsx("div",{className:"flex-1 w-full overflow-auto h-full min-h-[500px]",ref:g,children:n.jsx(dme,{html:v,height:u.height,width:u.width})})]}):n.jsx(pye,{type:"email",disablePreviewSubtext:i})})]})},Aye=()=>{const e=d5(),t=m5(),{channelSenders:i}=fre(),{channelAccounts:r}=pre(),{data:o}=Sre(),s=a.useMemo((()=>ale({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o})),[i?.results,r?.results,o]),l=s?.find((e=>e.channelSender.id===t?.smsChannelSenderId));if(!l&&!o)return null;if(!(e&&t&&i&&r&&s&&(void 0!==o||l)))return null;const u=l?.channelSender.channelSenderMetadata.from&&null!==l.channelSender.channelSenderMetadata.from?l.channelSender.channelSenderMetadata.from:null,c=l?.channelSender.channelSenderMetadata.friendlyName??(u&&null!==u?yye(u??""):l?.channelSender.channelSenderMetadata.messageServiceSid);return n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"From"}),n.jsx("div",{className:"text-base font-medium font-mono text-zinc-800",children:c})]})})},wye=({smsBody:e,imageUrls:a})=>n.jsxs(cye,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(Aye,{})})}),n.jsx("div",{className:"rounded-lg p-6 bg-white flex-1 min-h-0 flex items-center justify-center",children:n.jsx(qve,{body:e,imageUrls:a})})]}),Cye=({open:e,onOpenChange:a,automation:t})=>n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Send Preview SMS"}),n.jsx(H$,{children:"Send a preview SMS to the automation."})]}),n.jsx(kye,{automation:t,type:"sms",setOpenSendPreviewPopup:a,open:e})]})}),Mye=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1,setupRequired:r=!1})=>{const[o,s]=a.useState(!1),{channelSenders:l}=fre(),{channelAccounts:u}=pre(),c=d5(),d=m5(),[m,h]=a.useState(!1),{data:p}=Sre(),[g,v]=a.useState(r),f=ale({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:p}),y=f.find((e=>e.channelSender.id===d?.smsChannelSenderId));if(a.useEffect((()=>{y&&y.smsApplication&&y.smsApplication.status===ele.PENDING&&v(!1)}),[d?.smsChannelSenderId,p,f,y]),!c||void 0===l)return null;const k=d?.smsMessageBody||"",b=!y?.smsApplication||y.smsApplication.status===ele.APPROVED,S=(p||d?.smsChannelSenderId)&&k.length>0,A=Wve({companyName:d?.textMessageCompanyName??void 0,smsBody:k}),w=d?.textMessageMediaUrls??[];let C=null;return d?.smsChannelSenderId||(C="Please first select a sms sender"),d?.smsMessageBody||(C="Please first ensure you have a sms content"),n.jsx(eY,{children:g?n.jsx("div",{className:"w-full pt-8 mx-auto",children:n.jsx(gpe,{})}):n.jsxs(K4.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3,ease:[.16,1,.3,1]},className:"flex flex-col items-center w-full h-full",children:[n.jsx(lye,{open:m,onOpenChange:h}),n.jsx(Cye,{open:o,onOpenChange:s,automation:c}),n.jsx(cye,{actionButtons:n.jsxs(n.Fragment,{children:[!e&&b&&(C?n.jsx(pue,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!1,children:n.jsx("div",{className:"inline-block",children:n.jsx(gye,{onClick:()=>s(!0)})})}):n.jsx(gye,{onClick:()=>s(!0)})),c.status===da.DRAFT&&!t&&n.jsx(k5,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 font-medium text-sm shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>h(!0),children:"Edit content"}),S&&n.jsx(hye,{expandDialogContent:n.jsx(wye,{smsBody:A,imageUrls:w})})]}),children:S?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(Aye,{})})}),n.jsx("div",{className:"w-full h-[1.5px] bg-zinc-200 my-2"}),n.jsx("div",{className:"flex-1 w-full overflow-auto h-full flex items-center justify-center",children:n.jsx(qve,{body:A,imageUrls:w})})]}):n.jsx(pye,{type:"sms",disablePreviewSubtext:i})})]})})},Tye=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1})=>{const[r,o]=a.useState(null),s=m5(),{channelAccounts:l}=pre(),{state:{hideSms:u}}=a.useContext(uq),{channelSenders:c}=fre(),{data:d}=Sre(),m=a.useMemo((()=>ale({channelSenders:c?.results??[],channelAccounts:l?.results??[],smsApplication:d})),[c?.results,l?.results,d]);if(a.useEffect((()=>{r||o(s?.emailChannelSenderId?"email":"sms")}),[s?.emailChannelSenderId,r]),!s||!c||!r)return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx(v5,{text:["Loading..."]})});const h=!s?.smsChannelSenderId||u,p=!s?.emailChannelSenderId,g=0===m.length&&!d;return n.jsxs(aye,{defaultValue:"email",value:r,onValueChange:e=>o("email"===e?"email":"sms"),className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md pb-4",children:[n.jsx("div",{className:"max-w-[640px] mx-auto w-full",children:n.jsxs(nye,{className:"grid w-full "+(h||p?"grid-cols-1":"grid-cols-2"),children:[!p&&n.jsx(tye,{value:"email",className:"group data-[state=active]:bg-white",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx(w5.EmailIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),n.jsx(w5.EmailIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),n.jsx("span",{children:"Email"})]})}),!h&&n.jsx(tye,{value:"sms",className:"group data-[state=active]:bg-white",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(w5.SmsIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),n.jsx(w5.SmsIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),n.jsx("span",{children:"SMS"}),g&&n.jsx(pue,{title:"To enable SMS, please complete your business information and request approval from Twilio"})]})})]})}),n.jsx(iye,{value:"email",children:n.jsx(Sye,{disablePreview:e,disableEditContent:t,disablePreviewSubtext:i})}),n.jsx(iye,{value:"sms",children:n.jsx(Mye,{disablePreview:e,disableEditContent:t,disablePreviewSubtext:i,setupRequired:g})})]})},Eye="reach-styles-module__h2___J-48W",xye="reach-styles-module__h3___QiFj-",Nye="reach-styles-module__minorText___1TEN6",_ye=({children:e,className:a})=>n.jsx("h2",{className:vm(Eye,a),children:e}),Pye=({children:e,className:a})=>n.jsx("h3",{className:vm(xye,a),children:e}),Lye=({children:e,className:a})=>n.jsx("p",{className:vm(Nye,a),children:e}),jye=({title:e,children:a,headerActions:t})=>n.jsxs("div",{className:"max-w-[1000px] mx-auto w-full flex-1 flex flex-col gap-4 pt-4",children:[n.jsxs("div",{className:"px-4 flex",children:[n.jsx(_ye,{className:"text-primary",children:e}),t&&n.jsx("div",{className:"ml-auto",children:t})]}),a]}),Bye=()=>n.jsx(jye,{title:"Preview & Schedule",children:n.jsx(Tye,{disablePreview:!0,disableEditContent:!0,disablePreviewSubtext:!0})}),Rye=()=>{const e=d5(),t=m5(),{channelSenders:i}=fre(),{channelAccounts:r}=pre(),{data:o}=Sre(),[s,l]=a.useState(null),[u,c]=a.useState(null),[d,m]=a.useState(null),[h,p]=a.useState(null);return a.useEffect((()=>{i&&m(i),r&&p(r)}),[i,r]),a.useEffect((()=>{if(t&&d&&h){const e=t.emailChannelSenderId,a=t.smsChannelSenderId,n=d.results.find((a=>a.id===e)),i=d.results.find((e=>e.id===a));if(n&&t.emailSubject&&t.emailHtmlBody){const e=n.channelSenderMetadata?.userPart,a=h.results.find((e=>e.id===n.channelAccountId));if(a)switch(a.channelAccountMetadata.type){case gre.REACH_MANAGED:l({fromEmail:`${e}@${a.channelAccountMetadata.baseDomain}.embedreach.com`,fromName:n.channelSenderMetadata?.emailFromName,subject:t.emailSubject,previewText:t.emailPreviewText,body:t.emailHtmlBody});break;case gre.TWILLIO:break;default:throw ire(a.channelAccountMetadata.type,gre)}}(o||i)&&t.smsMessageBody&&c({fromPhone:i?Yve(i.channelSenderMetadata):"",body:t.smsMessageBody,companyName:t.textMessageCompanyName})}}),[t,d,h,o]),e?n.jsx("div",s||u?{className:"w-full",children:n.jsx("div",{className:"flex flex-col gap-4 w-full",children:n.jsx(Bye,{})})}:{className:"flex justify-center items-center h-full",children:n.jsx("div",{children:"No preview data Please complete previous steps"})}):n.jsx(v5,{text:["Loading..."]})};function zye(e){return(zye="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Dye(e){if(null===e||!0===e||!1===e)return NaN;var a=Number(e);return isNaN(a)?a:a<0?Math.ceil(a):Math.floor(a)}function Kye(e,a){if(a.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+a.length+" present")}function Oye(e){Kye(1,arguments);var a=Object.prototype.toString.call(e);return e instanceof Date||"object"===zye(e)&&"[object Date]"===a?new Date(e.getTime()):"number"==typeof e||"[object Number]"===a?new Date(e):new Date(NaN)}function Hye(e,a){Kye(2,arguments);var n=Oye(e),t=Dye(a);return isNaN(t)?new Date(NaN):t?(n.setDate(n.getDate()+t),n):n}function Iye(e,a){Kye(2,arguments);var n=Oye(e),t=Dye(a);if(isNaN(t))return new Date(NaN);if(!t)return n;var i=n.getDate(),r=new Date(n.getTime());return r.setMonth(n.getMonth()+t+1,0),i>=r.getDate()?r:(n.setFullYear(r.getFullYear(),r.getMonth(),i),n)}var Gye={};function Fye(){return Gye}function Vye(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Oye(e),h=m.getDay(),p=(h<d?7:0)+h-d;return m.setDate(m.getDate()-p),m.setHours(0,0,0,0),m}function Jye(e){return Kye(1,arguments),Vye(e,{weekStartsOn:1})}function Uye(e){Kye(1,arguments);var a=function(e){Kye(1,arguments);var a=Oye(e),n=a.getFullYear(),t=new Date(0);t.setFullYear(n+1,0,4),t.setHours(0,0,0,0);var i=Jye(t),r=new Date(0);r.setFullYear(n,0,4),r.setHours(0,0,0,0);var o=Jye(r);return a.getTime()>=i.getTime()?n+1:a.getTime()>=o.getTime()?n:n-1}(e),n=new Date(0);return n.setFullYear(a,0,4),n.setHours(0,0,0,0),Jye(n)}function Wye(e){var a=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return a.setUTCFullYear(e.getFullYear()),e.getTime()-a.getTime()}function qye(e){Kye(1,arguments);var a=Oye(e);return a.setHours(0,0,0,0),a}function Zye(e,a){Kye(2,arguments);var n=qye(e),t=qye(a),i=n.getTime()-Wye(n),r=t.getTime()-Wye(t);return Math.round((i-r)/864e5)}function $ye(e,a){return Kye(2,arguments),Hye(e,7*Dye(a))}function Yye(e,a){return Kye(2,arguments),Iye(e,12*Dye(a))}function Qye(e,a){Kye(2,arguments);var n=qye(e),t=qye(a);return n.getTime()===t.getTime()}function Xye(e){return Kye(1,arguments),e instanceof Date||"object"===zye(e)&&"[object Date]"===Object.prototype.toString.call(e)}function eke(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return 12*(n.getFullYear()-t.getFullYear())+(n.getMonth()-t.getMonth())}function ake(e){Kye(1,arguments);var a=Oye(e),n=a.getMonth();return a.setFullYear(a.getFullYear(),n+1,0),a.setHours(23,59,59,999),a}function nke(e){Kye(1,arguments);var a=Oye(e);return a.setDate(1),a.setHours(0,0,0,0),a}function tke(e){Kye(1,arguments);var a=Oye(e),n=new Date(0);return n.setFullYear(a.getFullYear(),0,1),n.setHours(0,0,0,0),n}function ike(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Oye(e),h=m.getDay(),p=6+(h<d?-7:0)-(h-d);return m.setDate(m.getDate()+p),m.setHours(23,59,59,999),m}function rke(e){return Kye(1,arguments),ike(e,{weekStartsOn:1})}function oke(e,a){return Kye(2,arguments),function(e,a){Kye(2,arguments);var n=Oye(e).getTime(),t=Dye(a);return new Date(n+t)}(e,-Dye(a))}function ske(e){Kye(1,arguments);var a=Oye(e),n=a.getUTCDay(),t=(n<1?7:0)+n-1;return a.setUTCDate(a.getUTCDate()-t),a.setUTCHours(0,0,0,0),a}function lke(e){Kye(1,arguments);var a=Oye(e),n=a.getUTCFullYear(),t=new Date(0);t.setUTCFullYear(n+1,0,4),t.setUTCHours(0,0,0,0);var i=ske(t),r=new Date(0);r.setUTCFullYear(n,0,4),r.setUTCHours(0,0,0,0);var o=ske(r);return a.getTime()>=i.getTime()?n+1:a.getTime()>=o.getTime()?n:n-1}function uke(e){Kye(1,arguments);var a=Oye(e),n=ske(a).getTime()-function(e){Kye(1,arguments);var a=lke(e),n=new Date(0);return n.setUTCFullYear(a,0,4),n.setUTCHours(0,0,0,0),ske(n)}(a).getTime();return Math.round(n/6048e5)+1}function cke(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Oye(e),h=m.getUTCDay(),p=(h<d?7:0)+h-d;return m.setUTCDate(m.getUTCDate()-p),m.setUTCHours(0,0,0,0),m}function dke(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Oye(e),d=c.getUTCFullYear(),m=Fye(),h=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:m.firstWeekContainsDate)&&void 0!==t?t:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setUTCFullYear(d+1,0,h),p.setUTCHours(0,0,0,0);var g=cke(p,a),v=new Date(0);v.setUTCFullYear(d,0,h),v.setUTCHours(0,0,0,0);var f=cke(v,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=f.getTime()?d:d-1}function mke(e,a){Kye(1,arguments);var n=Oye(e),t=cke(n,a).getTime()-function(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:c.firstWeekContainsDate)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1),m=dke(e,a),h=new Date(0);return h.setUTCFullYear(m,0,d),h.setUTCHours(0,0,0,0),cke(h,a)}(n,a).getTime();return Math.round(t/6048e5)+1}function hke(e,a){for(var n=e<0?"-":"",t=Math.abs(e).toString();t.length<a;)t="0"+t;return n+t}var pke=function(e,a){var n=e.getUTCFullYear(),t=n>0?n:1-n;return hke("yy"===a?t%100:t,a.length)},gke=function(e,a){var n=e.getUTCMonth();return"M"===a?String(n+1):hke(n+1,2)},vke=function(e,a){return hke(e.getUTCDate(),a.length)},fke=function(e,a){return hke(e.getUTCHours()%12||12,a.length)},yke=function(e,a){return hke(e.getUTCHours(),a.length)},kke=function(e,a){return hke(e.getUTCMinutes(),a.length)},bke=function(e,a){return hke(e.getUTCSeconds(),a.length)},Ske=function(e,a){var n=a.length,t=e.getUTCMilliseconds();return hke(Math.floor(t*Math.pow(10,n-3)),a.length)},Ake="midnight",wke="noon",Cke="morning",Mke="afternoon",Tke="evening",Eke="night",xke={G:function(e,a,n){var t=e.getUTCFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return n.era(t,{width:"abbreviated"});case"GGGGG":return n.era(t,{width:"narrow"});default:return n.era(t,{width:"wide"})}},y:function(e,a,n){if("yo"===a){var t=e.getUTCFullYear();return n.ordinalNumber(t>0?t:1-t,{unit:"year"})}return pke(e,a)},Y:function(e,a,n,t){var i=dke(e,t),r=i>0?i:1-i;return"YY"===a?hke(r%100,2):"Yo"===a?n.ordinalNumber(r,{unit:"year"}):hke(r,a.length)},R:function(e,a){return hke(lke(e),a.length)},u:function(e,a){return hke(e.getUTCFullYear(),a.length)},Q:function(e,a,n){var t=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"Q":return String(t);case"QQ":return hke(t,2);case"Qo":return n.ordinalNumber(t,{unit:"quarter"});case"QQQ":return n.quarter(t,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(t,{width:"narrow",context:"formatting"});default:return n.quarter(t,{width:"wide",context:"formatting"})}},q:function(e,a,n){var t=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"q":return String(t);case"qq":return hke(t,2);case"qo":return n.ordinalNumber(t,{unit:"quarter"});case"qqq":return n.quarter(t,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(t,{width:"narrow",context:"standalone"});default:return n.quarter(t,{width:"wide",context:"standalone"})}},M:function(e,a,n){var t=e.getUTCMonth();switch(a){case"M":case"MM":return gke(e,a);case"Mo":return n.ordinalNumber(t+1,{unit:"month"});case"MMM":return n.month(t,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(t,{width:"narrow",context:"formatting"});default:return n.month(t,{width:"wide",context:"formatting"})}},L:function(e,a,n){var t=e.getUTCMonth();switch(a){case"L":return String(t+1);case"LL":return hke(t+1,2);case"Lo":return n.ordinalNumber(t+1,{unit:"month"});case"LLL":return n.month(t,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(t,{width:"narrow",context:"standalone"});default:return n.month(t,{width:"wide",context:"standalone"})}},w:function(e,a,n,t){var i=mke(e,t);return"wo"===a?n.ordinalNumber(i,{unit:"week"}):hke(i,a.length)},I:function(e,a,n){var t=uke(e);return"Io"===a?n.ordinalNumber(t,{unit:"week"}):hke(t,a.length)},d:function(e,a,n){return"do"===a?n.ordinalNumber(e.getUTCDate(),{unit:"date"}):vke(e,a)},D:function(e,a,n){var t=function(e){Kye(1,arguments);var a=Oye(e),n=a.getTime();a.setUTCMonth(0,1),a.setUTCHours(0,0,0,0);var t=a.getTime();return Math.floor((n-t)/864e5)+1}(e);return"Do"===a?n.ordinalNumber(t,{unit:"dayOfYear"}):hke(t,a.length)},E:function(e,a,n){var t=e.getUTCDay();switch(a){case"E":case"EE":case"EEE":return n.day(t,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(t,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(t,{width:"short",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})}},e:function(e,a,n,t){var i=e.getUTCDay(),r=(i-t.weekStartsOn+8)%7||7;switch(a){case"e":return String(r);case"ee":return hke(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,a,n,t){var i=e.getUTCDay(),r=(i-t.weekStartsOn+8)%7||7;switch(a){case"c":return String(r);case"cc":return hke(r,a.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,a,n){var t=e.getUTCDay(),i=0===t?7:t;switch(a){case"i":return String(i);case"ii":return hke(i,a.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(t,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(t,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(t,{width:"short",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})}},a:function(e,a,n){var t=e.getUTCHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},b:function(e,a,n){var t,i=e.getUTCHours();switch(t=12===i?wke:0===i?Ake:i/12>=1?"pm":"am",a){case"b":case"bb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},B:function(e,a,n){var t,i=e.getUTCHours();switch(t=i>=17?Tke:i>=12?Mke:i>=4?Cke:Eke,a){case"B":case"BB":case"BBB":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},h:function(e,a,n){if("ho"===a){var t=e.getUTCHours()%12;return 0===t&&(t=12),n.ordinalNumber(t,{unit:"hour"})}return fke(e,a)},H:function(e,a,n){return"Ho"===a?n.ordinalNumber(e.getUTCHours(),{unit:"hour"}):yke(e,a)},K:function(e,a,n){var t=e.getUTCHours()%12;return"Ko"===a?n.ordinalNumber(t,{unit:"hour"}):hke(t,a.length)},k:function(e,a,n){var t=e.getUTCHours();return 0===t&&(t=24),"ko"===a?n.ordinalNumber(t,{unit:"hour"}):hke(t,a.length)},m:function(e,a,n){return"mo"===a?n.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):kke(e,a)},s:function(e,a,n){return"so"===a?n.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):bke(e,a)},S:function(e,a){return Ske(e,a)},X:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();if(0===i)return"Z";switch(a){case"X":return _ke(i);case"XXXX":case"XX":return Pke(i);default:return Pke(i,":")}},x:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"x":return _ke(i);case"xxxx":case"xx":return Pke(i);default:return Pke(i,":")}},O:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Nke(i,":");default:return"GMT"+Pke(i,":")}},z:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Nke(i,":");default:return"GMT"+Pke(i,":")}},t:function(e,a,n,t){return hke(Math.floor((t._originalDate||e).getTime()/1e3),a.length)},T:function(e,a,n,t){return hke((t._originalDate||e).getTime(),a.length)}};function Nke(e,a){var n=e>0?"-":"+",t=Math.abs(e),i=Math.floor(t/60),r=t%60;if(0===r)return n+String(i);var o=a;return n+String(i)+o+hke(r,2)}function _ke(e,a){return e%60==0?(e>0?"-":"+")+hke(Math.abs(e)/60,2):Pke(e,a)}function Pke(e,a){var n=a||"",t=e>0?"-":"+",i=Math.abs(e);return t+hke(Math.floor(i/60),2)+n+hke(i%60,2)}var Lke=function(e,a){switch(e){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});default:return a.date({width:"full"})}},jke=function(e,a){switch(e){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});default:return a.time({width:"full"})}},Bke={p:jke,P:function(e,a){var n,t=e.match(/(P+)(p+)?/)||[],i=t[1],r=t[2];if(!r)return Lke(e,a);switch(i){case"P":n=a.dateTime({width:"short"});break;case"PP":n=a.dateTime({width:"medium"});break;case"PPP":n=a.dateTime({width:"long"});break;default:n=a.dateTime({width:"full"})}return n.replace("{{date}}",Lke(i,a)).replace("{{time}}",jke(r,a))}},Rke=["D","DD"],zke=["YY","YYYY"];function Dke(e,a,n){if("YYYY"===e)throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(a,"`) for formatting years to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("YY"===e)throw new RangeError("Use `yy` instead of `YY` (in `".concat(a,"`) for formatting years to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("D"===e)throw new RangeError("Use `d` instead of `D` (in `".concat(a,"`) for formatting days of the month to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("DD"===e)throw new RangeError("Use `dd` instead of `DD` (in `".concat(a,"`) for formatting days of the month to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var Kke={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function Oke(e){return function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=a.width?String(a.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var Hke={date:Oke({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Oke({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Oke({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Ike={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Gke(e){return function(a,n){var t;if("formatting"===(null!=n&&n.context?String(n.context):"standalone")&&e.formattingValues){var i=e.defaultFormattingWidth||e.defaultWidth,r=null!=n&&n.width?String(n.width):i;t=e.formattingValues[r]||e.formattingValues[i]}else{var o=e.defaultWidth,s=null!=n&&n.width?String(n.width):e.defaultWidth;t=e.values[s]||e.values[o]}return t[e.argumentCallback?e.argumentCallback(a):a]}}var Fke={ordinalNumber:function(e,a){var n=Number(e),t=n%100;if(t>20||t<10)switch(t%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:Gke({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Gke({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:Gke({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:Gke({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:Gke({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function Vke(e){return function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.width,i=a.match(t&&e.matchPatterns[t]||e.matchPatterns[e.defaultMatchWidth]);if(!i)return null;var r,o=i[0],s=t&&e.parsePatterns[t]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(s)?function(e,a){for(var n=0;n<e.length;n++)if(a(e[n]))return n;return}(s,(function(e){return e.test(o)})):function(e,a){for(var n in e)if(e.hasOwnProperty(n)&&a(e[n]))return n;return}(s,(function(e){return e.test(o)}));return r=e.valueCallback?e.valueCallback(l):l,{value:r=n.valueCallback?n.valueCallback(r):r,rest:a.slice(o.length)}}}var Jke={ordinalNumber:function(e){return function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=a.match(e.matchPattern);if(!t)return null;var i=t[0],r=a.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];return{value:o=n.valueCallback?n.valueCallback(o):o,rest:a.slice(i.length)}}}({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Vke({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:Vke({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:Vke({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:Vke({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Vke({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},Uke={code:"en-US",formatDistance:function(e,a,n){var t,i=Kke[e];return t="string"==typeof i?i:1===a?i.one:i.other.replace("{{count}}",a.toString()),null!=n&&n.addSuffix?n.comparison&&n.comparison>0?"in "+t:t+" ago":t},formatLong:Hke,formatRelative:function(e,a,n,t){return Ike[e]},localize:Fke,match:Jke,options:{weekStartsOn:0,firstWeekContainsDate:1}},Wke=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,qke=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Zke=/^'([^]*?)'?$/,$ke=/''/g,Yke=/[a-zA-Z]/;function Qke(e,a,n){var t,i,r,o,s,l,u,c,d,m,h,p,g,v,f,y,k,b;Kye(2,arguments);var S=String(a),A=Fye(),w=null!==(t=null!==(i=null==n?void 0:n.locale)&&void 0!==i?i:A.locale)&&void 0!==t?t:Uke,C=Dye(null!==(r=null!==(o=null!==(s=null!==(l=null==n?void 0:n.firstWeekContainsDate)&&void 0!==l?l:null==n||null===(u=n.locale)||void 0===u||null===(c=u.options)||void 0===c?void 0:c.firstWeekContainsDate)&&void 0!==s?s:A.firstWeekContainsDate)&&void 0!==o?o:null===(d=A.locale)||void 0===d||null===(m=d.options)||void 0===m?void 0:m.firstWeekContainsDate)&&void 0!==r?r:1);if(!(C>=1&&C<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var M=Dye(null!==(h=null!==(p=null!==(g=null!==(v=null==n?void 0:n.weekStartsOn)&&void 0!==v?v:null==n||null===(f=n.locale)||void 0===f||null===(y=f.options)||void 0===y?void 0:y.weekStartsOn)&&void 0!==g?g:A.weekStartsOn)&&void 0!==p?p:null===(k=A.locale)||void 0===k||null===(b=k.options)||void 0===b?void 0:b.weekStartsOn)&&void 0!==h?h:0);if(!(M>=0&&M<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!w.localize)throw new RangeError("locale must contain localize property");if(!w.formatLong)throw new RangeError("locale must contain formatLong property");var T=Oye(e);if(!function(e){if(Kye(1,arguments),!Xye(e)&&"number"!=typeof e)return!1;var a=Oye(e);return!isNaN(Number(a))}(T))throw new RangeError("Invalid time value");var E=oke(T,Wye(T)),x={firstWeekContainsDate:C,weekStartsOn:M,locale:w,_originalDate:T};return S.match(qke).map((function(e){var a=e[0];return"p"===a||"P"===a?(0,Bke[a])(e,w.formatLong):e})).join("").match(Wke).map((function(t){if("''"===t)return"'";var i=t[0];if("'"===i)return function(e){var a=e.match(Zke);if(!a)return e;return a[1].replace($ke,"'")}(t);var r=xke[i];if(r)return null!=n&&n.useAdditionalWeekYearTokens||-1===zke.indexOf(t)||Dke(t,a,String(e)),null!=n&&n.useAdditionalDayOfYearTokens||!function(e){return-1!==Rke.indexOf(e)}(t)||Dke(t,a,String(e)),r(E,t,w.localize,x);if(i.match(Yke))throw new RangeError("Format string contains an unescaped latin alphabet character `"+i+"`");return t})).join("")}function Xke(e){return Kye(1,arguments),Math.floor(function(e){return Kye(1,arguments),Oye(e).getTime()}(e)/1e3)}function ebe(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:c.firstWeekContainsDate)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1),m=function(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Oye(e),d=c.getFullYear(),m=Fye(),h=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:m.firstWeekContainsDate)&&void 0!==t?t:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setFullYear(d+1,0,h),p.setHours(0,0,0,0);var g=Vye(p,a),v=new Date(0);v.setFullYear(d,0,h),v.setHours(0,0,0,0);var f=Vye(v,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=f.getTime()?d:d-1}(e,a),h=new Date(0);return h.setFullYear(m,0,d),h.setHours(0,0,0,0),Vye(h,a)}function abe(e,a){return Kye(1,arguments),function(e,a,n){Kye(2,arguments);var t=Vye(e,n),i=Vye(a,n),r=t.getTime()-Wye(t),o=i.getTime()-Wye(i);return Math.round((r-o)/6048e5)}(function(e){Kye(1,arguments);var a=Oye(e),n=a.getMonth();return a.setFullYear(a.getFullYear(),n+1,0),a.setHours(0,0,0,0),a}(e),nke(e),a)+1}function nbe(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return n.getTime()>t.getTime()}function tbe(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return n.getTime()<t.getTime()}function ibe(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()}function rbe(e,a){return Kye(2,arguments),Hye(e,-Dye(a))}function obe(e,a){Kye(2,arguments);var n=Oye(e),t=Dye(a),i=n.getFullYear(),r=n.getDate(),o=new Date(0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);var s=function(e){Kye(1,arguments);var a=Oye(e),n=a.getFullYear(),t=a.getMonth(),i=new Date(0);return i.setFullYear(n,t+1,0),i.setHours(0,0,0,0),i.getDate()}(o);return n.setMonth(t,Math.min(r,s)),n}function sbe(e,a){Kye(2,arguments);var n=Oye(e),t=Dye(a);return isNaN(n.getTime())?new Date(NaN):(n.setFullYear(t),n)}var lbe=function(){return lbe=Object.assign||function(e){for(var a,n=1,t=arguments.length;n<t;n++)for(var i in a=arguments[n])Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i]);return e},lbe.apply(this,arguments)};function ube(e,a,n){for(var t,i=0,r=a.length;i<r;i++)!t&&i in a||(t||(t=Array.prototype.slice.call(a,0,i)),t[i]=a[i]);return e.concat(t||Array.prototype.slice.call(a))}function cbe(e){return"multiple"===e.mode}function dbe(e){return"range"===e.mode}function mbe(e){return"single"===e.mode}"function"==typeof SuppressedError&&SuppressedError;var hbe={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};var pbe=Object.freeze({__proto__:null,formatCaption:function(e,a){return Qke(e,"LLLL y",a)},formatDay:function(e,a){return Qke(e,"d",a)},formatMonthCaption:function(e,a){return Qke(e,"LLLL",a)},formatWeekNumber:function(e){return"".concat(e)},formatWeekdayName:function(e,a){return Qke(e,"cccccc",a)},formatYearCaption:function(e,a){return Qke(e,"yyyy",a)}}),gbe=Object.freeze({__proto__:null,labelDay:function(e,a,n){return Qke(e,"do MMMM (EEEE)",n)},labelMonthDropdown:function(){return"Month: "},labelNext:function(){return"Go to next month"},labelPrevious:function(){return"Go to previous month"},labelWeekNumber:function(e){return"Week n. ".concat(e)},labelWeekday:function(e,a){return Qke(e,"cccc",a)},labelYearDropdown:function(){return"Year: "}});var vbe=a.createContext(void 0);function fbe(e){var a,t,i=e.initialProps,r={captionLayout:"buttons",classNames:hbe,formatters:pbe,labels:gbe,locale:Uke,modifiersClassNames:{},modifiers:{},numberOfMonths:1,styles:{},today:new Date,mode:"default"},o=function(e){var a=e.fromYear,n=e.toYear,t=e.fromMonth,i=e.toMonth,r=e.fromDate,o=e.toDate;return t?r=nke(t):a&&(r=new Date(a,0,1)),i?o=ake(i):n&&(o=new Date(n,11,31)),{fromDate:r?qye(r):void 0,toDate:o?qye(o):void 0}}(i),s=o.fromDate,l=o.toDate,u=null!==(a=i.captionLayout)&&void 0!==a?a:r.captionLayout;"buttons"===u||s&&l||(u="buttons"),(mbe(i)||cbe(i)||dbe(i))&&(t=i.onSelect);var c=lbe(lbe(lbe({},r),i),{captionLayout:u,classNames:lbe(lbe({},r.classNames),i.classNames),components:lbe({},i.components),formatters:lbe(lbe({},r.formatters),i.formatters),fromDate:s,labels:lbe(lbe({},r.labels),i.labels),mode:i.mode||r.mode,modifiers:lbe(lbe({},r.modifiers),i.modifiers),modifiersClassNames:lbe(lbe({},r.modifiersClassNames),i.modifiersClassNames),onSelect:t,styles:lbe(lbe({},r.styles),i.styles),toDate:l});return n.jsx(vbe.Provider,{value:c,children:e.children})}function ybe(){var e=a.useContext(vbe);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function kbe(e){var a=ybe();return n.jsx("div",{className:a.classNames.caption_label,style:a.styles.caption_label,"aria-live":"polite",role:"presentation",id:e.id,children:(0,a.formatters.formatCaption)(e.displayMonth,{locale:a.locale})})}function bbe(e){return n.jsx("svg",lbe({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:n.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function Sbe(e){var a,t,i=e.onChange,r=e.value,o=e.children,s=e.caption,l=e.className,u=e.style,c=ybe(),d=null!==(t=null===(a=c.components)||void 0===a?void 0:a.IconDropdown)&&void 0!==t?t:bbe;return n.jsxs("div",{className:l,style:u,children:[n.jsx("span",{className:c.classNames.vhidden,children:e["aria-label"]}),n.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:c.classNames.dropdown,style:c.styles.dropdown,value:r,onChange:i,children:o}),n.jsxs("div",{className:c.classNames.caption_label,style:c.styles.caption_label,"aria-hidden":"true",children:[s,n.jsx(d,{className:c.classNames.dropdown_icon,style:c.styles.dropdown_icon})]})]})}function Abe(e){var a,t=ybe(),i=t.fromDate,r=t.toDate,o=t.styles,s=t.locale,l=t.formatters.formatMonthCaption,u=t.classNames,c=t.components,d=t.labels.labelMonthDropdown;if(!i)return n.jsx(n.Fragment,{});if(!r)return n.jsx(n.Fragment,{});var m=[];if(function(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return n.getFullYear()===t.getFullYear()}(i,r))for(var h=nke(i),p=i.getMonth();p<=r.getMonth();p++)m.push(obe(h,p));else for(h=nke(new Date),p=0;p<=11;p++)m.push(obe(h,p));var g=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:Sbe;return n.jsx(g,{name:"months","aria-label":d(),className:u.dropdown_month,style:o.dropdown_month,onChange:function(a){var n=Number(a.target.value),t=obe(nke(e.displayMonth),n);e.onChange(t)},value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:s}),children:m.map((function(e){return n.jsx("option",{value:e.getMonth(),children:l(e,{locale:s})},e.getMonth())}))})}function wbe(e){var a,t=e.displayMonth,i=ybe(),r=i.fromDate,o=i.toDate,s=i.locale,l=i.styles,u=i.classNames,c=i.components,d=i.formatters.formatYearCaption,m=i.labels.labelYearDropdown,h=[];if(!r)return n.jsx(n.Fragment,{});if(!o)return n.jsx(n.Fragment,{});for(var p=r.getFullYear(),g=o.getFullYear(),v=p;v<=g;v++)h.push(sbe(tke(new Date),v));var f=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:Sbe;return n.jsx(f,{name:"years","aria-label":m(),className:u.dropdown_year,style:l.dropdown_year,onChange:function(a){var n=sbe(nke(t),Number(a.target.value));e.onChange(n)},value:t.getFullYear(),caption:d(t,{locale:s}),children:h.map((function(e){return n.jsx("option",{value:e.getFullYear(),children:d(e,{locale:s})},e.getFullYear())}))})}function Cbe(){var e=ybe(),n=function(e){var a=e.month||e.defaultMonth||e.today||new Date,n=e.toDate,t=e.fromDate,i=e.numberOfMonths,r=void 0===i?1:i;return n&&eke(n,a)<0&&(a=Iye(n,-1*(r-1))),t&&eke(a,t)<0&&(a=t),nke(a)}(e),t=function(e,n){var t=a.useState(e);return[void 0===n?t[0]:n,t[1]]}(n,e.month),i=t[1];return[t[0],function(a){var n;if(!e.disableNavigation){var t=nke(a);i(t),null===(n=e.onMonthChange)||void 0===n||n.call(e,t)}}]}var Mbe=a.createContext(void 0);function Tbe(e){var a=ybe(),t=Cbe(),i=t[0],r=t[1],o=function(e,a){for(var n=a.reverseMonths,t=a.numberOfMonths,i=nke(e),r=eke(nke(Iye(i,t)),i),o=[],s=0;s<r;s++){var l=Iye(i,s);o.push(l)}return n&&(o=o.reverse()),o}(i,a),s=function(e,a){if(!a.disableNavigation){var n=a.toDate,t=a.numberOfMonths,i=void 0===t?1:t,r=a.pagedNavigation?i:1,o=nke(e);if(!n)return Iye(o,r);if(!(eke(n,e)<i))return Iye(o,r)}}(i,a),l=function(e,a){if(!a.disableNavigation){var n=a.fromDate,t=a.numberOfMonths,i=a.pagedNavigation?void 0===t?1:t:1,r=nke(e);if(!n)return Iye(r,-i);if(!(eke(r,n)<=0))return Iye(r,-i)}}(i,a),u=function(e){return o.some((function(a){return ibe(e,a)}))};return n.jsx(Mbe.Provider,{value:{currentMonth:i,displayMonths:o,goToMonth:r,goToDate:function(e,n){u(e)||(n&&tbe(e,n)?r(Iye(e,1+-1*a.numberOfMonths)):r(e))},previousMonth:l,nextMonth:s,isDateDisplayed:u},children:e.children})}function Ebe(){var e=a.useContext(Mbe);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function xbe(e){var a,t=ybe(),i=t.classNames,r=t.styles,o=t.components,s=Ebe().goToMonth,l=function(a){s(Iye(a,e.displayIndex?-e.displayIndex:0))},u=null!==(a=null==o?void 0:o.CaptionLabel)&&void 0!==a?a:kbe,c=n.jsx(u,{id:e.id,displayMonth:e.displayMonth});return n.jsxs("div",{className:i.caption_dropdowns,style:r.caption_dropdowns,children:[n.jsx("div",{className:i.vhidden,children:c}),n.jsx(Abe,{onChange:l,displayMonth:e.displayMonth}),n.jsx(wbe,{onChange:l,displayMonth:e.displayMonth})]})}function Nbe(e){return n.jsx("svg",lbe({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function _be(e){return n.jsx("svg",lbe({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var Pbe=a.forwardRef((function(e,a){var t=ybe(),i=t.classNames,r=t.styles,o=[i.button_reset,i.button];e.className&&o.push(e.className);var s=o.join(" "),l=lbe(lbe({},r.button_reset),r.button);return e.style&&Object.assign(l,e.style),n.jsx("button",lbe({},e,{ref:a,type:"button",className:s,style:l}))}));function Lbe(e){var a,t,i=ybe(),r=i.dir,o=i.locale,s=i.classNames,l=i.styles,u=i.labels,c=u.labelPrevious,d=u.labelNext,m=i.components;if(!e.nextMonth&&!e.previousMonth)return n.jsx(n.Fragment,{});var h=c(e.previousMonth,{locale:o}),p=[s.nav_button,s.nav_button_previous].join(" "),g=d(e.nextMonth,{locale:o}),v=[s.nav_button,s.nav_button_next].join(" "),f=null!==(a=null==m?void 0:m.IconRight)&&void 0!==a?a:_be,y=null!==(t=null==m?void 0:m.IconLeft)&&void 0!==t?t:Nbe;return n.jsxs("div",{className:s.nav,style:l.nav,children:[!e.hidePrevious&&n.jsx(Pbe,{name:"previous-month","aria-label":h,className:p,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:n.jsx("rtl"===r?f:y,{className:s.nav_icon,style:l.nav_icon})}),!e.hideNext&&n.jsx(Pbe,{name:"next-month","aria-label":g,className:v,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:n.jsx("rtl"===r?y:f,{className:s.nav_icon,style:l.nav_icon})})]})}function jbe(e){var a=ybe().numberOfMonths,t=Ebe(),i=t.previousMonth,r=t.nextMonth,o=t.goToMonth,s=t.displayMonths,l=s.findIndex((function(a){return ibe(e.displayMonth,a)})),u=0===l,c=l===s.length-1;return n.jsx(Lbe,{displayMonth:e.displayMonth,hideNext:a>1&&(u||!c),hidePrevious:a>1&&(c||!u),nextMonth:r,previousMonth:i,onPreviousClick:function(){i&&o(i)},onNextClick:function(){r&&o(r)}})}function Bbe(e){var a,t,i=ybe(),r=i.classNames,o=i.styles,s=i.captionLayout,l=i.components,u=null!==(a=null==l?void 0:l.CaptionLabel)&&void 0!==a?a:kbe;return t=i.disableNavigation?n.jsx(u,{id:e.id,displayMonth:e.displayMonth}):"dropdown"===s?n.jsx(xbe,{displayMonth:e.displayMonth,id:e.id}):n.jsxs(n.Fragment,"dropdown-buttons"===s?{children:[n.jsx(xbe,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),n.jsx(jbe,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}:{children:[n.jsx(u,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(jbe,{displayMonth:e.displayMonth,id:e.id})]}),n.jsx("div",{className:r.caption,style:o.caption,children:t})}function Rbe(e){var a=ybe(),t=a.footer;return t?n.jsx("tfoot",{className:a.classNames.tfoot,style:a.styles.tfoot,children:n.jsx("tr",{children:n.jsx("td",{colSpan:8,children:t})})}):n.jsx(n.Fragment,{})}function zbe(){var e=ybe(),a=e.classNames,t=e.styles,i=e.showWeekNumber,r=e.locale,o=e.formatters.formatWeekdayName,s=e.labels.labelWeekday,l=function(e,a,n){for(var t=n?Jye(new Date):Vye(new Date,{locale:e,weekStartsOn:a}),i=[],r=0;r<7;r++){var o=Hye(t,r);i.push(o)}return i}(r,e.weekStartsOn,e.ISOWeek);return n.jsxs("tr",{style:t.head_row,className:a.head_row,children:[i&&n.jsx("td",{style:t.head_cell,className:a.head_cell}),l.map((function(e,i){return n.jsx("th",{scope:"col",className:a.head_cell,style:t.head_cell,"aria-label":s(e,{locale:r}),children:o(e,{locale:r})},i)}))]})}function Dbe(){var e,a=ybe(),t=a.components,i=null!==(e=null==t?void 0:t.HeadRow)&&void 0!==e?e:zbe;return n.jsx("thead",{style:a.styles.head,className:a.classNames.head,children:n.jsx(i,{})})}function Kbe(e){var a=ybe();return n.jsx(n.Fragment,{children:(0,a.formatters.formatDay)(e.date,{locale:a.locale})})}var Obe=a.createContext(void 0);function Hbe(e){if(!cbe(e.initialProps)){return n.jsx(Obe.Provider,{value:{selected:void 0,modifiers:{disabled:[]}},children:e.children})}return n.jsx(Ibe,{initialProps:e.initialProps,children:e.children})}function Ibe(e){var a=e.initialProps,t=e.children,i=a.selected,r=a.min,o=a.max,s={disabled:[]};return i&&s.disabled.push((function(e){var a=o&&i.length>o-1,n=i.some((function(a){return Qye(a,e)}));return Boolean(a&&!n)})),n.jsx(Obe.Provider,{value:{selected:i,onDayClick:function(e,n,t){var s,l;if((null===(s=a.onDayClick)||void 0===s||s.call(a,e,n,t),!Boolean(n.selected&&r&&(null==i?void 0:i.length)===r))&&!Boolean(!n.selected&&o&&(null==i?void 0:i.length)===o)){var u=i?ube([],i):[];if(n.selected){var c=u.findIndex((function(a){return Qye(e,a)}));u.splice(c,1)}else u.push(e);null===(l=a.onSelect)||void 0===l||l.call(a,u,e,n,t)}},modifiers:s},children:t})}function Gbe(){var e=a.useContext(Obe);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}var Fbe,Vbe,Jbe=a.createContext(void 0);function Ube(e){if(!dbe(e.initialProps)){return n.jsx(Jbe.Provider,{value:{selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}},children:e.children})}return n.jsx(Wbe,{initialProps:e.initialProps,children:e.children})}function Wbe(e){var a=e.initialProps,t=e.children,i=a.selected,r=i||{},o=r.from,s=r.to,l=a.min,u=a.max,c={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(c.range_start=[o],s?(c.range_end=[s],Qye(o,s)||(c.range_middle=[{after:o,before:s}])):c.range_end=[o]):s&&(c.range_start=[s],c.range_end=[s]),l&&(o&&!s&&c.disabled.push({after:rbe(o,l-1),before:Hye(o,l-1)}),o&&s&&c.disabled.push({after:o,before:Hye(o,l-1)}),!o&&s&&c.disabled.push({after:rbe(s,l-1),before:Hye(s,l-1)})),u){if(o&&!s&&(c.disabled.push({before:Hye(o,1-u)}),c.disabled.push({after:Hye(o,u-1)})),o&&s){var d=u-(Zye(s,o)+1);c.disabled.push({before:rbe(o,d)}),c.disabled.push({after:Hye(s,d)})}!o&&s&&(c.disabled.push({before:Hye(s,1-u)}),c.disabled.push({after:Hye(s,u-1)}))}return n.jsx(Jbe.Provider,{value:{selected:i,onDayClick:function(e,n,t){var r,o;null===(r=a.onDayClick)||void 0===r||r.call(a,e,n,t);var s=function(e,a){var n=a||{},t=n.from,i=n.to;if(t&&i){if(Qye(i,e)&&Qye(t,e))return;if(Qye(i,e))return{from:i,to:void 0};if(Qye(t,e))return;return nbe(t,e)?{from:e,to:i}:{from:t,to:e}}return i?nbe(e,i)?{from:i,to:e}:{from:e,to:i}:t?tbe(e,t)?{from:e,to:t}:{from:t,to:e}:{from:e,to:void 0}}(e,i);null===(o=a.onSelect)||void 0===o||o.call(a,s,e,n,t)},modifiers:c},children:t})}function qbe(){var e=a.useContext(Jbe);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function Zbe(e){return Array.isArray(e)?ube([],e):void 0!==e?[e]:[]}(Vbe=Fbe||(Fbe={})).Outside="outside",Vbe.Disabled="disabled",Vbe.Selected="selected",Vbe.Hidden="hidden",Vbe.Today="today",Vbe.RangeStart="range_start",Vbe.RangeEnd="range_end",Vbe.RangeMiddle="range_middle";var $be=Fbe.Selected,Ybe=Fbe.Disabled,Qbe=Fbe.Hidden,Xbe=Fbe.Today,eSe=Fbe.RangeEnd,aSe=Fbe.RangeMiddle,nSe=Fbe.RangeStart,tSe=Fbe.Outside;var iSe=a.createContext(void 0);function rSe(e){var a=ybe(),t=function(e,a,n){var t,i=((t={})[$be]=Zbe(e.selected),t[Ybe]=Zbe(e.disabled),t[Qbe]=Zbe(e.hidden),t[Xbe]=[e.today],t[eSe]=[],t[aSe]=[],t[nSe]=[],t[tSe]=[],t);return e.fromDate&&i[Ybe].push({before:e.fromDate}),e.toDate&&i[Ybe].push({after:e.toDate}),cbe(e)?i[Ybe]=i[Ybe].concat(a.modifiers[Ybe]):dbe(e)&&(i[Ybe]=i[Ybe].concat(n.modifiers[Ybe]),i[nSe]=n.modifiers[nSe],i[aSe]=n.modifiers[aSe],i[eSe]=n.modifiers[eSe]),i}(a,Gbe(),qbe()),i=function(e){var a={};return Object.entries(e).forEach((function(e){a[e[0]]=Zbe(e[1])})),a}(a.modifiers),r=lbe(lbe({},t),i);return n.jsx(iSe.Provider,{value:r,children:e.children})}function oSe(){var e=a.useContext(iSe);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function sSe(e,a){return a.some((function(a){if("boolean"==typeof a)return a;if(Xye(a))return Qye(e,a);var n,t,i,r,o;if(function(e){return Array.isArray(e)&&e.every(Xye)}(a))return a.includes(e);if(function(e){return Boolean(e&&"object"==typeof e&&"from"in e)}(a))return n=e,o=(t=a).to,(r=t.from)&&o?(Zye(o,r)<0&&(r=(i=[o,r])[0],o=i[1]),Zye(n,r)>=0&&Zye(o,n)>=0):o?Qye(o,n):!!r&&Qye(r,n);if(function(e){return Boolean(e&&"object"==typeof e&&"dayOfWeek"in e)}(a))return a.dayOfWeek.includes(e.getDay());if(function(e){return Boolean(e&&"object"==typeof e&&"before"in e&&"after"in e)}(a)){var s=Zye(a.before,e)>0,l=Zye(a.after,e)<0;return nbe(a.before,a.after)?l&&s:s||l}return function(e){return Boolean(e&&"object"==typeof e&&"after"in e)}(a)?Zye(e,a.after)>0:function(e){return Boolean(e&&"object"==typeof e&&"before"in e)}(a)?Zye(a.before,e)>0:"function"==typeof a&&a(e)}))}function lSe(e,a,n){var t=Object.keys(a).reduce((function(n,t){return sSe(e,a[t])&&n.push(t),n}),[]),i={};return t.forEach((function(e){return i[e]=!0})),n&&!ibe(e,n)&&(i.outside=!0),i}function uSe(e,a){var n=a.moveBy,t=a.direction,i=a.context,r=a.modifiers,o=a.retry,s=void 0===o?{count:0,lastFocused:e}:o,l=i.weekStartsOn,u=i.fromDate,c=i.toDate,d=i.locale,m={day:Hye,week:$ye,month:Iye,year:Yye,startOfWeek:function(e){return i.ISOWeek?Jye(e):Vye(e,{locale:d,weekStartsOn:l})},endOfWeek:function(e){return i.ISOWeek?rke(e):ike(e,{locale:d,weekStartsOn:l})}}[n](e,"after"===t?1:-1);"before"===t&&u?m=function(e){var a,n;if(Kye(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==zye(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=Oye(e);(void 0===n||n<a||isNaN(Number(a)))&&(n=a)})),n||new Date(NaN)}([u,m]):"after"===t&&c&&(m=function(e){var a,n;if(Kye(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==zye(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=Oye(e);(void 0===n||n>a||isNaN(a.getDate()))&&(n=a)})),n||new Date(NaN)}([c,m]));var h=!0;if(r){var p=lSe(m,r);h=!p.disabled&&!p.hidden}return h?m:s.count>365?s.lastFocused:uSe(m,{moveBy:n,direction:t,context:i,modifiers:r,retry:lbe(lbe({},s),{count:s.count+1})})}var cSe=a.createContext(void 0);function dSe(e){var t=Ebe(),i=oSe(),r=a.useState(),o=r[0],s=r[1],l=a.useState(),u=l[0],c=l[1],d=function(e,a){for(var n,t,i=nke(e[0]),r=ake(e[e.length-1]),o=i;o<=r;){var s=lSe(o,a);if(s.disabled||s.hidden)o=Hye(o,1);else{if(s.selected)return o;s.today&&!t&&(t=o),n||(n=o),o=Hye(o,1)}}return t||n}(t.displayMonths,i),m=(null!=o?o:u&&t.isDateDisplayed(u))?u:d,h=function(e){s(e)},p=ybe(),g=function(e,a){if(o){var n=uSe(o,{moveBy:e,direction:a,context:p,modifiers:i});Qye(o,n)||(t.goToDate(n,o),h(n))}};return n.jsx(cSe.Provider,{value:{focusedDay:o,focusTarget:m,blur:function(){c(o),s(void 0)},focus:h,focusDayAfter:function(){return g("day","after")},focusDayBefore:function(){return g("day","before")},focusWeekAfter:function(){return g("week","after")},focusWeekBefore:function(){return g("week","before")},focusMonthBefore:function(){return g("month","before")},focusMonthAfter:function(){return g("month","after")},focusYearBefore:function(){return g("year","before")},focusYearAfter:function(){return g("year","after")},focusStartOfWeek:function(){return g("startOfWeek","before")},focusEndOfWeek:function(){return g("endOfWeek","after")}},children:e.children})}function mSe(){var e=a.useContext(cSe);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}var hSe=a.createContext(void 0);function pSe(e){if(!mbe(e.initialProps)){return n.jsx(hSe.Provider,{value:{selected:void 0},children:e.children})}return n.jsx(gSe,{initialProps:e.initialProps,children:e.children})}function gSe(e){var a=e.initialProps;return n.jsx(hSe.Provider,{value:{selected:a.selected,onDayClick:function(e,n,t){var i,r,o;null===(i=a.onDayClick)||void 0===i||i.call(a,e,n,t),!n.selected||a.required?null===(o=a.onSelect)||void 0===o||o.call(a,e,e,n,t):null===(r=a.onSelect)||void 0===r||r.call(a,void 0,e,n,t)}},children:e.children})}function vSe(){var e=a.useContext(hSe);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function fSe(e,a){var n=[e.classNames.day];return Object.keys(a).forEach((function(a){var t=e.modifiersClassNames[a];if(t)n.push(t);else if(function(e){return Object.values(Fbe).includes(e)}(a)){var i=e.classNames["day_".concat(a)];i&&n.push(i)}})),n}function ySe(e,t,i){var r,o,s,l=ybe(),u=mSe(),c=function(e,a){return lSe(e,oSe(),a)}(e,t),d=function(e,a){var n=ybe(),t=vSe(),i=Gbe(),r=qbe(),o=mSe(),s=o.focusDayAfter,l=o.focusDayBefore,u=o.focusWeekAfter,c=o.focusWeekBefore,d=o.blur,m=o.focus,h=o.focusMonthBefore,p=o.focusMonthAfter,g=o.focusYearBefore,v=o.focusYearAfter,f=o.focusStartOfWeek,y=o.focusEndOfWeek;return{onClick:function(o){var s,l,u,c;mbe(n)?null===(s=t.onDayClick)||void 0===s||s.call(t,e,a,o):cbe(n)?null===(l=i.onDayClick)||void 0===l||l.call(i,e,a,o):dbe(n)?null===(u=r.onDayClick)||void 0===u||u.call(r,e,a,o):null===(c=n.onDayClick)||void 0===c||c.call(n,e,a,o)},onFocus:function(t){var i;m(e),null===(i=n.onDayFocus)||void 0===i||i.call(n,e,a,t)},onBlur:function(t){var i;d(),null===(i=n.onDayBlur)||void 0===i||i.call(n,e,a,t)},onKeyDown:function(t){var i;switch(t.key){case"ArrowLeft":t.preventDefault(),t.stopPropagation(),"rtl"===n.dir?s():l();break;case"ArrowRight":t.preventDefault(),t.stopPropagation(),"rtl"===n.dir?l():s();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),u();break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),c();break;case"PageUp":t.preventDefault(),t.stopPropagation(),t.shiftKey?g():h();break;case"PageDown":t.preventDefault(),t.stopPropagation(),t.shiftKey?v():p();break;case"Home":t.preventDefault(),t.stopPropagation(),f();break;case"End":t.preventDefault(),t.stopPropagation(),y()}null===(i=n.onDayKeyDown)||void 0===i||i.call(n,e,a,t)},onKeyUp:function(t){var i;null===(i=n.onDayKeyUp)||void 0===i||i.call(n,e,a,t)},onMouseEnter:function(t){var i;null===(i=n.onDayMouseEnter)||void 0===i||i.call(n,e,a,t)},onMouseLeave:function(t){var i;null===(i=n.onDayMouseLeave)||void 0===i||i.call(n,e,a,t)},onPointerEnter:function(t){var i;null===(i=n.onDayPointerEnter)||void 0===i||i.call(n,e,a,t)},onPointerLeave:function(t){var i;null===(i=n.onDayPointerLeave)||void 0===i||i.call(n,e,a,t)},onTouchCancel:function(t){var i;null===(i=n.onDayTouchCancel)||void 0===i||i.call(n,e,a,t)},onTouchEnd:function(t){var i;null===(i=n.onDayTouchEnd)||void 0===i||i.call(n,e,a,t)},onTouchMove:function(t){var i;null===(i=n.onDayTouchMove)||void 0===i||i.call(n,e,a,t)},onTouchStart:function(t){var i;null===(i=n.onDayTouchStart)||void 0===i||i.call(n,e,a,t)}}}(e,c),m=function(){var e=ybe(),a=vSe(),n=Gbe(),t=qbe();return mbe(e)?a.selected:cbe(e)?n.selected:dbe(e)?t.selected:void 0}(),h=Boolean(l.onDayClick||"default"!==l.mode);a.useEffect((function(){var a;c.outside||u.focusedDay&&h&&Qye(u.focusedDay,e)&&(null===(a=i.current)||void 0===a||a.focus())}),[u.focusedDay,e,i,h,c.outside]);var p=fSe(l,c).join(" "),g=function(e,a){var n=lbe({},e.styles.day);return Object.keys(a).forEach((function(a){var t;n=lbe(lbe({},n),null===(t=e.modifiersStyles)||void 0===t?void 0:t[a])})),n}(l,c),v=Boolean(c.outside&&!l.showOutsideDays||c.hidden),f=null!==(s=null===(o=l.components)||void 0===o?void 0:o.DayContent)&&void 0!==s?s:Kbe,y={style:g,className:p,children:n.jsx(f,{date:e,displayMonth:t,activeModifiers:c}),role:"gridcell"},k=u.focusTarget&&Qye(u.focusTarget,e)&&!c.outside,b=u.focusedDay&&Qye(u.focusedDay,e),S=lbe(lbe(lbe({},y),((r={disabled:c.disabled,role:"gridcell"})["aria-selected"]=c.selected,r.tabIndex=b||k?0:-1,r)),d);return{isButton:h,isHidden:v,activeModifiers:c,selectedDays:m,buttonProps:S,divProps:y}}function kSe(e){var t=a.useRef(null),i=ySe(e.date,e.displayMonth,t);return i.isHidden?n.jsx("div",{role:"gridcell"}):i.isButton?n.jsx(Pbe,lbe({name:"day",ref:t},i.buttonProps)):n.jsx("div",lbe({},i.divProps))}function bSe(e){var a=e.number,t=e.dates,i=ybe(),r=i.onWeekNumberClick,o=i.styles,s=i.classNames,l=i.locale,u=i.labels.labelWeekNumber,c=(0,i.formatters.formatWeekNumber)(Number(a),{locale:l});if(!r)return n.jsx("span",{className:s.weeknumber,style:o.weeknumber,children:c});var d=u(Number(a),{locale:l});return n.jsx(Pbe,{name:"week-number","aria-label":d,className:s.weeknumber,style:o.weeknumber,onClick:function(e){r(a,t,e)},children:c})}function SSe(e){var a,t,i,r=ybe(),o=r.styles,s=r.classNames,l=r.components,u=null!==(a=null==l?void 0:l.Day)&&void 0!==a?a:kSe,c=null!==(t=null==l?void 0:l.WeekNumber)&&void 0!==t?t:bSe;return r.showWeekNumber&&(i=n.jsx("td",{className:s.cell,style:o.cell,children:n.jsx(c,{number:e.weekNumber,dates:e.dates})})),n.jsxs("tr",{className:s.row,style:o.row,children:[i,e.dates.map((function(a){return n.jsx("td",{className:s.cell,style:o.cell,role:"presentation",children:n.jsx(u,{displayMonth:e.displayMonth,date:a})},Xke(a))}))]})}function ASe(e,a,n){for(var t=(null==n?void 0:n.ISOWeek)?rke(a):ike(a,n),i=(null==n?void 0:n.ISOWeek)?Jye(e):Vye(e,n),r=Zye(t,i),o=[],s=0;s<=r;s++)o.push(Hye(i,s));var l=o.reduce((function(e,a){var t=(null==n?void 0:n.ISOWeek)?function(e){Kye(1,arguments);var a=Oye(e),n=Jye(a).getTime()-Uye(a).getTime();return Math.round(n/6048e5)+1}(a):function(e,a){Kye(1,arguments);var n=Oye(e),t=Vye(n,a).getTime()-ebe(n,a).getTime();return Math.round(t/6048e5)+1}(a,n),i=e.find((function(e){return e.weekNumber===t}));return i?(i.dates.push(a),e):(e.push({weekNumber:t,dates:[a]}),e)}),[]);return l}function wSe(e){var a,t,i,r=ybe(),o=r.locale,s=r.classNames,l=r.styles,u=r.hideHead,c=r.components,d=r.weekStartsOn,m=r.firstWeekContainsDate,h=r.ISOWeek,p=function(e,a){var n=ASe(nke(e),ake(e),a);if(null==a?void 0:a.useFixedWeeks){var t=abe(e,a);if(t<6){var i=n[n.length-1],r=i.dates[i.dates.length-1],o=$ye(r,6-t),s=ASe($ye(r,1),o,a);n.push.apply(n,s)}}return n}(e.displayMonth,{useFixedWeeks:Boolean(r.fixedWeeks),ISOWeek:h,locale:o,weekStartsOn:d,firstWeekContainsDate:m}),g=null!==(a=null==c?void 0:c.Head)&&void 0!==a?a:Dbe,v=null!==(t=null==c?void 0:c.Row)&&void 0!==t?t:SSe,f=null!==(i=null==c?void 0:c.Footer)&&void 0!==i?i:Rbe;return n.jsxs("table",{id:e.id,className:s.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!u&&n.jsx(g,{}),n.jsx("tbody",{className:s.tbody,style:l.tbody,children:p.map((function(a){return n.jsx(v,{displayMonth:e.displayMonth,dates:a.dates,weekNumber:a.weekNumber},a.weekNumber)}))}),n.jsx(f,{displayMonth:e.displayMonth})]})}var CSe="undefined"!=typeof window&&window.document&&window.document.createElement?a.useLayoutEffect:a.useEffect,MSe=!1,TSe=0;function ESe(){return"react-day-picker-".concat(++TSe)}function xSe(e){var t,i,r=ybe(),o=r.dir,s=r.classNames,l=r.styles,u=r.components,c=Ebe().displayMonths,d=function(e){var n,t=null!=e?e:MSe?ESe():null,i=a.useState(t),r=i[0],o=i[1];return CSe((function(){null===r&&o(ESe())}),[]),a.useEffect((function(){!1===MSe&&(MSe=!0)}),[]),null!==(n=null!=e?e:r)&&void 0!==n?n:void 0}(r.id?"".concat(r.id,"-").concat(e.displayIndex):void 0),m=r.id?"".concat(r.id,"-grid-").concat(e.displayIndex):void 0,h=[s.month],p=l.month,g=0===e.displayIndex,v=e.displayIndex===c.length-1,f=!g&&!v;"rtl"===o&&(v=(t=[g,v])[0],g=t[1]),g&&(h.push(s.caption_start),p=lbe(lbe({},p),l.caption_start)),v&&(h.push(s.caption_end),p=lbe(lbe({},p),l.caption_end)),f&&(h.push(s.caption_between),p=lbe(lbe({},p),l.caption_between));var y=null!==(i=null==u?void 0:u.Caption)&&void 0!==i?i:Bbe;return n.jsxs("div",{className:h.join(" "),style:p,children:[n.jsx(y,{id:d,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(wSe,{id:m,"aria-labelledby":d,displayMonth:e.displayMonth})]},e.displayIndex)}function NSe(e){var a=ybe();return n.jsx("div",{className:a.classNames.months,style:a.styles.months,children:e.children})}function _Se(e){var t,i,r=e.initialProps,o=ybe(),s=mSe(),l=Ebe(),u=a.useState(!1),c=u[0],d=u[1];a.useEffect((function(){o.initialFocus&&s.focusTarget&&(c||(s.focus(s.focusTarget),d(!0)))}),[o.initialFocus,c,s.focus,s.focusTarget,s]);var m=[o.classNames.root,o.className];o.numberOfMonths>1&&m.push(o.classNames.multiple_months),o.showWeekNumber&&m.push(o.classNames.with_weeknumber);var h=lbe(lbe({},o.styles.root),o.style),p=Object.keys(r).filter((function(e){return e.startsWith("data-")})).reduce((function(e,a){var n;return lbe(lbe({},e),((n={})[a]=r[a],n))}),{}),g=null!==(i=null===(t=r.components)||void 0===t?void 0:t.Months)&&void 0!==i?i:NSe;return n.jsx("div",lbe({className:m.join(" "),style:h,dir:o.dir,id:o.id,nonce:r.nonce,title:r.title,lang:r.lang},p,{children:n.jsx(g,{children:l.displayMonths.map((function(e,a){return n.jsx(xSe,{displayIndex:a,displayMonth:e},a)}))})}))}function PSe(e){var a=e.children,t=function(e,a){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&a.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(e);i<t.length;i++)a.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(n[t[i]]=e[t[i]])}return n}(e,["children"]);return n.jsx(fbe,{initialProps:t,children:n.jsx(Tbe,{children:n.jsx(pSe,{initialProps:t,children:n.jsx(Hbe,{initialProps:t,children:n.jsx(Ube,{initialProps:t,children:n.jsx(rSe,{children:n.jsx(dSe,{children:a})})})})})})})}function LSe(e){return n.jsx(PSe,lbe({},e,{children:n.jsx(_Se,{initialProps:e})}))}function jSe({className:e,classNames:a,showOutsideDays:t=!0,...i}){const r={months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:vm(y5({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-[#6b7280] rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-[#f1f5f9] [&:has([aria-selected].day-outside)]:bg-[#f1f5f9]/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",day:vm(y5({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"!bg-black !text-gray-200 hover:!bg-black hover:!text-gray-200 focus:!bg-black focus:!text-white",day_today:"bg-gray-200 text-black",day_outside:"day-outside text-[#94a3b8] aria-selected:bg-[#f1f5f9]/50 aria-selected:text-[#94a3b8]",day_disabled:"text-[#94a3b8] opacity-50",day_range_middle:"aria-selected:bg-[#f1f5f9] aria-selected:text-black",day_hidden:"invisible",...a};return n.jsx(LSe,{showOutsideDays:t,className:vm("p-3",e),classNames:r,components:{IconLeft:()=>n.jsx(Lc,{className:"h-4 w-4"}),IconRight:()=>n.jsx(jc,{className:"h-4 w-4"})},...i})}jSe.displayName="Calendar";const BSe=({setScheduleTime:e,setTimezone:a,timezone:t,scheduleTime:i,setIsDirty:o,canEditScheduleTime:s})=>{const[l,u]=r.useState(i&&i<(new Date).toISOString()?"Please select a time in the future":null),[c,d]=r.useState(i&&"now"!==i?eue(new Date(i),"HH:mm"):"00:00"),m=Intl.supportedValuesOf("timeZone").map((e=>({label:e,value:e}))),h=e=>{if(!s)return;const n=new Date(i||(new Date).toISOString()),t=hle(new Date,15);n<new Date(t.toLocaleString("en-US",{timeZone:e}))?u("Please select a time at least 15 minutes in the future"):(u(null),a(e),o(!0))},p=a=>{if(!s)return;const n=hle(new Date,15);new Date(a.toLocaleString("en-US",{timeZone:t}))<new Date(n.toLocaleString("en-US",{timeZone:t}))?u("Please select a time at least 15 minutes in the future"):(u(null),e(a.toISOString()),o(!0))};return n.jsx("div",{className:"w-full @container/schedule-time",children:n.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[n.jsxs("div",{className:"flex gap-2 w-full @xl/schedule-time:flex-row flex-col items-center justify-center",children:[n.jsxs(are,{children:[n.jsx(nre,{asChild:!0,children:n.jsxs(k5,{variant:"outline",disabled:!s,className:vm("bg-background w-full sm:w-[280px] justify-start text-left font-normal",!i&&"text-muted-foreground",!s&&"opacity-50 cursor-not-allowed"),children:[n.jsx(Nc,{className:"mr-2 h-4 w-4"}),i?"now"===i?"Send immediately":eue(new Date(i),"PPP"):n.jsx("span",{children:"Pick a date"})]})}),n.jsx(tre,{className:"w-auto p-0 z-[60] pointer-events-auto",children:n.jsx(jSe,{mode:"single",selected:i?new Date(i):void 0,onSelect:e=>{if(!e||!s)return;const[a,n]=c.split(":").map(Number);e.setHours(a,n),p(e)},disabled:e=>{const a=new Date;return a.setHours(0,0,0,0),e<a||!s},initialFocus:!0})})]}),n.jsx("input",{type:"time",value:c,onChange:e=>{if(s&&(d(e.target.value),i&&e.target.value)){const[a,n]=e.target.value.split(":").map(Number),t=new Date(i);t.setHours(a,n),p(t)}},disabled:!s,className:vm("flex h-9 w-full sm:w-[150px] rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",l&&"border-red-500",!s&&"opacity-50 cursor-not-allowed")}),n.jsx("div",{className:"w-full sm:w-[200px]",children:n.jsx(Jve,{options:m,selectedValues:[t],setSelectedValues:e=>h(e[0]),onValueChange:e=>h(e[0]),placeholder:"Select timezone...",searchPlaceholder:"Search timezone...",emptyMessage:"No timezone found",title:"Select Timezone",singleSelect:!0,canOpen:s})})]}),l&&n.jsxs("p",{className:"text-destructive text-sm mt-2 flex items-center",children:[n.jsx("span",{className:"mr-2",children:"⚠️"}),l]})]})})},RSe=({title:e="Edit Schedule Time"})=>{const t=d5(),i=ce(),{updateAutomation:r}=ta(t?.id||""),{toast:o}=Ge(),[s,l]=a.useState(null),[u,c]=a.useState(t?.triggerMetadata?.triggerType===sa.ONE_TIME?t?.triggerMetadata?.scheduledAt:null),[d,m]=a.useState(t?.triggerMetadata?.triggerType===sa.ONE_TIME&&t?.triggerMetadata?.timezone||"America/New_York"),[h,p]=a.useState(!1),[g,v]=a.useState(null);let f=a.useRef(null);const y=a.useCallback((()=>{t&&("sendNow"===s||"now"===u?r({trigger:{triggerType:sa.ONE_TIME,scheduledAt:"now"}},{onSuccess:()=>{v({title:"Schedule time updated successfully 🚀",description:`${_h("engage:broadcast")} scheduled to begin sending in 5 minutes after you activate it`})},onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:Le.all})}}):u&&d&&r({trigger:{triggerType:sa.ONE_TIME,scheduledAt:u,timezone:d}},{onSuccess:()=>{v({title:"Schedule time updated successfully 🚀",description:`${_h("engage:broadcast")} scheduled to start at ${new Date(u).toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric"})}`})},onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:Le.all})}}))}),[t,s,u,d,r,o,i]);if(a.useEffect((()=>(g&&(f.current&&clearTimeout(f.current),f.current=setTimeout((()=>{o(g),v(null)}),800)),()=>{f.current&&clearTimeout(f.current)})),[g,o]),a.useEffect((()=>{t&&h&&s&&("sendNow"===s||u)&&(y(),p(!1))}),[s,u,d,y,t,h]),a.useEffect((()=>{null===s&&t?.triggerMetadata&&"object"==typeof t.triggerMetadata&&null!==t.triggerMetadata&&"scheduledAt"in t.triggerMetadata&&("now"===t?.triggerMetadata?.scheduledAt&&t?.triggerType===sa.ONE_TIME?l("sendNow"):(t?.triggerMetadata?.scheduledAt&&c(t.triggerMetadata.scheduledAt),t?.triggerMetadata?.timezone&&m(t.triggerMetadata.timezone),l("schedule")))}),[t,s]),!t)return null;const k=t.status===da.DRAFT;return n.jsx(jye,{title:e,headerActions:!k&&n.jsx(pue,{title:"You can only edit the schedule time if the automation is in draft mode"}),children:n.jsx("div",{className:"@container flex-1 mx-4",children:n.jsxs("div",{className:"flex @[1000px]:flex-row flex-col gap-8 items-center",children:[n.jsxs("div",{className:"flex-1 w-full",children:[n.jsxs("div",{className:"grid grid-cols-1 @[480px]:grid-cols-2 gap-4",children:[n.jsx(A5,{selected:"sendNow"===s,title:"Send Now",subtitle:"Campaign will begin sending in 5 minutes",icon:n.jsx(w5.SendButton,{className:"text-primary"}),onClick:()=>{k&&(l("sendNow"),c("now"),m("America/New_York"),p(!0))},disabled:!k}),n.jsx(A5,{selected:"schedule"===s,title:"Schedule",subtitle:"Choose date and time",icon:n.jsx(w5.ScheduleButton,{className:"text-primary"}),onClick:()=>{k&&l("schedule")},disabled:!k})]}),n.jsx(eY,{children:"schedule"===s&&n.jsx(f5,{className:"overflow-hidden mt-8",children:n.jsx("div",{className:"bg-gray-50 rounded-xl p-5 border border-gray-100 flex items-center justify-center",children:n.jsx(BSe,{setScheduleTime:e=>{c(e),p(!0)},setTimezone:e=>{m(e),p(!0)},timezone:d,scheduleTime:u,setIsDirty:p,canEditScheduleTime:k})})})})]}),u&&n.jsx(K4.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},transition:{duration:.6,ease:[.23,1,.32,1],delay:.1},className:"@[1000px]:w-80 max-w-md w-full shrink-0 h-fit p-4 bg-blue-50 rounded-xl border border-blue-100 backdrop-blur-sm",children:n.jsxs(n.Fragment,"now"===u?{children:[n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Ready to send immediately"}),n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.4},className:"text-md font-bold text-gray-800",children:"Once you mark this automation as active, we'll send it 5 minutes from that moment"})]}:{children:[n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Currently scheduled for:"}),n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.4},className:"text-md font-bold text-gray-800",children:new Date(u).toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0,timeZoneName:"short",timeZone:d||void 0})})]})})]})})})},zSe=()=>n.jsx("div",{children:n.jsx(RSe,{title:"Set Schedule Time"})});var DSe=(e=>(e.DAYS="days",e))(DSe||{});const KSe=(e,a)=>{switch(e){case u5.EQUALS:return"Equals";case u5.NOT_EQUALS:return"Not Equals";case u5.GREATER_THAN:return a===s5.Date?"Date on or after":"Greater than";case u5.LESS_THAN:return a===s5.Date?"Date on or before":"Less than";case u5.EXISTS:return"Exists";case u5.EQUALS_MONTH_DAY:return"Month and Day Matches";case u5.EQUALS_MONTH_DAY_YEAR:return"Month, Day, and Year Matches";case u5.BETWEEN_MONTH_DAY:return"Between Month Day";case u5.BETWEEN_MONTH_DAY_YEAR:return"Between Month Day Year";case u5.ARRAY_CONTAINS:return"Is One Of";default:return e}},OSe={email:"Email Address",phone:"Phone Number",firstName:"First Name",lastName:"Last Name"},HSe=({options:e,value:a,onChange:t,placeholder:i,className:o="",disableInput:s=!1})=>{const[l,u]=r.useState(!1);return n.jsxs(are,{modal:!0,open:l,onOpenChange:u,children:[n.jsx(nre,{asChild:!0,children:n.jsxs(k5,{"aria-expanded":l,className:vm("w-full overflow-hidden justify-between",o),variant:"outline",children:[a?e.find((e=>e.value===a))?.label:i,n.jsx(Rc,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),n.jsx(tre,{className:vm("w-full min-w-[120px] max-w-[600px] p-0",o),children:n.jsxs(Nge,{children:[!s&&n.jsx(_ge,{placeholder:`${i}...`}),n.jsxs(Pge,{children:[n.jsxs(Lge,{children:["No ",i.toLowerCase()," found."]}),n.jsx(jge,{children:e.map((e=>n.jsxs(Bge,{value:e.value,onSelect:e=>{t(e===a?"":e),u(!1)},children:[n.jsx(_c,{className:vm("mr-2 h-4 w-4",a===e.value?"opacity-100":"opacity-0")}),e.label]},e.id||e.value)))})]})]})})]})};var ISe="Switch",[GSe,FSe]=G6(ISe),[VSe,JSe]=GSe(ISe),USe=r.forwardRef(((e,a)=>{const{__scopeSwitch:t,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),v=nq(a,(e=>g(e))),f=r.useRef(!1),y=!p||(m||!!p.closest("form")),[k=!1,b]=J6({prop:o,defaultProp:s,onChange:d});return n.jsxs(VSe,{scope:t,checked:k,disabled:u,children:[n.jsx(Y6.button,{type:"button",role:"switch","aria-checked":k,"aria-required":l,"data-state":$Se(k),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:v,onClick:I6(e.onClick,(e=>{b((e=>!e)),y&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())}))}),y&&n.jsx(ZSe,{control:p,bubbles:!f.current,name:i,value:c,checked:k,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"}})]})}));USe.displayName=ISe;var WSe="SwitchThumb",qSe=r.forwardRef(((e,a)=>{const{__scopeSwitch:t,...i}=e,r=JSe(WSe,t);return n.jsx(Y6.span,{"data-state":$Se(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:a})}));qSe.displayName=WSe;var ZSe=e=>{const{control:a,checked:t,bubbles:i=!0,...o}=e,s=r.useRef(null),l=Spe(t),u=i7(a);return r.useEffect((()=>{const e=s.current,a=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(a,"checked").set;if(l!==t&&n){const a=new Event("click",{bubbles:i});n.call(e,t),e.dispatchEvent(a)}}),[l,t,i]),n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...o,tabIndex:-1,ref:s,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function $Se(e){return e?"checked":"unchecked"}var YSe=USe,QSe=qSe;const XSe=r.forwardRef((({className:e,...a},t)=>n.jsx(YSe,{className:vm("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input/50",e),...a,ref:t,children:n.jsx(QSe,{className:vm("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})));XSe.displayName=YSe.displayName;const eAe=({onSelect:e,date:a,placeholder:t="Pick a date",monthDayOnly:i=!1})=>n.jsxs(are,{modal:!0,children:[n.jsx(nre,{asChild:!0,children:n.jsxs(k5,{variant:"outline",className:vm("w-[200px] justify-start text-left font-normal h-9",!a&&"text-muted-foreground"),children:[n.jsx(Nc,{className:"mr-2 h-4 w-4"}),a?eue(a,i?"MMMM d":"PPP"):n.jsx("span",{children:t})]})}),n.jsx(tre,{className:"w-auto p-0",align:"start",children:n.jsx(jSe,{mode:"single",selected:a,onSelect:e,initialFocus:!0})})]}),aAe=e=>void 0===e.value||!("number"!=typeof e.value||e.value<0)&&(e.unit===DSe.DAYS&&(("before"===e.direction||"after"===e.direction)&&"relative"===e.type)),nAe=({fieldType:e,operator:a,value:t,onChange:i,options:o,toast:s})=>{const l=t.length>0&&"object"==typeof t[0]&&"type"in t[0]&&"relative"===t[0].type,u=t.length>0&&"object"==typeof t[0]&&"startDate"in t[0]&&"endDate"in t[0],[c,d]=r.useState((e===s5.Date||e===s5.DateTime)&&t.length>0&&t[0]instanceof Date?t[0]:void 0),[m,h]=r.useState(l),[p,g]=r.useState(l?t[0]:{type:"relative",value:0,unit:DSe.DAYS,direction:"before"}),[v,f]=r.useState(u?t[0]:void 0),[y,k]=r.useState(!1);if(r.useEffect((()=>{a!==u5.EQUALS_MONTH_DAY&&a!==u5.EQUALS_MONTH_DAY_YEAR&&m&&(h(!1),i(c?[c]:[]))}),[a,m,c,i]),r.useEffect((()=>{if(u&&v?.startDate){k("object"==typeof v.startDate&&"type"in v.startDate)}}),[u,v]),e===s5.String||e===s5.ReachResource||e===s5.Array)return a===u5.EXISTS?null:n.jsx(Jve,{options:(o||[]).map((e=>({label:e.displayName,value:e.id}))),onValueChange:e=>{i(e)},selectedValues:t.map((e=>{const a=(o||[]).find((a=>a.id===String(e)||a.displayName===String(e)||a.id===a.displayName&&a.id===String(e)));return a?.id||String(e)})),setSelectedValues:e=>{i(e)}});if(e===s5.Date||e===s5.DateTime){const e=a===u5.EQUALS_MONTH_DAY||a===u5.EQUALS_MONTH_DAY_YEAR,t=a===u5.BETWEEN_MONTH_DAY||a===u5.BETWEEN_MONTH_DAY_YEAR,r=e=>{aAe(e)?(g(e),m&&i([e])):s({title:"Invalid relative date",description:"Please enter a valid non-negative number of days.",variant:"destructive"})},o=e=>{const a=e.startDate??v?.startDate,n=e.endDate??v?.endDate,t=a&&"object"==typeof a&&"type"in a,r=n&&"object"==typeof n&&"type"in n;if(a&&n){if(t!==r)return void s({title:"Invalid date range",description:"Both start and end dates must be of the same type (either both absolute or both relative).",variant:"destructive"});if(!t&&!r&&!(e=>!e.finalStartDate||!e.finalEndDate||e.finalStartDate<e.finalEndDate)({finalStartDate:a,finalEndDate:n}))return void s({title:"Invalid date range",description:"Start date must be before end date.",variant:"destructive"});if(t&&(!aAe(a)||!aAe(n)))return void s({title:"Invalid relative date",description:"Please enter valid relative dates.",variant:"destructive"})}f(e),a&&n&&i([{startDate:a,endDate:n}])},l=e=>{e&&(e=>e instanceof Date?!isNaN(e.getTime()):"object"==typeof e&&"type"in e&&"relative"===e.type&&aAe(e))(e)?(d(e),i([e]),h(!1)):e||(d(void 0),i([]),h(!1))},u=e=>{h(e),i(e?[p]:c?[c]:[])};return n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"min-h-[36px] flex items-center",children:[(!m||!e)&&!t&&n.jsx(eAe,{date:c,onSelect:l,monthDayOnly:a===u5.EQUALS_MONTH_DAY}),e&&m&&n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(qae,{type:"number",value:void 0===p.value?"":p.value,onChange:e=>{const a=""===e.target.value?void 0:parseInt(e.target.value,10);r({...p,value:a})},className:"w-20 h-9",min:"0","aria-label":"Relative days value"}),n.jsxs(nme,{value:p.direction,onValueChange:e=>{r({...p,direction:e})},children:[n.jsx(rme,{className:"w-[180px] h-9","aria-label":"Relative direction",children:n.jsx(ime,{placeholder:"Select direction..."})}),n.jsxs(lme,{children:[n.jsx(ume,{value:"before",children:"days before today"}),n.jsx(ume,{value:"after",children:"days after today"})]})]})]}),t&&n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"flex flex-col space-y-2",children:[n.jsx("div",{className:"flex items-center space-x-2",children:y?n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(qae,{type:"number",value:v?.startDate&&"object"==typeof v.startDate&&"type"in v.startDate?v.startDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:DSe.DAYS,direction:v?.startDate?.direction||"before"};aAe(a)&&(f({...v,startDate:a}),o({...v,startDate:a}))},className:"w-20 h-9",min:"0","aria-label":"Start date relative days"}),n.jsxs(nme,{value:v?.startDate&&"object"==typeof v.startDate&&"type"in v.startDate?v.startDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:v?.startDate?.value,unit:DSe.DAYS,direction:e};aAe(a)&&(f({...v,startDate:a}),o({...v,startDate:a}))},children:[n.jsx(rme,{className:"w-[180px] h-9",children:n.jsx(ime,{placeholder:"Select direction..."})}),n.jsxs(lme,{children:[n.jsx(ume,{value:"before",children:"days before today"}),n.jsx(ume,{value:"after",children:"days after today"})]})]}),n.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"Start"})]}):n.jsx(eAe,{placeholder:"Start date",date:v?.startDate instanceof Date||"string"==typeof v?.startDate?v.startDate instanceof Date?v.startDate:new Date(v.startDate):void 0,monthDayOnly:a===u5.BETWEEN_MONTH_DAY,onSelect:e=>{const a=e;a&&(f({...v,startDate:a}),o({...v,startDate:a}))}})}),n.jsx("div",{className:"flex items-center space-x-2",children:y?n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(qae,{type:"number",value:v?.endDate&&"object"==typeof v.endDate&&"type"in v.endDate?v.endDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:DSe.DAYS,direction:v?.endDate?.direction||"before"};aAe(a)&&(f({...v,endDate:a}),o({...v,endDate:a}))},className:"w-20 h-9",min:"0","aria-label":"End date relative days"}),n.jsxs(nme,{value:v?.endDate&&"object"==typeof v.endDate&&"type"in v.endDate?v.endDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:v?.endDate?.value,unit:DSe.DAYS,direction:e};aAe(a)&&(f({...v,endDate:a}),o({...v,endDate:a}))},children:[n.jsx(rme,{className:"w-[180px] h-9",children:n.jsx(ime,{placeholder:"Select direction..."})}),n.jsxs(lme,{children:[n.jsx(ume,{value:"before",children:"days before today"}),n.jsx(ume,{value:"after",children:"days after today"})]})]}),n.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"End"})]}):n.jsx(eAe,{placeholder:"End date",date:v?.endDate instanceof Date||"string"==typeof v?.endDate?v.endDate instanceof Date?v.endDate:new Date(v.endDate):void 0,monthDayOnly:a===u5.BETWEEN_MONTH_DAY,onSelect:e=>{const a=e;a&&(f({...v,endDate:a}),o({...v,endDate:a}))}})})]}),n.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[n.jsx(XSe,{id:"between-relative-date-switch",checked:y,onCheckedChange:e=>{if(k(e),e){const e={type:"relative",value:0,unit:DSe.DAYS,direction:"before"},a={type:"relative",value:0,unit:DSe.DAYS,direction:"before"};f({startDate:e,endDate:a}),o({startDate:e,endDate:a})}else{const e=new Date,a=new Date(e);a.setDate(a.getDate()+1),f({startDate:e,endDate:a}),o({startDate:e,endDate:a})}},"aria-label":"Toggle relative date input for between dates"}),n.jsx(Eue,{htmlFor:"between-relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})]}),e&&n.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[n.jsx(XSe,{id:"relative-date-switch",checked:m,onCheckedChange:u,"aria-label":"Toggle relative date input"}),n.jsx(Eue,{htmlFor:"relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})}if(e===s5.Number||e===s5.Integer)return a===u5.EXISTS?null:n.jsx(qae,{type:"number",value:t.length>0?String(t[0]):"",onChange:e=>i([Number(e.target.value)]),className:"w-[200px]"});if(e===s5.Boolean){if(a===u5.EXISTS)return null;const e=t.length>0&&Boolean(t[0]);return n.jsx(XSe,{checked:e,onCheckedChange:e=>i([e])})}return n.jsx(qae,{value:t.length>0?String(t[0]):"",onChange:e=>i([e.target.value]),className:"w-[200px]",disabled:!0})},tAe=({condition:e,onUpdate:t,onDuplicate:i,onDelete:r,segmentsConditions:o})=>{const{toast:s}=Ge(),l=(e=>{const a=o.conditions.find((a=>a.field===e));return a||null})(e.field)||{operators:[],type:s5.String,options:void 0},u=l.operators,c=l.type,d=o.conditions.map((e=>e.field)).map((e=>({value:e,label:OSe[e]||e})));return a.useEffect((()=>{setTimeout((()=>document.body.style.pointerEvents=""),0)}),[]),n.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch gap-2 min-w-0 w-full",children:[n.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 items-stretch gap-2 min-w-0 w-full",children:[n.jsx("div",{className:"flex-1 min-w-0 items-center flex",children:n.jsx(HSe,{options:d,value:e.field,onChange:a=>{const n=a,i=o.conditions.find((e=>e.field===n));if(!i)return;const r=i.operators.map((e=>({value:e,label:KSe(e,i.type),fieldType:i.type}))),s=r[0]?.value;let l=[];switch(i.type){case s5.Boolean:l=[!1];break;case s5.Number:l=[0];break;case s5.Date:case s5.DateTime:l=[new Date];break;case s5.String:l=i.options?.length?i.options.map((e=>e.displayName)):[];break;default:l=[]}t({...e,field:n,operator:s,value:l})},placeholder:"Select field",className:"w-full",disableInput:!0})}),n.jsxs("div",{className:"flex-1 min-w-0 max-w-xs flex gap-2 items-center",children:[(e.operator===u5.EQUALS_MONTH_DAY||e.operator===u5.EQUALS_MONTH_DAY_YEAR||e.operator===u5.BETWEEN_MONTH_DAY||e.operator===u5.BETWEEN_MONTH_DAY_YEAR)&&n.jsx("div",{className:"flex items-center",children:(e=>{let a;switch(e){case u5.EQUALS_MONTH_DAY:a="This operator will check if only the month and day are equal. This is useful for things like birthday, where year does not matter";break;case u5.EQUALS_MONTH_DAY_YEAR:a="This operator will check if only the month and day are equal. This is useful for things like appointment dates, where specific day and month is important but year does not matter";break;case u5.BETWEEN_MONTH_DAY:a="This operator will check if the date is between the two dates, but only checking the month and the day, not the year. This is helpful for things like birthday, where year does not matter";break;case u5.BETWEEN_MONTH_DAY_YEAR:a="This operator will check if the date is between the two dates, checking the month, day and year. This is helpful for things like appointment dates, where specific day, month and year is important";break;default:return null}return n.jsx(pue,{title:a})})(e.operator)}),n.jsx(HSe,{options:u.map((e=>({value:e,label:e?KSe(e,c):e}))),value:e.operator,onChange:a=>t({...e,operator:a}),placeholder:"Select operator",className:"w-full",disableInput:!0})]}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(nAe,{fieldType:c,operator:e.operator,options:"string"==typeof e.value[0]&&e.value[0]&&Array.isArray(l.options)?[...(l.options||[]).map((e=>({displayName:e.displayName,id:e.id}))),...e.value.filter((e=>!l.options?.some((a=>a.id===e||a.displayName===e)))).map((e=>({displayName:e,id:e})))]:l.options?.map((e=>({displayName:e.displayName,id:e.id}))),value:e.value,onChange:a=>t({...e,value:a}),toast:s})})]}),n.jsxs("div",{className:"flex items-center flex-shrink-0 pl-2",children:[n.jsx(k5,{size:"icon",variant:"ghost",onClick:i,children:n.jsx(Ic,{className:"h-4 w-4"})}),n.jsx(k5,{size:"icon",variant:"ghost",onClick:r,children:n.jsx(vd,{className:"h-4 w-4"})})]})]})},iAe=({onSelectStyle:e})=>{const[t,i]=a.useState(null);return n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 max-w-4xl mx-auto",children:[n.jsx(A5,{onClick:()=>{i("ai"),e("ai")},title:"Build with AI",subtitle:"Describe your audience in plain language and let AI create the conditions",icon:n.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:n.jsx(pd,{className:"w-full h-full"})})}),selected:"ai"===t}),n.jsx(A5,{onClick:()=>{i("manual"),e("manual")},title:"Build Manually",subtitle:`Create your ${_h("engage:segment")} by configuring conditions directly`,icon:n.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:n.jsx(dd,{className:"w-full h-full"})})}),selected:"manual"===t})]})},rAe=({segmentId:e,setOpen:a,setTextToSegment:t,promptBuilderStyle:i,textToSegment:r})=>n.jsx("div",{children:n.jsx(D$,{className:"",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(O$,{className:"text-3xl font-normal",children:e?`Edit ${_h("engage:segment")}`:`Create ${_h("engage:segment")}`}),n.jsxs("div",{className:"flex items-center gap-2",children:[!1===i&&!1===r&&n.jsx(kie,{children:n.jsxs(bie,{children:[n.jsx(Sie,{asChild:!0,children:n.jsx(k5,{variant:"outline",size:"sm",onClick:()=>t(!0),children:n.jsx(pd,{className:"h-4 w-3"})})}),n.jsx(Aie,{children:n.jsxs("p",{children:["Use AI to create ",_h("engage:segment")," by describing them in natural language"]})})]})}),n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>{a(!1)},className:"h-8 w-8",children:n.jsx(Ad,{className:"h-4 w-4"})})]})]})})}),oAe=({setTextToSegment:e,setSegment:t})=>{const[i,r]=a.useState(""),[o,s]=a.useState(!1),{toast:u}=Ge();return n.jsxs("div",{className:"flex flex-col gap-6 p-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Describe your audience"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Describe the audience you want to target in plain language, and our AI will create the conditions for you."})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(eY,{children:[o&&n.jsx(f5,{children:n.jsx(v5,{})}),!o&&n.jsx(f5,{children:n.jsx(Uve,{placeholder:"Describe your target audience...",className:"min-h-[120px] resize-none",value:i,onChange:e=>r(e.target.value)})})]}),n.jsx("div",{className:"flex justify-end gap-2",children:n.jsxs(k5,{onClick:async()=>{if(!i)return void u({title:"Please enter a description",description:"Please enter a description of your target audience",variant:"destructive"});s(!0);const a=await(async e=>(await Pe(`${l}/text-to-segment`,{method:"POST",body:JSON.stringify({text:e})})).data)(i);a.success&&a.conditions?(u({title:`${_h("engage:segment")} conditions built successfully 🚀`,description:`Your ${_h("engage:segment")} conditions have been built successfully`}),t(a.conditions)):u({title:`${_h("engage:segment")} build failed`,description:"Please try again",variant:"destructive"}),e(!1),s(!1)},children:[n.jsx(pd,{className:"h-4 w-4"}),"Generate ",_h("engage:segment")]})})]})]})};function sAe({segmentId:e,setOpen:a,onSegmentUpdated:t}){const{toast:i}=Ge(),o=void 0===e,[s,l]=r.useState(!1),[u,c]=r.useState({version:"1.0",id:"",name:"",description:"",logic:"AND",conditions:[]}),{segment:d,isLoading:m}=r5(e||""),{updateSegment:h}=o5(e),{createSegment:p,isCreating:g,segmentsConditions:v}=n5(),[f,y]=r.useState(!1),[k,b]=r.useState(!!o);r.useEffect((()=>{v&&c(d?{version:"1.0",id:d.id,name:d.name,description:d.description,logic:"AND",conditions:d.conditions}:{version:"1.0",id:"",name:"",description:"",logic:"AND",conditions:[{field:v.conditions[0].field,operator:v.conditions[0].operators[0],value:[]}]})}),[d,v]);const S=e=>e.value.some((e=>"object"==typeof e&&"type"in e&&"relative"===e.type)),A=e=>e.value.some((e=>"object"==typeof e&&"startDate"in e&&"endDate"in e));if(!v||m)return n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(v5,{})});return n.jsxs(n.Fragment,{children:[n.jsx(rAe,{segmentId:e,setOpen:a,setTextToSegment:y,promptBuilderStyle:k,textToSegment:f},"segment-builder-header"),k?n.jsx(f5,{children:n.jsx(iAe,{onSelectStyle:e=>{"ai"===e&&y(!0),b(!1)}})},"prompt-builder-style"):n.jsx(f5,{children:n.jsxs("div",{className:"flex flex-1 flex-col",children:[n.jsx("div",{className:"flex flex-1 flex-col px-8 py-2",children:n.jsx("div",{className:"flex flex-1 flex-col gap-4 overflow-visible",children:n.jsx(eY,{children:f?n.jsx(f5,{children:n.jsx(oAe,{setTextToSegment:y,setSegment:e=>c({...u,conditions:e})})}):n.jsxs(f5,{children:[n.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex items-center gap-0",children:[n.jsx(Eue,{className:"text-muted-foreground text-xs",children:"Name"}),n.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),n.jsx(qae,{placeholder:`${_h("engage:segment")} name`,value:u.name,onChange:e=>c({...u,name:e.target.value})})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(Eue,{className:"text-muted-foreground text-xs",children:"Description"}),n.jsx(qae,{placeholder:`${_h("engage:segment")} description`,value:u.description,onChange:e=>c({...u,description:e.target.value})})]})]}),u.conditions.length>0&&n.jsx("div",{className:"flex-1 overflow-y-auto pb-8",children:n.jsx("div",{className:"grid",children:n.jsx(eY,{mode:"popLayout",children:u.conditions.map(((e,a)=>n.jsxs(K4.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{type:"spring",stiffness:300,damping:30,mass:.5},children:[a>0&&n.jsxs(K4.div,{className:"relative flex items-center gap-3 py-1",initial:{opacity:0},animate:{opacity:1},transition:{delay:.1},children:[n.jsx(K4.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}}),n.jsx(K4.span,{className:"text-muted-foreground text-xs",initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},children:"AND"}),n.jsx(K4.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}})]}),n.jsx(tAe,{condition:e,onUpdate:e=>((e,a)=>{const n=[...u.conditions];n[e]=a,c({...u,conditions:n})})(a,e),segmentsConditions:v,onDuplicate:()=>(e=>{const a=[...u.conditions];a.splice(e+1,0,{...u.conditions[e]}),c({...u,conditions:a})})(a),onDelete:()=>(e=>{const a=u.conditions.filter(((a,n)=>n!==e));c({...u,conditions:a})})(a)})]},`${e.field}-${e.operator}-${a}`)))})})})]})})})}),n.jsx("div",{className:"border-t px-8 py-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(k5,f?{variant:"secondary",onClick:()=>y(!1),children:[n.jsx(dd,{className:"h-4 w-4"}),"Manual Builder"]}:{variant:"secondary",onClick:()=>{c({...u,conditions:[...u.conditions,{field:v.conditions[0].field,operator:v.conditions[0].operators[0],value:[]}]})},children:[n.jsx(sd,{className:"h-4 w-4"}),"Add Condition"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(k5,{variant:"destructive",onClick:()=>a(!1),children:"Cancel"}),n.jsx(k5,{variant:"default",onClick:async()=>{if(!u.name)return void i({title:"Name is required",description:"Please ensure all fields are filled out",variant:"destructive"});const{valid:n,error:r}=(e=>{for(const a of e){if(!a.field||!a.operator)return{valid:!1,error:"Please ensure all fields are filled out for condition"};if(a.operator!==u5.EXISTS&&0===a.value.length)return{valid:!1,error:`Please ensure a value is selected for ${a.field}`};if(a.operator===u5.EXISTS&&a.value.length>0)return{valid:!1,error:`EXISTS operator can only be used with an empty array for ${a.field}`};if(S(a)&&a.operator!==u5.EQUALS_MONTH_DAY&&a.operator!==u5.EQUALS_MONTH_DAY_YEAR)return{valid:!1,error:`Relative dates can only be used with the month and day or month, day, and year operator for ${a.field}`};if(S(a)&&void 0===a.value[0].value)return{valid:!1,error:`Please select a value for the relative date for ${a.field}`};if(A(a)&&a.operator!==u5.BETWEEN_MONTH_DAY&&a.operator!==u5.BETWEEN_MONTH_DAY_YEAR)return{valid:!1,error:`Between dates can only be used with the between month day or between month day year operator for ${a.field}`};if(A(a)&&a.value.length>1)return{valid:!1,error:`Between dates can only have a single value for ${a.field}`};if(A(a)){const e=a.value[0];if(!e.startDate||!e.endDate)return{valid:!1,error:`Please ensure both a start and end date are selected for ${a.field}`};if(e.startDate instanceof Date&&e.endDate instanceof Date&&e.startDate>e.endDate)return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("type"in e.startDate&&"relative"===e.startDate.type&&"type"in e.endDate&&"relative"===e.endDate.type){if(!e.startDate.value||!e.endDate.value)return{valid:!1,error:`Please ensure both a start and end date are selected for ${a.field}`};if(e.startDate.direction!==e.endDate.direction)return{valid:!1,error:`Start and end date must be of the same direction for ${a.field}`};const n=e=>{if(e.unit===DSe.DAYS)return e.value??0;throw U4(e.unit,DSe)};if("before"===e.startDate.direction&&n(e.startDate)>n(e.endDate))return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("after"===e.startDate.direction&&n(e.startDate)<n(e.endDate))return{valid:!1,error:`Start date must be after end date for ${a.field}`}}}}return{valid:!0,error:void 0}})(u.conditions);if(!n)return void i({title:"Conditions are invalid",description:r??"Please ensure all fields are filled out",variant:"destructive"});const o=u.conditions.map((e=>{const a=v?.conditions.find((a=>a.field===e.field));return a?.type===s5.Date&&(e.value=e.value.map((e=>e instanceof Date?e.toISOString().split("T")[0]:e))),e}));l(!0);try{e&&d?h({name:u.name,description:u.description,conditions:o},{onSuccess:()=>{i({title:`${_h("engage:segment")} updated successfully`}),a(!1),t?.(e)},onError:()=>{i({title:`Error updating ${_h("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}}):p({name:u.name,description:u.description,conditions:u.conditions},{onSuccess:e=>{i({title:`${_h("engage:segment")} created successfully`}),t?.(e?.id??!1),a(!1)},onError:()=>{i({title:`Error creating ${_h("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}})}catch(s){i({title:`Error saving ${_h("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}finally{l(!1)}},disabled:s||g,children:s||g?n.jsxs(n.Fragment,{children:[n.jsx(Zc,{className:"mr-2 h-4 w-4 animate-spin"}),e?"Updating...":"Creating..."]}):e?"Update":"Create"})]})]})})]})},"manual-builder-style")]})}function lAe({open:e,setOpen:a,segmentId:t,onSegmentUpdated:i}){return n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"flex max-h-[86vh] flex-col gap-0 overflow-visible max-w-6xl w-full",hideCloseButton:!0,children:[n.jsxs(lq,{children:[n.jsxs(O$,{children:[_h("engage:segment")," Builder"]}),n.jsxs(H$,{children:["Build a ",_h("engage:segment")," to target your audience"]})]}),n.jsx(sAe,{segmentId:t,setOpen:a,onSegmentUpdated:e=>{i?.(e),a(!1)}})]})})}const uAe=()=>n.jsx(pue,{title:`These are estimated numbers of ${_h("engage:user",{count:2}).toLocaleLowerCase()} that are matched. The actual count may change at the time of sending. You can see the breakdown of who have opted into email or sms.`}),cAe=({value:e,label:a,percentage:t,variant:i,isLoading:r,selected:o})=>n.jsxs("div",{className:"rounded-md border-2 border-muted-foreground/20 px-2 pt-2 pb-3 duration-300 ease-in-out overflow-x-auto max-w-full min-w-0 "+(o?"scale-[1.02] [border-color:hsl(var(--reach-primary))] shadow-lg":""),style:{containerType:"inline-size"},"data-card-container":!0,children:[n.jsxs("div",{className:"flex flex-col gap-1 items-start w-full min-w-0",children:[n.jsx("div",{className:"flex items-baseline gap-2 w-full min-w-0 @container/num",children:r?n.jsx("span",{className:"animate-pulse",children:"..."}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-semibold pl-2 break-words max-w-full min-w-0 truncate\n text-xl @[250px]/card:text-2xl @[350px]/card:text-3xl @[500px]/card:text-4xl text-primary",children:e.toLocaleString()}),void 0!==t&&e.toLocaleString().replace(/,/g,"").length<5&&n.jsxs("span",{className:"text-muted-foreground/50 text-sm hidden @[120px]/num:inline",children:["(",t,"%)"]})]})}),n.jsx("span",{className:`px-2 sm:px-2.5 py-1 text-xs font-medium rounded-lg ${{default:"bg-gray-100/50 text-gray-700",blue:"bg-blue-100/50 text-blue-700",green:"bg-green-100/50 text-green-700"}[i]}`,children:a})]}),n.jsx("p",{className:"text-sm text-muted-fore hidden @[250px]/card:inline mt-1",children:1===e?"contact":"contacts"})]}),dAe=({countResponse:e})=>{const t=a.useMemo((()=>e?.recipients?e.recipients.reduce(((a,n)=>({total:e.count,emails:a.emails+(n.email?1:0),phones:a.phones+(n.phone?1:0)})),{total:0,emails:0,phones:0}):{total:0,emails:0,phones:0}),[e]),i=e=>Math.round(e/(t.total||1)*100);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Lye,{children:"Estimated Matches"}),n.jsx(uAe,{})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 md:mb-6 w-full gap-4 mt-3 px-1",children:[n.jsx(cAe,{value:t.total,label:"Total",variant:"default",isLoading:void 0===e}),n.jsx(cAe,{value:t.emails,label:"Subscribed to Email",percentage:i(t.emails),variant:"blue",isLoading:void 0===e}),n.jsx(cAe,{value:t.phones,label:"Subscribed to SMS",percentage:i(t.phones),variant:"green",isLoading:void 0===e})]})]})},mAe=e=>{const a=`${e.firstName||""} ${e.lastName||""}`.trim();return a||(e.firstName?e.firstName:e.lastName?e.lastName:e.email?e.email:e.phone?e.phone:`Unnamed ${_h("engage:user")}`)},hAe=({recipients:e})=>e?.length?n.jsx("div",{className:"bg-foreground/5 rounded-lg h-full relative overflow-hidden",children:n.jsx("div",{className:"absolute inset-0 w-full h-full overflow-y-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{className:"sticky top-0 bg-foreground/5 backdrop-blur-sm",children:n.jsxs("tr",{children:[n.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Name"}),n.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Contact"})]})}),n.jsx("tbody",{className:"divide-y divide-gray-200/50",children:e.map(((e,a)=>n.jsxs("tr",{className:"hover:bg-white/50 transition-colors",children:[n.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-gray-900",children:mAe(e)}),n.jsx("td",{className:"px-3 sm:px-4 py-3",children:n.jsxs("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:[e.email&&n.jsx("span",{className:"px-2 sm:px-2.5 py-1 text-xs font-medium bg-blue-100/50 text-blue-700 rounded-lg",children:"Email"}),e.phone&&n.jsx("span",{className:"px-2 sm:px-2.5 py-1 text-xs font-medium bg-green-100/50 text-green-700 rounded-lg",children:"Phone"})]})})]},a)))})]})})}):null,pAe=({onSelectionChange:e,defaultValue:t="all",canEditAudience:i=!0})=>{const[r,o]=a.useState(t),s=a=>{i&&(o(a),e?.(a))};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Lye,{children:"Filter"}),!i&&n.jsx(pue,{title:"You cannot edit the audience unless you are in draft mode"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4 p-1",children:[n.jsx(A5,{onClick:()=>s("all"),title:`All ${_h("engage:user",{count:2})}`,subtitle:"Send to everyone",icon:n.jsx(w5.UsersIcon,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"all"===r,disabled:!i}),n.jsx(A5,{onClick:()=>s("segments"),title:`Select ${_h("engage:user",{count:2})}`,subtitle:`Choose from ${_h("engage:segment",{count:2})}`,icon:n.jsx(w5.UserEdit,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"segments"===r,disabled:!i})]})]})},gAe=({segments:e,allSegments:t,onAddSegment:i,onRemoveSegment:r,setOpenCreateSegmentDialog:o,canEditAudience:s=!0})=>{const[l,u]=a.useState([]),c=t.map((e=>({label:e.name,value:e.id})));return a.useEffect((()=>{u(e)}),[e]),n.jsx("div",{children:n.jsx(Jve,{canOpen:s,selectedValues:l,setSelectedValues:u,options:c,onValueChange:a=>{const n=a.filter((a=>!e.includes(a))),t=e.filter((e=>!a.includes(e)));n.forEach(i),t.forEach(r)},placeholder:"Select segments",maxCount:5,extraCommandItems:[e=>n.jsxs(Bge,{onSelect:()=>{e(!0),o(!0)},className:"cursor-pointer",children:[n.jsx(w5.PlusIcon,{className:"w-4 h-4"}),"New"]},"new-segment")]})})},vAe=({includedSegments:e,excludedSegments:t,handleAddSegment:i,handleRemoveSegment:r,setOpenCreateSegmentDialog:o,segments:s,defaultIsExcludeOpen:l=!1,canEditAudience:u=!0})=>{const[c,d]=a.useState(l);return n.jsxs("div",{children:[n.jsx(gAe,{segments:e,allSegments:s||[],onAddSegment:e=>i(e,"include"),onRemoveSegment:e=>r(e,"include"),setOpenCreateSegmentDialog:o}),n.jsx("div",{className:"border-t border-gray-200 my-8"}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(k5,{onClick:()=>{u&&d(!c)},className:"flex items-center gap-1 transition-colors",size:"sm",children:[n.jsx(K4.div,{animate:{rotate:c?180:0},transition:{duration:.2},children:n.jsx(w5.DropdownMenuTrigger,{className:"w-5 h-5"})}),n.jsx("span",{children:"Don't send to"})]}),n.jsx(eY,{children:c&&n.jsx(K4.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeInOut"},children:n.jsx(gAe,{canEditAudience:u,segments:t,allSegments:s||[],onAddSegment:e=>i(e,"exclude"),onRemoveSegment:e=>r(e,"exclude"),setOpenCreateSegmentDialog:o})})})]})]})},fAe=({title:e="Preview Audience"})=>{const t=d5(),[i,r]=a.useState("all"),[o,s]=a.useState(t?.includeSegmentIds||[]),[l,u]=a.useState(t?.excludeSegmentIds||[]),[c,d]=a.useState(!1),[m,h]=a.useState(!1),{segments:p,isLoading:g}=t5(),{updateAutomation:v}=ta(t?.id??""),[f,y]=a.useState(void 0),k=1===o.length&&0===l.length&&void 0!==p?.find((e=>e.type===l5.ALL_USERS&&e.id===o[0]));a.useEffect((()=>{t&&!m&&(1===o.length&&void 0!==p?.find((e=>e.type===l5.ALL_USERS&&e.id===o[0]))?r("all"):r("segments"),e5({includeSegments:o,excludeSegments:l}).then((e=>{y(e)})),h(!0))}),[t,k,m,o,l,p]);a.useEffect((()=>{t&&m&&(JSON.stringify(o)===JSON.stringify(t.includeSegmentIds)&&JSON.stringify(l)===JSON.stringify(t.excludeSegmentIds)||(v({includeSegments:o,excludeSegments:l}),e5({includeSegments:o,excludeSegments:l}).then((e=>{y(e)}))))}),[o,l,t,m,v]);const b=t?.status===da.DRAFT;return n.jsxs(jye,{title:e,children:[!g&&p&&m?n.jsxs("div",{className:"flex gap-8 w-full pb-4 px-4",children:[n.jsxs("div",{className:"flex flex-col flex-1 relative overflow-y-auto pb-4 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",children:[n.jsx(dAe,{countResponse:f}),n.jsx(pAe,{onSelectionChange:e=>{if(r(e),"all"===e){const e=p?.find((e=>e.type===l5.ALL_USERS));if(!e)return;s([e.id]),u([])}},defaultValue:i,canEditAudience:b}),n.jsx(eY,{children:"segments"===i&&n.jsx(K4.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3,ease:"easeInOut"},className:"w-full pt-4",children:n.jsx(vAe,{canEditAudience:b,includedSegments:o,excludedSegments:l,handleAddSegment:(e,a)=>{"include"===a?s((a=>[...a,e])):u((a=>[...a,e]))},handleRemoveSegment:(e,a)=>{"include"===a?s((a=>a.filter((a=>a!==e)))):u((a=>a.filter((a=>a!==e))))},setOpenCreateSegmentDialog:d,segments:p,defaultIsExcludeOpen:l.length>0})})})]}),n.jsx("div",{className:"flex flex-col flex-1 relative overflow-hidden",children:f?.recipients&&n.jsx(hAe,{recipients:f.recipients})})]}):n.jsx("div",{children:n.jsx(v5,{text:["Fetching segments","Finishing up"]})}),n.jsx(lAe,{open:c,setOpen:d,onSegmentUpdated:e=>{e&&s((a=>[...a,e]))}})]})},yAe=()=>n.jsx(fAe,{title:"Select Audience"}),kAe=()=>{const{channelSenders:e}=fre(),{channelAccounts:t}=pre(),i=m5(),{updateCommunicationGroup:r}=$e(),{state:{selectedChannels:o},setSelectedChannels:s}=a.useContext(dre),l=d5(),{data:u}=Sre(),c=a.useCallback((async e=>{s(e),e.includes("email")||i?.id&&r({groupId:i?.id,params:{emailChannelSenderId:null}}),e.includes("sms")||i?.id&&r({groupId:i?.id,params:{smsChannelSenderId:null}})}),[s,r,i?.id]),d=a.useMemo((()=>wme({channelSenders:e?.results??[],channelAccounts:t?.results??[]})),[e?.results,t?.results]),m=a.useMemo((()=>ale({channelSenders:e?.results??[],channelAccounts:t?.results??[],smsApplication:u})),[e?.results,t?.results,u]);if(!o||!d||!m)return n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(v5,{text:["Fetching Content..."]})});const h=d.length>0,p=m.length>0;return n.jsx("div",{className:"flex flex-col gap-4 flex-shrink-0",children:n.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(oye,{automationType:l?.triggerMetadata?.triggerType,selectedChannels:o,setSelectedChannels:c,hasEmailChannelSenders:h,hasSmsChannelSenders:p})})})};var bAe=(e=>(e[e.SelectAudience=1]="SelectAudience",e[e.SelectSenders=2]="SelectSenders",e[e.EditEmailContent=3]="EditEmailContent",e[e.EditSmsContent=4]="EditSmsContent",e[e.Schedule=5]="Schedule",e[e.PreviewAndSend=6]="PreviewAndSend",e))(bAe||{});const SAe="https://assets.embedreach.com/defaults/logo-placeholder-128.png",AAe="You have not uploaded a custom logo. Please make sure to double check your email before sending!",wAe=()=>{const e=d5(),n=m5(),{state:{selectedChannels:t}}=a.useContext(dre),{data:i}=Sre(),{channelSenders:r}=fre(),{channelAccounts:o}=pre(),s=ale({channelSenders:r?.results??[],channelAccounts:o?.results??[],smsApplication:i}),l=a.useCallback((async a=>e?await(async e=>{const{currentStep:a,automation:n,communicationGroup:t,selectedChannels:i,smsChannelSenders:r}=e;switch(a){case bAe.SelectAudience:return{canMove:n.includeSegmentIds.length>0,errorMessage:"Please ensure you have selected at least one segment"};case bAe.SelectSenders:return{canMove:i.length>0,errorMessage:"Please ensure you have selected at least one channel"};case bAe.EditSmsContent:{const e=n.actionData?.find((e=>"send_communication"===e.actionType));if(!e)return{canMove:!1,errorMessage:"Please ensure you have selected either a email communication or text communication"};if(!t)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};const a=r.find((e=>e.channelSender.id===t.smsChannelSenderId));return a?t.smsMessageBody?a.smsApplication&&a.smsApplication.status!==ele.APPROVED?{canMove:!0,errorMessage:null,warningMessage:"You will only be able to send this message once your SMS application is approved"}:{canMove:!0,errorMessage:null}:{canMove:!1,errorMessage:"Please ensure you have a text body"}:{canMove:!1,errorMessage:"Please ensure you have selected a text sender"}}case bAe.EditEmailContent:{const e=n.actionData?.find((e=>"send_communication"===e.actionType));if(!e)return{canMove:!1,errorMessage:"Please ensure you have selected either a email communication or text communication"};if(!t)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};if(!t.emailChannelSenderId)return{canMove:!1,errorMessage:"Please ensure you have selected a email sender"};if(!t.emailHtmlBody||!t.emailSubject)return{canMove:!1,errorMessage:"Please ensure you have a email body and subject"};let a=null;return t.emailChannelSenderId&&t.emailHtmlBody&&t.emailHtmlBody.includes(SAe)&&(a=AAe),{canMove:!0,errorMessage:null,warningMessage:a}}case bAe.Schedule:{if(!n.triggerMetadata)return{canMove:!1,errorMessage:"Please make sure to select a time to send before starting!"};if(n.triggerMetadata.triggerType!==sa.ONE_TIME)return{canMove:Boolean(n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:null};if(!n.triggerMetadata?.scheduledAt)return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${_h("engage:broadcast")}`};if(!Boolean(n.triggerMetadata?.scheduledAt&&("now"===n.triggerMetadata.scheduledAt||"now"!==n.triggerMetadata.scheduledAt&&new Date(n.triggerMetadata.scheduledAt)>new Date)))return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${_h("engage:broadcast")}`};if(!Boolean(n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))))return{canMove:!1,errorMessage:"Please ensure you have set a valid email or sms communication"};const e=n.triggerMetadata;return{canMove:Boolean(e.scheduledAt&&("now"===e.scheduledAt||new Date(e.scheduledAt)>new Date)&&n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:`Please ensure you have set a valid future date for your ${_h("engage:broadcast")}`}}case bAe.PreviewAndSend:return{canMove:!0,errorMessage:null};default:ire(a,bAe)}})({currentStep:a,automation:e,communicationGroup:n,selectedChannels:t,smsChannelSenders:s}):{canMove:!1,errorMessage:`${_h("engage:broadcast")} not loaded`}),[e,n,t,s]);return{validateStep:l}},CAe=({onFinish:e,getExtraMergeFields:t,onBeforeSchedule:i})=>{const r=d5(),o=m5(),{updateAutomation:s}=ta(r?.id||""),{estimatedMatchesStats:l}=(e=>{const{data:n}=i5({automationId:e?.id??"",includeSegments:e?.includeSegmentIds??[],excludeSegments:e?.excludeSegmentIds??[]}),t=a.useMemo((()=>n?.recipients?n.recipients.reduce(((e,a)=>({emails:e.emails+(a.email?1:0),phones:e.phones+(a.phone?1:0)})),{emails:0,phones:0}):{emails:0,phones:0}),[n?.recipients]);return{estimatedMatches:n,estimatedMatchesStats:t}})(r??void 0),{state:{selectedChannels:u}}=a.useContext(dre),{validateStep:c}=wAe(),[d,m]=a.useState([]),{data:h}=Sre(),[p,g]=a.useState(!1),{channelSenders:v}=fre(),{channelAccounts:f}=pre(),{updateCommunicationGroup:y}=$e(),k=a.useRef(!1),[b,S]=a.useState(bAe.SelectAudience);if(a.useEffect((()=>{if(null!==r&&null!==o){const e=ale({channelSenders:v?.results??[],channelAccounts:f?.results??[],smsApplication:h});m((({automation:e,communicationGroup:a,selectedChannels:t,smsChannelSenders:i})=>e?[{id:"audience",title:"Audience",step:1,isValid:()=>e.includeSegmentIds.length>0,content:n.jsx(vue,{content:n.jsx(yAe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===sa.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},{id:"senders",title:"Channel Senders",step:2,isValid:()=>0!==t.length,content:n.jsx(vue,{content:n.jsx(kAe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===sa.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},...t.includes("email")?[{id:"edit-email-content",title:"Edit Email Content",step:3,isValid:()=>{const n=e.actionData?.find((e=>"send_communication"===e.actionType));return!!n&&!!a.emailChannelSenderId&&!(!a.emailHtmlBody||!a.emailSubject)},content:n.jsx(vue,{content:n.jsx(Cme,{})},"audience"),footerConfig:{backText:"",nextText:"",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],...t.includes("sms")?[{id:"edit-sms-content",title:"Edit SMS Content",step:4,isValid:()=>{const n=e.actionData?.find((e=>"send_communication"===e.actionType));return!!(n&&n.actionMetadata.communicationGroupId&&a.smsChannelSenderId&&a.smsMessageBody)},content:n.jsx(vue,{content:n.jsx($ve,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],{id:"schedule",title:"Schedule",step:5,isValid:()=>Boolean(e.triggerMetadata?.triggerType===sa.ONE_TIME&&e.triggerMetadata?.scheduledAt&&("now"===e.triggerMetadata.scheduledAt||"now"!==e.triggerMetadata.scheduledAt&&new Date(e.triggerMetadata.scheduledAt)>new Date)&&e.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),content:n.jsx(vue,{className:"flex-1",content:n.jsx(zSe,{})},"schedule"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}},{id:"send",title:"Send",step:6,isValid:()=>Boolean(e.triggerMetadata?.triggerType===sa.ONE_TIME&&e.triggerMetadata?.scheduledAt&&("now"===e.triggerMetadata.scheduledAt||"now"!==e.triggerMetadata.scheduledAt&&new Date(e.triggerMetadata.scheduledAt)>new Date(Date.now()+18e4))&&e.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),content:n.jsx(vue,{className:"flex-1",content:n.jsx(Rye,{})},"send"),footerConfig:{backText:"Back",nextText:e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&"now"===e.triggerMetadata.scheduledAt?"Send Now":"Schedule",hideBack:!1,backDisabled:!1,getInfoTooltipTitle:()=>{const e=i.find((e=>e.channelSender.id===a.smsChannelSenderId));if(e&&null!==e.smsApplication&&e.smsApplication?.status!==ele.APPROVED)return"You cannot send this yet if you have selected a text channel and don't have an approved SMS application. Please save as draft and try again later."},nextDisabled:()=>{const e=i.find((e=>e.channelSender.id===a.smsChannelSenderId));return!(!a.smsChannelSenderId||e&&(null===e.smsApplication||e.smsApplication?.status===ele.APPROVED))||null===a.smsChannelSenderId&&null===a.emailChannelSenderId}}}]:[])({automation:r,communicationGroup:o,selectedChannels:u,smsChannelSenders:e}))}}),[r,o,t,u,v?.results,f?.results,h]),a.useEffect((()=>{t&&!k.current&&t().then((e=>{o?.id&&(k.current=!0,y({groupId:o?.id,params:{extraMergeFields:e}}))}))}),[t,o,y]),!(r&&b&&o&&d.length))return n.jsx("div",{className:"flex-1 flex flex-col @container justify-center items-center h-[500px]",children:n.jsx(v5,{text:[`Fetching ${_h("engage:broadcast")} data`,"Finishing up"]})});const A=async()=>{const{canMove:a,errorMessage:n,warningMessage:t}=await c(b);a?(t&&Ie({title:t,variant:"warning"}),b===bAe.PreviewAndSend?await(async()=>{if(null===o.emailChannelSenderId&&null===o.smsChannelSenderId)return void Ie({title:"Oops!",description:"Please select an email sender or sms sender",variant:"destructive"});const a=ale({channelSenders:v?.results??[],channelAccounts:f?.results??[],smsApplication:h});if(o.smsChannelSenderId){const e=a.find((e=>e.channelSender.id===o.smsChannelSenderId));if(e?.smsApplication?.application&&e?.smsApplication.status!==ele.APPROVED)return void Ie({title:"Oops!",description:"You cant schedule a communication with a pending sms application. Please save as a draft and re-try once the application is approved."})}if(i)try{const a=await i({estimatedEmailRecipients:l?.emails||0,estimatedSmsRecipients:l?.phones||0});!0===a?s({status:da.ACTIVE},{onSuccess:()=>{Ie({title:`${_h("engage:broadcast")} scheduled!`}),e()},onError:()=>{Ie({title:"Oops!",description:"Please contact your administrator",variant:"destructive"})}}):Ie({title:"Oops!",description:a,variant:"destructive"})}catch(n){Ie({title:"Oops!",description:"An error occurred while checking scheduling conditions",variant:"destructive"})}else s({status:da.ACTIVE}),Ie({title:`${_h("engage:broadcast")} scheduled!`}),e()})():S(b===bAe.SelectSenders&&1===u.length&&"sms"===u[0]||b===bAe.EditEmailContent&&1===u.length&&"email"===u[0]?b+2:b+1)):Ie({title:"Oops!",description:n,variant:"destructive"})},w=()=>{b>bAe.SelectAudience&&S(b===bAe.EditSmsContent&&1===u.length&&"sms"===u[0]?b-2:b-1)},C=()=>{e()};return n.jsxs("div",{className:"flex-1 flex flex-col @container h-full min-h-0",children:[n.jsxs("header",{className:"w-full flex items-center gap-4 h-16 px-6",children:[n.jsx("h1",{className:"text-xl font-bold leading-none",children:r.name}),n.jsx("div",{className:"flex items-center gap-4",children:n.jsx(B5,{variant:rue(r.status),children:rre({status:r.status,automationType:r.triggerType})})})]}),n.jsxs("main",{className:"flex gap-4 flex-1 min-h-0",children:[n.jsx("div",{className:"hidden @[1000px]:block",children:n.jsx("nav",{className:"space-y-0 w-50 self-start pr-6 pl-8 pt-4 ",children:d.map((e=>n.jsx("div",{className:`\n rounded-md transition-colors\n ${e.step===b?"bg-[var(--reach-secondary)] text-[var(--reach-primary-foreground)] font-medium":e.step<b?"text-muted-foreground hover:bg-muted":"text-muted-foreground/60"}\n `,children:n.jsx(V5,{label:e.title,isActive:e.step===b,isCompleted:e.isValid(),onClick:async()=>{if(!p)if(e.step>b){const{canMove:a,errorMessage:n,warningMessages:t}=await(async e=>{if(e<=b)return{canMove:!0,errorMessage:null};g(!0);try{const a=[];for(let n=b;n<e;n++){const{canMove:e,errorMessage:t,warningMessage:i}=await c(n);if(!e)return{canMove:e,errorMessage:t};i&&a.push(i)}return{canMove:!0,errorMessage:null,warningMessages:a}}finally{g(!1)}})(e.step);if(a){if(t&&t.length>0)for(const e of t)Ie({title:e,variant:"warning"});S(e.step)}else n&&Ie({title:"Cannot navigate to this step",description:n,variant:"destructive"})}else S(e.step)}})},e.step)))})}),n.jsx("section",{className:"flex-1 mr-6 w-full relative rounded-xl bg-gray-100 ml-6 @[1000px]:ml-0",children:n.jsx("div",{className:" overflow-y-auto top-0 left-0 right-0 bottom-0 flex-1 h-full flex-col flex",children:n.jsx(eY,{children:n.jsx(f5,{className:"pt-0 h-full",children:d.find((e=>e.step===b))?.content},b)})})})]}),n.jsx("footer",{className:"w-full flex justify-end shadow-md z-10 items-center h-16 px-6",children:n.jsx(gue,{handleSkipAndSaveAsDraft:C,handleBack:w,handleNext:A,hideBack:d.find((e=>e.step===b))?.footerConfig.hideBack??!1,backText:d.find((e=>e.step===b))?.footerConfig.backText??"Back",nextText:d.find((e=>e.step===b))?.footerConfig.nextText??"Next",backDisabled:d.find((e=>e.step===b))?.footerConfig.backDisabled??!1,nextDisabled:d.find((e=>e.step===b))?.footerConfig.nextDisabled()??!1,getInfoTooltipTitle:d.find((e=>e.step===b))?.footerConfig.getInfoTooltipTitle??void 0})})]})},MAe=({children:e,actionId:t})=>{const{setActionId:i}=a.useContext(Q4);return a.useEffect((()=>{i(t)}),[t,i]),n.jsx("div",{children:n.jsx(mre,{children:e})})},TAe=()=>n.jsxs("div",{children:[n.jsx("div",{className:E5,children:n.jsx(w5.OneTimeBroadcast,{})}),n.jsx("h3",{className:x5,children:_h("engage:broadcast")}),n.jsx("p",{className:N5,children:"Send a single message to your current list, like announcing a sale or newsletter."})]}),EAe=()=>n.jsxs("div",{children:[n.jsx("div",{className:_5,children:"Coming Soon"}),n.jsx("div",{className:E5,children:n.jsx(w5.RealtimeActivity,{})}),n.jsx("h3",{className:x5,children:"Realtime Activity"}),n.jsx("p",{className:N5,children:"Responds to immediate actions your contacts take, like abandoned carts, form submissions, or appointment bookings."})]}),xAe=({selectedType:e,setAutomationName:a,automationName:t,setAutomationDescription:i,automationDescription:r})=>n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 max-w-lg mx-auto",children:[n.jsxs("h2",{className:"text-2xl font-semibold mb-8 text-center",children:["Name Your"," ",_h(e===sa.ONE_TIME?"engage:broadcast":"engage:trigger_based")]}),n.jsxs("div",{className:"w-full space-y-6",children:[n.jsx("div",{className:"bg-gray-50 p-6 rounded-xl items-center justify-center text-center",children:(()=>{switch(e){case sa.ONE_TIME:return n.jsx(TAe,{});case sa.TRIGGER_BASED:return n.jsx(EAe,{});default:throw ire(e,sa)}})()}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[n.jsx("label",{htmlFor:"automationName",className:"block text-sm font-medium text-gray-900",children:"Name"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Only visible to your team"})]}),n.jsx(qae,{id:"automationName",type:"text",value:t,onChange:e=>a(e.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500 shadow-sm",placeholder:"e.g. April Newsletter Campaign",autoFocus:!0})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[n.jsx("label",{htmlFor:"automationDescription",className:"block text-sm font-medium text-gray-900",children:"Description"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Optional"})]}),n.jsx(Uve,{id:"automationDescription",value:r,onChange:e=>i(e.target.value),className:"w-full min-h-[80px] resize-none",placeholder:`Add any helpful context for your team. If left blank, we'll generate one for you when you start the ${_h("engage:broadcast").toLowerCase()}`})]})]})]})]}),NAe=({onClose:e,automationType:t,currentStep:i,setCurrentStep:r,getExtraMergeFields:o,onBeforeSchedule:s})=>{const{createAutomation:l,isCreating:u}=na(),[c,m]=a.useState(!1),[h,p]=a.useState(void 0),[g,v]=a.useState(void 0),[f,y]=a.useState(!1),[k,b]=a.useState(t?{name:void 0,description:void 0,type:t}:{name:void 0,description:void 0,type:void 0}),S=void 0!==k.name&&void 0!==k.type&&""!==k.name;a.useEffect((()=>{if(k.type&&!k.name&&!f){const e=new Date,a=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),n=e.toLocaleDateString([],{month:"long",day:"numeric"}),t=`${_h("engage:broadcast")} ${n} ${a}`,i="";b((e=>({...e,name:t,description:i}))),y(!0)}}),[k,f]);if(u||c)return n.jsx("div",{className:T5,children:n.jsx(v5,{text:[`Creating ${_h("engage:broadcast")}`,"Finishing up"]})});return n.jsxs("div",{className:P$("relative overflow-y-auto h-full p-8",i===b5.OneTimeWizard?"max-h-[90vh]":"h-full"),children:[n.jsx(eY,{mode:"wait",children:n.jsx(f5,{className:"h-full",children:(()=>{switch(i){case b5.ChooseAutomationType:return n.jsx(P5,{onNext:e=>{b({...k,type:e}),r(b5.SetAutomationName)}});case b5.SetAutomationName:return k.type?n.jsx(xAe,{selectedType:k.type,setAutomationName:e=>{b({...k,name:e})},automationName:k.name??"",setAutomationDescription:e=>{b({...k,description:e})},automationDescription:k.description??""}):null;case b5.OneTimeWizard:return h&&g?n.jsx(p5,{automationId:h,children:n.jsx(MAe,{actionId:g,children:n.jsx(CAe,{onFinish:()=>{e?.(h)},getExtraMergeFields:o,onBeforeSchedule:s})})}):null;default:throw U4(i,b5)}})()},i)}),i!==b5.OneTimeWizard&&n.jsx("div",{className:"pt-2",children:n.jsx(S5,{onClose:e,currentStep:i,setCurrentStep:r,isDisabled:!S,createAutomation:async()=>{if(!S||!k.name||!k.type)return;m(!0);l({name:k.name,type:k.type,description:k.description},{onSuccess:async a=>{if(a.id){const n=await(async e=>(await Pe(`${d}`,{method:"POST",body:JSON.stringify(e)})).data)({}),i=J4().toString();await je(a.id,{action:[{actionType:"send_communication",actionMetadata:{actionType:"send_communication",communicationGroupId:n.id,currentActionId:i}}]}),p(a.id),await We({automationId:a.id,actionId:i}),t===sa.ONE_TIME?(r(b5.OneTimeWizard),v(i),m(!1)):e?.(a.id)}else e?.("error")},onError:()=>{e?.("error")},onSettled:()=>{b({name:void 0,description:void 0,type:void 0})}})},disableBackButton:void 0!==t})})]})};function _Ae({open:e,setOpen:t,onClose:i,automationType:r,getExtraMergeFields:o,replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c}){const[d,m]=a.useState(r?b5.SetAutomationName:b5.ChooseAutomationType);return a.useEffect((()=>{e&&m(r?b5.SetAutomationName:b5.ChooseAutomationType)}),[e,r]),n.jsx(cq,{children:n.jsx(dq,{replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c,children:n.jsx(L$,{open:e,onOpenChange:t,children:n.jsxs(z$,{hideCloseButton:d===b5.OneTimeWizard,className:`flex max-h-[86vh] ${d===b5.OneTimeWizard?"max-w-[90vw]":"max-w-4xl"} flex-col gap-0 overflow-visible p-0`,children:[n.jsx(D$,{children:n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs(lq,{children:[n.jsx(O$,{className:"text-3xl font-normal",children:"Create Automation"}),n.jsx(H$,{children:"Create a new automation to send messages to your customers."})]})})}),n.jsx(NAe,{onClose:e=>{i?.(e),t(!1)},automationType:r,currentStep:d,setCurrentStep:m,getExtraMergeFields:o})]})})})})}const PAe=({tabs:e,activeTab:t,onTabChange:i,tabsLocation:r="left",secondaryTabs:o=!1})=>{const s=a.useRef([]),[l,u]=a.useState({width:0,left:0});a.useEffect((()=>{const a=s.current[e.findIndex((e=>e.id===t))];a&&u({width:a.offsetWidth,left:a.offsetLeft})}),[t,e]);const c=e.find((e=>e.id===t));return n.jsxs("div",{className:"flex flex-col gap-4 w-full overflow-x-hidden h-full",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{className:"relative flex items-center gap-8 "+("left"===r?"w-full justify-start":"w-full justify-center"),children:[n.jsx("div",{className:"absolute bottom-0 h-[1px] rounded-full transition-all duration-300 ease-out\n bg-gradient-to-r from-primary to-primary/90\n shadow-[0_0_8px_rgba(var(--primary-rgb),0.3)]",style:{width:`${l.width}px`,left:`${l.left}px`}}),e.map(((e,a)=>n.jsx("button",{ref:e=>s.current[a]=e,onClick:()=>i(e.id),className:P$("relative px-7 py-3 transition-all duration-200 text-lg",t!==e.id&&"text-muted-foreground",o&&"text-sm"),children:e.label},e.id)))]})}),n.jsx("div",{className:"relative overflow-hidden flex-grow min-h-0",children:n.jsx("div",{className:"relative h-full",children:c?c.content:null})})]})},LAe=e=>{if(!e)return"$0.00";const a="string"==typeof e?e.replace(/,/g,""):e,n=Number(a);return Number.isNaN(n)?"$0.00":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(n)},jAe="reach-styles-module__header___-izE2",BAe="reach-styles-module__title___n1hA9",RAe="reach-styles-module__description___EvXM-",zAe="reach-styles-module__content___okv68",DAe="reach-styles-module__footer___YA4U4",KAe=Sc("reach-styles-module__base___zJcoE",{variants:{variant:{default:"reach-styles-module__default___88Q0d",destructive:"reach-styles-module__destructive___5EWhN",outline:"reach-styles-module__outline___gj9sC",secondary:"reach-styles-module__secondary___cN5Wj"}},defaultVariants:{variant:"default"}}),OAe=r.forwardRef((({className:e,variant:a,...t},i)=>n.jsx("div",{ref:i,className:vm(KAe({variant:a}),e),...t})));OAe.displayName="Card";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(jAe,e),...a}))).displayName="CardHeader";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(BAe,e),...a}))).displayName="CardTitle";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(RAe,e),...a}))).displayName="CardDescription";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(zAe,e),...a}))).displayName="CardContent";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(DAe,e),...a}))).displayName="CardFooter";const HAe=({Icon:e,title:a,value:t,tooltipText:i,change:r})=>n.jsxs(OAe,{className:"relative flex flex-col justify-between min-h-[130px] transition-all duration-300 hover:shadow-md p-4",children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsx("div",{className:"rounded-lg p-2 bg-primary/10 flex items-center justify-center",children:n.jsx(e,{className:"w-5 h-5 text-primary"})}),n.jsx("div",{className:"absolute top-3 right-3",children:n.jsx(pue,{title:i})})]}),n.jsxs("div",{className:"mt-4",children:[n.jsx("div",{className:"text-2xl font-bold leading-tight text-primary",children:t}),n.jsx(Lye,{children:a})]}),r&&n.jsx("div",{className:"absolute bottom-3 right-3",children:n.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full bg-green-100 text-green-600 text-xs font-semibold",children:r})})]}),IAe=({activeTab:e,automation:a})=>{if(!a)return null;const t={sales:[{Icon:w5.SalesAmount,title:"Order Amount",value:LAe(a.derivedRevenue),tooltipText:"Total derived revenue from this campaign"}]};return n.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:t[e].map(((e,a)=>n.jsx(HAe,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},GAe=({activeTab:e,statistics:a})=>{const t={email:[{Icon:w5.MessagesSent,title:"Emails Sent",value:a.email.numberSent,tooltipText:"Total number of emails that were successfully sent in this campaign"},{Icon:w5.OpenRate,title:"Open Rate",value:`${(100*a.email.openPercentage).toFixed(2)}%`,tooltipText:"Percentage of recipients who opened the email out of total emails delivered"},{Icon:w5.TotalBounceRate,title:"Total Bounce Rate",value:`${(100*(a.email.softBounceRate+a.email.hardBounceRate)).toFixed(2)}%`,tooltipText:"Percentage of emails that were not delivered due to permanent (hard) or temporary (soft) delivery failures"},{Icon:w5.LinksClicked,title:"Links Clicked",value:a.email.linksClicked,tooltipText:"Total number of times recipients clicked on links within the email"},{Icon:w5.SpamComplies,title:"Spam Complaints",value:`${(100*a.email.spamComplaintRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who marked this email as spam"},{Icon:w5.UnsubscribeRate,title:"Unsubscribe Rate",value:`${(100*a.email.unsubscribedRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who unsubscribed after receiving this email"}],sms:[{Icon:w5.MessagesSent,title:"SMS Sent",value:a.sms.numberSent,tooltipText:"Total number of SMS messages that were successfully sent in this campaign"}]};return n.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:t[e].map(((e,a)=>n.jsx(HAe,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},FAe=({automationId:e,includeSales:t=!1,includeSms:i=!1,automation:r})=>{const[o,s]=a.useState("email"),{statistics:l,isLoading:u}=ia(e);if(u||!l)return n.jsx("div",{className:"bg-white rounded-2xl w-full p-6 space-y-4 relative h-[14.05rem]",children:n.jsx(v5,{text:[`Fetching ${_h("engage:insight",{count:2})}`,"Finishing up"]})});const c=[{id:"email",label:`Email ${_h("engage:insight",{count:2})}`,content:n.jsx(GAe,{activeTab:"email",statistics:l})},...i?[{id:"sms",label:`SMS ${_h("engage:insight",{count:2})}`,content:n.jsx(GAe,{activeTab:"sms",statistics:l})}]:[],...t?[{id:"sales",label:`Sales ${_h("engage:insight",{count:2})}`,content:n.jsx(IAe,{activeTab:"sales",automation:r})}]:[]];return n.jsx(PAe,{tabs:c,activeTab:o,onTabChange:e=>s(e),tabsLocation:"left"})},VAe={all:["website"],content:()=>[...VAe.all,"content"],analyze:()=>[...VAe.all,"analyze"],brandSettings:()=>[...VAe.all,"brand-settings"]},JAe=async()=>(await Pe("/web-presence/brand-settings",{method:"POST"})).data,UAe=({isLoading:e,brandSettings:t,onComplete:i})=>{const[r,o]=a.useState(0),s=[{text:"Analyzing your brand palette",icon:nd},{text:"Extracting your visual identity",icon:Fc},{text:"Discovering your brand personality",icon:Jc},{text:"Crafting your email style",icon:Yc},{text:"Finalizing your brand profile",icon:Dc}];a.useEffect((()=>{if(!e)return;const a=setInterval((()=>{o((e=>{const n=e+1;return n>=s.length?(clearInterval(a),setTimeout((()=>{i()}),1500),e):n}))}),2500);return()=>clearInterval(a)}),[e,i,s.length]);return n.jsx(K4.div,{className:"flex flex-col items-center justify-center h-full w-full bg-background p-6",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6},children:n.jsxs("div",{className:"flex flex-col items-center gap-8 max-w-2xl w-full",children:[n.jsx(K4.div,t?.logoUrl?{className:"w-24 h-24 sm:w-32 sm:h-32 flex items-center justify-center rounded-xl overflow-hidden bg-card shadow-md border",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:n.jsx("img",{src:t.logoUrl,alt:"Brand Logo",className:"max-w-full max-h-full object-contain"})}:{className:"w-24 h-24 sm:w-32 sm:h-32 rounded-xl flex items-center justify-center shadow-md border bg-primary",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:t?.brandName?n.jsx("span",{className:"text-4xl sm:text-5xl font-bold text-white",children:t.brandName.charAt(0)}):n.jsx(pd,{className:"w-12 h-12 sm:w-16 sm:h-16 text-white"})}),n.jsx(K4.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-xl font-medium text-center text-foreground",children:s[r].text},`loading-${r}`),n.jsx("div",{className:"flex items-center justify-center space-x-8 sm:space-x-12",children:s.map(((e,a)=>{const t=a<=r,i=a===r;return n.jsxs(K4.div,{className:"relative flex items-center justify-center w-12 h-12 rounded-full border-2 "+(t?"bg-card shadow-md border-primary":"bg-muted border-muted-foreground/30"),initial:{scale:.8,opacity:.5},animate:{scale:i?1.1:1,opacity:t?1:.5},transition:{duration:.3},children:[n.jsx(e.icon,{className:"w-5 h-5 "+(t?"text-primary":"text-muted-foreground")}),i&&n.jsx(K4.div,{className:"absolute inset-0 rounded-full border-2 border-primary",initial:{scale:1,opacity:.8},animate:{scale:2.5,opacity:0},transition:{duration:3,repeat:1/0,ease:"easeOut"}})]},`step-${a}`)}))}),n.jsx(K4.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8,duration:.6},className:"w-full",children:n.jsx("div",{className:"h-[140px] w-full max-w-lg mx-auto p-5 bg-gradient-to-br from-card/70 to-card/40 backdrop-blur-md rounded-2xl border border-border/60 shadow-lg",children:n.jsxs("div",{className:"h-full flex flex-col justify-center",children:[0===r&&n.jsxs("div",{className:"space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80 text-center",children:"Extracted Color Palette"}),n.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[t?.primaryColor,...t?.secondaryColors||[]]?.slice(0,4).map(((e,a)=>n.jsx("div",{className:"flex flex-col items-center gap-1",children:n.jsx("div",{className:"w-10 h-10 rounded-xl border-2 border-white/50 shadow-md",style:{backgroundColor:e}})},a)))}),n.jsx("div",{className:"text-center text-xs text-muted-foreground",children:"Brand colors identified"})]}),1===r&&n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Identity"}),t?.brandName?n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xl font-bold",children:t.brandName}),t.brandTagline&&n.jsxs("div",{className:"text-sm text-muted-foreground italic px-4",children:['"',t.brandTagline,'"']}),n.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Visual identity extracted"})]}):n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Extracting brand elements..."})]}),2===r&&n.jsxs("div",{className:"text-center space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Personality"}),t?.brandPersonality?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-center gap-4",children:[t.brandPersonality.tone&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Tone"}),n.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:t.brandPersonality.tone})]}),t.brandPersonality.voice&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Voice"}),n.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:t.brandPersonality.voice})]})]}),t.brandPersonality.values&&t.brandPersonality.values.length>0&&n.jsx("div",{className:"flex justify-center gap-1 flex-wrap",children:t.brandPersonality.values.slice(0,3).map(((e,a)=>n.jsx("span",{className:"px-2 py-1 text-xs font-medium rounded-full",children:e},a)))})]}):n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand tone and voice..."})]}),3===r&&n.jsxs("div",{className:"text-center space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Email Template Preview"}),n.jsxs("div",{className:"bg-background/60 rounded-lg p-3 border border-border/30",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx("div",{className:"w-4 h-4 rounded"}),n.jsx("div",{className:"text-xs font-medium text-foreground",children:t?.brandName||"Your Brand"})]}),n.jsxs("div",{className:"text-xs text-muted-foreground text-left",children:["Email styling applied with your brand colors",t?.brandPersonality?.tone&&`, ${t.brandPersonality.tone} tone`,", and visual identity"]})]})]}),4===r&&n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Kit Complete"}),n.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Identity"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.brandName?"✓":"—"})]}),n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Colors"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.primaryColor?"✓":"—"})]}),n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Personality"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.brandPersonality?.tone?"✓":"—"})]})]})]}),(0===r&&!t?.primaryColor&&!t?.colorPalette||1===r&&!t?.brandName||2===r&&!t?.brandPersonality)&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand data..."}),n.jsx("div",{className:"flex justify-center gap-1 mt-2",children:[...Array(3)].map(((e,a)=>n.jsx(K4.div,{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/50",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:1,repeat:1/0,delay:.2*a}},a)))})]})]})})},`content-${r}`)]})})},WAe=({setAutoParse:e,onBrandSettingsGenerated:t,onForceRefresh:i})=>{const{data:r,updateWebsite:o,isUpdatingWebsite:s,updateBrandSettings:l}=kpe(),u=ke({mutationFn:JAe,mutationKey:VAe.brandSettings()}),[c,d]=a.useState(r?.website||""),[m,h]=a.useState(!1),[p,g]=a.useState(null),[v,f]=a.useState(!1),[y,k]=a.useState(!1),b=()=>{e(!1)};return y&&p?n.jsx(K4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 h-full",children:n.jsx(ZAe,{initialBrandSettings:p,onSave:()=>{p&&(l({logoBase64:p.logo_base64,primaryColor:p.primaryColor,secondaryColors:p.secondaryColors,brandTagline:p.brandTagline,brandName:p.brandName,brandPersonality:p.brandPersonality,colorPalette:p.colorPalette}),i&&i(),Ie({title:"Brand settings saved successfully 🚀",description:"Your brand identity has been updated."}),e(!1))},onBack:b,showAutoParseButton:!1})},"results"):n.jsxs("div",{className:"w-full h-full flex flex-col bg-white rounded-lg overflow-hidden",children:[n.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:n.jsxs(eY,{mode:"wait",children:[!v&&!y&&n.jsx(K4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col h-full",children:n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 space-y-8",children:[n.jsxs("div",{className:"space-y-2 w-full max-w-md",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block text-center",children:"Your Website URL"}),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 items-center",children:[n.jsx(qae,{type:"url",value:c,onChange:e=>d(e.target.value),placeholder:"https://example.com",className:"flex-1",disabled:!m}),n.jsx(eY,{mode:"wait",children:m?n.jsxs(K4.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex gap-2",children:[n.jsx(k5,{variant:"outline",size:"sm",onClick:()=>{h(!1),d(r?.website||"")},className:"w-full sm:w-auto",children:"Cancel"}),n.jsx(k5,{size:"sm",onClick:async()=>{try{o(c),h(!1),Ie({title:"Website URL updated successfully 🎉",description:"Your website URL has been saved."})}catch(e){Ie({title:"Error updating website URL",description:"Please try again.",variant:"destructive"})}},disabled:s||!c,className:"w-full sm:w-auto",children:s?n.jsx(v5,{}):"Save Changes"})]},"save"):n.jsx(K4.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},children:n.jsx(k5,{variant:"outline",size:"sm",onClick:()=>h(!0),className:"w-full sm:w-auto",children:"Edit URL"})},"edit")})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full max-w-2xl",children:[n.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[n.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"What we'll analyze"}),n.jsxs("ul",{className:"text-sm text-gray-600 space-y-1",children:[n.jsx("li",{children:"• Your brand colors and color palette"}),n.jsx("li",{children:"• Your logo (if detectable)"}),n.jsx("li",{children:"• Your brand name and tagline"}),n.jsx("li",{children:"• Your brand's tone and personality"})]})]}),n.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[n.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"How it helps you"}),n.jsx("p",{className:"text-sm text-gray-600",children:"Our AI will automatically extract your brand assets to create consistently styled emails that match your website. This helps maintain brand recognition and professionalism in all your communications."})]})]}),n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},className:"text-sm text-muted-foreground text-center max-w-md",children:"We'll use AI to analyze your website and extract your brand elements to create perfectly matched email templates."})]})},"url-confirmation"),v&&p&&n.jsx(K4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 h-full",children:n.jsx(UAe,{isLoading:v,brandSettings:p,onComplete:()=>{f(!1),k(!0),Ie({title:"Brand settings generated successfully!",description:"Your brand identity has been analyzed."})}})},"analyzing"),v&&!p&&n.jsx(K4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col items-center justify-center h-full",children:n.jsxs(K4.div,{className:"flex flex-col items-center gap-8",initial:{backgroundPosition:"0% 0%"},animate:{backgroundPosition:"100% 100%"},transition:{duration:5,repeat:1/0,repeatType:"reverse"},children:[n.jsxs(K4.div,{className:"relative w-24 h-24 flex items-center justify-center",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:[n.jsx(ud,{className:"w-12 h-12 text-primary drop-shadow-md"}),n.jsx(K4.div,{className:"absolute inset-0 rounded-full border-2",style:{borderColor:"var(--primary)"},initial:{scale:1,opacity:.8},animate:{scale:2.5,opacity:0},transition:{duration:3,repeat:1/0,ease:"easeOut"}})]}),n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:"Analyzing your website"}),n.jsx(eY,{mode:"wait",children:n.jsx(K4.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-gray-600 max-w-md text-center px-4",children:"Generating your brand's unique visual identity and personality"},"loading-message")})]})]})},"pre-analyzing")]})}),!v&&!y&&n.jsxs(K$,{className:"p-4",children:[n.jsx(k5,{variant:"outline",onClick:b,className:"gap-1",children:"Go Back"}),n.jsxs(k5,{onClick:async()=>{try{f(!0);const e=await u.mutateAsync();g(e),t&&t(e)}catch(e){f(!1),g(null),Ie({title:"Error generating brand settings",description:"Please try again.",variant:"destructive"})}},disabled:!c||u.isPending,className:"gap-1",children:[n.jsx(pd,{className:"h-4 w-4 text-amber-500"}),u.isPending?n.jsx(v5,{}):"Analyze Website"]})]})]})},qAe=["#a91919","#2563eb","#16a34a","#f59e0b","#6d28d9"],ZAe=({initialBrandSettings:e,onSave:t,onBack:i,showAutoParseButton:r=!0})=>{const{data:o,isLoading:s,updateBrandSettings:l,isUpdatingBrandSettings:u}=kpe(),[c,d]=a.useState({}),[m,h]=a.useState(!1),[p,g]=a.useState({}),[v,f]=a.useState(""),[y,k]=a.useState(""),[b,S]=a.useState("#000000"),[A,w]=a.useState(Date.now()),[C,M]=a.useState(!1),[T,E]=a.useState(null),[x,N]=a.useState({identity:!0,colors:!0,personality:!0}),_=a.useRef(null),{toast:P}=Ge();a.useEffect((()=>{if(e)return d({brandName:e.brandName,brandTagline:e.brandTagline,logoUrl:e.logoUrl,primaryColor:e.primaryColor||"#000000",secondaryColors:e.secondaryColors||[],brandPersonality:{tone:e.brandPersonality?.tone,voice:e.brandPersonality?.voice,values:e.brandPersonality?.values||[]}}),void w(Date.now());o?.branding&&(d({brandName:o.branding.brandName||o.name,brandTagline:o.branding.brandTagline||"",logoUrl:o.branding.logoUrl||"",primaryColor:o.branding.primaryColor||"#000000",secondaryColors:o.branding.secondaryColors||[],brandPersonality:{tone:o.branding.brandPersonality?.tone,voice:o.branding.brandPersonality?.voice,values:o.branding.brandPersonality?.values||[]}}),w(Date.now()))}),[o,e]);const L=e=>{N((a=>({...a,[e]:!a[e]})))},j=e=>{g((a=>{const n={...a,[e]:!a[e]};return n[e]&&("brandName"===e?f(c.brandName||""):"brandTagline"===e?f(c.brandTagline||""):"primaryColor"===e?f(c.primaryColor||"#000000"):"tone"===e?f(c.brandPersonality?.tone||""):"voice"===e&&f(c.brandPersonality?.voice||"")),n}))},B=e=>{"brandName"===e?d((e=>({...e,brandName:v}))):"brandTagline"===e?d((e=>({...e,brandTagline:v}))):"primaryColor"===e?d((e=>({...e,primaryColor:v}))):"tone"===e?d((e=>({...e,brandPersonality:{...e.brandPersonality,tone:v||void 0}}))):"voice"===e&&d((e=>({...e,brandPersonality:{...e.brandPersonality,voice:v||void 0}}))),j(e)},R=e=>{j(e)},z=e=>{d((a=>({...a,primaryColor:e})))},D=()=>{y.trim()&&(d((e=>{const a=e.brandPersonality?.values||[];return{...e,brandPersonality:{...e.brandPersonality,values:[...a,y.trim()]}}})),k(""))};return s?n.jsx("div",{className:"flex justify-center items-center h-full min-h-[500px] w-full bg-white rounded-lg shadow-sm",children:n.jsx(v5,{})}):m?n.jsx(WAe,{setAutoParse:h,onForceRefresh:()=>w(Date.now())}):n.jsxs("div",{className:"w-full h-full flex flex-col bg-white rounded-lg overflow-hidden gap-4 pt-16",children:[n.jsxs("div",{className:"flex-1 overflow-y-auto space-y-4 px-6 pt-2",children:[n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("identity"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Identity"})]}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(x.identity?Bc:Pc,{className:"h-4 w-4"})})]}),x.identity&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Brand Name"}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("brandName"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.brandName?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{value:v,onChange:e=>f(e.target.value),className:"flex-1",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>R("brandName"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>B("brandName"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border border-gray-200 text-sm font-medium",children:c.brandName})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Brand Tagline"}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("brandTagline"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.brandTagline?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{value:v,onChange:e=>f(e.target.value),className:"flex-1",autoFocus:!0,placeholder:"Your brand's tagline"}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>R("brandTagline"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>B("brandTagline"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border border-gray-200 text-sm italic",children:c.brandTagline||"No tagline set"})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-3",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Logo"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Square image, 128x128px, PNG recommended"})]})}),n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsxs("div",{className:"relative group",children:[n.jsx("div",{className:"w-24 h-24 rounded-lg border-2 border-dashed border-gray-200 flex items-center justify-center bg-gray-50 overflow-hidden",children:c.logoUrl?n.jsx("img",{src:c?.logoUrl,alt:c.brandName||"Brand logo",className:"w-full h-full object-contain"},A):n.jsx(Uc,{className:"h-10 w-10 text-gray-300"})}),n.jsxs("div",{className:"absolute inset-0 bg-black bg-opacity-40 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:[n.jsx("input",{type:"file",ref:_,onChange:e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{const n=e.result.split(",")[1];E(n);const t=URL.createObjectURL(a);d((e=>({...e,logoUrl:t}))),w(Date.now()),l({logoBase64:n})},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),n.jsxs(k5,{variant:"ghost",size:"sm",onClick:()=>{_.current?.click()},className:"text-white hover:text-white hover:bg-black hover:bg-opacity-20",children:[n.jsx(yd,{className:"h-4 w-4 mr-1"}),"Update"]})]})]}),c.logoUrl&&n.jsxs("div",{className:"flex-1 flex items-center gap-2 max-w-md bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[n.jsx("div",{className:"flex-1 truncate text-sm text-gray-600 font-mono",children:c.logoUrl}),n.jsxs(k5,{variant:"ghost",size:"sm",onClick:async()=>{if(c.logoUrl)try{await navigator.clipboard.writeText(c.logoUrl),M(!0),setTimeout((()=>M(!1)),1500),P({title:"Logo URL copied to clipboard"})}catch(QHe){try{const e=document.createElement("textarea");e.value=c.logoUrl,e.style.position="fixed",e.style.left="-9999px",document.body.appendChild(e),e.focus(),e.select();const a=document.execCommand("copy");if(document.body.removeChild(e),!a)throw new Error("Fallback copy command failed");M(!0),setTimeout((()=>M(!1)),1500),P({title:"Logo URL copied to clipboard"})}catch(e){P({title:"Failed to copy URL",description:"Could not copy the URL to clipboard. Please try again or copy manually.",variant:"destructive"})}}},className:"h-7 px-2 text-xs shrink-0",children:[C?n.jsx(_c,{className:"h-3.5 w-3.5 mr-1 text-green-500"}):n.jsx(Ic,{className:"h-3.5 w-3.5 mr-1"}),C?"Copied":"Copy"]})]})]})]})]})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("colors"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Colors"})]}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(x.colors?Bc:Pc,{className:"h-4 w-4"})})]}),x.colors&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Primary Color"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Your main brand color used throughout the interface"})]}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("primaryColor"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("div",{className:"w-14 h-14 rounded-lg shadow-md",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsxs("div",p.primaryColor?{className:"flex flex-1 gap-2 max-w-sm",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(nd,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),n.jsx(qae,{type:"text",value:v,onChange:e=>f(e.target.value),className:"pl-10 h-10 font-mono text-sm flex-1",placeholder:"#000000",maxLength:7,autoFocus:!0})]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("primaryColor"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>B("primaryColor"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}:{className:"flex-1 max-w-sm",children:[n.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[n.jsx(nd,{className:"h-4 w-4 text-gray-400"}),n.jsx("div",{className:"text-sm font-mono",children:c.primaryColor||"#000000"})]}),n.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[n.jsx(qae,{type:"color",value:c.primaryColor||"#000000",onChange:e=>z(e.target.value),className:"w-8 h-8 p-1 cursor-pointer rounded-md"}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:qAe.map(((e,a)=>n.jsx(k5,{variant:"ghost",size:"icon",className:"w-6 h-6 rounded-full border border-gray-200 "+(c.primaryColor===e?"ring-2 ring-gray-400 ring-offset-1":""),style:{backgroundColor:e},onClick:()=>z(e)},a)))})]})]})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Secondary Colors"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Additional colors that complement your primary brand color"})]})}),n.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[n.jsx("div",{className:"flex flex-wrap gap-3 mb-4",children:c.secondaryColors?.length?c.secondaryColors.map(((e,a)=>n.jsxs("div",{className:"group relative flex flex-col items-center",children:[n.jsx("div",{className:"w-12 h-12 rounded-lg shadow-sm border border-gray-200 mb-1 group-hover:ring-2 ring-gray-200",style:{backgroundColor:e}}),n.jsx("div",{className:"text-xs font-mono text-gray-600",children:e}),n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>{return a=e,void d((e=>{const n=e.secondaryColors||[];return{...e,secondaryColors:n.filter((e=>e!==a))}}));var a},className:"absolute -top-1 -right-1 w-5 h-5 bg-white rounded-full shadow border border-gray-200 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(Ad,{className:"w-3 h-3 text-gray-500"})})]},a))):n.jsx("div",{className:"text-sm text-gray-500 italic my-2",children:"No secondary colors set"})}),n.jsxs("div",{className:"flex items-end gap-3",children:[n.jsxs("div",{className:"flex-1 max-w-xs",children:[n.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Add color"}),n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx(qae,{type:"color",value:b,onChange:e=>S(e.target.value),className:"w-10 h-10 p-1 cursor-pointer rounded-md"}),n.jsx(qae,{type:"text",value:b,onChange:e=>S(e.target.value),className:"h-10 font-mono text-sm",placeholder:"#000000",maxLength:7})]})]}),n.jsxs(k5,{variant:"outline",onClick:()=>{b&&(d((e=>{const a=e.secondaryColors||[];return{...e,secondaryColors:[...a,b]}})),S("#000000"))},className:"h-10",children:[n.jsx(sd,{className:"h-4 w-4 mr-1"}),"Add Color"]})]})]})]})]})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("personality"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Personality"})]}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(x.personality?Bc:Pc,{className:"h-4 w-4"})})]}),x.personality&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Tone"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"The overall feeling and attitude your brand conveys"})]}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("tone"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.tone?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{type:"text",value:v,onChange:e=>f(e.target.value),className:"flex-1 h-10 rounded-md border border-gray-200 px-3 py-2",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("tone"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>B("tone"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"flex h-10 items-center px-4 bg-gray-50 rounded-lg border border-gray-200 text-sm",children:c.brandPersonality?.tone||"No tone set"})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Voice"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"How your brand expresses itself in communication"})]}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("voice"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.voice?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{type:"text",value:v,onChange:e=>f(e.target.value),className:"flex-1 h-10 rounded-md border border-gray-200 px-3 py-2",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("voice"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>B("voice"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"flex h-10 items-center px-4 bg-gray-50 rounded-lg border border-gray-200 text-sm",children:c.brandPersonality?.voice||"No voice set"})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Values"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Core principles and beliefs that drive your brand"})]})}),n.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[n.jsx("div",{className:"mb-4",children:n.jsx("div",c.brandPersonality?.values&&c.brandPersonality.values.length>0?{className:"flex flex-wrap gap-2",children:c.brandPersonality.values.map(((e,a)=>n.jsxs(B5,{variant:"outline",className:"px-3 py-1.5 border-2 hover:border-red-100 group transition-colors text-primary",style:{borderColor:`${c.primaryColor}30`||"#f3f4f6",backgroundColor:`${c.primaryColor}08`||"#f9fafb"},children:[e,n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>{return a=e,void d((e=>{const n=e.brandPersonality?.values||[];return{...e,brandPersonality:{...e.brandPersonality,values:n.filter((e=>e!==a))}}}));var a},className:"ml-1.5 w-4 h-4 flex items-center justify-center rounded-full bg-gray-200 hover:bg-red-100 hover:text-red-500 transition-colors",children:n.jsx(Ad,{className:"w-2.5 h-2.5"})})]},a)))}:{className:"text-sm text-gray-500 italic py-2",children:"No brand values set"})}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{placeholder:"Add a brand value",value:y,onChange:e=>k(e.target.value),className:"flex-1",onKeyDown:e=>"Enter"===e.key&&D()}),n.jsxs(k5,{variant:"outline",onClick:D,disabled:!y.trim(),children:[n.jsx(sd,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})]})]})]}),n.jsxs(K$,{className:"pb-4 px-6",children:[i?n.jsx(k5,{variant:"outline",className:"gap-1.5",onClick:i,children:"Go Back"}):r&&n.jsxs(k5,{variant:"outline",className:"gap-1.5",onClick:()=>{h(!0)},children:[n.jsx(pd,{className:"h-4 w-4 text-amber-500"}),"Auto Parse"]}),n.jsx(k5,{className:"px-4",onClick:async()=>{let e;T?e=T:c.logoUrl?.startsWith("data:image/png;base64,")?e=c.logoUrl.split(",")[1]:c.logoUrl?.startsWith("blob:")&&(e=void 0),l({brandName:c.brandName,brandTagline:c.brandTagline,logoBase64:e,primaryColor:c.primaryColor,secondaryColors:c.secondaryColors,brandPersonality:c.brandPersonality}),P({title:"Brand settings saved 🚀"}),t&&t(),E(null)},disabled:u,children:u?"Saving":"Save Changes"})]})]})},$Ae=Zse.object({channelSenderId:Zse.string().min(1,"Please select a channel sender"),replyTo:Zse.string().trim().min(1).email("Please enter a valid email address").or(Zse.literal("").transform((()=>null))).or(Zse.null()).optional(),fromName:Zse.string().trim().min(1).or(Zse.literal("").transform((()=>null))).or(Zse.null()).optional()}),YAe=()=>{const{channelSenders:e,isLoading:t}=fre(),{channelAccounts:i,isLoading:r}=pre(),{updateChannelSender:o,isUpdating:s}=yre(),{toast:l}=Ge(),u=Zhe({resolver:ape($Ae),defaultValues:{channelSenderId:"",replyTo:"",fromName:""}}),c=a.useMemo((()=>wme({channelSenders:e?.results??[],channelAccounts:i?.results??[]})),[e?.results,i?.results]);if(a.useEffect((()=>{if(c&&c.length>0&&!u.getValues("channelSenderId")){const e=c[0];u.setValue("channelSenderId",e.channelSenderId),u.setValue("replyTo",e.channelSender.channelSenderMetadata.emailReplyTo??""),u.setValue("fromName",e.channelSender.channelSenderMetadata.emailFromName??"")}}),[c,u]),t||void 0===e||r||void 0===i)return n.jsx("div",{className:"flex justify-center items-center h-full py-10",children:n.jsx(v5,{})});return n.jsxs("div",{className:"w-full max-w-4xl mx-auto mt-8",children:[n.jsxs("div",{className:"mb-6",children:[n.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-gray-900 mb-1",children:"Set up Your Email Channel"}),n.jsx("p",{className:"text-muted-foreground text-base",children:"Define your default sender name, email address, and reply-to to start sending emails with confidence."})]}),n.jsx(npe,{...u,children:n.jsxs("form",{onSubmit:u.handleSubmit((async e=>{const a=c.find((a=>a.channelSenderId===e.channelSenderId));a&&o({toUpdate:{channelSenderMetadata:{...a.channelSender.channelSenderMetadata,emailReplyTo:e.replyTo?e.replyTo:`noreply@${a.baseDomain??""}`,emailFromName:e.fromName?e.fromName:null}},id:a.channelSender.id},{onSuccess:()=>{l({title:"Email channel sender updated successfully!"})},onError:()=>{l({title:"Failed to update email channel sender",description:"Please contact your administrator",variant:"destructive"})}})})),className:"bg-white border border-gray-200 rounded-2xl shadow-sm p-8 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[n.jsx(lpe,{className:"flex items-center gap-1 text-base font-medium mb-2",children:"Email Channel Sender"}),n.jsxs(nme,{value:u.watch("channelSenderId"),onValueChange:e=>{u.setValue("channelSenderId",e);const a=c.find((a=>a.channelSenderId===e));a&&u.setValue("replyTo",a.channelSender.channelSenderMetadata.emailReplyTo??"")},children:[n.jsx(rme,{className:"w-full bg-gray-50 border-gray-200 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 rounded-lg min-h-[48px] text-base",children:n.jsx(ime,{placeholder:"Select a sender"})}),n.jsx(lme,{children:c.map((e=>n.jsx(ume,{value:e.channelSenderId,children:n.jsxs("div",{className:"flex flex-col text-left",children:[n.jsx("span",{className:"font-medium",children:e.fullDomain}),n.jsx("span",{className:"text-xs text-muted-foreground",children:e.channelSender.channelSenderMetadata.emailReplyTo||"No reply-to set"})]})},e.channelSenderId)))})]})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[n.jsxs(lpe,{className:"flex items-center gap-1 text-base font-medium mb-0.5",children:["Reply-to Email",n.jsx(pue,{title:"Reply to email to use when the reply button is clicked"})]}),n.jsxs("span",{className:"text-xs text-muted-foreground font-normal mb-1",children:["Optional – will use"," ",n.jsx("span",{className:"font-mono",children:u.watch("channelSenderId")?`noreply@${c.find((e=>e.channelSenderId===u.watch("channelSenderId")))?.baseDomain}`:"sender domain"})," ","if empty"]}),n.jsx(hpe,{control:u.control,name:"replyTo",type:"email",placeholder:"Replies from recipients will go to this email (optional)"})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[n.jsxs(lpe,{className:"flex items-center gap-1 text-base font-medium mb-0.5",children:["From Name",n.jsx(pue,{title:"From name to use when the email is sent"})]}),n.jsx(hpe,{control:u.control,name:"fromName",placeholder:"From name to use when the email is sent (optional)"})]}),n.jsx("div",{className:"flex gap-3 pt-4 justify-end border-t border-gray-100",children:n.jsx(k5,{type:"submit",disabled:s,className:"min-w-[120px]",children:s?"Saving...":"Save"})})]})})]})},QAe=()=>{const[e,t]=a.useState(null),{channelSenders:i}=fre(),{channelAccounts:r}=pre(),{data:o}=Sre(),s=ale({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o});a.useEffect((()=>{s.length>0&&s.some((e=>e.smsApplication?.status===ele.APPROVED||!e.smsApplication))?t(!0):t(!1)}),[s,o]);const l={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}};if(null===e)return n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:n.jsx(v5,{})});const u=s.some((e=>e.smsApplication?.status===ele.APPROVED));return n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:e?n.jsxs(K4.div,{initial:"hidden",animate:"visible",exit:"exit",variants:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1],staggerChildren:.1}},exit:{opacity:0,y:-20,transition:{duration:.3,ease:[.4,0,1,1]}}},className:vm("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl p-6 gap-3 border border-border mx-auto mb-16","bg-background"),children:[n.jsx(K4.div,{variants:l,className:"w-16 h-16 rounded-xl flex items-center justify-center bg-green-50",children:n.jsx(w5.SmsIcon,{className:"text-green-600"})}),n.jsx(K4.h2,{variants:l,className:"text-lg font-medium text-foreground",children:"SMS Sending Number Active"}),n.jsx(K4.div,{variants:l,className:"max-w-xl mx-auto",children:n.jsx("p",u?{className:"text-sm font-normal text-muted-foreground mb-2",children:"Your SMS sending number has been verified and is ready to use. You can now create and send SMS campaigns!"}:{className:"text-sm font-normal text-muted-foreground mb-2",children:"You already have a valid SMS sending number and it is ready to use. You can create and send SMS campaigns!"})}),n.jsxs(K4.div,{variants:l,className:"flex items-center gap-2 px-4 py-2 bg-green-50 border border-green-200 rounded-full mt-2",children:[n.jsx(K4.div,{animate:{scale:[1,1.2,1],opacity:[1,.8,1]},transition:{duration:2,repeat:Number.POSITIVE_INFINITY,ease:"easeInOut"},className:"w-2 h-2 bg-green-500 rounded-full"}),n.jsx("span",{className:"text-sm font-medium text-green-800",children:"Ready to send"})]})]}):n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:n.jsx(gpe,{})})})};function XAe({tabs:e,activeTab:a,onTabChange:t,title:i}){return n.jsxs("div",{className:"flex h-full",children:[n.jsxs("div",{className:"w-48 py-2 pl-4",children:[i&&n.jsx("h2",{className:"px-4 pt-4 pb-5 text-lg font-medium",children:i}),e.map((e=>n.jsx(k5,{variant:"ghost",className:vm("w-full justify-start mb-1",a===e.id&&"bg-accent"),onClick:()=>t(e.id),children:e.label},e.id)))]}),n.jsx("div",{className:"flex-1 overflow-y-auto pl-6 pr-4 pb-4",children:e.find((e=>e.id===a))?.content})]})}function ewe({open:e,setOpen:t}){const[i,r]=a.useState("brand");a.useEffect((()=>{e&&r("brand")}),[e]);const o=[{id:"brand",label:"Brand",content:n.jsx(ZAe,{})},{id:"email-channel",label:"Email Channel",content:n.jsx(YAe,{})},{id:"sms-channel",label:"SMS Channel",content:n.jsx(QAe,{})}];return n.jsx(L$,{open:e,onOpenChange:t,children:n.jsxs(z$,{className:"flex w-[90vw] h-[90vh] flex-col gap-0 overflow-hidden sm:max-w-xl md:max-w-3xl lg:max-w-4xl xl:max-w-5xl p-0",children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Settings"}),n.jsx(H$,{children:"Edit your business and brand settings"})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(XAe,{tabs:o,activeTab:i,onTabChange:r,title:"Settings"})})]})})}const awe=e=>{const{updateAutomation:n,updateError:t,isUpdateSuccess:i}=ta(e),{toast:r}=Ge();return a.useEffect((()=>{i?r({title:"Status updated",description:"The status has been updated successfully"}):t&&r({title:"Error updating status",description:"Please try again",variant:"destructive"})}),[i,t,r]),{toggleStatus:async e=>{try{return await n({status:e?da.ACTIVE:da.DRAFT}),!0}catch(a){return r({title:"Error updating status",description:"Please try again",variant:"destructive"}),!1}}}};function nwe(){const{toast:e}=Ge(),[t,i]=a.useState(null),{toggleStatus:r}=awe(t||""),o=qne(),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{automations:h,nextCursor:p,isLoading:g,error:v,isFetching:f,isPlaceholderData:y}=ra({cursor:u,limit:s,triggerType:sa.TRIGGER_BASED,search:d||void 0});a.useEffect((()=>{v&&e({title:`Error Fetching ${_h("engage:automation")}`,description:v?.message||"Please try again.",variant:"destructive"})}),[v,e]);const k=a.useMemo((()=>(h||[]).map((e=>({...e,emailsSent:0,smsSent:0,updated_at:e.updatedAt||e.createdAt})))),[h]),b=a.useCallback((async(e,a)=>{try{i(e);const n=a===da.ACTIVE;await r(n)}finally{i(null)}}),[r,i]),S=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]),A=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),w=a.useMemo((()=>hue({automationName:_h("engage:automation"),setUrl:A,onToggle:b,vsaasManaged:!0})),[b,A]);return n.jsx("div",{className:"w-full h-[75vh] flex flex-col",children:n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx($ae,{data:k,columns:w,paginationMode:"cursor",initialPageSize:s,isLoading:g&&!y,onRowClick:e=>{o(`/automations/view-modal/${e.id}?showBackButton=true`)},cursorPaginationQueryResult:{nextCursor:p,isLoading:g,isFetching:f,isPlaceholderData:y},onQueryParametersChange:S,searchValue:d,onSearchChange:m})})})}function twe(){const{toast:e}=Ge(),[t,i]=a.useState(!1),[r,o]=a.useState(null),{toggleStatus:s}=awe(r||""),l=qne(),[u,c]=a.useState(10),[d,m]=a.useState(void 0),[h,p]=a.useState(""),{automations:g,nextCursor:v,isLoading:f,error:y,isFetching:k,isPlaceholderData:b}=ra({cursor:d,limit:u,triggerType:sa.ONE_TIME,search:h||void 0});a.useEffect((()=>{y&&e({title:`Error Fetching ${_h("engage:broadcast")}`,description:y?.message||"Please try again.",variant:"destructive"})}),[y,e]);const S=a.useMemo((()=>(g||[]).map((e=>({...e,updated_at:e.updatedAt})))),[g]),A=a.useCallback((async(e,a)=>{try{o(e);const n=a===da.ACTIVE;await s(n)}finally{o(null)}}),[s,o]),w=a.useCallback((e=>{m(e.cursor),c(e.pageSize)}),[]),C=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),M=a.useMemo((()=>hue({automationName:_h("engage:broadcast"),setUrl:C,onToggle:A,pillForStatus:!0})),[A,C]);return n.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx($ae,{data:S,columns:M,paginationMode:"cursor",initialPageSize:u,headerActions:n.jsxs(k5,{className:"bg-primary",onClick:()=>i(!0),children:[n.jsx(sd,{className:"h-4 w-4 mr-1"}),"New"]}),isLoading:f&&!b,cursorPaginationQueryResult:{nextCursor:v,isLoading:f,isFetching:k,isPlaceholderData:b},onRowClick:e=>{l(`/automations/view-modal/${e.id}?showBackButton=true`)},onQueryParametersChange:w,searchValue:h,onSearchChange:p})}),n.jsx(_Ae,{open:t,setOpen:i,onClose:a=>{iue(i,e,a,`Error creating ${_h("engage:broadcast")}`,"Please try again"),m(void 0),c(10),p(""),!1!==a&&l(`/automations/view-modal/${a}?showBackButton=true`)},automationType:sa.ONE_TIME})]})}function iwe(){const{toast:e}=Ge(),[t,i]=a.useState(!1),[r,o]=a.useState(null),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{segments:h,isLoading:p,nextCursor:g,isFetching:v,isPlaceholderData:f}=t5({search:d||void 0,cursor:u,limit:s}),y=a.useCallback((e=>{o(e),i(!0)}),[o]),k=a.useMemo((()=>function(e){return[sue("name",`${_h("engage:segment")} Name`,!0),lue(),tue({accessorKey:"user_count",header:_h("engage:user_other"),meta:{align:"right",displayName:_h("engage:user_other")},cellClassName:"text-muted-foreground pr-4",cellFormatter:e=>{const a=e.getValue()??0;return`${a.toLocaleString()} ${1===a?_h("engage:user").toLowerCase():_h("engage:user_other").toLowerCase()}`}}),uue("updated_at"),mue(e||(()=>{}))]}(y)),[y]),b=a.useMemo((()=>h?h.map((e=>({...e,updated_at:e.createdAt.toString(),user_count:e.userCount,user_count_updated_at:e.userCountUpdatedAt}))):[]),[h]),S=a.useMemo((()=>n.jsxs(k5,{onClick:()=>{o(null),i(!0)},children:[n.jsx(sd,{className:"h-4 w-4"}),"New List"]})),[]),A=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]);return n.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx($ae,{data:b,columns:k,paginationMode:"cursor",initialPageSize:s,headerActions:S,isLoading:p&&!f,cursorPaginationQueryResult:{nextCursor:g,isLoading:p,isFetching:v,isPlaceholderData:f},onQueryParametersChange:A,onRowClick:a=>{a.type===l5.CUSTOM?(o(a.id),i(!0)):e({title:`${_h("engage:segment")} cannot be edited`})},searchValue:d,onSearchChange:m})}),n.jsx(lAe,{open:t,setOpen:i,segmentId:r??void 0,onSegmentUpdated:a=>{iue(i,e,a,`Error creating ${_h("engage:segment")}`,"Please try again"),c(void 0),l(10),m("")}})]})}const rwe=()=>{const e=ce(),[t,i]=a.useState(!1),[r,o]=a.useState(null),{automations:s,isLoading:l}=ra({triggerType:sa.TRIGGER_BASED}),[u,c]=a.useState();return a.useEffect((()=>{e.prefetchQuery({queryKey:Le.list()}),e.prefetchQuery({queryKey:a5.lists()})}),[e]),a.useEffect((()=>{if(l||void 0===s)return;const e=[{id:"broadcasts",label:_h("engage:broadcast",{count:2}),content:n.jsx(twe,{})},{id:"segments",label:_h("engage:segment",{count:2}),content:n.jsx(iwe,{})},{id:"statistics",label:_h("engage:insight",{count:2}),content:n.jsx(FAe,{})}];s.length>0?(o("automations"),c([{id:"automations",label:_h("engage:automation",{count:2}),content:n.jsx(nwe,{})},...e])):(o("broadcasts"),c(e))}),[s,l]),null===r||null==u?n.jsx("div",{className:"w-full h-full flex justify-center items-center",children:n.jsx(v5,{})}):n.jsxs("div",{className:"w-full h-full flex flex-col gap-4",children:[n.jsx(ewe,{open:t,setOpen:i}),n.jsx("div",{className:"flex justify-end",children:n.jsx(k5,{variant:"outline",onClick:()=>i(!0),children:n.jsx(md,{className:"w-4 h-4"})})}),n.jsx("div",{className:"flex-1 w-full h-full flex flex-col gap-4",children:n.jsx(PAe,{activeTab:r,tabs:u,onTabChange:o})})]})};function owe({value:e,schema:t,onSubmit:i,fieldName:r,className:o,successMessage:s="Updated successfully",errorMessage:l="Failed to update",placeholderText:u}){const[c,d]=a.useState(!1),[m,h]=a.useState(!1),[p,g]=a.useState(0),[v,f]=a.useState(0),[y,k]=a.useState(e),[b,S]=a.useState(e),A=a.useRef(null),w=a.useRef(null),C=a.useRef(null),M=a.useRef(null),{toast:T}=Ge(),E=Zhe({resolver:ape(t),defaultValues:{[r]:e}});a.useEffect((()=>{E.reset({[r]:e}),k(e),S(e)}),[e,r,E]),a.useEffect((()=>{w.current&&g(w.current.offsetWidth),M.current&&!c&&f(M.current.offsetWidth)}),[c]),a.useEffect((()=>{C.current&&y&&g(C.current.offsetWidth)}),[y]),a.useEffect((()=>{c&&A.current&&(A.current.focus(),A.current.select())}),[c]);const x=async e=>{h(!0);const a=e[r];try{await i(e),S(a),T({variant:"success",title:s}),d(!1)}catch(n){T({variant:"destructive",title:l})}finally{h(!1)}},N=()=>{E.reset(),d(!1),k(b)},_=e=>{"Escape"===e.key&&N()};return c?n.jsx(npe,{...E,children:n.jsxs("form",{onSubmit:E.handleSubmit(x),className:P$("inline-flex items-center gap-2 min-h-[20px]",o),style:{minWidth:v?`${v}px`:"auto"},children:[n.jsx("span",{ref:C,className:"absolute invisible whitespace-pre leading-none select-none pointer-events-none",style:{font:"inherit"},children:y||b}),n.jsx(ipe,{control:E.control,name:r,render:({field:e})=>n.jsx(spe,{className:"flex-1 min-w-0",children:n.jsx(upe,{children:n.jsx("input",{...e,ref:A,style:{width:`${Math.max(p+40,120)}px`,minWidth:`${Math.max(p,100)}px`,font:"inherit"},className:"bg-transparent outline-none leading-none h-[20px] border-none p-0 m-0",onChange:a=>{e.onChange(a),k(a.target.value)},onKeyDown:_,disabled:m,onBlur:a=>{e.onBlur(),setTimeout((()=>{a.currentTarget.form?.contains(document.activeElement)||N()}),0)}})})})}),n.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n.jsx(k5,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",onClick:N,disabled:m,children:n.jsx(Ad,{className:"h-3 w-3"})}),n.jsx(k5,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",disabled:m,onClick:()=>{E.handleSubmit(x)()},children:m?n.jsx(Zc,{className:"h-3 w-3 animate-spin"}):n.jsx(_c,{className:"h-3 w-3"})})]})]})}):n.jsxs("button",{ref:M,type:"button",className:P$("group relative inline-flex items-center gap-2 cursor-pointer min-h-[20px] bg-transparent border-none p-0 text-left",o),onClick:()=>d(!0),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),d(!0))},"aria-label":"Edit field",children:[n.jsx("span",{ref:w,className:P$("leading-none select-none",o,{italic:!b}),children:b||u}),n.jsx(id,{className:"h-3 w-3 transition-opacity duration-200 flex-shrink-0 opacity-0 group-hover:opacity-100"})]})}function swe({open:e,onOpenChange:a}){const t=d5(),{toast:i}=Ge(),{updateAutomation:r}=ta(t?.id||""),o=ce();return n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"sm:max-w-[425px]",children:[n.jsx(D$,{children:n.jsx(O$,{children:t?.status===da.SENDING?`Cancel ${_h("engage:automation")}`:`Cancel ${_h("engage:automation")} Before Sending`})}),n.jsx("div",{className:"space-y-4",children:t?n.jsxs(n.Fragment,t.status===da.SENDING?{children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",n.jsx("span",{className:"font-bold px-1 text-primary",children:t.name}),_h("engage:automation")," as soon as possible."]}),n.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[n.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),n.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[n.jsxs("li",{children:["We'll attempt to cancel the"," ",_h("engage:broadcast").toLowerCase()]}),n.jsx("li",{children:"Any messages already in the process of being sent will be delivered"}),n.jsxs("li",{children:["Future ",_h("engage:broadcast").toLowerCase()," messages will be cancelled"]}),n.jsxs("li",{children:["You can create a new ",_h("engage:broadcast").toLowerCase()," if needed"]})]})]})]}:{children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",n.jsx("span",{className:"font-bold px-1 text-primary",children:t.name}),_h("engage:automation")," before it starts sending."]}),n.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[n.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),n.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[n.jsx("li",{children:"The automation will be cancelled"}),n.jsx("li",{children:"You can create a new automation if needed"})]})]})]}):null}),n.jsxs(K$,{className:"gap-2 sm:gap-0",children:[n.jsx(k5,{variant:"outline",onClick:()=>a(!1),children:"Continue Running"}),n.jsxs(k5,{variant:"destructive",onClick:()=>{if(!t)return;const e=t.status===da.SENDING?da.PARTIALLY_CANCELLED:da.CANCELLED,n=t.status===da.SENDING?`Attempting to cancel ${_h("engage:broadcast").toLowerCase()}`:`Successfully cancelled ${_h("engage:broadcast").toLowerCase()}`,s=`Failed to cancel ${_h("engage:broadcast").toLowerCase()}`;r({status:e},{onError:()=>{i({title:s,description:"Please contact your administrator.",variant:"destructive"}),o.invalidateQueries({queryKey:Le.all})},onSuccess:()=>{a(!1),i({title:n,description:t.status===da.SENDING?`We'll attempt to cancel your ${_h("engage:broadcast").toLowerCase()}. Any messages already in progress will be delivered.`:`Your ${_h("engage:broadcast").toLowerCase()} has been cancelled.`})}})},children:["Cancel ",_h("engage:automation")]})]})]})})}function lwe({open:e,onOpenChange:a,setIsActive:t}){const i=d5(),{updateAutomation:r}=ta(i?.id||""),{toast:o}=Ge(),s=ce(),l=_h(i?.triggerType===sa.ONE_TIME?"engage:broadcast":"engage:automation"),u=i?.triggerType===sa.ONE_TIME?"Unschedule":"Convert to draft";return n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"sm:max-w-[425px]",children:[n.jsx(D$,{children:n.jsx(O$,{children:u})}),n.jsxs("div",{children:["Are you sure you want to convert",n.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name})," ",l," to draft?"]}),n.jsxs(K$,{className:"gap-2 sm:gap-0",children:[n.jsx(k5,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),n.jsx(k5,{variant:"destructive",onClick:()=>{r({status:da.DRAFT},{onSuccess:()=>{o({title:`Updated ${l}`,description:`${l} status updated to draft`}),a(!1),t(!1)},onError:()=>{o({title:`Failed to update ${l}`,description:"Please try again"}),s.invalidateQueries({queryKey:Le.all})}})},children:u})]})]})})}const uwe=Ese({name:hse().min(2,"Title must be at least 2 characters"),description:hse()});function cwe({open:e,onOpenChange:a,onDuplicationCreated:t}){const i=d5(),{toast:r}=Ge(),o=Zhe({resolver:ape(uwe),defaultValues:{name:`${i?.name} (copy)`,description:i?.description??""}}),{duplicateAutomation:s}=oa();return n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"sm:max-w-[425px]",children:[n.jsx(D$,{children:n.jsx(O$,{children:"Duplicate Automation"})}),n.jsx(npe,{...o,children:n.jsxs("form",{onSubmit:o.handleSubmit((async function(e){i&&e.name?s({automationId:i.id,name:e.name,description:e.description},{onSuccess:e=>{e.id&&(t?.(e.id),a(!1))}}):r({title:"Error duplicating automation",description:"Please try again. Please make sure to fill in the name of the automation."})})),className:"space-y-4",children:[n.jsxs("div",{children:["Create a copy of the",n.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name}),"automation with a new title and description."]}),n.jsx(ipe,{control:o.control,name:"name",render:({field:e})=>n.jsxs(spe,{children:[n.jsx(lpe,{children:"Title"}),n.jsx(upe,{children:n.jsx(qae,{...e})}),n.jsx(cpe,{})]})}),n.jsx(ipe,{control:o.control,name:"description",render:({field:e})=>n.jsxs(spe,{children:[n.jsx(lpe,{children:"Description"}),n.jsx(upe,{children:n.jsx(Uve,{...e})}),n.jsx(cpe,{})]})}),n.jsx(K$,{children:n.jsx(k5,{type:"submit",children:"Duplicate"})})]})})]})})}const dwe=Ese({name:hse().min(2,"Title must be at least 2 characters")}),mwe=Ese({description:hse().max(300,"Description must be less than 300 characters")}),hwe=({showBackButton:e,onDuplicationCreated:t,onBeforeSchedule:i})=>{const r=d5(),o=qne(),{updateAutomation:s}=ta(r?.id||""),{toast:l}=Ge(),u=(()=>{const{state:e}=c5();return e.recipientStats})(),c=m5(),{data:d}=Sre(),{channelSenders:m}=fre(),{channelAccounts:h}=pre(),p=ce(),[g,v]=a.useState(void 0),[f,y]=a.useState(!1),[k,b]=a.useState(!1),[S,A]=a.useState(!1),[w,C]=a.useState(0),[M,T]=a.useState(!1),E=ale({channelSenders:m?.results??[],channelAccounts:h?.results??[],smsApplication:d});a.useEffect((()=>{if(r)switch(r.status){case da.DRAFT:v(!1);break;case da.ACTIVE:case da.RUNNING:case da.COMPLETED:v(!0);break;case da.FAILED:case da.DEACTIVATED:v(!1);break;case da.SENDING:case da.SCHEDULED:v(!0);break;case da.PARTIALLY_CANCELLED:case da.CANCELLED:v(!1);break;default:throw ire(r.status,da)}}),[r]);const x=a.useCallback((()=>{if(!r)return l({title:"Automation not found",description:"Please contact your administrator",variant:"destructive"}),null;const e=async e=>{if(g&&!e)b(!0);else{if(A(!0),i&&!0===e){let e=0;for(;!u&&e<20;)await new Promise((e=>setTimeout(e,100))),e++;if(!u)return l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),void A(!1);const a=await i({estimatedEmailRecipients:u?.emails??0,estimatedSmsRecipients:u?.phones??0});if(!0!==a)return l({title:"Error while updating the status",description:a,variant:"destructive"}),void A(!1)}if(c?.emailChannelSenderId&&c?.emailHtmlBody&&c?.emailHtmlBody?.includes(SAe)){if(0===w)return l({title:`${AAe}. You can click send again to send anyway.`,variant:"warning"}),C(w+1),void A(!1);C(w+1)}switch(r.triggerType){case sa.ONE_TIME:if(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt)return l({title:"Ensure you have selected a scheduled time",variant:"destructive"}),void A(!1);if(!c||!c.emailChannelSenderId&&!c.smsChannelSenderId)return l({title:"Ensure you have selected at least one kind of communication",variant:"destructive"}),void A(!1);break;case sa.TRIGGER_BASED:break;default:throw ire(r.triggerType,sa)}const a=_h(r.triggerType===sa.ONE_TIME?"engage:automation":"engage:broadcast");s({status:e?da.ACTIVE:da.DEACTIVATED},{onSuccess:()=>{v(e),l(r.triggerType===sa.ONE_TIME?e?{title:`${a} started!`}:{title:`${a} has been unscheduled`}:{title:`${a} status updated to ${e?"active":"inactive"}`}),A(!1)},onError:()=>{l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),A(!1),p.invalidateQueries({queryKey:Le.all})}})}};if(!r||!c)return null;const a=E.find((e=>e.channelSender.id===c?.smsChannelSenderId)),t=!r.triggerMetadata||null===r.triggerMetadata,o=r.triggerMetadata?.triggerType===sa.ONE_TIME&&!r.triggerMetadata?.scheduledAt,d=!c?.emailChannelSenderId&&!c?.smsChannelSenderId,m=r.triggerType===sa.ONE_TIME,h=m&&a&&a?.smsApplication?.application&&a?.smsApplication?.status!==ele.APPROVED,f=c?.emailChannelSenderId&&(!c?.emailSubject||!c?.emailHtmlBody),y=c?.smsChannelSenderId&&!c?.smsMessageBody,k=m&&(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt);let S,M=!1,x=!0;switch(r.status){case da.ACTIVE:M=!1;break;case da.DRAFT:(d||f||y)&&(M=!0,f&&(S="Missing subject in email communication"),y&&(S="Missing SMS message in SMS communication")),k&&(M=!0),h&&(M=!0);break;case da.DEACTIVATED:case da.PARTIALLY_CANCELLED:case da.CANCELLED:switch(M=!0,x=!1,r.status){case da.DEACTIVATED:S="Automation is deactivated";break;case da.PARTIALLY_CANCELLED:S="Automation is partially cancelled";break;case da.CANCELLED:S="Automation is cancelled";break;default:throw ire(r.status,da)}break;case da.RUNNING:M=!0,r.triggerType===sa.TRIGGER_BASED?(S="Cannot change status of running automation",x=!0):x=r.triggerType===sa.ONE_TIME&&r.status===da.RUNNING;break;case da.COMPLETED:M=!0,S="Cannot change status of completed automation",x=!1;break;case da.FAILED:M=!0,S="Cannot change status of failed automation",x=!1;break;case da.SENDING:case da.SCHEDULED:M=!1,x=!0;break;default:throw ire(r.status,da)}const N=(()=>{switch(r.triggerType){case sa.TRIGGER_BASED:return n.jsxs("div",{className:"flex items-center gap-2 w-[12ch] cursor-pointer",children:[n.jsx(g?_c:Oc,{className:"w-4 h-4"}),n.jsx("div",{className:"text-[13px] font-medium",children:g?"Active":"Inactive"}),n.jsx(XSe,{checked:g,onCheckedChange:e,disabled:M})]});case sa.ONE_TIME:if((r.status===da.RUNNING||r.status===da.SCHEDULED||r.status===da.SENDING)&&r.triggerType===sa.ONE_TIME)return n.jsx(k5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>T(!0),disabled:!1,children:"Cancel"});if(t||o||d||h||f||y){return n.jsx("div",{className:"flex items-center gap-2 cursor-not-allowed",children:(()=>{const a=r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"===r.triggerMetadata?.scheduledAt?"Send Now":"Schedule Send";if(r.status!==da.DRAFT&&r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"!==r.triggerMetadata?.scheduledAt&&r.status===da.ACTIVE)return n.jsx(k5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:r.triggerType===sa.ONE_TIME?"Unschedule":"Convert to Draft"});const t=[];h&&t.push("The SMS number selected is still not approved"),k&&t.push("Please select a schedule time on the left sidebar"),d&&t.push("Please add at least one sender"),f&&t.push("Please add a subject to your email communication"),y&&t.push("Please add a message to your SMS communication");const i=t.map((e=>{return(a=e).charAt(0).toUpperCase()+a.slice(1);var a})),o=`You cannot start this ${_h("engage:broadcast")} yet. ${i.join(" · ")}`;return n.jsx("div",{className:"flex items-center gap-2",children:n.jsx(pue,{alertText:o,asChild:!1,className:"!cursor-not-allowed",children:n.jsx(k5,{variant:"outline",className:"flex items-center gap-2",disabled:!0,asChild:!1,children:a})})})})()})}if(!g){let a="Schedule Send";return r.triggerMetadata&&r.triggerMetadata.triggerType===sa.ONE_TIME&&r.triggerMetadata.scheduledAt&&"now"===r.triggerMetadata.scheduledAt&&(a="Send Now"),n.jsx(k5,{variant:"default",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:a})}return n.jsx(k5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:r.triggerType===sa.ONE_TIME?"Unschedule":"Convert to Draft"});default:throw ire(r.triggerType,sa)}})();return M&&S&&r.triggerType===sa.TRIGGER_BASED?n.jsx(pue,{alertText:S,asChild:!0,children:n.jsx("div",{className:"flex items-center gap-2",children:x&&N})}):n.jsx("div",{className:"flex items-center gap-2",children:x&&N})}),[r,c,E,l,g,i,s,u,w,p]),N=a.useMemo((()=>r?n.jsx(B5,{variant:rue(r.status),children:rre({status:r.status,automationType:r.triggerType})}):null),[r]);return r&&void 0!==g?n.jsxs("header",{className:"flex px-1 pt-1",children:[n.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[e&&n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>o(-1),children:n.jsx(Tc,{})}),n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs("div",{className:"flex flex-col gap-0 items-start",children:[n.jsx(owe,{value:r.name,schema:dwe,onSubmit:e=>{s({name:e.name},{onError:()=>{l({title:"Failed to update automation name",description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:Le.all})}})},fieldName:"name",className:"text-lg",successMessage:"Automation name updated",errorMessage:"Failed to update automation name"}),r.automationType!==ua.MANAGED?n.jsx(owe,{value:r.description||"",schema:mwe,onSubmit:e=>{s({description:e.description},{onError:()=>{l({title:"Failed to update automation description",description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:Le.all})}})},fieldName:"description",className:"text-sm "+(r.description?"text-current":"text-muted-foreground"),successMessage:"Description updated",errorMessage:"Failed to update description",placeholderText:"Describe the goal of the automation"}):r.description&&n.jsx("div",{className:"text-sm text-current",children:r.description})]})})]}),n.jsxs("div",{className:"ml-auto flex gap-4 items-center",children:[n.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[N,r.triggerType===sa.ONE_TIME&&n.jsx("div",{role:"button",tabIndex:0,className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-10 w-10 cursor-pointer",onClick:()=>y(!0),children:n.jsx(pue,{title:"Duplicate",Icon:w5.DuplicateIcon,asChild:!1,onClick:()=>y(!0)})})]}),n.jsx("div",S?{className:"flex items-center text-muted-foreground pr-2",children:n.jsx(v5,{size:"sm"})}:{className:"flex items-center",children:x()})]}),n.jsx(cwe,{open:f,onOpenChange:y,onDuplicationCreated:t}),n.jsx(lwe,{open:k,onOpenChange:b,setIsActive:v}),n.jsx(swe,{open:M,onOpenChange:T})]}):null},pwe=()=>{const e=d5(),{isLoading:t}=ia(e?.id),{state:{hideSales:i,hideSms:r}}=a.useContext(uq);return!e||t?n.jsx(v5,{text:[`Fetching ${_h("engage:insight",{count:2})}`,"Finishing up"]}):n.jsx("div",{className:"h-full p-4",children:n.jsx(FAe,{automationId:e.id,automation:e,includeSales:!i,includeSms:!r})})},gwe=()=>{const e=d5(),[t,i]=a.useState(10),[r,o]=a.useState(void 0),[s,l]=a.useState(""),{sentCommunications:u,isLoading:c,isFetching:d,isPlaceholderData:m,fetchError:h}=aa({automationId:e?.id??"",cursor:r,limit:t,search:s||void 0}),p=a.useCallback((e=>{o(e.cursor),i(e.pageSize)}),[]),g=[{accessorKey:"communicationsSent",id:"lastCommunication",header:"Updated At",cell:({row:e})=>{const a=e.original.communicationsSent||[];if(0===a.length)return n.jsx("span",{className:"text-gray-400",children:"None"});const t=a.reduce(((e,a)=>e&&e.updatedAt?a.updatedAt&&new Date(a.updatedAt)>new Date(e.updatedAt)?a:e:a));return t?.updatedAt?n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("span",{className:"text-sm text-gray-600",children:eue(new Date(t.updatedAt),"MMM d, yyyy h:mm a")})}):n.jsx("span",{className:"text-gray-400",children:"Not available"})}},{accessorFn:e=>`${e.firstName||""} ${e.lastName||""}`.trim(),id:"name",header:"Name",cell:({row:e})=>{const a=`${e.original.firstName||""} ${e.original.lastName||""}`.trim();return a||n.jsx("span",{className:"text-gray-400",children:"Not provided"})}},{accessorKey:"email",header:"Email",cell:({row:e})=>e.original.email||n.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"phone",header:"Phone",cell:({row:e})=>e.original.phone?yye(e.original.phone):n.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"communicationsSent",id:"communicationsSent",header:"Communications Sent",cell:({row:e})=>{const a=e.original.communicationsSent||[],t=a.filter((e=>e.type===ma.EMAIL)),i=a.filter((e=>e.type===ma.SMS)),r=t.length>0,o=i.length>0,s=t.some((e=>e.delivered)),l=i.some((e=>e.delivered)),u=t.find((e=>e.error))?.error,c=i.find((e=>e.error))?.error,d=t.some((e=>e.skipped)),m=i.some((e=>e.skipped)),h=(e,a,t,i)=>n.jsxs("div",{className:"flex items-center gap-1.5 cursor-pointer",children:[n.jsxs("div",{className:"relative",children:[n.jsx("email"===e?w5.EmailIcon:w5.SmsIcon,{className:"h-4 w-4 "+(t?"text-red-500":i?"text-gray-400":a?"text-green-500":"text-gray-400")}),a&&!t&&!i&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-green-500 ring-1 ring-white"}),t&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-red-500 ring-1 ring-white"}),i&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-gray-400 ring-1 ring-white"})]}),n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"text-sm font-medium",children:"email"===e?"Email":"SMS"}),n.jsx("span",t?{className:"text-xs text-red-500",children:"Failed"}:i?{className:"text-xs text-gray-500",children:"Skipped"}:{className:"text-xs "+(a?"text-green-600":"text-gray-500"),children:a?"Delivered":"Pending"})]})]});return n.jsxs("div",{className:"flex items-center gap-3",children:[r&&(u?n.jsx(pue,{title:u,children:h("email",s,u,d)}):h("email",s,u,d)),r&&o&&n.jsx("div",{className:"h-8 w-px bg-gray-200"}),o&&(c?n.jsx(pue,{title:c,children:h("sms",l,c,m)}):h("sms",l,c,m)),!r&&!o&&n.jsx("span",{className:"text-sm text-gray-400",children:"None"})]})}}];return e&&!c&&u?h?n.jsxs("div",{children:["Error: ",h.message]}):!u||!s&&0===u.results.length?n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[n.jsx("div",{className:"mb-4",children:n.jsx(w5.UserIcon,{className:"h-12 w-12 text-gray-400"})}),n.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Communications Sent Yet"}),n.jsxs("p",{className:"text-gray-500",children:["This"," ",_h(e.triggerType===sa.ONE_TIME?"engage:broadcast":"engage:automation")," ","hasn't sent any communications yet. Please check back later to see recipient details once communications have been sent."]})]}):n.jsx("div",{className:"h-full p-4",children:n.jsx($ae,{data:u.results,columns:g,paginationMode:"cursor",initialPageSize:t,isLoading:c&&!m,cursorPaginationQueryResult:{nextCursor:u.pagination.cursor,isLoading:c,isFetching:d,isPlaceholderData:m},onQueryParametersChange:p,searchValue:s,onSearchChange:l})}):n.jsx(v5,{text:["Fetching Recipients","Finishing up"]})},vwe=()=>{const e=d5();return e?e?.triggerType===sa.ONE_TIME&&e?.status===da.DRAFT?n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[n.jsx("div",{className:"mb-4",children:n.jsx(w5.UserIcon,{className:"h-12 w-12 text-gray-400"})}),n.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Recipients Available Yet"}),n.jsxs("p",{className:"text-gray-500",children:["Recipients will be available once this"," ",_h(e.triggerType===sa.ONE_TIME?"engage:broadcast":"engage:automation")," ","has completed running. Please check back after the automation has finished."]})]}):n.jsx(gwe,{}):n.jsx(v5,{text:["Fetching Recipients","Finishing up"]})},fwe=a.createContext(null);fwe.displayName="PanelGroupContext";const ywe="data-panel-group",kwe="data-panel-group-direction",bwe="data-panel-group-id",Swe="data-panel",Awe="data-panel-collapsible",wwe="data-panel-id",Cwe="data-panel-size",Mwe="data-resize-handle",Twe="data-resize-handle-active",Ewe="data-panel-resize-handle-enabled",xwe="data-panel-resize-handle-id",Nwe="data-resize-handle-state",_we=a.useLayoutEffect,Pwe=r["useId".toString()],Lwe="function"==typeof Pwe?Pwe:()=>null;let jwe=0;function Bwe(e=null){const n=Lwe(),t=a.useRef(e||n||null);return null===t.current&&(t.current=""+jwe++),null!=e?e:t.current}function Rwe({children:e,className:n="",collapsedSize:t,collapsible:i,defaultSize:r,forwardedRef:o,id:s,maxSize:l,minSize:u,onCollapse:c,onExpand:d,onResize:m,order:h,style:p,tagName:g="div",...v}){const f=a.useContext(fwe);if(null===f)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:k,getPanelSize:b,getPanelStyle:S,groupId:A,isPanelCollapsed:w,reevaluatePanelConstraints:C,registerPanel:M,resizePanel:T,unregisterPanel:E}=f,x=Bwe(s),N=a.useRef({callbacks:{onCollapse:c,onExpand:d,onResize:m},constraints:{collapsedSize:t,collapsible:i,defaultSize:r,maxSize:l,minSize:u},id:x,idIsFromProps:void 0!==s,order:h});a.useRef({didLogMissingDefaultSizeWarning:!1}),_we((()=>{const{callbacks:e,constraints:a}=N.current,n={...a};N.current.id=x,N.current.idIsFromProps=void 0!==s,N.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=m,a.collapsedSize=t,a.collapsible=i,a.defaultSize=r,a.maxSize=l,a.minSize=u,n.collapsedSize===a.collapsedSize&&n.collapsible===a.collapsible&&n.maxSize===a.maxSize&&n.minSize===a.minSize||C(N.current,n)})),_we((()=>{const e=N.current;return M(e),()=>{E(e)}}),[h,x,M,E]),a.useImperativeHandle(o,(()=>({collapse:()=>{y(N.current)},expand:e=>{k(N.current,e)},getId:()=>x,getSize:()=>b(N.current),isCollapsed:()=>w(N.current),isExpanded:()=>!w(N.current),resize:e=>{T(N.current,e)}})),[y,k,b,w,x,T]);const _=S(N.current,r);return a.createElement(g,{...v,children:e,className:n,id:x,style:{..._,...p},[bwe]:A,[Swe]:"",[Awe]:i||void 0,[wwe]:x,[Cwe]:parseFloat(""+_.flexGrow).toFixed(1)})}const zwe=a.forwardRef(((e,n)=>a.createElement(Rwe,{...e,forwardedRef:n})));Rwe.displayName="Panel",zwe.displayName="forwardRef(Panel)";let Dwe=null,Kwe=-1,Owe=null;function Hwe(e,a){var n,t;const i=function(e,a){if(a){const e=!!(a&Xwe),n=!!(a&eCe);if(a&Ywe)return e?"se-resize":n?"ne-resize":"e-resize";if(a&Qwe)return e?"sw-resize":n?"nw-resize":"w-resize";if(e)return"s-resize";if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,a);if(Dwe!==i){var r;if(Dwe=i,null===Owe&&(Owe=document.createElement("style"),document.head.appendChild(Owe)),Kwe>=0)null===(r=Owe.sheet)||void 0===r||r.removeRule(Kwe);Kwe=null!==(n=null===(t=Owe.sheet)||void 0===t?void 0:t.insertRule(`*{cursor: ${i} !important;}`))&&void 0!==n?n:-1}}function Iwe(e){return"keydown"===e.type}function Gwe(e){return e.type.startsWith("pointer")}function Fwe(e){return e.type.startsWith("mouse")}function Vwe(e){if(Gwe(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Fwe(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const Jwe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Uwe(e){const a=getComputedStyle(e);return"fixed"===a.position||(!("auto"===a.zIndex||"static"===a.position&&!function(e){var a;const n=getComputedStyle(null!==(a=$we(e))&&void 0!==a?a:e).display;return"flex"===n||"inline-flex"===n}(e))||(+a.opacity<1||("transform"in a&&"none"!==a.transform||("webkitTransform"in a&&"none"!==a.webkitTransform||("mixBlendMode"in a&&"normal"!==a.mixBlendMode||("filter"in a&&"none"!==a.filter||("webkitFilter"in a&&"none"!==a.webkitFilter||("isolation"in a&&"isolate"===a.isolation||(!!Jwe.test(a.willChange)||"touch"===a.webkitOverflowScrolling)))))))))}function Wwe(e){let a=e.length;for(;a--;){const n=e[a];if(fCe(n,"Missing node"),Uwe(n))return n}return null}function qwe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Zwe(e){const a=[];for(;e;)a.push(e),e=$we(e);return a}function $we(e){const{parentNode:a}=e;return a&&a instanceof ShadowRoot?a.host:a}const Ywe=1,Qwe=2,Xwe=4,eCe=8,aCe="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let nCe=[],tCe=!1,iCe=new Map,rCe=new Map;const oCe=new Set;function sCe(e){const{target:a}=e,{x:n,y:t}=Vwe(e);tCe=!0,dCe({target:a,x:n,y:t}),gCe(),nCe.length>0&&(vCe("down",e),e.preventDefault(),cCe(a)||e.stopImmediatePropagation())}function lCe(e){const{x:a,y:n}=Vwe(e);if(tCe&&0===e.buttons&&(tCe=!1,vCe("up",e)),!tCe){const{target:t}=e;dCe({target:t,x:a,y:n})}vCe("move",e),hCe(),nCe.length>0&&e.preventDefault()}function uCe(e){const{target:a}=e,{x:n,y:t}=Vwe(e);rCe.clear(),tCe=!1,nCe.length>0&&(e.preventDefault(),cCe(a)||e.stopImmediatePropagation()),vCe("up",e),dCe({target:a,x:n,y:t}),hCe(),gCe()}function cCe(e){let a=e;for(;a;){if(a.hasAttribute(Mwe))return!0;a=a.parentElement}return!1}function dCe({target:e,x:a,y:n}){nCe.splice(0);let t=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(t=e),oCe.forEach((e=>{const{element:i,hitAreaMargins:r}=e,o=i.getBoundingClientRect(),{bottom:s,left:l,right:u,top:c}=o,d=aCe?r.coarse:r.fine;if(a>=l-d&&a<=u+d&&n>=c-d&&n<=s+d){if(null!==t&&document.contains(t)&&i!==t&&!i.contains(t)&&!t.contains(i)&&function(e,a){if(e===a)throw new Error("Cannot compare node with itself");const n={a:Zwe(e),b:Zwe(a)};let t;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),a=n.b.pop(),t=e;fCe(t,"Stacking order can only be calculated for elements with a common ancestor");const i=qwe(Wwe(n.a)),r=qwe(Wwe(n.b));if(i===r){const e=t.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let i=e.length;for(;i--;){const n=e[i];if(n===a.a)return 1;if(n===a.b)return-1}}return Math.sign(i-r)}(t,i)>0){let e=t,a=!1;for(;e&&!e.contains(i);){if((m=e.getBoundingClientRect()).x<(h=o).x+h.width&&m.x+m.width>h.x&&m.y<h.y+h.height&&m.y+m.height>h.y){a=!0;break}e=e.parentElement}if(a)return}nCe.push(e)}var m,h}))}function mCe(e,a){rCe.set(e,a)}function hCe(){let e=!1,a=!1;nCe.forEach((n=>{const{direction:t}=n;"horizontal"===t?e=!0:a=!0}));let n=0;rCe.forEach((e=>{n|=e})),e&&a?Hwe("intersection",n):e?Hwe("horizontal",n):a?Hwe("vertical",n):null!==Owe&&(document.head.removeChild(Owe),Dwe=null,Owe=null,Kwe=-1)}let pCe=new AbortController;function gCe(){pCe.abort(),pCe=new AbortController;const e={capture:!0,signal:pCe.signal};oCe.size&&(tCe?(nCe.length>0&&iCe.forEach(((a,n)=>{const{body:t}=n;a>0&&(t.addEventListener("contextmenu",uCe,e),t.addEventListener("pointerleave",lCe,e),t.addEventListener("pointermove",lCe,e))})),iCe.forEach(((a,n)=>{const{body:t}=n;t.addEventListener("pointerup",uCe,e),t.addEventListener("pointercancel",uCe,e)}))):iCe.forEach(((a,n)=>{const{body:t}=n;a>0&&(t.addEventListener("pointerdown",sCe,e),t.addEventListener("pointermove",lCe,e))})))}function vCe(e,a){oCe.forEach((n=>{const{setResizeHandlerState:t}=n,i=nCe.includes(n);t(e,i,a)}))}function fCe(e,a){if(!e)throw Error(a)}function yCe(e,a,n=10){return e.toFixed(n)===a.toFixed(n)?0:e>a?1:-1}function kCe(e,a,n=10){return 0===yCe(e,a,n)}function bCe(e,a,n){return 0===yCe(e,a,n)}function SCe({panelConstraints:e,panelIndex:a,size:n}){const t=e[a];fCe(null!=t,`Panel constraints not found for index ${a}`);let{collapsedSize:i=0,collapsible:r,maxSize:o=100,minSize:s=0}=t;if(yCe(n,s)<0)if(r){n=yCe(n,(i+s)/2)<0?i:s}else n=s;return n=Math.min(o,n),n=parseFloat(n.toFixed(10))}function ACe({delta:e,initialLayout:a,panelConstraints:n,pivotIndices:t,prevLayout:i,trigger:r}){if(bCe(e,0))return a;const o=[...a],[s,l]=t;fCe(null!=s,"Invalid first pivot index"),fCe(null!=l,"Invalid second pivot index");let u=0;if("keyboard"===r){{const t=e<0?l:s,i=n[t];fCe(i,`Panel constraints not found for index ${t}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const n=a[t];if(fCe(null!=n,`Previous layout not found for panel index ${t}`),bCe(n,r)){const a=u-n;yCe(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}{const t=e<0?s:l,i=n[t];fCe(i,`No panel constraints found for index ${t}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const n=a[t];if(fCe(null!=n,`Previous layout not found for panel index ${t}`),bCe(n,u)){const a=n-r;yCe(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}}{const t=e<0?1:-1;let i=e<0?l:s,r=0;for(;;){const e=a[i];fCe(null!=e,`Previous layout not found for panel index ${i}`);if(r+=SCe({panelConstraints:n,panelIndex:i,size:100})-e,i+=t,i<0||i>=n.length)break}const o=Math.min(Math.abs(e),Math.abs(r));e=e<0?0-o:o}{let t=e<0?s:l;for(;t>=0&&t<n.length;){const i=Math.abs(e)-Math.abs(u),r=a[t];fCe(null!=r,`Previous layout not found for panel index ${t}`);const s=SCe({panelConstraints:n,panelIndex:t,size:r-i});if(!bCe(r,s)&&(u+=r-s,o[t]=s,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(function(e,a,n){if(e.length!==a.length)return!1;for(let t=0;t<e.length;t++)if(!bCe(e[t],a[t],n))return!1;return!0}(i,o))return i;{const t=e<0?l:s,i=a[t];fCe(null!=i,`Previous layout not found for panel index ${t}`);const r=i+u,c=SCe({panelConstraints:n,panelIndex:t,size:r});if(o[t]=c,!bCe(c,r)){let a=r-c;let t=e<0?l:s;for(;t>=0&&t<n.length;){const i=o[t];fCe(null!=i,`Previous layout not found for panel index ${t}`);const r=SCe({panelConstraints:n,panelIndex:t,size:i+a});if(bCe(i,r)||(a-=r-i,o[t]=r),bCe(a,0))break;e>0?t--:t++}}}return bCe(o.reduce(((e,a)=>a+e),0),100)?o:i}function wCe({layout:e,panelsArray:a,pivotIndices:n}){let t=0,i=100,r=0,o=0;const s=n[0];fCe(null!=s,"No pivot index found"),a.forEach(((e,a)=>{const{constraints:n}=e,{maxSize:l=100,minSize:u=0}=n;a===s?(t=u,i=l):(r+=u,o+=l)}));return{valueMax:Math.min(i,100-r),valueMin:Math.max(t,100-o),valueNow:e[s]}}function CCe(e,a=document){return Array.from(a.querySelectorAll(`[${xwe}][data-panel-group-id="${e}"]`))}function MCe(e,a,n=document){const t=CCe(e,n).findIndex((e=>e.getAttribute(xwe)===a));return null!=t?t:null}function TCe(e,a,n){const t=MCe(e,a,n);return null!=t?[t,t+1]:[-1,-1]}function ECe(e,a=document){var n;if(a instanceof HTMLElement&&(null==a||null===(n=a.dataset)||void 0===n?void 0:n.panelGroupId)==e)return a;const t=a.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return t||null}function xCe(e,a=document){const n=a.querySelector(`[${xwe}="${e}"]`);return n||null}function NCe({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:i,panelDataArray:r,panelGroupElement:o,setLayout:s}){a.useRef({didWarnAboutMissingResizeHandle:!1}),_we((()=>{if(!o)return;const e=CCe(t,o);for(let a=0;a<r.length-1;a++){const{valueMax:n,valueMin:t,valueNow:o}=wCe({layout:i,panelsArray:r,pivotIndices:[a,a+1]}),s=e[a];if(null==s);else{const e=r[a];fCe(e,`No panel data found for index "${a}"`),s.setAttribute("aria-controls",e.id),s.setAttribute("aria-valuemax",""+Math.round(n)),s.setAttribute("aria-valuemin",""+Math.round(t)),s.setAttribute("aria-valuenow",null!=o?""+Math.round(o):"")}}return()=>{e.forEach(((e,a)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")}))}}),[t,i,r,o]),a.useEffect((()=>{if(!o)return;const e=n.current;fCe(e,"Eager values not found");const{panelDataArray:a}=e;fCe(null!=ECe(t,o),`No group found for id "${t}"`);const r=CCe(t,o);fCe(r,`No resize handles found for group id "${t}"`);const l=r.map((e=>{const n=e.getAttribute(xwe);fCe(n,"Resize handle element has no handle id attribute");const[r,l]=function(e,a,n,t=document){var i,r,o,s;const l=xCe(a,t),u=CCe(e,t),c=l?u.indexOf(l):-1;return[null!==(i=null===(r=n[c])||void 0===r?void 0:r.id)&&void 0!==i?i:null,null!==(o=null===(s=n[c+1])||void 0===s?void 0:s.id)&&void 0!==o?o:null]}(t,n,a,o);if(null==r||null==l)return()=>{};const u=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=a.findIndex((e=>e.id===r));if(l>=0){const e=a[l];fCe(e,`No panel data found for index ${l}`);const r=i[l],{collapsedSize:u=0,collapsible:c,minSize:d=0}=e.constraints;if(null!=r&&c){const e=ACe({delta:bCe(r,u)?d-u:u-r,initialLayout:i,panelConstraints:a.map((e=>e.constraints)),pivotIndices:TCe(t,n,o),prevLayout:i,trigger:"keyboard"});i!==e&&s(e)}}break}}};return e.addEventListener("keydown",u),()=>{e.removeEventListener("keydown",u)}}));return()=>{l.forEach((e=>e()))}}),[o,e,n,t,i,r,s])}function _Ce(e,a){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==a[n])return!1;return!0}function PCe(e,a){const n="horizontal"===e,{x:t,y:i}=Vwe(a);return n?t:i}function LCe(e,a,n,t,i,r){if(Iwe(e)){const a="horizontal"===n;let t=0;t=e.shiftKey?100:null!=i?i:10;let r=0;switch(e.key){case"ArrowDown":r=a?0:t;break;case"ArrowLeft":r=a?-t:0;break;case"ArrowRight":r=a?t:0;break;case"ArrowUp":r=a?0:-t;break;case"End":r=100;break;case"Home":r=-100}return r}return null==t?0:function(e,a,n,t,i){const r="horizontal"===n,o=xCe(a,i);fCe(o,`No resize handle element found for id "${a}"`);const s=o.getAttribute(bwe);fCe(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=t;const u=PCe(n,e),c=ECe(s,i);fCe(c,`No group element found for id "${s}"`);const d=c.getBoundingClientRect();return(u-l)/(r?d.width:d.height)*100}(e,a,n,t,r)}function jCe(e,a,n){a.forEach(((a,t)=>{const i=e[t];fCe(i,`Panel data not found for index ${t}`);const{callbacks:r,constraints:o,id:s}=i,{collapsedSize:l=0,collapsible:u}=o,c=n[s];if(null==c||a!==c){n[s]=a;const{onCollapse:e,onExpand:t,onResize:i}=r;i&&i(a,c),u&&(e||t)&&(!t||null!=c&&!kCe(c,l)||kCe(a,l)||t(),!e||null!=c&&kCe(c,l)||!kCe(a,l)||e())}}))}function BCe(e,a){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=a[n])return!1;return!0}function RCe(e){try{if("undefined"==typeof localStorage)throw new Error("localStorage not supported in this environment");e.getItem=e=>localStorage.getItem(e),e.setItem=(e,a)=>{localStorage.setItem(e,a)}}catch(a){e.getItem=()=>null,e.setItem=()=>{}}}function zCe(e){return`react-resizable-panels:${e}`}function DCe(e){return e.map((e=>{const{constraints:a,id:n,idIsFromProps:t,order:i}=e;return t?n:i?`${i}:${JSON.stringify(a)}`:JSON.stringify(a)})).sort(((e,a)=>e.localeCompare(a))).join(",")}function KCe(e,a){try{const n=zCe(e),t=a.getItem(n);if(t){const e=JSON.parse(t);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function OCe(e,a,n,t,i){var r;const o=zCe(e),s=DCe(a),l=null!==(r=KCe(e,i))&&void 0!==r?r:{};l[s]={expandToSizes:Object.fromEntries(n.entries()),layout:t};try{i.setItem(o,JSON.stringify(l))}catch(u){}}function HCe({layout:e,panelConstraints:a}){const n=[...e],t=n.reduce(((e,a)=>e+a),0);if(n.length!==a.length)throw Error(`Invalid ${a.length} panel layout: ${n.map((e=>`${e}%`)).join(", ")}`);if(!bCe(t,100)&&n.length>0)for(let r=0;r<a.length;r++){const e=n[r];fCe(null!=e,`No layout data found for index ${r}`);n[r]=100/t*e}let i=0;for(let r=0;r<a.length;r++){const e=n[r];fCe(null!=e,`No layout data found for index ${r}`);const t=SCe({panelConstraints:a,panelIndex:r,size:e});e!=t&&(i+=e-t,n[r]=t)}if(!bCe(i,0))for(let r=0;r<a.length;r++){const e=n[r];fCe(null!=e,`No layout data found for index ${r}`);const t=SCe({panelConstraints:a,panelIndex:r,size:e+i});if(e!==t&&(i-=t-e,n[r]=t,bCe(i,0)))break}return n}const ICe={getItem:e=>(RCe(ICe),ICe.getItem(e)),setItem:(e,a)=>{RCe(ICe),ICe.setItem(e,a)}},GCe={};function FCe({autoSaveId:e=null,children:n,className:t="",direction:i,forwardedRef:r,id:o=null,onLayout:s=null,keyboardResizeBy:l=null,storage:u=ICe,style:c,tagName:d="div",...m}){const h=Bwe(o),p=a.useRef(null),[g,v]=a.useState(null),[f,y]=a.useState([]),k=function(){const[e,n]=a.useState(0);return a.useCallback((()=>n((e=>e+1))),[])}(),b=a.useRef({}),S=a.useRef(new Map),A=a.useRef(0),w=a.useRef({autoSaveId:e,direction:i,dragState:g,id:h,keyboardResizeBy:l,onLayout:s,storage:u}),C=a.useRef({layout:f,panelDataArray:[],panelDataArrayChanged:!1});a.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),a.useImperativeHandle(r,(()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:e}=C.current;return e},setLayout:e=>{const{onLayout:a}=w.current,{layout:n,panelDataArray:t}=C.current,i=HCe({layout:e,panelConstraints:t.map((e=>e.constraints))});_Ce(n,i)||(y(i),C.current.layout=i,a&&a(i),jCe(t,i,b.current))}})),[]),_we((()=>{w.current.autoSaveId=e,w.current.direction=i,w.current.dragState=g,w.current.id=h,w.current.onLayout=s,w.current.storage=u})),NCe({committedValuesRef:w,eagerValuesRef:C,groupId:h,layout:f,panelDataArray:C.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),a.useEffect((()=>{const{panelDataArray:a}=C.current;if(e){if(0===f.length||f.length!==a.length)return;let n=GCe[e];null==n&&(n=function(e,a=10){let n=null;return(...t)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...t)}),a)}}(OCe,100),GCe[e]=n);const t=[...a],i=new Map(S.current);n(e,t,i,f,u)}}),[e,f,u]),a.useEffect((()=>{}));const M=a.useCallback((e=>{const{onLayout:a}=w.current,{layout:n,panelDataArray:t}=C.current;if(e.constraints.collapsible){const i=t.map((e=>e.constraints)),{collapsedSize:r=0,panelSize:o,pivotIndices:s}=UCe(t,e,n);if(fCe(null!=o,`Panel size not found for panel "${e.id}"`),!kCe(o,r)){S.current.set(e.id,o);const l=ACe({delta:JCe(t,e)===t.length-1?o-r:r-o,initialLayout:n,panelConstraints:i,pivotIndices:s,prevLayout:n,trigger:"imperative-api"});BCe(n,l)||(y(l),C.current.layout=l,a&&a(l),jCe(t,l,b.current))}}}),[]),T=a.useCallback(((e,a)=>{const{onLayout:n}=w.current,{layout:t,panelDataArray:i}=C.current;if(e.constraints.collapsible){const r=i.map((e=>e.constraints)),{collapsedSize:o=0,panelSize:s=0,minSize:l=0,pivotIndices:u}=UCe(i,e,t),c=null!=a?a:l;if(kCe(s,o)){const a=S.current.get(e.id),o=null!=a&&a>=c?a:c,l=ACe({delta:JCe(i,e)===i.length-1?s-o:o-s,initialLayout:t,panelConstraints:r,pivotIndices:u,prevLayout:t,trigger:"imperative-api"});BCe(t,l)||(y(l),C.current.layout=l,n&&n(l),jCe(i,l,b.current))}}}),[]),E=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{panelSize:t}=UCe(n,e,a);return fCe(null!=t,`Panel size not found for panel "${e.id}"`),t}),[]),x=a.useCallback(((e,a)=>{const{panelDataArray:n}=C.current,t=JCe(n,e);return function({defaultSize:e,dragState:a,layout:n,panelData:t,panelIndex:i,precision:r=3}){const o=n[i];let s;return s=null==o?null!=e?e.toPrecision(r):"1":1===t.length?"1":o.toPrecision(r),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:null!==a?"none":void 0}}({defaultSize:a,dragState:g,layout:f,panelData:n,panelIndex:t})}),[g,f]),N=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{collapsedSize:t=0,collapsible:i,panelSize:r}=UCe(n,e,a);return fCe(null!=r,`Panel size not found for panel "${e.id}"`),!0===i&&kCe(r,t)}),[]),_=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{collapsedSize:t=0,collapsible:i,panelSize:r}=UCe(n,e,a);return fCe(null!=r,`Panel size not found for panel "${e.id}"`),!i||yCe(r,t)>0}),[]),P=a.useCallback((e=>{const{panelDataArray:a}=C.current;a.push(e),a.sort(((e,a)=>{const n=e.order,t=a.order;return null==n&&null==t?0:null==n?-1:null==t?1:n-t})),C.current.panelDataArrayChanged=!0,k()}),[k]);_we((()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:a,storage:n}=w.current,{layout:t,panelDataArray:i}=C.current;let r=null;if(e){const a=function(e,a,n){var t,i;return null!==(i=(null!==(t=KCe(e,n))&&void 0!==t?t:{})[DCe(a)])&&void 0!==i?i:null}(e,i,n);a&&(S.current=new Map(Object.entries(a.expandToSizes)),r=a.layout)}null==r&&(r=function({panelDataArray:e}){const a=Array(e.length),n=e.map((e=>e.constraints));let t=0,i=100;for(let r=0;r<e.length;r++){const e=n[r];fCe(e,`Panel constraints not found for index ${r}`);const{defaultSize:o}=e;null!=o&&(t++,a[r]=o,i-=o)}for(let r=0;r<e.length;r++){const o=n[r];fCe(o,`Panel constraints not found for index ${r}`);const{defaultSize:s}=o;if(null!=s)continue;const l=i/(e.length-t);t++,a[r]=l,i-=l}return a}({panelDataArray:i}));const o=HCe({layout:r,panelConstraints:i.map((e=>e.constraints))});_Ce(t,o)||(y(o),C.current.layout=o,a&&a(o),jCe(i,o,b.current))}})),_we((()=>{const e=C.current;return()=>{e.layout=[]}}),[]);const L=a.useCallback((e=>{let a=!1;const n=p.current;if(n){"rtl"===window.getComputedStyle(n,null).getPropertyValue("direction")&&(a=!0)}return function(n){n.preventDefault();const t=p.current;if(!t)return()=>null;const{direction:i,dragState:r,id:o,keyboardResizeBy:s,onLayout:l}=w.current,{layout:u,panelDataArray:c}=C.current,{initialLayout:d}=null!=r?r:{},m=TCe(o,e,t);let h=LCe(n,e,i,r,s,t);const g="horizontal"===i;g&&a&&(h=-h);const v=ACe({delta:h,initialLayout:null!=d?d:u,panelConstraints:c.map((e=>e.constraints)),pivotIndices:m,prevLayout:u,trigger:Iwe(n)?"keyboard":"mouse-or-touch"}),f=!BCe(u,v);(Gwe(n)||Fwe(n))&&A.current!=h&&(A.current=h,mCe(e,f||0===h?0:g?h<0?Ywe:Qwe:h<0?Xwe:eCe)),f&&(y(v),C.current.layout=v,l&&l(v),jCe(c,v,b.current))}}),[]),j=a.useCallback(((e,a)=>{const{onLayout:n}=w.current,{layout:t,panelDataArray:i}=C.current,r=i.map((e=>e.constraints)),{panelSize:o,pivotIndices:s}=UCe(i,e,t);fCe(null!=o,`Panel size not found for panel "${e.id}"`);const l=ACe({delta:JCe(i,e)===i.length-1?o-a:a-o,initialLayout:t,panelConstraints:r,pivotIndices:s,prevLayout:t,trigger:"imperative-api"});BCe(t,l)||(y(l),C.current.layout=l,n&&n(l),jCe(i,l,b.current))}),[]),B=a.useCallback(((e,a)=>{const{layout:n,panelDataArray:t}=C.current,{collapsedSize:i=0,collapsible:r}=a,{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:u=0}=e.constraints,{panelSize:c}=UCe(t,e,n);null!=c&&(r&&s&&kCe(c,i)?kCe(i,o)||j(e,o):c<u?j(e,u):c>l&&j(e,l))}),[j]),R=a.useCallback(((e,a)=>{const{direction:n}=w.current,{layout:t}=C.current;if(!p.current)return;const i=xCe(e,p.current);fCe(i,`Drag handle element not found for id "${e}"`);const r=PCe(n,a);v({dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:r,initialLayout:t})}),[]),z=a.useCallback((()=>{v(null)}),[]),D=a.useCallback((e=>{const{panelDataArray:a}=C.current,n=JCe(a,e);n>=0&&(a.splice(n,1),delete b.current[e.id],C.current.panelDataArrayChanged=!0,k())}),[k]),K=a.useMemo((()=>({collapsePanel:M,direction:i,dragState:g,expandPanel:T,getPanelSize:E,getPanelStyle:x,groupId:h,isPanelCollapsed:N,isPanelExpanded:_,reevaluatePanelConstraints:B,registerPanel:P,registerResizeHandle:L,resizePanel:j,startDragging:R,stopDragging:z,unregisterPanel:D,panelGroupElement:p.current})),[M,g,i,T,E,x,h,N,_,B,P,L,j,R,z,D]);return a.createElement(fwe.Provider,{value:K},a.createElement(d,{...m,children:n,className:t,id:o,ref:p,style:{...{display:"flex",flexDirection:"horizontal"===i?"row":"column",height:"100%",overflow:"hidden",width:"100%"},...c},[ywe]:"",[kwe]:i,[bwe]:h}))}const VCe=a.forwardRef(((e,n)=>a.createElement(FCe,{...e,forwardedRef:n})));function JCe(e,a){return e.findIndex((e=>e===a||e.id===a.id))}function UCe(e,a,n){const t=JCe(e,a);return{...a.constraints,panelSize:n[t],pivotIndices:t===e.length-1?[t-1,t]:[t,t+1]}}function WCe({children:e=null,className:n="",disabled:t=!1,hitAreaMargins:i,id:r,onBlur:o,onClick:s,onDragging:l,onFocus:u,onPointerDown:c,onPointerUp:d,style:m={},tabIndex:h=0,tagName:p="div",...g}){var v,f;const y=a.useRef(null),k=a.useRef({onClick:s,onDragging:l,onPointerDown:c,onPointerUp:d});a.useEffect((()=>{k.current.onClick=s,k.current.onDragging=l,k.current.onPointerDown=c,k.current.onPointerUp=d}));const b=a.useContext(fwe);if(null===b)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:A,registerResizeHandle:w,startDragging:C,stopDragging:M,panelGroupElement:T}=b,E=Bwe(r),[x,N]=a.useState("inactive"),[_,P]=a.useState(!1),[L,j]=a.useState(null),B=a.useRef({state:x});_we((()=>{B.current.state=x})),a.useEffect((()=>{if(t)j(null);else{const e=w(E);j((()=>e))}}),[t,E,w]);const R=null!==(v=null==i?void 0:i.coarse)&&void 0!==v?v:15,z=null!==(f=null==i?void 0:i.fine)&&void 0!==f?f:5;a.useEffect((()=>{if(t||null==L)return;const e=y.current;fCe(e,"Element ref not attached");let a=!1;return function(e,a,n,t,i){var r;const{ownerDocument:o}=a,s={direction:n,element:a,hitAreaMargins:t,setResizeHandlerState:i},l=null!==(r=iCe.get(o))&&void 0!==r?r:0;return iCe.set(o,l+1),oCe.add(s),gCe(),function(){var a;rCe.delete(e),oCe.delete(s);const n=null!==(a=iCe.get(o))&&void 0!==a?a:1;if(iCe.set(o,n-1),gCe(),1===n&&iCe.delete(o),nCe.includes(s)){const e=nCe.indexOf(s);e>=0&&nCe.splice(e,1),hCe(),i("up",!0,null)}}}(E,e,S,{coarse:R,fine:z},((e,n,t)=>{if(n)switch(e){case"down":{N("drag"),a=!1,fCe(t,'Expected event to be defined for "down" action'),C(E,t);const{onDragging:e,onPointerDown:n}=k.current;null==e||e(!0),null==n||n();break}case"move":{const{state:e}=B.current;a=!0,"drag"!==e&&N("hover"),fCe(t,'Expected event to be defined for "move" action'),L(t);break}case"up":{N("hover"),M();const{onClick:e,onDragging:n,onPointerUp:t}=k.current;null==n||n(!1),null==t||t(),a||null==e||e();break}}else N("inactive")}))}),[R,S,t,z,w,E,L,C,M]),function({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:i}){a.useEffect((()=>{if(e||null==t||null==i)return;const a=xCe(n,i);if(null==a)return;const r=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),t(e);break;case"F6":{e.preventDefault();const t=a.getAttribute(bwe);fCe(t,`No group element found for id "${t}"`);const r=CCe(t,i),o=MCe(t,n,i);fCe(null!==o,`No resize element found for id "${n}"`),r[e.shiftKey?o>0?o-1:r.length-1:o+1<r.length?o+1:0].focus();break}}};return a.addEventListener("keydown",r),()=>{a.removeEventListener("keydown",r)}}),[i,e,n,t])}({disabled:t,handleId:E,resizeHandler:L,panelGroupElement:T});return a.createElement(p,{...g,children:e,className:n,id:r,onBlur:()=>{P(!1),null==o||o()},onFocus:()=>{P(!0),null==u||u()},ref:y,role:"separator",style:{touchAction:"none",userSelect:"none",...m},tabIndex:h,[kwe]:S,[bwe]:A,[Mwe]:"",[Twe]:"drag"===x?"pointer":_?"keyboard":void 0,[Ewe]:!t,[xwe]:E,[Nwe]:x})}FCe.displayName="PanelGroup",VCe.displayName="forwardRef(PanelGroup)",WCe.displayName="PanelResizeHandle";const qCe=({className:e,...a})=>n.jsx(VCe,{className:P$("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...a}),ZCe=zwe,$Ce=({withHandle:e,className:a,...t})=>n.jsx(WCe,{className:P$("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...t,children:e&&n.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:n.jsx(Vc,{className:"h-2.5 w-2.5"})})}),YCe=({copyText:e})=>n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),QCe="rgba(245, 246, 247, 1)",XCe={[ca.SEND_COMMUNICATION]:{color:{bg:QCe},clickable:!0},[ca.WAIT_UNTIL_NEXT_FIXED_TIME]:{color:{bg:QCe},clickable:!1}},eMe={[ca.SEND_COMMUNICATION]:"Send Email & SMS",[ca.WAIT_UNTIL_NEXT_FIXED_TIME]:"Wait"},aMe=({children:e,onClick:a,iconBgColor:t,iconStrokeColor:i,Icon:r,disabled:o=!1,selected:s=!1})=>{const l=r;return n.jsxs(K4.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},style:{backgroundColor:s?t:QCe},onClick:a,className:vm("flex gap-2 items-center rounded-md transition-colors group","p-2 border-2 border-transparent overflow-hidden",!o&&"hover:border-primary cursor-pointer",s&&"border-primary"),children:[n.jsx("div",{className:vm("bg-purple-50 rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 transition-colors",!o&&"group-hover/trigger-audience:bg-background",t),children:n.jsx(l,{className:vm("w-4 h-4 stroke-purple-500 group-hover/trigger-audience:fill-purple-50 transition-colors",i)})}),e]})},nMe=({segmentName:e})=>n.jsx("span",{className:"inline-flex items-center bg-white border border-gray-200 rounded-md px-2 py-0.5 text-sm font-medium shadow-sm",children:e}),tMe=()=>{const e=d5(),{setActionId:t,state:{selectedActionId:i}}=a.useContext(Q4),[r,o]=a.useState(e?.includeSegmentIds||null),[s,l]=a.useState(e?.excludeSegmentIds||null),{segments:u}=t5(),c=a.useCallback((()=>u?.find((e=>e.type===l5.ALL_USERS))),[u]);return a.useEffect((()=>{e&&u&&(null===r&&null===s?(o(e?.includeSegmentIds||null),l(e?.excludeSegmentIds||null),0===e.includeSegmentIds.length&&0===e.excludeSegmentIds.length&&(o([c()?.id||""]),l([]))):(JSON.stringify(e.includeSegmentIds)!==JSON.stringify(r)&&o(e.includeSegmentIds),JSON.stringify(e.excludeSegmentIds)!==JSON.stringify(s)&&l(e.excludeSegmentIds)))}),[e,s,r,u,c]),e&&r&&s?n.jsx(n.Fragment,{children:n.jsx(aMe,{selected:i===bme.EditAudience,iconBgColor:"bg-purple-50",iconStrokeColor:"stroke-purple-500",onClick:()=>{t(bme.EditAudience)},Icon:w5.AudienceIcon,children:n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Lye,{children:"Audience"}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(YCe,{copyText:`Send to all ${_h("engage:user",{count:2})} in ${1===r.length?"this":"these"} ${_h("engage:segment",{count:r.length}).toLowerCase()}`}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map((e=>{const a=u?.find((a=>a.id===e));return a?n.jsx(nMe,{segmentName:a.name},e):null}))})]})]})})}):null},iMe=()=>{const e=d5(),{setActionId:t,state:{selectedActionId:i}}=a.useContext(Q4),{segments:r}=t5(),o=_h(e?.triggerType===sa.TRIGGER_BASED?"engage:automation":"engage:broadcast"),s=`Start this ${o?.toLowerCase()}`;if(!e||!r)return null;return n.jsx(n.Fragment,{children:(()=>{switch(e.triggerType){case sa.TRIGGER_BASED:{if(e.triggerMetadata&&e.triggerMetadata.triggerType!==sa.TRIGGER_BASED||!e.triggerMetadata||e.triggerMetadata.eventName!==la.USER_ENTERS_SEGMENT||!e.triggerMetadata.eventFilter.segment_id)return null;const a=e.triggerMetadata.eventFilter.segment_id,t=r.find((e=>e.id===a))?.name;return t?n.jsx(aMe,{iconBgColor:"bg-amber-100",disabled:!0,iconStrokeColor:"stroke-amber-500",onClick:()=>{},Icon:w5.TriggerIcon,children:n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Lye,{children:s}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(YCe,{copyText:`When ${_h("engage:user").toLowerCase()} joins the`}),n.jsx(nMe,{segmentName:t})]})]})}):null}case sa.ONE_TIME:{const a=!e.triggerMetadata||!("scheduledAt"in e.triggerMetadata);return n.jsxs(aMe,{iconBgColor:"bg-amber-100",iconStrokeColor:"stroke-amber-500",onClick:()=>{t(bme.EditTime)},selected:i===bme.EditTime,Icon:w5.TriggerIcon,children:[n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Lye,{children:s}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(YCe,a?{copyText:`Click to set the date and time for this ${_h("engage:broadcast")}`}:{copyText:"Bulk send at"}),!1===a&&e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&e.triggerMetadata.scheduledAt&&n.jsx("div",{className:"text-xs font-medium",children:n.jsx(nMe,{segmentName:"now"===e.triggerMetadata.scheduledAt?"5 minutes after send":eue(new Date(e.triggerMetadata.scheduledAt),"h:mma MM/dd/yy")})})]})]}),n.jsx("div",{className:"",children:a&&n.jsx(pue,{title:`Please select a time before sending this ${_h("engage:broadcast")}.`,alertText:`A scheduled time is needed before sending this ${_h("engage:broadcast")}.`,Icon:w5.AlertTriangleIcon,iconColor:"text-red-500",size:"large"})})]})}default:throw ire(e.triggerType,sa)}})()})},rMe=({type:e,disabled:t=!1,actionId:i})=>{const{state:{selectedSubStepType:r},setSelectedSubStepType:o,setActionId:s}=a.useContext(Q4),l=m5(),u=r===e,c=a.useCallback((()=>{if(!l)return"Need to select a channel";switch(e){case Sme.EMAIL:return l.emailChannelSenderId?l.emailHtmlBody?!!l.emailSubject||"Please add a subject to the email":"Please add content to the email":"Please select a email sender";case Sme.SMS:return l.smsChannelSenderId?!!l.smsMessageBody||"Please add content to the sms":"Please select a sms sender"}}),[l,e]);if(t)return null;const d=c();return n.jsx(K4.div,{layout:!0,initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15,ease:"easeInOut"},className:vm("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group","border-2 border-transparent",u&&"border-primary",!t&&"hover:border-muted-foreground/30",t&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:u?"#f5f6f7":QCe},onClick:()=>{t||(s(i),o(e))},children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"rounded-md p-1.5 flex items-center justify-center w-6 h-6 flex-shrink-0 bg-white border",children:((e,a)=>{switch(e){case Sme.EMAIL:return n.jsx(w5.EmailIcon,{className:vm("w-6 h-6",a?"text-primary":"text-gray-400")});case Sme.SMS:return n.jsx(w5.SmsIcon,{className:vm("w-6 h-6",a?"text-primary":"text-gray-400")})}})(e,u)}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("div",{style:{color:u?"#3b82f6":"#64748b"},children:n.jsx(Lye,{className:"text-xs",children:(()=>{switch(e){case Sme.EMAIL:return"Email";case Sme.SMS:return"SMS"}})()})}),n.jsx("div",{className:"text-[10px] font-medium text-muted-foreground",children:(()=>{if(!l)return"";switch(e){case Sme.EMAIL:return l.emailSubject||"No subject set";case Sme.SMS:return l.smsMessageBody?`${l.smsMessageBody.substring(0,40)}${l.smsMessageBody.length>40?"...":""}`:"No message set"}})()}),!0!==d&&n.jsx("div",{className:"text-[10px] text-amber-600 font-medium",children:d})]})]})})},oMe=e=>{switch(e){case ca.SEND_COMMUNICATION:return"Send Communication";case ca.WAIT_UNTIL_NEXT_FIXED_TIME:return"Wait";default:throw U4(e,ca)}},sMe=e=>{switch(e){case ca.SEND_COMMUNICATION:return n.jsx(w5.CommunicationIcon,{className:"w-4 h-4"});case ca.WAIT_UNTIL_NEXT_FIXED_TIME:return n.jsx(w5.WaitUntilNextFixedTimeIcon,{className:"w-4 h-4"});default:throw ire(e,ca)}},lMe=e=>{if(!(e&&e.actionType===ca.WAIT_UNTIL_NEXT_FIXED_TIME&&"hour"in e&&"minute"in e&&"timezone"in e))return null;const{hour:a,minute:n,timezone:t}=e;return`Wait until next ${`${a?.toString().padStart(2,"0")}:${n?.toString().padStart(2,"0")}`} ${t}`},uMe=({actionDataWithMetadata:e})=>{const{actionData:t,communicationGroup:i}=e,{state:{selectedActionId:r},setActionId:o,setSelectedCommunicationGroupId:s}=a.useContext(Q4),l=a.useMemo((()=>r===t.actionMetadata.currentActionId),[r,t.actionMetadata.currentActionId]),u=XCe[t.actionType],c=u.color,d=u.clickable;return n.jsxs(K4.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},className:vm("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group"," border-2 border-transparent",l&&"border-primary",t.actionType!==ca.WAIT_UNTIL_NEXT_FIXED_TIME&&"hover:border-primary"),style:{backgroundColor:l?c.bg:c.bgUnselected??QCe},onClick:()=>{d&&(o(t.actionMetadata.currentActionId),t.actionType===ca.SEND_COMMUNICATION&&s(t.actionMetadata.communicationGroupId))},children:[n.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[n.jsx("div",{className:"rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 bg-white",children:sMe(t.actionType)}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{style:{color:l?c.text:c.textUnselected},children:n.jsx(Lye,{children:eMe[t.actionType]})}),n.jsx("div",t.actionType===ca.WAIT_UNTIL_NEXT_FIXED_TIME?{className:"text-[11px] text-muted-foreground font-normal rounded bg-muted/40 w-fit max-w-full truncate",children:lMe(t.actionMetadata)}:{className:"text-xs font-medium text-muted-foreground",children:t.actionType===ca.SEND_COMMUNICATION&&i?.emailSubject?i?.emailSubject:oMe(t.actionType)})]})]}),t.actionType===ca.SEND_COMMUNICATION&&n.jsx("div",{className:"flex items-center pr-2",children:n.jsx(w5.NextButton,l?{className:"w-4 h-4 text-muted-foreground rotate-90 transition-transform duration-200"}:{className:"w-4 h-4 text-muted-foreground transition-transform duration-200"})})]})},cMe=()=>{const e=m5(),[t,i]=a.useState(!1),[r,o]=a.useState(void 0),s=d5(),{setActionId:l,setSelectedSubStepType:u,state:{selectedActionId:c,selectedSubStepType:d}}=a.useContext(Q4);if(ta(s?.id||""),a.useEffect((()=>{if(!s)return;if(c)return;const e=s.actionData?.find((e=>"send_communication"===e.actionType));e&&l(e.actionMetadata.currentActionId)}),[s,l,c]),a.useEffect((()=>{if(!s)return;(async()=>{const e=[];for(const a of s.actionData??[])switch(a.actionType){case ca.SEND_COMMUNICATION:{const n=await Fe(a.actionMetadata.communicationGroupId);e.push({actionData:a,communicationGroup:n});break}case ca.WAIT_UNTIL_NEXT_FIXED_TIME:e.push({actionData:a});break;default:throw U4(a.actionType,ca)}o(e)})()}),[s]),a.useEffect((()=>{if(c&&r&&e&&null===d){const a=r.find((e=>e.actionData.actionMetadata.currentActionId===c));"send_communication"===a?.actionData.actionType&&u(e?.emailChannelSenderId?Sme.EMAIL:Sme.SMS)}}),[c,r,u,e,d]),!s||!r)return null;const m=(e=>{const{steps:a,rootActionId:n}=e;if(!a||!n)return a??[];const t=new Map(a.map((e=>[e.actionData.actionMetadata.currentActionId,e]))),i=t.get(n);if(!i)return a;const r=[];let o=i;for(;o;){r.push(o);const e=o.actionData.actionMetadata.nextActionId;if(!e)break;o=t.get(e)}return r})({steps:r,rootActionId:s.triggerMetadata?.triggerType===sa.TRIGGER_BASED?s.triggerMetadata.rootActionId:void 0}).filter((e=>!!t||"send_communication"===e.actionData.actionType));let h=()=>n.jsx("div",{},"empty-trigger-audience");return(t||s.triggerType===sa.ONE_TIME)&&(h=()=>n.jsxs("div",{className:"flex flex-col gap-3",children:[s.triggerType===sa.ONE_TIME&&n.jsx(tMe,{}),s.triggerType!==sa.ONE_TIME&&n.jsx(iMe,{})]})),n.jsxs("div",{className:"flex-1 flex flex-col gap-2 w-full overflow-visible",children:[s.triggerType===sa.TRIGGER_BASED&&n.jsxs("div",{className:"flex gap-2 items-center justify-between",children:[n.jsx("div",{className:"text-[13px] text-muted-foreground",children:"Messages sent in listed order"}),n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx("div",{className:"text-[13px] font-medium",children:"Show all details"}),n.jsx(XSe,{defaultChecked:t,onCheckedChange:()=>{i(!t)}})]})]}),n.jsx("div",{className:"flex-1 flex flex-col gap-3",children:n.jsxs(eY,{mode:"popLayout",children:[h(),m.map(((a,t)=>n.jsx(K4.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,delay:.05*t,ease:"easeInOut"},children:n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(uMe,{actionDataWithMetadata:a}),"send_communication"===a.actionData.actionType&&c===a.actionData.actionMetadata.currentActionId&&a.actionData.actionMetadata.currentActionId&&n.jsxs("div",{className:"flex gap-3",children:[n.jsx(K4.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,delay:.25*m.length,ease:"easeInOut"},className:"w-12 flex justify-end items-center",children:n.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full rounded-full"})}),n.jsxs("div",{className:"flex flex-col gap-3 flex-1",children:[e?.emailChannelSenderId&&n.jsx(rMe,{type:Sme.EMAIL,actionId:a.actionData.actionMetadata.currentActionId}),e?.smsChannelSenderId&&n.jsx(rMe,{type:Sme.SMS,actionId:a.actionData.actionMetadata.currentActionId})]})]})]})},a.actionData.actionMetadata?.currentActionId??t))),s.triggerType===sa.ONE_TIME&&n.jsx("div",{className:"flex flex-col gap-3",children:n.jsx(iMe,{})},"one-time-trigger")]})})]})},dMe=()=>{const e=d5(),{segments:a}=t5();return n.jsx("div",e&&a?{className:"h-full pt-4 relative",children:n.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col gap-3",children:n.jsx(cMe,{})})}:{className:"flex h-full items-center justify-center",children:n.jsx(v5,{text:[`Getting details on your ${_h("engage:automation",{count:1}).toLowerCase()}`,"Finishing up"]})})},mMe=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1,hideSms:r=!1})=>{const{state:{selectedSubStepType:o}}=a.useContext(Q4);if(!m5())return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx(v5,{text:["Loading..."]})});if(!o)return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"text-center",children:[n.jsx("h3",{className:"text-lg font-medium text-muted-foreground mb-2",children:"Select Communication Type"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose Email or SMS from the steps on the left to preview and edit content"})]})})});const s={disablePreview:e,disableEditContent:t,disablePreviewSubtext:i};return n.jsxs("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:[o===Sme.EMAIL&&n.jsx(Sye,{...s}),o===Sme.SMS&&!r&&n.jsx(Mye,{...s})]})},hMe=()=>{const{state:{selectedActionId:e}}=a.useContext(Q4),{state:{hideSms:t}}=a.useContext(uq);return n.jsx("div",{className:"flex flex-col gap-4 h-full w-full",children:n.jsx(eY,{mode:"wait",children:e===bme.EditTime?n.jsx(RSe,{}):e===bme.EditAudience?n.jsx(fAe,{}):n.jsx(mMe,{hideSms:t})})})},pMe=()=>n.jsxs(qCe,{direction:"horizontal",className:"flex-1",children:[n.jsx(ZCe,{defaultSize:30,minSize:16,maxSize:48,children:n.jsx("aside",{className:"h-full",children:n.jsx(dMe,{})})}),n.jsx($Ce,{className:"px-1 opacity-0 hover:opacity-100 transition-opacity duration-200 mx-1"}),n.jsx(ZCe,{defaultSize:70,children:n.jsx("main",{className:"h-full",children:n.jsx(hMe,{})})})]}),gMe=()=>{const[e,t]=a.useState("workflow"),i=[{id:"workflow",label:"Workflow",content:n.jsx(pMe,{})},{id:"recipients",label:"Recipients",content:n.jsx(vwe,{})},{id:"insights",label:_h("engage:insight",{count:2}),content:n.jsx(pwe,{})}];return n.jsx(PAe,{tabs:i,activeTab:e,onTabChange:t,tabsLocation:"left"})},vMe=({showBackButton:e=!1,onDuplicationCreated:t,onBeforeSchedule:i,getExtraMergeFields:r,hideSms:o,hideSales:s,replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d})=>{const m=d5(),h=m5(),{updateCommunicationGroup:p}=$e(),{toast:g}=Ge(),{channelSenders:v}=fre(),f=a.useRef("");return a.useEffect((()=>{if(h&&r){(async()=>{const e=await r(),a=JSON.stringify(e);a!==f.current&&(f.current=a,p({groupId:h?.id,params:{extraMergeFields:e}},{onError:()=>{g({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}}))})()}}),[h,r,p,g]),a.useEffect((()=>{if(m&&h&&v&&m.automationType===ua.MANAGED&&null===h.emailChannelSenderId&&null===h.smsChannelSenderId){if(!h.emailChannelSenderId){const e=v.results.filter((e=>e.channelSenderMetadata.userPart));e.length>0&&p({groupId:h.id,params:{emailChannelSenderId:e[0].id}})}if(!h.smsChannelSenderId){const e=v.results.filter((e=>e.channelSenderMetadata.from||e.channelSenderMetadata.messageServiceSid));e.length>0&&p({groupId:h.id,params:{smsChannelSenderId:e[0].id}})}}}),[m,h,v,p]),m&&h?n.jsx(cq,{children:n.jsx(dq,{replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d,hideSms:o,hideSales:s,children:n.jsxs("div",{className:"h-full flex flex-col gap-4",children:[n.jsx(hwe,{showBackButton:e,onDuplicationCreated:t,onBeforeSchedule:i}),n.jsx("div",{className:"flex-1 border-t",children:n.jsx(gMe,{})})]})})}):n.jsx("div",{className:"flex h-screen items-center justify-center",children:n.jsx(v5,{text:[`Fetching ${_h("engage:automation").toLowerCase()} data`,"Finishing up"]})})},fMe=({...e})=>{const a=function(){let{matches:e}=r.useContext(Gne),a=e[e.length-1];return a?a.params:{}}(),[t]=Lte(),i=e.automationId||a?.automationId||t.get("automationId")||"",o="true"===t.get("showBackButton")||e.showBackButton;return n.jsx(p5,{automationId:i,children:n.jsx("div",{className:"bg-background h-full",children:n.jsx(vMe,{...e,showBackButton:o})})})};Object.values(Object.assign({}));var yMe=e=>null!=e;var kMe=e=>"function"!=typeof e||e.length?e:e(),bMe=e=>Array.isArray(e)?e:e?[e]:[];var SMe=Ha;var AMe,wMe=function(e){const[a,n]=Pa(),t=e?.throw?(e,a)=>{throw n(e instanceof Error?e:new Error(a)),e}:(e,a)=>{n(e instanceof Error?e:new Error(a))},i=e?.api?Array.isArray(e.api)?e.api:[e.api]:[globalThis.localStorage].filter(Boolean),r=e?.prefix?`${e.prefix}.`:"",o=new Map,s=new Proxy({},{get(a,n){let s=o.get(n);s||(s=Pa(void 0,{equals:!1}),o.set(n,s)),s[0]();const l=i.reduce(((e,a)=>{if(null!==e||!a)return e;try{return a.getItem(`${r}${n}`)}catch(QHe){return t(QHe,`Error reading ${r}${n} from ${a.name}`),null}}),null);return null!==l&&e?.deserializer?e.deserializer(l,n,e.options):l}});return!1!==e?.sync&&Oa((()=>{const e=e=>{let a=!1;i.forEach((n=>{try{n!==e.storageArea&&e.key&&e.newValue!==n.getItem(e.key)&&(e.newValue?n.setItem(e.key,e.newValue):n.removeItem(e.key),a=!0)}catch(QHe){t(QHe,`Error synching api ${n.name} from storage event (${e.key}=${e.newValue})`)}})),a&&e.key&&o.get(e.key)?.[1]()};"addEventListener"in globalThis?(globalThis.addEventListener("storage",e),Ha((()=>globalThis.removeEventListener("storage",e)))):(i.forEach((a=>a.addEventListener?.("storage",e))),Ha((()=>i.forEach((a=>a.removeEventListener?.("storage",e))))))})),[s,(a,n,s)=>{const l=e?.serializer?e.serializer(n,a,s??e.options):n,u=`${r}${a}`;i.forEach((e=>{try{e.getItem(u)!==l&&e.setItem(u,l)}catch(QHe){t(QHe,`Error setting ${r}${a} to ${l} in ${e.name}`)}}));const c=o.get(a);c&&c[1]()},{clear:()=>i.forEach((e=>{try{e.clear()}catch(QHe){t(QHe,`Error clearing ${e.name}`)}})),error:a,remove:e=>i.forEach((a=>{try{a.removeItem(`${r}${e}`)}catch(QHe){t(QHe,`Error removing ${r}${e} from ${a.name}`)}})),toJSON:()=>{const a={},n=(n,t)=>{if(!a.hasOwnProperty(n)){const i=t&&e?.deserializer?e.deserializer(t,n,e.options):t;i&&(a[n]=i)}};return i.forEach((e=>{if("function"==typeof e.getAll){let a;try{a=e.getAll()}catch(QHe){t(QHe,`Error getting all values from in ${e.name}`)}for(const e of a)n(e,a[e])}else{let i,r=0;try{for(;i=e.key(r++);)a.hasOwnProperty(i)||n(i,e.getItem(i))}catch(QHe){t(QHe,`Error getting all values from ${e.name}`)}}})),a}}]},CMe=e=>{if(!e)return"";let a="";for(const n in e){if(!e.hasOwnProperty(n))continue;const t=e[n];a+=t instanceof Date?`; ${n}=${t.toUTCString()}`:"boolean"==typeof t?`; ${n}`:`; ${n}=${t}`}return a},MMe=("function"==typeof(AMe={_cookies:[globalThis.document,"cookie"],getItem:e=>MMe._cookies[0][MMe._cookies[1]].match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)")?.pop()??null,setItem:(e,a,n)=>{const t=MMe.getItem(e);MMe._cookies[0][MMe._cookies[1]]=`${e}=${a}${CMe(n)}`;const i=Object.assign(new Event("storage"),{key:e,oldValue:t,newValue:a,url:globalThis.document.URL,storageArea:MMe});window.dispatchEvent(i)},removeItem:e=>{MMe._cookies[0][MMe._cookies[1]]=`${e}=deleted${CMe({expires:new Date(0)})}`},key:e=>{let a=null,n=0;return MMe._cookies[0][MMe._cookies[1]].replace(/(?:^|;)\s*(.+?)\s*=\s*[^;]+/g,((t,i)=>(!a&&i&&n++===e&&(a=i),""))),a},get length(){let e=0;return MMe._cookies[0][MMe._cookies[1]].replace(/(?:^|;)\s*.+?\s*=\s*[^;]+/g,(a=>(e+=a?1:0,""))),e}}).clear||(AMe.clear=()=>{let e;for(;e=AMe.key(0);)AMe.removeItem(e)}),AMe),TMe=796,EMe="bottom",xMe="system",NMe=Object.keys(Xt)[0],_Me=Object.keys(ni)[0],PMe=Ja({client:void 0,onlineManager:void 0,queryFlavor:"",version:"",shadowDOMTarget:void 0});function LMe(){return Ua(PMe)}var jMe=Ja(void 0),BMe=e=>{const[a,n]=Pa(null),t=()=>{const e=a();null!=e&&(e.close(),n(null))},i=(t,i)=>{if(null!=a())return;const r=window.open("","TSQD-Devtools-Panel",`width=${t},height=${i},popup`);if(!r)throw new Error("Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.");r.document.head.innerHTML="",r.document.body.innerHTML="",function(e=window.document){if(e[Rn]){for(let a of e[Rn].keys())e.removeEventListener(a,Zn);delete e[Rn]}}(r.document),r.document.title="TanStack Query Devtools",r.document.body.style.margin="0",r.addEventListener("pagehide",(()=>{e.setLocalStore("pip_open","false"),n(null)})),[...(LMe().shadowDOMTarget||document).styleSheets].forEach((e=>{try{const a=[...e.cssRules].map((e=>e.cssText)).join(""),n=document.createElement("style"),t=e.ownerNode;let i="";t&&"id"in t&&(i=t.id),i&&n.setAttribute("id",i),n.textContent=a,r.document.head.appendChild(n)}catch(YHe){const n=document.createElement("link");if(null==e.href)return;n.rel="stylesheet",n.type=e.type,n.media=e.media.toString(),n.href=e.href,r.document.head.appendChild(n)}})),Kn(["focusin","focusout","pointermove","keydown","pointerdown","pointerup","click","mousedown","input"],r.document),e.setLocalStore("pip_open","true"),n(r)};Ba((()=>{"true"!==(e.localStore.pip_open??"false")||e.disabled||i(Number(window.innerWidth),Number(e.localStore.height||500))})),Ba((()=>{const e=(LMe().shadowDOMTarget||document).querySelector("#_goober"),n=a();if(e&&n){const a=new MutationObserver((()=>{const a=(LMe().shadowDOMTarget||n.document).querySelector("#_goober");a&&(a.textContent=e.textContent)}));a.observe(e,{childList:!0,subtree:!0,characterDataOldValue:!0}),Ha((()=>{a.disconnect()}))}}));const r=Ra((()=>({pipWindow:a(),requestPipWindow:i,closePipWindow:t,disabled:e.disabled??!1})));return mn(jMe.Provider,{value:r,get children(){return e.children}})},RMe=()=>Ra((()=>{const e=Ua(jMe);if(!e)throw new Error("usePiPWindow must be used within a PiPProvider");return e()})),zMe=Ja((()=>"dark"));function DMe(){return Ua(zMe)}var KMe={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Ấ":"A","Ắ":"A","Ẳ":"A","Ẵ":"A","Ặ":"A","Æ":"AE","Ầ":"A","Ằ":"A","Ȃ":"A","Ç":"C","Ḉ":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ế":"E","Ḗ":"E","Ề":"E","Ḕ":"E","Ḝ":"E","Ȇ":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ḯ":"I","Ȋ":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ố":"O","Ṍ":"O","Ṓ":"O","Ȏ":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","ấ":"a","ắ":"a","ẳ":"a","ẵ":"a","ặ":"a","æ":"ae","ầ":"a","ằ":"a","ȃ":"a","ç":"c","ḉ":"c","è":"e","é":"e","ê":"e","ë":"e","ế":"e","ḗ":"e","ề":"e","ḕ":"e","ḝ":"e","ȇ":"e","ì":"i","í":"i","î":"i","ï":"i","ḯ":"i","ȋ":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ố":"o","ṍ":"o","ṓ":"o","ȏ":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","C̆":"C","c̆":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","Ǵ":"G","ĝ":"g","ǵ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ḫ":"H","ḫ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","Ḱ":"K","ḱ":"k","K̆":"K","k̆":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"l","ł":"l","Ḿ":"M","ḿ":"m","M̆":"M","m̆":"m","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"n","N̆":"N","n̆":"n","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","P̆":"P","p̆":"p","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","R̆":"R","r̆":"r","Ȓ":"R","ȓ":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","Ș":"S","ș":"s","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","ț":"t","Ț":"T","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","T̆":"T","t̆":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ȗ":"U","ȗ":"u","V̆":"V","v̆":"v","Ŵ":"W","ŵ":"w","Ẃ":"W","ẃ":"w","X̆":"X","x̆":"x","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Y̆":"Y","y̆":"y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ſ":"s","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Ǎ":"A","ǎ":"a","Ǐ":"I","ǐ":"i","Ǒ":"O","ǒ":"o","Ǔ":"U","ǔ":"u","Ǖ":"U","ǖ":"u","Ǘ":"U","ǘ":"u","Ǚ":"U","ǚ":"u","Ǜ":"U","ǜ":"u","Ứ":"U","ứ":"u","Ṹ":"U","ṹ":"u","Ǻ":"A","ǻ":"a","Ǽ":"AE","ǽ":"ae","Ǿ":"O","ǿ":"o","Þ":"TH","þ":"th","Ṕ":"P","ṕ":"p","Ṥ":"S","ṥ":"s","X́":"X","x́":"x","Ѓ":"Г","ѓ":"г","Ќ":"К","ќ":"к","A̋":"A","a̋":"a","E̋":"E","e̋":"e","I̋":"I","i̋":"i","Ǹ":"N","ǹ":"n","Ồ":"O","ồ":"o","Ṑ":"O","ṑ":"o","Ừ":"U","ừ":"u","Ẁ":"W","ẁ":"w","Ỳ":"Y","ỳ":"y","Ȁ":"A","ȁ":"a","Ȅ":"E","ȅ":"e","Ȉ":"I","ȉ":"i","Ȍ":"O","ȍ":"o","Ȑ":"R","ȑ":"r","Ȕ":"U","ȕ":"u","B̌":"B","b̌":"b","Č̣":"C","č̣":"c","Ê̌":"E","ê̌":"e","F̌":"F","f̌":"f","Ǧ":"G","ǧ":"g","Ȟ":"H","ȟ":"h","J̌":"J","ǰ":"j","Ǩ":"K","ǩ":"k","M̌":"M","m̌":"m","P̌":"P","p̌":"p","Q̌":"Q","q̌":"q","Ř̩":"R","ř̩":"r","Ṧ":"S","ṧ":"s","V̌":"V","v̌":"v","W̌":"W","w̌":"w","X̌":"X","x̌":"x","Y̌":"Y","y̌":"y","A̧":"A","a̧":"a","B̧":"B","b̧":"b","Ḑ":"D","ḑ":"d","Ȩ":"E","ȩ":"e","Ɛ̧":"E","ɛ̧":"e","Ḩ":"H","ḩ":"h","I̧":"I","i̧":"i","Ɨ̧":"I","ɨ̧":"i","M̧":"M","m̧":"m","O̧":"O","o̧":"o","Q̧":"Q","q̧":"q","U̧":"U","u̧":"u","X̧":"X","x̧":"x","Z̧":"Z","z̧":"z"},OMe=Object.keys(KMe).join("|"),HMe=new RegExp(OMe,"g");var IMe=7,GMe=6,FMe=5,VMe=4,JMe=3,UMe=2,WMe=1,qMe=0;function ZMe(e,a,n){var t;if((n=n||{}).threshold=null!=(t=n.threshold)?t:WMe,!n.accessors){const t=$Me(e,a,n);return{rankedValue:e,rank:t,accessorIndex:-1,accessorThreshold:n.threshold,passed:t>=n.threshold}}const i=function(e,a){const n=[];for(let t=0,i=a.length;t<i;t++){const i=a[t],r=eTe(i),o=QMe(e,i);for(let e=0,a=o.length;e<a;e++)n.push({itemValue:o[e],attributes:r})}return n}(e,n.accessors),r={rankedValue:e,rank:qMe,accessorIndex:-1,accessorThreshold:n.threshold,passed:!1};for(let o=0;o<i.length;o++){const e=i[o];let t=$Me(e.itemValue,a,n);const{minRanking:s,maxRanking:l,threshold:u=n.threshold}=e.attributes;t<s&&t>=WMe?t=s:t>l&&(t=l),t=Math.min(t,l),t>=u&&t>r.rank&&(r.rank=t,r.passed=!0,r.accessorIndex=o,r.accessorThreshold=u,r.rankedValue=e.itemValue)}return r}function $Me(e,a,n){return e=YMe(e,n),(a=YMe(a,n)).length>e.length?qMe:e===a?IMe:(e=e.toLowerCase())===(a=a.toLowerCase())?GMe:e.startsWith(a)?FMe:e.includes(` ${a}`)?VMe:e.includes(a)?JMe:1===a.length?qMe:function(e){let a="";return e.split(" ").forEach((e=>{e.split("-").forEach((e=>{a+=e.substr(0,1)}))})),a}(e).includes(a)?UMe:function(e,a){let n=0,t=0;function i(e,a,t){for(let i=t,r=a.length;i<r;i++){if(a[i]===e)return n+=1,i+1}return-1}function r(e){return WMe+n/a.length*(1/e)}const o=i(a[0],e,0);if(o<0)return qMe;t=o;for(let s=1,l=a.length;s<l;s++){t=i(a[s],e,t);if(!(t>-1))return qMe}return r(t-o)}(e,a)}function YMe(e,a){let{keepDiacritics:n}=a;return e=`${e}`,n||(e=e.replace(HMe,(e=>KMe[e]))),e}function QMe(e,a){let n=a;"object"==typeof a&&(n=a.accessor);const t=n(e);return null==t?[]:Array.isArray(t)?t:[String(t)]}var XMe={maxRanking:1/0,minRanking:-1/0};function eTe(e){return"function"==typeof e?XMe:{...XMe,...e}}var aTe={data:""},nTe=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,tTe=/\/\*[^]*?\*\/| +/g,iTe=/\n+/g,rTe=(e,a)=>{let n="",t="",i="";for(let r in e){let o=e[r];"@"==r[0]?"i"==r[1]?n=r+" "+o+";":t+="f"==r[1]?rTe(o,r):r+"{"+rTe(o,"k"==r[1]?"":a)+"}":"object"==typeof o?t+=rTe(o,a?a.replace(/([^,])+/g,(e=>r.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,(a=>/&/.test(a)?a.replace(/&/g,e):e?e+" "+a:a)))):r):null!=o&&(r=/^--/.test(r)?r:r.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=rTe.p?rTe.p(r,o):r+":"+o+";")}return n+(a&&i?a+"{"+i+"}":i)+t},oTe={},sTe=e=>{if("object"==typeof e){let a="";for(let n in e)a+=n+sTe(e[n]);return a}return e};function lTe(e){let a=this||{},n=e.call?e(a.p):e;return((e,a,n,t,i)=>{let r=sTe(e),o=oTe[r]||(oTe[r]=(e=>{let a=0,n=11;for(;a<e.length;)n=101*n+e.charCodeAt(a++)>>>0;return"go"+n})(r));if(!oTe[o]){let a=r!==e?e:(e=>{let a,n,t=[{}];for(;a=nTe.exec(e.replace(tTe,""));)a[4]?t.shift():a[3]?(n=a[3].replace(iTe," ").trim(),t.unshift(t[0][n]=t[0][n]||{})):t[0][a[1]]=a[2].replace(iTe," ").trim();return t[0]})(e);oTe[o]=rTe(i?{["@keyframes "+o]:a}:a,n?"":"."+o)}let s=n&&oTe.g?oTe.g:null;return n&&(oTe.g=oTe[o]),l=oTe[o],u=a,c=t,(d=s)?u.data=u.data.replace(d,l):-1===u.data.indexOf(l)&&(u.data=c?l+u.data:u.data+l),o;var l,u,c,d})(n.unshift?n.raw?((e,a,n)=>e.reduce(((e,t,i)=>{let r=a[i];if(r&&r.call){let e=r(n),a=e&&e.props&&e.props.className||/^go/.test(e)&&e;r=a?"."+a:e&&"object"==typeof e?e.props?"":rTe(e,""):!1===e?"":e}return e+t+(null==r?"":r)}),""))(n,[].slice.call(arguments,1),a.p):n.reduce(((e,n)=>Object.assign(e,n&&n.call?n(a.p):n)),{}):n,(e=>"object"==typeof window?((e?e.querySelector("#_goober"):window._goober)||Object.assign((e||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:e||aTe)(a.target),a.g,a.o,a.k)}function uTe(e){var a,n,t="";if("string"==typeof e||"number"==typeof e)t+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(a=0;a<i;a++)e[a]&&(n=uTe(e[a]))&&(t&&(t+=" "),t+=n)}else for(n in e)e[n]&&(t&&(t+=" "),t+=n);return t}function cTe(){for(var e,a,n=0,t="",i=arguments.length;n<i;n++)(e=arguments[n])&&(a=uTe(e))&&(t&&(t+=" "),t+=a);return t}function dTe(e,a){const n=Da(e),{onChange:t}=a;let i=new Set(a.appear?void 0:n);const r=new WeakSet,[o,s]=Pa([],{equals:!1}),[l]=[Fa,Ga],u=e=>{s((a=>(a.push.apply(a,e),a)));for(const a of e)r.delete(a)},c=(e,a,n)=>e.splice(n,0,a);return Ra((a=>{const n=o(),s=e();if(Da(l))return l(),a;if(n.length){const e=a.filter((e=>!n.includes(e)));return n.length=0,t({list:e,added:[],removed:[],unchanged:e,finishRemoved:u}),e}return Da((()=>{const e=new Set(s),n=s.slice(),o=[],l=[],d=[];for(const a of s)(i.has(a)?d:o).push(a);let m=!o.length;for(let t=0;t<a.length;t++){const i=a[t];e.has(i)||(r.has(i)||(l.push(i),r.add(i)),c(n,i,t)),m&&i!==n[t]&&(m=!1)}return!l.length&&m?a:(t({list:n,added:o,removed:l,unchanged:d,finishRemoved:u}),i=e,n)}))}),a.appear?[]:n.slice())}function mTe(...e){return a=e,(...e)=>{for(const n of a)n&&n(...e)};var a}lTe.bind({g:1}),lTe.bind({k:1});var hTe=e=>e instanceof Element;function pTe(e,a){if(a(e))return e;if("function"==typeof e&&!e.length)return pTe(e(),a);if(Array.isArray(e)){const n=[];for(const t of e){const e=pTe(t,a);e&&(Array.isArray(e)?n.push.apply(n,e):n.push(e))}return n.length?n:null}return null}function gTe(e,a=hTe,n=hTe){const t=Ra(e),i=Ra((()=>pTe(t(),a)));return i.toArray=()=>{const e=i();return Array.isArray(e)?e:e?[e]:[]},i}function vTe(e){requestAnimationFrame((()=>requestAnimationFrame(e)))}function fTe(e,a,n,t){const{onBeforeEnter:i,onEnter:r,onAfterEnter:o}=a;function s(a){a&&a.target!==n||(n.removeEventListener("transitionend",s),n.removeEventListener("animationend",s),n.classList.remove(...e.enterActive),n.classList.remove(...e.enterTo),o?.(n))}i?.(n),n.classList.add(...e.enter),n.classList.add(...e.enterActive),queueMicrotask((()=>{if(!n.parentNode)return t?.();r?.(n,(()=>s()))})),vTe((()=>{n.classList.remove(...e.enter),n.classList.add(...e.enterTo),(!r||r.length<2)&&(n.addEventListener("transitionend",s),n.addEventListener("animationend",s))}))}function yTe(e,a,n,t){const{onBeforeExit:i,onExit:r,onAfterExit:o}=a;if(!n.parentNode)return t?.();function s(a){a&&a.target!==n||(t?.(),n.removeEventListener("transitionend",s),n.removeEventListener("animationend",s),n.classList.remove(...e.exitActive),n.classList.remove(...e.exitTo),o?.(n))}i?.(n),n.classList.add(...e.exit),n.classList.add(...e.exitActive),r?.(n,(()=>s())),vTe((()=>{n.classList.remove(...e.exit),n.classList.add(...e.exitTo),(!r||r.length<2)&&(n.addEventListener("transitionend",s),n.addEventListener("animationend",s))}))}var kTe=e=>{const a=function(e){return Ra((()=>{const a=e.name||"s";return{enterActive:(e.enterActiveClass||a+"-enter-active").split(" "),enter:(e.enterClass||a+"-enter").split(" "),enterTo:(e.enterToClass||a+"-enter-to").split(" "),exitActive:(e.exitActiveClass||a+"-exit-active").split(" "),exit:(e.exitClass||a+"-exit").split(" "),exitTo:(e.exitToClass||a+"-exit-to").split(" "),move:(e.moveClass||a+"-move").split(" ")}}))}(e);return dTe(gTe((()=>e.children)).toArray,{appear:e.appear,onChange({added:n,removed:t,finishRemoved:i,list:r}){const o=a();for(const a of n)fTe(o,e,a);const s=[];for(const e of r)e.isConnected&&(e instanceof HTMLElement||e instanceof SVGElement)&&s.push({el:e,rect:e.getBoundingClientRect()});queueMicrotask((()=>{const e=[];for(const{el:a,rect:n}of s)if(a.isConnected){const t=a.getBoundingClientRect(),i=n.left-t.left,r=n.top-t.top;(i||r)&&(a.style.transform=`translate(${i}px, ${r}px)`,a.style.transitionDuration="0s",e.push(a))}document;for(const a of e){let e=function(n){(n.target===a||/transform$/.test(n.propertyName))&&(a.removeEventListener("transitionend",e),a.classList.remove(...o.move))};a.classList.add(...o.move),a.style.transform=a.style.transitionDuration="",a.addEventListener("transitionend",e)}}));for(const a of t)yTe(o,e,a,(()=>i([a])))}})},bTe=Symbol("fallback");function STe(e){for(const a of e)a.dispose()}function ATe(e){const{by:a}=e;return Ra(function(e,a,n,t={}){const i=new Map;return Ha((()=>STe(i.values()))),()=>{const n=e()||[];return Da((()=>{if(!n.length)return STe(i.values()),i.clear(),t.fallback?[_a((e=>(i.set(bTe,{dispose:e}),t.fallback())))]:[];const e=new Array(n.length),o=i.get(bTe);if(!i.size||o){o?.dispose(),i.delete(bTe);for(let t=0;t<n.length;t++){const i=n[t];r(e,i,t,a(i,t))}return e}const s=new Set(i.keys());for(let t=0;t<n.length;t++){const o=n[t],l=a(o,t);s.delete(l);const u=i.get(l);u?(e[t]=u.mapped,u.setIndex?.(t),u.setItem((()=>o))):r(e,o,t,l)}for(const a of s)i.get(a)?.dispose(),i.delete(a);return e}))};function r(e,a,t,r){_a((o=>{const[s,l]=Pa(a),u={setItem:l,dispose:o};if(n.length>1){const[e,a]=Pa(t);u.setIndex=a,u.mapped=n(s,e)}else u.mapped=n(s);i.set(r,u),e[t]=u.mapped}))}}((()=>e.each),"function"==typeof a?a:e=>e[a],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}function wTe(e,a,n,t){const i=()=>{bMe(kMe(e)).forEach((e=>{e&&bMe(kMe(a)).forEach((a=>function(e,a,n,t){return e.addEventListener(a,n,t),SMe(e.removeEventListener.bind(e,a,n,t))}(e,a,n,t)))}))};"function"==typeof e?Ba(i):ja(i)}function CTe(e,a,n){const t=new WeakMap,{observe:i,unobserve:r}=function(e,a){const n=new ResizeObserver(e);return Ha(n.disconnect.bind(n)),{observe:e=>n.observe(e,a),unobserve:n.unobserve.bind(n)}}((e=>{for(const n of e){const{contentRect:e,target:i}=n,r=Math.round(e.width),o=Math.round(e.height),s=t.get(i);s&&s.width===r&&s.height===o||(a(e,i,n),t.set(i,{width:r,height:o}))}}),n);Ba((a=>{const n=bMe(kMe(e)).filter(yMe);return function(e,a,n,t){const i=e.length,r=a.length;let o,s,l=0;if(r)if(i){for(;l<r&&a[l]===e[l];l++);for(o of(a=a.slice(l),e=e.slice(l),a))e.includes(o)||t(o);for(s of e)a.includes(s)||n(s)}else for(;l<r;l++)t(a[l]);else for(;l<i;l++)n(e[l])}(n,a,i,r),n}),[])}var MTe=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function TTe(e){const a={};let n;for(;n=MTe.exec(e);)a[n[1]]=n[2];return a}function ETe(e,a){if("string"==typeof e){if("string"==typeof a)return`${e};${a}`;e=TTe(e)}else"string"==typeof a&&(a=TTe(a));return{...e,...a}}function xTe(e,a){const n=[...e],t=n.indexOf(a);return-1!==t&&n.splice(t,1),n}function NTe(e){return"[object String]"===Object.prototype.toString.call(e)}function _Te(e){return a=>`${e()}-${a}`}function PTe(e,a){return!!e&&(e===a||e.contains(a))}function LTe(e,a=!1){const{activeElement:n}=jTe(e);if(!n?.nodeName)return null;if(BTe(n)&&n.contentDocument)return LTe(n.contentDocument.body,a);if(a){const e=n.getAttribute("aria-activedescendant");if(e){const a=jTe(n).getElementById(e);if(a)return a}}return n}function jTe(e){return e?e.ownerDocument||e:document}function BTe(e){return"IFRAME"===e.tagName}var RTe=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(RTe||{});function zTe(e){return"undefined"!=typeof window&&null!=window.navigator&&e.test(window.navigator.userAgentData?.platform||window.navigator.platform)}function DTe(){return zTe(/^Mac/i)}function KTe(){return zTe(/^iPhone/i)||zTe(/^iPad/i)||DTe()&&navigator.maxTouchPoints>1}function OTe(e,a){return a&&("function"==typeof a?a(e):a[0](a[1],e)),e?.defaultPrevented}function HTe(e){return a=>{for(const n of e)OTe(a,n)}}function ITe(e){return DTe()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function GTe(e){if(e)if(function(){if(null==FTe){FTe=!1;try{document.createElement("div").focus({get preventScroll(){return FTe=!0,!0}})}catch(YHe){}}return FTe}())e.focus({preventScroll:!0});else{const a=function(e){let a=e.parentNode;const n=[],t=document.scrollingElement||document.documentElement;for(;a instanceof HTMLElement&&a!==t;)(a.offsetHeight<a.scrollHeight||a.offsetWidth<a.scrollWidth)&&n.push({element:a,scrollTop:a.scrollTop,scrollLeft:a.scrollLeft}),a=a.parentNode;t instanceof HTMLElement&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft});return n}(e);e.focus(),function(e){for(const{element:a,scrollTop:n,scrollLeft:t}of e)a.scrollTop=n,a.scrollLeft=t}(a)}}var FTe=null;var VTe=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],JTe=[...VTe,'[tabindex]:not([tabindex="-1"]):not([disabled])'],UTe=VTe.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])",WTe=JTe.join(':not([hidden]):not([tabindex="-1"]),');function qTe(e,a){const n=Array.from(e.querySelectorAll(UTe)).filter(ZTe);return a&&ZTe(e)&&n.unshift(e),n.forEach(((e,a)=>{if(BTe(e)&&e.contentDocument){const t=qTe(e.contentDocument.body,!1);n.splice(a,1,...t)}})),n}function ZTe(e){return $Te(e)&&!function(e){const a=parseInt(e.getAttribute("tabindex")||"0",10);return a<0}(e)}function $Te(e){return e.matches(UTe)&&YTe(e)}function YTe(e,a){return"#comment"!==e.nodeName&&function(e){if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const{display:a,visibility:n}=e.style;let t="none"!==a&&"hidden"!==n&&"collapse"!==n;if(t){if(!e.ownerDocument.defaultView)return t;const{getComputedStyle:a}=e.ownerDocument.defaultView,{display:n,visibility:i}=a(e);t="none"!==n&&"hidden"!==i&&"collapse"!==i}return t}(e)&&function(e,a){return!e.hasAttribute("hidden")&&("DETAILS"!==e.nodeName||!a||"SUMMARY"===a.nodeName||e.hasAttribute("open"))}(e,a)&&(!e.parentElement||YTe(e.parentElement,e))}function QTe(e){for(;e&&!XTe(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}function XTe(e){const a=window.getComputedStyle(e);return/(auto|scroll)/.test(a.overflow+a.overflowX+a.overflowY)}function eEe(){}function aEe(e,a){return fn(e,a)}var nEe=new Map,tEe=new Set;function iEe(){if("undefined"==typeof window)return;const e=a=>{if(!a.target)return;const n=nEe.get(a.target);if(n&&(n.delete(a.propertyName),0===n.size&&(a.target.removeEventListener("transitioncancel",e),nEe.delete(a.target)),0===nEe.size)){for(const e of tEe)e();tEe.clear()}};document.body.addEventListener("transitionrun",(a=>{if(!a.target)return;let n=nEe.get(a.target);n||(n=new Set,nEe.set(a.target,n),a.target.addEventListener("transitioncancel",e)),n.add(a.propertyName)})),document.body.addEventListener("transitionend",e)}function rEe(e,a){const n=oEe(e,a,"left"),t=oEe(e,a,"top"),i=a.offsetWidth,r=a.offsetHeight;let o=e.scrollLeft,s=e.scrollTop;const l=o+e.offsetWidth,u=s+e.offsetHeight;n<=o?o=n:n+i>l&&(o+=n+i-l),t<=s?s=t:t+r>u&&(s+=t+r-u),e.scrollLeft=o,e.scrollTop=s}function oEe(e,a,n){const t="left"===n?"offsetLeft":"offsetTop";let i=0;for(;a.offsetParent&&(i+=a[t],a.offsetParent!==e);){if(a.offsetParent.contains(e)){i-=e[t];break}a=a.offsetParent}return i}"undefined"!=typeof document&&("loading"!==document.readyState?iEe():document.addEventListener("DOMContentLoaded",iEe));var sEe={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"};function lEe(e){return a=>(e(a),()=>e(void 0))}function uEe(e,a){const[n,t]=Pa(cEe(a?.()));return Ba((()=>{t(e()?.tagName.toLowerCase()||cEe(a?.()))})),n}function cEe(e){return NTe(e)?e:void 0}function dEe(e){const[a,n]=yn(e,["as"]);if(!a.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return mn(nt,fn(n,{get component(){return a.as}}))}var mEe=["id","name","validationState","required","disabled","readOnly"];var hEe=Ja();function pEe(){const e=Ua(hEe);if(void 0===e)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function gEe(e){const a=pEe(),n=aEe({id:a.generateId("description")},e);return Ba((()=>Ha(a.registerDescription(n.id)))),mn(dEe,fn({as:"div"},(()=>a.dataset()),n))}function vEe(e){const a=pEe(),n=aEe({id:a.generateId("error-message")},e),[t,i]=yn(n,["forceMount"]),r=()=>"invalid"===a.validationState();return Ba((()=>{r()&&Ha(a.registerErrorMessage(i.id))})),mn(Mn,{get when(){return t.forceMount||r()},get children(){return mn(dEe,fn({as:"div"},(()=>a.dataset()),i))}})}function fEe(e){let a;const n=pEe(),t=aEe({id:n.generateId("label")},e),[i,r]=yn(t,["ref"]),o=uEe((()=>a),(()=>"label"));return Ba((()=>Ha(n.registerLabel(r.id)))),mn(dEe,fn({as:"label",ref(e){const n=mTe((e=>a=e),i.ref);"function"==typeof n&&n(e)},get for(){return Ra((()=>"label"===o()))()?n.fieldId():void 0}},(()=>n.dataset()),r))}function yEe(e,a){Ba(Ka(e,(e=>{if(null==e)return;const n=function(e){return function(e){return e.matches("textarea, input, select, button")}(e)?e.form:e.closest("form")}(e);null!=n&&(n.addEventListener("reset",a,{passive:!0}),Ha((()=>{n.removeEventListener("reset",a)})))})))}function kEe(e){const[a,n]=Pa(e.defaultValue?.()),t=Ra((()=>void 0!==e.value?.())),i=Ra((()=>t()?e.value?.():a()));return[i,a=>{Da((()=>{const r=function(e,...a){return"function"==typeof e?e(...a):e}(a,i());return Object.is(r,i())||(t()||n(r),e.onChange?.(r)),r}))}]}function bEe(e){const[a,n]=kEe(e);return[()=>a()??!1,n]}var SEe=Object.defineProperty,AEe=(e,a)=>{for(var n in a)SEe(e,n,{get:a[n],enumerable:!0})},wEe=Ja();function CEe(){return Ua(wEe)}function MEe(e,a){return Boolean(a.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function TEe(e,a){const n=function(e){const a=e.map(((e,a)=>[a,e]));let n=!1;return a.sort((([e,a],[t,i])=>{const r=a.ref(),o=i.ref();return r===o?0:r&&o?MEe(r,o)?(e>t&&(n=!0),-1):(e<t&&(n=!0),1):0})),n?a.map((([e,a])=>a)):e}(e);e!==n&&a(n)}function EEe(e,a){if("function"!=typeof IntersectionObserver)return void function(e,a){Ba((()=>{const n=setTimeout((()=>{TEe(e(),a)}));Ha((()=>clearTimeout(n)))}))}(e,a);let n=[];Ba((()=>{const t=function(e){const a=e[0],n=e[e.length-1]?.ref();let t=a?.ref()?.parentElement;for(;t;){if(n&&t.contains(n))return t;t=t.parentElement}return jTe(t).body}(e()),i=new IntersectionObserver((()=>{const t=!!n.length;n=e(),t&&TEe(e(),a)}),{root:t});for(const a of e()){const e=a.ref();e&&i.observe(e)}Ha((()=>i.disconnect()))}))}function xEe(e={}){const[a,n]=function(e){const[a,n]=kEe(e);return[()=>a()??[],n]}({value:()=>kMe(e.items),onChange:a=>e.onItemsChange?.(a)});EEe(a,n);const t=e=>(n((a=>{const n=function(e,a){const n=a.ref();if(!n)return-1;let t=e.length;if(!t)return-1;for(;t--;){const a=e[t]?.ref();if(a&&MEe(a,n))return t+1}return 0}(a,e);return function(e,a,n=-1){return n in e?[...e.slice(0,n),a,...e.slice(n)]:[...e,a]}(a,e,n)})),()=>{n((a=>{const n=a.filter((a=>a.ref()!==e.ref()));return a.length===n.length?a:n}))});return{DomCollectionProvider:e=>mn(wEe.Provider,{value:{registerItem:t},get children(){return e.children}})}}function NEe(e){const a=function(){const e=CEe();if(void 0===e)throw new Error("[kobalte]: `useDomCollectionContext` must be used within a `DomCollectionProvider` component");return e}(),n=aEe({shouldRegisterItem:!0},e);Ba((()=>{if(!n.shouldRegisterItem)return;Ha(a.registerItem(n.getItem()))}))}function _Ee(e){let a=e.startIndex??0;const n=e.startLevel??0,t=[],i=a=>{if(null==a)return"";const n=e.getKey??"key",t=NTe(n)?a[n]:n(a);return null!=t?String(t):""},r=a=>{if(null==a)return"";const n=e.getTextValue??"textValue",t=NTe(n)?a[n]:n(a);return null!=t?String(t):""},o=a=>{if(null==a)return!1;const n=e.getDisabled??"disabled";return(NTe(n)?a[n]:n(a))??!1},s=a=>{if(null!=a)return NTe(e.getSectionChildren)?a[e.getSectionChildren]:e.getSectionChildren?.(a)};for(const l of e.dataSource)if(NTe(l)||"number"==typeof l)t.push({type:"item",rawValue:l,key:String(l),textValue:String(l),disabled:o(l),level:n,index:a}),a++;else if(null!=s(l)){t.push({type:"section",rawValue:l,key:"",textValue:"",disabled:!1,level:n,index:a}),a++;const i=s(l)??[];if(i.length>0){const r=_Ee({dataSource:i,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:a,startLevel:n+1});t.push(...r),a+=r.length}}else t.push({type:"item",rawValue:l,key:i(l),textValue:r(l),disabled:o(l),level:n,index:a}),a++;return t}function PEe(e,a=[]){return Ra((()=>{const n=_Ee({dataSource:kMe(e.dataSource),getKey:kMe(e.getKey),getTextValue:kMe(e.getTextValue),getDisabled:kMe(e.getDisabled),getSectionChildren:kMe(e.getSectionChildren)});for(let e=0;e<a.length;e++)a[e]();return e.factory(n)}))}var LEe=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),jEe=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function BEe(e){return function(e){if(Intl.Locale){const a=new Intl.Locale(e).maximize().script??"";return LEe.has(a)}const a=e.split("-")[0];return jEe.has(a)}(e)?"rtl":"ltr"}function REe(){let e="undefined"!=typeof navigator&&(navigator.language||navigator.userLanguage)||"en-US";return{locale:e,direction:BEe(e)}}var zEe=REe(),DEe=new Set;function KEe(){zEe=REe();for(const e of DEe)e(zEe)}var OEe=Ja();function HEe(){const e=function(){const[e,a]=Pa(zEe),n=Ra((()=>e()));return Oa((()=>{0===DEe.size&&window.addEventListener("languagechange",KEe),DEe.add(a),Ha((()=>{DEe.delete(a),0===DEe.size&&window.removeEventListener("languagechange",KEe)}))})),{locale:()=>n().locale,direction:()=>n().direction}}();return Ua(OEe)||e}var IEe=new Map;var GEe=class e extends Set{anchorKey;currentKey;constructor(a,n,t){super(a),a instanceof e?(this.anchorKey=n||a.anchorKey,this.currentKey=t||a.currentKey):(this.anchorKey=n,this.currentKey=t)}};function FEe(e){return DTe()||KTe()?e.altKey:e.ctrlKey}function VEe(e){return DTe()?e.metaKey:e.ctrlKey}function JEe(e){return new GEe(e)}function UEe(e){const a=aEe({selectionMode:"none",selectionBehavior:"toggle"},e),[n,t]=Pa(!1),[i,r]=Pa(),o=Ra((()=>{const e=kMe(a.selectedKeys);return null!=e?JEe(e):e})),s=Ra((()=>{const e=kMe(a.defaultSelectedKeys);return null!=e?JEe(e):new GEe})),[l,u]=function(e){const[a,n]=kEe(e);return[()=>a()??new GEe,n]}({value:o,defaultValue:s,onChange:e=>a.onSelectionChange?.(e)}),[c,d]=Pa(kMe(a.selectionBehavior));return Ba((()=>{const e=l();"replace"===kMe(a.selectionBehavior)&&"toggle"===c()&&"object"==typeof e&&0===e.size&&d("replace")})),Ba((()=>{d(kMe(a.selectionBehavior)??"toggle")})),{selectionMode:()=>kMe(a.selectionMode),disallowEmptySelection:()=>kMe(a.disallowEmptySelection)??!1,selectionBehavior:c,setSelectionBehavior:d,isFocused:n,setFocused:t,focusedKey:i,setFocusedKey:r,selectedKeys:l,setSelectedKeys:e=>{!kMe(a.allowDuplicateSelectionEvents)&&function(e,a){if(e.size!==a.size)return!1;for(const n of e)if(!a.has(n))return!1;return!0}(e,l())||u(e)}}}function WEe(e,a,n){const t=fn({selectOnFocus:()=>"replace"===kMe(e.selectionManager).selectionBehavior()},e),i=()=>a(),{direction:r}=HEe();let o={top:0,left:0};wTe((()=>kMe(t.isVirtualized)?void 0:i()),"scroll",(()=>{const e=i();e&&(o={top:e.scrollTop,left:e.scrollLeft})}));const{typeSelectHandlers:s}=function(e){const[a,n]=Pa(""),[t,i]=Pa(-1);return{typeSelectHandlers:{onKeyDown:r=>{if(kMe(e.isDisabled))return;const o=kMe(e.keyboardDelegate),s=kMe(e.selectionManager);if(!o.getKeyForSearch)return;const l=function(e){return 1!==e.length&&/^[A-Z]/i.test(e)?"":e}(r.key);if(!l||r.ctrlKey||r.metaKey)return;" "===l&&a().trim().length>0&&(r.preventDefault(),r.stopPropagation());let u=n((e=>e+l)),c=o.getKeyForSearch(u,s.focusedKey())??o.getKeyForSearch(u);null==c&&function(e){return e.split("").every((a=>a===e[0]))}(u)&&(u=u[0],c=o.getKeyForSearch(u,s.focusedKey())??o.getKeyForSearch(u)),null!=c&&(s.setFocusedKey(c),e.onTypeSelect?.(c)),clearTimeout(t()),i(window.setTimeout((()=>n("")),500))}}}}({isDisabled:()=>kMe(t.disallowTypeAhead),keyboardDelegate:()=>kMe(t.keyboardDelegate),selectionManager:()=>kMe(t.selectionManager)}),l=()=>kMe(t.orientation)??"vertical",u=()=>{const e=kMe(t.autoFocus);if(!e)return;const n=kMe(t.selectionManager),i=kMe(t.keyboardDelegate);let r;"first"===e&&(r=i.getFirstKey?.()),"last"===e&&(r=i.getLastKey?.());const o=n.selectedKeys();o.size&&(r=o.values().next().value),n.setFocused(!0),n.setFocusedKey(r);const s=a();s&&null==r&&!kMe(t.shouldUseVirtualFocus)&&GTe(s)};Oa((()=>{t.deferAutoFocus?setTimeout(u,0):u()})),Ba(Ka([i,()=>kMe(t.isVirtualized),()=>kMe(t.selectionManager).focusedKey()],(e=>{const[a,n,i]=e;if(n)i&&t.scrollToKey?.(i);else if(i&&a){const e=a.querySelector(`[data-key="${i}"]`);e&&rEe(a,e)}})));return{tabIndex:Ra((()=>{if(!kMe(t.shouldUseVirtualFocus))return null==kMe(t.selectionManager).focusedKey()?0:-1})),onKeyDown:e=>{OTe(e,s.onKeyDown),e.altKey&&"Tab"===e.key&&e.preventDefault();const n=a();if(!n?.contains(e.target))return;const i=kMe(t.selectionManager),o=kMe(t.selectOnFocus),u=a=>{null!=a&&(i.setFocusedKey(a),e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&!FEe(e)&&i.replaceSelection(a))},c=kMe(t.keyboardDelegate),d=kMe(t.shouldFocusWrap),m=i.focusedKey();switch(e.key){case"vertical"===l()?"ArrowDown":"ArrowRight":if(c.getKeyBelow){let a;e.preventDefault(),a=null!=m?c.getKeyBelow(m):c.getFirstKey?.(),null==a&&d&&(a=c.getFirstKey?.(m)),u(a)}break;case"vertical"===l()?"ArrowUp":"ArrowLeft":if(c.getKeyAbove){let a;e.preventDefault(),a=null!=m?c.getKeyAbove(m):c.getLastKey?.(),null==a&&d&&(a=c.getLastKey?.(m)),u(a)}break;case"vertical"===l()?"ArrowLeft":"ArrowUp":if(c.getKeyLeftOf){e.preventDefault();const a="rtl"===r();let n;n=null!=m?c.getKeyLeftOf(m):a?c.getFirstKey?.():c.getLastKey?.(),u(n)}break;case"vertical"===l()?"ArrowRight":"ArrowDown":if(c.getKeyRightOf){e.preventDefault();const a="rtl"===r();let n;n=null!=m?c.getKeyRightOf(m):a?c.getLastKey?.():c.getFirstKey?.(),u(n)}break;case"Home":if(c.getFirstKey){e.preventDefault();const a=c.getFirstKey(m,VEe(e));null!=a&&(i.setFocusedKey(a),VEe(e)&&e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&i.replaceSelection(a))}break;case"End":if(c.getLastKey){e.preventDefault();const a=c.getLastKey(m,VEe(e));null!=a&&(i.setFocusedKey(a),VEe(e)&&e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&i.replaceSelection(a))}break;case"PageDown":if(c.getKeyPageBelow&&null!=m){e.preventDefault();u(c.getKeyPageBelow(m))}break;case"PageUp":if(c.getKeyPageAbove&&null!=m){e.preventDefault();u(c.getKeyPageAbove(m))}break;case"a":VEe(e)&&"multiple"===i.selectionMode()&&!0!==kMe(t.disallowSelectAll)&&(e.preventDefault(),i.selectAll());break;case"Escape":e.defaultPrevented||(e.preventDefault(),kMe(t.disallowEmptySelection)||i.clearSelection());break;case"Tab":if(!kMe(t.allowsTabNavigation)){if(e.shiftKey)n.focus();else{const e=function(e,a){const n=a?.tabbable?WTe:UTe,t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>a?.from?.contains(e)?NodeFilter.FILTER_REJECT:e.matches(n)&&YTe(e)&&(!a?.accept||a.accept(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});return a?.from&&(t.currentNode=a.from),t}(n,{tabbable:!0});let a,t;do{t=e.lastChild(),t&&(a=t)}while(t);a&&!a.contains(document.activeElement)&&GTe(a)}break}}},onMouseDown:e=>{i()===e.target&&e.preventDefault()},onFocusIn:e=>{const a=kMe(t.selectionManager),n=kMe(t.keyboardDelegate),r=kMe(t.selectOnFocus);if(a.isFocused())e.currentTarget.contains(e.target)||a.setFocused(!1);else if(e.currentTarget.contains(e.target))if(a.setFocused(!0),null==a.focusedKey()){const t=e=>{null!=e&&(a.setFocusedKey(e),r&&a.replaceSelection(e))},i=e.relatedTarget;i&&e.currentTarget.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING?t(a.lastSelectedKey()??n.getLastKey?.()):t(a.firstSelectedKey()??n.getFirstKey?.())}else if(!kMe(t.isVirtualized)){const e=i();if(e){e.scrollTop=o.top,e.scrollLeft=o.left;const n=e.querySelector(`[data-key="${a.focusedKey()}"]`);n&&(GTe(n),rEe(e,n))}}},onFocusOut:e=>{const a=kMe(t.selectionManager);e.currentTarget.contains(e.relatedTarget)||a.setFocused(!1)}}}function qEe(e,a){const n=()=>kMe(e.selectionManager),t=()=>kMe(e.key),i=()=>kMe(e.shouldUseVirtualFocus),r=e=>{"none"!==n().selectionMode()&&("single"===n().selectionMode()?n().isSelected(t())&&!n().disallowEmptySelection()?n().toggleSelection(t()):n().replaceSelection(t()):e?.shiftKey?n().extendSelection(t()):"toggle"===n().selectionBehavior()||VEe(e)||"pointerType"in e&&"touch"===e.pointerType?n().toggleSelection(t()):n().replaceSelection(t()))},o=()=>kMe(e.disabled)||n().isDisabled(t()),s=()=>!o()&&n().canSelectItem(t());let l=null;const u=Ra((()=>{if(!i()&&!o())return t()===n().focusedKey()?0:-1})),c=Ra((()=>kMe(e.virtualized)?void 0:t()));return Ba(Ka([a,t,i,()=>n().focusedKey(),()=>n().isFocused()],(([a,n,t,i,r])=>{a&&n===i&&r&&!t&&document.activeElement!==a&&(e.focus?e.focus():GTe(a))}))),{isSelected:()=>n().isSelected(t()),isDisabled:o,allowsSelection:s,tabIndex:u,dataKey:c,onPointerDown:a=>{s()&&(l=a.pointerType,"mouse"!==a.pointerType||0!==a.button||kMe(e.shouldSelectOnPressUp)||r(a))},onPointerUp:a=>{s()&&"mouse"===a.pointerType&&0===a.button&&kMe(e.shouldSelectOnPressUp)&&kMe(e.allowsDifferentPressOrigin)&&r(a)},onClick:a=>{s()&&(kMe(e.shouldSelectOnPressUp)&&!kMe(e.allowsDifferentPressOrigin)||"mouse"!==l)&&r(a)},onKeyDown:e=>{s()&&["Enter"," "].includes(e.key)&&(FEe(e)?n().toggleSelection(t()):r(e))},onMouseDown:e=>{o()&&e.preventDefault()},onFocus:e=>{const r=a();i()||o()||!r||e.target===r&&n().setFocusedKey(t())}}}var ZEe=class{collection;state;constructor(e,a){this.collection=e,this.state=a}selectionMode(){return this.state.selectionMode()}disallowEmptySelection(){return this.state.disallowEmptySelection()}selectionBehavior(){return this.state.selectionBehavior()}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}isFocused(){return this.state.isFocused()}setFocused(e){this.state.setFocused(e)}focusedKey(){return this.state.focusedKey()}setFocusedKey(e){(null==e||this.collection().getItem(e))&&this.state.setFocusedKey(e)}selectedKeys(){return this.state.selectedKeys()}isSelected(e){if("none"===this.state.selectionMode())return!1;const a=this.getKey(e);return null!=a&&this.state.selectedKeys().has(a)}isEmpty(){return 0===this.state.selectedKeys().size}isSelectAll(){if(this.isEmpty())return!1;const e=this.state.selectedKeys();return this.getAllSelectableKeys().every((a=>e.has(a)))}firstSelectedKey(){let e;for(const a of this.state.selectedKeys()){const n=this.collection().getItem(a);e&&!(null!=n?.index&&null!=e?.index&&n.index<e.index)||(e=n)}return e?.key}lastSelectedKey(){let e;for(const a of this.state.selectedKeys()){const n=this.collection().getItem(a);e&&!(null!=n?.index&&null!=e?.index&&n.index>e.index)||(e=n)}return e?.key}extendSelection(e){if("none"===this.selectionMode())return;if("single"===this.selectionMode())return void this.replaceSelection(e);const a=this.getKey(e);if(null==a)return;const n=this.state.selectedKeys(),t=n.anchorKey||a,i=new GEe(n,t,a);for(const r of this.getKeyRange(t,n.currentKey||a))i.delete(r);for(const r of this.getKeyRange(a,t))this.canSelectItem(r)&&i.add(r);this.state.setSelectedKeys(i)}getKeyRange(e,a){const n=this.collection().getItem(e),t=this.collection().getItem(a);return n&&t?null!=n.index&&null!=t.index&&n.index<=t.index?this.getKeyRangeInternal(e,a):this.getKeyRangeInternal(a,e):[]}getKeyRangeInternal(e,a){const n=[];let t=e;for(;null!=t;){const e=this.collection().getItem(t);if(e&&"item"===e.type&&n.push(t),t===a)return n;t=this.collection().getKeyAfter(t)}return[]}getKey(e){const a=this.collection().getItem(e);return a?a&&"item"===a.type?a.key:null:e}toggleSelection(e){if("none"===this.selectionMode())return;if("single"===this.selectionMode()&&!this.isSelected(e))return void this.replaceSelection(e);const a=this.getKey(e);if(null==a)return;const n=new GEe(this.state.selectedKeys());n.has(a)?n.delete(a):this.canSelectItem(a)&&(n.add(a),n.anchorKey=a,n.currentKey=a),this.disallowEmptySelection()&&0===n.size||this.state.setSelectedKeys(n)}replaceSelection(e){if("none"===this.selectionMode())return;const a=this.getKey(e);if(null==a)return;const n=this.canSelectItem(a)?new GEe([a],a,a):new GEe;this.state.setSelectedKeys(n)}setSelectedKeys(e){if("none"===this.selectionMode())return;const a=new GEe;for(const n of e){const e=this.getKey(n);if(null!=e&&(a.add(e),"single"===this.selectionMode()))break}this.state.setSelectedKeys(a)}selectAll(){"multiple"===this.selectionMode()&&this.state.setSelectedKeys(new Set(this.getAllSelectableKeys()))}clearSelection(){const e=this.state.selectedKeys();!this.disallowEmptySelection()&&e.size>0&&this.state.setSelectedKeys(new GEe)}toggleSelectAll(){this.isSelectAll()?this.clearSelection():this.selectAll()}select(e,a){"none"!==this.selectionMode()&&("single"===this.selectionMode()?this.isSelected(e)&&!this.disallowEmptySelection()?this.toggleSelection(e):this.replaceSelection(e):"toggle"===this.selectionBehavior()||a&&"touch"===a.pointerType?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys())return!0;const a=this.selectedKeys();if(e.size!==a.size)return!1;for(const n of e)if(!a.has(n))return!1;for(const n of a)if(!e.has(n))return!1;return!0}canSelectItem(e){if("none"===this.state.selectionMode())return!1;const a=this.collection().getItem(e);return null!=a&&!a.disabled}isDisabled(e){const a=this.collection().getItem(e);return!a||a.disabled}getAllSelectableKeys(){const e=[];return(a=>{for(;null!=a;){if(this.canSelectItem(a)){const n=this.collection().getItem(a);if(!n)continue;"item"===n.type&&e.push(a)}a=this.collection().getKeyAfter(a)}})(this.collection().getFirstKey()),e}},$Ee=class{keyMap=new Map;iterable;firstKey;lastKey;constructor(e){this.iterable=e;for(const t of e)this.keyMap.set(t.key,t);if(0===this.keyMap.size)return;let a,n=0;for(const[t,i]of this.keyMap)a?(a.nextKey=t,i.prevKey=a.key):(this.firstKey=t,i.prevKey=void 0),"item"===i.type&&(i.index=n++),a=i,a.nextKey=void 0;this.lastKey=a.key}*[Symbol.iterator](){yield*this.iterable}getSize(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(e){return this.keyMap.get(e)?.prevKey}getKeyAfter(e){return this.keyMap.get(e)?.nextKey}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(e){return this.keyMap.get(e)}at(e){const a=[...this.getKeys()];return this.getItem(a[e])}};var YEe,QEe=e=>"function"==typeof e?e():e,XEe=e=>{const a=Ra((()=>{const a=QEe(e.element);if(a)return getComputedStyle(a)})),n=()=>a()?.animationName??"none",[t,i]=Pa(QEe(e.show)?"present":"hidden");let r="none";return Ba((t=>{const o=QEe(e.show);return Da((()=>{if(t===o)return o;const e=r,s=n();if(o)i("present");else if("none"===s||"none"===a()?.display)i("hidden");else{i(!0===t&&e!==s?"hiding":"hidden")}})),o})),Ba((()=>{const a=QEe(e.element);if(!a)return;const o=e=>{e.target===a&&(r=n())},s=e=>{const r=n().includes(e.animationName);e.target===a&&r&&"hiding"===t()&&i("hidden")};a.addEventListener("animationstart",o),a.addEventListener("animationcancel",s),a.addEventListener("animationend",s),Ha((()=>{a.removeEventListener("animationstart",o),a.removeEventListener("animationcancel",s),a.removeEventListener("animationend",s)}))})),{present:()=>"present"===t()||"hiding"===t(),state:t}},exe="data-kb-top-layer",axe=!1,nxe=[];function txe(e){return nxe.findIndex((a=>a.node===e))}function ixe(){return nxe.filter((e=>e.isPointerBlocking))}function rxe(){return ixe().length>0}function oxe(e){const a=txe([...ixe()].slice(-1)[0]?.node);return txe(e)<a}var sxe={layers:nxe,isTopMostLayer:function(e){return nxe[nxe.length-1].node===e},hasPointerBlockingLayer:rxe,isBelowPointerBlockingLayer:oxe,addLayer:function(e){nxe.push(e)},removeLayer:function(e){const a=txe(e);a<0||nxe.splice(a,1)},indexOf:txe,find:function(e){return nxe[txe(e)]},assignPointerEventToLayers:function(){for(const{node:e}of nxe)e.style.pointerEvents=oxe(e)?"none":"auto"},disableBodyPointerEvents:function(e){if(rxe()&&!axe){const a=jTe(e);YEe=document.body.style.pointerEvents,a.body.style.pointerEvents="none",axe=!0}},restoreBodyPointerEvents:function(e){if(rxe())return;const a=jTe(e);a.body.style.pointerEvents=YEe,0===a.body.style.length&&a.body.removeAttribute("style"),axe=!1}};AEe({},{Button:()=>cxe,Root:()=>uxe});var lxe=["button","color","file","image","reset","submit"];function uxe(e){let a;const n=aEe({type:"button"},e),[t,i]=yn(n,["ref","type","disabled"]),r=uEe((()=>a),(()=>"button")),o=Ra((()=>{const e=r();return null!=e&&function(e){const a=e.tagName.toLowerCase();return"button"===a||!("input"!==a||!e.type)&&-1!==lxe.indexOf(e.type)}({tagName:e,type:t.type})})),s=Ra((()=>"input"===r())),l=Ra((()=>"a"===r()&&null!=a?.getAttribute("href")));return mn(dEe,fn({as:"button",ref(e){const n=mTe((e=>a=e),t.ref);"function"==typeof n&&n(e)},get type(){return o()||s()?t.type:void 0},get role(){return o()||l()?void 0:"button"},get tabIndex(){return o()||l()||t.disabled?void 0:0},get disabled(){return o()||s()?t.disabled:void 0},get"aria-disabled"(){return!(o()||s()||!t.disabled)||void 0},get"data-disabled"(){return t.disabled?"":void 0}},i))}var cxe=uxe,dxe=["top","right","bottom","left"],mxe=Math.min,hxe=Math.max,pxe=Math.round,gxe=Math.floor,vxe=e=>({x:e,y:e}),fxe={left:"right",right:"left",bottom:"top",top:"bottom"},yxe={start:"end",end:"start"};function kxe(e,a,n){return hxe(e,mxe(a,n))}function bxe(e,a){return"function"==typeof e?e(a):e}function Sxe(e){return e.split("-")[0]}function Axe(e){return e.split("-")[1]}function wxe(e){return"x"===e?"y":"x"}function Cxe(e){return"y"===e?"height":"width"}function Mxe(e){return["top","bottom"].includes(Sxe(e))?"y":"x"}function Txe(e){return wxe(Mxe(e))}function Exe(e){return e.replace(/start|end/g,(e=>yxe[e]))}function xxe(e){return e.replace(/left|right|bottom|top/g,(e=>fxe[e]))}function Nxe(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function _xe(e){const{x:a,y:n,width:t,height:i}=e;return{width:t,height:i,top:n,left:a,right:a+t,bottom:n+i,x:a,y:n}}function Pxe(e,a,n){let{reference:t,floating:i}=e;const r=Mxe(a),o=Txe(a),s=Cxe(o),l=Sxe(a),u="y"===r,c=t.x+t.width/2-i.width/2,d=t.y+t.height/2-i.height/2,m=t[s]/2-i[s]/2;let h;switch(l){case"top":h={x:c,y:t.y-i.height};break;case"bottom":h={x:c,y:t.y+t.height};break;case"right":h={x:t.x+t.width,y:d};break;case"left":h={x:t.x-i.width,y:d};break;default:h={x:t.x,y:t.y}}switch(Axe(a)){case"start":h[o]-=m*(n&&u?-1:1);break;case"end":h[o]+=m*(n&&u?-1:1)}return h}async function Lxe(e,a){var n;void 0===a&&(a={});const{x:t,y:i,platform:r,rects:o,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:m=!1,padding:h=0}=bxe(a,e),p=Nxe(h),g=s[m?"floating"===d?"reference":"floating":d],v=_xe(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(g)))||n?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),f="floating"===d?{x:t,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),k=await(null==r.isElement?void 0:r.isElement(y))&&await(null==r.getScale?void 0:r.getScale(y))||{x:1,y:1},b=_xe(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:f,offsetParent:y,strategy:l}):f);return{top:(v.top-b.top+p.top)/k.y,bottom:(b.bottom-v.bottom+p.bottom)/k.y,left:(v.left-b.left+p.left)/k.x,right:(b.right-v.right+p.right)/k.x}}function jxe(e,a){return{top:e.top-a.height,right:e.right-a.width,bottom:e.bottom-a.height,left:e.left-a.width}}function Bxe(e){return dxe.some((a=>e[a]>=0))}function Rxe(e){return Kxe(e)?(e.nodeName||"").toLowerCase():"#document"}function zxe(e){var a;return(null==e||null==(a=e.ownerDocument)?void 0:a.defaultView)||window}function Dxe(e){var a;return null==(a=(Kxe(e)?e.ownerDocument:e.document)||window.document)?void 0:a.documentElement}function Kxe(e){return e instanceof Node||e instanceof zxe(e).Node}function Oxe(e){return e instanceof Element||e instanceof zxe(e).Element}function Hxe(e){return e instanceof HTMLElement||e instanceof zxe(e).HTMLElement}function Ixe(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof zxe(e).ShadowRoot)}function Gxe(e){const{overflow:a,overflowX:n,overflowY:t,display:i}=qxe(e);return/auto|scroll|overlay|hidden|clip/.test(a+t+n)&&!["inline","contents"].includes(i)}function Fxe(e){return["table","td","th"].includes(Rxe(e))}function Vxe(e){return[":popover-open",":modal"].some((a=>{try{return e.matches(a)}catch(YHe){return!1}}))}function Jxe(e){const a=Uxe(),n=Oxe(e)?qxe(e):e;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!a&&!!n.backdropFilter&&"none"!==n.backdropFilter||!a&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function Uxe(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function Wxe(e){return["html","body","#document"].includes(Rxe(e))}function qxe(e){return zxe(e).getComputedStyle(e)}function Zxe(e){return Oxe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $xe(e){if("html"===Rxe(e))return e;const a=e.assignedSlot||e.parentNode||Ixe(e)&&e.host||Dxe(e);return Ixe(a)?a.host:a}function Yxe(e){const a=$xe(e);return Wxe(a)?e.ownerDocument?e.ownerDocument.body:e.body:Hxe(a)&&Gxe(a)?a:Yxe(a)}function Qxe(e,a,n){var t;void 0===a&&(a=[]),void 0===n&&(n=!0);const i=Yxe(e),r=i===(null==(t=e.ownerDocument)?void 0:t.body),o=zxe(i);return r?a.concat(o,o.visualViewport||[],Gxe(i)?i:[],o.frameElement&&n?Qxe(o.frameElement):[]):a.concat(i,Qxe(i,[],n))}function Xxe(e){const a=qxe(e);let n=parseFloat(a.width)||0,t=parseFloat(a.height)||0;const i=Hxe(e),r=i?e.offsetWidth:n,o=i?e.offsetHeight:t,s=pxe(n)!==r||pxe(t)!==o;return s&&(n=r,t=o),{width:n,height:t,$:s}}function eNe(e){return Oxe(e)?e:e.contextElement}function aNe(e){const a=eNe(e);if(!Hxe(a))return vxe(1);const n=a.getBoundingClientRect(),{width:t,height:i,$:r}=Xxe(a);let o=(r?pxe(n.width):n.width)/t,s=(r?pxe(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var nNe=vxe(0);function tNe(e){const a=zxe(e);return Uxe()&&a.visualViewport?{x:a.visualViewport.offsetLeft,y:a.visualViewport.offsetTop}:nNe}function iNe(e,a,n,t){void 0===a&&(a=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),r=eNe(e);let o=vxe(1);a&&(t?Oxe(t)&&(o=aNe(t)):o=aNe(e));const s=function(e,a,n){return void 0===a&&(a=!1),!(!n||a&&n!==zxe(e))&&a}(r,n,t)?tNe(r):vxe(0);let l=(i.left+s.x)/o.x,u=(i.top+s.y)/o.y,c=i.width/o.x,d=i.height/o.y;if(r){const e=zxe(r),a=t&&Oxe(t)?zxe(t):t;let n=e,i=n.frameElement;for(;i&&t&&a!==n;){const e=aNe(i),a=i.getBoundingClientRect(),t=qxe(i),r=a.left+(i.clientLeft+parseFloat(t.paddingLeft))*e.x,o=a.top+(i.clientTop+parseFloat(t.paddingTop))*e.y;l*=e.x,u*=e.y,c*=e.x,d*=e.y,l+=r,u+=o,n=zxe(i),i=n.frameElement}}return _xe({width:c,height:d,x:l,y:u})}function rNe(e){return iNe(Dxe(e)).left+Zxe(e).scrollLeft}function oNe(e,a,n){let t;if("viewport"===a)t=function(e,a){const n=zxe(e),t=Dxe(e),i=n.visualViewport;let r=t.clientWidth,o=t.clientHeight,s=0,l=0;if(i){r=i.width,o=i.height;const e=Uxe();(!e||e&&"fixed"===a)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:o,x:s,y:l}}(e,n);else if("document"===a)t=function(e){const a=Dxe(e),n=Zxe(e),t=e.ownerDocument.body,i=hxe(a.scrollWidth,a.clientWidth,t.scrollWidth,t.clientWidth),r=hxe(a.scrollHeight,a.clientHeight,t.scrollHeight,t.clientHeight);let o=-n.scrollLeft+rNe(e);const s=-n.scrollTop;return"rtl"===qxe(t).direction&&(o+=hxe(a.clientWidth,t.clientWidth)-i),{width:i,height:r,x:o,y:s}}(Dxe(e));else if(Oxe(a))t=function(e,a){const n=iNe(e,!0,"fixed"===a),t=n.top+e.clientTop,i=n.left+e.clientLeft,r=Hxe(e)?aNe(e):vxe(1);return{width:e.clientWidth*r.x,height:e.clientHeight*r.y,x:i*r.x,y:t*r.y}}(a,n);else{const n=tNe(e);t={...a,x:a.x-n.x,y:a.y-n.y}}return _xe(t)}function sNe(e,a){const n=$xe(e);return!(n===a||!Oxe(n)||Wxe(n))&&("fixed"===qxe(n).position||sNe(n,a))}function lNe(e,a,n){const t=Hxe(a),i=Dxe(a),r="fixed"===n,o=iNe(e,!0,r,a);let s={scrollLeft:0,scrollTop:0};const l=vxe(0);if(t||!t&&!r)if(("body"!==Rxe(a)||Gxe(i))&&(s=Zxe(a)),t){const e=iNe(a,!0,r,a);l.x=e.x+a.clientLeft,l.y=e.y+a.clientTop}else i&&(l.x=rNe(i));return{x:o.left+s.scrollLeft-l.x,y:o.top+s.scrollTop-l.y,width:o.width,height:o.height}}function uNe(e){return"static"===qxe(e).position}function cNe(e,a){return Hxe(e)&&"fixed"!==qxe(e).position?a?a(e):e.offsetParent:null}function dNe(e,a){const n=zxe(e);if(Vxe(e))return n;if(!Hxe(e)){let a=$xe(e);for(;a&&!Wxe(a);){if(Oxe(a)&&!uNe(a))return a;a=$xe(a)}return n}let t=cNe(e,a);for(;t&&Fxe(t)&&uNe(t);)t=cNe(t,a);return t&&Wxe(t)&&uNe(t)&&!Jxe(t)?n:t||function(e){let a=$xe(e);for(;Hxe(a)&&!Wxe(a);){if(Jxe(a))return a;if(Vxe(a))return null;a=$xe(a)}return null}(e)||n}var mNe={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:a,rect:n,offsetParent:t,strategy:i}=e;const r="fixed"===i,o=Dxe(t),s=!!a&&Vxe(a.floating);if(t===o||s&&r)return n;let l={scrollLeft:0,scrollTop:0},u=vxe(1);const c=vxe(0),d=Hxe(t);if((d||!d&&!r)&&(("body"!==Rxe(t)||Gxe(o))&&(l=Zxe(t)),Hxe(t))){const e=iNe(t);u=aNe(t),c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x,y:n.y*u.y-l.scrollTop*u.y+c.y}},getDocumentElement:Dxe,getClippingRect:function(e){let{element:a,boundary:n,rootBoundary:t,strategy:i}=e;const r=[..."clippingAncestors"===n?Vxe(a)?[]:function(e,a){const n=a.get(e);if(n)return n;let t=Qxe(e,[],!1).filter((e=>Oxe(e)&&"body"!==Rxe(e))),i=null;const r="fixed"===qxe(e).position;let o=r?$xe(e):e;for(;Oxe(o)&&!Wxe(o);){const a=qxe(o),n=Jxe(o);n||"fixed"!==a.position||(i=null),(r?!n&&!i:!n&&"static"===a.position&&i&&["absolute","fixed"].includes(i.position)||Gxe(o)&&!n&&sNe(e,o))?t=t.filter((e=>e!==o)):i=a,o=$xe(o)}return a.set(e,t),t}(a,this._c):[].concat(n),t],o=r.reduce(((e,n)=>{const t=oNe(a,n,i);return e.top=hxe(t.top,e.top),e.right=mxe(t.right,e.right),e.bottom=mxe(t.bottom,e.bottom),e.left=hxe(t.left,e.left),e}),oNe(a,r[0],i));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:dNe,getElementRects:async function(e){const a=this.getOffsetParent||dNe,n=this.getDimensions,t=await n(e.floating);return{reference:lNe(e.reference,await a(e.floating),e.strategy),floating:{x:0,y:0,width:t.width,height:t.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:a,height:n}=Xxe(e);return{width:a,height:n}},getScale:aNe,isElement:Oxe,isRTL:function(e){return"rtl"===qxe(e).direction}};function hNe(e,a,n,t){void 0===t&&(t={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:l=!1}=t,u=eNe(e),c=i||r?[...u?Qxe(u):[],...Qxe(a)]:[];c.forEach((e=>{i&&e.addEventListener("scroll",n,{passive:!0}),r&&e.addEventListener("resize",n)}));const d=u&&s?function(e,a){let n,t=null;const i=Dxe(e);function r(){var e;clearTimeout(n),null==(e=t)||e.disconnect(),t=null}return function o(s,l){void 0===s&&(s=!1),void 0===l&&(l=1),r();const{left:u,top:c,width:d,height:m}=e.getBoundingClientRect();if(s||a(),!d||!m)return;const h={rootMargin:-gxe(c)+"px "+-gxe(i.clientWidth-(u+d))+"px "+-gxe(i.clientHeight-(c+m))+"px "+-gxe(u)+"px",threshold:hxe(0,mxe(1,l))||1};let p=!0;function g(e){const a=e[0].intersectionRatio;if(a!==l){if(!p)return o();a?o(!1,a):n=setTimeout((()=>{o(!1,1e-7)}),1e3)}p=!1}try{t=new IntersectionObserver(g,{...h,root:i.ownerDocument})}catch(YHe){t=new IntersectionObserver(g,h)}t.observe(e)}(!0),r}(u,n):null;let m,h=-1,p=null;o&&(p=new ResizeObserver((e=>{let[t]=e;t&&t.target===u&&p&&(p.unobserve(a),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(a)}))),n()})),u&&!l&&p.observe(u),p.observe(a));let g=l?iNe(e):null;return l&&function a(){const t=iNe(e);!g||t.x===g.x&&t.y===g.y&&t.width===g.width&&t.height===g.height||n();g=t,m=requestAnimationFrame(a)}(),n(),()=>{var e;c.forEach((e=>{i&&e.removeEventListener("scroll",n),r&&e.removeEventListener("resize",n)})),null==d||d(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(m)}}var pNe=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(a){var n,t;const{x:i,y:r,placement:o,middlewareData:s}=a,l=await async function(e,a){const{placement:n,platform:t,elements:i}=e,r=await(null==t.isRTL?void 0:t.isRTL(i.floating)),o=Sxe(n),s=Axe(n),l="y"===Mxe(n),u=["left","top"].includes(o)?-1:1,c=r&&l?-1:1,d=bxe(a,e);let{mainAxis:m,crossAxis:h,alignmentAxis:p}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return s&&"number"==typeof p&&(h="end"===s?-1*p:p),l?{x:h*c,y:m*u}:{x:m*u,y:h*c}}(a,e);return o===(null==(n=s.offset)?void 0:n.placement)&&null!=(t=s.arrow)&&t.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:{...l,placement:o}}}}},gNe=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(a){const{x:n,y:t,placement:i}=a,{mainAxis:r=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:a,y:n}=e;return{x:a,y:n}}},...l}=bxe(e,a),u={x:n,y:t},c=await Lxe(a,l),d=Mxe(Sxe(i)),m=wxe(d);let h=u[m],p=u[d];if(r){h=kxe(h+c["y"===m?"top":"left"],h,h-c["y"===m?"bottom":"right"])}if(o){p=kxe(p+c["y"===d?"top":"left"],p,p-c["y"===d?"bottom":"right"])}const g=s.fn({...a,[m]:h,[d]:p});return{...g,data:{x:g.x-n,y:g.y-t}}}}},vNe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(a){var n,t;const{placement:i,middlewareData:r,rects:o,initialPlacement:s,platform:l,elements:u}=a,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...v}=bxe(e,a);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const f=Sxe(i),y=Mxe(s),k=Sxe(s)===s,b=await(null==l.isRTL?void 0:l.isRTL(u.floating)),S=m||(k||!g?[xxe(s)]:function(e){const a=xxe(e);return[Exe(e),a,Exe(a)]}(s)),A="none"!==p;!m&&A&&S.push(...function(e,a,n,t){const i=Axe(e);let r=function(e,a,n){const t=["left","right"],i=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(e){case"top":case"bottom":return n?a?i:t:a?t:i;case"left":case"right":return a?r:o;default:return[]}}(Sxe(e),"start"===n,t);return i&&(r=r.map((e=>e+"-"+i)),a&&(r=r.concat(r.map(Exe)))),r}(s,g,p,b));const w=[s,...S],C=await Lxe(a,v),M=[];let T=(null==(t=r.flip)?void 0:t.overflows)||[];if(c&&M.push(C[f]),d){const e=function(e,a,n){void 0===n&&(n=!1);const t=Axe(e),i=Txe(e),r=Cxe(i);let o="x"===i?t===(n?"end":"start")?"right":"left":"start"===t?"bottom":"top";return a.reference[r]>a.floating[r]&&(o=xxe(o)),[o,xxe(o)]}(i,o,b);M.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:i,overflows:M}],!M.every((e=>e<=0))){var E,x;const e=((null==(E=r.flip)?void 0:E.index)||0)+1,a=w[e];if(a)return{data:{index:e,overflows:T},reset:{placement:a}};let n=null==(x=T.filter((e=>e.overflows[0]<=0)).sort(((e,a)=>e.overflows[1]-a.overflows[1]))[0])?void 0:x.placement;if(!n)switch(h){case"bestFit":{var N;const e=null==(N=T.filter((e=>{if(A){const a=Mxe(e.placement);return a===y||"y"===a}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,a)=>e+a),0)])).sort(((e,a)=>e[1]-a[1]))[0])?void 0:N[0];e&&(n=e);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}},fNe=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(a){const{placement:n,rects:t,platform:i,elements:r}=a,{apply:o=()=>{},...s}=bxe(e,a),l=await Lxe(a,s),u=Sxe(n),c=Axe(n),d="y"===Mxe(n),{width:m,height:h}=t.floating;let p,g;"top"===u||"bottom"===u?(p=u,g=c===(await(null==i.isRTL?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(g=u,p="end"===c?"top":"bottom");const v=h-l.top-l.bottom,f=m-l.left-l.right,y=mxe(h-l[p],v),k=mxe(m-l[g],f),b=!a.middlewareData.shift;let S=y,A=k;if(d?A=c||b?mxe(k,f):f:S=c||b?mxe(y,v):v,b&&!c){const e=hxe(l.left,0),a=hxe(l.right,0),n=hxe(l.top,0),t=hxe(l.bottom,0);d?A=m-2*(0!==e||0!==a?e+a:hxe(l.left,l.right)):S=h-2*(0!==n||0!==t?n+t:hxe(l.top,l.bottom))}await o({...a,availableWidth:A,availableHeight:S});const w=await i.getDimensions(r.floating);return m!==w.width||h!==w.height?{reset:{rects:!0}}:{}}}},yNe=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(a){const{rects:n}=a,{strategy:t="referenceHidden",...i}=bxe(e,a);switch(t){case"referenceHidden":{const e=jxe(await Lxe(a,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Bxe(e)}}}case"escaped":{const e=jxe(await Lxe(a,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Bxe(e)}}}default:return{}}}}},kNe=e=>({name:"arrow",options:e,async fn(a){const{x:n,y:t,placement:i,rects:r,platform:o,elements:s,middlewareData:l}=a,{element:u,padding:c=0}=bxe(e,a)||{};if(null==u)return{};const d=Nxe(c),m={x:n,y:t},h=Txe(i),p=Cxe(h),g=await o.getDimensions(u),v="y"===h,f=v?"top":"left",y=v?"bottom":"right",k=v?"clientHeight":"clientWidth",b=r.reference[p]+r.reference[h]-m[h]-r.floating[p],S=m[h]-r.reference[h],A=await(null==o.getOffsetParent?void 0:o.getOffsetParent(u));let w=A?A[k]:0;w&&await(null==o.isElement?void 0:o.isElement(A))||(w=s.floating[k]||r.floating[p]);const C=b/2-S/2,M=w/2-g[p]/2-1,T=mxe(d[f],M),E=mxe(d[y],M),x=T,N=w-g[p]-E,_=w/2-g[p]/2+C,P=kxe(x,_,N),L=!l.arrow&&null!=Axe(i)&&_!==P&&r.reference[p]/2-(_<x?T:E)-g[p]/2<0,j=L?_<x?_-x:_-N:0;return{[h]:m[h]+j,data:{[h]:P,centerOffset:_-P-j,...L&&{alignmentOffset:j}},reset:L}}}),bNe=(e,a,n)=>{const t={platform:mNe,...n},i={...t.platform,_c:new Map};return(async(e,a,n)=>{const{placement:t="bottom",strategy:i="absolute",middleware:r=[],platform:o}=n,s=r.filter(Boolean),l=await(null==o.isRTL?void 0:o.isRTL(a));let u=await o.getElementRects({reference:e,floating:a,strategy:i}),{x:c,y:d}=Pxe(u,t,l),m=t,h={},p=0;for(let g=0;g<s.length;g++){const{name:n,fn:r}=s[g],{x:v,y:f,data:y,reset:k}=await r({x:c,y:d,initialPlacement:t,placement:m,strategy:i,middlewareData:h,rects:u,platform:o,elements:{reference:e,floating:a}});c=null!=v?v:c,d=null!=f?f:d,h={...h,[n]:{...h[n],...y}},k&&p<=50&&(p++,"object"==typeof k&&(k.placement&&(m=k.placement),k.rects&&(u=!0===k.rects?await o.getElementRects({reference:e,floating:a,strategy:i}):k.rects),({x:c,y:d}=Pxe(u,m,l))),g=-1)}return{x:c,y:d,placement:m,strategy:i,middlewareData:h}})(e,a,{...t,platform:i})},SNe=Ja();function ANe(){const e=Ua(SNe);if(void 0===e)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var wNe=Dn('<svg display="block" viewBox="0 0 30 30" style="transform:scale(1.02)"><g><path fill="none" d="M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z"></path><path stroke="none" d="M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z">'),CNe={top:180,right:-90,bottom:0,left:90};function MNe(e){const a=ANe(),n=aEe({size:30},e),[t,i]=yn(n,["ref","style","size"]),r=()=>a.currentPlacement().split("-")[0],o=function(e){const[a,n]=Pa();return Ba((()=>{const a=e();var t;a&&n((t=a,jTe(t).defaultView||window).getComputedStyle(a))})),a}(a.contentRef),s=()=>2*Number.parseInt(o()?.getPropertyValue(`border-${r()}-width`)||"0px")*(30/t.size);return mn(dEe,fn({as:"div",ref(e){const n=mTe(a.setArrowRef,t.ref);"function"==typeof n&&n(e)},"aria-hidden":"true",get style(){return ETe({position:"absolute","font-size":`${t.size}px`,width:"1em",height:"1em","pointer-events":"none",fill:o()?.getPropertyValue("background-color")||"none",stroke:o()?.getPropertyValue(`border-${r()}-color`)||"none","stroke-width":s()},t.style)}},i,{get children(){const e=wNe(),a=e.firstChild;return ja((()=>On(a,"transform",`rotate(${CNe[r()]} 15 15) translate(0 2)`))),e}}))}function TNe(e){const{x:a=0,y:n=0,width:t=0,height:i=0}=e??{};if("function"==typeof DOMRect)return new DOMRect(a,n,t,i);const r={x:a,y:n,width:t,height:i,top:n,right:a+t,bottom:n+i,left:a};return{...r,toJSON:()=>r}}function ENe(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var xNe={top:"bottom",right:"left",bottom:"top",left:"right"};var NNe=Object.assign((function(e){const a=aEe({getAnchorRect:e=>e?.getBoundingClientRect(),placement:"bottom",gutter:0,shift:0,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,hideWhenDetached:!1,detachedPadding:0,arrowPadding:4,overflowPadding:8},e),[n,t]=Pa(),[i,r]=Pa(),[o,s]=Pa(a.placement),l=()=>{return e=a.anchorRef?.(),n=a.getAnchorRect,{contextElement:e,getBoundingClientRect:()=>{const a=n(e);return a?TNe(a):e?e.getBoundingClientRect():TNe()}};var e,n},{direction:u}=HEe();async function c(){const e=l(),t=n(),r=i();if(!e||!t)return;const o=(r?.clientHeight||0)/2,c="number"==typeof a.gutter?a.gutter+o:a.gutter??o;t.style.setProperty("--kb-popper-content-overflow-padding",`${a.overflowPadding}px`),e.getBoundingClientRect();const d=[pNe((({placement:e})=>{const n=!!e.split("-")[1];return{mainAxis:c,crossAxis:n?void 0:a.shift,alignmentAxis:a.shift}}))];if(!1!==a.flip){const e="string"==typeof a.flip?a.flip.split(" "):void 0;if(void 0!==e&&!e.every(ENe))throw new Error("`flip` expects a spaced-delimited list of placements");d.push(vNe({padding:a.overflowPadding,fallbackPlacements:e}))}(a.slide||a.overlap)&&d.push(gNe({mainAxis:a.slide,crossAxis:a.overlap,padding:a.overflowPadding})),d.push(fNe({padding:a.overflowPadding,apply({availableWidth:e,availableHeight:n,rects:i}){const r=Math.round(i.reference.width);e=Math.floor(e),n=Math.floor(n),t.style.setProperty("--kb-popper-anchor-width",`${r}px`),t.style.setProperty("--kb-popper-content-available-width",`${e}px`),t.style.setProperty("--kb-popper-content-available-height",`${n}px`),a.sameWidth&&(t.style.width=`${r}px`),a.fitViewport&&(t.style.maxWidth=`${e}px`,t.style.maxHeight=`${n}px`)}})),a.hideWhenDetached&&d.push(yNe({padding:a.detachedPadding})),r&&d.push(kNe({element:r,padding:a.arrowPadding}));const m=await bNe(e,t,{placement:a.placement,strategy:"absolute",middleware:d,platform:{...mNe,isRTL:()=>"rtl"===u()}});if(s(m.placement),a.onCurrentPlacementChange?.(m.placement),!t)return;t.style.setProperty("--kb-popper-content-transform-origin",function(e,a){const[n,t]=e.split("-"),i=xNe[n];return t?"left"===n||"right"===n?`${i} ${"start"===t?"top":"bottom"}`:"start"===t?`${i} ${"rtl"===a?"right":"left"}`:`${i} ${"rtl"===a?"left":"right"}`:`${i} center`}(m.placement,u()));const h=Math.round(m.x),p=Math.round(m.y);let g;if(a.hideWhenDetached&&(g=m.middlewareData.hide?.referenceHidden?"hidden":"visible"),Object.assign(t.style,{top:"0",left:"0",transform:`translate3d(${h}px, ${p}px, 0)`,visibility:g}),r&&m.middlewareData.arrow){const{x:e,y:a}=m.middlewareData.arrow,n=m.placement.split("-")[0];Object.assign(r.style,{left:null!=e?`${e}px`:"",top:null!=a?`${a}px`:"",[n]:"100%"})}}return Ba((()=>{const e=l(),a=n();if(!e||!a)return;Ha(hNe(e,a,c,{elementResize:"function"==typeof ResizeObserver}))})),Ba((()=>{const e=n(),t=a.contentRef?.();e&&t&&queueMicrotask((()=>{e.style.zIndex=getComputedStyle(t).zIndex}))})),mn(SNe.Provider,{value:{currentPlacement:o,contentRef:()=>a.contentRef?.(),setPositionerRef:t,setArrowRef:r},get children(){return a.children}})}),{Arrow:MNe,Context:SNe,usePopperContext:ANe,Positioner:function(e){const a=ANe(),[n,t]=yn(e,["ref","style"]);return mn(dEe,fn({as:"div",ref(e){const t=mTe(a.setPositionerRef,n.ref);"function"==typeof t&&t(e)},"data-popper-positioner":"",get style(){return ETe({position:"absolute",top:0,left:0,"min-width":"max-content"},n.style)}},t))}});var _Ne="interactOutside.pointerDownOutside",PNe="interactOutside.focusOutside";var LNe=Ja();function jNe(e){let a;const n=Ua(LNe),[t,i]=yn(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]);!function(e,a){let n,t=eEe;const i=()=>jTe(a()),r=a=>e.onPointerDownOutside?.(a),o=a=>e.onFocusOutside?.(a),s=a=>e.onInteractOutside?.(a),l=n=>{const t=n.target;return t instanceof HTMLElement&&!t.closest(`[${exe}]`)&&!!PTe(i(),t)&&!PTe(a(),t)&&!e.shouldExcludeElement?.(t)},u=e=>{function n(){const n=a(),t=e.target;if(!n||!t||!l(e))return;const i=HTe([r,s]);t.addEventListener(_Ne,i,{once:!0});const o=new CustomEvent(_Ne,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:2===e.button||ITe(e)&&0===e.button}});t.dispatchEvent(o)}"touch"===e.pointerType?(i().removeEventListener("click",n),t=n,i().addEventListener("click",n,{once:!0})):n()},c=e=>{const n=a(),t=e.target;if(!n||!t||!l(e))return;const i=HTe([o,s]);t.addEventListener(PNe,i,{once:!0});const r=new CustomEvent(PNe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:!1}});t.dispatchEvent(r)};Ba((()=>{kMe(e.isDisabled)||(n=window.setTimeout((()=>{i().addEventListener("pointerdown",u,!0)}),0),i().addEventListener("focusin",c,!0),Ha((()=>{window.clearTimeout(n),i().removeEventListener("click",t),i().removeEventListener("pointerdown",u,!0),i().removeEventListener("focusin",c,!0)})))}))}({shouldExcludeElement:e=>!!a&&(t.excludedElements?.some((a=>PTe(a(),e)))||[...r].some((a=>PTe(a,e)))),onPointerDownOutside:e=>{a&&!sxe.isBelowPointerBlockingLayer(a)&&(t.bypassTopMostLayerCheck||sxe.isTopMostLayer(a))&&(t.onPointerDownOutside?.(e),t.onInteractOutside?.(e),e.defaultPrevented||t.onDismiss?.())},onFocusOutside:e=>{t.onFocusOutside?.(e),t.onInteractOutside?.(e),e.defaultPrevented||t.onDismiss?.()}},(()=>a)),function(e){const a=a=>{a.key===RTe.Escape&&e.onEscapeKeyDown?.(a)};Ba((()=>{if(kMe(e.isDisabled))return;const n=e.ownerDocument?.()??jTe();n.addEventListener("keydown",a),Ha((()=>{n.removeEventListener("keydown",a)}))}))}({ownerDocument:()=>jTe(a),onEscapeKeyDown:e=>{a&&sxe.isTopMostLayer(a)&&(t.onEscapeKeyDown?.(e),!e.defaultPrevented&&t.onDismiss&&(e.preventDefault(),t.onDismiss()))}}),Oa((()=>{if(!a)return;sxe.addLayer({node:a,isPointerBlocking:t.disableOutsidePointerEvents,dismiss:t.onDismiss});const e=n?.registerNestedLayer(a);sxe.assignPointerEventToLayers(),sxe.disableBodyPointerEvents(a),Ha((()=>{a&&(sxe.removeLayer(a),e?.(),sxe.assignPointerEventToLayers(),sxe.restoreBodyPointerEvents(a))}))})),Ba(Ka([()=>a,()=>t.disableOutsidePointerEvents],(([e,a])=>{if(!e)return;const n=sxe.find(e);n&&n.isPointerBlocking!==a&&(n.isPointerBlocking=a,sxe.assignPointerEventToLayers()),a&&sxe.disableBodyPointerEvents(e),Ha((()=>{sxe.restoreBodyPointerEvents(e)}))}),{defer:!0}));return mn(LNe.Provider,{value:{registerNestedLayer:e=>{r.add(e);const a=n?.registerNestedLayer(e);return()=>{r.delete(e),a?.()}}},get children(){return mn(dEe,fn({as:"div",ref(e){const n=mTe((e=>a=e),t.ref);"function"==typeof n&&n(e)}},i))}})}function BNe(e={}){const[a,n]=bEe({value:()=>kMe(e.open),defaultValue:()=>!!kMe(e.defaultOpen),onChange:a=>e.onOpenChange?.(a)}),t=()=>{n(!0)},i=()=>{n(!1)};return{isOpen:a,setIsOpen:n,open:t,close:i,toggle:()=>{a()?i():t()}}}var RNe={};AEe(RNe,{Description:()=>gEe,ErrorMessage:()=>vEe,Item:()=>HNe,ItemControl:()=>INe,ItemDescription:()=>GNe,ItemIndicator:()=>FNe,ItemInput:()=>VNe,ItemLabel:()=>JNe,Label:()=>UNe,RadioGroup:()=>qNe,Root:()=>WNe});var zNe=Ja();function DNe(){const e=Ua(zNe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupContext` must be used within a `RadioGroup` component");return e}var KNe=Ja();function ONe(){const e=Ua(KNe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupItemContext` must be used within a `RadioGroup.Item` component");return e}function HNe(e){const a=pEe(),n=DNe(),t=aEe({id:`${a.generateId("item")}-${Sn()}`},e),[i,r]=yn(t,["value","disabled","onPointerDown"]),[o,s]=Pa(),[l,u]=Pa(),[c,d]=Pa(),[m,h]=Pa(),[p,g]=Pa(!1),v=Ra((()=>n.isSelectedValue(i.value))),f=Ra((()=>i.disabled||a.isDisabled()||!1)),y=e=>{OTe(e,i.onPointerDown),p()&&e.preventDefault()},k=Ra((()=>({...a.dataset(),"data-disabled":f()?"":void 0,"data-checked":v()?"":void 0}))),b={value:()=>i.value,dataset:k,isSelected:v,isDisabled:f,inputId:o,labelId:l,descriptionId:c,inputRef:m,select:()=>n.setSelectedValue(i.value),generateId:_Te((()=>r.id)),registerInput:lEe(s),registerLabel:lEe(u),registerDescription:lEe(d),setIsFocused:g,setInputRef:h};return mn(KNe.Provider,{value:b,get children(){return mn(dEe,fn({as:"div",role:"group",onPointerDown:y},k,r))}})}function INe(e){const a=ONe(),n=aEe({id:a.generateId("control")},e),[t,i]=yn(n,["onClick","onKeyDown"]);return mn(dEe,fn({as:"div",onClick:e=>{OTe(e,t.onClick),a.select(),a.inputRef()?.focus()},onKeyDown:e=>{OTe(e,t.onKeyDown),e.key===RTe.Space&&(a.select(),a.inputRef()?.focus())}},(()=>a.dataset()),i))}function GNe(e){const a=ONe(),n=aEe({id:a.generateId("description")},e);return Ba((()=>Ha(a.registerDescription(n.id)))),mn(dEe,fn({as:"div"},(()=>a.dataset()),n))}function FNe(e){const a=ONe(),n=aEe({id:a.generateId("indicator")},e),[t,i]=yn(n,["ref","forceMount"]),[r,o]=Pa(),{present:s}=XEe({show:()=>t.forceMount||a.isSelected(),element:()=>r()??null});return mn(Mn,{get when(){return s()},get children(){return mn(dEe,fn({as:"div",ref(e){const a=mTe(o,t.ref);"function"==typeof a&&a(e)}},(()=>a.dataset()),i))}})}function VNe(e){const a=pEe(),n=DNe(),t=ONe(),i=aEe({id:t.generateId("input")},e),[r,o]=yn(i,["ref","style","aria-labelledby","aria-describedby","onChange","onFocus","onBlur"]),[s,l]=Pa(!1);return Ba(Ka([()=>t.isSelected(),()=>t.value()],(e=>{if(!e[0]&&e[1]===t.value())return;l(!0);const a=t.inputRef();a?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),a?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))}),{defer:!0})),Ba((()=>Ha(t.registerInput(o.id)))),mn(dEe,fn({as:"input",ref(e){const a=mTe(t.setInputRef,r.ref);"function"==typeof a&&a(e)},type:"radio",get name(){return a.name()},get value(){return t.value()},get checked(){return t.isSelected()},get required(){return a.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return a.isReadOnly()},get style(){return ETe({...sEe},r.style)},get"aria-labelledby"(){return[r["aria-labelledby"],t.labelId(),null!=r["aria-labelledby"]&&null!=o["aria-label"]?o.id:void 0].filter(Boolean).join(" ")||void 0},get"aria-describedby"(){return[r["aria-describedby"],t.descriptionId(),n.ariaDescribedBy()].filter(Boolean).join(" ")||void 0},onChange:e=>{if(OTe(e,r.onChange),e.stopPropagation(),!s()){n.setSelectedValue(t.value());e.target.checked=t.isSelected()}l(!1)},onFocus:e=>{OTe(e,r.onFocus),t.setIsFocused(!0)},onBlur:e=>{OTe(e,r.onBlur),t.setIsFocused(!1)}},(()=>t.dataset()),o))}function JNe(e){const a=ONe(),n=aEe({id:a.generateId("label")},e);return Ba((()=>Ha(a.registerLabel(n.id)))),mn(dEe,fn({as:"label",get for(){return a.inputId()}},(()=>a.dataset()),n))}function UNe(e){return mn(fEe,fn({as:"span"},e))}function WNe(e){let a;const n=aEe({id:`radiogroup-${Sn()}`,orientation:"vertical"},e),[t,i,r]=yn(n,["ref","value","defaultValue","onChange","orientation","aria-labelledby","aria-describedby"],mEe),[o,s]=kEe({value:()=>t.value,defaultValue:()=>t.defaultValue,onChange:e=>t.onChange?.(e)}),{formControlContext:l}=function(e){const a=aEe({id:`form-control-${Sn()}`},e),[n,t]=Pa(),[i,r]=Pa(),[o,s]=Pa(),[l,u]=Pa();return{formControlContext:{name:()=>kMe(a.name)??kMe(a.id),dataset:Ra((()=>({"data-valid":"valid"===kMe(a.validationState)?"":void 0,"data-invalid":"invalid"===kMe(a.validationState)?"":void 0,"data-required":kMe(a.required)?"":void 0,"data-disabled":kMe(a.disabled)?"":void 0,"data-readonly":kMe(a.readOnly)?"":void 0}))),validationState:()=>kMe(a.validationState),isRequired:()=>kMe(a.required),isDisabled:()=>kMe(a.disabled),isReadOnly:()=>kMe(a.readOnly),labelId:n,fieldId:i,descriptionId:o,errorMessageId:l,getAriaLabelledBy:(e,a,t)=>{const i=null!=t||null!=n();return[t,n(),i&&null!=a?e:void 0].filter(Boolean).join(" ")||void 0},getAriaDescribedBy:e=>[o(),l(),e].filter(Boolean).join(" ")||void 0,generateId:_Te((()=>kMe(a.id))),registerLabel:lEe(t),registerField:lEe(r),registerDescription:lEe(s),registerErrorMessage:lEe(u)}}}(i);yEe((()=>a),(()=>s(t.defaultValue??"")));const u=()=>l.getAriaDescribedBy(t["aria-describedby"]),c=e=>e===o(),d={ariaDescribedBy:u,isSelectedValue:c,setSelectedValue:e=>{if(!l.isReadOnly()&&!l.isDisabled()&&(s(e),a))for(const n of a.querySelectorAll("[type='radio']")){n.checked=c(n.value)}}};return mn(hEe.Provider,{value:l,get children(){return mn(zNe.Provider,{value:d,get children(){return mn(dEe,fn({as:"div",ref(e){const n=mTe((e=>a=e),t.ref);"function"==typeof n&&n(e)},role:"radiogroup",get id(){return kMe(i.id)},get"aria-invalid"(){return"invalid"===l.validationState()||void 0},get"aria-required"(){return l.isRequired()||void 0},get"aria-disabled"(){return l.isDisabled()||void 0},get"aria-readonly"(){return l.isReadOnly()||void 0},get"aria-orientation"(){return t.orientation},get"aria-labelledby"(){return l.getAriaLabelledBy(kMe(i.id),r["aria-label"],t["aria-labelledby"])},get"aria-describedby"(){return u()}},(()=>l.dataset()),r))}})}})}var qNe=Object.assign(WNe,{Description:gEe,ErrorMessage:vEe,Item:HNe,ItemControl:INe,ItemDescription:GNe,ItemIndicator:FNe,ItemInput:VNe,ItemLabel:JNe,Label:UNe}),ZNe=class{collection;ref;collator;constructor(e,a,n){this.collection=e,this.ref=a,this.collator=n}getKeyBelow(e){let a=this.collection().getKeyAfter(e);for(;null!=a;){const e=this.collection().getItem(a);if(e&&"item"===e.type&&!e.disabled)return a;a=this.collection().getKeyAfter(a)}}getKeyAbove(e){let a=this.collection().getKeyBefore(e);for(;null!=a;){const e=this.collection().getItem(a);if(e&&"item"===e.type&&!e.disabled)return a;a=this.collection().getKeyBefore(a)}}getFirstKey(){let e=this.collection().getFirstKey();for(;null!=e;){const a=this.collection().getItem(e);if(a&&"item"===a.type&&!a.disabled)return e;e=this.collection().getKeyAfter(e)}}getLastKey(){let e=this.collection().getLastKey();for(;null!=e;){const a=this.collection().getItem(e);if(a&&"item"===a.type&&!a.disabled)return e;e=this.collection().getKeyBefore(e)}}getItem(e){return this.ref?.()?.querySelector(`[data-key="${e}"]`)??null}getKeyPageAbove(e){const a=this.ref?.();let n=this.getItem(e);if(!a||!n)return;const t=Math.max(0,n.offsetTop+n.offsetHeight-a.offsetHeight);let i=e;for(;i&&n&&n.offsetTop>t;)i=this.getKeyAbove(i),n=null!=i?this.getItem(i):null;return i}getKeyPageBelow(e){const a=this.ref?.();let n=this.getItem(e);if(!a||!n)return;const t=Math.min(a.scrollHeight,n.offsetTop-n.offsetHeight+a.offsetHeight);let i=e;for(;i&&n&&n.offsetTop<t;)i=this.getKeyBelow(i),n=null!=i?this.getItem(i):null;return i}getKeyForSearch(e,a){const n=this.collator?.();if(!n)return;let t=null!=a?this.getKeyBelow(a):this.getFirstKey();for(;null!=t;){const a=this.collection().getItem(t);if(a){const i=a.textValue.slice(0,e.length);if(a.textValue&&0===n.compare(i,e))return t}t=this.getKeyBelow(t)}}};function $Ne(e,a,n){const t=function(e){const{locale:a}=HEe(),n=Ra((()=>a()+(e?Object.entries(e).sort(((e,a)=>e[0]<a[0]?-1:1)).join():"")));return Ra((()=>{const t=n();let i;return IEe.has(t)&&(i=IEe.get(t)),i||(i=new Intl.Collator(a(),e),IEe.set(t,i)),i}))}({usage:"search",sensitivity:"base"});return WEe({selectionManager:()=>kMe(e.selectionManager),keyboardDelegate:Ra((()=>{const n=kMe(e.keyboardDelegate);return n||new ZNe(e.collection,a,t)})),autoFocus:()=>kMe(e.autoFocus),deferAutoFocus:()=>kMe(e.deferAutoFocus),shouldFocusWrap:()=>kMe(e.shouldFocusWrap),disallowEmptySelection:()=>kMe(e.disallowEmptySelection),selectOnFocus:()=>kMe(e.selectOnFocus),disallowTypeAhead:()=>kMe(e.disallowTypeAhead),shouldUseVirtualFocus:()=>kMe(e.shouldUseVirtualFocus),allowsTabNavigation:()=>kMe(e.allowsTabNavigation),isVirtualized:()=>kMe(e.isVirtualized),scrollToKey:a=>kMe(e.scrollToKey)?.(a),orientation:()=>kMe(e.orientation)},a)}var YNe="focusScope.autoFocusOnMount",QNe="focusScope.autoFocusOnUnmount",XNe={bubbles:!1,cancelable:!0},e_e={stack:[],active(){return this.stack[0]},add(e){e!==this.active()&&this.active()?.pause(),this.stack=xTe(this.stack,e),this.stack.unshift(e)},remove(e){this.stack=xTe(this.stack,e),this.active()?.resume()}};function a_e(e,a){const[n,t]=Pa(!1),i={pause(){t(!0)},resume(){t(!1)}};let r=null;const o=a=>e.onMountAutoFocus?.(a),s=a=>e.onUnmountAutoFocus?.(a),l=()=>jTe(a()),u=()=>{const e=l().createElement("span");return e.setAttribute("data-focus-trap",""),e.tabIndex=0,Object.assign(e.style,sEe),e},c=()=>{const e=a();return e?qTe(e,!0).filter((e=>!e.hasAttribute("data-focus-trap"))):[]},d=()=>{const e=c();return e.length>0?e[0]:null};Ba((()=>{const e=a();if(!e)return;e_e.add(i);const n=LTe(e);if(!PTe(e,n)){const a=new CustomEvent(YNe,XNe);e.addEventListener(YNe,o),e.dispatchEvent(a),a.defaultPrevented||setTimeout((()=>{GTe(d()),LTe(e)===n&&GTe(e)}),0)}Ha((()=>{e.removeEventListener(YNe,o),setTimeout((()=>{const t=new CustomEvent(QNe,XNe);(()=>{const e=a();if(!e)return!1;const n=LTe(e);return!!n&&!PTe(e,n)&&$Te(n)})()&&t.preventDefault(),e.addEventListener(QNe,s),e.dispatchEvent(t),t.defaultPrevented||GTe(n??l().body),e.removeEventListener(QNe,s),e_e.remove(i)}),0)}))})),Ba((()=>{const t=a();if(!t||!kMe(e.trapFocus)||n())return;const i=e=>{const a=e.target;a?.closest(`[${exe}]`)||(PTe(t,a)?r=a:GTe(r))},o=e=>{const a=e.relatedTarget??LTe(t);a?.closest(`[${exe}]`)||PTe(t,a)||GTe(r)};l().addEventListener("focusin",i),l().addEventListener("focusout",o),Ha((()=>{l().removeEventListener("focusin",i),l().removeEventListener("focusout",o)}))})),Ba((()=>{const t=a();if(!t||!kMe(e.trapFocus)||n())return;const i=u();t.insertAdjacentElement("afterbegin",i);const r=u();function o(e){const a=d(),n=(()=>{const e=c();return e.length>0?e[e.length-1]:null})();GTe(e.relatedTarget===a?n:a)}t.insertAdjacentElement("beforeend",r),i.addEventListener("focusin",o),r.addEventListener("focusin",o);const s=new MutationObserver((e=>{for(const a of e)a.previousSibling===r&&(r.remove(),t.insertAdjacentElement("beforeend",r)),a.nextSibling===i&&(i.remove(),t.insertAdjacentElement("afterbegin",i))}));s.observe(t,{childList:!0,subtree:!1}),Ha((()=>{i.removeEventListener("focusin",o),r.removeEventListener("focusin",o),i.remove(),r.remove(),s.disconnect()}))}))}var n_e="data-live-announcer";function t_e(e){Ba((()=>{kMe(e.isDisabled)||Ha(function(e,a=document.body){const n=new Set(e),t=new Set,i=e=>{for(const t of e.querySelectorAll(`[${n_e}], [${exe}]`))n.add(t);const a=e=>{if(n.has(e)||e.parentElement&&t.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(const a of n)if(e.contains(a))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a}),o=a(e);if(o===NodeFilter.FILTER_ACCEPT&&r(e),o!==NodeFilter.FILTER_REJECT){let e=i.nextNode();for(;null!=e;)r(e),e=i.nextNode()}},r=e=>{const a=i_e.get(e)??0;"true"===e.getAttribute("aria-hidden")&&0===a||(0===a&&e.setAttribute("aria-hidden","true"),t.add(e),i_e.set(e,a+1))};r_e.length&&r_e[r_e.length-1].disconnect();i(a);const o=new MutationObserver((e=>{for(const a of e)if("childList"===a.type&&0!==a.addedNodes.length&&![...n,...t].some((e=>e.contains(a.target)))){for(const e of a.removedNodes)e instanceof Element&&(n.delete(e),t.delete(e));for(const e of a.addedNodes)!(e instanceof HTMLElement||e instanceof SVGElement)||"true"!==e.dataset.liveAnnouncer&&"true"!==e.dataset.reactAriaTopLayer?e instanceof Element&&i(e):n.add(e)}}));o.observe(a,{childList:!0,subtree:!0});const s={observe(){o.observe(a,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return r_e.push(s),()=>{o.disconnect();for(const e of t){const a=i_e.get(e);if(null==a)return;1===a?(e.removeAttribute("aria-hidden"),i_e.delete(e)):i_e.set(e,a-1)}s===r_e[r_e.length-1]?(r_e.pop(),r_e.length&&r_e[r_e.length-1].observe()):r_e.splice(r_e.indexOf(s),1)}}(kMe(e.targets),kMe(e.root)))}))}var i_e=new WeakMap,r_e=[];var o_e=new Map,s_e=e=>{Ba((()=>{const a=QEe(e.style)??{},n=QEe(e.properties)??[],t={};for(const r in a)t[r]=e.element.style[r];const i=o_e.get(e.key);i?i.activeCount++:o_e.set(e.key,{activeCount:1,originalStyles:t,properties:n.map((e=>e.key))}),Object.assign(e.element.style,e.style);for(const r of n)e.element.style.setProperty(r.key,r.value);Ha((()=>{const a=o_e.get(e.key);if(a)if(1===a.activeCount){o_e.delete(e.key);for(const[n,t]of Object.entries(a.originalStyles))e.element.style[n]=t;for(const n of a.properties)e.element.style.removeProperty(n);0===e.element.style.length&&e.element.removeAttribute("style"),e.cleanup?.()}else a.activeCount--}))}))},l_e=(e,a)=>{switch(a){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},u_e=(e,a)=>{const n=getComputedStyle(e),t="x"===a?n.overflowX:n.overflowY;return"auto"===t||"scroll"===t||"HTML"===e.tagName&&"visible"===t},[c_e,d_e]=Pa([]),m_e=e=>[e.deltaX,e.deltaY],h_e=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],p_e=(e,a,n,t)=>{const i=null!==t&&g_e(t,e),[r,o]=((e,a,n)=>{const t="x"===a&&"rtl"===window.getComputedStyle(e).direction?-1:1;let i=e,r=0,o=0,s=!1;do{const[e,l,u]=l_e(i,a),c=u-e-t*l;0===l&&0===c||!u_e(i,a)||(r+=c,o+=l),i===(n??document.documentElement)?s=!0:i=i._$host??i.parentElement}while(i&&!s);return[r,o]})(e,a,i?t:void 0);return!(n>0&&Math.abs(r)<=1)&&!(n<0&&Math.abs(o)<1)},g_e=(e,a)=>{if(e.contains(a))return!0;let n=a;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},v_e=e=>{const a=fn({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=Sn();let t=[0,0],i=null,r=null;Ba((()=>{QEe(a.enabled)&&(d_e((e=>[...e,n])),Ha((()=>{d_e((e=>e.filter((e=>e!==n))))})))})),Ba((()=>{if(!QEe(a.enabled)||!QEe(a.hideScrollbar))return;const{body:e}=document,n=window.innerWidth-e.offsetWidth;if(QEe(a.preventScrollbarShift)){const t={overflow:"hidden"},i=[];n>0&&("padding"===QEe(a.preventScrollbarShiftMode)?t.paddingRight=`calc(${window.getComputedStyle(e).paddingRight} + ${n}px)`:t.marginRight=`calc(${window.getComputedStyle(e).marginRight} + ${n}px)`,i.push({key:"--scrollbar-width",value:`${n}px`}));const r=window.scrollY,o=window.scrollX;s_e({key:"prevent-scroll",element:e,style:t,properties:i,cleanup:()=>{QEe(a.restoreScrollPosition)&&n>0&&window.scrollTo(o,r)}})}else s_e({key:"prevent-scroll",element:e,style:{overflow:"hidden"}})})),Ba((()=>{var e;(e=n,c_e().indexOf(e)===c_e().length-1&&QEe(a.enabled))&&(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Ha((()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)})))}));const o=e=>{t=h_e(e),i=null,r=null},s=e=>{const n=e.target,t=QEe(a.element),i=m_e(e),r=Math.abs(i[0])>Math.abs(i[1])?"x":"y",o=p_e(n,r,"x"===r?i[0]:i[1],t);let s;s=!t||!g_e(t,n)||!o,s&&e.cancelable&&e.preventDefault()},l=e=>{const n=QEe(a.element),o=e.target;let s;if(2===e.touches.length)s=!QEe(a.allowPinchZoom);else{if(null==i||null===r){const a=h_e(e).map(((e,a)=>t[a]-e)),n=Math.abs(a[0])>Math.abs(a[1])?"x":"y";i=n,r="x"===n?a[0]:a[1]}if("range"===o.type)s=!1;else{const e=p_e(o,i,r,n);s=!n||!g_e(n,o)||!e}}s&&e.cancelable&&e.preventDefault()}},f_e=v_e,y_e=Ja();function k_e(){return Ua(y_e)}function b_e(){const e=k_e();if(void 0===e)throw new Error("[kobalte]: `useMenuContext` must be used within a `Menu` component");return e}var S_e=Ja();function A_e(){const e=Ua(S_e);if(void 0===e)throw new Error("[kobalte]: `useMenuItemContext` must be used within a `Menu.Item` component");return e}var w_e=Ja();function C_e(){const e=Ua(w_e);if(void 0===e)throw new Error("[kobalte]: `useMenuRootContext` must be used within a `MenuRoot` component");return e}function M_e(e){let a;const n=C_e(),t=b_e(),i=aEe({id:n.generateId(`item-${Sn()}`)},e),[r,o]=yn(i,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[s,l]=Pa(),[u,c]=Pa(),[d,m]=Pa(),h=()=>t.listState().selectionManager(),p=()=>o.id,g=()=>{r.onSelect?.(),r.closeOnSelect&&setTimeout((()=>{t.close(!0)}))};NEe({getItem:()=>({ref:()=>a,type:"item",key:p(),textValue:r.textValue??d()?.textContent??a?.textContent??"",disabled:r.disabled??!1})});const v=qEe({key:p,selectionManager:h,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),f=e=>{OTe(e,r.onPointerMove),"mouse"===e.pointerType&&(r.disabled?t.onItemLeave(e):(t.onItemEnter(e),e.defaultPrevented||(GTe(e.currentTarget),t.listState().selectionManager().setFocused(!0),t.listState().selectionManager().setFocusedKey(p()))))},y=e=>{OTe(e,r.onPointerLeave),"mouse"===e.pointerType&&t.onItemLeave(e)},k=e=>{OTe(e,r.onPointerUp),r.disabled||0!==e.button||g()},b=e=>{if(OTe(e,r.onKeyDown),!e.repeat&&!r.disabled)switch(e.key){case"Enter":case" ":g()}},S=Ra((()=>r.indeterminate?"mixed":null!=r.checked?r.checked:void 0)),A=Ra((()=>({"data-indeterminate":r.indeterminate?"":void 0,"data-checked":r.checked&&!r.indeterminate?"":void 0,"data-disabled":r.disabled?"":void 0,"data-highlighted":h().focusedKey()===p()?"":void 0}))),w={isChecked:()=>r.checked,dataset:A,setLabelRef:m,generateId:_Te((()=>o.id)),registerLabel:lEe(l),registerDescription:lEe(c)};return mn(S_e.Provider,{value:w,get children(){return mn(dEe,fn({as:"div",ref(e){const n=mTe((e=>a=e),r.ref);"function"==typeof n&&n(e)},get tabIndex(){return v.tabIndex()},get"aria-checked"(){return S()},get"aria-disabled"(){return r.disabled},get"aria-labelledby"(){return s()},get"aria-describedby"(){return u()},get"data-key"(){return v.dataKey()},get onPointerDown(){return HTe([r.onPointerDown,v.onPointerDown])},get onPointerUp(){return HTe([k,v.onPointerUp])},get onClick(){return HTe([r.onClick,v.onClick])},get onKeyDown(){return HTe([b,v.onKeyDown])},get onMouseDown(){return HTe([r.onMouseDown,v.onMouseDown])},get onFocus(){return HTe([r.onFocus,v.onFocus])},onPointerMove:f,onPointerLeave:y},A,o))}})}function T_e(e){const a=aEe({closeOnSelect:!1},e),[n,t]=yn(a,["checked","defaultChecked","onChange","onSelect"]),i=function(e={}){const[a,n]=bEe({value:()=>kMe(e.isSelected),defaultValue:()=>!!kMe(e.defaultIsSelected),onChange:a=>e.onSelectedChange?.(a)});return{isSelected:a,setIsSelected:a=>{kMe(e.isReadOnly)||kMe(e.isDisabled)||n(a)},toggle:()=>{kMe(e.isReadOnly)||kMe(e.isDisabled)||n(!a())}}}({isSelected:()=>n.checked,defaultIsSelected:()=>n.defaultChecked,onSelectedChange:e=>n.onChange?.(e),isDisabled:()=>t.disabled});return mn(M_e,fn({role:"menuitemcheckbox",get checked(){return i.isSelected()},onSelect:()=>{n.onSelect?.(),i.toggle()}},t))}var E_e=Ja();function x_e(){return Ua(E_e)}var N_e={next:(e,a)=>"ltr"===e?"horizontal"===a?"ArrowRight":"ArrowDown":"horizontal"===a?"ArrowLeft":"ArrowUp",previous:(e,a)=>N_e.next("ltr"===e?"rtl":"ltr",a)},__e=e=>"horizontal"===e?"ArrowDown":"ArrowRight",P_e=e=>"horizontal"===e?"ArrowUp":"ArrowLeft";function L_e(e){const a=C_e(),n=b_e(),t=x_e(),{direction:i}=HEe(),r=aEe({id:a.generateId("trigger")},e),[o,s]=yn(r,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let l=()=>a.value();void 0!==t&&(l=()=>a.value()??o.id,void 0===t.lastValue()&&t.setLastValue(l));const u=uEe((()=>n.triggerRef()),(()=>"button")),c=Ra((()=>"a"===u()&&null!=n.triggerRef()?.getAttribute("href")));Ba(Ka((()=>t?.value()),(e=>{c()&&e===l()&&n.triggerRef()?.focus()})));const d=()=>{void 0!==t?n.isOpen()?t.value()===l()&&t.closeMenu():(t.autoFocusMenu()||t.setAutoFocusMenu(!0),n.open(!1)):n.toggle(!0)};return Ba((()=>Ha(n.registerTriggerId(o.id)))),mn(uxe,fn({ref(e){const a=mTe(n.setTriggerRef,o.ref);"function"==typeof a&&a(e)},get"data-kb-menu-value-trigger"(){return a.value()},get id(){return o.id},get disabled(){return o.disabled},"aria-haspopup":"true",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return Ra((()=>!!n.isOpen()))()?n.contentId():void 0},get"data-highlighted"(){return void 0!==l()&&t?.value()===l()||void 0},get tabIndex(){return void 0!==t?t.value()===l()||t.lastValue()===l()?0:-1:void 0},onPointerDown:e=>{OTe(e,o.onPointerDown),e.currentTarget.dataset.pointerType=e.pointerType,o.disabled||"touch"===e.pointerType||0!==e.button||d()},onMouseOver:e=>{OTe(e,o.onMouseOver),"touch"!==n.triggerRef()?.dataset.pointerType&&(o.disabled||void 0===t||void 0===t.value()||t.setValue(l))},onClick:e=>{OTe(e,o.onClick),o.disabled||"touch"===e.currentTarget.dataset.pointerType&&d()},onKeyDown:e=>{if(OTe(e,o.onKeyDown),!o.disabled){if(c())switch(e.key){case"Enter":case" ":return}switch(e.key){case"Enter":case" ":case __e(a.orientation()):e.stopPropagation(),e.preventDefault(),function(e){if(document.contains(e)){const a=document.scrollingElement||document.documentElement;if("hidden"===window.getComputedStyle(a).overflow){let n=QTe(e);for(;e&&n&&e!==a&&n!==a;)rEe(n,e),n=QTe(e=n)}else{const{left:a,top:n}=e.getBoundingClientRect();e?.scrollIntoView?.({block:"nearest"});const{left:t,top:i}=e.getBoundingClientRect();(Math.abs(a-t)>1||Math.abs(n-i)>1)&&e.scrollIntoView?.({block:"nearest"})}}}(e.currentTarget),n.open("first"),t?.setAutoFocusMenu(!0),t?.setValue(l);break;case P_e(a.orientation()):e.stopPropagation(),e.preventDefault(),n.open("last");break;case N_e.next(i(),a.orientation()):if(void 0===t)break;e.stopPropagation(),e.preventDefault(),t.nextMenu();break;case N_e.previous(i(),a.orientation()):if(void 0===t)break;e.stopPropagation(),e.preventDefault(),t.previousMenu()}}},onFocus:e=>{OTe(e,o.onFocus),void 0!==t&&"touch"!==e.currentTarget.dataset.pointerType&&t.setValue(l)},role:void 0!==t?"menuitem":void 0},(()=>n.dataset()),s))}var j_e=Ja();function B_e(){return Ua(j_e)}function R_e(e){let a;const n=C_e(),t=b_e(),i=x_e(),r=B_e(),{direction:o}=HEe(),s=aEe({id:n.generateId(`content-${Sn()}`)},e),[l,u]=yn(s,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let c=0;const d=()=>null==t.parentMenuContext()&&void 0===i&&n.isModal(),m=$Ne({selectionManager:t.listState().selectionManager,collection:t.listState().collection,autoFocus:t.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!t.listState().selectionManager().isFocused(),orientation:()=>"horizontal"===n.orientation()?"vertical":"horizontal"},(()=>a));a_e({trapFocus:()=>d()&&t.isOpen(),onMountAutoFocus:e=>{void 0===i&&l.onOpenAutoFocus?.(e)},onUnmountAutoFocus:l.onCloseAutoFocus},(()=>a));const h=e=>{l.onEscapeKeyDown?.(e),i?.setAutoFocusMenu(!1),t.close(!0)},p=e=>{l.onFocusOutside?.(e),n.isModal()&&e.preventDefault()};Ba((()=>Ha(t.registerContentId(l.id))));const g={ref:mTe((e=>{t.setContentRef(e),a=e}),l.ref),role:"menu",get id(){return l.id},get tabIndex(){return m.tabIndex()},get"aria-labelledby"(){return t.triggerId()},onKeyDown:HTe([l.onKeyDown,m.onKeyDown,e=>{if(PTe(e.currentTarget,e.target)&&("Tab"===e.key&&t.isOpen()&&e.preventDefault(),void 0!==i&&"true"!==e.currentTarget.getAttribute("aria-haspopup")))switch(e.key){case N_e.next(o(),n.orientation()):e.stopPropagation(),e.preventDefault(),t.close(!0),i.setAutoFocusMenu(!0),i.nextMenu();break;case N_e.previous(o(),n.orientation()):if(e.currentTarget.hasAttribute("data-closed"))break;e.stopPropagation(),e.preventDefault(),t.close(!0),i.setAutoFocusMenu(!0),i.previousMenu()}}]),onMouseDown:HTe([l.onMouseDown,m.onMouseDown]),onFocusIn:HTe([l.onFocusIn,m.onFocusIn]),onFocusOut:HTe([l.onFocusOut,m.onFocusOut]),onPointerEnter:e=>{OTe(e,l.onPointerEnter),t.isOpen()&&(t.parentMenuContext()?.listState().selectionManager().setFocused(!1),t.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},onPointerMove:e=>{if(OTe(e,l.onPointerMove),"mouse"!==e.pointerType)return;const a=c!==e.clientX;PTe(e.currentTarget,e.target)&&a&&(t.setPointerDir(e.clientX>c?"right":"left"),c=e.clientX)},get"data-orientation"(){return n.orientation()}};return mn(Mn,{get when(){return t.contentPresent()},get children(){return mn(Mn,{get when(){return void 0===r||null!=t.parentMenuContext()},get fallback(){return mn(dEe,fn({as:"div"},(()=>t.dataset()),g,u))},get children(){return mn(NNe.Positioner,{get children(){return mn(jNe,fn({get disableOutsidePointerEvents(){return Ra((()=>!!d()))()&&t.isOpen()},get excludedElements(){return[t.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return ETe({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},l.style)},onEscapeKeyDown:h,onFocusOutside:p,get onDismiss(){return t.close}},(()=>t.dataset()),g,u))}})}})}})}function z_e(e){let a;const n=C_e(),t=b_e(),[i,r]=yn(e,["ref"]);return f_e({element:()=>a??null,enabled:()=>t.contentPresent()&&n.preventScroll()}),mn(R_e,fn({ref(e){const n=mTe((e=>{a=e}),i.ref);"function"==typeof n&&n(e)}},r))}var D_e=Ja();function K_e(e){const a=aEe({id:C_e().generateId(`group-${Sn()}`)},e),[n,t]=Pa(),i={generateId:_Te((()=>a.id)),registerLabelId:lEe(t)};return mn(D_e.Provider,{value:i,get children(){return mn(dEe,fn({as:"div",role:"group",get"aria-labelledby"(){return n()}},a))}})}function O_e(e){const a=function(){const e=Ua(D_e);if(void 0===e)throw new Error("[kobalte]: `useMenuGroupContext` must be used within a `Menu.Group` component");return e}(),n=aEe({id:a.generateId("label")},e),[t,i]=yn(n,["id"]);return Ba((()=>Ha(a.registerLabelId(t.id)))),mn(dEe,fn({as:"span",get id(){return t.id},"aria-hidden":"true"},i))}function H_e(e){const a=b_e();return mn(dEe,fn({as:"span","aria-hidden":"true"},(()=>a.dataset()),aEe({children:"▼"},e)))}function I_e(e){return mn(M_e,fn({role:"menuitem",closeOnSelect:!0},e))}function G_e(e){const a=A_e(),n=aEe({id:a.generateId("description")},e),[t,i]=yn(n,["id"]);return Ba((()=>Ha(a.registerDescription(t.id)))),mn(dEe,fn({as:"div",get id(){return t.id}},(()=>a.dataset()),i))}function F_e(e){const a=A_e(),n=aEe({id:a.generateId("indicator")},e),[t,i]=yn(n,["forceMount"]);return mn(Mn,{get when(){return t.forceMount||a.isChecked()},get children(){return mn(dEe,fn({as:"div"},(()=>a.dataset()),i))}})}function V_e(e){const a=A_e(),n=aEe({id:a.generateId("label")},e),[t,i]=yn(n,["ref","id"]);return Ba((()=>Ha(a.registerLabel(t.id)))),mn(dEe,fn({as:"div",ref(e){const n=mTe(a.setLabelRef,t.ref);"function"==typeof n&&n(e)},get id(){return t.id}},(()=>a.dataset()),i))}function J_e(e){const a=b_e();return mn(Mn,{get when(){return a.contentPresent()},get children(){return mn(at,e)}})}var U_e=Ja();function W_e(e){const a=aEe({id:C_e().generateId(`radiogroup-${Sn()}`)},e),[n,t]=yn(a,["value","defaultValue","onChange","disabled"]),[i,r]=kEe({value:()=>n.value,defaultValue:()=>n.defaultValue,onChange:e=>n.onChange?.(e)});return mn(U_e.Provider,{value:{isDisabled:()=>n.disabled,isSelectedValue:e=>e===i(),setSelectedValue:r},get children(){return mn(K_e,t)}})}function q_e(e){const a=function(){const e=Ua(U_e);if(void 0===e)throw new Error("[kobalte]: `useMenuRadioGroupContext` must be used within a `Menu.RadioGroup` component");return e}(),n=aEe({closeOnSelect:!1},e),[t,i]=yn(n,["value","onSelect"]);return mn(M_e,fn({role:"menuitemradio",get checked(){return a.isSelectedValue(t.value)},onSelect:()=>{t.onSelect?.(),a.setSelectedValue(t.value)}},i))}function Z_e(e,a,n){const t=e.split("-")[0],i=n.getBoundingClientRect(),r=[],o=a.clientX,s=a.clientY;switch(t){case"top":r.push([o,s+5]),r.push([i.left,i.bottom]),r.push([i.left,i.top]),r.push([i.right,i.top]),r.push([i.right,i.bottom]);break;case"right":r.push([o-5,s]),r.push([i.left,i.top]),r.push([i.right,i.top]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]);break;case"bottom":r.push([o,s-5]),r.push([i.right,i.top]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]),r.push([i.left,i.top]);break;case"left":r.push([o+5,s]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]),r.push([i.left,i.top]),r.push([i.right,i.top])}return r}function $_e(e){const a=C_e(),n=CEe(),t=k_e(),i=x_e(),r=B_e(),o=aEe({placement:"horizontal"===a.orientation()?"bottom-start":"right-start"},e),[s,l]=yn(o,["open","defaultOpen","onOpenChange"]);let u=0,c=null,d="right";const[m,h]=Pa(),[p,g]=Pa(),[v,f]=Pa(),[y,k]=Pa(),[b,S]=Pa(!0),[A,w]=Pa(l.placement),[C,M]=Pa([]),[T,E]=Pa([]),{DomCollectionProvider:x}=xEe({items:T,onItemsChange:E}),N=BNe({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:e=>s.onOpenChange?.(e)}),{present:_}=XEe({show:()=>a.forceMount()||N.isOpen(),element:()=>y()??null}),P=function(e){const a=UEe(e),n=PEe({dataSource:()=>kMe(e.dataSource),getKey:()=>kMe(e.getKey),getTextValue:()=>kMe(e.getTextValue),getDisabled:()=>kMe(e.getDisabled),getSectionChildren:()=>kMe(e.getSectionChildren),factory:a=>new $Ee(e.filter?e.filter(a):a)},[()=>e.filter]),t=new ZEe(n,a);return La((()=>{const e=a.focusedKey();null==e||n().getItem(e)||a.setFocusedKey(void 0)})),{collection:n,selectionManager:()=>t}}({selectionMode:"none",dataSource:T}),L=e=>{S(e),N.open()},j=(e=!1)=>{N.close(),e&&t&&t.close(!0)},B=()=>{const e=y();e&&(GTe(e),P.selectionManager().setFocused(!0),P.selectionManager().setFocusedKey(void 0))},R=()=>{null!=r?setTimeout((()=>B())):B()},z=e=>{return d===c?.side&&(a=e,n=c?.area,!!n&&function(e,a){const[n,t]=e;let i=!1;for(let r=a.length,o=0,s=r-1;o<r;s=o++){const[e,l]=a[o],[u,c]=a[s],[,d]=a[0===s?r-1:s-1]||[0,0],m=(l-c)*(n-e)-(e-u)*(t-l);if(c<l){if(t>=c&&t<l){if(0===m)return!0;m>0&&(t===c?t>d&&(i=!i):i=!i)}}else if(l<c){if(t>l&&t<=c){if(0===m)return!0;m<0&&(t===c?t<d&&(i=!i):i=!i)}}else if(t==l&&(n>=u&&n<=e||n>=e&&n<=u))return!0}return i}([a.clientX,a.clientY],n));var a,n};t_e({isDisabled:()=>!(null==t&&N.isOpen()&&a.isModal()),targets:()=>[y(),...C()].filter(Boolean)}),Ba((()=>{const e=y();if(!e||!t)return;const a=t.registerNestedMenu(e);Ha((()=>{a()}))})),Ba((()=>{void 0===t&&i?.registerMenu(a.value(),[y(),...C()])})),Ba((()=>{void 0===t&&void 0!==i&&(i.value()===a.value()?(v()?.focus(),i.autoFocusMenu()&&L(!0)):j())})),Ba((()=>{void 0===t&&void 0!==i&&N.isOpen()&&i.setValue(a.value())})),Ha((()=>{void 0===t&&i?.unregisterMenu(a.value())}));const D={dataset:Ra((()=>({"data-expanded":N.isOpen()?"":void 0,"data-closed":N.isOpen()?void 0:""}))),isOpen:N.isOpen,contentPresent:_,nestedMenus:C,currentPlacement:A,pointerGraceTimeoutId:()=>u,autoFocus:b,listState:()=>P,parentMenuContext:()=>t,triggerRef:v,contentRef:y,triggerId:m,contentId:p,setTriggerRef:f,setContentRef:k,open:L,close:j,toggle:e=>{S(e),N.toggle()},focusContent:R,onItemEnter:e=>{z(e)&&e.preventDefault()},onItemLeave:e=>{z(e)||R()},onTriggerLeave:e=>{z(e)&&e.preventDefault()},setPointerDir:e=>d=e,setPointerGraceTimeoutId:e=>u=e,setPointerGraceIntent:e=>c=e,registerNestedMenu:e=>{M((a=>[...a,e]));const a=t?.registerNestedMenu(e);return()=>{M((a=>xTe(a,e))),a?.()}},registerItemToParentDomCollection:n?.registerItem,registerTriggerId:lEe(h),registerContentId:lEe(g)};return mn(x,{get children(){return mn(y_e.Provider,{value:D,get children(){return mn(Mn,{when:void 0===r,get fallback(){return l.children},get children(){return mn(NNe,fn({anchorRef:v,contentRef:y,onCurrentPlacementChange:w},l))}})}})}})}function Y_e(e){const{direction:a}=HEe();return mn($_e,fn({get placement(){return"rtl"===a()?"left-start":"right-start"},flip:!0},e))}var Q_e=(e,a)=>"ltr"===e?["horizontal"===a?"ArrowLeft":"ArrowUp"]:["horizontal"===a?"ArrowRight":"ArrowDown"];function X_e(e){const a=b_e(),n=C_e(),[t,i]=yn(e,["onFocusOutside","onKeyDown"]),{direction:r}=HEe();return mn(R_e,fn({onOpenAutoFocus:e=>{e.preventDefault()},onCloseAutoFocus:e=>{e.preventDefault()},onFocusOutside:e=>{t.onFocusOutside?.(e);const n=e.target;PTe(a.triggerRef(),n)||a.close()},onKeyDown:e=>{OTe(e,t.onKeyDown);const i=PTe(e.currentTarget,e.target),o=Q_e(r(),n.orientation()).includes(e.key),s=null!=a.parentMenuContext();i&&o&&s&&(a.close(),GTe(a.triggerRef()))}},i))}var ePe=["Enter"," "],aPe=(e,a)=>"ltr"===e?[...ePe,"horizontal"===a?"ArrowRight":"ArrowDown"]:[...ePe,"horizontal"===a?"ArrowLeft":"ArrowUp"];function nPe(e){let a;const n=C_e(),t=b_e(),i=aEe({id:n.generateId(`sub-trigger-${Sn()}`)},e),[r,o]=yn(i,["ref","id","textValue","disabled","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]);let s=null;const l=()=>{s&&window.clearTimeout(s),s=null},{direction:u}=HEe(),c=()=>r.id,d=()=>{const e=t.parentMenuContext();if(null==e)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");return e.listState().selectionManager()},m=qEe({key:c,selectionManager:d,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),h=e=>{OTe(e,r.onClick),t.isOpen()||r.disabled||t.open(!0)},p=e=>{OTe(e,r.onKeyDown),e.repeat||r.disabled||aPe(u(),n.orientation()).includes(e.key)&&(e.stopPropagation(),e.preventDefault(),d().setFocused(!1),d().setFocusedKey(void 0),t.isOpen()||t.open("first"),t.focusContent(),t.listState().selectionManager().setFocused(!0),t.listState().selectionManager().setFocusedKey(t.listState().collection().getFirstKey()))};return Ba((()=>{if(null==t.registerItemToParentDomCollection)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");Ha(t.registerItemToParentDomCollection({ref:()=>a,type:"item",key:c(),textValue:r.textValue??a?.textContent??"",disabled:r.disabled??!1}))})),Ba(Ka((()=>t.parentMenuContext()?.pointerGraceTimeoutId()),(e=>{Ha((()=>{window.clearTimeout(e),t.parentMenuContext()?.setPointerGraceIntent(null)}))}))),Ba((()=>Ha(t.registerTriggerId(r.id)))),Ha((()=>{l()})),mn(dEe,fn({as:"div",ref(e){const n=mTe((e=>{t.setTriggerRef(e),a=e}),r.ref);"function"==typeof n&&n(e)},get id(){return r.id},role:"menuitem",get tabIndex(){return m.tabIndex()},"aria-haspopup":"true",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return Ra((()=>!!t.isOpen()))()?t.contentId():void 0},get"aria-disabled"(){return r.disabled},get"data-key"(){return m.dataKey()},get"data-highlighted"(){return d().focusedKey()===c()?"":void 0},get"data-disabled"(){return r.disabled?"":void 0},get onPointerDown(){return HTe([r.onPointerDown,m.onPointerDown])},get onPointerUp(){return HTe([r.onPointerUp,m.onPointerUp])},get onClick(){return HTe([h,m.onClick])},get onKeyDown(){return HTe([p,m.onKeyDown])},get onMouseDown(){return HTe([r.onMouseDown,m.onMouseDown])},get onFocus(){return HTe([r.onFocus,m.onFocus])},onPointerMove:e=>{if(OTe(e,r.onPointerMove),"mouse"!==e.pointerType)return;const a=t.parentMenuContext();a?.onItemEnter(e),e.defaultPrevented||(r.disabled?a?.onItemLeave(e):(t.isOpen()||s||(t.parentMenuContext()?.setPointerGraceIntent(null),s=window.setTimeout((()=>{t.open(!1),l()}),100)),a?.onItemEnter(e),e.defaultPrevented||(t.listState().selectionManager().isFocused()&&(t.listState().selectionManager().setFocused(!1),t.listState().selectionManager().setFocusedKey(void 0)),GTe(e.currentTarget),a?.listState().selectionManager().setFocused(!0),a?.listState().selectionManager().setFocusedKey(c()))))},onPointerLeave:e=>{if(OTe(e,r.onPointerLeave),"mouse"!==e.pointerType)return;l();const a=t.parentMenuContext(),n=t.contentRef();if(n){a?.setPointerGraceIntent({area:Z_e(t.currentPlacement(),e,n),side:t.currentPlacement().split("-")[0]}),window.clearTimeout(a?.pointerGraceTimeoutId());const i=window.setTimeout((()=>{a?.setPointerGraceIntent(null)}),300);a?.setPointerGraceTimeoutId(i)}else{if(a?.onTriggerLeave(e),e.defaultPrevented)return;a?.setPointerGraceIntent(null)}a?.onItemLeave(e)}},(()=>t.dataset()),o))}function tPe(e){const a=x_e(),n=aEe({id:`menu-${Sn()}`,modal:!0},e),[t,i]=yn(n,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value","orientation"]),r=BNe({open:()=>t.open,defaultOpen:()=>t.defaultOpen,onOpenChange:e=>t.onOpenChange?.(e)}),o={isModal:()=>t.modal??!0,preventScroll:()=>t.preventScroll??o.isModal(),forceMount:()=>t.forceMount??!1,generateId:_Te((()=>t.id)),value:()=>t.value,orientation:()=>t.orientation??a?.orientation()??"horizontal"};return mn(w_e.Provider,{value:o,get children(){return mn($_e,fn({get open(){return r.isOpen()},get onOpenChange(){return r.setIsOpen}},i))}})}function iPe(e){let a;const n=aEe({orientation:"horizontal"},e),[t,i]=yn(n,["ref","orientation"]),r=uEe((()=>a),(()=>"hr"));return mn(dEe,fn({as:"hr",ref(e){const n=mTe((e=>a=e),t.ref);"function"==typeof n&&n(e)},get role(){return"hr"!==r()?"separator":void 0},get"aria-orientation"(){return"vertical"===t.orientation?"vertical":void 0},get"data-orientation"(){return t.orientation}},i))}AEe({},{Root:()=>iPe,Separator:()=>rPe});var rPe=iPe,oPe={};function sPe(e){const a=C_e(),n=b_e(),[t,i]=yn(e,["onCloseAutoFocus","onInteractOutside"]);let r=!1;return mn(z_e,fn({onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),r||GTe(n.triggerRef()),r=!1,e.preventDefault()},onInteractOutside:e=>{t.onInteractOutside?.(e),a.isModal()&&!e.detail.isContextMenu||(r=!0)}},i))}function lPe(e){return mn(tPe,aEe({id:`dropdownmenu-${Sn()}`},e))}AEe(oPe,{Arrow:()=>MNe,CheckboxItem:()=>T_e,Content:()=>sPe,DropdownMenu:()=>uPe,Group:()=>K_e,GroupLabel:()=>O_e,Icon:()=>H_e,Item:()=>I_e,ItemDescription:()=>G_e,ItemIndicator:()=>F_e,ItemLabel:()=>V_e,Portal:()=>J_e,RadioGroup:()=>W_e,RadioItem:()=>q_e,Root:()=>lPe,Separator:()=>iPe,Sub:()=>Y_e,SubContent:()=>X_e,SubTrigger:()=>nPe,Trigger:()=>L_e});var uPe=Object.assign(lPe,{Arrow:MNe,CheckboxItem:T_e,Content:sPe,Group:K_e,GroupLabel:O_e,Icon:H_e,Item:I_e,ItemDescription:G_e,ItemIndicator:F_e,ItemLabel:V_e,Portal:J_e,RadioGroup:W_e,RadioItem:q_e,Separator:iPe,Sub:Y_e,SubContent:X_e,SubTrigger:nPe,Trigger:L_e}),cPe={colors:{inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000000",white:"#ffffff",neutral:{50:"#f9fafb",100:"#f2f4f7",200:"#eaecf0",300:"#d0d5dd",400:"#98a2b3",500:"#667085",600:"#475467",700:"#344054",800:"#1d2939",900:"#101828"},darkGray:{50:"#525c7a",100:"#49536e",200:"#414962",300:"#394056",400:"#313749",500:"#292e3d",600:"#212530",700:"#191c24",800:"#111318",900:"#0b0d10"},gray:{50:"#f9fafb",100:"#f2f4f7",200:"#eaecf0",300:"#d0d5dd",400:"#98a2b3",500:"#667085",600:"#475467",700:"#344054",800:"#1d2939",900:"#101828"},blue:{25:"#F5FAFF",50:"#EFF8FF",100:"#D1E9FF",200:"#B2DDFF",300:"#84CAFF",400:"#53B1FD",500:"#2E90FA",600:"#1570EF",700:"#175CD3",800:"#1849A9",900:"#194185"},green:{25:"#F6FEF9",50:"#ECFDF3",100:"#D1FADF",200:"#A6F4C5",300:"#6CE9A6",400:"#32D583",500:"#12B76A",600:"#039855",700:"#027A48",800:"#05603A",900:"#054F31"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},yellow:{25:"#FFFCF5",50:"#FFFAEB",100:"#FEF0C7",200:"#FEDF89",300:"#FEC84B",400:"#FDB022",500:"#F79009",600:"#DC6803",700:"#B54708",800:"#93370D",900:"#7A2E0E"},purple:{25:"#FAFAFF",50:"#F4F3FF",100:"#EBE9FE",200:"#D9D6FE",300:"#BDB4FE",400:"#9B8AFB",500:"#7A5AF8",600:"#6938EF",700:"#5925DC",800:"#4A1FB8",900:"#3E1C96"},teal:{25:"#F6FEFC",50:"#F0FDF9",100:"#CCFBEF",200:"#99F6E0",300:"#5FE9D0",400:"#2ED3B7",500:"#15B79E",600:"#0E9384",700:"#107569",800:"#125D56",900:"#134E48"},pink:{25:"#fdf2f8",50:"#fce7f3",100:"#fbcfe8",200:"#f9a8d4",300:"#f472b6",400:"#ec4899",500:"#db2777",600:"#be185d",700:"#9d174d",800:"#831843",900:"#500724"},cyan:{25:"#ecfeff",50:"#cffafe",100:"#a5f3fc",200:"#67e8f9",300:"#22d3ee",400:"#06b6d4",500:"#0891b2",600:"#0e7490",700:"#155e75",800:"#164e63",900:"#083344"}},alpha:{90:"e5",80:"cc"},font:{size:{xs:"calc(var(--tsqd-font-size) * 0.75)",sm:"calc(var(--tsqd-font-size) * 0.875)",md:"var(--tsqd-font-size)"},lineHeight:{xs:"calc(var(--tsqd-font-size) * 1)",sm:"calc(var(--tsqd-font-size) * 1.25)",md:"calc(var(--tsqd-font-size) * 1.5)"},weight:{medium:"500",semibold:"600",bold:"700"}},border:{radius:{xs:"calc(var(--tsqd-font-size) * 0.125)",sm:"calc(var(--tsqd-font-size) * 0.25)",full:"9999px"}},size:{.25:"calc(var(--tsqd-font-size) * 0.0625)",.5:"calc(var(--tsqd-font-size) * 0.125)",1:"calc(var(--tsqd-font-size) * 0.25)",1.5:"calc(var(--tsqd-font-size) * 0.375)",2:"calc(var(--tsqd-font-size) * 0.5)",2.5:"calc(var(--tsqd-font-size) * 0.625)",3:"calc(var(--tsqd-font-size) * 0.75)",3.5:"calc(var(--tsqd-font-size) * 0.875)",4:"calc(var(--tsqd-font-size) * 1)",4.5:"calc(var(--tsqd-font-size) * 1.125)",5:"calc(var(--tsqd-font-size) * 1.25)",6:"calc(var(--tsqd-font-size) * 1.5)",6.5:"calc(var(--tsqd-font-size) * 1.625)",14:"calc(var(--tsqd-font-size) * 3.5)"},shadow:{xs:(e="rgb(0 0 0 / 0.1)")=>"0 1px 2px 0 rgb(0 0 0 / 0.05)",sm:(e="rgb(0 0 0 / 0.1)")=>`0 1px 3px 0 ${e}, 0 1px 2px -1px ${e}`,md:(e="rgb(0 0 0 / 0.1)")=>`0 4px 6px -1px ${e}, 0 2px 4px -2px ${e}`,lg:(e="rgb(0 0 0 / 0.1)")=>`0 10px 15px -3px ${e}, 0 4px 6px -4px ${e}`,xl:(e="rgb(0 0 0 / 0.1)")=>`0 20px 25px -5px ${e}, 0 8px 10px -6px ${e}`,"2xl":(e="rgb(0 0 0 / 0.25)")=>`0 25px 50px -12px ${e}`,inner:(e="rgb(0 0 0 / 0.05)")=>`inset 0 2px 4px 0 ${e}`,none:()=>"none"}},dPe=Dn('<svg width=14 height=14 viewBox="0 0 14 14"fill=none xmlns=http://www.w3.org/2000/svg><path d="M13 13L9.00007 9M10.3333 5.66667C10.3333 8.244 8.244 10.3333 5.66667 10.3333C3.08934 10.3333 1 8.244 1 5.66667C1 3.08934 3.08934 1 5.66667 1C8.244 1 10.3333 3.08934 10.3333 5.66667Z"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),mPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9 3H15M3 6H21M19 6L18.2987 16.5193C18.1935 18.0975 18.1409 18.8867 17.8 19.485C17.4999 20.0118 17.0472 20.4353 16.5017 20.6997C15.882 21 15.0911 21 13.5093 21H10.4907C8.90891 21 8.11803 21 7.49834 20.6997C6.95276 20.4353 6.50009 20.0118 6.19998 19.485C5.85911 18.8867 5.8065 18.0975 5.70129 16.5193L5 6M10 10.5V15.5M14 10.5V15.5"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),hPe=Dn('<svg width=10 height=6 viewBox="0 0 10 6"fill=none xmlns=http://www.w3.org/2000/svg><path d="M1 1L5 5L9 1"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),pPe=Dn('<svg width=12 height=12 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 13.3333V2.66667M8 2.66667L4 6.66667M8 2.66667L12 6.66667"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),gPe=Dn('<svg width=12 height=12 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 2.66667V13.3333M8 13.3333L4 9.33333M8 13.3333L12 9.33333"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),vPe=Dn('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M12 2v2m0 16v2M4 12H2m4.314-5.686L4.9 4.9m12.786 1.414L19.1 4.9M6.314 17.69 4.9 19.104m12.786-1.414 1.414 1.414M22 12h-2m-3 0a5 5 0 1 1-10 0 5 5 0 0 1 10 0Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),fPe=Dn('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M22 15.844a10.424 10.424 0 0 1-4.306.925c-5.779 0-10.463-4.684-10.463-10.462 0-1.536.33-2.994.925-4.307A10.464 10.464 0 0 0 2 11.538C2 17.316 6.684 22 12.462 22c4.243 0 7.896-2.526 9.538-6.156Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),yPe=Dn('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 21h8m-4-4v4m-5.2-4h10.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C22 14.72 22 13.88 22 12.2V7.8c0-1.68 0-2.52-.327-3.162a3 3 0 0 0-1.311-1.311C19.72 3 18.88 3 17.2 3H6.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C2 5.28 2 6.12 2 7.8v4.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C4.28 17 5.12 17 6.8 17Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),kPe=Dn('<svg stroke=currentColor fill=currentColor stroke-width=0 viewBox="0 0 24 24"height=1em width=1em xmlns=http://www.w3.org/2000/svg><path fill=none d="M0 0h24v24H0z"></path><path d="M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3a4.237 4.237 0 00-6 0zm-4-4l2 2a7.074 7.074 0 0110 0l2-2C15.14 9.14 8.87 9.14 5 13z">'),bPe=Dn('<svg stroke-width=0 viewBox="0 0 24 24"height=1em width=1em xmlns=http://www.w3.org/2000/svg><path fill=none d="M24 .01c0-.01 0-.01 0 0L0 0v24h24V.01zM0 0h24v24H0V0zm0 0h24v24H0V0z"></path><path d="M22.99 9C19.15 5.16 13.8 3.76 8.84 4.78l2.52 2.52c3.47-.17 6.99 1.05 9.63 3.7l2-2zm-4 4a9.793 9.793 0 00-4.49-2.56l3.53 3.53.96-.97zM2 3.05L5.07 6.1C3.6 6.82 2.22 7.78 1 9l1.99 2c1.24-1.24 2.67-2.16 4.2-2.77l2.24 2.24A9.684 9.684 0 005 13v.01L6.99 15a7.042 7.042 0 014.92-2.06L18.98 20l1.27-1.26L3.29 1.79 2 3.05zM9 17l3 3 3-3a4.237 4.237 0 00-6 0z">'),SPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9.3951 19.3711L9.97955 20.6856C10.1533 21.0768 10.4368 21.4093 10.7958 21.6426C11.1547 21.8759 11.5737 22.0001 12.0018 22C12.4299 22.0001 12.8488 21.8759 13.2078 21.6426C13.5667 21.4093 13.8503 21.0768 14.024 20.6856L14.6084 19.3711C14.8165 18.9047 15.1664 18.5159 15.6084 18.26C16.0532 18.0034 16.5678 17.8941 17.0784 17.9478L18.5084 18.1C18.9341 18.145 19.3637 18.0656 19.7451 17.8713C20.1265 17.6771 20.4434 17.3763 20.6573 17.0056C20.8715 16.635 20.9735 16.2103 20.9511 15.7829C20.9286 15.3555 20.7825 14.9438 20.5307 14.5978L19.684 13.4344C19.3825 13.0171 19.2214 12.5148 19.224 12C19.2239 11.4866 19.3865 10.9864 19.6884 10.5711L20.5351 9.40778C20.787 9.06175 20.933 8.65007 20.9555 8.22267C20.978 7.79528 20.8759 7.37054 20.6618 7C20.4479 6.62923 20.131 6.32849 19.7496 6.13423C19.3681 5.93997 18.9386 5.86053 18.5129 5.90556L17.0829 6.05778C16.5722 6.11141 16.0577 6.00212 15.6129 5.74556C15.17 5.48825 14.82 5.09736 14.6129 4.62889L14.024 3.31444C13.8503 2.92317 13.5667 2.59072 13.2078 2.3574C12.8488 2.12408 12.4299 1.99993 12.0018 2C11.5737 1.99993 11.1547 2.12408 10.7958 2.3574C10.4368 2.59072 10.1533 2.92317 9.97955 3.31444L9.3951 4.62889C9.18803 5.09736 8.83798 5.48825 8.3951 5.74556C7.95032 6.00212 7.43577 6.11141 6.9251 6.05778L5.49066 5.90556C5.06499 5.86053 4.6354 5.93997 4.25397 6.13423C3.87255 6.32849 3.55567 6.62923 3.34177 7C3.12759 7.37054 3.02555 7.79528 3.04804 8.22267C3.07052 8.65007 3.21656 9.06175 3.46844 9.40778L4.3151 10.5711C4.61704 10.9864 4.77964 11.4866 4.77955 12C4.77964 12.5134 4.61704 13.0137 4.3151 13.4289L3.46844 14.5922C3.21656 14.9382 3.07052 15.3499 3.04804 15.7773C3.02555 16.2047 3.12759 16.6295 3.34177 17C3.55589 17.3706 3.8728 17.6712 4.25417 17.8654C4.63554 18.0596 5.06502 18.1392 5.49066 18.0944L6.92066 17.9422C7.43133 17.8886 7.94587 17.9979 8.39066 18.2544C8.83519 18.511 9.18687 18.902 9.3951 19.3711Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path><path d="M12 15C13.6568 15 15 13.6569 15 12C15 10.3431 13.6568 9 12 9C10.3431 9 8.99998 10.3431 8.99998 12C8.99998 13.6569 10.3431 15 12 15Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),APe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M16 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V8M11.5 12.5L17 7M17 7H12M17 7V12M6.2 21H8.8C9.9201 21 10.4802 21 10.908 20.782C11.2843 20.5903 11.5903 20.2843 11.782 19.908C12 19.4802 12 18.9201 12 17.8V15.2C12 14.0799 12 13.5198 11.782 13.092C11.5903 12.7157 11.2843 12.4097 10.908 12.218C10.4802 12 9.92011 12 8.8 12H6.2C5.0799 12 4.51984 12 4.09202 12.218C3.71569 12.4097 3.40973 12.7157 3.21799 13.092C3 13.5198 3 14.0799 3 15.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),wPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path class=copier d="M8 8V5.2C8 4.0799 8 3.51984 8.21799 3.09202C8.40973 2.71569 8.71569 2.40973 9.09202 2.21799C9.51984 2 10.0799 2 11.2 2H18.8C19.9201 2 20.4802 2 20.908 2.21799C21.2843 2.40973 21.5903 2.71569 21.782 3.09202C22 3.51984 22 4.0799 22 5.2V12.8C22 13.9201 22 14.4802 21.782 14.908C21.5903 15.2843 21.2843 15.5903 20.908 15.782C20.4802 16 19.9201 16 18.8 16H16M5.2 22H12.8C13.9201 22 14.4802 22 14.908 21.782C15.2843 21.5903 15.5903 21.2843 15.782 20.908C16 20.4802 16 19.9201 16 18.8V11.2C16 10.0799 16 9.51984 15.782 9.09202C15.5903 8.71569 15.2843 8.40973 14.908 8.21799C14.4802 8 13.9201 8 12.8 8H5.2C4.0799 8 3.51984 8 3.09202 8.21799C2.71569 8.40973 2.40973 8.71569 2.21799 9.09202C2 9.51984 2 10.0799 2 11.2V18.8C2 19.9201 2 20.4802 2.21799 20.908C2.40973 21.2843 2.71569 21.5903 3.09202 21.782C3.51984 22 4.07989 22 5.2 22Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round stroke=currentColor>'),CPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M2.5 21.4998L8.04927 19.3655C8.40421 19.229 8.58168 19.1607 8.74772 19.0716C8.8952 18.9924 9.0358 18.901 9.16804 18.7984C9.31692 18.6829 9.45137 18.5484 9.72028 18.2795L21 6.99982C22.1046 5.89525 22.1046 4.10438 21 2.99981C19.8955 1.89525 18.1046 1.89524 17 2.99981L5.72028 14.2795C5.45138 14.5484 5.31692 14.6829 5.20139 14.8318C5.09877 14.964 5.0074 15.1046 4.92823 15.2521C4.83911 15.4181 4.77085 15.5956 4.63433 15.9506L2.5 21.4998ZM2.5 21.4998L4.55812 16.1488C4.7054 15.7659 4.77903 15.5744 4.90534 15.4867C5.01572 15.4101 5.1523 15.3811 5.2843 15.4063C5.43533 15.4351 5.58038 15.5802 5.87048 15.8703L8.12957 18.1294C8.41967 18.4195 8.56472 18.5645 8.59356 18.7155C8.61877 18.8475 8.58979 18.9841 8.51314 19.0945C8.42545 19.2208 8.23399 19.2944 7.85107 19.4417L2.5 21.4998Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),MPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M7.5 12L10.5 15L16.5 9M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),TPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9 9L15 15M15 9L9 15M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"stroke=#F04438 stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),EPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 xmlns=http://www.w3.org/2000/svg><rect class=list width=20 height=20 y=2 x=2 rx=2></rect><line class=list-item y1=7 y2=7 x1=6 x2=18></line><line class=list-item y2=12 y1=12 x1=6 x2=18></line><line class=list-item y1=17 y2=17 x1=6 x2=18>'),xPe=Dn('<svg viewBox="0 0 24 24"height=20 width=20 fill=none xmlns=http://www.w3.org/2000/svg><path d="M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),NPe=Dn('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M7.5 12L10.5 15L16.5 9M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),_Pe=Dn('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M12 2V6M12 18V22M6 12H2M22 12H18M19.0784 19.0784L16.25 16.25M19.0784 4.99994L16.25 7.82837M4.92157 19.0784L7.75 16.25M4.92157 4.99994L7.75 7.82837"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path><animateTransform attributeName=transform attributeType=XML type=rotate from=0 to=360 dur=2s repeatCount=indefinite>'),PPe=Dn('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M15 9L9 15M9 9L15 15M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),LPe=Dn('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9.5 15V9M14.5 15V9M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),jPe=Dn('<svg version=1.0 viewBox="0 0 633 633"><linearGradient x1=-666.45 x2=-666.45 y1=163.28 y2=163.99 gradientTransform="matrix(633 0 0 633 422177 -103358)"gradientUnits=userSpaceOnUse><stop stop-color=#6BDAFF offset=0></stop><stop stop-color=#F9FFB5 offset=.32></stop><stop stop-color=#FFA770 offset=.71></stop><stop stop-color=#FF7373 offset=1></stop></linearGradient><circle cx=316.5 cy=316.5 r=316.5></circle><defs><filter x=-137.5 y=412 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=412 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=610.5 rx=214.5 ry=186 fill=#015064 stroke=#00CFE2 stroke-width=25></ellipse></g><defs><filter x=316.5 y=412 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=412 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=610.5 rx=214.5 ry=186 fill=#015064 stroke=#00CFE2 stroke-width=25></ellipse></g><defs><filter x=-137.5 y=450 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=450 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=648.5 rx=214.5 ry=186 fill=#015064 stroke=#00A8B8 stroke-width=25></ellipse></g><defs><filter x=316.5 y=450 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=450 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=648.5 rx=214.5 ry=186 fill=#015064 stroke=#00A8B8 stroke-width=25></ellipse></g><defs><filter x=-137.5 y=486 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=486 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=684.5 rx=214.5 ry=186 fill=#015064 stroke=#007782 stroke-width=25></ellipse></g><defs><filter x=316.5 y=486 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=486 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=684.5 rx=214.5 ry=186 fill=#015064 stroke=#007782 stroke-width=25></ellipse></g><defs><filter x=272.2 y=308 width=176.9 height=129.3 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=272.2 y=308 width=176.9 height=129.3 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><line x1=436 x2=431 y1=403.2 y2=431.8 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><line x1=291 x2=280 y1=341.5 y2=403.5 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><line x1=332.9 x2=328.6 y1=384.1 y2=411.2 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><linearGradient x1=-670.75 x2=-671.59 y1=164.4 y2=164.49 gradientTransform="matrix(-184.16 -32.472 -11.461 64.997 -121359 -32126)"gradientUnits=userSpaceOnUse><stop stop-color=#EE2700 offset=0></stop><stop stop-color=#FF008E offset=1></stop></linearGradient><path d="m344.1 363 97.7 17.2c5.8 2.1 8.2 6.1 7.1 12.1s-4.7 9.2-11 9.9l-106-18.7-57.5-59.2c-3.2-4.8-2.9-9.1 0.8-12.8s8.3-4.4 13.7-2.1l55.2 53.6z"clip-rule=evenodd fill-rule=evenodd></path><line x1=428.2 x2=429.1 y1=384.5 y2=378 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=395.2 x2=396.1 y1=379.5 y2=373 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=362.2 x2=363.1 y1=373.5 y2=367.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=324.2 x2=328.4 y1=351.3 y2=347.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=303.2 x2=307.4 y1=331.3 y2=327.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line></g><defs><filter x=73.2 y=113.8 width=280.6 height=317.4 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=73.2 y=113.8 width=280.6 height=317.4 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-672.16 x2=-672.16 y1=165.03 y2=166.03 gradientTransform="matrix(-100.18 48.861 97.976 200.88 -83342 -93.059)"gradientUnits=userSpaceOnUse><stop stop-color=#A17500 offset=0></stop><stop stop-color=#5D2100 offset=1></stop></linearGradient><path d="m192.3 203c8.1 37.3 14 73.6 17.8 109.1 3.8 35.4 2.8 75.1-3 119.2l61.2-16.7c-15.6-59-25.2-97.9-28.6-116.6s-10.8-51.9-22.1-99.6l-25.3 4.6"clip-rule=evenodd fill-rule=evenodd></path><g stroke=#2F8A00><linearGradient x1=-660.23 x2=-660.23 y1=166.72 y2=167.72 gradientTransform="matrix(92.683 4.8573 -2.0259 38.657 61680 -3088.6)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m195 183.9s-12.6-22.1-36.5-29.9c-15.9-5.2-34.4-1.5-55.5 11.1 15.9 14.3 29.5 22.6 40.7 24.9 16.8 3.6 51.3-6.1 51.3-6.1z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-661.36 x2=-661.36 y1=164.18 y2=165.18 gradientTransform="matrix(110 5.7648 -6.3599 121.35 73933 -15933)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5s-47.5-8.5-83.2 15.7c-23.8 16.2-34.3 49.3-31.6 99.4 30.3-27.8 52.1-48.5 65.2-61.9 19.8-20.2 49.6-53.2 49.6-53.2z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-656.79 x2=-656.79 y1=165.15 y2=166.15 gradientTransform="matrix(62.954 3.2993 -3.5023 66.828 42156 -8754.1)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m195 183.9c-0.8-21.9 6-38 20.6-48.2s29.8-15.4 45.5-15.3c-6.1 21.4-14.5 35.8-25.2 43.4s-24.4 14.2-40.9 20.1z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-663.07 x2=-663.07 y1=165.44 y2=166.44 gradientTransform="matrix(152.47 7.9907 -3.0936 59.029 101884 -4318.7)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c31.9-30 64.1-39.7 96.7-29s50.8 30.4 54.6 59.1c-35.2-5.5-60.4-9.6-75.8-12.1-15.3-2.6-40.5-8.6-75.5-18z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-662.57 x2=-662.57 y1=164.44 y2=165.44 gradientTransform="matrix(136.46 7.1517 -5.2163 99.533 91536 -11442)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c35.8-7.6 65.6-0.2 89.2 22s37.7 49 42.3 80.3c-39.8-9.7-68.3-23.8-85.5-42.4s-32.5-38.5-46-59.9z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-656.43 x2=-656.43 y1=163.86 y2=164.86 gradientTransform="matrix(60.866 3.1899 -8.7773 167.48 41560 -25168)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c-33.6 13.8-53.6 35.7-60.1 65.6s-3.6 63.1 8.7 99.6c27.4-40.3 43.2-69.6 47.4-88s5.6-44.1 4-77.2z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><path d="m196.5 182.3c-14.8 21.6-25.1 41.4-30.8 59.4s-9.5 33-11.1 45.1"fill=none stroke-linecap=round stroke-width=8></path><path d="m194.9 185.7c-24.4 1.7-43.8 9-58.1 21.8s-24.7 25.4-31.3 37.8"fill=none stroke-linecap=round stroke-width=8></path><path d="m204.5 176.4c29.7-6.7 52-8.4 67-5.1s26.9 8.6 35.8 15.9"fill=none stroke-linecap=round stroke-width=8></path><path d="m196.5 181.4c20.3 9.9 38.2 20.5 53.9 31.9s27.4 22.1 35.1 32"fill=none stroke-linecap=round stroke-width=8></path></g></g><defs><filter x=50.5 y=399 width=532 height=633 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=50.5 y=399 width=532 height=633 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-666.06 x2=-666.23 y1=163.36 y2=163.75 gradientTransform="matrix(532 0 0 633 354760 -102959)"gradientUnits=userSpaceOnUse><stop stop-color=#FFF400 offset=0></stop><stop stop-color=#3C8700 offset=1></stop></linearGradient><ellipse cx=316.5 cy=715.5 rx=266 ry=316.5></ellipse></g><defs><filter x=391 y=-24 width=288 height=283 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=391 y=-24 width=288 height=283 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-664.56 x2=-664.56 y1=163.79 y2=164.79 gradientTransform="matrix(227 0 0 227 151421 -37204)"gradientUnits=userSpaceOnUse><stop stop-color=#FFDF00 offset=0></stop><stop stop-color=#FF9D00 offset=1></stop></linearGradient><circle cx=565.5 cy=89.5 r=113.5></circle><linearGradient x1=-644.5 x2=-645.77 y1=342 y2=342 gradientTransform="matrix(30 0 0 1 19770 -253)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=427 x2=397 y1=89 y2=89 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-641.56 x2=-642.83 y1=196.02 y2=196.07 gradientTransform="matrix(26.5 0 0 5.5 17439 -1025.5)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=430.5 x2=404 y1=55.5 y2=50 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-643.73 x2=-645 y1=185.83 y2=185.9 gradientTransform="matrix(29 0 0 8 19107 -1361)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=431 x2=402 y1=122 y2=130 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-638.94 x2=-640.22 y1=177.09 y2=177.39 gradientTransform="matrix(24 0 0 13 15783 -2145)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=442 x2=418 y1=153 y2=166 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-633.42 x2=-634.7 y1=172.41 y2=173.31 gradientTransform="matrix(20 0 0 19 13137 -3096)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=464 x2=444 y1=180 y2=199 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-619.05 x2=-619.52 y1=170.82 y2=171.82 gradientTransform="matrix(13.83 0 0 22.85 9050 -3703.4)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=491.4 x2=477.5 y1=203 y2=225.9 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-578.5 x2=-578.63 y1=170.31 y2=171.31 gradientTransform="matrix(7.5 0 0 24.5 4860 -3953)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=524.5 x2=517 y1=219.5 y2=244 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=666.5 x2=666.5 y1=170.31 y2=171.31 gradientTransform="matrix(.5 0 0 24.5 231.5 -3944)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=564.5 x2=565 y1=228.5 y2=253 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12>');function BPe(){return dPe()}function RPe(){return mPe()}function zPe(){return hPe()}function DPe(){return pPe()}function KPe(){return gPe()}function OPe(){return(e=gPe()).style.setProperty("transform","rotate(90deg)"),e;var e}function HPe(){return(e=gPe()).style.setProperty("transform","rotate(-90deg)"),e;var e}function IPe(){return vPe()}function GPe(){return fPe()}function FPe(){return yPe()}function VPe(){return kPe()}function JPe(){return bPe()}function UPe(){return SPe()}function WPe(){return APe()}function qPe(){return wPe()}function ZPe(){return CPe()}function $Pe(e){return a=MPe(),n=a.firstChild,ja((()=>On(n,"stroke","dark"===e.theme?"#12B76A":"#027A48"))),a;var a,n}function YPe(){return TPe()}function QPe(){return EPe()}function XPe(e){return[mn(Mn,{get when(){return e.checked},get children(){var a=MPe(),n=a.firstChild;return ja((()=>On(n,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}}),mn(Mn,{get when(){return!e.checked},get children(){var a=xPe(),n=a.firstChild;return ja((()=>On(n,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}})]}function eLe(){return NPe()}function aLe(){return _Pe()}function nLe(){return PPe()}function tLe(){return LPe()}function iLe(){const e=Sn();return a=jPe(),r=(i=(t=(n=a.firstChild).nextSibling).nextSibling).firstChild,s=(o=i.nextSibling).firstChild,c=(u=(l=o.nextSibling).nextSibling).firstChild,m=(d=u.nextSibling).firstChild,g=(p=(h=d.nextSibling).nextSibling).firstChild,f=(v=p.nextSibling).firstChild,b=(k=(y=v.nextSibling).nextSibling).firstChild,A=(S=k.nextSibling).firstChild,M=(C=(w=S.nextSibling).nextSibling).firstChild,E=(T=C.nextSibling).firstChild,_=(N=(x=T.nextSibling).nextSibling).firstChild,L=(P=N.nextSibling).firstChild,R=(B=(j=P.nextSibling).nextSibling).firstChild,D=(z=B.nextSibling).firstChild,H=(O=(K=z.nextSibling).firstChild.nextSibling.nextSibling.nextSibling).nextSibling,G=(I=K.nextSibling).firstChild,V=(F=I.nextSibling).firstChild,re=(ie=(te=(ne=(ae=(ee=(X=(Q=(Y=($=(Z=(q=(W=(U=(J=F.nextSibling).firstChild).nextSibling).nextSibling.firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,se=(oe=J.nextSibling).firstChild,ue=(le=oe.nextSibling).firstChild,me=(de=(ce=le.nextSibling).firstChild).nextSibling,pe=(he=ce.nextSibling).firstChild,ve=(ge=he.nextSibling).firstChild,Re=(Be=(je=(Le=(Pe=(_e=(Ne=(xe=(Ee=(Te=(Me=(Ce=(we=(Ae=(Se=(be=(ke=(ye=(fe=ge.nextSibling).firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,On(n,"id",`a-${e}`),On(t,"fill",`url(#a-${e})`),On(r,"id",`am-${e}`),On(o,"id",`b-${e}`),On(s,"filter",`url(#am-${e})`),On(l,"mask",`url(#b-${e})`),On(c,"id",`ah-${e}`),On(d,"id",`k-${e}`),On(m,"filter",`url(#ah-${e})`),On(h,"mask",`url(#k-${e})`),On(g,"id",`ae-${e}`),On(v,"id",`j-${e}`),On(f,"filter",`url(#ae-${e})`),On(y,"mask",`url(#j-${e})`),On(b,"id",`ai-${e}`),On(S,"id",`i-${e}`),On(A,"filter",`url(#ai-${e})`),On(w,"mask",`url(#i-${e})`),On(M,"id",`aj-${e}`),On(T,"id",`h-${e}`),On(E,"filter",`url(#aj-${e})`),On(x,"mask",`url(#h-${e})`),On(_,"id",`ag-${e}`),On(P,"id",`g-${e}`),On(L,"filter",`url(#ag-${e})`),On(j,"mask",`url(#g-${e})`),On(R,"id",`af-${e}`),On(z,"id",`f-${e}`),On(D,"filter",`url(#af-${e})`),On(K,"mask",`url(#f-${e})`),On(O,"id",`m-${e}`),On(H,"fill",`url(#m-${e})`),On(G,"id",`ak-${e}`),On(F,"id",`e-${e}`),On(V,"filter",`url(#ak-${e})`),On(J,"mask",`url(#e-${e})`),On(U,"id",`n-${e}`),On(W,"fill",`url(#n-${e})`),On(q,"id",`r-${e}`),On(Z,"fill",`url(#r-${e})`),On($,"id",`s-${e}`),On(Y,"fill",`url(#s-${e})`),On(Q,"id",`q-${e}`),On(X,"fill",`url(#q-${e})`),On(ee,"id",`p-${e}`),On(ae,"fill",`url(#p-${e})`),On(ne,"id",`o-${e}`),On(te,"fill",`url(#o-${e})`),On(ie,"id",`l-${e}`),On(re,"fill",`url(#l-${e})`),On(se,"id",`al-${e}`),On(le,"id",`d-${e}`),On(ue,"filter",`url(#al-${e})`),On(ce,"mask",`url(#d-${e})`),On(de,"id",`u-${e}`),On(me,"fill",`url(#u-${e})`),On(pe,"id",`ad-${e}`),On(ge,"id",`c-${e}`),On(ve,"filter",`url(#ad-${e})`),On(fe,"mask",`url(#c-${e})`),On(ye,"id",`t-${e}`),On(ke,"fill",`url(#t-${e})`),On(be,"id",`v-${e}`),On(Se,"stroke",`url(#v-${e})`),On(Ae,"id",`aa-${e}`),On(we,"stroke",`url(#aa-${e})`),On(Ce,"id",`w-${e}`),On(Me,"stroke",`url(#w-${e})`),On(Te,"id",`ac-${e}`),On(Ee,"stroke",`url(#ac-${e})`),On(xe,"id",`ab-${e}`),On(Ne,"stroke",`url(#ab-${e})`),On(_e,"id",`y-${e}`),On(Pe,"stroke",`url(#y-${e})`),On(Le,"id",`x-${e}`),On(je,"stroke",`url(#x-${e})`),On(Be,"id",`z-${e}`),On(Re,"stroke",`url(#z-${e})`),a;var a,n,t,i,r,o,s,l,u,c,d,m,h,p,g,v,f,y,k,b,S,A,w,C,M,T,E,x,N,_,P,L,j,B,R,z,D,K,O,H,I,G,F,V,J,U,W,q,Z,$,Y,Q,X,ee,ae,ne,te,ie,re,oe,se,le,ue,ce,de,me,he,pe,ge,ve,fe,ye,ke,be,Se,Ae,we,Ce,Me,Te,Ee,xe,Ne,_e,Pe,Le,je,Be,Re}var rLe=Dn('<span><svg width=16 height=16 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M6 12L10 8L6 4"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),oLe=Dn('<button title="Copy object to clipboard">'),sLe=Dn('<button title="Remove all items"aria-label="Remove all items">'),lLe=Dn('<button title="Delete item"aria-label="Delete item">'),uLe=Dn('<button title="Toggle value"aria-label="Toggle value">'),cLe=Dn('<button title="Bulk Edit Data"aria-label="Bulk Edit Data">'),dLe=Dn("<div>"),mLe=Dn("<div><button> <span></span> <span> "),hLe=Dn("<input>"),pLe=Dn("<span>"),gLe=Dn("<div><span>:"),vLe=Dn("<div><div><button> [<!>...<!>]");var fLe=e=>{const a=DMe(),n=LMe().shadowDOMTarget?lTe.bind({target:LMe().shadowDOMTarget}):lTe,t=Ra((()=>"dark"===a()?TLe(n):MLe(n)));return i=rLe(),ja((()=>Hn(i,cTe(t().expander,n`
114
+ */Jpe.exports="production"===process.env.NODE_ENV?function(){if(Vpe)return Upe;Vpe=1;var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},n=a.useState,t=a.useEffect,i=a.useLayoutEffect,r=a.useDebugValue;function o(a){var n=a.getSnapshot;a=a.value;try{var t=n();return!e(a,t)}catch(i){return!0}}var s="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,a){return a()}:function(e,a){var s=a(),l=n({inst:{value:s,getSnapshot:a}}),u=l[0].inst,c=l[1];return i((function(){u.value=s,u.getSnapshot=a,o(u)&&c({inst:u})}),[e,s,a]),t((function(){return o(u)&&c({inst:u}),e((function(){o(u)&&c({inst:u})}))}),[e]),r(s),s};return Upe.useSyncExternalStore=void 0!==a.useSyncExternalStore?a.useSyncExternalStore:s,Upe}():(Wpe||(Wpe=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var a=e.getSnapshot;e=e.value;try{var n=a();return!t(e,n)}catch(i){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=a,t="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},i=n.useState,r=n.useEffect,o=n.useLayoutEffect,s=n.useDebugValue,l=!1,u=!1,c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,a){return a()}:function(a,c){l||void 0===n.startTransition||(l=!0);var d=c();if(!u){var m=c();t(d,m)||(u=!0)}var h=(m=i({inst:{value:d,getSnapshot:c}}))[0].inst,p=m[1];return o((function(){h.value=d,h.getSnapshot=c,e(h)&&p({inst:h})}),[a,d,c]),r((function(){return e(h)&&p({inst:h}),a((function(){e(h)&&p({inst:h})}))}),[a]),s(d),d};qpe.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),qpe);var Zpe=Jpe.exports,$pe='[cmdk-group=""]',Ype='[cmdk-group-items=""]',Qpe='[cmdk-item=""]',Xpe=`${Qpe}:not([aria-disabled="true"])`,ege="cmdk-item-select",age="data-value",nge=(e,a,n)=>Fpe(e,a,n),tge=r.createContext(void 0),ige=()=>r.useContext(tge),rge=r.createContext(void 0),oge=()=>r.useContext(rge),sge=r.createContext(void 0),lge=r.forwardRef(((e,a)=>{let n=Age((()=>{var a,n;return{search:"",value:null!=(n=null!=(a=e.value)?a:e.defaultValue)?n:"",filtered:{count:0,items:new Map,groups:new Set}}})),t=Age((()=>new Set)),i=Age((()=>new Map)),o=Age((()=>new Map)),s=Age((()=>new Set)),l=bge(e),{label:u,children:c,value:d,onValueChange:m,filter:h,shouldFilter:p,loop:g,disablePointerSelection:v=!1,vimBindings:f=!0,...y}=e,k=E8(),b=E8(),S=E8(),A=r.useRef(null),w=Tge();Sge((()=>{if(void 0!==d){let e=d.trim();n.current.value=e,C.emit()}}),[d]),Sge((()=>{w(6,_)}),[]);let C=r.useMemo((()=>({subscribe:e=>(s.current.add(e),()=>s.current.delete(e)),snapshot:()=>n.current,setState:(e,a,t)=>{var i,r,o;if(!Object.is(n.current[e],a)){if(n.current[e]=a,"search"===e)N(),E(),w(1,x);else if("value"===e&&(t||w(5,_),void 0!==(null==(i=l.current)?void 0:i.value))){return void(null==(o=(r=l.current).onValueChange)||o.call(r,null!=a?a:""))}C.emit()}},emit:()=>{s.current.forEach((e=>e()))}})),[]),M=r.useMemo((()=>({value:(e,a,t)=>{var i;a!==(null==(i=o.current.get(e))?void 0:i.value)&&(o.current.set(e,{value:a,keywords:t}),n.current.filtered.items.set(e,T(a,t)),w(2,(()=>{E(),C.emit()})))},item:(e,a)=>(t.current.add(e),a&&(i.current.has(a)?i.current.get(a).add(e):i.current.set(a,new Set([e]))),w(3,(()=>{N(),E(),n.current.value||x(),C.emit()})),()=>{o.current.delete(e),t.current.delete(e),n.current.filtered.items.delete(e);let a=P();w(4,(()=>{N(),(null==a?void 0:a.getAttribute("id"))===e&&x(),C.emit()}))}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{o.current.delete(e),i.current.delete(e)}),filter:()=>l.current.shouldFilter,label:u||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:k,inputId:S,labelId:b,listInnerRef:A})),[]);function T(e,a){var t,i;let r=null!=(i=null==(t=l.current)?void 0:t.filter)?i:nge;return e?r(e,n.current.search,a):0}function E(){if(!n.current.search||!1===l.current.shouldFilter)return;let e=n.current.filtered.items,a=[];n.current.filtered.groups.forEach((n=>{let t=i.current.get(n),r=0;t.forEach((a=>{let n=e.get(a);r=Math.max(n,r)})),a.push([n,r])}));let t=A.current;L().sort(((a,n)=>{var t,i;let r=a.getAttribute("id"),o=n.getAttribute("id");return(null!=(t=e.get(o))?t:0)-(null!=(i=e.get(r))?i:0)})).forEach((e=>{let a=e.closest(Ype);a?a.appendChild(e.parentElement===a?e:e.closest(`${Ype} > *`)):t.appendChild(e.parentElement===t?e:e.closest(`${Ype} > *`))})),a.sort(((e,a)=>a[1]-e[1])).forEach((e=>{var a;let n=null==(a=A.current)?void 0:a.querySelector(`${$pe}[${age}="${encodeURIComponent(e[0])}"]`);null==n||n.parentElement.appendChild(n)}))}function x(){let e=L().find((e=>"true"!==e.getAttribute("aria-disabled"))),a=null==e?void 0:e.getAttribute(age);C.setState("value",a||void 0)}function N(){var e,a,r,s;if(!n.current.search||!1===l.current.shouldFilter)return void(n.current.filtered.count=t.current.size);n.current.filtered.groups=new Set;let u=0;for(let i of t.current){let t=T(null!=(a=null==(e=o.current.get(i))?void 0:e.value)?a:"",null!=(s=null==(r=o.current.get(i))?void 0:r.keywords)?s:[]);n.current.filtered.items.set(i,t),t>0&&u++}for(let[t,o]of i.current)for(let e of o)if(n.current.filtered.items.get(e)>0){n.current.filtered.groups.add(t);break}n.current.filtered.count=u}function _(){var e,a,n;let t=P();t&&((null==(e=t.parentElement)?void 0:e.firstChild)===t&&(null==(n=null==(a=t.closest($pe))?void 0:a.querySelector('[cmdk-group-heading=""]'))||n.scrollIntoView({block:"nearest"})),t.scrollIntoView({block:"nearest"}))}function P(){var e;return null==(e=A.current)?void 0:e.querySelector(`${Qpe}[aria-selected="true"]`)}function L(){var e;return Array.from((null==(e=A.current)?void 0:e.querySelectorAll(Xpe))||[])}function j(e){let a=L()[e];a&&C.setState("value",a.getAttribute(age))}function B(e){var a;let n=P(),t=L(),i=t.findIndex((e=>e===n)),r=t[i+e];null!=(a=l.current)&&a.loop&&(r=i+e<0?t[t.length-1]:i+e===t.length?t[0]:t[i+e]),r&&C.setState("value",r.getAttribute(age))}function R(e){let a,n=P(),t=null==n?void 0:n.closest($pe);for(;t&&!a;)t=e>0?yge(t,$pe):kge(t,$pe),a=null==t?void 0:t.querySelector(Xpe);a?C.setState("value",a.getAttribute(age)):B(e)}let z=()=>j(L().length-1),D=e=>{e.preventDefault(),e.metaKey?z():e.altKey?R(1):B(1)},K=e=>{e.preventDefault(),e.metaKey?j(0):e.altKey?R(-1):B(-1)};return r.createElement(Y6.div,{ref:a,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:e=>{var a;if(null==(a=y.onKeyDown)||a.call(y,e),!e.defaultPrevented)switch(e.key){case"n":case"j":f&&e.ctrlKey&&D(e);break;case"ArrowDown":D(e);break;case"p":case"k":f&&e.ctrlKey&&K(e);break;case"ArrowUp":K(e);break;case"Home":e.preventDefault(),j(0);break;case"End":e.preventDefault(),z();break;case"Enter":if(!e.nativeEvent.isComposing&&229!==e.keyCode){e.preventDefault();let a=P();if(a){let e=new Event(ege);a.dispatchEvent(e)}}}}},r.createElement("label",{"cmdk-label":"",htmlFor:M.inputId,id:M.labelId,style:xge},u),Ege(e,(e=>r.createElement(rge.Provider,{value:C},r.createElement(tge.Provider,{value:M},e)))))})),uge=r.forwardRef(((e,a)=>{var n,t;let i=E8(),o=r.useRef(null),s=r.useContext(sge),l=ige(),u=bge(e),c=null!=(t=null==(n=u.current)?void 0:n.forceMount)?t:null==s?void 0:s.forceMount;Sge((()=>{if(!c)return l.item(i,null==s?void 0:s.id)}),[c]);let d=Mge(i,o,[e.value,e.children,o],e.keywords),m=oge(),h=Cge((e=>e.value&&e.value===d.current)),p=Cge((e=>!(!c&&!1!==l.filter())||(!e.search||e.filtered.items.get(i)>0)));function g(){var e,a;v(),null==(a=(e=u.current).onSelect)||a.call(e,d.current)}function v(){m.setState("value",d.current,!0)}if(r.useEffect((()=>{let a=o.current;if(a&&!e.disabled)return a.addEventListener(ege,g),()=>a.removeEventListener(ege,g)}),[p,e.onSelect,e.disabled]),!p)return null;let{disabled:f,value:y,onSelect:k,forceMount:b,keywords:S,...A}=e;return r.createElement(Y6.div,{ref:wge([o,a]),...A,id:i,"cmdk-item":"",role:"option","aria-disabled":!!f,"aria-selected":!!h,"data-disabled":!!f,"data-selected":!!h,onPointerMove:f||l.getDisablePointerSelection()?void 0:v,onClick:f?void 0:g},e.children)})),cge=r.forwardRef(((e,a)=>{let{heading:n,children:t,forceMount:i,...o}=e,s=E8(),l=r.useRef(null),u=r.useRef(null),c=E8(),d=ige(),m=Cge((e=>!(!i&&!1!==d.filter())||(!e.search||e.filtered.groups.has(s))));Sge((()=>d.group(s)),[]),Mge(s,l,[e.value,e.heading,u]);let h=r.useMemo((()=>({id:s,forceMount:i})),[i]);return r.createElement(Y6.div,{ref:wge([l,a]),...o,"cmdk-group":"",role:"presentation",hidden:!m||void 0},n&&r.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Ege(e,(e=>r.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},r.createElement(sge.Provider,{value:h},e)))))})),dge=r.forwardRef(((e,a)=>{let{alwaysRender:n,...t}=e,i=r.useRef(null),o=Cge((e=>!e.search));return n||o?r.createElement(Y6.div,{ref:wge([i,a]),...t,"cmdk-separator":"",role:"separator"}):null})),mge=r.forwardRef(((e,a)=>{let{onValueChange:n,...t}=e,i=null!=e.value,o=oge(),s=Cge((e=>e.search)),l=Cge((e=>e.value)),u=ige(),c=r.useMemo((()=>{var e;let a=null==(e=u.listInnerRef.current)?void 0:e.querySelector(`${Qpe}[${age}="${encodeURIComponent(l)}"]`);return null==a?void 0:a.getAttribute("id")}),[]);return r.useEffect((()=>{null!=e.value&&o.setState("search",e.value)}),[e.value]),r.createElement(Y6.input,{ref:a,...t,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":c,id:u.inputId,type:"text",value:i?e.value:s,onChange:e=>{i||o.setState("search",e.target.value),null==n||n(e.target.value)}})})),hge=r.forwardRef(((e,a)=>{let{children:n,label:t="Suggestions",...i}=e,o=r.useRef(null),s=r.useRef(null),l=ige();return r.useEffect((()=>{if(s.current&&o.current){let e,a=s.current,n=o.current,t=new ResizeObserver((()=>{e=requestAnimationFrame((()=>{n.style.setProperty("--cmdk-list-height",a.offsetHeight.toFixed(1)+"px")}))}));return t.observe(a),()=>{cancelAnimationFrame(e),t.unobserve(a)}}}),[]),r.createElement(Y6.div,{ref:wge([o,a]),...i,"cmdk-list":"",role:"listbox","aria-label":t,id:l.listId},Ege(e,(e=>r.createElement("div",{ref:wge([s,l.listInnerRef]),"cmdk-list-sizer":""},e))))})),pge=r.forwardRef(((e,a)=>{let{open:n,onOpenChange:t,overlayClassName:i,contentClassName:o,container:s,...l}=e;return r.createElement(C$,{open:n,onOpenChange:t},r.createElement(M$,{container:s},r.createElement(T$,{"cmdk-overlay":"",className:i}),r.createElement(E$,{"aria-label":e.label,"cmdk-dialog":"",className:o},r.createElement(lge,{ref:a,...l}))))})),gge=r.forwardRef(((e,a)=>Cge((e=>0===e.filtered.count))?r.createElement(Y6.div,{ref:a,...e,"cmdk-empty":"",role:"presentation"}):null)),vge=r.forwardRef(((e,a)=>{let{progress:n,children:t,label:i="Loading...",...o}=e;return r.createElement(Y6.div,{ref:a,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Ege(e,(e=>r.createElement("div",{"aria-hidden":!0},e))))})),fge=Object.assign(lge,{List:hge,Item:uge,Input:mge,Group:cge,Separator:dge,Dialog:pge,Empty:gge,Loading:vge});function yge(e,a){let n=e.nextElementSibling;for(;n;){if(n.matches(a))return n;n=n.nextElementSibling}}function kge(e,a){let n=e.previousElementSibling;for(;n;){if(n.matches(a))return n;n=n.previousElementSibling}}function bge(e){let a=r.useRef(e);return Sge((()=>{a.current=e})),a}var Sge="undefined"==typeof window?r.useEffect:r.useLayoutEffect;function Age(e){let a=r.useRef();return void 0===a.current&&(a.current=e()),a}function wge(e){return a=>{e.forEach((e=>{"function"==typeof e?e(a):null!=e&&(e.current=a)}))}}function Cge(e){let a=oge(),n=()=>e(a.snapshot());return Zpe.useSyncExternalStore(a.subscribe,n,n)}function Mge(e,a,n,t=[]){let i=r.useRef(),o=ige();return Sge((()=>{var r;let s=(()=>{var e;for(let a of n){if("string"==typeof a)return a.trim();if("object"==typeof a&&"current"in a)return a.current?null==(e=a.current.textContent)?void 0:e.trim():i.current}})(),l=t.map((e=>e.trim()));o.value(e,s,l),null==(r=a.current)||r.setAttribute(age,s),i.current=s})),i}var Tge=()=>{let[e,a]=r.useState(),n=Age((()=>new Map));return Sge((()=>{n.current.forEach((e=>e())),n.current=new Map}),[e]),(e,t)=>{n.current.set(e,t),a({})}};function Ege({asChild:e,children:a},n){return e&&r.isValidElement(a)?r.cloneElement(function(e){let a=e.type;return"function"==typeof a?a(e.props):"render"in a?a.render(e.props):e}(a),{ref:a.ref},n(a.props.children)):n(a)}var xge={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Nge=r.forwardRef((({className:e,...a},t)=>n.jsx(fge,{ref:t,className:vm("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a})));Nge.displayName=fge.displayName;const _ge=r.forwardRef((({className:e,searchIcon:a,...t},i)=>n.jsxs("div",{className:"flex items-center border-b px-3",children:[a||n.jsx(ud,{className:"mr-2 h-4 w-4 shrink-0 opacity-50 "}),n.jsx(fge.Input,{ref:i,className:vm("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})));_ge.displayName=fge.Input.displayName;const Pge=r.forwardRef((({className:e,...a},t)=>n.jsx(fge.List,{ref:t,className:vm("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a})));Pge.displayName=fge.List.displayName;const Lge=r.forwardRef(((e,a)=>n.jsx(fge.Empty,{ref:a,className:"py-6 text-center text-sm",...e})));Lge.displayName=fge.Empty.displayName;const jge=r.forwardRef((({className:e,...a},t)=>n.jsx(fge.Group,{ref:t,className:vm("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...a})));jge.displayName=fge.Group.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(fge.Separator,{ref:t,className:vm("-mx-1 h-px bg-border",e),...a}))).displayName=fge.Separator.displayName;const Bge=r.forwardRef((({className:e,...a},t)=>n.jsx(fge.Item,{ref:t,className:vm("relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...a})));function Rge(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function zge(...e){return a=>{let n=!1;const t=e.map((e=>{const t=Rge(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():Rge(e[a],null)}}}}function Dge(...e){return r.useCallback(zge(...e),e)}function Kge(e){const a=Oge(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Ige);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function Oge(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{const a=r(...e);return i(...e),a}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?zge(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}Bge.displayName=fge.Item.displayName;var Hge=Symbol("radix.slottable");function Ige(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Hge}var Gge=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=Kge(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),Fge=globalThis?.document?r.useLayoutEffect:()=>{};var Vge=e=>{const{present:a,children:n}=e,t=function(e){const[a,n]=r.useState(),t=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,n)=>a[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=Jge(t.current);o.current="mounted"===l?e:"none"}),[l]),Fge((()=>{const a=t.current,n=i.current;if(n!==e){const t=o.current,r=Jge(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(n&&t!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),Fge((()=>{if(a){let e;const n=a.ownerDocument.defaultView??window,r=r=>{const o=Jge(t.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const t=a.style.animationFillMode;a.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=t)}))}},s=e=>{e.target===a&&(o.current=Jge(t.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{n.clearTimeout(e),a.removeEventListener("animationstart",s),a.removeEventListener("animationcancel",r),a.removeEventListener("animationend",r)}}u("ANIMATION_END")}),[a,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{t.current=e?getComputedStyle(e):null,n(e)}),[])}}(a),i="function"==typeof n?n({present:t.isPresent}):r.Children.only(n),o=Dge(t.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||t.isPresent?r.cloneElement(i,{ref:o}):null};function Jge(e){return e?.animationName||"none"}function Uge(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function Wge(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}Vge.displayName="Presence";var qge=r.createContext(void 0);function Zge(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}var $ge="ScrollArea",[Yge,Qge]=function(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},Uge(i,...a)]}($ge),[Xge,eve]=Yge($ge),ave=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,type:i="hover",dir:o,scrollHideDelay:s=600,...l}=e,[u,c]=r.useState(null),[d,m]=r.useState(null),[h,p]=r.useState(null),[g,v]=r.useState(null),[f,y]=r.useState(null),[k,b]=r.useState(0),[S,A]=r.useState(0),[w,C]=r.useState(!1),[M,T]=r.useState(!1),E=Dge(a,(e=>c(e))),x=function(e){const a=r.useContext(qge);return e||a||"ltr"}(o);return n.jsx(Xge,{scope:t,type:i,dir:x,scrollHideDelay:s,scrollArea:u,viewport:d,onViewportChange:m,content:h,onContentChange:p,scrollbarX:g,onScrollbarXChange:v,scrollbarXEnabled:w,onScrollbarXEnabledChange:C,scrollbarY:f,onScrollbarYChange:y,scrollbarYEnabled:M,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:A,children:n.jsx(Gge.div,{dir:x,...l,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})}));ave.displayName=$ge;var nve="ScrollAreaViewport",tve=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,children:i,nonce:o,...s}=e,l=eve(nve,t),u=Dge(a,r.useRef(null),l.onViewportChange);return n.jsxs(n.Fragment,{children:[n.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),n.jsx(Gge.div,{"data-radix-scroll-area-viewport":"",...s,ref:u,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})}));tve.displayName=nve;var ive="ScrollAreaScrollbar",rve=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=eve(ive,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:l}=o,u="horizontal"===e.orientation;return r.useEffect((()=>(u?s(!0):l(!0),()=>{u?s(!1):l(!1)})),[u,s,l]),"hover"===o.type?n.jsx(ove,{...i,ref:a,forceMount:t}):"scroll"===o.type?n.jsx(sve,{...i,ref:a,forceMount:t}):"auto"===o.type?n.jsx(lve,{...i,ref:a,forceMount:t}):"always"===o.type?n.jsx(uve,{...i,ref:a}):null}));rve.displayName=ive;var ove=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=eve(ive,e.__scopeScrollArea),[s,l]=r.useState(!1);return r.useEffect((()=>{const e=o.scrollArea;let a=0;if(e){const n=()=>{window.clearTimeout(a),l(!0)},t=()=>{a=window.setTimeout((()=>l(!1)),o.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",t),()=>{window.clearTimeout(a),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",t)}}}),[o.scrollArea,o.scrollHideDelay]),n.jsx(Vge,{present:t||s,children:n.jsx(lve,{"data-state":s?"visible":"hidden",...i,ref:a})})})),sve=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=eve(ive,e.__scopeScrollArea),s="horizontal"===e.orientation,l=xve((()=>c("SCROLL_END")),100),[u,c]=(d={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},r.useReducer(((e,a)=>d[e][a]??e),"hidden"));var d;return r.useEffect((()=>{if("idle"===u){const e=window.setTimeout((()=>c("HIDE")),o.scrollHideDelay);return()=>window.clearTimeout(e)}}),[u,o.scrollHideDelay,c]),r.useEffect((()=>{const e=o.viewport,a=s?"scrollLeft":"scrollTop";if(e){let n=e[a];const t=()=>{const t=e[a];n!==t&&(c("SCROLL"),l()),n=t};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}}),[o.viewport,s,c,l]),n.jsx(Vge,{present:t||"hidden"!==u,children:n.jsx(uve,{"data-state":"hidden"===u?"hidden":"visible",...i,ref:a,onPointerEnter:Zge(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:Zge(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),lve=r.forwardRef(((e,a)=>{const t=eve(ive,e.__scopeScrollArea),{forceMount:i,...o}=e,[s,l]=r.useState(!1),u="horizontal"===e.orientation,c=xve((()=>{if(t.viewport){l(u?t.viewport.offsetWidth<t.viewport.scrollWidth:t.viewport.offsetHeight<t.viewport.scrollHeight)}}),10);return Nve(t.viewport,c),Nve(t.content,c),n.jsx(Vge,{present:i||s,children:n.jsx(uve,{"data-state":s?"visible":"hidden",...o,ref:a})})})),uve=r.forwardRef(((e,a)=>{const{orientation:t="vertical",...i}=e,o=eve(ive,e.__scopeScrollArea),s=r.useRef(null),l=r.useRef(0),[u,c]=r.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Ave(u.viewport,u.content),m={...i,sizes:u,onSizesChange:c,hasThumb:Boolean(d>0&&d<1),onThumbChange:e=>s.current=e,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:e=>l.current=e};function h(e,a){return function(e,a,n,t="ltr"){const i=wve(n),r=i/2,o=a||r,s=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-(i-o),u=n.content-n.viewport,c="ltr"===t?[0,u]:[-1*u,0];return Mve([s,l],c)(e)}(e,l.current,u,a)}return"horizontal"===t?n.jsx(cve,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=Cve(o.viewport.scrollLeft,u,o.dir);s.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollLeft=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollLeft=h(e,o.dir))}}):"vertical"===t?n.jsx(dve,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=Cve(o.viewport.scrollTop,u);s.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollTop=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollTop=h(e))}}):null})),cve=r.forwardRef(((e,a)=>{const{sizes:t,onSizesChange:i,...o}=e,s=eve(ive,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=Dge(a,c,s.onScrollbarXChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),n.jsx(pve,{"data-orientation":"horizontal",...o,ref:d,sizes:t,style:{bottom:0,left:"rtl"===s.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===s.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":wve(t)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.x),onDragScroll:a=>e.onDragScroll(a.x),onWheelScroll:(a,n)=>{if(s.viewport){const t=s.viewport.scrollLeft+a.deltaX;e.onWheelScroll(t),Tve(t,n)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Sve(l.paddingLeft),paddingEnd:Sve(l.paddingRight)}})}})})),dve=r.forwardRef(((e,a)=>{const{sizes:t,onSizesChange:i,...o}=e,s=eve(ive,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=Dge(a,c,s.onScrollbarYChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),n.jsx(pve,{"data-orientation":"vertical",...o,ref:d,sizes:t,style:{top:0,right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":wve(t)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.y),onDragScroll:a=>e.onDragScroll(a.y),onWheelScroll:(a,n)=>{if(s.viewport){const t=s.viewport.scrollTop+a.deltaY;e.onWheelScroll(t),Tve(t,n)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Sve(l.paddingTop),paddingEnd:Sve(l.paddingBottom)}})}})})),[mve,hve]=Yge(ive),pve=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,sizes:i,hasThumb:o,onThumbChange:s,onThumbPointerUp:l,onThumbPointerDown:u,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:m,onResize:h,...p}=e,g=eve(ive,t),[v,f]=r.useState(null),y=Dge(a,(e=>f(e))),k=r.useRef(null),b=r.useRef(""),S=g.viewport,A=i.content-i.viewport,w=Wge(m),C=Wge(c),M=xve(h,10);function T(e){if(k.current){d({x:e.clientX-k.current.left,y:e.clientY-k.current.top})}}return r.useEffect((()=>{const e=e=>{const a=e.target,n=v?.contains(a);n&&w(e,A)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[S,v,A,w]),r.useEffect(C,[i,C]),Nve(v,M),Nve(g.content,M),n.jsx(mve,{scope:t,scrollbar:v,hasThumb:o,onThumbChange:Wge(s),onThumbPointerUp:Wge(l),onThumbPositionChange:C,onThumbPointerDown:Wge(u),children:n.jsx(Gge.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Zge(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),k.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(e)}})),onPointerMove:Zge(e.onPointerMove,T),onPointerUp:Zge(e.onPointerUp,(e=>{const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=b.current,g.viewport&&(g.viewport.style.scrollBehavior=""),k.current=null}))})})})),gve="ScrollAreaThumb",vve=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,r=hve(gve,e.__scopeScrollArea);return n.jsx(Vge,{present:t||r.hasThumb,children:n.jsx(fve,{ref:a,...i})})})),fve=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,style:i,...o}=e,s=eve(gve,t),l=hve(gve,t),{onThumbPositionChange:u}=l,c=Dge(a,(e=>l.onThumbChange(e))),d=r.useRef(void 0),m=xve((()=>{d.current&&(d.current(),d.current=void 0)}),100);return r.useEffect((()=>{const e=s.viewport;if(e){const a=()=>{if(m(),!d.current){const a=Eve(e,u);d.current=a,u()}};return u(),e.addEventListener("scroll",a),()=>e.removeEventListener("scroll",a)}}),[s.viewport,m,u]),n.jsx(Gge.div,{"data-state":l.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:Zge(e.onPointerDownCapture,(e=>{const a=e.target.getBoundingClientRect();l.onThumbPointerDown({x:e.clientX-a.left,y:e.clientY-a.top})})),onPointerUp:Zge(e.onPointerUp,l.onThumbPointerUp)})}));vve.displayName=gve;var yve="ScrollAreaCorner",kve=r.forwardRef(((e,a)=>{const t=eve(yve,e.__scopeScrollArea),i=Boolean(t.scrollbarX&&t.scrollbarY);return"scroll"!==t.type&&i?n.jsx(bve,{...e,ref:a}):null}));kve.displayName=yve;var bve=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,...i}=e,o=eve(yve,t),[s,l]=r.useState(0),[u,c]=r.useState(0),d=Boolean(s&&u);return Nve(o.scrollbarX,(()=>{const e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),c(e)})),Nve(o.scrollbarY,(()=>{const e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),l(e)})),d?n.jsx(Gge.div,{...i,ref:a,style:{width:s,height:u,position:"absolute",right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:0,...e.style}}):null}));function Sve(e){return e?parseInt(e,10):0}function Ave(e,a){const n=e/a;return isNaN(n)?0:n}function wve(e){const a=Ave(e.viewport,e.content);return Math.max((e.scrollbar.size-(e.scrollbar.paddingStart+e.scrollbar.paddingEnd))*a,18)}function Cve(e,a,n="ltr"){const t=wve(a),i=a.content-a.viewport,r=a.scrollbar.size-(a.scrollbar.paddingStart+a.scrollbar.paddingEnd)-t,o=function(e,[a,n]){return Math.min(n,Math.max(a,e))}(e,"ltr"===n?[0,i]:[-1*i,0]);return Mve([0,i],[0,r])(o)}function Mve(e,a){return n=>{if(e[0]===e[1]||a[0]===a[1])return a[0];return a[0]+(a[1]-a[0])/(e[1]-e[0])*(n-e[0])}}function Tve(e,a){return e>0&&e<a}var Eve=(e,a=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},t=0;return function i(){const r={left:e.scrollLeft,top:e.scrollTop};(n.left!==r.left||n.top!==r.top)&&a(),n=r,t=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(t)};function xve(e,a){const n=Wge(e),t=r.useRef(0);return r.useEffect((()=>()=>window.clearTimeout(t.current)),[]),r.useCallback((()=>{window.clearTimeout(t.current),t.current=window.setTimeout(n,a)}),[n,a])}function Nve(e,a){const n=Wge(a);Fge((()=>{let a=0;if(e){const t=new ResizeObserver((()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(n)}));return t.observe(e),()=>{window.cancelAnimationFrame(a),t.unobserve(e)}}}),[e,n])}var _ve=ave,Pve=tve,Lve=kve;const jve=r.forwardRef((({className:e,children:a,...t},i)=>n.jsxs(_ve,{ref:i,className:P$("relative overflow-hidden",e),...t,children:[n.jsx(Pve,{className:"h-full w-full rounded-[inherit]",children:a}),n.jsx(Bve,{}),n.jsx(Lve,{})]})));jve.displayName=_ve.displayName;const Bve=r.forwardRef((({className:e,orientation:a="vertical",...t},i)=>n.jsx(rve,{ref:i,orientation:a,className:P$("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...t,children:n.jsx(vve,{className:"relative flex-1 rounded-full bg-border"})})));Bve.displayName=rve.displayName;var Rve=r.forwardRef(((e,a)=>{const{children:t,...i}=e,o=r.Children.toArray(t),s=o.find(Kve);if(s){const e=s.props.children,t=o.map((a=>a===s?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(zve,{...i,ref:a,children:r.isValidElement(e)?r.cloneElement(e,void 0,t):null})}return n.jsx(zve,{...i,ref:a,children:t})}));Rve.displayName="Slot";var zve=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?aq(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));zve.displayName="SlotClone";var Dve=({children:e})=>n.jsx(n.Fragment,{children:e});function Kve(e){return r.isValidElement(e)&&e.type===Dve}var Ove=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,a)=>{const t=r.forwardRef(((e,t)=>{const{asChild:i,...r}=e,o=i?Rve:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(o,{...r,ref:t})}));return t.displayName=`Primitive.${a}`,{...e,[a]:t}}),{}),Hve="horizontal",Ive=["horizontal","vertical"],Gve=r.forwardRef(((e,a)=>{const{decorative:t,orientation:i=Hve,...r}=e,o=function(e){return Ive.includes(e)}(i)?i:Hve;return n.jsx(Ove.div,{"data-orientation":o,...t?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...r,ref:a})}));Gve.displayName="Separator";var Fve=Gve;const Vve=r.forwardRef((({className:e,orientation:a="horizontal",decorative:t=!0,...i},r)=>n.jsx(Fve,{ref:r,decorative:t,orientation:a,className:vm("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...i})));function Jve({options:e,onValueChange:a,selectedValues:t,setSelectedValues:i,maxCount:o,placeholder:s="Select options",title:l="Select Items",searchPlaceholder:u="Search items...",emptyMessage:c="No items found",extraCommandItems:d=[],canOpen:m=!0,singleSelect:h=!1}){const[p,g]=r.useState(!1),[v,f]=r.useState(""),[y,k]=r.useState(t),b=r.useMemo((()=>Array.from(new Map([...e].filter((e=>e&&"string"==typeof e.value&&"string"==typeof e.label&&""!==e.value.trim()&&""!==e.label.trim())).map((e=>[e.value,e]))).values())),[e]),S=r.useMemo((()=>{if(!v)return b;return[...b.filter((e=>y.includes(e.value))),...b.filter((e=>!y.includes(e.value))).filter((e=>e.label.toLowerCase().includes(v.toLowerCase())))]}),[b,v,y]),A=r.useCallback((()=>t.map((a=>{const n=e.find((e=>e.value===a));return{value:a,label:n?.label||a}}))),[t,e]),w=e=>{if(h)return k([e]),a([e]),i([e]),void g(!1);k((a=>a.includes(e)?a.filter((a=>a!==e)):o&&a.length>=o?a:[...a,e]))};r.useEffect((()=>{p&&(k(t),f(""))}),[p,t]);const C=y.length,M=S.filter((e=>y.includes(e.value))).length,T=A(),E=!o||y.length<o,x=r.useMemo((()=>S.filter((e=>y.includes(e.value)))),[S,y]),N=r.useMemo((()=>S.filter((e=>!y.includes(e.value)))),[S,y]);return n.jsxs(L$,{open:p&&m,onOpenChange:m?g:void 0,children:[n.jsx(j$,{asChild:!0,children:n.jsxs(k5,{variant:"outline",disabled:!m,className:vm("w-full justify-between text-left font-normal h-9 p-3",!m&&"opacity-50 cursor-not-allowed"),children:[n.jsx("div",{className:"flex flex-nowrap items-center gap-1 max-w-[70%]",children:0===T.length?n.jsx("span",{className:"text-muted-foreground",children:s}):h?n.jsx(B5,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label}):T.length<=2?T.map((e=>n.jsx(B5,{variant:"secondary",className:"text-xs whitespace-nowrap",children:e.label},e.value))):n.jsxs(n.Fragment,{children:[n.jsx(B5,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label},T[0].value),n.jsxs(B5,{variant:"secondary",className:"text-xs whitespace-nowrap",children:["+",T.length-1," more"]})]})}),n.jsx(w5.DropdownMenuTrigger,{className:"h-4 w-4 opacity-50 ml-2 flex-shrink-0"})]})}),n.jsxs(z$,{className:"max-w-md w-full max-h-[80vh] p-0",children:[n.jsx(D$,{className:"p-6 pb-4",children:n.jsxs(O$,{className:"flex items-center gap-2 text-xl",children:[n.jsx(w5.UsersIcon,{className:"h-5 w-5 text-primary"}),l]})}),n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"relative",children:[n.jsx(w5.SearchIcon,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(qae,{placeholder:u,value:v,onChange:e=>f(e.target.value),className:"pl-10 h-11"})]})}),!h&&n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"flex items-center justify-between text-sm",children:[n.jsxs("span",{className:"text-muted-foreground",children:[C," of ",b.length," selected",o&&` (max ${o})`]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(k5,{variant:"ghost",size:"sm",onClick:()=>{const e=S.filter((e=>!y.includes(e.value))),a=o?e.slice(0,o-y.length):e;k((e=>[...e,...a.map((e=>e.value))]))},disabled:!E||M===S.length,className:"h-8 text-xs",children:"Select All"}),n.jsx(k5,{variant:"ghost",size:"sm",onClick:()=>{const e=new Set(S.map((e=>e.value)));k((a=>a.filter((a=>!e.has(a)))))},disabled:0===M,className:"h-8 text-xs",children:"Clear All"})]})]})}),n.jsx(Vve,{}),n.jsx(jve,{className:"flex-1 max-h-[300px]",children:n.jsx(Nge,{className:"rounded-none border-none",children:n.jsxs(jge,{children:[d.length>0&&n.jsxs(n.Fragment,{children:[d.map(((e,a)=>n.jsx("div",{className:"px-3 py-2",children:e(g)},`extra-command-${a}`))),n.jsx(Vve,{className:"my-2"})]}),0===S.length?n.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[n.jsx(w5.SearchIcon,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{children:c})]}):n.jsxs(n.Fragment,{children:[!h&&x.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:["Selected (",x.length,")"]}),x.map((e=>n.jsxs(Bge,{onSelect:()=>w(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors hover:bg-muted/50 cursor-pointer",children:[n.jsx(Rpe,{checked:!0,disabled:!1,onChange:()=>w(e.value),className:"flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),n.jsx(w5.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value))),n.jsx(Vve,{className:"my-2"})]}),n.jsx("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:h?"Options":`Available (${N.length})`}),N.map((e=>{const a=y.includes(e.value),t=!h&&!E;return n.jsxs(Bge,{onSelect:()=>!t&&w(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors "+(t?"opacity-50 cursor-not-allowed":"hover:bg-muted/50 cursor-pointer"),children:[!h&&n.jsx(Rpe,{checked:a,disabled:t,onChange:()=>!t&&w(e.value),className:"flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),a&&n.jsx(w5.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value)}))]})]})})}),!h&&n.jsxs(n.Fragment,{children:[n.jsx(Vve,{}),n.jsx("div",{className:"p-6 pt-4",children:n.jsxs("div",{className:"flex gap-3",children:[n.jsx(k5,{variant:"outline",onClick:()=>{k(t),f(""),g(!1)},className:"flex-1",children:"Cancel"}),n.jsxs(k5,{onClick:()=>{a(y),i(y),g(!1)},className:"flex-1 bg-primary hover:bg-primary/90",children:["Apply (",C,")"]})]})})]})]})]})}Vve.displayName=Fve.displayName;const Uve=r.forwardRef((({className:e,...a},t)=>n.jsx("textarea",{className:vm("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:t,...a})));Uve.displayName="Textarea";const Wve=e=>{const{companyName:a,smsBody:n}=e;return a&&n?`${a}:\n${n}`:n??""},qve=({body:e,imageUrls:a})=>n.jsx("div",{className:"sms-preview-outer @container",children:n.jsxs("div",{className:"sms-phone-mockup",children:[n.jsx("div",{className:"sms-phone-notch"}),n.jsxs("div",{className:"sms-phone-inner",children:[a&&a.length>0&&a.map(((e,a)=>n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:n.jsx("img",{src:e,alt:"MMS attachment",className:"sms-message-image",loading:"lazy"})})},e+a))),n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:e})})]}),n.jsx("div",{className:"sms-phone-home-indicator"})]})}),Zve=({mergeFieldsResponse:e})=>{const t=1500,i=d5(),r=m5(),{data:o}=Sre(),s=a.useCallback((()=>{const e=i?.actionData?.find((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId===r?.id));return e?.actionMetadata.communicationGroupId}),[i?.actionData,r?.id]),{channelSenders:l}=fre(),{data:u,isLoading:c}=ype(),{channelAccounts:d}=pre(),{toast:m}=Ge(),{updateCommunicationGroup:h,isUpdating:p}=$e(),[g,v]=a.useState(null),[f,y]=a.useState(!1),[k,b]=a.useState(null),[S,A]=a.useState(null),[w,C]=a.useState([]),[M,T]=a.useState(null),[E,x]=a.useState(!1),[N,_]=a.useState(!1),P=a.useRef(null),L=a.useRef(null),[j,B]=a.useState(null),[R,z]=a.useState(null),[D,K]=a.useState(!1),O=a.useMemo((()=>ale({channelSenders:l?.results??[],channelAccounts:d?.results??[],smsApplication:o})),[l,d,o]);a.useEffect((()=>{E||(B(w.length>0?w[0]:null),z(null),K(!1))}),[E,w]),a.useEffect((()=>{r?.textMessageMediaUrls&&C(r.textMessageMediaUrls)}),[r?.textMessageMediaUrls]);a.useEffect((()=>{r&&!1===N&&(r.smsChannelSenderId&&null===g&&v(r.smsChannelSenderId),r.smsMessageBody&&null===S&&(A(r.smsMessageBody),T(r.smsMessageBody)),r.textMessageCompanyName&&null===k&&b(r.textMessageCompanyName),r.textMessageMediaUrls&&0===w.length&&C(r.textMessageMediaUrls),E&&(null===M&&T(S),w.length>0&&!j&&!D&&B(w[0])),void 0!==l&&(g?g&&r?.id&&h({groupId:r.id,params:{smsChannelSenderId:g}}):O?.[0]&&(v(O[0].channelSender.id),r?.id&&h({groupId:r.id,params:{smsChannelSenderId:O[0].channelSender.id}}))),_(!0))}),[r,g,S,k,w,N,E,M,j,D,l,O,h]);a.useEffect((()=>{k||!u?.name||f||(y(!0),b(u.branding?.brandName?u.branding?.brandName:u.name))}),[k,u?.name,f,u?.branding?.brandName]);return d&&l&&!c&&void 0!==O&&void 0!==o?0===O?.length&&o?.status!==ele.PENDING?n.jsx(gpe,{}):n.jsxs("div",{children:[n.jsx(L$,{open:E,onOpenChange:x,children:n.jsxs(z$,{hideCloseButton:!0,className:"max-w-[50vw]",children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"SMS Editor"}),n.jsx(H$,{children:"Learn more about the SMS editor and how to use it to create your SMS."})]}),n.jsxs("div",{className:"",children:[j&&n.jsx("div",{className:"flex justify-center mb-6",children:n.jsx("div",{className:"relative group w-fit",children:n.jsx("img",{src:j,alt:"SMS attachment preview",className:"max-h-48 max-w-xs rounded-xl shadow-lg border border-gray-200 object-contain bg-white transition-transform duration-200",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.08)"}})})}),n.jsx(Uve,{ref:P,className:"min-h-[300px]",placeholder:"Text message content...",value:M??"",onChange:e=>{T(e.target.value)},maxLength:t-(k?.length||0)}),n.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Jve,{options:e?.mergeFields?.flatMap((e=>e.entries.map((e=>({label:e.label,value:e.value})))))??[],selectedValues:[],setSelectedValues:()=>{},onValueChange:e=>{if(e.length>0){const a=P.current,n=M||"",t=a?.selectionStart??n.length,i=a?.selectionEnd??n.length,r=n.slice(0,t)+e[0]+n.slice(i);T(r),setTimeout((()=>{const n=t+e[0].length;a?.focus(),a?.setSelectionRange(n,n)}),0)}},placeholder:"Add merge field",title:"Merge Fields",searchPlaceholder:"Search merge fields...",emptyMessage:"No merge fields found",singleSelect:!0}),n.jsx(pue,{title:"Dynamic content is a way to insert dynamic content into your messages such as the customer's name, email, or other details."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("input",{type:"file",ref:L,onChange:async e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{try{const a=await async function(e){if(!bpe)throw new Error("Image conversion is only supported in browser environments");return new Promise(((a,n)=>{try{const t=new window.Image;t.crossOrigin="anonymous",t.onload=()=>{try{const e=document.createElement("canvas");e.width=t.naturalWidth,e.height=t.naturalHeight;const i=e.getContext("2d");if(!i)return void n(new Error("Failed to get canvas context"));i.drawImage(t,0,0);const r=e.toDataURL("image/png",1);a(r)}catch(e){n(e)}},t.onerror=()=>{n(new Error("Failed to load image"))},t.src=e}catch(t){n(t)}}))}(e.result),n=function(e){if(!e.startsWith("data:"))throw new Error('Invalid data URL: must start with "data:"');const a=e.split(",");if(2!==a.length)throw new Error("Invalid data URL format: missing base64 data");if(!a[0].includes(";base64"))throw new Error("Invalid data URL format: missing base64 encoding");return a[1]}(a);z(n),B(a),K(!1),r?.id&&h({groupId:r.id,params:{textMessageMedia:[n]}},{onError:()=>{m({title:"Error updating image",description:"Please contact your administrator"})}})}catch(a){m({title:"Error converting image",description:"Failed to convert image to PNG format",variant:"destructive"})}},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),n.jsx(k5,j?{variant:"outline",onClick:()=>{L.current&&(L.current.value=""),r?.id&&h({groupId:r.id,params:{textMessageMedia:[]}},{onSuccess:()=>{B(null),z(null),K(!1),C([]),L.current&&(L.current.value="")},onError:()=>{m({title:"Error removing image",description:"Please contact your administrator"})}})},className:"px-4",disabled:D||p,children:"Remove Image"}:{variant:"outline",onClick:()=>{L.current?.click()},className:"px-4",disabled:w.length>=1||D||null!==R||p,children:"Add Image"}),n.jsx(k5,{variant:"outline",onClick:()=>{T(S),x(!1),B(w.length>0?w[0]:null),z(null),K(!1)},className:"px-4",children:"Cancel"}),n.jsx(k5,{onClick:()=>{if(M&&M.length>t)return void m({title:"SMS is too long",description:"Please shorten your message"});if(null===M||0===M.length)return void m({title:"Oops",description:"Please enter a message"});A(M);const e=s();e&&h({groupId:e,params:{smsChannelSenderId:g,smsMessageBody:M,textMessageCompanyName:k,textMessageMedia:R?[R]:D?[]:void 0}},{onSuccess:()=>{x(!1),B(null),z(null),K(!1)},onError:()=>{m({title:"Error updating SMS",description:"Please contact your administrator"})}})},className:"px-4",disabled:p,children:"Save Changes"})]})]}),n.jsxs("div",{className:"flex justify-end mt-2 text-sm transition-colors duration-300 items-center gap-2 "+(M&&M.length>320?M.length>=t?"text-red-500":"text-amber-500":"text-gray-500"),children:[M?M.length:0,"/",t-(k?.length||0)," characters",M&&M.length>320&&n.jsx(pue,{title:"The best delivery rates are achieved when the message is 320 characters or less.",onClick:()=>{window.open("https://help.twilio.com/articles/360033806753-Maximum-Message-Length-with-Twilio-Programmable-Messaging","_blank")},link:{url:"https://help.twilio.com/articles/360033806753-Maximum-Message-Length-with-Twilio-Programmable-Messaging",text:"The maximum number of characters for an SMS is 1500. This includes the company name, if you have one, and the merge fields. The recommended limit is 320 characters for best delivery rates. Click to learn more"}})]})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(Eue,{className:"text-foreground",children:"From Number"}),n.jsxs(nme,{onValueChange:e=>{v(e)},value:g??void 0,children:[n.jsx(rme,{children:n.jsx(ime,{placeholder:"Select number",children:g?(H=g,O?.find((e=>e.channelSender.id===H))?.channelSender.channelSenderMetadata.friendlyName??O?.find((e=>e.channelSender.id===H))?.channelSender.channelSenderMetadata.from??H):"Select number"})}),n.jsx(lme,{children:O?.map((e=>n.jsx(ume,{value:e.channelSender.id,children:e.channelSender.channelSenderMetadata.friendlyName??e.channelSender.channelSenderMetadata.from??"Select number"},e.channelSender.id)))})]})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 py-1",children:[n.jsx(Eue,{className:"text-foreground",children:"Company Name"}),n.jsx(pue,{title:"Adding your company name can help customers identify who they are talking to"})]}),n.jsx(qae,{placeholder:"Enter company name",value:k??"",onChange:e=>{const a=e.target.value;a.length>100?m({title:"Oops",description:"Company name cannot exceed 100 characters",variant:"destructive"}):b(a??null)},disabled:!g&&!o})]})]}),n.jsxs("div",{className:"border rounded-lg p-4",children:[n.jsxs("div",{className:"flex justify-between items-center mb-4",children:[n.jsx("h3",{className:"font-medium",children:"Preview"}),n.jsx("div",{children:n.jsx(k5,{onClick:()=>x(!0),className:"text-sm px-3 py-1 rounded ",disabled:0===(O?.length??0)&&void 0===o,children:"Edit"})})]}),n.jsx("div",{children:o?g||o?n.jsx(n.Fragment,{children:S?n.jsx(qve,{body:Wve({companyName:k??void 0,smsBody:S}),imageUrls:w}):n.jsx(cme,{type:"sms"})}):n.jsx(hme,{type:"sms"}):n.jsx("div",{children:"Submit an application"})})]})]})]}):n.jsx("div",{children:n.jsx(v5,{text:["Loading..."]})});var H},$ve=()=>{const e=m5(),{getMergeFields:a,isGetting:t}=Ye(e?.id??void 0);return t||!a?n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(v5,{text:["Fetching Content..."]})}):n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[n.jsx(Ame,{title:"SMS Campaign",type:"sms"}),n.jsx(Zve,{mergeFieldsResponse:a})]})},Yve=e=>e.friendlyName||e.from||e.messageServiceSid||"Unknown Sender";function Qve(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}function Xve(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},efe(i,...a)]}function efe(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function afe(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function nfe(...e){return a=>{let n=!1;const t=e.map((e=>{const t=afe(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():afe(e[a],null)}}}}function tfe(...e){return r.useCallback(nfe(...e),e)}function ife(e){const a=rfe(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(sfe);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function rfe(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?nfe(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var ofe=Symbol("radix.slottable");function sfe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===ofe}var lfe=globalThis?.document?r.useLayoutEffect:()=>{},ufe=r[" useId ".trim().toString()]||(()=>{}),cfe=0;function dfe(e){const[a,n]=r.useState(ufe());return lfe((()=>{n((e=>e??String(cfe++)))}),[e]),e||(a?`radix-${a}`:"")}var mfe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=ife(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});var hfe=r[" useInsertionEffect ".trim().toString()]||lfe;function pfe({prop:e,defaultProp:a,onChange:n=()=>{},caller:t}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[n,t]=r.useState(e),i=r.useRef(n),o=r.useRef(a);return hfe((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==n&&(o.current?.(n),i.current=n)}),[n,i]),[n,t,o]}({defaultProp:a,onChange:n}),l=void 0!==e,u=l?e:i;{const a=r.useRef(void 0!==e);r.useEffect((()=>{const e=a.current;if(e!==l){}a.current=l}),[l,t])}const c=r.useCallback((a=>{if(l){const n=function(e){return"function"==typeof e}(a)?a(e):a;n!==e&&s.current?.(n)}else o(a)}),[l,e,o,s]);return[u,c]}var gfe=r.createContext(void 0);function vfe(e){const a=r.useContext(gfe);return e||a||"ltr"}var ffe="rovingFocusGroup.onEntryFocus",yfe={bubbles:!1,cancelable:!0},kfe="RovingFocusGroup",[bfe,Sfe,Afe]=function(e){const t=e+"CollectionProvider",[i,r]=Xve(t),[o,s]=i(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:t,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return n.jsx(o,{scope:t,itemMap:s,collectionRef:r,children:i})};l.displayName=t;const u=e+"CollectionSlot",c=ife(u),d=a.forwardRef(((e,a)=>{const{scope:t,children:i}=e,r=tfe(a,s(u,t).collectionRef);return n.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=ife(m),g=a.forwardRef(((e,t)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=tfe(t,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),n.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(n){const t=s(e+"CollectionConsumer",n);return a.useCallback((()=>{const e=t.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(t.itemMap.values()).sort(((e,n)=>a.indexOf(e.ref.current)-a.indexOf(n.ref.current)))}),[t.collectionRef,t.itemMap])},r]}(kfe),[wfe,Cfe]=Xve(kfe,[Afe]),[Mfe,Tfe]=wfe(kfe),Efe=r.forwardRef(((e,a)=>n.jsx(bfe.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(bfe.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(xfe,{...e,ref:a})})})));Efe.displayName=kfe;var xfe=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:t,orientation:i,loop:o=!1,dir:s,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:m=!1,...h}=e,p=r.useRef(null),g=tfe(a,p),v=vfe(s),[f,y]=pfe({prop:l,defaultProp:u??null,onChange:c,caller:kfe}),[k,b]=r.useState(!1),S=function(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}(d),A=Sfe(t),w=r.useRef(!1),[C,M]=r.useState(0);return r.useEffect((()=>{const e=p.current;if(e)return e.addEventListener(ffe,S),()=>e.removeEventListener(ffe,S)}),[S]),n.jsx(Mfe,{scope:t,orientation:i,dir:v,loop:o,currentTabStopId:f,onItemFocus:r.useCallback((e=>y(e)),[y]),onItemShiftTab:r.useCallback((()=>b(!0)),[]),onFocusableItemAdd:r.useCallback((()=>M((e=>e+1))),[]),onFocusableItemRemove:r.useCallback((()=>M((e=>e-1))),[]),children:n.jsx(mfe.div,{tabIndex:k||0===C?-1:0,"data-orientation":i,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:Qve(e.onMouseDown,(()=>{w.current=!0})),onFocus:Qve(e.onFocus,(e=>{if(e.target===e.currentTarget&&!w.current&&!k){const a=new CustomEvent(ffe,yfe);if(e.currentTarget.dispatchEvent(a),!a.defaultPrevented){const e=A().filter((e=>e.focusable));Lfe([e.find((e=>e.active)),e.find((e=>e.id===f)),...e].filter(Boolean).map((e=>e.ref.current)),m)}}w.current=!1})),onBlur:Qve(e.onBlur,(()=>b(!1)))})})})),Nfe="RovingFocusGroupItem",_fe=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:o=!1,tabStopId:s,children:l,...u}=e,c=dfe(),d=s||c,m=Tfe(Nfe,t),h=m.currentTabStopId===d,p=Sfe(t),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:f}=m;return r.useEffect((()=>{if(i)return g(),()=>v()}),[i,g,v]),n.jsx(bfe.ItemSlot,{scope:t,id:d,focusable:i,active:o,children:n.jsx(mfe.span,{tabIndex:h?0:-1,"data-orientation":m.orientation,...u,ref:a,onMouseDown:Qve(e.onMouseDown,(e=>{i?m.onItemFocus(d):e.preventDefault()})),onFocus:Qve(e.onFocus,(()=>m.onItemFocus(d))),onKeyDown:Qve(e.onKeyDown,(e=>{if("Tab"===e.key&&e.shiftKey)return void m.onItemShiftTab();if(e.target!==e.currentTarget)return;const a=function(e,a,n){const t=function(e,a){return"rtl"!==a?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,n);return"vertical"===a&&["ArrowLeft","ArrowRight"].includes(t)||"horizontal"===a&&["ArrowUp","ArrowDown"].includes(t)?void 0:Pfe[t]}(e,m.orientation,m.dir);if(void 0!==a){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=p().filter((e=>e.focusable)).map((e=>e.ref.current));if("last"===a)i.reverse();else if("prev"===a||"next"===a){"prev"===a&&i.reverse();const r=i.indexOf(e.currentTarget);i=m.loop?(t=r+1,(n=i).map(((e,a)=>n[(t+a)%n.length]))):i.slice(r+1)}setTimeout((()=>Lfe(i)))}var n,t})),children:"function"==typeof l?l({isCurrentTabStop:h,hasTabStop:null!=f}):l})})}));_fe.displayName=Nfe;var Pfe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Lfe(e,a=!1){const n=document.activeElement;for(const t of e){if(t===n)return;if(t.focus({preventScroll:a}),document.activeElement!==n)return}}var jfe=Efe,Bfe=_fe;var Rfe=e=>{const{present:a,children:n}=e,t=function(e){const[a,n]=r.useState(),t=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,n)=>a[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=zfe(t.current);o.current="mounted"===l?e:"none"}),[l]),lfe((()=>{const a=t.current,n=i.current;if(n!==e){const t=o.current,r=zfe(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(n&&t!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),lfe((()=>{if(a){let e;const n=a.ownerDocument.defaultView??window,r=r=>{const o=zfe(t.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const t=a.style.animationFillMode;a.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=t)}))}},s=e=>{e.target===a&&(o.current=zfe(t.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{n.clearTimeout(e),a.removeEventListener("animationstart",s),a.removeEventListener("animationcancel",r),a.removeEventListener("animationend",r)}}u("ANIMATION_END")}),[a,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{t.current=e?getComputedStyle(e):null,n(e)}),[])}}(a),i="function"==typeof n?n({present:t.isPresent}):r.Children.only(n),o=tfe(t.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||t.isPresent?r.cloneElement(i,{ref:o}):null};function zfe(e){return e?.animationName||"none"}Rfe.displayName="Presence";var Dfe="Tabs",[Kfe,Ofe]=Xve(Dfe,[Cfe]),Hfe=Cfe(),[Ife,Gfe]=Kfe(Dfe),Ffe=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,onValueChange:r,defaultValue:o,orientation:s="horizontal",dir:l,activationMode:u="automatic",...c}=e,d=vfe(l),[m,h]=pfe({prop:i,onChange:r,defaultProp:o??"",caller:Dfe});return n.jsx(Ife,{scope:t,baseId:dfe(),value:m,onValueChange:h,orientation:s,dir:d,activationMode:u,children:n.jsx(mfe.div,{dir:d,"data-orientation":s,...c,ref:a})})}));Ffe.displayName=Dfe;var Vfe="TabsList",Jfe=r.forwardRef(((e,a)=>{const{__scopeTabs:t,loop:i=!0,...r}=e,o=Gfe(Vfe,t),s=Hfe(t);return n.jsx(jfe,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:i,children:n.jsx(mfe.div,{role:"tablist","aria-orientation":o.orientation,...r,ref:a})})}));Jfe.displayName=Vfe;var Ufe="TabsTrigger",Wfe=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,disabled:r=!1,...o}=e,s=Gfe(Ufe,t),l=Hfe(t),u=$fe(s.baseId,i),c=Yfe(s.baseId,i),d=i===s.value;return n.jsx(Bfe,{asChild:!0,...l,focusable:!r,active:d,children:n.jsx(mfe.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:u,...o,ref:a,onMouseDown:Qve(e.onMouseDown,(e=>{r||0!==e.button||!1!==e.ctrlKey?e.preventDefault():s.onValueChange(i)})),onKeyDown:Qve(e.onKeyDown,(e=>{[" ","Enter"].includes(e.key)&&s.onValueChange(i)})),onFocus:Qve(e.onFocus,(()=>{d||r||!("manual"!==s.activationMode)||s.onValueChange(i)}))})})}));Wfe.displayName=Ufe;var qfe="TabsContent",Zfe=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,forceMount:o,children:s,...l}=e,u=Gfe(qfe,t),c=$fe(u.baseId,i),d=Yfe(u.baseId,i),m=i===u.value,h=r.useRef(m);return r.useEffect((()=>{const e=requestAnimationFrame((()=>h.current=!1));return()=>cancelAnimationFrame(e)}),[]),n.jsx(Rfe,{present:o||m,children:({present:t})=>n.jsx(mfe.div,{"data-state":m?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":c,hidden:!t,id:d,tabIndex:0,...l,ref:a,style:{...e.style,animationDuration:h.current?"0s":void 0},children:t&&s})})}));function $fe(e,a){return`${e}-trigger-${a}`}function Yfe(e,a){return`${e}-content-${a}`}Zfe.displayName=qfe;var Qfe=Jfe,Xfe=Wfe,eye=Zfe;const aye=Ffe,nye=r.forwardRef((({className:e,...a},t)=>n.jsx(Qfe,{ref:t,className:vm("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...a})));nye.displayName=Qfe.displayName;const tye=r.forwardRef((({className:e,...a},t)=>n.jsx(Xfe,{ref:t,className:vm("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...a})));tye.displayName=Xfe.displayName;const iye=r.forwardRef((({className:e,...a},t)=>n.jsx(eye,{ref:t,className:vm("ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a})));iye.displayName=eye.displayName;const rye=({onOpenChange:e})=>n.jsx("div",{role:"button",tabIndex:0,"aria-label":"Close dialog",onClick:()=>e(!1),onKeyDown:a=>{"Enter"!==a.key&&" "!==a.key||e(!1)},className:"absolute top-3 right-3 z-20 rounded-full p-2 bg-white/80 shadow-lg border border-gray-200 hover:bg-primary/90 hover:text-white active:bg-primary/95 transition-all duration-200 focus:outline-none focus:ring-4 focus:ring-primary/30 focus:ring-offset-2 group cursor-pointer",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)"},children:n.jsx(w5.CloseButton,{className:"w-5 h-5 text-primary group-hover:text-primary-foreground group-active:text-primary-foreground transition-colors duration-200"})}),oye=({selectedChannels:e,setSelectedChannels:a,hasEmailChannelSenders:t,hasSmsChannelSenders:i,automationType:r})=>{const{toast:o}=Ge(),s=[...t?[{label:"Email",value:"email",icon:w5.EmailIcon,checked:e.includes("email")}]:[],...i?[{label:"SMS",value:"sms",icon:w5.SmsIcon,checked:e.includes("sms")}]:[]];return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-xl font-medium text-foreground",children:"Message Types"}),n.jsxs("p",{className:"text-muted-foreground mb-2 text-sm",children:["Select the channels you want to use in this"," ",r===sa.ONE_TIME?_h("engage:broadcast").toLowerCase():_h("engage:automation").toLowerCase()]})]}),n.jsx("div",{className:"w-full grid grid-cols-2 gap-3",children:s.map((t=>n.jsxs(jpe,{checked:t.checked,onCheckedChange:()=>{"email"===t.value?e.includes("email")?e.includes("sms")?a(["sms"]):o({title:"Cant Remove Email",description:`At least one channel is required for an ${r===sa.ONE_TIME?_h("engage:broadcast").toLowerCase():_h("engage:automation").toLowerCase()}`,variant:"destructive"}):a([...e,"email"]):e.includes("sms")?e.includes("email")?a(["email"]):o({title:"Cant Remove SMS",description:`At least one channel is required for an ${r===sa.ONE_TIME?_h("engage:broadcast").toLowerCase():_h("engage:automation").toLowerCase()}`,variant:"destructive"}):a([...e,"sms"])},className:"relative ring-[1px] ring-border rounded-lg px-4 py-3 text-start text-muted-foreground data-[state=checked]:ring-2 data-[state=checked]:ring-primary data-[state=checked]:font-medium",children:[n.jsx(t.icon,{className:"mb-3",size:20}),n.jsx("span",{className:"font-medium tracking-tight",children:t.label}),n.jsx(Bpe,{className:"absolute top-2 right-2",children:n.jsx(Kc,{className:"fill-primary text-primary-foreground"})})]},t.value)))})]})},sye=({getExtraMergeFields:e})=>{const[t,i]=a.useState(null),r=a.useRef(null),{toast:o}=Ge(),s=m5(),{channelSenders:l}=fre(),{channelAccounts:u}=pre(),{updateCommunicationGroup:c}=$e(),d=d5(),{data:m}=Sre(),{setSelectedSubStepType:h}=a.useContext(Q4),{getMergeFields:p,isGetting:g}=Ye(s?.id??void 0),[v,f]=a.useState(void 0);a.useEffect((()=>{const e=s?.id;e&&t&&(t.includes("email")||null===s?.emailChannelSenderId||c({groupId:e,params:{emailChannelSenderId:null}}),t.includes("sms")||null===s?.smsChannelSenderId||c({groupId:e,params:{smsChannelSenderId:null}}),1===t.length&&("email"===t[0]&&h(Sme.EMAIL),"sms"===t[0]&&h(Sme.SMS)))}),[t,c,s,m,h]),a.useEffect((()=>{const e=s?.id;e||0!==t?.length||i(["email"])}),[d,s,t]);const y=a.useCallback((e=>{const a=[];e.emailChannelSenderId&&a.push("email"),e.smsChannelSenderId&&a.push("sms"),0===a.length&&a.push("email"),i(a)}),[]);a.useEffect((()=>{s&&!t&&y(s)}),[s,y,t]),a.useEffect((()=>{g||void 0===v&&(e?e().then((e=>{s?.id&&(y(s),c({groupId:s?.id,params:{extraMergeFields:e}},{onSuccess:async()=>{try{const e=await Ve(s?.id);f(e)}catch{o({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}},onError:e=>{o({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}}))})):f(p))}),[e,c,s,o,g,p,v,y]);const k=a.useMemo((()=>wme({channelSenders:l?.results??[],channelAccounts:u?.results??[]})),[l?.results,u?.results]),b=a.useMemo((()=>ale({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:m})),[l?.results,u?.results,m]);if(!t||g||!v||!k||!b)return n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(v5,{text:["Fetching Content..."]})});const S=k.length>0,A=b.length>0;return n.jsxs("div",{className:"flex flex-col gap-4 flex-shrink-0",children:[n.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(oye,{automationType:d?.triggerMetadata?.triggerType,selectedChannels:t,setSelectedChannels:i,hasEmailChannelSenders:S,hasSmsChannelSenders:A})}),t.includes("email")&&n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",ref:r,children:[n.jsx(Ame,{title:"Email Campaign",type:"email"}),n.jsx(yme,{mergeFieldsResponse:v,emailChannelSendersWithChannelAccounts:k})]}),t.includes("sms")&&n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[n.jsx(Ame,{title:"SMS Campaign",type:"sms"}),n.jsx(Zve,{mergeFieldsResponse:v})]})]})},lye=({open:e,onOpenChange:a})=>n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"max-w-[75vw] min-h-[75vh] overflow-y-auto max-h-[90vh] po",hideCloseButton:!0,children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Edit Campaign Content"}),n.jsx(H$,{children:"Edit the content of the campaign"})]}),n.jsx(rye,{onOpenChange:a}),n.jsx(sye,{})]})}),uye=()=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"}),n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"}),n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"})]}),cye=({children:e,actionButtons:a})=>n.jsxs("div",{className:"flex-1 w-full relative overflow-hidden max-w-screen-lg mx-auto",children:[n.jsxs("div",{className:"h-full relative w-full rounded-2xl bg-white border border-zinc-200 overflow-hidden min-h-[500px] flex flex-col",style:{containerType:"inline-size"},children:[n.jsxs("div",{className:"flex items-center space-x-3 pt-3 px-4 z-10 w-full justify-between",children:[n.jsx(uye,{}),a&&n.jsx("div",{className:"flex items-center space-x-2",children:a})]}),e]}),n.jsx("div",{className:"text-center text-sm text-muted-foreground mt-4",children:n.jsx("p",{children:"These previews show exactly how your messages will appear to your customers"})})]}),dye=()=>{const e=d5(),t=m5(),{channelSenders:i}=fre(),{channelAccounts:r}=pre(),o=a.useMemo((()=>i?.results?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=r?.results?.find((a=>a.id===e.channelAccountId));return a&&a.channelAccountMetadata.type===gre.REACH_MANAGED?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,channelSenderMetadata:e.channelSenderMetadata}]:[]}))||[]),[i?.results,r?.results]),s=t?.emailChannelSenderId;if(!(e&&t&&o&&s))return null;const l=o.find((e=>e.channelSenderId===s)),u=l?.fullDomain,c=l?.channelSenderMetadata.emailReplyTo,d=t.emailSubject,m=t.emailPreviewText,h=l?.channelSenderMetadata.emailFromName;return n.jsxs("div",{className:"space-y-1 overflow-hidden",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"From"}),n.jsxs("div",{className:"text-base font-medium",children:[u,h&&n.jsxs("span",{className:"text-muted-foreground",children:["<",h,">"]})]})]}),c&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Reply-To"}),n.jsx("div",{className:"text-base font-medium",children:c})]}),d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Subject"}),n.jsx("div",{className:"text-base font-medium",children:d})]}),m&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Preview Text"}),n.jsx("div",{className:"text-sm font-medium line-clamp-2",children:m})]})]})},mye=({emailBody:e})=>{const[t,i]=a.useState({width:0,height:0}),r=a.useRef(null);return a.useEffect((()=>{const e=()=>{r.current&&requestAnimationFrame((()=>{i({width:r.current?r.current.offsetWidth-75:0,height:r.current?r.current.offsetHeight-75:0})}))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[r]),n.jsxs(cye,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(dye,{})})}),n.jsx("div",{className:"rounded-lg p-6 bg-white flex-1 min-h-0 flex items-center justify-center",ref:r,children:n.jsx(dme,{html:e,height:t.height,width:t.width})})]})},hye=({expandDialogContent:e})=>{const[t,i]=a.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(L$,{open:t,onOpenChange:i,children:n.jsxs(z$,{hideCloseButton:!0,className:"w-[80vw] h-[80vh] max-h-none bg-transparent border-none max-w-screen-lg ",children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Expanded Preview"}),n.jsx(H$,{children:"Expanded view of communication content"})]}),n.jsxs("div",{className:"h-full flex flex-col overflow-hidden rounded-xl",children:[n.jsx(rye,{onOpenChange:i}),e]})]})}),n.jsx(k5,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 flex items-center gap-2 shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>i(!0),children:n.jsx(w5.ExpandIcon,{className:"w-4 h-4 text-muted-foreground"})})]})},pye=({type:e,disablePreviewSubtext:a=!1})=>{const t="sms"===e?"SMS":"Email";return n.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center",children:n.jsxs("div",{className:"flex flex-col items-center justify-center bg-zinc-50/80 border border-zinc-100 rounded-2xl shadow-md px-6 py-12 max-w-[90vw] w-full sm:max-w-md mx-auto text-center",style:{containerType:"inline-size"},children:[n.jsx("sms"===e?w5.SmsIcon:w5.EmailIcon,{className:"w-12 h-12 text-zinc-500 mb-4"}),n.jsxs("h2",{className:"text-xl font-semibold text-zinc-800 mb-2",children:["No ",t," Content Yet"]}),!a&&n.jsxs("p",{className:"text-zinc-500 text-base mb-1",children:["Click"," ",n.jsx("span",{className:"font-medium text-zinc-700",children:"Edit content"})," to start crafting your ",t," message."]})]})})},gye=a.forwardRef((({onClick:e},a)=>n.jsxs(k5,{ref:a,variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 flex items-center gap-2 shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:e,children:[n.jsx(w5.PreviewButton,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium text-sm",children:"Test"})]})));gye.displayName="PreviewButton";const vye=e=>/^[^\s@.]+(?:\.[^\s@.]+)*@[^\s@.]+(?:\.[^\s@.]+)+$/.test(e),fye=e=>{if(!/^[0-9\s()+.-]+$/.test(e))return!1;const a=e.replace(/\D/g,"");return e.startsWith("+")?a.length>=10&&a.length<=15:10===a.length||!(11!==a.length||!a.startsWith("1"))},yye=e=>{const a=e.replace(/\D/g,"");if(10===a.length)return`(${a.slice(0,3)}) ${a.slice(3,6)}-${a.slice(6)}`;if(11===a.length&&a.startsWith("1"))return`+1 (${a.slice(1,4)}) ${a.slice(4,7)}-${a.slice(7)}`;if(a.length>0){const n=e.startsWith("+")?"+":"",t=a.slice((e.startsWith("+"),0));return`${n}${t.match(/.{1,4}/g)?.join("-")||t}`}return e},kye=({automation:e,type:t,setOpenSendPreviewPopup:i,open:r})=>{const[o,s]=a.useState(""),[l,u]=a.useState(""),[c,d]=a.useState(null),[m,h]=a.useState(!1),[p,g]=a.useState(""),[v,f]=a.useState(!1),{sendTestCommunication:y,sendError:k,isSendSuccess:b}=Qe(),{toast:S}=Ge(),A=e.actionData?.find((e=>"send_communication"===e.actionType)),w=A?.actionMetadata.communicationGroupId,{communicationGroup:C,isGetting:M}=Ze(w??void 0),{data:T}=i5({includeSegments:e.includeSegmentIds,excludeSegments:e.excludeSegmentIds,automationId:e.id}),E=a.useRef(null),x=a.useMemo((()=>[...T?.recipients??[]].filter((e=>!(!e.firstName||!e.lastName)&&(!("email"===t&&!e.email)&&!("sms"===t&&!e.phone))))),[T?.recipients,t]),N=a.useCallback((()=>{if(!w)return Promise.resolve(null);if(!C)return Promise.reject(new Error("Communication group not loaded"));switch(t){case"email":return Promise.resolve(C.emailChannelSenderId);case"sms":return Promise.resolve(C.smsChannelSenderId);default:return Promise.reject(new Error(`Unsupported type: ${t}`))}}),[C,t,w]);a.useEffect((()=>{(async()=>{try{const e=await N();d(e)}catch(e){d(null)}finally{h(!0)}})()}),[N]),a.useEffect((()=>{b&&(S({title:"Success",description:`Preview ${"email"===t?"email":"SMS"} sent successfully!`}),i(!1))}),[b,t,i,S]),a.useEffect((()=>{k&&(S({title:"Error",description:`Failed to send preview: ${k.message}`,variant:"destructive"}),i(!1))}),[k,S,i]),a.useEffect((()=>{r&&(s(""),u(""),g(""),f(!1))}),[r]),a.useEffect((()=>{!r&&v&&setTimeout((()=>{document.body.style.pointerEvents=""}),0)}),[r,v]);return m&&!M&&T?c?n.jsxs("div",{className:"",ref:E,children:[n.jsxs("h3",{className:"text-xl font-semibold text-gray-900 mb-4",children:["Send Test ","email"===t?"Email":"Text"]}),n.jsx(qae,{type:"email"===t?"email":"tel",placeholder:"email"===t?"Enter email address":"Enter phone number",value:o,onChange:e=>{s(e.target.value),u("")},className:"w-full px-3 py-3 border border-gray-300 rounded-lg text-base \n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\n placeholder-gray-400"}),n.jsxs("p",{className:"text-sm text-muted-foreground mt-1.5",children:["Enter a valid ","email"===t?"email address":"phone number"," to send a test to that recipient."]}),n.jsx("div",{className:"my-4 border-t border-gray-200"}),n.jsxs("div",{className:"mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(nme,{value:p,onValueChange:e=>{g(e)},onOpenChange:e=>{f(e),!e&&E.current&&E.current.focus()},children:[n.jsx(rme,{className:"w-full bg-white border border-gray-300 rounded-lg text-base\n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:n.jsx(ime,{children:p?T?.recipients.find((e=>e.id===p))?.firstName+" "+T?.recipients.find((e=>e.id===p))?.lastName:"Preview as"})}),n.jsx(lme,{position:"popper",className:"z-[100]",children:n.jsx(tme,{children:x.map((e=>n.jsx(ume,{value:e.id,className:"cursor-pointer hover:bg-gray-50",children:n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("span",{className:"font-medium",children:[e.firstName," ",e.lastName]}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:[e.email&&`Email: ${e.email}`,e.email&&e.phone&&" • ",e.phone&&`Phone: ${e.phone}`]})]})},`${e.firstName}-${e.lastName}`)))})})]}),p&&n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>g(""),className:"h-10 w-10 rounded-lg hover:bg-gray-100",title:"Clear selection",children:n.jsx(w5.CloseButton,{className:"h-4 w-4 text-gray-500"})})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1.5",children:"Optional: Test as a specific recipient to see how the message will appear with their data. If not selected, raw merge tags will be used."})]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"my-4 border-t border-gray-200"}),n.jsx("p",{className:"text-red-500 text-sm mb-4 -mt-2",children:l})]}),n.jsx(k5,{onClick:()=>{if(!("email"===t?vye(o):fye(o)))return void u("Please enter a valid "+("email"===t?"email address":"phone number"));if(!c)return void u("No sender found, please update the automation first!");const a=e.actionData?.find((e=>"send_communication"===e.actionType)),n=a?.actionMetadata.communicationGroupId;if(!n)return Promise.resolve(null);y({id:n,params:"email"===t?{emailAddress:o,previewAsRecipientId:p}:{phoneNumber:o,previewAsRecipientId:p}})},disabled:!o,className:"w-full disabled:cursor-not-allowed",children:"Send Test"})]}):n.jsx("div",{className:"flex justify-center items-center h-full",children:n.jsxs("div",{className:"text-center flex flex-col justify-center items-center gap-2",children:[n.jsx(w5.AlertCircleIcon,{className:"h-12 w-12 text-gray-400 mb-4"}),n.jsx("h3",{className:"text-lg font-semibold text-gray-700 mb-2",children:"No sender found"}),n.jsx("p",{className:"text-gray-500",children:"Please update the automation to include a sender for this type"})]})}):n.jsx("div",{className:"flex justify-center items-center h-full",children:n.jsx(v5,{text:["Fetching sender data","Fetching recipients"]})})},bye=({open:e,onOpenChange:a,automation:t})=>n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Send Preview Email"}),n.jsx(H$,{children:"Send a preview email to the automation."})]}),n.jsx(kye,{automation:t,type:"email",setOpenSendPreviewPopup:a,open:e})]})}),Sye=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1})=>{const r=d5(),o=m5(),{channelSenders:s}=fre(),{channelAccounts:l}=pre(),[u,c]=a.useState({width:0,height:0}),[d,m]=a.useState(!1),[h,p]=a.useState(!1),g=a.useRef(null);if(a.useEffect((()=>{const e=()=>{g.current&&requestAnimationFrame((()=>{c({width:g.current?g.current.offsetWidth-75:0,height:g.current?g.current.offsetHeight-75:0})}))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[g]),!r||!o||void 0===s||void 0===l)return null;const v=o?.emailHtmlBody||"",f=o?.emailChannelSenderId&&v.length>0,y=wme({channelSenders:s?.results??[],channelAccounts:l?.results??[]});let k=null;return o?.emailChannelSenderId||(k="Please first select an email sender"),o?.emailSubject||(k="Please first ensure you have an email subject"),o?.emailHtmlBody||(k="Please first ensure you have an email content"),n.jsxs("div",{className:"flex-1 flex flex-col items-center w-full",children:[n.jsx(lye,{open:h,onOpenChange:p}),y.length>0&&n.jsx(bye,{open:d,onOpenChange:m,automation:r}),n.jsx(cye,{actionButtons:n.jsx(n.Fragment,{children:n.jsxs("div",{className:"flex items-center space-x-2",children:[!e&&f&&(k?n.jsx(pue,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!0,children:n.jsx(gye,{onClick:()=>m(!0)})}):n.jsx(gye,{onClick:()=>m(!0)})),!t&&r.status===da.DRAFT&&n.jsx(k5,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 font-medium text-sm shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>p(!0),children:"Edit content"}),f&&n.jsx(hye,{expandDialogContent:n.jsx(mye,{emailBody:v})})]})}),children:f?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(dye,{})})}),n.jsx("div",{className:"w-full h-[1.5px] bg-zinc-200 my-2"}),n.jsx("div",{className:"flex-1 w-full overflow-auto h-full min-h-[500px]",ref:g,children:n.jsx(dme,{html:v,height:u.height,width:u.width})})]}):n.jsx(pye,{type:"email",disablePreviewSubtext:i})})]})},Aye=()=>{const e=d5(),t=m5(),{channelSenders:i}=fre(),{channelAccounts:r}=pre(),{data:o}=Sre(),s=a.useMemo((()=>ale({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o})),[i?.results,r?.results,o]),l=s?.find((e=>e.channelSender.id===t?.smsChannelSenderId));if(!l&&!o)return null;if(!(e&&t&&i&&r&&s&&(void 0!==o||l)))return null;const u=l?.channelSender.channelSenderMetadata.from&&null!==l.channelSender.channelSenderMetadata.from?l.channelSender.channelSenderMetadata.from:null,c=l?.channelSender.channelSenderMetadata.friendlyName??(u&&null!==u?yye(u??""):l?.channelSender.channelSenderMetadata.messageServiceSid);return n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"From"}),n.jsx("div",{className:"text-base font-medium font-mono text-zinc-800",children:c})]})})},wye=({smsBody:e,imageUrls:a})=>n.jsxs(cye,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(Aye,{})})}),n.jsx("div",{className:"rounded-lg p-6 bg-white flex-1 min-h-0 flex items-center justify-center",children:n.jsx(qve,{body:e,imageUrls:a})})]}),Cye=({open:e,onOpenChange:a,automation:t})=>n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Send Preview SMS"}),n.jsx(H$,{children:"Send a preview SMS to the automation."})]}),n.jsx(kye,{automation:t,type:"sms",setOpenSendPreviewPopup:a,open:e})]})}),Mye=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1,setupRequired:r=!1})=>{const[o,s]=a.useState(!1),{channelSenders:l}=fre(),{channelAccounts:u}=pre(),c=d5(),d=m5(),[m,h]=a.useState(!1),{data:p}=Sre(),[g,v]=a.useState(r),f=ale({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:p}),y=f.find((e=>e.channelSender.id===d?.smsChannelSenderId));if(a.useEffect((()=>{y&&y.smsApplication&&y.smsApplication.status===ele.PENDING&&v(!1)}),[d?.smsChannelSenderId,p,f,y]),!c||void 0===l)return null;const k=d?.smsMessageBody||"",b=!y?.smsApplication||y.smsApplication.status===ele.APPROVED,S=(p||d?.smsChannelSenderId)&&k.length>0,A=Wve({companyName:d?.textMessageCompanyName??void 0,smsBody:k}),w=d?.textMessageMediaUrls??[];let C=null;return d?.smsChannelSenderId||(C="Please first select a sms sender"),d?.smsMessageBody||(C="Please first ensure you have a sms content"),n.jsx(eY,{children:g?n.jsx("div",{className:"w-full pt-8 mx-auto",children:n.jsx(gpe,{})}):n.jsxs(K4.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3,ease:[.16,1,.3,1]},className:"flex flex-col items-center w-full h-full",children:[n.jsx(lye,{open:m,onOpenChange:h}),n.jsx(Cye,{open:o,onOpenChange:s,automation:c}),n.jsx(cye,{actionButtons:n.jsxs(n.Fragment,{children:[!e&&b&&(C?n.jsx(pue,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!1,children:n.jsx("div",{className:"inline-block",children:n.jsx(gye,{onClick:()=>s(!0)})})}):n.jsx(gye,{onClick:()=>s(!0)})),c.status===da.DRAFT&&!t&&n.jsx(k5,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 font-medium text-sm shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>h(!0),children:"Edit content"}),S&&n.jsx(hye,{expandDialogContent:n.jsx(wye,{smsBody:A,imageUrls:w})})]}),children:S?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(Aye,{})})}),n.jsx("div",{className:"w-full h-[1.5px] bg-zinc-200 my-2"}),n.jsx("div",{className:"flex-1 w-full overflow-auto h-full flex items-center justify-center",children:n.jsx(qve,{body:A,imageUrls:w})})]}):n.jsx(pye,{type:"sms",disablePreviewSubtext:i})})]})})},Tye=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1})=>{const[r,o]=a.useState(null),s=m5(),{channelAccounts:l}=pre(),{state:{hideSms:u}}=a.useContext(uq),{channelSenders:c}=fre(),{data:d}=Sre(),m=a.useMemo((()=>ale({channelSenders:c?.results??[],channelAccounts:l?.results??[],smsApplication:d})),[c?.results,l?.results,d]);if(a.useEffect((()=>{r||o(s?.emailChannelSenderId?"email":"sms")}),[s?.emailChannelSenderId,r]),!s||!c||!r)return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx(v5,{text:["Loading..."]})});const h=!s?.smsChannelSenderId||u,p=!s?.emailChannelSenderId,g=0===m.length&&!d;return n.jsxs(aye,{defaultValue:"email",value:r,onValueChange:e=>o("email"===e?"email":"sms"),className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md pb-4",children:[n.jsx("div",{className:"max-w-[640px] mx-auto w-full",children:n.jsxs(nye,{className:"grid w-full "+(h||p?"grid-cols-1":"grid-cols-2"),children:[!p&&n.jsx(tye,{value:"email",className:"group data-[state=active]:bg-white",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx(w5.EmailIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),n.jsx(w5.EmailIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),n.jsx("span",{children:"Email"})]})}),!h&&n.jsx(tye,{value:"sms",className:"group data-[state=active]:bg-white",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(w5.SmsIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),n.jsx(w5.SmsIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),n.jsx("span",{children:"SMS"}),g&&n.jsx(pue,{title:"To enable SMS, please complete your business information and request approval from Twilio"})]})})]})}),n.jsx(iye,{value:"email",children:n.jsx(Sye,{disablePreview:e,disableEditContent:t,disablePreviewSubtext:i})}),n.jsx(iye,{value:"sms",children:n.jsx(Mye,{disablePreview:e,disableEditContent:t,disablePreviewSubtext:i,setupRequired:g})})]})},Eye="reach-styles-module__h2___J-48W",xye="reach-styles-module__h3___QiFj-",Nye="reach-styles-module__minorText___1TEN6",_ye=({children:e,className:a})=>n.jsx("h2",{className:vm(Eye,a),children:e}),Pye=({children:e,className:a})=>n.jsx("h3",{className:vm(xye,a),children:e}),Lye=({children:e,className:a})=>n.jsx("p",{className:vm(Nye,a),children:e}),jye=({title:e,children:a,headerActions:t})=>n.jsxs("div",{className:"max-w-[1000px] mx-auto w-full flex-1 flex flex-col gap-4 pt-4",children:[n.jsxs("div",{className:"px-4 flex",children:[n.jsx(_ye,{className:"text-primary",children:e}),t&&n.jsx("div",{className:"ml-auto",children:t})]}),a]}),Bye=()=>n.jsx(jye,{title:"Preview & Schedule",children:n.jsx(Tye,{disablePreview:!0,disableEditContent:!0,disablePreviewSubtext:!0})}),Rye=()=>{const e=d5(),t=m5(),{channelSenders:i}=fre(),{channelAccounts:r}=pre(),{data:o}=Sre(),[s,l]=a.useState(null),[u,c]=a.useState(null),[d,m]=a.useState(null),[h,p]=a.useState(null);return a.useEffect((()=>{i&&m(i),r&&p(r)}),[i,r]),a.useEffect((()=>{if(t&&d&&h){const e=t.emailChannelSenderId,a=t.smsChannelSenderId,n=d.results.find((a=>a.id===e)),i=d.results.find((e=>e.id===a));if(n&&t.emailSubject&&t.emailHtmlBody){const e=n.channelSenderMetadata?.userPart,a=h.results.find((e=>e.id===n.channelAccountId));if(a)switch(a.channelAccountMetadata.type){case gre.REACH_MANAGED:l({fromEmail:`${e}@${a.channelAccountMetadata.baseDomain}.embedreach.com`,fromName:n.channelSenderMetadata?.emailFromName,subject:t.emailSubject,previewText:t.emailPreviewText,body:t.emailHtmlBody});break;case gre.TWILLIO:break;default:throw ire(a.channelAccountMetadata.type,gre)}}(o||i)&&t.smsMessageBody&&c({fromPhone:i?Yve(i.channelSenderMetadata):"",body:t.smsMessageBody,companyName:t.textMessageCompanyName})}}),[t,d,h,o]),e?n.jsx("div",s||u?{className:"w-full",children:n.jsx("div",{className:"flex flex-col gap-4 w-full",children:n.jsx(Bye,{})})}:{className:"flex justify-center items-center h-full",children:n.jsx("div",{children:"No preview data Please complete previous steps"})}):n.jsx(v5,{text:["Loading..."]})};function zye(e){return(zye="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Dye(e){if(null===e||!0===e||!1===e)return NaN;var a=Number(e);return isNaN(a)?a:a<0?Math.ceil(a):Math.floor(a)}function Kye(e,a){if(a.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+a.length+" present")}function Oye(e){Kye(1,arguments);var a=Object.prototype.toString.call(e);return e instanceof Date||"object"===zye(e)&&"[object Date]"===a?new Date(e.getTime()):"number"==typeof e||"[object Number]"===a?new Date(e):new Date(NaN)}function Hye(e,a){Kye(2,arguments);var n=Oye(e),t=Dye(a);return isNaN(t)?new Date(NaN):t?(n.setDate(n.getDate()+t),n):n}function Iye(e,a){Kye(2,arguments);var n=Oye(e),t=Dye(a);if(isNaN(t))return new Date(NaN);if(!t)return n;var i=n.getDate(),r=new Date(n.getTime());return r.setMonth(n.getMonth()+t+1,0),i>=r.getDate()?r:(n.setFullYear(r.getFullYear(),r.getMonth(),i),n)}var Gye={};function Fye(){return Gye}function Vye(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Oye(e),h=m.getDay(),p=(h<d?7:0)+h-d;return m.setDate(m.getDate()-p),m.setHours(0,0,0,0),m}function Jye(e){return Kye(1,arguments),Vye(e,{weekStartsOn:1})}function Uye(e){Kye(1,arguments);var a=function(e){Kye(1,arguments);var a=Oye(e),n=a.getFullYear(),t=new Date(0);t.setFullYear(n+1,0,4),t.setHours(0,0,0,0);var i=Jye(t),r=new Date(0);r.setFullYear(n,0,4),r.setHours(0,0,0,0);var o=Jye(r);return a.getTime()>=i.getTime()?n+1:a.getTime()>=o.getTime()?n:n-1}(e),n=new Date(0);return n.setFullYear(a,0,4),n.setHours(0,0,0,0),Jye(n)}function Wye(e){var a=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return a.setUTCFullYear(e.getFullYear()),e.getTime()-a.getTime()}function qye(e){Kye(1,arguments);var a=Oye(e);return a.setHours(0,0,0,0),a}function Zye(e,a){Kye(2,arguments);var n=qye(e),t=qye(a),i=n.getTime()-Wye(n),r=t.getTime()-Wye(t);return Math.round((i-r)/864e5)}function $ye(e,a){return Kye(2,arguments),Hye(e,7*Dye(a))}function Yye(e,a){return Kye(2,arguments),Iye(e,12*Dye(a))}function Qye(e,a){Kye(2,arguments);var n=qye(e),t=qye(a);return n.getTime()===t.getTime()}function Xye(e){return Kye(1,arguments),e instanceof Date||"object"===zye(e)&&"[object Date]"===Object.prototype.toString.call(e)}function eke(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return 12*(n.getFullYear()-t.getFullYear())+(n.getMonth()-t.getMonth())}function ake(e){Kye(1,arguments);var a=Oye(e),n=a.getMonth();return a.setFullYear(a.getFullYear(),n+1,0),a.setHours(23,59,59,999),a}function nke(e){Kye(1,arguments);var a=Oye(e);return a.setDate(1),a.setHours(0,0,0,0),a}function tke(e){Kye(1,arguments);var a=Oye(e),n=new Date(0);return n.setFullYear(a.getFullYear(),0,1),n.setHours(0,0,0,0),n}function ike(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Oye(e),h=m.getDay(),p=6+(h<d?-7:0)-(h-d);return m.setDate(m.getDate()+p),m.setHours(23,59,59,999),m}function rke(e){return Kye(1,arguments),ike(e,{weekStartsOn:1})}function oke(e,a){return Kye(2,arguments),function(e,a){Kye(2,arguments);var n=Oye(e).getTime(),t=Dye(a);return new Date(n+t)}(e,-Dye(a))}function ske(e){Kye(1,arguments);var a=Oye(e),n=a.getUTCDay(),t=(n<1?7:0)+n-1;return a.setUTCDate(a.getUTCDate()-t),a.setUTCHours(0,0,0,0),a}function lke(e){Kye(1,arguments);var a=Oye(e),n=a.getUTCFullYear(),t=new Date(0);t.setUTCFullYear(n+1,0,4),t.setUTCHours(0,0,0,0);var i=ske(t),r=new Date(0);r.setUTCFullYear(n,0,4),r.setUTCHours(0,0,0,0);var o=ske(r);return a.getTime()>=i.getTime()?n+1:a.getTime()>=o.getTime()?n:n-1}function uke(e){Kye(1,arguments);var a=Oye(e),n=ske(a).getTime()-function(e){Kye(1,arguments);var a=lke(e),n=new Date(0);return n.setUTCFullYear(a,0,4),n.setUTCHours(0,0,0,0),ske(n)}(a).getTime();return Math.round(n/6048e5)+1}function cke(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Oye(e),h=m.getUTCDay(),p=(h<d?7:0)+h-d;return m.setUTCDate(m.getUTCDate()-p),m.setUTCHours(0,0,0,0),m}function dke(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Oye(e),d=c.getUTCFullYear(),m=Fye(),h=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:m.firstWeekContainsDate)&&void 0!==t?t:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setUTCFullYear(d+1,0,h),p.setUTCHours(0,0,0,0);var g=cke(p,a),v=new Date(0);v.setUTCFullYear(d,0,h),v.setUTCHours(0,0,0,0);var f=cke(v,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=f.getTime()?d:d-1}function mke(e,a){Kye(1,arguments);var n=Oye(e),t=cke(n,a).getTime()-function(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:c.firstWeekContainsDate)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1),m=dke(e,a),h=new Date(0);return h.setUTCFullYear(m,0,d),h.setUTCHours(0,0,0,0),cke(h,a)}(n,a).getTime();return Math.round(t/6048e5)+1}function hke(e,a){for(var n=e<0?"-":"",t=Math.abs(e).toString();t.length<a;)t="0"+t;return n+t}var pke=function(e,a){var n=e.getUTCFullYear(),t=n>0?n:1-n;return hke("yy"===a?t%100:t,a.length)},gke=function(e,a){var n=e.getUTCMonth();return"M"===a?String(n+1):hke(n+1,2)},vke=function(e,a){return hke(e.getUTCDate(),a.length)},fke=function(e,a){return hke(e.getUTCHours()%12||12,a.length)},yke=function(e,a){return hke(e.getUTCHours(),a.length)},kke=function(e,a){return hke(e.getUTCMinutes(),a.length)},bke=function(e,a){return hke(e.getUTCSeconds(),a.length)},Ske=function(e,a){var n=a.length,t=e.getUTCMilliseconds();return hke(Math.floor(t*Math.pow(10,n-3)),a.length)},Ake="midnight",wke="noon",Cke="morning",Mke="afternoon",Tke="evening",Eke="night",xke={G:function(e,a,n){var t=e.getUTCFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return n.era(t,{width:"abbreviated"});case"GGGGG":return n.era(t,{width:"narrow"});default:return n.era(t,{width:"wide"})}},y:function(e,a,n){if("yo"===a){var t=e.getUTCFullYear();return n.ordinalNumber(t>0?t:1-t,{unit:"year"})}return pke(e,a)},Y:function(e,a,n,t){var i=dke(e,t),r=i>0?i:1-i;return"YY"===a?hke(r%100,2):"Yo"===a?n.ordinalNumber(r,{unit:"year"}):hke(r,a.length)},R:function(e,a){return hke(lke(e),a.length)},u:function(e,a){return hke(e.getUTCFullYear(),a.length)},Q:function(e,a,n){var t=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"Q":return String(t);case"QQ":return hke(t,2);case"Qo":return n.ordinalNumber(t,{unit:"quarter"});case"QQQ":return n.quarter(t,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(t,{width:"narrow",context:"formatting"});default:return n.quarter(t,{width:"wide",context:"formatting"})}},q:function(e,a,n){var t=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"q":return String(t);case"qq":return hke(t,2);case"qo":return n.ordinalNumber(t,{unit:"quarter"});case"qqq":return n.quarter(t,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(t,{width:"narrow",context:"standalone"});default:return n.quarter(t,{width:"wide",context:"standalone"})}},M:function(e,a,n){var t=e.getUTCMonth();switch(a){case"M":case"MM":return gke(e,a);case"Mo":return n.ordinalNumber(t+1,{unit:"month"});case"MMM":return n.month(t,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(t,{width:"narrow",context:"formatting"});default:return n.month(t,{width:"wide",context:"formatting"})}},L:function(e,a,n){var t=e.getUTCMonth();switch(a){case"L":return String(t+1);case"LL":return hke(t+1,2);case"Lo":return n.ordinalNumber(t+1,{unit:"month"});case"LLL":return n.month(t,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(t,{width:"narrow",context:"standalone"});default:return n.month(t,{width:"wide",context:"standalone"})}},w:function(e,a,n,t){var i=mke(e,t);return"wo"===a?n.ordinalNumber(i,{unit:"week"}):hke(i,a.length)},I:function(e,a,n){var t=uke(e);return"Io"===a?n.ordinalNumber(t,{unit:"week"}):hke(t,a.length)},d:function(e,a,n){return"do"===a?n.ordinalNumber(e.getUTCDate(),{unit:"date"}):vke(e,a)},D:function(e,a,n){var t=function(e){Kye(1,arguments);var a=Oye(e),n=a.getTime();a.setUTCMonth(0,1),a.setUTCHours(0,0,0,0);var t=a.getTime();return Math.floor((n-t)/864e5)+1}(e);return"Do"===a?n.ordinalNumber(t,{unit:"dayOfYear"}):hke(t,a.length)},E:function(e,a,n){var t=e.getUTCDay();switch(a){case"E":case"EE":case"EEE":return n.day(t,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(t,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(t,{width:"short",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})}},e:function(e,a,n,t){var i=e.getUTCDay(),r=(i-t.weekStartsOn+8)%7||7;switch(a){case"e":return String(r);case"ee":return hke(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,a,n,t){var i=e.getUTCDay(),r=(i-t.weekStartsOn+8)%7||7;switch(a){case"c":return String(r);case"cc":return hke(r,a.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,a,n){var t=e.getUTCDay(),i=0===t?7:t;switch(a){case"i":return String(i);case"ii":return hke(i,a.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(t,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(t,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(t,{width:"short",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})}},a:function(e,a,n){var t=e.getUTCHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},b:function(e,a,n){var t,i=e.getUTCHours();switch(t=12===i?wke:0===i?Ake:i/12>=1?"pm":"am",a){case"b":case"bb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},B:function(e,a,n){var t,i=e.getUTCHours();switch(t=i>=17?Tke:i>=12?Mke:i>=4?Cke:Eke,a){case"B":case"BB":case"BBB":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},h:function(e,a,n){if("ho"===a){var t=e.getUTCHours()%12;return 0===t&&(t=12),n.ordinalNumber(t,{unit:"hour"})}return fke(e,a)},H:function(e,a,n){return"Ho"===a?n.ordinalNumber(e.getUTCHours(),{unit:"hour"}):yke(e,a)},K:function(e,a,n){var t=e.getUTCHours()%12;return"Ko"===a?n.ordinalNumber(t,{unit:"hour"}):hke(t,a.length)},k:function(e,a,n){var t=e.getUTCHours();return 0===t&&(t=24),"ko"===a?n.ordinalNumber(t,{unit:"hour"}):hke(t,a.length)},m:function(e,a,n){return"mo"===a?n.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):kke(e,a)},s:function(e,a,n){return"so"===a?n.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):bke(e,a)},S:function(e,a){return Ske(e,a)},X:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();if(0===i)return"Z";switch(a){case"X":return _ke(i);case"XXXX":case"XX":return Pke(i);default:return Pke(i,":")}},x:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"x":return _ke(i);case"xxxx":case"xx":return Pke(i);default:return Pke(i,":")}},O:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Nke(i,":");default:return"GMT"+Pke(i,":")}},z:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Nke(i,":");default:return"GMT"+Pke(i,":")}},t:function(e,a,n,t){return hke(Math.floor((t._originalDate||e).getTime()/1e3),a.length)},T:function(e,a,n,t){return hke((t._originalDate||e).getTime(),a.length)}};function Nke(e,a){var n=e>0?"-":"+",t=Math.abs(e),i=Math.floor(t/60),r=t%60;if(0===r)return n+String(i);var o=a;return n+String(i)+o+hke(r,2)}function _ke(e,a){return e%60==0?(e>0?"-":"+")+hke(Math.abs(e)/60,2):Pke(e,a)}function Pke(e,a){var n=a||"",t=e>0?"-":"+",i=Math.abs(e);return t+hke(Math.floor(i/60),2)+n+hke(i%60,2)}var Lke=function(e,a){switch(e){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});default:return a.date({width:"full"})}},jke=function(e,a){switch(e){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});default:return a.time({width:"full"})}},Bke={p:jke,P:function(e,a){var n,t=e.match(/(P+)(p+)?/)||[],i=t[1],r=t[2];if(!r)return Lke(e,a);switch(i){case"P":n=a.dateTime({width:"short"});break;case"PP":n=a.dateTime({width:"medium"});break;case"PPP":n=a.dateTime({width:"long"});break;default:n=a.dateTime({width:"full"})}return n.replace("{{date}}",Lke(i,a)).replace("{{time}}",jke(r,a))}},Rke=["D","DD"],zke=["YY","YYYY"];function Dke(e,a,n){if("YYYY"===e)throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(a,"`) for formatting years to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("YY"===e)throw new RangeError("Use `yy` instead of `YY` (in `".concat(a,"`) for formatting years to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("D"===e)throw new RangeError("Use `d` instead of `D` (in `".concat(a,"`) for formatting days of the month to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("DD"===e)throw new RangeError("Use `dd` instead of `DD` (in `".concat(a,"`) for formatting days of the month to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var Kke={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function Oke(e){return function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=a.width?String(a.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var Hke={date:Oke({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Oke({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Oke({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Ike={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Gke(e){return function(a,n){var t;if("formatting"===(null!=n&&n.context?String(n.context):"standalone")&&e.formattingValues){var i=e.defaultFormattingWidth||e.defaultWidth,r=null!=n&&n.width?String(n.width):i;t=e.formattingValues[r]||e.formattingValues[i]}else{var o=e.defaultWidth,s=null!=n&&n.width?String(n.width):e.defaultWidth;t=e.values[s]||e.values[o]}return t[e.argumentCallback?e.argumentCallback(a):a]}}var Fke={ordinalNumber:function(e,a){var n=Number(e),t=n%100;if(t>20||t<10)switch(t%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:Gke({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Gke({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:Gke({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:Gke({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:Gke({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function Vke(e){return function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.width,i=a.match(t&&e.matchPatterns[t]||e.matchPatterns[e.defaultMatchWidth]);if(!i)return null;var r,o=i[0],s=t&&e.parsePatterns[t]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(s)?function(e,a){for(var n=0;n<e.length;n++)if(a(e[n]))return n;return}(s,(function(e){return e.test(o)})):function(e,a){for(var n in e)if(e.hasOwnProperty(n)&&a(e[n]))return n;return}(s,(function(e){return e.test(o)}));return r=e.valueCallback?e.valueCallback(l):l,{value:r=n.valueCallback?n.valueCallback(r):r,rest:a.slice(o.length)}}}var Jke={ordinalNumber:function(e){return function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=a.match(e.matchPattern);if(!t)return null;var i=t[0],r=a.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];return{value:o=n.valueCallback?n.valueCallback(o):o,rest:a.slice(i.length)}}}({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Vke({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:Vke({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:Vke({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:Vke({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Vke({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},Uke={code:"en-US",formatDistance:function(e,a,n){var t,i=Kke[e];return t="string"==typeof i?i:1===a?i.one:i.other.replace("{{count}}",a.toString()),null!=n&&n.addSuffix?n.comparison&&n.comparison>0?"in "+t:t+" ago":t},formatLong:Hke,formatRelative:function(e,a,n,t){return Ike[e]},localize:Fke,match:Jke,options:{weekStartsOn:0,firstWeekContainsDate:1}},Wke=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,qke=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Zke=/^'([^]*?)'?$/,$ke=/''/g,Yke=/[a-zA-Z]/;function Qke(e,a,n){var t,i,r,o,s,l,u,c,d,m,h,p,g,v,f,y,k,b;Kye(2,arguments);var S=String(a),A=Fye(),w=null!==(t=null!==(i=null==n?void 0:n.locale)&&void 0!==i?i:A.locale)&&void 0!==t?t:Uke,C=Dye(null!==(r=null!==(o=null!==(s=null!==(l=null==n?void 0:n.firstWeekContainsDate)&&void 0!==l?l:null==n||null===(u=n.locale)||void 0===u||null===(c=u.options)||void 0===c?void 0:c.firstWeekContainsDate)&&void 0!==s?s:A.firstWeekContainsDate)&&void 0!==o?o:null===(d=A.locale)||void 0===d||null===(m=d.options)||void 0===m?void 0:m.firstWeekContainsDate)&&void 0!==r?r:1);if(!(C>=1&&C<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var M=Dye(null!==(h=null!==(p=null!==(g=null!==(v=null==n?void 0:n.weekStartsOn)&&void 0!==v?v:null==n||null===(f=n.locale)||void 0===f||null===(y=f.options)||void 0===y?void 0:y.weekStartsOn)&&void 0!==g?g:A.weekStartsOn)&&void 0!==p?p:null===(k=A.locale)||void 0===k||null===(b=k.options)||void 0===b?void 0:b.weekStartsOn)&&void 0!==h?h:0);if(!(M>=0&&M<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!w.localize)throw new RangeError("locale must contain localize property");if(!w.formatLong)throw new RangeError("locale must contain formatLong property");var T=Oye(e);if(!function(e){if(Kye(1,arguments),!Xye(e)&&"number"!=typeof e)return!1;var a=Oye(e);return!isNaN(Number(a))}(T))throw new RangeError("Invalid time value");var E=oke(T,Wye(T)),x={firstWeekContainsDate:C,weekStartsOn:M,locale:w,_originalDate:T};return S.match(qke).map((function(e){var a=e[0];return"p"===a||"P"===a?(0,Bke[a])(e,w.formatLong):e})).join("").match(Wke).map((function(t){if("''"===t)return"'";var i=t[0];if("'"===i)return function(e){var a=e.match(Zke);if(!a)return e;return a[1].replace($ke,"'")}(t);var r=xke[i];if(r)return null!=n&&n.useAdditionalWeekYearTokens||-1===zke.indexOf(t)||Dke(t,a,String(e)),null!=n&&n.useAdditionalDayOfYearTokens||!function(e){return-1!==Rke.indexOf(e)}(t)||Dke(t,a,String(e)),r(E,t,w.localize,x);if(i.match(Yke))throw new RangeError("Format string contains an unescaped latin alphabet character `"+i+"`");return t})).join("")}function Xke(e){return Kye(1,arguments),Math.floor(function(e){return Kye(1,arguments),Oye(e).getTime()}(e)/1e3)}function ebe(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Fye(),d=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:c.firstWeekContainsDate)&&void 0!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1),m=function(e,a){var n,t,i,r,o,s,l,u;Kye(1,arguments);var c=Oye(e),d=c.getFullYear(),m=Fye(),h=Dye(null!==(n=null!==(t=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:m.firstWeekContainsDate)&&void 0!==t?t:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setFullYear(d+1,0,h),p.setHours(0,0,0,0);var g=Vye(p,a),v=new Date(0);v.setFullYear(d,0,h),v.setHours(0,0,0,0);var f=Vye(v,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=f.getTime()?d:d-1}(e,a),h=new Date(0);return h.setFullYear(m,0,d),h.setHours(0,0,0,0),Vye(h,a)}function abe(e,a){return Kye(1,arguments),function(e,a,n){Kye(2,arguments);var t=Vye(e,n),i=Vye(a,n),r=t.getTime()-Wye(t),o=i.getTime()-Wye(i);return Math.round((r-o)/6048e5)}(function(e){Kye(1,arguments);var a=Oye(e),n=a.getMonth();return a.setFullYear(a.getFullYear(),n+1,0),a.setHours(0,0,0,0),a}(e),nke(e),a)+1}function nbe(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return n.getTime()>t.getTime()}function tbe(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return n.getTime()<t.getTime()}function ibe(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()}function rbe(e,a){return Kye(2,arguments),Hye(e,-Dye(a))}function obe(e,a){Kye(2,arguments);var n=Oye(e),t=Dye(a),i=n.getFullYear(),r=n.getDate(),o=new Date(0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);var s=function(e){Kye(1,arguments);var a=Oye(e),n=a.getFullYear(),t=a.getMonth(),i=new Date(0);return i.setFullYear(n,t+1,0),i.setHours(0,0,0,0),i.getDate()}(o);return n.setMonth(t,Math.min(r,s)),n}function sbe(e,a){Kye(2,arguments);var n=Oye(e),t=Dye(a);return isNaN(n.getTime())?new Date(NaN):(n.setFullYear(t),n)}var lbe=function(){return lbe=Object.assign||function(e){for(var a,n=1,t=arguments.length;n<t;n++)for(var i in a=arguments[n])Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i]);return e},lbe.apply(this,arguments)};function ube(e,a,n){for(var t,i=0,r=a.length;i<r;i++)!t&&i in a||(t||(t=Array.prototype.slice.call(a,0,i)),t[i]=a[i]);return e.concat(t||Array.prototype.slice.call(a))}function cbe(e){return"multiple"===e.mode}function dbe(e){return"range"===e.mode}function mbe(e){return"single"===e.mode}"function"==typeof SuppressedError&&SuppressedError;var hbe={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};var pbe=Object.freeze({__proto__:null,formatCaption:function(e,a){return Qke(e,"LLLL y",a)},formatDay:function(e,a){return Qke(e,"d",a)},formatMonthCaption:function(e,a){return Qke(e,"LLLL",a)},formatWeekNumber:function(e){return"".concat(e)},formatWeekdayName:function(e,a){return Qke(e,"cccccc",a)},formatYearCaption:function(e,a){return Qke(e,"yyyy",a)}}),gbe=Object.freeze({__proto__:null,labelDay:function(e,a,n){return Qke(e,"do MMMM (EEEE)",n)},labelMonthDropdown:function(){return"Month: "},labelNext:function(){return"Go to next month"},labelPrevious:function(){return"Go to previous month"},labelWeekNumber:function(e){return"Week n. ".concat(e)},labelWeekday:function(e,a){return Qke(e,"cccc",a)},labelYearDropdown:function(){return"Year: "}});var vbe=a.createContext(void 0);function fbe(e){var a,t,i=e.initialProps,r={captionLayout:"buttons",classNames:hbe,formatters:pbe,labels:gbe,locale:Uke,modifiersClassNames:{},modifiers:{},numberOfMonths:1,styles:{},today:new Date,mode:"default"},o=function(e){var a=e.fromYear,n=e.toYear,t=e.fromMonth,i=e.toMonth,r=e.fromDate,o=e.toDate;return t?r=nke(t):a&&(r=new Date(a,0,1)),i?o=ake(i):n&&(o=new Date(n,11,31)),{fromDate:r?qye(r):void 0,toDate:o?qye(o):void 0}}(i),s=o.fromDate,l=o.toDate,u=null!==(a=i.captionLayout)&&void 0!==a?a:r.captionLayout;"buttons"===u||s&&l||(u="buttons"),(mbe(i)||cbe(i)||dbe(i))&&(t=i.onSelect);var c=lbe(lbe(lbe({},r),i),{captionLayout:u,classNames:lbe(lbe({},r.classNames),i.classNames),components:lbe({},i.components),formatters:lbe(lbe({},r.formatters),i.formatters),fromDate:s,labels:lbe(lbe({},r.labels),i.labels),mode:i.mode||r.mode,modifiers:lbe(lbe({},r.modifiers),i.modifiers),modifiersClassNames:lbe(lbe({},r.modifiersClassNames),i.modifiersClassNames),onSelect:t,styles:lbe(lbe({},r.styles),i.styles),toDate:l});return n.jsx(vbe.Provider,{value:c,children:e.children})}function ybe(){var e=a.useContext(vbe);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function kbe(e){var a=ybe();return n.jsx("div",{className:a.classNames.caption_label,style:a.styles.caption_label,"aria-live":"polite",role:"presentation",id:e.id,children:(0,a.formatters.formatCaption)(e.displayMonth,{locale:a.locale})})}function bbe(e){return n.jsx("svg",lbe({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:n.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function Sbe(e){var a,t,i=e.onChange,r=e.value,o=e.children,s=e.caption,l=e.className,u=e.style,c=ybe(),d=null!==(t=null===(a=c.components)||void 0===a?void 0:a.IconDropdown)&&void 0!==t?t:bbe;return n.jsxs("div",{className:l,style:u,children:[n.jsx("span",{className:c.classNames.vhidden,children:e["aria-label"]}),n.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:c.classNames.dropdown,style:c.styles.dropdown,value:r,onChange:i,children:o}),n.jsxs("div",{className:c.classNames.caption_label,style:c.styles.caption_label,"aria-hidden":"true",children:[s,n.jsx(d,{className:c.classNames.dropdown_icon,style:c.styles.dropdown_icon})]})]})}function Abe(e){var a,t=ybe(),i=t.fromDate,r=t.toDate,o=t.styles,s=t.locale,l=t.formatters.formatMonthCaption,u=t.classNames,c=t.components,d=t.labels.labelMonthDropdown;if(!i)return n.jsx(n.Fragment,{});if(!r)return n.jsx(n.Fragment,{});var m=[];if(function(e,a){Kye(2,arguments);var n=Oye(e),t=Oye(a);return n.getFullYear()===t.getFullYear()}(i,r))for(var h=nke(i),p=i.getMonth();p<=r.getMonth();p++)m.push(obe(h,p));else for(h=nke(new Date),p=0;p<=11;p++)m.push(obe(h,p));var g=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:Sbe;return n.jsx(g,{name:"months","aria-label":d(),className:u.dropdown_month,style:o.dropdown_month,onChange:function(a){var n=Number(a.target.value),t=obe(nke(e.displayMonth),n);e.onChange(t)},value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:s}),children:m.map((function(e){return n.jsx("option",{value:e.getMonth(),children:l(e,{locale:s})},e.getMonth())}))})}function wbe(e){var a,t=e.displayMonth,i=ybe(),r=i.fromDate,o=i.toDate,s=i.locale,l=i.styles,u=i.classNames,c=i.components,d=i.formatters.formatYearCaption,m=i.labels.labelYearDropdown,h=[];if(!r)return n.jsx(n.Fragment,{});if(!o)return n.jsx(n.Fragment,{});for(var p=r.getFullYear(),g=o.getFullYear(),v=p;v<=g;v++)h.push(sbe(tke(new Date),v));var f=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:Sbe;return n.jsx(f,{name:"years","aria-label":m(),className:u.dropdown_year,style:l.dropdown_year,onChange:function(a){var n=sbe(nke(t),Number(a.target.value));e.onChange(n)},value:t.getFullYear(),caption:d(t,{locale:s}),children:h.map((function(e){return n.jsx("option",{value:e.getFullYear(),children:d(e,{locale:s})},e.getFullYear())}))})}function Cbe(){var e=ybe(),n=function(e){var a=e.month||e.defaultMonth||e.today||new Date,n=e.toDate,t=e.fromDate,i=e.numberOfMonths,r=void 0===i?1:i;return n&&eke(n,a)<0&&(a=Iye(n,-1*(r-1))),t&&eke(a,t)<0&&(a=t),nke(a)}(e),t=function(e,n){var t=a.useState(e);return[void 0===n?t[0]:n,t[1]]}(n,e.month),i=t[1];return[t[0],function(a){var n;if(!e.disableNavigation){var t=nke(a);i(t),null===(n=e.onMonthChange)||void 0===n||n.call(e,t)}}]}var Mbe=a.createContext(void 0);function Tbe(e){var a=ybe(),t=Cbe(),i=t[0],r=t[1],o=function(e,a){for(var n=a.reverseMonths,t=a.numberOfMonths,i=nke(e),r=eke(nke(Iye(i,t)),i),o=[],s=0;s<r;s++){var l=Iye(i,s);o.push(l)}return n&&(o=o.reverse()),o}(i,a),s=function(e,a){if(!a.disableNavigation){var n=a.toDate,t=a.numberOfMonths,i=void 0===t?1:t,r=a.pagedNavigation?i:1,o=nke(e);if(!n)return Iye(o,r);if(!(eke(n,e)<i))return Iye(o,r)}}(i,a),l=function(e,a){if(!a.disableNavigation){var n=a.fromDate,t=a.numberOfMonths,i=a.pagedNavigation?void 0===t?1:t:1,r=nke(e);if(!n)return Iye(r,-i);if(!(eke(r,n)<=0))return Iye(r,-i)}}(i,a),u=function(e){return o.some((function(a){return ibe(e,a)}))};return n.jsx(Mbe.Provider,{value:{currentMonth:i,displayMonths:o,goToMonth:r,goToDate:function(e,n){u(e)||(n&&tbe(e,n)?r(Iye(e,1+-1*a.numberOfMonths)):r(e))},previousMonth:l,nextMonth:s,isDateDisplayed:u},children:e.children})}function Ebe(){var e=a.useContext(Mbe);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function xbe(e){var a,t=ybe(),i=t.classNames,r=t.styles,o=t.components,s=Ebe().goToMonth,l=function(a){s(Iye(a,e.displayIndex?-e.displayIndex:0))},u=null!==(a=null==o?void 0:o.CaptionLabel)&&void 0!==a?a:kbe,c=n.jsx(u,{id:e.id,displayMonth:e.displayMonth});return n.jsxs("div",{className:i.caption_dropdowns,style:r.caption_dropdowns,children:[n.jsx("div",{className:i.vhidden,children:c}),n.jsx(Abe,{onChange:l,displayMonth:e.displayMonth}),n.jsx(wbe,{onChange:l,displayMonth:e.displayMonth})]})}function Nbe(e){return n.jsx("svg",lbe({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function _be(e){return n.jsx("svg",lbe({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var Pbe=a.forwardRef((function(e,a){var t=ybe(),i=t.classNames,r=t.styles,o=[i.button_reset,i.button];e.className&&o.push(e.className);var s=o.join(" "),l=lbe(lbe({},r.button_reset),r.button);return e.style&&Object.assign(l,e.style),n.jsx("button",lbe({},e,{ref:a,type:"button",className:s,style:l}))}));function Lbe(e){var a,t,i=ybe(),r=i.dir,o=i.locale,s=i.classNames,l=i.styles,u=i.labels,c=u.labelPrevious,d=u.labelNext,m=i.components;if(!e.nextMonth&&!e.previousMonth)return n.jsx(n.Fragment,{});var h=c(e.previousMonth,{locale:o}),p=[s.nav_button,s.nav_button_previous].join(" "),g=d(e.nextMonth,{locale:o}),v=[s.nav_button,s.nav_button_next].join(" "),f=null!==(a=null==m?void 0:m.IconRight)&&void 0!==a?a:_be,y=null!==(t=null==m?void 0:m.IconLeft)&&void 0!==t?t:Nbe;return n.jsxs("div",{className:s.nav,style:l.nav,children:[!e.hidePrevious&&n.jsx(Pbe,{name:"previous-month","aria-label":h,className:p,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:n.jsx("rtl"===r?f:y,{className:s.nav_icon,style:l.nav_icon})}),!e.hideNext&&n.jsx(Pbe,{name:"next-month","aria-label":g,className:v,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:n.jsx("rtl"===r?y:f,{className:s.nav_icon,style:l.nav_icon})})]})}function jbe(e){var a=ybe().numberOfMonths,t=Ebe(),i=t.previousMonth,r=t.nextMonth,o=t.goToMonth,s=t.displayMonths,l=s.findIndex((function(a){return ibe(e.displayMonth,a)})),u=0===l,c=l===s.length-1;return n.jsx(Lbe,{displayMonth:e.displayMonth,hideNext:a>1&&(u||!c),hidePrevious:a>1&&(c||!u),nextMonth:r,previousMonth:i,onPreviousClick:function(){i&&o(i)},onNextClick:function(){r&&o(r)}})}function Bbe(e){var a,t,i=ybe(),r=i.classNames,o=i.styles,s=i.captionLayout,l=i.components,u=null!==(a=null==l?void 0:l.CaptionLabel)&&void 0!==a?a:kbe;return t=i.disableNavigation?n.jsx(u,{id:e.id,displayMonth:e.displayMonth}):"dropdown"===s?n.jsx(xbe,{displayMonth:e.displayMonth,id:e.id}):n.jsxs(n.Fragment,"dropdown-buttons"===s?{children:[n.jsx(xbe,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),n.jsx(jbe,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}:{children:[n.jsx(u,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(jbe,{displayMonth:e.displayMonth,id:e.id})]}),n.jsx("div",{className:r.caption,style:o.caption,children:t})}function Rbe(e){var a=ybe(),t=a.footer;return t?n.jsx("tfoot",{className:a.classNames.tfoot,style:a.styles.tfoot,children:n.jsx("tr",{children:n.jsx("td",{colSpan:8,children:t})})}):n.jsx(n.Fragment,{})}function zbe(){var e=ybe(),a=e.classNames,t=e.styles,i=e.showWeekNumber,r=e.locale,o=e.formatters.formatWeekdayName,s=e.labels.labelWeekday,l=function(e,a,n){for(var t=n?Jye(new Date):Vye(new Date,{locale:e,weekStartsOn:a}),i=[],r=0;r<7;r++){var o=Hye(t,r);i.push(o)}return i}(r,e.weekStartsOn,e.ISOWeek);return n.jsxs("tr",{style:t.head_row,className:a.head_row,children:[i&&n.jsx("td",{style:t.head_cell,className:a.head_cell}),l.map((function(e,i){return n.jsx("th",{scope:"col",className:a.head_cell,style:t.head_cell,"aria-label":s(e,{locale:r}),children:o(e,{locale:r})},i)}))]})}function Dbe(){var e,a=ybe(),t=a.components,i=null!==(e=null==t?void 0:t.HeadRow)&&void 0!==e?e:zbe;return n.jsx("thead",{style:a.styles.head,className:a.classNames.head,children:n.jsx(i,{})})}function Kbe(e){var a=ybe();return n.jsx(n.Fragment,{children:(0,a.formatters.formatDay)(e.date,{locale:a.locale})})}var Obe=a.createContext(void 0);function Hbe(e){if(!cbe(e.initialProps)){return n.jsx(Obe.Provider,{value:{selected:void 0,modifiers:{disabled:[]}},children:e.children})}return n.jsx(Ibe,{initialProps:e.initialProps,children:e.children})}function Ibe(e){var a=e.initialProps,t=e.children,i=a.selected,r=a.min,o=a.max,s={disabled:[]};return i&&s.disabled.push((function(e){var a=o&&i.length>o-1,n=i.some((function(a){return Qye(a,e)}));return Boolean(a&&!n)})),n.jsx(Obe.Provider,{value:{selected:i,onDayClick:function(e,n,t){var s,l;if((null===(s=a.onDayClick)||void 0===s||s.call(a,e,n,t),!Boolean(n.selected&&r&&(null==i?void 0:i.length)===r))&&!Boolean(!n.selected&&o&&(null==i?void 0:i.length)===o)){var u=i?ube([],i):[];if(n.selected){var c=u.findIndex((function(a){return Qye(e,a)}));u.splice(c,1)}else u.push(e);null===(l=a.onSelect)||void 0===l||l.call(a,u,e,n,t)}},modifiers:s},children:t})}function Gbe(){var e=a.useContext(Obe);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}var Fbe,Vbe,Jbe=a.createContext(void 0);function Ube(e){if(!dbe(e.initialProps)){return n.jsx(Jbe.Provider,{value:{selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}},children:e.children})}return n.jsx(Wbe,{initialProps:e.initialProps,children:e.children})}function Wbe(e){var a=e.initialProps,t=e.children,i=a.selected,r=i||{},o=r.from,s=r.to,l=a.min,u=a.max,c={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(c.range_start=[o],s?(c.range_end=[s],Qye(o,s)||(c.range_middle=[{after:o,before:s}])):c.range_end=[o]):s&&(c.range_start=[s],c.range_end=[s]),l&&(o&&!s&&c.disabled.push({after:rbe(o,l-1),before:Hye(o,l-1)}),o&&s&&c.disabled.push({after:o,before:Hye(o,l-1)}),!o&&s&&c.disabled.push({after:rbe(s,l-1),before:Hye(s,l-1)})),u){if(o&&!s&&(c.disabled.push({before:Hye(o,1-u)}),c.disabled.push({after:Hye(o,u-1)})),o&&s){var d=u-(Zye(s,o)+1);c.disabled.push({before:rbe(o,d)}),c.disabled.push({after:Hye(s,d)})}!o&&s&&(c.disabled.push({before:Hye(s,1-u)}),c.disabled.push({after:Hye(s,u-1)}))}return n.jsx(Jbe.Provider,{value:{selected:i,onDayClick:function(e,n,t){var r,o;null===(r=a.onDayClick)||void 0===r||r.call(a,e,n,t);var s=function(e,a){var n=a||{},t=n.from,i=n.to;if(t&&i){if(Qye(i,e)&&Qye(t,e))return;if(Qye(i,e))return{from:i,to:void 0};if(Qye(t,e))return;return nbe(t,e)?{from:e,to:i}:{from:t,to:e}}return i?nbe(e,i)?{from:i,to:e}:{from:e,to:i}:t?tbe(e,t)?{from:e,to:t}:{from:t,to:e}:{from:e,to:void 0}}(e,i);null===(o=a.onSelect)||void 0===o||o.call(a,s,e,n,t)},modifiers:c},children:t})}function qbe(){var e=a.useContext(Jbe);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function Zbe(e){return Array.isArray(e)?ube([],e):void 0!==e?[e]:[]}(Vbe=Fbe||(Fbe={})).Outside="outside",Vbe.Disabled="disabled",Vbe.Selected="selected",Vbe.Hidden="hidden",Vbe.Today="today",Vbe.RangeStart="range_start",Vbe.RangeEnd="range_end",Vbe.RangeMiddle="range_middle";var $be=Fbe.Selected,Ybe=Fbe.Disabled,Qbe=Fbe.Hidden,Xbe=Fbe.Today,eSe=Fbe.RangeEnd,aSe=Fbe.RangeMiddle,nSe=Fbe.RangeStart,tSe=Fbe.Outside;var iSe=a.createContext(void 0);function rSe(e){var a=ybe(),t=function(e,a,n){var t,i=((t={})[$be]=Zbe(e.selected),t[Ybe]=Zbe(e.disabled),t[Qbe]=Zbe(e.hidden),t[Xbe]=[e.today],t[eSe]=[],t[aSe]=[],t[nSe]=[],t[tSe]=[],t);return e.fromDate&&i[Ybe].push({before:e.fromDate}),e.toDate&&i[Ybe].push({after:e.toDate}),cbe(e)?i[Ybe]=i[Ybe].concat(a.modifiers[Ybe]):dbe(e)&&(i[Ybe]=i[Ybe].concat(n.modifiers[Ybe]),i[nSe]=n.modifiers[nSe],i[aSe]=n.modifiers[aSe],i[eSe]=n.modifiers[eSe]),i}(a,Gbe(),qbe()),i=function(e){var a={};return Object.entries(e).forEach((function(e){a[e[0]]=Zbe(e[1])})),a}(a.modifiers),r=lbe(lbe({},t),i);return n.jsx(iSe.Provider,{value:r,children:e.children})}function oSe(){var e=a.useContext(iSe);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function sSe(e,a){return a.some((function(a){if("boolean"==typeof a)return a;if(Xye(a))return Qye(e,a);var n,t,i,r,o;if(function(e){return Array.isArray(e)&&e.every(Xye)}(a))return a.includes(e);if(function(e){return Boolean(e&&"object"==typeof e&&"from"in e)}(a))return n=e,o=(t=a).to,(r=t.from)&&o?(Zye(o,r)<0&&(r=(i=[o,r])[0],o=i[1]),Zye(n,r)>=0&&Zye(o,n)>=0):o?Qye(o,n):!!r&&Qye(r,n);if(function(e){return Boolean(e&&"object"==typeof e&&"dayOfWeek"in e)}(a))return a.dayOfWeek.includes(e.getDay());if(function(e){return Boolean(e&&"object"==typeof e&&"before"in e&&"after"in e)}(a)){var s=Zye(a.before,e)>0,l=Zye(a.after,e)<0;return nbe(a.before,a.after)?l&&s:s||l}return function(e){return Boolean(e&&"object"==typeof e&&"after"in e)}(a)?Zye(e,a.after)>0:function(e){return Boolean(e&&"object"==typeof e&&"before"in e)}(a)?Zye(a.before,e)>0:"function"==typeof a&&a(e)}))}function lSe(e,a,n){var t=Object.keys(a).reduce((function(n,t){return sSe(e,a[t])&&n.push(t),n}),[]),i={};return t.forEach((function(e){return i[e]=!0})),n&&!ibe(e,n)&&(i.outside=!0),i}function uSe(e,a){var n=a.moveBy,t=a.direction,i=a.context,r=a.modifiers,o=a.retry,s=void 0===o?{count:0,lastFocused:e}:o,l=i.weekStartsOn,u=i.fromDate,c=i.toDate,d=i.locale,m={day:Hye,week:$ye,month:Iye,year:Yye,startOfWeek:function(e){return i.ISOWeek?Jye(e):Vye(e,{locale:d,weekStartsOn:l})},endOfWeek:function(e){return i.ISOWeek?rke(e):ike(e,{locale:d,weekStartsOn:l})}}[n](e,"after"===t?1:-1);"before"===t&&u?m=function(e){var a,n;if(Kye(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==zye(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=Oye(e);(void 0===n||n<a||isNaN(Number(a)))&&(n=a)})),n||new Date(NaN)}([u,m]):"after"===t&&c&&(m=function(e){var a,n;if(Kye(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==zye(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=Oye(e);(void 0===n||n>a||isNaN(a.getDate()))&&(n=a)})),n||new Date(NaN)}([c,m]));var h=!0;if(r){var p=lSe(m,r);h=!p.disabled&&!p.hidden}return h?m:s.count>365?s.lastFocused:uSe(m,{moveBy:n,direction:t,context:i,modifiers:r,retry:lbe(lbe({},s),{count:s.count+1})})}var cSe=a.createContext(void 0);function dSe(e){var t=Ebe(),i=oSe(),r=a.useState(),o=r[0],s=r[1],l=a.useState(),u=l[0],c=l[1],d=function(e,a){for(var n,t,i=nke(e[0]),r=ake(e[e.length-1]),o=i;o<=r;){var s=lSe(o,a);if(s.disabled||s.hidden)o=Hye(o,1);else{if(s.selected)return o;s.today&&!t&&(t=o),n||(n=o),o=Hye(o,1)}}return t||n}(t.displayMonths,i),m=(null!=o?o:u&&t.isDateDisplayed(u))?u:d,h=function(e){s(e)},p=ybe(),g=function(e,a){if(o){var n=uSe(o,{moveBy:e,direction:a,context:p,modifiers:i});Qye(o,n)||(t.goToDate(n,o),h(n))}};return n.jsx(cSe.Provider,{value:{focusedDay:o,focusTarget:m,blur:function(){c(o),s(void 0)},focus:h,focusDayAfter:function(){return g("day","after")},focusDayBefore:function(){return g("day","before")},focusWeekAfter:function(){return g("week","after")},focusWeekBefore:function(){return g("week","before")},focusMonthBefore:function(){return g("month","before")},focusMonthAfter:function(){return g("month","after")},focusYearBefore:function(){return g("year","before")},focusYearAfter:function(){return g("year","after")},focusStartOfWeek:function(){return g("startOfWeek","before")},focusEndOfWeek:function(){return g("endOfWeek","after")}},children:e.children})}function mSe(){var e=a.useContext(cSe);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}var hSe=a.createContext(void 0);function pSe(e){if(!mbe(e.initialProps)){return n.jsx(hSe.Provider,{value:{selected:void 0},children:e.children})}return n.jsx(gSe,{initialProps:e.initialProps,children:e.children})}function gSe(e){var a=e.initialProps;return n.jsx(hSe.Provider,{value:{selected:a.selected,onDayClick:function(e,n,t){var i,r,o;null===(i=a.onDayClick)||void 0===i||i.call(a,e,n,t),!n.selected||a.required?null===(o=a.onSelect)||void 0===o||o.call(a,e,e,n,t):null===(r=a.onSelect)||void 0===r||r.call(a,void 0,e,n,t)}},children:e.children})}function vSe(){var e=a.useContext(hSe);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function fSe(e,a){var n=[e.classNames.day];return Object.keys(a).forEach((function(a){var t=e.modifiersClassNames[a];if(t)n.push(t);else if(function(e){return Object.values(Fbe).includes(e)}(a)){var i=e.classNames["day_".concat(a)];i&&n.push(i)}})),n}function ySe(e,t,i){var r,o,s,l=ybe(),u=mSe(),c=function(e,a){return lSe(e,oSe(),a)}(e,t),d=function(e,a){var n=ybe(),t=vSe(),i=Gbe(),r=qbe(),o=mSe(),s=o.focusDayAfter,l=o.focusDayBefore,u=o.focusWeekAfter,c=o.focusWeekBefore,d=o.blur,m=o.focus,h=o.focusMonthBefore,p=o.focusMonthAfter,g=o.focusYearBefore,v=o.focusYearAfter,f=o.focusStartOfWeek,y=o.focusEndOfWeek;return{onClick:function(o){var s,l,u,c;mbe(n)?null===(s=t.onDayClick)||void 0===s||s.call(t,e,a,o):cbe(n)?null===(l=i.onDayClick)||void 0===l||l.call(i,e,a,o):dbe(n)?null===(u=r.onDayClick)||void 0===u||u.call(r,e,a,o):null===(c=n.onDayClick)||void 0===c||c.call(n,e,a,o)},onFocus:function(t){var i;m(e),null===(i=n.onDayFocus)||void 0===i||i.call(n,e,a,t)},onBlur:function(t){var i;d(),null===(i=n.onDayBlur)||void 0===i||i.call(n,e,a,t)},onKeyDown:function(t){var i;switch(t.key){case"ArrowLeft":t.preventDefault(),t.stopPropagation(),"rtl"===n.dir?s():l();break;case"ArrowRight":t.preventDefault(),t.stopPropagation(),"rtl"===n.dir?l():s();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),u();break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),c();break;case"PageUp":t.preventDefault(),t.stopPropagation(),t.shiftKey?g():h();break;case"PageDown":t.preventDefault(),t.stopPropagation(),t.shiftKey?v():p();break;case"Home":t.preventDefault(),t.stopPropagation(),f();break;case"End":t.preventDefault(),t.stopPropagation(),y()}null===(i=n.onDayKeyDown)||void 0===i||i.call(n,e,a,t)},onKeyUp:function(t){var i;null===(i=n.onDayKeyUp)||void 0===i||i.call(n,e,a,t)},onMouseEnter:function(t){var i;null===(i=n.onDayMouseEnter)||void 0===i||i.call(n,e,a,t)},onMouseLeave:function(t){var i;null===(i=n.onDayMouseLeave)||void 0===i||i.call(n,e,a,t)},onPointerEnter:function(t){var i;null===(i=n.onDayPointerEnter)||void 0===i||i.call(n,e,a,t)},onPointerLeave:function(t){var i;null===(i=n.onDayPointerLeave)||void 0===i||i.call(n,e,a,t)},onTouchCancel:function(t){var i;null===(i=n.onDayTouchCancel)||void 0===i||i.call(n,e,a,t)},onTouchEnd:function(t){var i;null===(i=n.onDayTouchEnd)||void 0===i||i.call(n,e,a,t)},onTouchMove:function(t){var i;null===(i=n.onDayTouchMove)||void 0===i||i.call(n,e,a,t)},onTouchStart:function(t){var i;null===(i=n.onDayTouchStart)||void 0===i||i.call(n,e,a,t)}}}(e,c),m=function(){var e=ybe(),a=vSe(),n=Gbe(),t=qbe();return mbe(e)?a.selected:cbe(e)?n.selected:dbe(e)?t.selected:void 0}(),h=Boolean(l.onDayClick||"default"!==l.mode);a.useEffect((function(){var a;c.outside||u.focusedDay&&h&&Qye(u.focusedDay,e)&&(null===(a=i.current)||void 0===a||a.focus())}),[u.focusedDay,e,i,h,c.outside]);var p=fSe(l,c).join(" "),g=function(e,a){var n=lbe({},e.styles.day);return Object.keys(a).forEach((function(a){var t;n=lbe(lbe({},n),null===(t=e.modifiersStyles)||void 0===t?void 0:t[a])})),n}(l,c),v=Boolean(c.outside&&!l.showOutsideDays||c.hidden),f=null!==(s=null===(o=l.components)||void 0===o?void 0:o.DayContent)&&void 0!==s?s:Kbe,y={style:g,className:p,children:n.jsx(f,{date:e,displayMonth:t,activeModifiers:c}),role:"gridcell"},k=u.focusTarget&&Qye(u.focusTarget,e)&&!c.outside,b=u.focusedDay&&Qye(u.focusedDay,e),S=lbe(lbe(lbe({},y),((r={disabled:c.disabled,role:"gridcell"})["aria-selected"]=c.selected,r.tabIndex=b||k?0:-1,r)),d);return{isButton:h,isHidden:v,activeModifiers:c,selectedDays:m,buttonProps:S,divProps:y}}function kSe(e){var t=a.useRef(null),i=ySe(e.date,e.displayMonth,t);return i.isHidden?n.jsx("div",{role:"gridcell"}):i.isButton?n.jsx(Pbe,lbe({name:"day",ref:t},i.buttonProps)):n.jsx("div",lbe({},i.divProps))}function bSe(e){var a=e.number,t=e.dates,i=ybe(),r=i.onWeekNumberClick,o=i.styles,s=i.classNames,l=i.locale,u=i.labels.labelWeekNumber,c=(0,i.formatters.formatWeekNumber)(Number(a),{locale:l});if(!r)return n.jsx("span",{className:s.weeknumber,style:o.weeknumber,children:c});var d=u(Number(a),{locale:l});return n.jsx(Pbe,{name:"week-number","aria-label":d,className:s.weeknumber,style:o.weeknumber,onClick:function(e){r(a,t,e)},children:c})}function SSe(e){var a,t,i,r=ybe(),o=r.styles,s=r.classNames,l=r.components,u=null!==(a=null==l?void 0:l.Day)&&void 0!==a?a:kSe,c=null!==(t=null==l?void 0:l.WeekNumber)&&void 0!==t?t:bSe;return r.showWeekNumber&&(i=n.jsx("td",{className:s.cell,style:o.cell,children:n.jsx(c,{number:e.weekNumber,dates:e.dates})})),n.jsxs("tr",{className:s.row,style:o.row,children:[i,e.dates.map((function(a){return n.jsx("td",{className:s.cell,style:o.cell,role:"presentation",children:n.jsx(u,{displayMonth:e.displayMonth,date:a})},Xke(a))}))]})}function ASe(e,a,n){for(var t=(null==n?void 0:n.ISOWeek)?rke(a):ike(a,n),i=(null==n?void 0:n.ISOWeek)?Jye(e):Vye(e,n),r=Zye(t,i),o=[],s=0;s<=r;s++)o.push(Hye(i,s));var l=o.reduce((function(e,a){var t=(null==n?void 0:n.ISOWeek)?function(e){Kye(1,arguments);var a=Oye(e),n=Jye(a).getTime()-Uye(a).getTime();return Math.round(n/6048e5)+1}(a):function(e,a){Kye(1,arguments);var n=Oye(e),t=Vye(n,a).getTime()-ebe(n,a).getTime();return Math.round(t/6048e5)+1}(a,n),i=e.find((function(e){return e.weekNumber===t}));return i?(i.dates.push(a),e):(e.push({weekNumber:t,dates:[a]}),e)}),[]);return l}function wSe(e){var a,t,i,r=ybe(),o=r.locale,s=r.classNames,l=r.styles,u=r.hideHead,c=r.components,d=r.weekStartsOn,m=r.firstWeekContainsDate,h=r.ISOWeek,p=function(e,a){var n=ASe(nke(e),ake(e),a);if(null==a?void 0:a.useFixedWeeks){var t=abe(e,a);if(t<6){var i=n[n.length-1],r=i.dates[i.dates.length-1],o=$ye(r,6-t),s=ASe($ye(r,1),o,a);n.push.apply(n,s)}}return n}(e.displayMonth,{useFixedWeeks:Boolean(r.fixedWeeks),ISOWeek:h,locale:o,weekStartsOn:d,firstWeekContainsDate:m}),g=null!==(a=null==c?void 0:c.Head)&&void 0!==a?a:Dbe,v=null!==(t=null==c?void 0:c.Row)&&void 0!==t?t:SSe,f=null!==(i=null==c?void 0:c.Footer)&&void 0!==i?i:Rbe;return n.jsxs("table",{id:e.id,className:s.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!u&&n.jsx(g,{}),n.jsx("tbody",{className:s.tbody,style:l.tbody,children:p.map((function(a){return n.jsx(v,{displayMonth:e.displayMonth,dates:a.dates,weekNumber:a.weekNumber},a.weekNumber)}))}),n.jsx(f,{displayMonth:e.displayMonth})]})}var CSe="undefined"!=typeof window&&window.document&&window.document.createElement?a.useLayoutEffect:a.useEffect,MSe=!1,TSe=0;function ESe(){return"react-day-picker-".concat(++TSe)}function xSe(e){var t,i,r=ybe(),o=r.dir,s=r.classNames,l=r.styles,u=r.components,c=Ebe().displayMonths,d=function(e){var n,t=null!=e?e:MSe?ESe():null,i=a.useState(t),r=i[0],o=i[1];return CSe((function(){null===r&&o(ESe())}),[]),a.useEffect((function(){!1===MSe&&(MSe=!0)}),[]),null!==(n=null!=e?e:r)&&void 0!==n?n:void 0}(r.id?"".concat(r.id,"-").concat(e.displayIndex):void 0),m=r.id?"".concat(r.id,"-grid-").concat(e.displayIndex):void 0,h=[s.month],p=l.month,g=0===e.displayIndex,v=e.displayIndex===c.length-1,f=!g&&!v;"rtl"===o&&(v=(t=[g,v])[0],g=t[1]),g&&(h.push(s.caption_start),p=lbe(lbe({},p),l.caption_start)),v&&(h.push(s.caption_end),p=lbe(lbe({},p),l.caption_end)),f&&(h.push(s.caption_between),p=lbe(lbe({},p),l.caption_between));var y=null!==(i=null==u?void 0:u.Caption)&&void 0!==i?i:Bbe;return n.jsxs("div",{className:h.join(" "),style:p,children:[n.jsx(y,{id:d,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(wSe,{id:m,"aria-labelledby":d,displayMonth:e.displayMonth})]},e.displayIndex)}function NSe(e){var a=ybe();return n.jsx("div",{className:a.classNames.months,style:a.styles.months,children:e.children})}function _Se(e){var t,i,r=e.initialProps,o=ybe(),s=mSe(),l=Ebe(),u=a.useState(!1),c=u[0],d=u[1];a.useEffect((function(){o.initialFocus&&s.focusTarget&&(c||(s.focus(s.focusTarget),d(!0)))}),[o.initialFocus,c,s.focus,s.focusTarget,s]);var m=[o.classNames.root,o.className];o.numberOfMonths>1&&m.push(o.classNames.multiple_months),o.showWeekNumber&&m.push(o.classNames.with_weeknumber);var h=lbe(lbe({},o.styles.root),o.style),p=Object.keys(r).filter((function(e){return e.startsWith("data-")})).reduce((function(e,a){var n;return lbe(lbe({},e),((n={})[a]=r[a],n))}),{}),g=null!==(i=null===(t=r.components)||void 0===t?void 0:t.Months)&&void 0!==i?i:NSe;return n.jsx("div",lbe({className:m.join(" "),style:h,dir:o.dir,id:o.id,nonce:r.nonce,title:r.title,lang:r.lang},p,{children:n.jsx(g,{children:l.displayMonths.map((function(e,a){return n.jsx(xSe,{displayIndex:a,displayMonth:e},a)}))})}))}function PSe(e){var a=e.children,t=function(e,a){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&a.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(e);i<t.length;i++)a.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(n[t[i]]=e[t[i]])}return n}(e,["children"]);return n.jsx(fbe,{initialProps:t,children:n.jsx(Tbe,{children:n.jsx(pSe,{initialProps:t,children:n.jsx(Hbe,{initialProps:t,children:n.jsx(Ube,{initialProps:t,children:n.jsx(rSe,{children:n.jsx(dSe,{children:a})})})})})})})}function LSe(e){return n.jsx(PSe,lbe({},e,{children:n.jsx(_Se,{initialProps:e})}))}function jSe({className:e,classNames:a,showOutsideDays:t=!0,...i}){const r={months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:vm(y5({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-[#6b7280] rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-[#f1f5f9] [&:has([aria-selected].day-outside)]:bg-[#f1f5f9]/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",day:vm(y5({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"!bg-black !text-gray-200 hover:!bg-black hover:!text-gray-200 focus:!bg-black focus:!text-white",day_today:"bg-gray-200 text-black",day_outside:"day-outside text-[#94a3b8] aria-selected:bg-[#f1f5f9]/50 aria-selected:text-[#94a3b8]",day_disabled:"text-[#94a3b8] opacity-50",day_range_middle:"aria-selected:bg-[#f1f5f9] aria-selected:text-black",day_hidden:"invisible",...a};return n.jsx(LSe,{showOutsideDays:t,className:vm("p-3",e),classNames:r,components:{IconLeft:()=>n.jsx(Lc,{className:"h-4 w-4"}),IconRight:()=>n.jsx(jc,{className:"h-4 w-4"})},...i})}jSe.displayName="Calendar";const BSe=({setScheduleTime:e,setTimezone:a,timezone:t,scheduleTime:i,setIsDirty:o,canEditScheduleTime:s})=>{const[l,u]=r.useState(i&&i<(new Date).toISOString()?"Please select a time in the future":null),[c,d]=r.useState(i&&"now"!==i?eue(new Date(i),"HH:mm"):"00:00"),m=Intl.supportedValuesOf("timeZone").map((e=>({label:e,value:e}))),h=e=>{if(!s)return;const n=new Date(i||(new Date).toISOString()),t=hle(new Date,15);n<new Date(t.toLocaleString("en-US",{timeZone:e}))?u("Please select a time at least 15 minutes in the future"):(u(null),a(e),o(!0))},p=a=>{if(!s)return;const n=hle(new Date,15);new Date(a.toLocaleString("en-US",{timeZone:t}))<new Date(n.toLocaleString("en-US",{timeZone:t}))?u("Please select a time at least 15 minutes in the future"):(u(null),e(a.toISOString()),o(!0))};return n.jsx("div",{className:"w-full @container/schedule-time",children:n.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[n.jsxs("div",{className:"flex gap-2 w-full @xl/schedule-time:flex-row flex-col items-center justify-center",children:[n.jsxs(are,{children:[n.jsx(nre,{asChild:!0,children:n.jsxs(k5,{variant:"outline",disabled:!s,className:vm("bg-background w-full sm:w-[280px] justify-start text-left font-normal",!i&&"text-muted-foreground",!s&&"opacity-50 cursor-not-allowed"),children:[n.jsx(Nc,{className:"mr-2 h-4 w-4"}),i?"now"===i?"Send immediately":eue(new Date(i),"PPP"):n.jsx("span",{children:"Pick a date"})]})}),n.jsx(tre,{className:"w-auto p-0 z-[60] pointer-events-auto",children:n.jsx(jSe,{mode:"single",selected:i?new Date(i):void 0,onSelect:e=>{if(!e||!s)return;const[a,n]=c.split(":").map(Number);e.setHours(a,n),p(e)},disabled:e=>{const a=new Date;return a.setHours(0,0,0,0),e<a||!s},initialFocus:!0})})]}),n.jsx("input",{type:"time",value:c,onChange:e=>{if(s&&(d(e.target.value),i&&e.target.value)){const[a,n]=e.target.value.split(":").map(Number),t=new Date(i);t.setHours(a,n),p(t)}},disabled:!s,className:vm("flex h-9 w-full sm:w-[150px] rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",l&&"border-red-500",!s&&"opacity-50 cursor-not-allowed")}),n.jsx("div",{className:"w-full sm:w-[200px]",children:n.jsx(Jve,{options:m,selectedValues:[t],setSelectedValues:e=>h(e[0]),onValueChange:e=>h(e[0]),placeholder:"Select timezone...",searchPlaceholder:"Search timezone...",emptyMessage:"No timezone found",title:"Select Timezone",singleSelect:!0,canOpen:s})})]}),l&&n.jsxs("p",{className:"text-destructive text-sm mt-2 flex items-center",children:[n.jsx("span",{className:"mr-2",children:"⚠️"}),l]})]})})},RSe=({title:e="Edit Schedule Time"})=>{const t=d5(),i=ce(),{updateAutomation:r}=ta(t?.id||""),{toast:o}=Ge(),[s,l]=a.useState(null),[u,c]=a.useState(t?.triggerMetadata?.triggerType===sa.ONE_TIME?t?.triggerMetadata?.scheduledAt:null),[d,m]=a.useState(t?.triggerMetadata?.triggerType===sa.ONE_TIME&&t?.triggerMetadata?.timezone||"America/New_York"),[h,p]=a.useState(!1),[g,v]=a.useState(null);let f=a.useRef(null);const y=a.useCallback((()=>{t&&("sendNow"===s||"now"===u?r({trigger:{triggerType:sa.ONE_TIME,scheduledAt:"now"}},{onSuccess:()=>{v({title:"Schedule time updated successfully 🚀",description:`${_h("engage:broadcast")} scheduled to begin sending in 5 minutes after you activate it`})},onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:Le.all})}}):u&&d&&r({trigger:{triggerType:sa.ONE_TIME,scheduledAt:u,timezone:d}},{onSuccess:()=>{v({title:"Schedule time updated successfully 🚀",description:`${_h("engage:broadcast")} scheduled to start at ${new Date(u).toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric"})}`})},onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:Le.all})}}))}),[t,s,u,d,r,o,i]);if(a.useEffect((()=>(g&&(f.current&&clearTimeout(f.current),f.current=setTimeout((()=>{o(g),v(null)}),800)),()=>{f.current&&clearTimeout(f.current)})),[g,o]),a.useEffect((()=>{t&&h&&s&&("sendNow"===s||u)&&(y(),p(!1))}),[s,u,d,y,t,h]),a.useEffect((()=>{null===s&&t?.triggerMetadata&&"object"==typeof t.triggerMetadata&&null!==t.triggerMetadata&&"scheduledAt"in t.triggerMetadata&&("now"===t?.triggerMetadata?.scheduledAt&&t?.triggerType===sa.ONE_TIME?l("sendNow"):(t?.triggerMetadata?.scheduledAt&&c(t.triggerMetadata.scheduledAt),t?.triggerMetadata?.timezone&&m(t.triggerMetadata.timezone),l("schedule")))}),[t,s]),!t)return null;const k=t.status===da.DRAFT;return n.jsx(jye,{title:e,headerActions:!k&&n.jsx(pue,{title:"You can only edit the schedule time if the automation is in draft mode"}),children:n.jsx("div",{className:"@container flex-1 mx-4",children:n.jsxs("div",{className:"flex @[1000px]:flex-row flex-col gap-8 items-center",children:[n.jsxs("div",{className:"flex-1 w-full",children:[n.jsxs("div",{className:"grid grid-cols-1 @[480px]:grid-cols-2 gap-4",children:[n.jsx(A5,{selected:"sendNow"===s,title:"Send Now",subtitle:"Campaign will begin sending in 5 minutes",icon:n.jsx(w5.SendButton,{className:"text-primary"}),onClick:()=>{k&&(l("sendNow"),c("now"),m("America/New_York"),p(!0))},disabled:!k}),n.jsx(A5,{selected:"schedule"===s,title:"Schedule",subtitle:"Choose date and time",icon:n.jsx(w5.ScheduleButton,{className:"text-primary"}),onClick:()=>{k&&l("schedule")},disabled:!k})]}),n.jsx(eY,{children:"schedule"===s&&n.jsx(f5,{className:"overflow-hidden mt-8",children:n.jsx("div",{className:"bg-gray-50 rounded-xl p-5 border border-gray-100 flex items-center justify-center",children:n.jsx(BSe,{setScheduleTime:e=>{c(e),p(!0)},setTimezone:e=>{m(e),p(!0)},timezone:d,scheduleTime:u,setIsDirty:p,canEditScheduleTime:k})})})})]}),u&&n.jsx(K4.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},transition:{duration:.6,ease:[.23,1,.32,1],delay:.1},className:"@[1000px]:w-80 max-w-md w-full shrink-0 h-fit p-4 bg-blue-50 rounded-xl border border-blue-100 backdrop-blur-sm",children:n.jsxs(n.Fragment,"now"===u?{children:[n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Ready to send immediately"}),n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.4},className:"text-md font-bold text-gray-800",children:"Once you mark this automation as active, we'll send it 5 minutes from that moment"})]}:{children:[n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Currently scheduled for:"}),n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.4},className:"text-md font-bold text-gray-800",children:new Date(u).toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0,timeZoneName:"short",timeZone:d||void 0})})]})})]})})})},zSe=()=>n.jsx("div",{children:n.jsx(RSe,{title:"Set Schedule Time"})});var DSe=(e=>(e.DAYS="days",e))(DSe||{});const KSe=(e,a)=>{switch(e){case u5.EQUALS:return"Equals";case u5.NOT_EQUALS:return"Not Equals";case u5.GREATER_THAN:return a===s5.Date?"Date on or after":"Greater than";case u5.LESS_THAN:return a===s5.Date?"Date on or before":"Less than";case u5.EXISTS:return"Exists";case u5.EQUALS_MONTH_DAY:return"Month and Day Matches";case u5.EQUALS_MONTH_DAY_YEAR:return"Month, Day, and Year Matches";case u5.BETWEEN_MONTH_DAY:return"Between Month Day";case u5.BETWEEN_MONTH_DAY_YEAR:return"Between Month Day Year";case u5.ARRAY_CONTAINS:return"Is One Of";default:return e}},OSe={email:"Email Address",phone:"Phone Number",firstName:"First Name",lastName:"Last Name"},HSe=({options:e,value:a,onChange:t,placeholder:i,className:o="",disableInput:s=!1})=>{const[l,u]=r.useState(!1);return n.jsxs(are,{modal:!0,open:l,onOpenChange:u,children:[n.jsx(nre,{asChild:!0,children:n.jsxs(k5,{"aria-expanded":l,className:vm("w-full overflow-hidden justify-between",o),variant:"outline",children:[a?e.find((e=>e.value===a))?.label:i,n.jsx(Rc,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),n.jsx(tre,{className:vm("w-full min-w-[120px] max-w-[600px] p-0",o),children:n.jsxs(Nge,{children:[!s&&n.jsx(_ge,{placeholder:`${i}...`}),n.jsxs(Pge,{children:[n.jsxs(Lge,{children:["No ",i.toLowerCase()," found."]}),n.jsx(jge,{children:e.map((e=>n.jsxs(Bge,{value:e.value,onSelect:e=>{t(e===a?"":e),u(!1)},children:[n.jsx(_c,{className:vm("mr-2 h-4 w-4",a===e.value?"opacity-100":"opacity-0")}),e.label]},e.id||e.value)))})]})]})})]})};var ISe="Switch",[GSe,FSe]=G6(ISe),[VSe,JSe]=GSe(ISe),USe=r.forwardRef(((e,a)=>{const{__scopeSwitch:t,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),v=nq(a,(e=>g(e))),f=r.useRef(!1),y=!p||(m||!!p.closest("form")),[k=!1,b]=J6({prop:o,defaultProp:s,onChange:d});return n.jsxs(VSe,{scope:t,checked:k,disabled:u,children:[n.jsx(Y6.button,{type:"button",role:"switch","aria-checked":k,"aria-required":l,"data-state":$Se(k),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:v,onClick:I6(e.onClick,(e=>{b((e=>!e)),y&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())}))}),y&&n.jsx(ZSe,{control:p,bubbles:!f.current,name:i,value:c,checked:k,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"}})]})}));USe.displayName=ISe;var WSe="SwitchThumb",qSe=r.forwardRef(((e,a)=>{const{__scopeSwitch:t,...i}=e,r=JSe(WSe,t);return n.jsx(Y6.span,{"data-state":$Se(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:a})}));qSe.displayName=WSe;var ZSe=e=>{const{control:a,checked:t,bubbles:i=!0,...o}=e,s=r.useRef(null),l=Spe(t),u=i7(a);return r.useEffect((()=>{const e=s.current,a=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(a,"checked").set;if(l!==t&&n){const a=new Event("click",{bubbles:i});n.call(e,t),e.dispatchEvent(a)}}),[l,t,i]),n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...o,tabIndex:-1,ref:s,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function $Se(e){return e?"checked":"unchecked"}var YSe=USe,QSe=qSe;const XSe=r.forwardRef((({className:e,...a},t)=>n.jsx(YSe,{className:vm("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input/50",e),...a,ref:t,children:n.jsx(QSe,{className:vm("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})));XSe.displayName=YSe.displayName;const eAe=({onSelect:e,date:a,placeholder:t="Pick a date",monthDayOnly:i=!1})=>n.jsxs(are,{modal:!0,children:[n.jsx(nre,{asChild:!0,children:n.jsxs(k5,{variant:"outline",className:vm("w-[200px] justify-start text-left font-normal h-9",!a&&"text-muted-foreground"),children:[n.jsx(Nc,{className:"mr-2 h-4 w-4"}),a?eue(a,i?"MMMM d":"PPP"):n.jsx("span",{children:t})]})}),n.jsx(tre,{className:"w-auto p-0",align:"start",children:n.jsx(jSe,{mode:"single",selected:a,onSelect:e,initialFocus:!0})})]}),aAe=e=>void 0===e.value||!("number"!=typeof e.value||e.value<0)&&(e.unit===DSe.DAYS&&(("before"===e.direction||"after"===e.direction)&&"relative"===e.type)),nAe=({fieldType:e,operator:a,value:t,onChange:i,options:o,toast:s})=>{const l=t.length>0&&"object"==typeof t[0]&&"type"in t[0]&&"relative"===t[0].type,u=t.length>0&&"object"==typeof t[0]&&"startDate"in t[0]&&"endDate"in t[0],[c,d]=r.useState((e===s5.Date||e===s5.DateTime)&&t.length>0&&t[0]instanceof Date?t[0]:void 0),[m,h]=r.useState(l),[p,g]=r.useState(l?t[0]:{type:"relative",value:0,unit:DSe.DAYS,direction:"before"}),[v,f]=r.useState(u?t[0]:void 0),[y,k]=r.useState(!1);if(r.useEffect((()=>{a!==u5.EQUALS_MONTH_DAY&&a!==u5.EQUALS_MONTH_DAY_YEAR&&m&&(h(!1),i(c?[c]:[]))}),[a,m,c,i]),r.useEffect((()=>{if(u&&v?.startDate){k("object"==typeof v.startDate&&"type"in v.startDate)}}),[u,v]),e===s5.String||e===s5.ReachResource||e===s5.Array)return a===u5.EXISTS?null:n.jsx(Jve,{options:(o||[]).map((e=>({label:e.displayName,value:e.id}))),onValueChange:e=>{i(e)},selectedValues:t.map((e=>{const a=(o||[]).find((a=>a.id===String(e)||a.displayName===String(e)||a.id===a.displayName&&a.id===String(e)));return a?.id||String(e)})),setSelectedValues:e=>{i(e)}});if(e===s5.Date||e===s5.DateTime){const e=a===u5.EQUALS_MONTH_DAY||a===u5.EQUALS_MONTH_DAY_YEAR,t=a===u5.BETWEEN_MONTH_DAY||a===u5.BETWEEN_MONTH_DAY_YEAR,r=e=>{aAe(e)?(g(e),m&&i([e])):s({title:"Invalid relative date",description:"Please enter a valid non-negative number of days.",variant:"destructive"})},o=e=>{const a=e.startDate??v?.startDate,n=e.endDate??v?.endDate,t=a&&"object"==typeof a&&"type"in a,r=n&&"object"==typeof n&&"type"in n;if(a&&n){if(t!==r)return void s({title:"Invalid date range",description:"Both start and end dates must be of the same type (either both absolute or both relative).",variant:"destructive"});if(!t&&!r&&!(e=>!e.finalStartDate||!e.finalEndDate||e.finalStartDate<e.finalEndDate)({finalStartDate:a,finalEndDate:n}))return void s({title:"Invalid date range",description:"Start date must be before end date.",variant:"destructive"});if(t&&(!aAe(a)||!aAe(n)))return void s({title:"Invalid relative date",description:"Please enter valid relative dates.",variant:"destructive"})}f(e),a&&n&&i([{startDate:a,endDate:n}])},l=e=>{e&&(e=>e instanceof Date?!isNaN(e.getTime()):"object"==typeof e&&"type"in e&&"relative"===e.type&&aAe(e))(e)?(d(e),i([e]),h(!1)):e||(d(void 0),i([]),h(!1))},u=e=>{h(e),i(e?[p]:c?[c]:[])};return n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"min-h-[36px] flex items-center",children:[(!m||!e)&&!t&&n.jsx(eAe,{date:c,onSelect:l,monthDayOnly:a===u5.EQUALS_MONTH_DAY}),e&&m&&n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(qae,{type:"number",value:void 0===p.value?"":p.value,onChange:e=>{const a=""===e.target.value?void 0:parseInt(e.target.value,10);r({...p,value:a})},className:"w-20 h-9",min:"0","aria-label":"Relative days value"}),n.jsxs(nme,{value:p.direction,onValueChange:e=>{r({...p,direction:e})},children:[n.jsx(rme,{className:"w-[180px] h-9","aria-label":"Relative direction",children:n.jsx(ime,{placeholder:"Select direction..."})}),n.jsxs(lme,{children:[n.jsx(ume,{value:"before",children:"days before today"}),n.jsx(ume,{value:"after",children:"days after today"})]})]})]}),t&&n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"flex flex-col space-y-2",children:[n.jsx("div",{className:"flex items-center space-x-2",children:y?n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(qae,{type:"number",value:v?.startDate&&"object"==typeof v.startDate&&"type"in v.startDate?v.startDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:DSe.DAYS,direction:v?.startDate?.direction||"before"};aAe(a)&&(f({...v,startDate:a}),o({...v,startDate:a}))},className:"w-20 h-9",min:"0","aria-label":"Start date relative days"}),n.jsxs(nme,{value:v?.startDate&&"object"==typeof v.startDate&&"type"in v.startDate?v.startDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:v?.startDate?.value,unit:DSe.DAYS,direction:e};aAe(a)&&(f({...v,startDate:a}),o({...v,startDate:a}))},children:[n.jsx(rme,{className:"w-[180px] h-9",children:n.jsx(ime,{placeholder:"Select direction..."})}),n.jsxs(lme,{children:[n.jsx(ume,{value:"before",children:"days before today"}),n.jsx(ume,{value:"after",children:"days after today"})]})]}),n.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"Start"})]}):n.jsx(eAe,{placeholder:"Start date",date:v?.startDate instanceof Date||"string"==typeof v?.startDate?v.startDate instanceof Date?v.startDate:new Date(v.startDate):void 0,monthDayOnly:a===u5.BETWEEN_MONTH_DAY,onSelect:e=>{const a=e;a&&(f({...v,startDate:a}),o({...v,startDate:a}))}})}),n.jsx("div",{className:"flex items-center space-x-2",children:y?n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(qae,{type:"number",value:v?.endDate&&"object"==typeof v.endDate&&"type"in v.endDate?v.endDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:DSe.DAYS,direction:v?.endDate?.direction||"before"};aAe(a)&&(f({...v,endDate:a}),o({...v,endDate:a}))},className:"w-20 h-9",min:"0","aria-label":"End date relative days"}),n.jsxs(nme,{value:v?.endDate&&"object"==typeof v.endDate&&"type"in v.endDate?v.endDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:v?.endDate?.value,unit:DSe.DAYS,direction:e};aAe(a)&&(f({...v,endDate:a}),o({...v,endDate:a}))},children:[n.jsx(rme,{className:"w-[180px] h-9",children:n.jsx(ime,{placeholder:"Select direction..."})}),n.jsxs(lme,{children:[n.jsx(ume,{value:"before",children:"days before today"}),n.jsx(ume,{value:"after",children:"days after today"})]})]}),n.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"End"})]}):n.jsx(eAe,{placeholder:"End date",date:v?.endDate instanceof Date||"string"==typeof v?.endDate?v.endDate instanceof Date?v.endDate:new Date(v.endDate):void 0,monthDayOnly:a===u5.BETWEEN_MONTH_DAY,onSelect:e=>{const a=e;a&&(f({...v,endDate:a}),o({...v,endDate:a}))}})})]}),n.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[n.jsx(XSe,{id:"between-relative-date-switch",checked:y,onCheckedChange:e=>{if(k(e),e){const e={type:"relative",value:0,unit:DSe.DAYS,direction:"before"},a={type:"relative",value:0,unit:DSe.DAYS,direction:"before"};f({startDate:e,endDate:a}),o({startDate:e,endDate:a})}else{const e=new Date,a=new Date(e);a.setDate(a.getDate()+1),f({startDate:e,endDate:a}),o({startDate:e,endDate:a})}},"aria-label":"Toggle relative date input for between dates"}),n.jsx(Eue,{htmlFor:"between-relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})]}),e&&n.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[n.jsx(XSe,{id:"relative-date-switch",checked:m,onCheckedChange:u,"aria-label":"Toggle relative date input"}),n.jsx(Eue,{htmlFor:"relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})}if(e===s5.Number||e===s5.Integer)return a===u5.EXISTS?null:n.jsx(qae,{type:"number",value:t.length>0?String(t[0]):"",onChange:e=>i([Number(e.target.value)]),className:"w-[200px]"});if(e===s5.Boolean){if(a===u5.EXISTS)return null;const e=t.length>0&&Boolean(t[0]);return n.jsx(XSe,{checked:e,onCheckedChange:e=>i([e])})}return n.jsx(qae,{value:t.length>0?String(t[0]):"",onChange:e=>i([e.target.value]),className:"w-[200px]",disabled:!0})},tAe=({condition:e,onUpdate:t,onDuplicate:i,onDelete:r,segmentsConditions:o})=>{const{toast:s}=Ge(),l=(e=>{const a=o.conditions.find((a=>a.field===e));return a||null})(e.field)||{operators:[],type:s5.String,options:void 0},u=l.operators,c=l.type,d=o.conditions.map((e=>e.field)).map((e=>({value:e,label:OSe[e]||e})));return a.useEffect((()=>{setTimeout((()=>document.body.style.pointerEvents=""),0)}),[]),n.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch gap-2 min-w-0 w-full",children:[n.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 items-stretch gap-2 min-w-0 w-full",children:[n.jsx("div",{className:"flex-1 min-w-0 items-center flex",children:n.jsx(HSe,{options:d,value:e.field,onChange:a=>{const n=a,i=o.conditions.find((e=>e.field===n));if(!i)return;const r=i.operators.map((e=>({value:e,label:KSe(e,i.type),fieldType:i.type}))),s=r[0]?.value;let l=[];switch(i.type){case s5.Boolean:l=[!1];break;case s5.Number:l=[0];break;case s5.Date:case s5.DateTime:l=[new Date];break;case s5.String:l=i.options?.length?i.options.map((e=>e.displayName)):[];break;default:l=[]}t({...e,field:n,operator:s,value:l})},placeholder:"Select field",className:"w-full",disableInput:!0})}),n.jsxs("div",{className:"flex-1 min-w-0 max-w-xs flex gap-2 items-center",children:[(e.operator===u5.EQUALS_MONTH_DAY||e.operator===u5.EQUALS_MONTH_DAY_YEAR||e.operator===u5.BETWEEN_MONTH_DAY||e.operator===u5.BETWEEN_MONTH_DAY_YEAR)&&n.jsx("div",{className:"flex items-center",children:(e=>{let a;switch(e){case u5.EQUALS_MONTH_DAY:a="This operator will check if only the month and day are equal. This is useful for things like birthday, where year does not matter";break;case u5.EQUALS_MONTH_DAY_YEAR:a="This operator will check if only the month and day are equal. This is useful for things like appointment dates, where specific day and month is important but year does not matter";break;case u5.BETWEEN_MONTH_DAY:a="This operator will check if the date is between the two dates, but only checking the month and the day, not the year. This is helpful for things like birthday, where year does not matter";break;case u5.BETWEEN_MONTH_DAY_YEAR:a="This operator will check if the date is between the two dates, checking the month, day and year. This is helpful for things like appointment dates, where specific day, month and year is important";break;default:return null}return n.jsx(pue,{title:a})})(e.operator)}),n.jsx(HSe,{options:u.map((e=>({value:e,label:e?KSe(e,c):e}))),value:e.operator,onChange:a=>t({...e,operator:a}),placeholder:"Select operator",className:"w-full",disableInput:!0})]}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(nAe,{fieldType:c,operator:e.operator,options:"string"==typeof e.value[0]&&e.value[0]&&Array.isArray(l.options)?[...(l.options||[]).map((e=>({displayName:e.displayName,id:e.id}))),...e.value.filter((e=>!l.options?.some((a=>a.id===e||a.displayName===e)))).map((e=>({displayName:e,id:e})))]:l.options?.map((e=>({displayName:e.displayName,id:e.id}))),value:e.value,onChange:a=>t({...e,value:a}),toast:s})})]}),n.jsxs("div",{className:"flex items-center flex-shrink-0 pl-2",children:[n.jsx(k5,{size:"icon",variant:"ghost",onClick:i,children:n.jsx(Ic,{className:"h-4 w-4"})}),n.jsx(k5,{size:"icon",variant:"ghost",onClick:r,children:n.jsx(vd,{className:"h-4 w-4"})})]})]})},iAe=({onSelectStyle:e})=>{const[t,i]=a.useState(null);return n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 max-w-4xl mx-auto",children:[n.jsx(A5,{onClick:()=>{i("ai"),e("ai")},title:"Build with AI",subtitle:"Describe your audience in plain language and let AI create the conditions",icon:n.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:n.jsx(pd,{className:"w-full h-full"})})}),selected:"ai"===t}),n.jsx(A5,{onClick:()=>{i("manual"),e("manual")},title:"Build Manually",subtitle:`Create your ${_h("engage:segment")} by configuring conditions directly`,icon:n.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:n.jsx(dd,{className:"w-full h-full"})})}),selected:"manual"===t})]})},rAe=({segmentId:e,setOpen:a,setTextToSegment:t,promptBuilderStyle:i,textToSegment:r})=>n.jsx("div",{children:n.jsx(D$,{className:"",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(O$,{className:"text-3xl font-normal",children:e?`Edit ${_h("engage:segment")}`:`Create ${_h("engage:segment")}`}),n.jsxs("div",{className:"flex items-center gap-2",children:[!1===i&&!1===r&&n.jsx(kie,{children:n.jsxs(bie,{children:[n.jsx(Sie,{asChild:!0,children:n.jsx(k5,{variant:"outline",size:"sm",onClick:()=>t(!0),children:n.jsx(pd,{className:"h-4 w-3"})})}),n.jsx(Aie,{children:n.jsxs("p",{children:["Use AI to create ",_h("engage:segment")," by describing them in natural language"]})})]})}),n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>{a(!1)},className:"h-8 w-8",children:n.jsx(Ad,{className:"h-4 w-4"})})]})]})})}),oAe=({setTextToSegment:e,setSegment:t})=>{const[i,r]=a.useState(""),[o,s]=a.useState(!1),{toast:u}=Ge();return n.jsxs("div",{className:"flex flex-col gap-6 p-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Describe your audience"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Describe the audience you want to target in plain language, and our AI will create the conditions for you."})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(eY,{children:[o&&n.jsx(f5,{children:n.jsx(v5,{})}),!o&&n.jsx(f5,{children:n.jsx(Uve,{placeholder:"Describe your target audience...",className:"min-h-[120px] resize-none",value:i,onChange:e=>r(e.target.value)})})]}),n.jsx("div",{className:"flex justify-end gap-2",children:n.jsxs(k5,{onClick:async()=>{if(!i)return void u({title:"Please enter a description",description:"Please enter a description of your target audience",variant:"destructive"});s(!0);const a=await(async e=>(await Pe(`${l}/text-to-segment`,{method:"POST",body:JSON.stringify({text:e})})).data)(i);a.success&&a.conditions?(u({title:`${_h("engage:segment")} conditions built successfully 🚀`,description:`Your ${_h("engage:segment")} conditions have been built successfully`}),t(a.conditions)):u({title:`${_h("engage:segment")} build failed`,description:"Please try again",variant:"destructive"}),e(!1),s(!1)},children:[n.jsx(pd,{className:"h-4 w-4"}),"Generate ",_h("engage:segment")]})})]})]})};function sAe({segmentId:e,setOpen:a,onSegmentUpdated:t}){const{toast:i}=Ge(),o=void 0===e,[s,l]=r.useState(!1),[u,c]=r.useState({version:"1.0",id:"",name:"",description:"",logic:"AND",conditions:[]}),{segment:d,isLoading:m}=r5(e||""),{updateSegment:h}=o5(e),{createSegment:p,isCreating:g,segmentsConditions:v}=n5(),[f,y]=r.useState(!1),[k,b]=r.useState(!!o);r.useEffect((()=>{v&&c(d?{version:"1.0",id:d.id,name:d.name,description:d.description,logic:"AND",conditions:d.conditions}:{version:"1.0",id:"",name:"",description:"",logic:"AND",conditions:[{field:v.conditions[0].field,operator:v.conditions[0].operators[0],value:[]}]})}),[d,v]);const S=e=>e.value.some((e=>"object"==typeof e&&"type"in e&&"relative"===e.type)),A=e=>e.value.some((e=>"object"==typeof e&&"startDate"in e&&"endDate"in e));if(!v||m)return n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(v5,{})});return n.jsxs(n.Fragment,{children:[n.jsx(rAe,{segmentId:e,setOpen:a,setTextToSegment:y,promptBuilderStyle:k,textToSegment:f},"segment-builder-header"),k?n.jsx(f5,{children:n.jsx(iAe,{onSelectStyle:e=>{"ai"===e&&y(!0),b(!1)}})},"prompt-builder-style"):n.jsx(f5,{children:n.jsxs("div",{className:"flex flex-1 flex-col",children:[n.jsx("div",{className:"flex flex-1 flex-col px-8 py-2",children:n.jsx("div",{className:"flex flex-1 flex-col gap-4 overflow-visible",children:n.jsx(eY,{children:f?n.jsx(f5,{children:n.jsx(oAe,{setTextToSegment:y,setSegment:e=>c({...u,conditions:e})})}):n.jsxs(f5,{children:[n.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex items-center gap-0",children:[n.jsx(Eue,{className:"text-muted-foreground text-xs",children:"Name"}),n.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),n.jsx(qae,{placeholder:`${_h("engage:segment")} name`,value:u.name,onChange:e=>c({...u,name:e.target.value})})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(Eue,{className:"text-muted-foreground text-xs",children:"Description"}),n.jsx(qae,{placeholder:`${_h("engage:segment")} description`,value:u.description,onChange:e=>c({...u,description:e.target.value})})]})]}),u.conditions.length>0&&n.jsx("div",{className:"flex-1 overflow-y-auto pb-8",children:n.jsx("div",{className:"grid",children:n.jsx(eY,{mode:"popLayout",children:u.conditions.map(((e,a)=>n.jsxs(K4.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{type:"spring",stiffness:300,damping:30,mass:.5},children:[a>0&&n.jsxs(K4.div,{className:"relative flex items-center gap-3 py-1",initial:{opacity:0},animate:{opacity:1},transition:{delay:.1},children:[n.jsx(K4.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}}),n.jsx(K4.span,{className:"text-muted-foreground text-xs",initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},children:"AND"}),n.jsx(K4.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}})]}),n.jsx(tAe,{condition:e,onUpdate:e=>((e,a)=>{const n=[...u.conditions];n[e]=a,c({...u,conditions:n})})(a,e),segmentsConditions:v,onDuplicate:()=>(e=>{const a=[...u.conditions];a.splice(e+1,0,{...u.conditions[e]}),c({...u,conditions:a})})(a),onDelete:()=>(e=>{const a=u.conditions.filter(((a,n)=>n!==e));c({...u,conditions:a})})(a)})]},`${e.field}-${e.operator}-${a}`)))})})})]})})})}),n.jsx("div",{className:"border-t px-8 py-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(k5,f?{variant:"secondary",onClick:()=>y(!1),children:[n.jsx(dd,{className:"h-4 w-4"}),"Manual Builder"]}:{variant:"secondary",onClick:()=>{c({...u,conditions:[...u.conditions,{field:v.conditions[0].field,operator:v.conditions[0].operators[0],value:[]}]})},children:[n.jsx(sd,{className:"h-4 w-4"}),"Add Condition"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(k5,{variant:"destructive",onClick:()=>a(!1),children:"Cancel"}),n.jsx(k5,{variant:"default",onClick:async()=>{if(!u.name)return void i({title:"Name is required",description:"Please ensure all fields are filled out",variant:"destructive"});const{valid:n,error:r}=(e=>{for(const a of e){if(!a.field||!a.operator)return{valid:!1,error:"Please ensure all fields are filled out for condition"};if(a.operator!==u5.EXISTS&&0===a.value.length)return{valid:!1,error:`Please ensure a value is selected for ${a.field}`};if(a.operator===u5.EXISTS&&a.value.length>0)return{valid:!1,error:`EXISTS operator can only be used with an empty array for ${a.field}`};if(S(a)&&a.operator!==u5.EQUALS_MONTH_DAY&&a.operator!==u5.EQUALS_MONTH_DAY_YEAR)return{valid:!1,error:`Relative dates can only be used with the month and day or month, day, and year operator for ${a.field}`};if(S(a)&&void 0===a.value[0].value)return{valid:!1,error:`Please select a value for the relative date for ${a.field}`};if(A(a)&&a.operator!==u5.BETWEEN_MONTH_DAY&&a.operator!==u5.BETWEEN_MONTH_DAY_YEAR)return{valid:!1,error:`Between dates can only be used with the between month day or between month day year operator for ${a.field}`};if(A(a)&&a.value.length>1)return{valid:!1,error:`Between dates can only have a single value for ${a.field}`};if(A(a)){const e=a.value[0];if(!e.startDate||!e.endDate)return{valid:!1,error:`Please ensure both a start and end date are selected for ${a.field}`};if(e.startDate instanceof Date&&e.endDate instanceof Date&&e.startDate>e.endDate)return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("type"in e.startDate&&"relative"===e.startDate.type&&"type"in e.endDate&&"relative"===e.endDate.type){if(!e.startDate.value||!e.endDate.value)return{valid:!1,error:`Please ensure both a start and end date are selected for ${a.field}`};if(e.startDate.direction!==e.endDate.direction)return{valid:!1,error:`Start and end date must be of the same direction for ${a.field}`};const n=e=>{if(e.unit===DSe.DAYS)return e.value??0;throw U4(e.unit,DSe)};if("before"===e.startDate.direction&&n(e.startDate)>n(e.endDate))return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("after"===e.startDate.direction&&n(e.startDate)<n(e.endDate))return{valid:!1,error:`Start date must be after end date for ${a.field}`}}}}return{valid:!0,error:void 0}})(u.conditions);if(!n)return void i({title:"Conditions are invalid",description:r??"Please ensure all fields are filled out",variant:"destructive"});const o=u.conditions.map((e=>{const a=v?.conditions.find((a=>a.field===e.field));return a?.type===s5.Date&&(e.value=e.value.map((e=>e instanceof Date?e.toISOString().split("T")[0]:e))),e}));l(!0);try{e&&d?h({name:u.name,description:u.description,conditions:o},{onSuccess:()=>{i({title:`${_h("engage:segment")} updated successfully`}),a(!1),t?.(e)},onError:()=>{i({title:`Error updating ${_h("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}}):p({name:u.name,description:u.description,conditions:u.conditions},{onSuccess:e=>{i({title:`${_h("engage:segment")} created successfully`}),t?.(e?.id??!1),a(!1)},onError:()=>{i({title:`Error creating ${_h("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}})}catch(s){i({title:`Error saving ${_h("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}finally{l(!1)}},disabled:s||g,children:s||g?n.jsxs(n.Fragment,{children:[n.jsx(Zc,{className:"mr-2 h-4 w-4 animate-spin"}),e?"Updating...":"Creating..."]}):e?"Update":"Create"})]})]})})]})},"manual-builder-style")]})}function lAe({open:e,setOpen:a,segmentId:t,onSegmentUpdated:i}){return n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"flex max-h-[86vh] flex-col gap-0 overflow-visible max-w-6xl w-full",hideCloseButton:!0,children:[n.jsxs(lq,{children:[n.jsxs(O$,{children:[_h("engage:segment")," Builder"]}),n.jsxs(H$,{children:["Build a ",_h("engage:segment")," to target your audience"]})]}),n.jsx(sAe,{segmentId:t,setOpen:a,onSegmentUpdated:e=>{i?.(e),a(!1)}})]})})}const uAe=()=>n.jsx(pue,{title:`These are estimated numbers of ${_h("engage:user",{count:2}).toLocaleLowerCase()} that are matched. The actual count may change at the time of sending. You can see the breakdown of who have opted into email or sms.`}),cAe=({value:e,label:a,percentage:t,variant:i,isLoading:r,selected:o})=>n.jsxs("div",{className:"rounded-md border-2 border-muted-foreground/20 px-2 pt-2 pb-3 duration-300 ease-in-out overflow-x-auto max-w-full min-w-0 "+(o?"scale-[1.02] [border-color:hsl(var(--reach-primary))] shadow-lg":""),style:{containerType:"inline-size"},"data-card-container":!0,children:[n.jsxs("div",{className:"flex flex-col gap-1 items-start w-full min-w-0",children:[n.jsx("div",{className:"flex items-baseline gap-2 w-full min-w-0 @container/num",children:r?n.jsx("span",{className:"animate-pulse",children:"..."}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-semibold pl-2 break-words max-w-full min-w-0 truncate\n text-xl @[250px]/card:text-2xl @[350px]/card:text-3xl @[500px]/card:text-4xl text-primary",children:e.toLocaleString()}),void 0!==t&&e.toLocaleString().replace(/,/g,"").length<5&&n.jsxs("span",{className:"text-muted-foreground/50 text-sm hidden @[120px]/num:inline",children:["(",t,"%)"]})]})}),n.jsx("span",{className:`px-2 sm:px-2.5 py-1 text-xs font-medium rounded-lg ${{default:"bg-gray-100/50 text-gray-700",blue:"bg-blue-100/50 text-blue-700",green:"bg-green-100/50 text-green-700"}[i]}`,children:a})]}),n.jsx("p",{className:"text-sm text-muted-fore hidden @[250px]/card:inline mt-1",children:1===e?"contact":"contacts"})]}),dAe=({countResponse:e})=>{const t=a.useMemo((()=>e?.recipients?e.recipients.reduce(((a,n)=>({total:e.count,emails:a.emails+(n.email?1:0),phones:a.phones+(n.phone?1:0)})),{total:0,emails:0,phones:0}):{total:0,emails:0,phones:0}),[e]),i=e=>Math.round(e/(t.total||1)*100);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Lye,{children:"Estimated Matches"}),n.jsx(uAe,{})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 md:mb-6 w-full gap-4 mt-3 px-1",children:[n.jsx(cAe,{value:t.total,label:"Total",variant:"default",isLoading:void 0===e}),n.jsx(cAe,{value:t.emails,label:"Subscribed to Email",percentage:i(t.emails),variant:"blue",isLoading:void 0===e}),n.jsx(cAe,{value:t.phones,label:"Subscribed to SMS",percentage:i(t.phones),variant:"green",isLoading:void 0===e})]})]})},mAe=e=>{const a=`${e.firstName||""} ${e.lastName||""}`.trim();return a||(e.firstName?e.firstName:e.lastName?e.lastName:e.email?e.email:e.phone?e.phone:`Unnamed ${_h("engage:user")}`)},hAe=({recipients:e})=>e?.length?n.jsx("div",{className:"bg-foreground/5 rounded-lg h-full relative overflow-hidden",children:n.jsx("div",{className:"absolute inset-0 w-full h-full overflow-y-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{className:"sticky top-0 bg-foreground/5 backdrop-blur-sm",children:n.jsxs("tr",{children:[n.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Name"}),n.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Contact"})]})}),n.jsx("tbody",{className:"divide-y divide-gray-200/50",children:e.map(((e,a)=>n.jsxs("tr",{className:"hover:bg-white/50 transition-colors",children:[n.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-gray-900",children:mAe(e)}),n.jsx("td",{className:"px-3 sm:px-4 py-3",children:n.jsxs("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:[e.email&&n.jsx("span",{className:"px-2 sm:px-2.5 py-1 text-xs font-medium bg-blue-100/50 text-blue-700 rounded-lg",children:"Email"}),e.phone&&n.jsx("span",{className:"px-2 sm:px-2.5 py-1 text-xs font-medium bg-green-100/50 text-green-700 rounded-lg",children:"Phone"})]})})]},a)))})]})})}):null,pAe=({onSelectionChange:e,defaultValue:t="all",canEditAudience:i=!0})=>{const[r,o]=a.useState(t),s=a=>{i&&(o(a),e?.(a))};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Lye,{children:"Filter"}),!i&&n.jsx(pue,{title:"You cannot edit the audience unless you are in draft mode"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4 p-1",children:[n.jsx(A5,{onClick:()=>s("all"),title:`All ${_h("engage:user",{count:2})}`,subtitle:"Send to everyone",icon:n.jsx(w5.UsersIcon,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"all"===r,disabled:!i}),n.jsx(A5,{onClick:()=>s("segments"),title:`Select ${_h("engage:user",{count:2})}`,subtitle:`Choose from ${_h("engage:segment",{count:2})}`,icon:n.jsx(w5.UserEdit,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"segments"===r,disabled:!i})]})]})},gAe=({segments:e,allSegments:t,onAddSegment:i,onRemoveSegment:r,setOpenCreateSegmentDialog:o,canEditAudience:s=!0})=>{const[l,u]=a.useState([]),c=t.map((e=>({label:e.name,value:e.id})));return a.useEffect((()=>{u(e)}),[e]),n.jsx("div",{children:n.jsx(Jve,{canOpen:s,selectedValues:l,setSelectedValues:u,options:c,onValueChange:a=>{const n=a.filter((a=>!e.includes(a))),t=e.filter((e=>!a.includes(e)));n.forEach(i),t.forEach(r)},placeholder:"Select segments",maxCount:5,extraCommandItems:[e=>n.jsxs(Bge,{onSelect:()=>{e(!0),o(!0)},className:"cursor-pointer",children:[n.jsx(w5.PlusIcon,{className:"w-4 h-4"}),"New"]},"new-segment")]})})},vAe=({includedSegments:e,excludedSegments:t,handleAddSegment:i,handleRemoveSegment:r,setOpenCreateSegmentDialog:o,segments:s,defaultIsExcludeOpen:l=!1,canEditAudience:u=!0})=>{const[c,d]=a.useState(l);return n.jsxs("div",{children:[n.jsx(gAe,{segments:e,allSegments:s||[],onAddSegment:e=>i(e,"include"),onRemoveSegment:e=>r(e,"include"),setOpenCreateSegmentDialog:o}),n.jsx("div",{className:"border-t border-gray-200 my-8"}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(k5,{onClick:()=>{u&&d(!c)},className:"flex items-center gap-1 transition-colors",size:"sm",children:[n.jsx(K4.div,{animate:{rotate:c?180:0},transition:{duration:.2},children:n.jsx(w5.DropdownMenuTrigger,{className:"w-5 h-5"})}),n.jsx("span",{children:"Don't send to"})]}),n.jsx(eY,{children:c&&n.jsx(K4.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeInOut"},children:n.jsx(gAe,{canEditAudience:u,segments:t,allSegments:s||[],onAddSegment:e=>i(e,"exclude"),onRemoveSegment:e=>r(e,"exclude"),setOpenCreateSegmentDialog:o})})})]})]})},fAe=({title:e="Preview Audience"})=>{const t=d5(),[i,r]=a.useState("all"),[o,s]=a.useState(t?.includeSegmentIds||[]),[l,u]=a.useState(t?.excludeSegmentIds||[]),[c,d]=a.useState(!1),[m,h]=a.useState(!1),{segments:p,isLoading:g}=t5(),{updateAutomation:v}=ta(t?.id??""),[f,y]=a.useState(void 0),k=1===o.length&&0===l.length&&void 0!==p?.find((e=>e.type===l5.ALL_USERS&&e.id===o[0]));a.useEffect((()=>{t&&!m&&(1===o.length&&void 0!==p?.find((e=>e.type===l5.ALL_USERS&&e.id===o[0]))?r("all"):r("segments"),e5({includeSegments:o,excludeSegments:l}).then((e=>{y(e)})),h(!0))}),[t,k,m,o,l,p]);a.useEffect((()=>{t&&m&&(JSON.stringify(o)===JSON.stringify(t.includeSegmentIds)&&JSON.stringify(l)===JSON.stringify(t.excludeSegmentIds)||(v({includeSegments:o,excludeSegments:l}),e5({includeSegments:o,excludeSegments:l}).then((e=>{y(e)}))))}),[o,l,t,m,v]);const b=t?.status===da.DRAFT;return n.jsxs(jye,{title:e,children:[!g&&p&&m?n.jsxs("div",{className:"flex gap-8 w-full pb-4 px-4",children:[n.jsxs("div",{className:"flex flex-col flex-1 relative overflow-y-auto pb-4 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",children:[n.jsx(dAe,{countResponse:f}),n.jsx(pAe,{onSelectionChange:e=>{if(r(e),"all"===e){const e=p?.find((e=>e.type===l5.ALL_USERS));if(!e)return;s([e.id]),u([])}},defaultValue:i,canEditAudience:b}),n.jsx(eY,{children:"segments"===i&&n.jsx(K4.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3,ease:"easeInOut"},className:"w-full pt-4",children:n.jsx(vAe,{canEditAudience:b,includedSegments:o,excludedSegments:l,handleAddSegment:(e,a)=>{"include"===a?s((a=>[...a,e])):u((a=>[...a,e]))},handleRemoveSegment:(e,a)=>{"include"===a?s((a=>a.filter((a=>a!==e)))):u((a=>a.filter((a=>a!==e))))},setOpenCreateSegmentDialog:d,segments:p,defaultIsExcludeOpen:l.length>0})})})]}),n.jsx("div",{className:"flex flex-col flex-1 relative overflow-hidden",children:f?.recipients&&n.jsx(hAe,{recipients:f.recipients})})]}):n.jsx("div",{children:n.jsx(v5,{text:["Fetching segments","Finishing up"]})}),n.jsx(lAe,{open:c,setOpen:d,onSegmentUpdated:e=>{e&&s((a=>[...a,e]))}})]})},yAe=()=>n.jsx(fAe,{title:"Select Audience"}),kAe=()=>{const{channelSenders:e}=fre(),{channelAccounts:t}=pre(),i=m5(),{updateCommunicationGroup:r}=$e(),{state:{selectedChannels:o},setSelectedChannels:s}=a.useContext(dre),l=d5(),{data:u}=Sre(),c=a.useCallback((async e=>{s(e),e.includes("email")||i?.id&&r({groupId:i?.id,params:{emailChannelSenderId:null}}),e.includes("sms")||i?.id&&r({groupId:i?.id,params:{smsChannelSenderId:null}})}),[s,r,i?.id]),d=a.useMemo((()=>wme({channelSenders:e?.results??[],channelAccounts:t?.results??[]})),[e?.results,t?.results]),m=a.useMemo((()=>ale({channelSenders:e?.results??[],channelAccounts:t?.results??[],smsApplication:u})),[e?.results,t?.results,u]);if(!o||!d||!m)return n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(v5,{text:["Fetching Content..."]})});const h=d.length>0,p=m.length>0;return n.jsx("div",{className:"flex flex-col gap-4 flex-shrink-0",children:n.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(oye,{automationType:l?.triggerMetadata?.triggerType,selectedChannels:o,setSelectedChannels:c,hasEmailChannelSenders:h,hasSmsChannelSenders:p})})})};var bAe=(e=>(e[e.SelectAudience=1]="SelectAudience",e[e.SelectSenders=2]="SelectSenders",e[e.EditEmailContent=3]="EditEmailContent",e[e.EditSmsContent=4]="EditSmsContent",e[e.Schedule=5]="Schedule",e[e.PreviewAndSend=6]="PreviewAndSend",e))(bAe||{});const SAe="https://assets.embedreach.com/defaults/logo-placeholder-128.png",AAe="You have not uploaded a custom logo. Please make sure to double check your email before sending!",wAe=()=>{const e=d5(),n=m5(),{state:{selectedChannels:t}}=a.useContext(dre),{data:i}=Sre(),{channelSenders:r}=fre(),{channelAccounts:o}=pre(),s=ale({channelSenders:r?.results??[],channelAccounts:o?.results??[],smsApplication:i}),l=a.useCallback((async a=>e?await(async e=>{const{currentStep:a,automation:n,communicationGroup:t,selectedChannels:i,smsChannelSenders:r}=e;switch(a){case bAe.SelectAudience:return{canMove:n.includeSegmentIds.length>0,errorMessage:"Please ensure you have selected at least one segment"};case bAe.SelectSenders:return{canMove:i.length>0,errorMessage:"Please ensure you have selected at least one channel"};case bAe.EditSmsContent:{const e=n.actionData?.find((e=>"send_communication"===e.actionType));if(!e)return{canMove:!1,errorMessage:"Please ensure you have selected either a email communication or text communication"};if(!t)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};const a=r.find((e=>e.channelSender.id===t.smsChannelSenderId));return a?t.smsMessageBody?a.smsApplication&&a.smsApplication.status!==ele.APPROVED?{canMove:!0,errorMessage:null,warningMessage:"You will only be able to send this message once your SMS application is approved"}:{canMove:!0,errorMessage:null}:{canMove:!1,errorMessage:"Please ensure you have a text body"}:{canMove:!1,errorMessage:"Please ensure you have selected a text sender"}}case bAe.EditEmailContent:{const e=n.actionData?.find((e=>"send_communication"===e.actionType));if(!e)return{canMove:!1,errorMessage:"Please ensure you have selected either a email communication or text communication"};if(!t)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};if(!t.emailChannelSenderId)return{canMove:!1,errorMessage:"Please ensure you have selected a email sender"};if(!t.emailHtmlBody||!t.emailSubject)return{canMove:!1,errorMessage:"Please ensure you have a email body and subject"};let a=null;return t.emailChannelSenderId&&t.emailHtmlBody&&t.emailHtmlBody.includes(SAe)&&(a=AAe),{canMove:!0,errorMessage:null,warningMessage:a}}case bAe.Schedule:{if(!n.triggerMetadata)return{canMove:!1,errorMessage:"Please make sure to select a time to send before starting!"};if(n.triggerMetadata.triggerType!==sa.ONE_TIME)return{canMove:Boolean(n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:null};if(!n.triggerMetadata?.scheduledAt)return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${_h("engage:broadcast")}`};if(!Boolean(n.triggerMetadata?.scheduledAt&&("now"===n.triggerMetadata.scheduledAt||"now"!==n.triggerMetadata.scheduledAt&&new Date(n.triggerMetadata.scheduledAt)>new Date)))return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${_h("engage:broadcast")}`};if(!Boolean(n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))))return{canMove:!1,errorMessage:"Please ensure you have set a valid email or sms communication"};const e=n.triggerMetadata;return{canMove:Boolean(e.scheduledAt&&("now"===e.scheduledAt||new Date(e.scheduledAt)>new Date)&&n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:`Please ensure you have set a valid future date for your ${_h("engage:broadcast")}`}}case bAe.PreviewAndSend:return{canMove:!0,errorMessage:null};default:ire(a,bAe)}})({currentStep:a,automation:e,communicationGroup:n,selectedChannels:t,smsChannelSenders:s}):{canMove:!1,errorMessage:`${_h("engage:broadcast")} not loaded`}),[e,n,t,s]);return{validateStep:l}},CAe=({onFinish:e,getExtraMergeFields:t,onBeforeSchedule:i})=>{const r=d5(),o=m5(),{updateAutomation:s}=ta(r?.id||""),{estimatedMatchesStats:l}=(e=>{const{data:n}=i5({automationId:e?.id??"",includeSegments:e?.includeSegmentIds??[],excludeSegments:e?.excludeSegmentIds??[]}),t=a.useMemo((()=>n?.recipients?n.recipients.reduce(((e,a)=>({emails:e.emails+(a.email?1:0),phones:e.phones+(a.phone?1:0)})),{emails:0,phones:0}):{emails:0,phones:0}),[n?.recipients]);return{estimatedMatches:n,estimatedMatchesStats:t}})(r??void 0),{state:{selectedChannels:u}}=a.useContext(dre),{validateStep:c}=wAe(),[d,m]=a.useState([]),{data:h}=Sre(),[p,g]=a.useState(!1),{channelSenders:v}=fre(),{channelAccounts:f}=pre(),{updateCommunicationGroup:y}=$e(),k=a.useRef(!1),[b,S]=a.useState(bAe.SelectAudience);if(a.useEffect((()=>{if(null!==r&&null!==o){const e=ale({channelSenders:v?.results??[],channelAccounts:f?.results??[],smsApplication:h});m((({automation:e,communicationGroup:a,selectedChannels:t,smsChannelSenders:i})=>e?[{id:"audience",title:"Audience",step:1,isValid:()=>e.includeSegmentIds.length>0,content:n.jsx(vue,{content:n.jsx(yAe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===sa.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},{id:"senders",title:"Channel Senders",step:2,isValid:()=>0!==t.length,content:n.jsx(vue,{content:n.jsx(kAe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===sa.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},...t.includes("email")?[{id:"edit-email-content",title:"Edit Email Content",step:3,isValid:()=>{const n=e.actionData?.find((e=>"send_communication"===e.actionType));return!!n&&!!a.emailChannelSenderId&&!(!a.emailHtmlBody||!a.emailSubject)},content:n.jsx(vue,{content:n.jsx(Cme,{})},"audience"),footerConfig:{backText:"",nextText:"",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],...t.includes("sms")?[{id:"edit-sms-content",title:"Edit SMS Content",step:4,isValid:()=>{const n=e.actionData?.find((e=>"send_communication"===e.actionType));return!!(n&&n.actionMetadata.communicationGroupId&&a.smsChannelSenderId&&a.smsMessageBody)},content:n.jsx(vue,{content:n.jsx($ve,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],{id:"schedule",title:"Schedule",step:5,isValid:()=>Boolean(e.triggerMetadata?.triggerType===sa.ONE_TIME&&e.triggerMetadata?.scheduledAt&&("now"===e.triggerMetadata.scheduledAt||"now"!==e.triggerMetadata.scheduledAt&&new Date(e.triggerMetadata.scheduledAt)>new Date)&&e.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),content:n.jsx(vue,{className:"flex-1",content:n.jsx(zSe,{})},"schedule"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}},{id:"send",title:"Send",step:6,isValid:()=>Boolean(e.triggerMetadata?.triggerType===sa.ONE_TIME&&e.triggerMetadata?.scheduledAt&&("now"===e.triggerMetadata.scheduledAt||"now"!==e.triggerMetadata.scheduledAt&&new Date(e.triggerMetadata.scheduledAt)>new Date(Date.now()+18e4))&&e.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),content:n.jsx(vue,{className:"flex-1",content:n.jsx(Rye,{})},"send"),footerConfig:{backText:"Back",nextText:e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&"now"===e.triggerMetadata.scheduledAt?"Send Now":"Schedule",hideBack:!1,backDisabled:!1,getInfoTooltipTitle:()=>{const e=i.find((e=>e.channelSender.id===a.smsChannelSenderId));if(e&&null!==e.smsApplication&&e.smsApplication?.status!==ele.APPROVED)return"You cannot send this yet if you have selected a text channel and don't have an approved SMS application. Please save as draft and try again later."},nextDisabled:()=>{const e=i.find((e=>e.channelSender.id===a.smsChannelSenderId));return!(!a.smsChannelSenderId||e&&(null===e.smsApplication||e.smsApplication?.status===ele.APPROVED))||null===a.smsChannelSenderId&&null===a.emailChannelSenderId}}}]:[])({automation:r,communicationGroup:o,selectedChannels:u,smsChannelSenders:e}))}}),[r,o,t,u,v?.results,f?.results,h]),a.useEffect((()=>{t&&!k.current&&t().then((e=>{o?.id&&(k.current=!0,y({groupId:o?.id,params:{extraMergeFields:e}}))}))}),[t,o,y]),!(r&&b&&o&&d.length))return n.jsx("div",{className:"flex-1 flex flex-col @container justify-center items-center h-[500px]",children:n.jsx(v5,{text:[`Fetching ${_h("engage:broadcast")} data`,"Finishing up"]})});const A=async()=>{const{canMove:a,errorMessage:n,warningMessage:t}=await c(b);a?(t&&Ie({title:t,variant:"warning"}),b===bAe.PreviewAndSend?await(async()=>{if(null===o.emailChannelSenderId&&null===o.smsChannelSenderId)return void Ie({title:"Oops!",description:"Please select an email sender or sms sender",variant:"destructive"});const a=ale({channelSenders:v?.results??[],channelAccounts:f?.results??[],smsApplication:h});if(o.smsChannelSenderId){const e=a.find((e=>e.channelSender.id===o.smsChannelSenderId));if(e?.smsApplication?.application&&e?.smsApplication.status!==ele.APPROVED)return void Ie({title:"Oops!",description:"You cant schedule a communication with a pending sms application. Please save as a draft and re-try once the application is approved."})}if(i)try{const a=await i({estimatedEmailRecipients:l?.emails||0,estimatedSmsRecipients:l?.phones||0});!0===a?s({status:da.ACTIVE},{onSuccess:()=>{Ie({title:`${_h("engage:broadcast")} scheduled!`}),e()},onError:()=>{Ie({title:"Oops!",description:"Please contact your administrator",variant:"destructive"})}}):Ie({title:"Oops!",description:a,variant:"destructive"})}catch(n){Ie({title:"Oops!",description:"An error occurred while checking scheduling conditions",variant:"destructive"})}else s({status:da.ACTIVE}),Ie({title:`${_h("engage:broadcast")} scheduled!`}),e()})():S(b===bAe.SelectSenders&&1===u.length&&"sms"===u[0]||b===bAe.EditEmailContent&&1===u.length&&"email"===u[0]?b+2:b+1)):Ie({title:"Oops!",description:n,variant:"destructive"})},w=()=>{b>bAe.SelectAudience&&S(b===bAe.EditSmsContent&&1===u.length&&"sms"===u[0]?b-2:b-1)},C=()=>{e()};return n.jsxs("div",{className:"flex-1 flex flex-col @container h-full min-h-0",children:[n.jsxs("header",{className:"w-full flex items-center gap-4 h-16 px-6",children:[n.jsx("h1",{className:"text-xl font-bold leading-none",children:r.name}),n.jsx("div",{className:"flex items-center gap-4",children:n.jsx(B5,{variant:rue(r.status),children:rre({status:r.status,automationType:r.triggerType})})})]}),n.jsxs("main",{className:"flex gap-4 flex-1 min-h-0",children:[n.jsx("div",{className:"hidden @[1000px]:block",children:n.jsx("nav",{className:"space-y-0 w-50 self-start pr-6 pl-8 pt-4 ",children:d.map((e=>n.jsx("div",{className:`\n rounded-md transition-colors\n ${e.step===b?"bg-[var(--reach-secondary)] text-[var(--reach-primary-foreground)] font-medium":e.step<b?"text-muted-foreground hover:bg-muted":"text-muted-foreground/60"}\n `,children:n.jsx(V5,{label:e.title,isActive:e.step===b,isCompleted:e.isValid(),onClick:async()=>{if(!p)if(e.step>b){const{canMove:a,errorMessage:n,warningMessages:t}=await(async e=>{if(e<=b)return{canMove:!0,errorMessage:null};g(!0);try{const a=[];for(let n=b;n<e;n++){const{canMove:e,errorMessage:t,warningMessage:i}=await c(n);if(!e)return{canMove:e,errorMessage:t};i&&a.push(i)}return{canMove:!0,errorMessage:null,warningMessages:a}}finally{g(!1)}})(e.step);if(a){if(t&&t.length>0)for(const e of t)Ie({title:e,variant:"warning"});S(e.step)}else n&&Ie({title:"Cannot navigate to this step",description:n,variant:"destructive"})}else S(e.step)}})},e.step)))})}),n.jsx("section",{className:"flex-1 mr-6 w-full relative rounded-xl bg-gray-100 ml-6 @[1000px]:ml-0",children:n.jsx("div",{className:" overflow-y-auto top-0 left-0 right-0 bottom-0 flex-1 h-full flex-col flex",children:n.jsx(eY,{children:n.jsx(f5,{className:"pt-0 h-full",children:d.find((e=>e.step===b))?.content},b)})})})]}),n.jsx("footer",{className:"w-full flex justify-end shadow-md z-10 items-center h-16 px-6",children:n.jsx(gue,{handleSkipAndSaveAsDraft:C,handleBack:w,handleNext:A,hideBack:d.find((e=>e.step===b))?.footerConfig.hideBack??!1,backText:d.find((e=>e.step===b))?.footerConfig.backText??"Back",nextText:d.find((e=>e.step===b))?.footerConfig.nextText??"Next",backDisabled:d.find((e=>e.step===b))?.footerConfig.backDisabled??!1,nextDisabled:d.find((e=>e.step===b))?.footerConfig.nextDisabled()??!1,getInfoTooltipTitle:d.find((e=>e.step===b))?.footerConfig.getInfoTooltipTitle??void 0})})]})},MAe=({children:e,actionId:t})=>{const{setActionId:i}=a.useContext(Q4);return a.useEffect((()=>{i(t)}),[t,i]),n.jsx("div",{children:n.jsx(mre,{children:e})})},TAe=()=>n.jsxs("div",{children:[n.jsx("div",{className:E5,children:n.jsx(w5.OneTimeBroadcast,{})}),n.jsx("h3",{className:x5,children:_h("engage:broadcast")}),n.jsx("p",{className:N5,children:"Send a single message to your current list, like announcing a sale or newsletter."})]}),EAe=()=>n.jsxs("div",{children:[n.jsx("div",{className:_5,children:"Coming Soon"}),n.jsx("div",{className:E5,children:n.jsx(w5.RealtimeActivity,{})}),n.jsx("h3",{className:x5,children:"Realtime Activity"}),n.jsx("p",{className:N5,children:"Responds to immediate actions your contacts take, like abandoned carts, form submissions, or appointment bookings."})]}),xAe=({selectedType:e,setAutomationName:a,automationName:t,setAutomationDescription:i,automationDescription:r})=>n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 max-w-lg mx-auto",children:[n.jsxs("h2",{className:"text-2xl font-semibold mb-8 text-center",children:["Name Your"," ",_h(e===sa.ONE_TIME?"engage:broadcast":"engage:trigger_based")]}),n.jsxs("div",{className:"w-full space-y-6",children:[n.jsx("div",{className:"bg-gray-50 p-6 rounded-xl items-center justify-center text-center",children:(()=>{switch(e){case sa.ONE_TIME:return n.jsx(TAe,{});case sa.TRIGGER_BASED:return n.jsx(EAe,{});default:throw ire(e,sa)}})()}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[n.jsx("label",{htmlFor:"automationName",className:"block text-sm font-medium text-gray-900",children:"Name"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Only visible to your team"})]}),n.jsx(qae,{id:"automationName",type:"text",value:t,onChange:e=>a(e.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500 shadow-sm",placeholder:"e.g. April Newsletter Campaign",autoFocus:!0})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[n.jsx("label",{htmlFor:"automationDescription",className:"block text-sm font-medium text-gray-900",children:"Description"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Optional"})]}),n.jsx(Uve,{id:"automationDescription",value:r,onChange:e=>i(e.target.value),className:"w-full min-h-[80px] resize-none",placeholder:`Add any helpful context for your team. If left blank, we'll generate one for you when you start the ${_h("engage:broadcast").toLowerCase()}`})]})]})]})]}),NAe=({onClose:e,automationType:t,currentStep:i,setCurrentStep:r,getExtraMergeFields:o,onBeforeSchedule:s})=>{const{createAutomation:l,isCreating:u}=na(),[c,m]=a.useState(!1),[h,p]=a.useState(void 0),[g,v]=a.useState(void 0),[f,y]=a.useState(!1),[k,b]=a.useState(t?{name:void 0,description:void 0,type:t}:{name:void 0,description:void 0,type:void 0}),S=void 0!==k.name&&void 0!==k.type&&""!==k.name;a.useEffect((()=>{if(k.type&&!k.name&&!f){const e=new Date,a=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),n=e.toLocaleDateString([],{month:"long",day:"numeric"}),t=`${_h("engage:broadcast")} ${n} ${a}`,i="";b((e=>({...e,name:t,description:i}))),y(!0)}}),[k,f]);if(u||c)return n.jsx("div",{className:T5,children:n.jsx(v5,{text:[`Creating ${_h("engage:broadcast")}`,"Finishing up"]})});return n.jsxs("div",{className:P$("relative overflow-y-auto h-full p-8",i===b5.OneTimeWizard?"max-h-[90vh]":"h-full"),children:[n.jsx(eY,{mode:"wait",children:n.jsx(f5,{className:"h-full",children:(()=>{switch(i){case b5.ChooseAutomationType:return n.jsx(P5,{onNext:e=>{b({...k,type:e}),r(b5.SetAutomationName)}});case b5.SetAutomationName:return k.type?n.jsx(xAe,{selectedType:k.type,setAutomationName:e=>{b({...k,name:e})},automationName:k.name??"",setAutomationDescription:e=>{b({...k,description:e})},automationDescription:k.description??""}):null;case b5.OneTimeWizard:return h&&g?n.jsx(p5,{automationId:h,children:n.jsx(MAe,{actionId:g,children:n.jsx(CAe,{onFinish:()=>{e?.(h)},getExtraMergeFields:o,onBeforeSchedule:s})})}):null;default:throw U4(i,b5)}})()},i)}),i!==b5.OneTimeWizard&&n.jsx("div",{className:"pt-2",children:n.jsx(S5,{onClose:e,currentStep:i,setCurrentStep:r,isDisabled:!S,createAutomation:async()=>{if(!S||!k.name||!k.type)return;m(!0);l({name:k.name,type:k.type,description:k.description},{onSuccess:async a=>{if(a.id){const n=await(async e=>(await Pe(`${d}`,{method:"POST",body:JSON.stringify(e)})).data)({}),i=J4().toString();await je(a.id,{action:[{actionType:"send_communication",actionMetadata:{actionType:"send_communication",communicationGroupId:n.id,currentActionId:i}}]}),p(a.id),await We({automationId:a.id,actionId:i}),t===sa.ONE_TIME?(r(b5.OneTimeWizard),v(i),m(!1)):e?.(a.id)}else e?.("error")},onError:()=>{e?.("error")},onSettled:()=>{b({name:void 0,description:void 0,type:void 0})}})},disableBackButton:void 0!==t})})]})};function _Ae({open:e,setOpen:t,onClose:i,automationType:r,getExtraMergeFields:o,replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c}){const[d,m]=a.useState(r?b5.SetAutomationName:b5.ChooseAutomationType);return a.useEffect((()=>{e&&m(r?b5.SetAutomationName:b5.ChooseAutomationType)}),[e,r]),n.jsx(cq,{children:n.jsx(dq,{replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c,children:n.jsx(L$,{open:e,onOpenChange:t,children:n.jsxs(z$,{hideCloseButton:d===b5.OneTimeWizard,className:`flex max-h-[86vh] ${d===b5.OneTimeWizard?"max-w-[90vw]":"max-w-4xl"} flex-col gap-0 overflow-visible p-0`,children:[n.jsx(D$,{children:n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs(lq,{children:[n.jsx(O$,{className:"text-3xl font-normal",children:"Create Automation"}),n.jsx(H$,{children:"Create a new automation to send messages to your customers."})]})})}),n.jsx(NAe,{onClose:e=>{i?.(e),t(!1)},automationType:r,currentStep:d,setCurrentStep:m,getExtraMergeFields:o})]})})})})}const PAe=({tabs:e,activeTab:t,onTabChange:i,tabsLocation:r="left",secondaryTabs:o=!1})=>{const s=a.useRef([]),[l,u]=a.useState({width:0,left:0});a.useEffect((()=>{const a=s.current[e.findIndex((e=>e.id===t))];a&&u({width:a.offsetWidth,left:a.offsetLeft})}),[t,e]);const c=e.find((e=>e.id===t));return n.jsxs("div",{className:"flex flex-col gap-4 w-full overflow-x-hidden h-full",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{className:"relative flex items-center gap-8 "+("left"===r?"w-full justify-start":"w-full justify-center"),children:[n.jsx("div",{className:"absolute bottom-0 h-[1px] rounded-full transition-all duration-300 ease-out\n bg-gradient-to-r from-primary to-primary/90\n shadow-[0_0_8px_rgba(var(--primary-rgb),0.3)]",style:{width:`${l.width}px`,left:`${l.left}px`}}),e.map(((e,a)=>n.jsx("button",{ref:e=>s.current[a]=e,onClick:()=>i(e.id),className:P$("relative px-7 py-3 transition-all duration-200 text-lg",t!==e.id&&"text-muted-foreground",o&&"text-sm"),children:e.label},e.id)))]})}),n.jsx("div",{className:"relative overflow-hidden flex-grow min-h-0",children:n.jsx("div",{className:"relative h-full",children:c?c.content:null})})]})},LAe=e=>{if(!e)return"$0.00";const a="string"==typeof e?e.replace(/,/g,""):e,n=Number(a);return Number.isNaN(n)?"$0.00":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(n)},jAe="reach-styles-module__header___-izE2",BAe="reach-styles-module__title___n1hA9",RAe="reach-styles-module__description___EvXM-",zAe="reach-styles-module__content___okv68",DAe="reach-styles-module__footer___YA4U4",KAe=Sc("reach-styles-module__base___zJcoE",{variants:{variant:{default:"reach-styles-module__default___88Q0d",destructive:"reach-styles-module__destructive___5EWhN",outline:"reach-styles-module__outline___gj9sC",secondary:"reach-styles-module__secondary___cN5Wj"}},defaultVariants:{variant:"default"}}),OAe=r.forwardRef((({className:e,variant:a,...t},i)=>n.jsx("div",{ref:i,className:vm(KAe({variant:a}),e),...t})));OAe.displayName="Card";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(jAe,e),...a}))).displayName="CardHeader";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(BAe,e),...a}))).displayName="CardTitle";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(RAe,e),...a}))).displayName="CardDescription";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(zAe,e),...a}))).displayName="CardContent";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:vm(DAe,e),...a}))).displayName="CardFooter";const HAe=({Icon:e,title:a,value:t,tooltipText:i,change:r})=>n.jsxs(OAe,{className:"relative flex flex-col justify-between min-h-[130px] transition-all duration-300 hover:shadow-md p-4",children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsx("div",{className:"rounded-lg p-2 bg-primary/10 flex items-center justify-center",children:n.jsx(e,{className:"w-5 h-5 text-primary"})}),n.jsx("div",{className:"absolute top-3 right-3",children:n.jsx(pue,{title:i})})]}),n.jsxs("div",{className:"mt-4",children:[n.jsx("div",{className:"text-2xl font-bold leading-tight text-primary",children:t}),n.jsx(Lye,{children:a})]}),r&&n.jsx("div",{className:"absolute bottom-3 right-3",children:n.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full bg-green-100 text-green-600 text-xs font-semibold",children:r})})]}),IAe=({activeTab:e,automation:a})=>{if(!a)return null;const t={sales:[{Icon:w5.SalesAmount,title:"Order Amount",value:LAe(a.derivedRevenue),tooltipText:"Total derived revenue from this campaign"}]};return n.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:t[e].map(((e,a)=>n.jsx(HAe,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},GAe=({activeTab:e,statistics:a})=>{const t={email:[{Icon:w5.MessagesSent,title:"Emails Sent",value:a.email.numberSent,tooltipText:"Total number of emails that were successfully sent in this campaign"},{Icon:w5.OpenRate,title:"Open Rate",value:`${(100*a.email.openPercentage).toFixed(2)}%`,tooltipText:"Percentage of recipients who opened the email out of total emails delivered"},{Icon:w5.TotalBounceRate,title:"Total Bounce Rate",value:`${(100*(a.email.softBounceRate+a.email.hardBounceRate)).toFixed(2)}%`,tooltipText:"Percentage of emails that were not delivered due to permanent (hard) or temporary (soft) delivery failures"},{Icon:w5.LinksClicked,title:"Links Clicked",value:a.email.linksClicked,tooltipText:"Total number of times recipients clicked on links within the email"},{Icon:w5.SpamComplies,title:"Spam Complaints",value:`${(100*a.email.spamComplaintRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who marked this email as spam"},{Icon:w5.UnsubscribeRate,title:"Unsubscribe Rate",value:`${(100*a.email.unsubscribedRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who unsubscribed after receiving this email"}],sms:[{Icon:w5.MessagesSent,title:"SMS Sent",value:a.sms.numberSent,tooltipText:"Total number of SMS messages that were successfully sent in this campaign"}]};return n.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:t[e].map(((e,a)=>n.jsx(HAe,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},FAe=({automationId:e,includeSales:t=!1,includeSms:i=!1,automation:r})=>{const[o,s]=a.useState("email"),{statistics:l,isLoading:u}=ia(e);if(u||!l)return n.jsx("div",{className:"bg-white rounded-2xl w-full p-6 space-y-4 relative h-[14.05rem]",children:n.jsx(v5,{text:[`Fetching ${_h("engage:insight",{count:2})}`,"Finishing up"]})});const c=[{id:"email",label:`Email ${_h("engage:insight",{count:2})}`,content:n.jsx(GAe,{activeTab:"email",statistics:l})},...i?[{id:"sms",label:`SMS ${_h("engage:insight",{count:2})}`,content:n.jsx(GAe,{activeTab:"sms",statistics:l})}]:[],...t?[{id:"sales",label:`Sales ${_h("engage:insight",{count:2})}`,content:n.jsx(IAe,{activeTab:"sales",automation:r})}]:[]];return n.jsx(PAe,{tabs:c,activeTab:o,onTabChange:e=>s(e),tabsLocation:"left"})},VAe={all:["website"],content:()=>[...VAe.all,"content"],analyze:()=>[...VAe.all,"analyze"],brandSettings:()=>[...VAe.all,"brand-settings"]},JAe=async()=>(await Pe("/web-presence/brand-settings",{method:"POST"})).data,UAe=({isLoading:e,brandSettings:t,onComplete:i})=>{const[r,o]=a.useState(0),s=[{text:"Analyzing your brand palette",icon:nd},{text:"Extracting your visual identity",icon:Fc},{text:"Discovering your brand personality",icon:Jc},{text:"Crafting your email style",icon:Yc},{text:"Finalizing your brand profile",icon:Dc}];a.useEffect((()=>{if(!e)return;const a=setInterval((()=>{o((e=>{const n=e+1;return n>=s.length?(clearInterval(a),setTimeout((()=>{i()}),1500),e):n}))}),2500);return()=>clearInterval(a)}),[e,i,s.length]);return n.jsx(K4.div,{className:"flex flex-col items-center justify-center h-full w-full bg-background p-6",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6},children:n.jsxs("div",{className:"flex flex-col items-center gap-8 max-w-2xl w-full",children:[n.jsx(K4.div,t?.logoUrl?{className:"w-24 h-24 sm:w-32 sm:h-32 flex items-center justify-center rounded-xl overflow-hidden bg-card shadow-md border",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:n.jsx("img",{src:t.logoUrl,alt:"Brand Logo",className:"max-w-full max-h-full object-contain"})}:{className:"w-24 h-24 sm:w-32 sm:h-32 rounded-xl flex items-center justify-center shadow-md border bg-primary",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:t?.brandName?n.jsx("span",{className:"text-4xl sm:text-5xl font-bold text-white",children:t.brandName.charAt(0)}):n.jsx(pd,{className:"w-12 h-12 sm:w-16 sm:h-16 text-white"})}),n.jsx(K4.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-xl font-medium text-center text-foreground",children:s[r].text},`loading-${r}`),n.jsx("div",{className:"flex items-center justify-center space-x-8 sm:space-x-12",children:s.map(((e,a)=>{const t=a<=r,i=a===r;return n.jsxs(K4.div,{className:"relative flex items-center justify-center w-12 h-12 rounded-full border-2 "+(t?"bg-card shadow-md border-primary":"bg-muted border-muted-foreground/30"),initial:{scale:.8,opacity:.5},animate:{scale:i?1.1:1,opacity:t?1:.5},transition:{duration:.3},children:[n.jsx(e.icon,{className:"w-5 h-5 "+(t?"text-primary":"text-muted-foreground")}),i&&n.jsx(K4.div,{className:"absolute inset-0 rounded-full border-2 border-primary",initial:{scale:1,opacity:.8},animate:{scale:2.5,opacity:0},transition:{duration:3,repeat:1/0,ease:"easeOut"}})]},`step-${a}`)}))}),n.jsx(K4.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8,duration:.6},className:"w-full",children:n.jsx("div",{className:"h-[140px] w-full max-w-lg mx-auto p-5 bg-gradient-to-br from-card/70 to-card/40 backdrop-blur-md rounded-2xl border border-border/60 shadow-lg",children:n.jsxs("div",{className:"h-full flex flex-col justify-center",children:[0===r&&n.jsxs("div",{className:"space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80 text-center",children:"Extracted Color Palette"}),n.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[t?.primaryColor,...t?.secondaryColors||[]]?.slice(0,4).map(((e,a)=>n.jsx("div",{className:"flex flex-col items-center gap-1",children:n.jsx("div",{className:"w-10 h-10 rounded-xl border-2 border-white/50 shadow-md",style:{backgroundColor:e}})},a)))}),n.jsx("div",{className:"text-center text-xs text-muted-foreground",children:"Brand colors identified"})]}),1===r&&n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Identity"}),t?.brandName?n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xl font-bold",children:t.brandName}),t.brandTagline&&n.jsxs("div",{className:"text-sm text-muted-foreground italic px-4",children:['"',t.brandTagline,'"']}),n.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Visual identity extracted"})]}):n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Extracting brand elements..."})]}),2===r&&n.jsxs("div",{className:"text-center space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Personality"}),t?.brandPersonality?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-center gap-4",children:[t.brandPersonality.tone&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Tone"}),n.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:t.brandPersonality.tone})]}),t.brandPersonality.voice&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Voice"}),n.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:t.brandPersonality.voice})]})]}),t.brandPersonality.values&&t.brandPersonality.values.length>0&&n.jsx("div",{className:"flex justify-center gap-1 flex-wrap",children:t.brandPersonality.values.slice(0,3).map(((e,a)=>n.jsx("span",{className:"px-2 py-1 text-xs font-medium rounded-full",children:e},a)))})]}):n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand tone and voice..."})]}),3===r&&n.jsxs("div",{className:"text-center space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Email Template Preview"}),n.jsxs("div",{className:"bg-background/60 rounded-lg p-3 border border-border/30",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx("div",{className:"w-4 h-4 rounded"}),n.jsx("div",{className:"text-xs font-medium text-foreground",children:t?.brandName||"Your Brand"})]}),n.jsxs("div",{className:"text-xs text-muted-foreground text-left",children:["Email styling applied with your brand colors",t?.brandPersonality?.tone&&`, ${t.brandPersonality.tone} tone`,", and visual identity"]})]})]}),4===r&&n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Kit Complete"}),n.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Identity"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.brandName?"✓":"—"})]}),n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Colors"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.primaryColor?"✓":"—"})]}),n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Personality"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.brandPersonality?.tone?"✓":"—"})]})]})]}),(0===r&&!t?.primaryColor&&!t?.colorPalette||1===r&&!t?.brandName||2===r&&!t?.brandPersonality)&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand data..."}),n.jsx("div",{className:"flex justify-center gap-1 mt-2",children:[...Array(3)].map(((e,a)=>n.jsx(K4.div,{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/50",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:1,repeat:1/0,delay:.2*a}},a)))})]})]})})},`content-${r}`)]})})},WAe=({setAutoParse:e,onBrandSettingsGenerated:t,onForceRefresh:i})=>{const{data:r,updateWebsite:o,isUpdatingWebsite:s,updateBrandSettings:l}=kpe(),u=ke({mutationFn:JAe,mutationKey:VAe.brandSettings()}),[c,d]=a.useState(r?.website||""),[m,h]=a.useState(!1),[p,g]=a.useState(null),[v,f]=a.useState(!1),[y,k]=a.useState(!1),b=()=>{e(!1)};return y&&p?n.jsx(K4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 h-full",children:n.jsx(ZAe,{initialBrandSettings:p,onSave:()=>{p&&(l({logoBase64:p.logo_base64,primaryColor:p.primaryColor,secondaryColors:p.secondaryColors,brandTagline:p.brandTagline,brandName:p.brandName,brandPersonality:p.brandPersonality,colorPalette:p.colorPalette}),i&&i(),Ie({title:"Brand settings saved successfully 🚀",description:"Your brand identity has been updated."}),e(!1))},onBack:b,showAutoParseButton:!1})},"results"):n.jsxs("div",{className:"w-full h-full flex flex-col bg-white rounded-lg overflow-hidden",children:[n.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:n.jsxs(eY,{mode:"wait",children:[!v&&!y&&n.jsx(K4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col h-full",children:n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 space-y-8",children:[n.jsxs("div",{className:"space-y-2 w-full max-w-md",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block text-center",children:"Your Website URL"}),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 items-center",children:[n.jsx(qae,{type:"url",value:c,onChange:e=>d(e.target.value),placeholder:"https://example.com",className:"flex-1",disabled:!m}),n.jsx(eY,{mode:"wait",children:m?n.jsxs(K4.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex gap-2",children:[n.jsx(k5,{variant:"outline",size:"sm",onClick:()=>{h(!1),d(r?.website||"")},className:"w-full sm:w-auto",children:"Cancel"}),n.jsx(k5,{size:"sm",onClick:async()=>{try{o(c),h(!1),Ie({title:"Website URL updated successfully 🎉",description:"Your website URL has been saved."})}catch(e){Ie({title:"Error updating website URL",description:"Please try again.",variant:"destructive"})}},disabled:s||!c,className:"w-full sm:w-auto",children:s?n.jsx(v5,{}):"Save Changes"})]},"save"):n.jsx(K4.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},children:n.jsx(k5,{variant:"outline",size:"sm",onClick:()=>h(!0),className:"w-full sm:w-auto",children:"Edit URL"})},"edit")})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full max-w-2xl",children:[n.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[n.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"What we'll analyze"}),n.jsxs("ul",{className:"text-sm text-gray-600 space-y-1",children:[n.jsx("li",{children:"• Your brand colors and color palette"}),n.jsx("li",{children:"• Your logo (if detectable)"}),n.jsx("li",{children:"• Your brand name and tagline"}),n.jsx("li",{children:"• Your brand's tone and personality"})]})]}),n.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[n.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"How it helps you"}),n.jsx("p",{className:"text-sm text-gray-600",children:"Our AI will automatically extract your brand assets to create consistently styled emails that match your website. This helps maintain brand recognition and professionalism in all your communications."})]})]}),n.jsx(K4.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},className:"text-sm text-muted-foreground text-center max-w-md",children:"We'll use AI to analyze your website and extract your brand elements to create perfectly matched email templates."})]})},"url-confirmation"),v&&p&&n.jsx(K4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 h-full",children:n.jsx(UAe,{isLoading:v,brandSettings:p,onComplete:()=>{f(!1),k(!0),Ie({title:"Brand settings generated successfully!",description:"Your brand identity has been analyzed."})}})},"analyzing"),v&&!p&&n.jsx(K4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col items-center justify-center h-full",children:n.jsxs(K4.div,{className:"flex flex-col items-center gap-8",initial:{backgroundPosition:"0% 0%"},animate:{backgroundPosition:"100% 100%"},transition:{duration:5,repeat:1/0,repeatType:"reverse"},children:[n.jsxs(K4.div,{className:"relative w-24 h-24 flex items-center justify-center",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:[n.jsx(ud,{className:"w-12 h-12 text-primary drop-shadow-md"}),n.jsx(K4.div,{className:"absolute inset-0 rounded-full border-2",style:{borderColor:"var(--primary)"},initial:{scale:1,opacity:.8},animate:{scale:2.5,opacity:0},transition:{duration:3,repeat:1/0,ease:"easeOut"}})]}),n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:"Analyzing your website"}),n.jsx(eY,{mode:"wait",children:n.jsx(K4.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-gray-600 max-w-md text-center px-4",children:"Generating your brand's unique visual identity and personality"},"loading-message")})]})]})},"pre-analyzing")]})}),!v&&!y&&n.jsxs(K$,{className:"p-4",children:[n.jsx(k5,{variant:"outline",onClick:b,className:"gap-1",children:"Go Back"}),n.jsxs(k5,{onClick:async()=>{try{f(!0);const e=await u.mutateAsync();g(e),t&&t(e)}catch(e){f(!1),g(null),Ie({title:"Error generating brand settings",description:"Please try again.",variant:"destructive"})}},disabled:!c||u.isPending,className:"gap-1",children:[n.jsx(pd,{className:"h-4 w-4 text-amber-500"}),u.isPending?n.jsx(v5,{}):"Analyze Website"]})]})]})},qAe=["#a91919","#2563eb","#16a34a","#f59e0b","#6d28d9"],ZAe=({initialBrandSettings:e,onSave:t,onBack:i,showAutoParseButton:r=!0})=>{const{data:o,isLoading:s,updateBrandSettings:l,isUpdatingBrandSettings:u}=kpe(),[c,d]=a.useState({}),[m,h]=a.useState(!1),[p,g]=a.useState({}),[v,f]=a.useState(""),[y,k]=a.useState(""),[b,S]=a.useState("#000000"),[A,w]=a.useState(Date.now()),[C,M]=a.useState(!1),[T,E]=a.useState(null),[x,N]=a.useState({identity:!0,colors:!0,personality:!0}),_=a.useRef(null),{toast:P}=Ge();a.useEffect((()=>{if(e)return d({brandName:e.brandName,brandTagline:e.brandTagline,logoUrl:e.logoUrl,primaryColor:e.primaryColor||"#000000",secondaryColors:e.secondaryColors||[],brandPersonality:{tone:e.brandPersonality?.tone,voice:e.brandPersonality?.voice,values:e.brandPersonality?.values||[]}}),void w(Date.now());o?.branding&&(d({brandName:o.branding.brandName||o.name,brandTagline:o.branding.brandTagline||"",logoUrl:o.branding.logoUrl||"",primaryColor:o.branding.primaryColor||"#000000",secondaryColors:o.branding.secondaryColors||[],brandPersonality:{tone:o.branding.brandPersonality?.tone,voice:o.branding.brandPersonality?.voice,values:o.branding.brandPersonality?.values||[]}}),w(Date.now()))}),[o,e]);const L=e=>{N((a=>({...a,[e]:!a[e]})))},j=e=>{g((a=>{const n={...a,[e]:!a[e]};return n[e]&&("brandName"===e?f(c.brandName||""):"brandTagline"===e?f(c.brandTagline||""):"primaryColor"===e?f(c.primaryColor||"#000000"):"tone"===e?f(c.brandPersonality?.tone||""):"voice"===e&&f(c.brandPersonality?.voice||"")),n}))},B=e=>{"brandName"===e?d((e=>({...e,brandName:v}))):"brandTagline"===e?d((e=>({...e,brandTagline:v}))):"primaryColor"===e?d((e=>({...e,primaryColor:v}))):"tone"===e?d((e=>({...e,brandPersonality:{...e.brandPersonality,tone:v||void 0}}))):"voice"===e&&d((e=>({...e,brandPersonality:{...e.brandPersonality,voice:v||void 0}}))),j(e)},R=e=>{j(e)},z=e=>{d((a=>({...a,primaryColor:e})))},D=()=>{y.trim()&&(d((e=>{const a=e.brandPersonality?.values||[];return{...e,brandPersonality:{...e.brandPersonality,values:[...a,y.trim()]}}})),k(""))};return s?n.jsx("div",{className:"flex justify-center items-center h-full min-h-[500px] w-full bg-white rounded-lg shadow-sm",children:n.jsx(v5,{})}):m?n.jsx(WAe,{setAutoParse:h,onForceRefresh:()=>w(Date.now())}):n.jsxs("div",{className:"w-full h-full flex flex-col bg-white rounded-lg overflow-hidden gap-4 pt-16",children:[n.jsxs("div",{className:"flex-1 overflow-y-auto space-y-4 px-6 pt-2",children:[n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("identity"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Identity"})]}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(x.identity?Bc:Pc,{className:"h-4 w-4"})})]}),x.identity&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Brand Name"}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("brandName"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.brandName?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{value:v,onChange:e=>f(e.target.value),className:"flex-1",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>R("brandName"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>B("brandName"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border border-gray-200 text-sm font-medium",children:c.brandName})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Brand Tagline"}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("brandTagline"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.brandTagline?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{value:v,onChange:e=>f(e.target.value),className:"flex-1",autoFocus:!0,placeholder:"Your brand's tagline"}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>R("brandTagline"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>B("brandTagline"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border border-gray-200 text-sm italic",children:c.brandTagline||"No tagline set"})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-3",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Logo"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Square image, 128x128px, PNG recommended"})]})}),n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsxs("div",{className:"relative group",children:[n.jsx("div",{className:"w-24 h-24 rounded-lg border-2 border-dashed border-gray-200 flex items-center justify-center bg-gray-50 overflow-hidden",children:c.logoUrl?n.jsx("img",{src:c?.logoUrl,alt:c.brandName||"Brand logo",className:"w-full h-full object-contain"},A):n.jsx(Uc,{className:"h-10 w-10 text-gray-300"})}),n.jsxs("div",{className:"absolute inset-0 bg-black bg-opacity-40 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:[n.jsx("input",{type:"file",ref:_,onChange:e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{const n=e.result.split(",")[1];E(n);const t=URL.createObjectURL(a);d((e=>({...e,logoUrl:t}))),w(Date.now()),l({logoBase64:n})},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),n.jsxs(k5,{variant:"ghost",size:"sm",onClick:()=>{_.current?.click()},className:"text-white hover:text-white hover:bg-black hover:bg-opacity-20",children:[n.jsx(yd,{className:"h-4 w-4 mr-1"}),"Update"]})]})]}),c.logoUrl&&n.jsxs("div",{className:"flex-1 flex items-center gap-2 max-w-md bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[n.jsx("div",{className:"flex-1 truncate text-sm text-gray-600 font-mono",children:c.logoUrl}),n.jsxs(k5,{variant:"ghost",size:"sm",onClick:async()=>{if(c.logoUrl)try{await navigator.clipboard.writeText(c.logoUrl),M(!0),setTimeout((()=>M(!1)),1500),P({title:"Logo URL copied to clipboard"})}catch(QHe){try{const e=document.createElement("textarea");e.value=c.logoUrl,e.style.position="fixed",e.style.left="-9999px",document.body.appendChild(e),e.focus(),e.select();const a=document.execCommand("copy");if(document.body.removeChild(e),!a)throw new Error("Fallback copy command failed");M(!0),setTimeout((()=>M(!1)),1500),P({title:"Logo URL copied to clipboard"})}catch(e){P({title:"Failed to copy URL",description:"Could not copy the URL to clipboard. Please try again or copy manually.",variant:"destructive"})}}},className:"h-7 px-2 text-xs shrink-0",children:[C?n.jsx(_c,{className:"h-3.5 w-3.5 mr-1 text-green-500"}):n.jsx(Ic,{className:"h-3.5 w-3.5 mr-1"}),C?"Copied":"Copy"]})]})]})]})]})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("colors"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Colors"})]}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(x.colors?Bc:Pc,{className:"h-4 w-4"})})]}),x.colors&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Primary Color"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Your main brand color used throughout the interface"})]}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("primaryColor"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("div",{className:"w-14 h-14 rounded-lg shadow-md",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsxs("div",p.primaryColor?{className:"flex flex-1 gap-2 max-w-sm",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(nd,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),n.jsx(qae,{type:"text",value:v,onChange:e=>f(e.target.value),className:"pl-10 h-10 font-mono text-sm flex-1",placeholder:"#000000",maxLength:7,autoFocus:!0})]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("primaryColor"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>B("primaryColor"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}:{className:"flex-1 max-w-sm",children:[n.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[n.jsx(nd,{className:"h-4 w-4 text-gray-400"}),n.jsx("div",{className:"text-sm font-mono",children:c.primaryColor||"#000000"})]}),n.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[n.jsx(qae,{type:"color",value:c.primaryColor||"#000000",onChange:e=>z(e.target.value),className:"w-8 h-8 p-1 cursor-pointer rounded-md"}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:qAe.map(((e,a)=>n.jsx(k5,{variant:"ghost",size:"icon",className:"w-6 h-6 rounded-full border border-gray-200 "+(c.primaryColor===e?"ring-2 ring-gray-400 ring-offset-1":""),style:{backgroundColor:e},onClick:()=>z(e)},a)))})]})]})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Secondary Colors"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Additional colors that complement your primary brand color"})]})}),n.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[n.jsx("div",{className:"flex flex-wrap gap-3 mb-4",children:c.secondaryColors?.length?c.secondaryColors.map(((e,a)=>n.jsxs("div",{className:"group relative flex flex-col items-center",children:[n.jsx("div",{className:"w-12 h-12 rounded-lg shadow-sm border border-gray-200 mb-1 group-hover:ring-2 ring-gray-200",style:{backgroundColor:e}}),n.jsx("div",{className:"text-xs font-mono text-gray-600",children:e}),n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>{return a=e,void d((e=>{const n=e.secondaryColors||[];return{...e,secondaryColors:n.filter((e=>e!==a))}}));var a},className:"absolute -top-1 -right-1 w-5 h-5 bg-white rounded-full shadow border border-gray-200 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(Ad,{className:"w-3 h-3 text-gray-500"})})]},a))):n.jsx("div",{className:"text-sm text-gray-500 italic my-2",children:"No secondary colors set"})}),n.jsxs("div",{className:"flex items-end gap-3",children:[n.jsxs("div",{className:"flex-1 max-w-xs",children:[n.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Add color"}),n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx(qae,{type:"color",value:b,onChange:e=>S(e.target.value),className:"w-10 h-10 p-1 cursor-pointer rounded-md"}),n.jsx(qae,{type:"text",value:b,onChange:e=>S(e.target.value),className:"h-10 font-mono text-sm",placeholder:"#000000",maxLength:7})]})]}),n.jsxs(k5,{variant:"outline",onClick:()=>{b&&(d((e=>{const a=e.secondaryColors||[];return{...e,secondaryColors:[...a,b]}})),S("#000000"))},className:"h-10",children:[n.jsx(sd,{className:"h-4 w-4 mr-1"}),"Add Color"]})]})]})]})]})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("personality"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Personality"})]}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(x.personality?Bc:Pc,{className:"h-4 w-4"})})]}),x.personality&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Tone"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"The overall feeling and attitude your brand conveys"})]}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("tone"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.tone?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{type:"text",value:v,onChange:e=>f(e.target.value),className:"flex-1 h-10 rounded-md border border-gray-200 px-3 py-2",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("tone"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>B("tone"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"flex h-10 items-center px-4 bg-gray-50 rounded-lg border border-gray-200 text-sm",children:c.brandPersonality?.tone||"No tone set"})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Voice"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"How your brand expresses itself in communication"})]}),n.jsx(k5,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>j("voice"),children:n.jsx(td,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.voice?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{type:"text",value:v,onChange:e=>f(e.target.value),className:"flex-1 h-10 rounded-md border border-gray-200 px-3 py-2",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("voice"),children:n.jsx(Ad,{className:"h-4 w-4 text-gray-500"})}),n.jsx(k5,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>B("voice"),children:n.jsx(_c,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"flex h-10 items-center px-4 bg-gray-50 rounded-lg border border-gray-200 text-sm",children:c.brandPersonality?.voice||"No voice set"})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Values"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Core principles and beliefs that drive your brand"})]})}),n.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[n.jsx("div",{className:"mb-4",children:n.jsx("div",c.brandPersonality?.values&&c.brandPersonality.values.length>0?{className:"flex flex-wrap gap-2",children:c.brandPersonality.values.map(((e,a)=>n.jsxs(B5,{variant:"outline",className:"px-3 py-1.5 border-2 hover:border-red-100 group transition-colors text-primary",style:{borderColor:`${c.primaryColor}30`||"#f3f4f6",backgroundColor:`${c.primaryColor}08`||"#f9fafb"},children:[e,n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>{return a=e,void d((e=>{const n=e.brandPersonality?.values||[];return{...e,brandPersonality:{...e.brandPersonality,values:n.filter((e=>e!==a))}}}));var a},className:"ml-1.5 w-4 h-4 flex items-center justify-center rounded-full bg-gray-200 hover:bg-red-100 hover:text-red-500 transition-colors",children:n.jsx(Ad,{className:"w-2.5 h-2.5"})})]},a)))}:{className:"text-sm text-gray-500 italic py-2",children:"No brand values set"})}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(qae,{placeholder:"Add a brand value",value:y,onChange:e=>k(e.target.value),className:"flex-1",onKeyDown:e=>"Enter"===e.key&&D()}),n.jsxs(k5,{variant:"outline",onClick:D,disabled:!y.trim(),children:[n.jsx(sd,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})]})]})]}),n.jsxs(K$,{className:"pb-4 px-6",children:[i?n.jsx(k5,{variant:"outline",className:"gap-1.5",onClick:i,children:"Go Back"}):r&&n.jsxs(k5,{variant:"outline",className:"gap-1.5",onClick:()=>{h(!0)},children:[n.jsx(pd,{className:"h-4 w-4 text-amber-500"}),"Auto Parse"]}),n.jsx(k5,{className:"px-4",onClick:async()=>{let e;T?e=T:c.logoUrl?.startsWith("data:image/png;base64,")?e=c.logoUrl.split(",")[1]:c.logoUrl?.startsWith("blob:")&&(e=void 0),l({brandName:c.brandName,brandTagline:c.brandTagline,logoBase64:e,primaryColor:c.primaryColor,secondaryColors:c.secondaryColors,brandPersonality:c.brandPersonality}),P({title:"Brand settings saved 🚀"}),t&&t(),E(null)},disabled:u,children:u?"Saving":"Save Changes"})]})]})},$Ae=Zse.object({channelSenderId:Zse.string().min(1,"Please select a channel sender"),replyTo:Zse.string().trim().min(1).email("Please enter a valid email address").or(Zse.literal("").transform((()=>null))).or(Zse.null()).optional(),fromName:Zse.string().trim().min(1).or(Zse.literal("").transform((()=>null))).or(Zse.null()).optional()}),YAe=()=>{const{channelSenders:e,isLoading:t}=fre(),{channelAccounts:i,isLoading:r}=pre(),{updateChannelSender:o,isUpdating:s}=yre(),{toast:l}=Ge(),u=Zhe({resolver:ape($Ae),defaultValues:{channelSenderId:"",replyTo:"",fromName:""}}),c=a.useMemo((()=>wme({channelSenders:e?.results??[],channelAccounts:i?.results??[]})),[e?.results,i?.results]);if(a.useEffect((()=>{if(c&&c.length>0&&!u.getValues("channelSenderId")){const e=c[0];u.setValue("channelSenderId",e.channelSenderId),u.setValue("replyTo",e.channelSender.channelSenderMetadata.emailReplyTo??""),u.setValue("fromName",e.channelSender.channelSenderMetadata.emailFromName??"")}}),[c,u]),t||void 0===e||r||void 0===i)return n.jsx("div",{className:"flex justify-center items-center h-full py-10",children:n.jsx(v5,{})});return n.jsxs("div",{className:"w-full max-w-4xl mx-auto mt-8",children:[n.jsxs("div",{className:"mb-6",children:[n.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-gray-900 mb-1",children:"Set up Your Email Channel"}),n.jsx("p",{className:"text-muted-foreground text-base",children:"Define your default sender name, email address, and reply-to to start sending emails with confidence."})]}),n.jsx(npe,{...u,children:n.jsxs("form",{onSubmit:u.handleSubmit((async e=>{const a=c.find((a=>a.channelSenderId===e.channelSenderId));a&&o({toUpdate:{channelSenderMetadata:{...a.channelSender.channelSenderMetadata,emailReplyTo:e.replyTo?e.replyTo:`noreply@${a.baseDomain??""}`,emailFromName:e.fromName?e.fromName:null}},id:a.channelSender.id},{onSuccess:()=>{l({title:"Email channel sender updated successfully!"})},onError:()=>{l({title:"Failed to update email channel sender",description:"Please contact your administrator",variant:"destructive"})}})})),className:"bg-white border border-gray-200 rounded-2xl shadow-sm p-8 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[n.jsx(lpe,{className:"flex items-center gap-1 text-base font-medium mb-2",children:"Email Channel Sender"}),n.jsxs(nme,{value:u.watch("channelSenderId"),onValueChange:e=>{u.setValue("channelSenderId",e);const a=c.find((a=>a.channelSenderId===e));a&&u.setValue("replyTo",a.channelSender.channelSenderMetadata.emailReplyTo??"")},children:[n.jsx(rme,{className:"w-full bg-gray-50 border-gray-200 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 rounded-lg min-h-[48px] text-base",children:n.jsx(ime,{placeholder:"Select a sender"})}),n.jsx(lme,{children:c.map((e=>n.jsx(ume,{value:e.channelSenderId,children:n.jsxs("div",{className:"flex flex-col text-left",children:[n.jsx("span",{className:"font-medium",children:e.fullDomain}),n.jsx("span",{className:"text-xs text-muted-foreground",children:e.channelSender.channelSenderMetadata.emailReplyTo||"No reply-to set"})]})},e.channelSenderId)))})]})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[n.jsxs(lpe,{className:"flex items-center gap-1 text-base font-medium mb-0.5",children:["Reply-to Email",n.jsx(pue,{title:"Reply to email to use when the reply button is clicked"})]}),n.jsxs("span",{className:"text-xs text-muted-foreground font-normal mb-1",children:["Optional – will use"," ",n.jsx("span",{className:"font-mono",children:u.watch("channelSenderId")?`noreply@${c.find((e=>e.channelSenderId===u.watch("channelSenderId")))?.baseDomain}`:"sender domain"})," ","if empty"]}),n.jsx(hpe,{control:u.control,name:"replyTo",type:"email",placeholder:"Replies from recipients will go to this email (optional)"})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[n.jsxs(lpe,{className:"flex items-center gap-1 text-base font-medium mb-0.5",children:["From Name",n.jsx(pue,{title:"From name to use when the email is sent"})]}),n.jsx(hpe,{control:u.control,name:"fromName",placeholder:"From name to use when the email is sent (optional)"})]}),n.jsx("div",{className:"flex gap-3 pt-4 justify-end border-t border-gray-100",children:n.jsx(k5,{type:"submit",disabled:s,className:"min-w-[120px]",children:s?"Saving...":"Save"})})]})})]})},QAe=()=>{const[e,t]=a.useState(null),{channelSenders:i}=fre(),{channelAccounts:r}=pre(),{data:o}=Sre(),s=ale({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o});a.useEffect((()=>{s.length>0&&s.some((e=>e.smsApplication?.status===ele.APPROVED||!e.smsApplication))?t(!0):t(!1)}),[s,o]);const l={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}};if(null===e)return n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:n.jsx(v5,{})});const u=s.some((e=>e.smsApplication?.status===ele.APPROVED));return n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:e?n.jsxs(K4.div,{initial:"hidden",animate:"visible",exit:"exit",variants:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1],staggerChildren:.1}},exit:{opacity:0,y:-20,transition:{duration:.3,ease:[.4,0,1,1]}}},className:vm("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl p-6 gap-3 border border-border mx-auto mb-16","bg-background"),children:[n.jsx(K4.div,{variants:l,className:"w-16 h-16 rounded-xl flex items-center justify-center bg-green-50",children:n.jsx(w5.SmsIcon,{className:"text-green-600"})}),n.jsx(K4.h2,{variants:l,className:"text-lg font-medium text-foreground",children:"SMS Sending Number Active"}),n.jsx(K4.div,{variants:l,className:"max-w-xl mx-auto",children:n.jsx("p",u?{className:"text-sm font-normal text-muted-foreground mb-2",children:"Your SMS sending number has been verified and is ready to use. You can now create and send SMS campaigns!"}:{className:"text-sm font-normal text-muted-foreground mb-2",children:"You already have a valid SMS sending number and it is ready to use. You can create and send SMS campaigns!"})}),n.jsxs(K4.div,{variants:l,className:"flex items-center gap-2 px-4 py-2 bg-green-50 border border-green-200 rounded-full mt-2",children:[n.jsx(K4.div,{animate:{scale:[1,1.2,1],opacity:[1,.8,1]},transition:{duration:2,repeat:Number.POSITIVE_INFINITY,ease:"easeInOut"},className:"w-2 h-2 bg-green-500 rounded-full"}),n.jsx("span",{className:"text-sm font-medium text-green-800",children:"Ready to send"})]})]}):n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:n.jsx(gpe,{})})})};function XAe({tabs:e,activeTab:a,onTabChange:t,title:i}){return n.jsxs("div",{className:"flex h-full",children:[n.jsxs("div",{className:"w-48 py-2 pl-4",children:[i&&n.jsx("h2",{className:"px-4 pt-4 pb-5 text-lg font-medium",children:i}),e.map((e=>n.jsx(k5,{variant:"ghost",className:vm("w-full justify-start mb-1",a===e.id&&"bg-accent"),onClick:()=>t(e.id),children:e.label},e.id)))]}),n.jsx("div",{className:"flex-1 overflow-y-auto pl-6 pr-4 pb-4",children:e.find((e=>e.id===a))?.content})]})}function ewe({open:e,setOpen:t}){const[i,r]=a.useState("brand");a.useEffect((()=>{e&&r("brand")}),[e]);const o=[{id:"brand",label:"Brand",content:n.jsx(ZAe,{})},{id:"email-channel",label:"Email Channel",content:n.jsx(YAe,{})},{id:"sms-channel",label:"SMS Channel",content:n.jsx(QAe,{})}];return n.jsx(L$,{open:e,onOpenChange:t,children:n.jsxs(z$,{className:"flex w-[90vw] h-[90vh] flex-col gap-0 overflow-hidden sm:max-w-xl md:max-w-3xl lg:max-w-4xl xl:max-w-5xl p-0",children:[n.jsxs(lq,{children:[n.jsx(O$,{children:"Settings"}),n.jsx(H$,{children:"Edit your business and brand settings"})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(XAe,{tabs:o,activeTab:i,onTabChange:r,title:"Settings"})})]})})}const awe=e=>{const{updateAutomation:n,updateError:t,isUpdateSuccess:i}=ta(e),{toast:r}=Ge();return a.useEffect((()=>{i?r({title:"Status updated",description:"The status has been updated successfully"}):t&&r({title:"Error updating status",description:"Please try again",variant:"destructive"})}),[i,t,r]),{toggleStatus:async e=>{try{return await n({status:e?da.ACTIVE:da.DRAFT}),!0}catch(a){return r({title:"Error updating status",description:"Please try again",variant:"destructive"}),!1}}}};function nwe(){const{toast:e}=Ge(),[t,i]=a.useState(null),{toggleStatus:r}=awe(t||""),o=qne(),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{automations:h,nextCursor:p,isLoading:g,error:v,isFetching:f,isPlaceholderData:y}=ra({cursor:u,limit:s,triggerType:sa.TRIGGER_BASED,search:d||void 0});a.useEffect((()=>{v&&e({title:`Error Fetching ${_h("engage:automation")}`,description:v?.message||"Please try again.",variant:"destructive"})}),[v,e]);const k=a.useMemo((()=>(h||[]).map((e=>({...e,emailsSent:0,smsSent:0,updated_at:e.updatedAt||e.createdAt})))),[h]),b=a.useCallback((async(e,a)=>{try{i(e);const n=a===da.ACTIVE;await r(n)}finally{i(null)}}),[r,i]),S=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]),A=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),w=a.useMemo((()=>hue({automationName:_h("engage:automation"),setUrl:A,onToggle:b,vsaasManaged:!0})),[b,A]);return n.jsx("div",{className:"w-full h-[75vh] flex flex-col",children:n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx($ae,{data:k,columns:w,paginationMode:"cursor",initialPageSize:s,isLoading:g&&!y,onRowClick:e=>{o(`/automations/view-modal/${e.id}?showBackButton=true`)},cursorPaginationQueryResult:{nextCursor:p,isLoading:g,isFetching:f,isPlaceholderData:y},onQueryParametersChange:S,searchValue:d,onSearchChange:m})})})}function twe(){const{toast:e}=Ge(),[t,i]=a.useState(!1),[r,o]=a.useState(null),{toggleStatus:s}=awe(r||""),l=qne(),[u,c]=a.useState(10),[d,m]=a.useState(void 0),[h,p]=a.useState(""),{automations:g,nextCursor:v,isLoading:f,error:y,isFetching:k,isPlaceholderData:b}=ra({cursor:d,limit:u,triggerType:sa.ONE_TIME,search:h||void 0});a.useEffect((()=>{y&&e({title:`Error Fetching ${_h("engage:broadcast")}`,description:y?.message||"Please try again.",variant:"destructive"})}),[y,e]);const S=a.useMemo((()=>(g||[]).map((e=>({...e,updated_at:e.updatedAt})))),[g]),A=a.useCallback((async(e,a)=>{try{o(e);const n=a===da.ACTIVE;await s(n)}finally{o(null)}}),[s,o]),w=a.useCallback((e=>{m(e.cursor),c(e.pageSize)}),[]),C=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),M=a.useMemo((()=>hue({automationName:_h("engage:broadcast"),setUrl:C,onToggle:A,pillForStatus:!0})),[A,C]);return n.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx($ae,{data:S,columns:M,paginationMode:"cursor",initialPageSize:u,headerActions:n.jsxs(k5,{className:"bg-primary",onClick:()=>i(!0),children:[n.jsx(sd,{className:"h-4 w-4 mr-1"}),"New"]}),isLoading:f&&!b,cursorPaginationQueryResult:{nextCursor:v,isLoading:f,isFetching:k,isPlaceholderData:b},onRowClick:e=>{l(`/automations/view-modal/${e.id}?showBackButton=true`)},onQueryParametersChange:w,searchValue:h,onSearchChange:p})}),n.jsx(_Ae,{open:t,setOpen:i,onClose:a=>{iue(i,e,a,`Error creating ${_h("engage:broadcast")}`,"Please try again"),m(void 0),c(10),p(""),!1!==a&&l(`/automations/view-modal/${a}?showBackButton=true`)},automationType:sa.ONE_TIME})]})}function iwe(){const{toast:e}=Ge(),[t,i]=a.useState(!1),[r,o]=a.useState(null),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{segments:h,isLoading:p,nextCursor:g,isFetching:v,isPlaceholderData:f}=t5({search:d||void 0,cursor:u,limit:s}),y=a.useCallback((e=>{o(e),i(!0)}),[o]),k=a.useMemo((()=>function(e){return[sue("name",`${_h("engage:segment")} Name`,!0),lue(),tue({accessorKey:"user_count",header:_h("engage:user_other"),meta:{align:"right",displayName:_h("engage:user_other")},cellClassName:"text-muted-foreground pr-4",cellFormatter:e=>{const a=e.getValue()??0;return`${a.toLocaleString()} ${1===a?_h("engage:user").toLowerCase():_h("engage:user_other").toLowerCase()}`}}),uue("updated_at"),mue(e||(()=>{}))]}(y)),[y]),b=a.useMemo((()=>h?h.map((e=>({...e,updated_at:e.createdAt.toString(),user_count:e.userCount,user_count_updated_at:e.userCountUpdatedAt}))):[]),[h]),S=a.useMemo((()=>n.jsxs(k5,{onClick:()=>{o(null),i(!0)},children:[n.jsx(sd,{className:"h-4 w-4"}),"New List"]})),[]),A=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]);return n.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx($ae,{data:b,columns:k,paginationMode:"cursor",initialPageSize:s,headerActions:S,isLoading:p&&!f,cursorPaginationQueryResult:{nextCursor:g,isLoading:p,isFetching:v,isPlaceholderData:f},onQueryParametersChange:A,onRowClick:a=>{a.type===l5.CUSTOM?(o(a.id),i(!0)):e({title:`${_h("engage:segment")} cannot be edited`})},searchValue:d,onSearchChange:m})}),n.jsx(lAe,{open:t,setOpen:i,segmentId:r??void 0,onSegmentUpdated:a=>{iue(i,e,a,`Error creating ${_h("engage:segment")}`,"Please try again"),c(void 0),l(10),m("")}})]})}const rwe=()=>{const e=ce(),[t,i]=a.useState(!1),[r,o]=a.useState(null),{automations:s,isLoading:l}=ra({triggerType:sa.TRIGGER_BASED}),[u,c]=a.useState();return a.useEffect((()=>{e.prefetchQuery({queryKey:Le.list()}),e.prefetchQuery({queryKey:a5.lists()})}),[e]),a.useEffect((()=>{if(l||void 0===s)return;const e=[{id:"broadcasts",label:_h("engage:broadcast",{count:2}),content:n.jsx(twe,{})},{id:"segments",label:_h("engage:segment",{count:2}),content:n.jsx(iwe,{})},{id:"statistics",label:_h("engage:insight",{count:2}),content:n.jsx(FAe,{})}];s.length>0?(o("automations"),c([{id:"automations",label:_h("engage:automation",{count:2}),content:n.jsx(nwe,{})},...e])):(o("broadcasts"),c(e))}),[s,l]),null===r||null==u?n.jsx("div",{className:"w-full h-full flex justify-center items-center",children:n.jsx(v5,{})}):n.jsxs("div",{className:"w-full h-full flex flex-col gap-4",children:[n.jsx(ewe,{open:t,setOpen:i}),n.jsx("div",{className:"flex justify-end",children:n.jsx(k5,{variant:"outline",onClick:()=>i(!0),children:n.jsx(md,{className:"w-4 h-4"})})}),n.jsx("div",{className:"flex-1 w-full h-full flex flex-col gap-4",children:n.jsx(PAe,{activeTab:r,tabs:u,onTabChange:o})})]})};function owe({value:e,schema:t,onSubmit:i,fieldName:r,className:o,successMessage:s="Updated successfully",errorMessage:l="Failed to update",placeholderText:u}){const[c,d]=a.useState(!1),[m,h]=a.useState(!1),[p,g]=a.useState(0),[v,f]=a.useState(0),[y,k]=a.useState(e),[b,S]=a.useState(e),A=a.useRef(null),w=a.useRef(null),C=a.useRef(null),M=a.useRef(null),{toast:T}=Ge(),E=Zhe({resolver:ape(t),defaultValues:{[r]:e}});a.useEffect((()=>{E.reset({[r]:e}),k(e),S(e)}),[e,r,E]),a.useEffect((()=>{w.current&&g(w.current.offsetWidth),M.current&&!c&&f(M.current.offsetWidth)}),[c]),a.useEffect((()=>{C.current&&y&&g(C.current.offsetWidth)}),[y]),a.useEffect((()=>{c&&A.current&&(A.current.focus(),A.current.select())}),[c]);const x=async e=>{h(!0);const a=e[r];try{await i(e),S(a),T({variant:"success",title:s}),d(!1)}catch(n){T({variant:"destructive",title:l})}finally{h(!1)}},N=()=>{E.reset(),d(!1),k(b)},_=e=>{"Escape"===e.key&&N()};return c?n.jsx(npe,{...E,children:n.jsxs("form",{onSubmit:E.handleSubmit(x),className:P$("inline-flex items-center gap-2 min-h-[20px]",o),style:{minWidth:v?`${v}px`:"auto"},children:[n.jsx("span",{ref:C,className:"absolute invisible whitespace-pre leading-none select-none pointer-events-none",style:{font:"inherit"},children:y||b}),n.jsx(ipe,{control:E.control,name:r,render:({field:e})=>n.jsx(spe,{className:"flex-1 min-w-0",children:n.jsx(upe,{children:n.jsx("input",{...e,ref:A,style:{width:`${Math.max(p+40,120)}px`,minWidth:`${Math.max(p,100)}px`,font:"inherit"},className:"bg-transparent outline-none leading-none h-[20px] border-none p-0 m-0",onChange:a=>{e.onChange(a),k(a.target.value)},onKeyDown:_,disabled:m,onBlur:a=>{e.onBlur(),setTimeout((()=>{a.currentTarget.form?.contains(document.activeElement)||N()}),0)}})})})}),n.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n.jsx(k5,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",onClick:N,disabled:m,children:n.jsx(Ad,{className:"h-3 w-3"})}),n.jsx(k5,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",disabled:m,onClick:()=>{E.handleSubmit(x)()},children:m?n.jsx(Zc,{className:"h-3 w-3 animate-spin"}):n.jsx(_c,{className:"h-3 w-3"})})]})]})}):n.jsxs("button",{ref:M,type:"button",className:P$("group relative inline-flex items-center gap-2 cursor-pointer min-h-[20px] bg-transparent border-none p-0 text-left",o),onClick:()=>d(!0),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),d(!0))},"aria-label":"Edit field",children:[n.jsx("span",{ref:w,className:P$("leading-none select-none",o,{italic:!b}),children:b||u}),n.jsx(id,{className:"h-3 w-3 transition-opacity duration-200 flex-shrink-0 opacity-0 group-hover:opacity-100"})]})}function swe({open:e,onOpenChange:a}){const t=d5(),{toast:i}=Ge(),{updateAutomation:r}=ta(t?.id||""),o=ce();return n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"sm:max-w-[425px]",children:[n.jsx(D$,{children:n.jsx(O$,{children:t?.status===da.SENDING?`Cancel ${_h("engage:automation")}`:`Cancel ${_h("engage:automation")} Before Sending`})}),n.jsx("div",{className:"space-y-4",children:t?n.jsxs(n.Fragment,t.status===da.SENDING?{children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",n.jsx("span",{className:"font-bold px-1 text-primary",children:t.name}),_h("engage:automation")," as soon as possible."]}),n.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[n.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),n.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[n.jsxs("li",{children:["We'll attempt to cancel the"," ",_h("engage:broadcast").toLowerCase()]}),n.jsx("li",{children:"Any messages already in the process of being sent will be delivered"}),n.jsxs("li",{children:["Future ",_h("engage:broadcast").toLowerCase()," messages will be cancelled"]}),n.jsxs("li",{children:["You can create a new ",_h("engage:broadcast").toLowerCase()," if needed"]})]})]})]}:{children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",n.jsx("span",{className:"font-bold px-1 text-primary",children:t.name}),_h("engage:automation")," before it starts sending."]}),n.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[n.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),n.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[n.jsx("li",{children:"The automation will be cancelled"}),n.jsx("li",{children:"You can create a new automation if needed"})]})]})]}):null}),n.jsxs(K$,{className:"gap-2 sm:gap-0",children:[n.jsx(k5,{variant:"outline",onClick:()=>a(!1),children:"Continue Running"}),n.jsxs(k5,{variant:"destructive",onClick:()=>{if(!t)return;const e=t.status===da.SENDING?da.PARTIALLY_CANCELLED:da.CANCELLED,n=t.status===da.SENDING?`Attempting to cancel ${_h("engage:broadcast").toLowerCase()}`:`Successfully cancelled ${_h("engage:broadcast").toLowerCase()}`,s=`Failed to cancel ${_h("engage:broadcast").toLowerCase()}`;r({status:e},{onError:()=>{i({title:s,description:"Please contact your administrator.",variant:"destructive"}),o.invalidateQueries({queryKey:Le.all})},onSuccess:()=>{a(!1),i({title:n,description:t.status===da.SENDING?`We'll attempt to cancel your ${_h("engage:broadcast").toLowerCase()}. Any messages already in progress will be delivered.`:`Your ${_h("engage:broadcast").toLowerCase()} has been cancelled.`})}})},children:["Cancel ",_h("engage:automation")]})]})]})})}function lwe({open:e,onOpenChange:a,setIsActive:t}){const i=d5(),{updateAutomation:r}=ta(i?.id||""),{toast:o}=Ge(),s=ce(),l=_h(i?.triggerType===sa.ONE_TIME?"engage:broadcast":"engage:automation"),u=i?.triggerType===sa.ONE_TIME?"Unschedule":"Convert to draft";return n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"sm:max-w-[425px]",children:[n.jsx(D$,{children:n.jsx(O$,{children:u})}),n.jsxs("div",{children:["Are you sure you want to convert",n.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name})," ",l," to draft?"]}),n.jsxs(K$,{className:"gap-2 sm:gap-0",children:[n.jsx(k5,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),n.jsx(k5,{variant:"destructive",onClick:()=>{r({status:da.DRAFT},{onSuccess:()=>{o({title:`Updated ${l}`,description:`${l} status updated to draft`}),a(!1),t(!1)},onError:()=>{o({title:`Failed to update ${l}`,description:"Please try again"}),s.invalidateQueries({queryKey:Le.all})}})},children:u})]})]})})}const uwe=Ese({name:hse().min(2,"Title must be at least 2 characters"),description:hse()});function cwe({open:e,onOpenChange:a,onDuplicationCreated:t}){const i=d5(),{toast:r}=Ge(),o=Zhe({resolver:ape(uwe),defaultValues:{name:`${i?.name} (copy)`,description:i?.description??""}}),{duplicateAutomation:s}=oa();return n.jsx(L$,{open:e,onOpenChange:a,children:n.jsxs(z$,{className:"sm:max-w-[425px]",children:[n.jsx(D$,{children:n.jsx(O$,{children:"Duplicate Automation"})}),n.jsx(npe,{...o,children:n.jsxs("form",{onSubmit:o.handleSubmit((async function(e){i&&e.name?s({automationId:i.id,name:e.name,description:e.description},{onSuccess:e=>{e.id&&(t?.(e.id),a(!1))}}):r({title:"Error duplicating automation",description:"Please try again. Please make sure to fill in the name of the automation."})})),className:"space-y-4",children:[n.jsxs("div",{children:["Create a copy of the",n.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name}),"automation with a new title and description."]}),n.jsx(ipe,{control:o.control,name:"name",render:({field:e})=>n.jsxs(spe,{children:[n.jsx(lpe,{children:"Title"}),n.jsx(upe,{children:n.jsx(qae,{...e})}),n.jsx(cpe,{})]})}),n.jsx(ipe,{control:o.control,name:"description",render:({field:e})=>n.jsxs(spe,{children:[n.jsx(lpe,{children:"Description"}),n.jsx(upe,{children:n.jsx(Uve,{...e})}),n.jsx(cpe,{})]})}),n.jsx(K$,{children:n.jsx(k5,{type:"submit",children:"Duplicate"})})]})})]})})}const dwe=Ese({name:hse().min(2,"Title must be at least 2 characters")}),mwe=Ese({description:hse().max(300,"Description must be less than 300 characters")}),hwe=({showBackButton:e,onDuplicationCreated:t,onBeforeSchedule:i})=>{const r=d5(),o=qne(),{updateAutomation:s}=ta(r?.id||""),{toast:l}=Ge(),u=(()=>{const{state:e}=c5();return e.recipientStats})(),c=m5(),{data:d}=Sre(),{channelSenders:m}=fre(),{channelAccounts:h}=pre(),p=ce(),[g,v]=a.useState(void 0),[f,y]=a.useState(!1),[k,b]=a.useState(!1),[S,A]=a.useState(!1),[w,C]=a.useState(0),[M,T]=a.useState(!1),E=ale({channelSenders:m?.results??[],channelAccounts:h?.results??[],smsApplication:d});a.useEffect((()=>{if(r)switch(r.status){case da.DRAFT:v(!1);break;case da.ACTIVE:case da.RUNNING:case da.COMPLETED:v(!0);break;case da.FAILED:case da.DEACTIVATED:v(!1);break;case da.SENDING:case da.SCHEDULED:v(!0);break;case da.PARTIALLY_CANCELLED:case da.CANCELLED:v(!1);break;default:throw ire(r.status,da)}}),[r]);const x=a.useCallback((()=>{if(!r)return l({title:"Automation not found",description:"Please contact your administrator",variant:"destructive"}),null;const e=async e=>{if(g&&!e)b(!0);else{if(A(!0),i&&!0===e){let e=0;for(;!u&&e<20;)await new Promise((e=>setTimeout(e,100))),e++;if(!u)return l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),void A(!1);const a=await i({estimatedEmailRecipients:u?.emails??0,estimatedSmsRecipients:u?.phones??0});if(!0!==a)return l({title:"Error while updating the status",description:a,variant:"destructive"}),void A(!1)}if(c?.emailChannelSenderId&&c?.emailHtmlBody&&c?.emailHtmlBody?.includes(SAe)){if(0===w)return l({title:`${AAe}. You can click send again to send anyway.`,variant:"warning"}),C(w+1),void A(!1);C(w+1)}switch(r.triggerType){case sa.ONE_TIME:if(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt)return l({title:"Ensure you have selected a scheduled time",variant:"destructive"}),void A(!1);if(!c||!c.emailChannelSenderId&&!c.smsChannelSenderId)return l({title:"Ensure you have selected at least one kind of communication",variant:"destructive"}),void A(!1);break;case sa.TRIGGER_BASED:break;default:throw ire(r.triggerType,sa)}const a=_h(r.triggerType===sa.ONE_TIME?"engage:automation":"engage:broadcast");s({status:e?da.ACTIVE:da.DEACTIVATED},{onSuccess:()=>{v(e),l(r.triggerType===sa.ONE_TIME?e?{title:`${a} started!`}:{title:`${a} has been unscheduled`}:{title:`${a} status updated to ${e?"active":"inactive"}`}),A(!1)},onError:()=>{l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),A(!1),p.invalidateQueries({queryKey:Le.all})}})}};if(!r||!c)return null;const a=E.find((e=>e.channelSender.id===c?.smsChannelSenderId)),t=!r.triggerMetadata||null===r.triggerMetadata,o=r.triggerMetadata?.triggerType===sa.ONE_TIME&&!r.triggerMetadata?.scheduledAt,d=!c?.emailChannelSenderId&&!c?.smsChannelSenderId,m=r.triggerType===sa.ONE_TIME,h=m&&a&&a?.smsApplication?.application&&a?.smsApplication?.status!==ele.APPROVED,f=c?.emailChannelSenderId&&(!c?.emailSubject||!c?.emailHtmlBody),y=c?.smsChannelSenderId&&!c?.smsMessageBody,k=m&&(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt);let S,M=!1,x=!0;switch(r.status){case da.ACTIVE:M=!1;break;case da.DRAFT:(d||f||y)&&(M=!0,f&&(S="Missing subject in email communication"),y&&(S="Missing SMS message in SMS communication")),k&&(M=!0),h&&(M=!0);break;case da.DEACTIVATED:case da.PARTIALLY_CANCELLED:case da.CANCELLED:switch(M=!0,x=!1,r.status){case da.DEACTIVATED:S="Automation is deactivated";break;case da.PARTIALLY_CANCELLED:S="Automation is partially cancelled";break;case da.CANCELLED:S="Automation is cancelled";break;default:throw ire(r.status,da)}break;case da.RUNNING:M=!0,r.triggerType===sa.TRIGGER_BASED?(S="Cannot change status of running automation",x=!0):x=r.triggerType===sa.ONE_TIME&&r.status===da.RUNNING;break;case da.COMPLETED:M=!0,S="Cannot change status of completed automation",x=!1;break;case da.FAILED:M=!0,S="Cannot change status of failed automation",x=!1;break;case da.SENDING:case da.SCHEDULED:M=!1,x=!0;break;default:throw ire(r.status,da)}const N=(()=>{switch(r.triggerType){case sa.TRIGGER_BASED:return n.jsxs("div",{className:"flex items-center gap-2 w-[12ch] cursor-pointer",children:[n.jsx(g?_c:Oc,{className:"w-4 h-4"}),n.jsx("div",{className:"text-[13px] font-medium",children:g?"Active":"Inactive"}),n.jsx(XSe,{checked:g,onCheckedChange:e,disabled:M})]});case sa.ONE_TIME:if((r.status===da.RUNNING||r.status===da.SCHEDULED||r.status===da.SENDING)&&r.triggerType===sa.ONE_TIME)return n.jsx(k5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>T(!0),disabled:!1,children:"Cancel"});if(t||o||d||h||f||y){return n.jsx("div",{className:"flex items-center gap-2 cursor-not-allowed",children:(()=>{const a=r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"===r.triggerMetadata?.scheduledAt?"Send Now":"Schedule Send";if(r.status!==da.DRAFT&&r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"!==r.triggerMetadata?.scheduledAt&&r.status===da.ACTIVE)return n.jsx(k5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:r.triggerType===sa.ONE_TIME?"Unschedule":"Convert to Draft"});const t=[];h&&t.push("The SMS number selected is still not approved"),k&&t.push("Please select a schedule time on the left sidebar"),d&&t.push("Please add at least one sender"),f&&t.push("Please add a subject to your email communication"),y&&t.push("Please add a message to your SMS communication");const i=t.map((e=>{return(a=e).charAt(0).toUpperCase()+a.slice(1);var a})),o=`You cannot start this ${_h("engage:broadcast")} yet. ${i.join(" · ")}`;return n.jsx("div",{className:"flex items-center gap-2",children:n.jsx(pue,{alertText:o,asChild:!1,className:"!cursor-not-allowed",children:n.jsx(k5,{variant:"outline",className:"flex items-center gap-2",disabled:!0,asChild:!1,children:a})})})})()})}if(!g){let a="Schedule Send";return r.triggerMetadata&&r.triggerMetadata.triggerType===sa.ONE_TIME&&r.triggerMetadata.scheduledAt&&"now"===r.triggerMetadata.scheduledAt&&(a="Send Now"),n.jsx(k5,{variant:"default",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:a})}return n.jsx(k5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:r.triggerType===sa.ONE_TIME?"Unschedule":"Convert to Draft"});default:throw ire(r.triggerType,sa)}})();return M&&S&&r.triggerType===sa.TRIGGER_BASED?n.jsx(pue,{alertText:S,asChild:!0,children:n.jsx("div",{className:"flex items-center gap-2",children:x&&N})}):n.jsx("div",{className:"flex items-center gap-2",children:x&&N})}),[r,c,E,l,g,i,s,u,w,p]),N=a.useMemo((()=>r?n.jsx(B5,{variant:rue(r.status),children:rre({status:r.status,automationType:r.triggerType})}):null),[r]);return r&&void 0!==g?n.jsxs("header",{className:"flex px-1 pt-1",children:[n.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[e&&n.jsx(k5,{variant:"ghost",size:"icon",onClick:()=>o(-1),children:n.jsx(Tc,{})}),n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs("div",{className:"flex flex-col gap-0 items-start",children:[n.jsx(owe,{value:r.name,schema:dwe,onSubmit:e=>{s({name:e.name},{onError:()=>{l({title:"Failed to update automation name",description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:Le.all})}})},fieldName:"name",className:"text-lg",successMessage:"Automation name updated",errorMessage:"Failed to update automation name"}),r.automationType!==ua.MANAGED?n.jsx(owe,{value:r.description||"",schema:mwe,onSubmit:e=>{s({description:e.description},{onError:()=>{l({title:"Failed to update automation description",description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:Le.all})}})},fieldName:"description",className:"text-sm "+(r.description?"text-current":"text-muted-foreground"),successMessage:"Description updated",errorMessage:"Failed to update description",placeholderText:"Describe the goal of the automation"}):r.description&&n.jsx("div",{className:"text-sm text-current",children:r.description})]})})]}),n.jsxs("div",{className:"ml-auto flex gap-4 items-center",children:[n.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[N,r.triggerType===sa.ONE_TIME&&n.jsx("div",{role:"button",tabIndex:0,className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-10 w-10 cursor-pointer",onClick:()=>y(!0),children:n.jsx(pue,{title:"Duplicate",Icon:w5.DuplicateIcon,asChild:!1,onClick:()=>y(!0)})})]}),n.jsx("div",S?{className:"flex items-center text-muted-foreground pr-2",children:n.jsx(v5,{size:"sm"})}:{className:"flex items-center",children:x()})]}),n.jsx(cwe,{open:f,onOpenChange:y,onDuplicationCreated:t}),n.jsx(lwe,{open:k,onOpenChange:b,setIsActive:v}),n.jsx(swe,{open:M,onOpenChange:T})]}):null},pwe=()=>{const e=d5(),{isLoading:t}=ia(e?.id),{state:{hideSales:i,hideSms:r}}=a.useContext(uq);return!e||t?n.jsx(v5,{text:[`Fetching ${_h("engage:insight",{count:2})}`,"Finishing up"]}):n.jsx("div",{className:"h-full p-4",children:n.jsx(FAe,{automationId:e.id,automation:e,includeSales:!i,includeSms:!r})})},gwe=()=>{const e=d5(),[t,i]=a.useState(10),[r,o]=a.useState(void 0),[s,l]=a.useState(""),{sentCommunications:u,isLoading:c,isFetching:d,isPlaceholderData:m,fetchError:h}=aa({automationId:e?.id??"",cursor:r,limit:t,search:s||void 0}),p=a.useCallback((e=>{o(e.cursor),i(e.pageSize)}),[]),g=[{accessorKey:"communicationsSent",id:"lastCommunication",header:"Updated At",cell:({row:e})=>{const a=e.original.communicationsSent||[];if(0===a.length)return n.jsx("span",{className:"text-gray-400",children:"None"});const t=a.reduce(((e,a)=>e&&e.updatedAt?a.updatedAt&&new Date(a.updatedAt)>new Date(e.updatedAt)?a:e:a));return t?.updatedAt?n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("span",{className:"text-sm text-gray-600",children:eue(new Date(t.updatedAt),"MMM d, yyyy h:mm a")})}):n.jsx("span",{className:"text-gray-400",children:"Not available"})}},{accessorFn:e=>`${e.firstName||""} ${e.lastName||""}`.trim(),id:"name",header:"Name",cell:({row:e})=>{const a=`${e.original.firstName||""} ${e.original.lastName||""}`.trim();return a||n.jsx("span",{className:"text-gray-400",children:"Not provided"})}},{accessorKey:"email",header:"Email",cell:({row:e})=>e.original.email||n.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"phone",header:"Phone",cell:({row:e})=>e.original.phone?yye(e.original.phone):n.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"communicationsSent",id:"communicationsSent",header:"Communications Sent",cell:({row:e})=>{const a=e.original.communicationsSent||[],t=a.filter((e=>e.type===ma.EMAIL)),i=a.filter((e=>e.type===ma.SMS)),r=t.length>0,o=i.length>0,s=t.some((e=>e.delivered)),l=i.some((e=>e.delivered)),u=t.find((e=>e.error))?.error,c=i.find((e=>e.error))?.error,d=t.some((e=>e.skipped)),m=i.some((e=>e.skipped)),h=(e,a,t,i)=>n.jsxs("div",{className:"flex items-center gap-1.5 cursor-pointer",children:[n.jsxs("div",{className:"relative",children:[n.jsx("email"===e?w5.EmailIcon:w5.SmsIcon,{className:"h-4 w-4 "+(t?"text-red-500":i?"text-gray-400":a?"text-green-500":"text-gray-400")}),a&&!t&&!i&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-green-500 ring-1 ring-white"}),t&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-red-500 ring-1 ring-white"}),i&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-gray-400 ring-1 ring-white"})]}),n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"text-sm font-medium",children:"email"===e?"Email":"SMS"}),n.jsx("span",t?{className:"text-xs text-red-500",children:"Failed"}:i?{className:"text-xs text-gray-500",children:"Skipped"}:{className:"text-xs "+(a?"text-green-600":"text-gray-500"),children:a?"Delivered":"Pending"})]})]});return n.jsxs("div",{className:"flex items-center gap-3",children:[r&&(u?n.jsx(pue,{title:u,children:h("email",s,u,d)}):h("email",s,u,d)),r&&o&&n.jsx("div",{className:"h-8 w-px bg-gray-200"}),o&&(c?n.jsx(pue,{title:c,children:h("sms",l,c,m)}):h("sms",l,c,m)),!r&&!o&&n.jsx("span",{className:"text-sm text-gray-400",children:"None"})]})}}];return e&&!c&&u?h?n.jsxs("div",{children:["Error: ",h.message]}):!u||!s&&0===u.results.length?n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[n.jsx("div",{className:"mb-4",children:n.jsx(w5.UserIcon,{className:"h-12 w-12 text-gray-400"})}),n.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Communications Sent Yet"}),n.jsxs("p",{className:"text-gray-500",children:["This"," ",_h(e.triggerType===sa.ONE_TIME?"engage:broadcast":"engage:automation")," ","hasn't sent any communications yet. Please check back later to see recipient details once communications have been sent."]})]}):n.jsx("div",{className:"h-full p-4",children:n.jsx($ae,{data:u.results,columns:g,paginationMode:"cursor",initialPageSize:t,isLoading:c&&!m,cursorPaginationQueryResult:{nextCursor:u.pagination.cursor,isLoading:c,isFetching:d,isPlaceholderData:m},onQueryParametersChange:p,searchValue:s,onSearchChange:l})}):n.jsx(v5,{text:["Fetching Recipients","Finishing up"]})},vwe=()=>{const e=d5();return e?e?.triggerType===sa.ONE_TIME&&e?.status===da.DRAFT?n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[n.jsx("div",{className:"mb-4",children:n.jsx(w5.UserIcon,{className:"h-12 w-12 text-gray-400"})}),n.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Recipients Available Yet"}),n.jsxs("p",{className:"text-gray-500",children:["Recipients will be available once this"," ",_h(e.triggerType===sa.ONE_TIME?"engage:broadcast":"engage:automation")," ","has completed running. Please check back after the automation has finished."]})]}):n.jsx(gwe,{}):n.jsx(v5,{text:["Fetching Recipients","Finishing up"]})},fwe=a.createContext(null);fwe.displayName="PanelGroupContext";const ywe="data-panel-group",kwe="data-panel-group-direction",bwe="data-panel-group-id",Swe="data-panel",Awe="data-panel-collapsible",wwe="data-panel-id",Cwe="data-panel-size",Mwe="data-resize-handle",Twe="data-resize-handle-active",Ewe="data-panel-resize-handle-enabled",xwe="data-panel-resize-handle-id",Nwe="data-resize-handle-state",_we=a.useLayoutEffect,Pwe=r["useId".toString()],Lwe="function"==typeof Pwe?Pwe:()=>null;let jwe=0;function Bwe(e=null){const n=Lwe(),t=a.useRef(e||n||null);return null===t.current&&(t.current=""+jwe++),null!=e?e:t.current}function Rwe({children:e,className:n="",collapsedSize:t,collapsible:i,defaultSize:r,forwardedRef:o,id:s,maxSize:l,minSize:u,onCollapse:c,onExpand:d,onResize:m,order:h,style:p,tagName:g="div",...v}){const f=a.useContext(fwe);if(null===f)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:k,getPanelSize:b,getPanelStyle:S,groupId:A,isPanelCollapsed:w,reevaluatePanelConstraints:C,registerPanel:M,resizePanel:T,unregisterPanel:E}=f,x=Bwe(s),N=a.useRef({callbacks:{onCollapse:c,onExpand:d,onResize:m},constraints:{collapsedSize:t,collapsible:i,defaultSize:r,maxSize:l,minSize:u},id:x,idIsFromProps:void 0!==s,order:h});a.useRef({didLogMissingDefaultSizeWarning:!1}),_we((()=>{const{callbacks:e,constraints:a}=N.current,n={...a};N.current.id=x,N.current.idIsFromProps=void 0!==s,N.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=m,a.collapsedSize=t,a.collapsible=i,a.defaultSize=r,a.maxSize=l,a.minSize=u,n.collapsedSize===a.collapsedSize&&n.collapsible===a.collapsible&&n.maxSize===a.maxSize&&n.minSize===a.minSize||C(N.current,n)})),_we((()=>{const e=N.current;return M(e),()=>{E(e)}}),[h,x,M,E]),a.useImperativeHandle(o,(()=>({collapse:()=>{y(N.current)},expand:e=>{k(N.current,e)},getId:()=>x,getSize:()=>b(N.current),isCollapsed:()=>w(N.current),isExpanded:()=>!w(N.current),resize:e=>{T(N.current,e)}})),[y,k,b,w,x,T]);const _=S(N.current,r);return a.createElement(g,{...v,children:e,className:n,id:x,style:{..._,...p},[bwe]:A,[Swe]:"",[Awe]:i||void 0,[wwe]:x,[Cwe]:parseFloat(""+_.flexGrow).toFixed(1)})}const zwe=a.forwardRef(((e,n)=>a.createElement(Rwe,{...e,forwardedRef:n})));Rwe.displayName="Panel",zwe.displayName="forwardRef(Panel)";let Dwe=null,Kwe=-1,Owe=null;function Hwe(e,a){var n,t;const i=function(e,a){if(a){const e=!!(a&Xwe),n=!!(a&eCe);if(a&Ywe)return e?"se-resize":n?"ne-resize":"e-resize";if(a&Qwe)return e?"sw-resize":n?"nw-resize":"w-resize";if(e)return"s-resize";if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,a);if(Dwe!==i){var r;if(Dwe=i,null===Owe&&(Owe=document.createElement("style"),document.head.appendChild(Owe)),Kwe>=0)null===(r=Owe.sheet)||void 0===r||r.removeRule(Kwe);Kwe=null!==(n=null===(t=Owe.sheet)||void 0===t?void 0:t.insertRule(`*{cursor: ${i} !important;}`))&&void 0!==n?n:-1}}function Iwe(e){return"keydown"===e.type}function Gwe(e){return e.type.startsWith("pointer")}function Fwe(e){return e.type.startsWith("mouse")}function Vwe(e){if(Gwe(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Fwe(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const Jwe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Uwe(e){const a=getComputedStyle(e);return"fixed"===a.position||(!("auto"===a.zIndex||"static"===a.position&&!function(e){var a;const n=getComputedStyle(null!==(a=$we(e))&&void 0!==a?a:e).display;return"flex"===n||"inline-flex"===n}(e))||(+a.opacity<1||("transform"in a&&"none"!==a.transform||("webkitTransform"in a&&"none"!==a.webkitTransform||("mixBlendMode"in a&&"normal"!==a.mixBlendMode||("filter"in a&&"none"!==a.filter||("webkitFilter"in a&&"none"!==a.webkitFilter||("isolation"in a&&"isolate"===a.isolation||(!!Jwe.test(a.willChange)||"touch"===a.webkitOverflowScrolling)))))))))}function Wwe(e){let a=e.length;for(;a--;){const n=e[a];if(fCe(n,"Missing node"),Uwe(n))return n}return null}function qwe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Zwe(e){const a=[];for(;e;)a.push(e),e=$we(e);return a}function $we(e){const{parentNode:a}=e;return a&&a instanceof ShadowRoot?a.host:a}const Ywe=1,Qwe=2,Xwe=4,eCe=8,aCe="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let nCe=[],tCe=!1,iCe=new Map,rCe=new Map;const oCe=new Set;function sCe(e){const{target:a}=e,{x:n,y:t}=Vwe(e);tCe=!0,dCe({target:a,x:n,y:t}),gCe(),nCe.length>0&&(vCe("down",e),e.preventDefault(),cCe(a)||e.stopImmediatePropagation())}function lCe(e){const{x:a,y:n}=Vwe(e);if(tCe&&0===e.buttons&&(tCe=!1,vCe("up",e)),!tCe){const{target:t}=e;dCe({target:t,x:a,y:n})}vCe("move",e),hCe(),nCe.length>0&&e.preventDefault()}function uCe(e){const{target:a}=e,{x:n,y:t}=Vwe(e);rCe.clear(),tCe=!1,nCe.length>0&&(e.preventDefault(),cCe(a)||e.stopImmediatePropagation()),vCe("up",e),dCe({target:a,x:n,y:t}),hCe(),gCe()}function cCe(e){let a=e;for(;a;){if(a.hasAttribute(Mwe))return!0;a=a.parentElement}return!1}function dCe({target:e,x:a,y:n}){nCe.splice(0);let t=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(t=e),oCe.forEach((e=>{const{element:i,hitAreaMargins:r}=e,o=i.getBoundingClientRect(),{bottom:s,left:l,right:u,top:c}=o,d=aCe?r.coarse:r.fine;if(a>=l-d&&a<=u+d&&n>=c-d&&n<=s+d){if(null!==t&&document.contains(t)&&i!==t&&!i.contains(t)&&!t.contains(i)&&function(e,a){if(e===a)throw new Error("Cannot compare node with itself");const n={a:Zwe(e),b:Zwe(a)};let t;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),a=n.b.pop(),t=e;fCe(t,"Stacking order can only be calculated for elements with a common ancestor");const i=qwe(Wwe(n.a)),r=qwe(Wwe(n.b));if(i===r){const e=t.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let i=e.length;for(;i--;){const n=e[i];if(n===a.a)return 1;if(n===a.b)return-1}}return Math.sign(i-r)}(t,i)>0){let e=t,a=!1;for(;e&&!e.contains(i);){if((m=e.getBoundingClientRect()).x<(h=o).x+h.width&&m.x+m.width>h.x&&m.y<h.y+h.height&&m.y+m.height>h.y){a=!0;break}e=e.parentElement}if(a)return}nCe.push(e)}var m,h}))}function mCe(e,a){rCe.set(e,a)}function hCe(){let e=!1,a=!1;nCe.forEach((n=>{const{direction:t}=n;"horizontal"===t?e=!0:a=!0}));let n=0;rCe.forEach((e=>{n|=e})),e&&a?Hwe("intersection",n):e?Hwe("horizontal",n):a?Hwe("vertical",n):null!==Owe&&(document.head.removeChild(Owe),Dwe=null,Owe=null,Kwe=-1)}let pCe=new AbortController;function gCe(){pCe.abort(),pCe=new AbortController;const e={capture:!0,signal:pCe.signal};oCe.size&&(tCe?(nCe.length>0&&iCe.forEach(((a,n)=>{const{body:t}=n;a>0&&(t.addEventListener("contextmenu",uCe,e),t.addEventListener("pointerleave",lCe,e),t.addEventListener("pointermove",lCe,e))})),iCe.forEach(((a,n)=>{const{body:t}=n;t.addEventListener("pointerup",uCe,e),t.addEventListener("pointercancel",uCe,e)}))):iCe.forEach(((a,n)=>{const{body:t}=n;a>0&&(t.addEventListener("pointerdown",sCe,e),t.addEventListener("pointermove",lCe,e))})))}function vCe(e,a){oCe.forEach((n=>{const{setResizeHandlerState:t}=n,i=nCe.includes(n);t(e,i,a)}))}function fCe(e,a){if(!e)throw Error(a)}function yCe(e,a,n=10){return e.toFixed(n)===a.toFixed(n)?0:e>a?1:-1}function kCe(e,a,n=10){return 0===yCe(e,a,n)}function bCe(e,a,n){return 0===yCe(e,a,n)}function SCe({panelConstraints:e,panelIndex:a,size:n}){const t=e[a];fCe(null!=t,`Panel constraints not found for index ${a}`);let{collapsedSize:i=0,collapsible:r,maxSize:o=100,minSize:s=0}=t;if(yCe(n,s)<0)if(r){n=yCe(n,(i+s)/2)<0?i:s}else n=s;return n=Math.min(o,n),n=parseFloat(n.toFixed(10))}function ACe({delta:e,initialLayout:a,panelConstraints:n,pivotIndices:t,prevLayout:i,trigger:r}){if(bCe(e,0))return a;const o=[...a],[s,l]=t;fCe(null!=s,"Invalid first pivot index"),fCe(null!=l,"Invalid second pivot index");let u=0;if("keyboard"===r){{const t=e<0?l:s,i=n[t];fCe(i,`Panel constraints not found for index ${t}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const n=a[t];if(fCe(null!=n,`Previous layout not found for panel index ${t}`),bCe(n,r)){const a=u-n;yCe(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}{const t=e<0?s:l,i=n[t];fCe(i,`No panel constraints found for index ${t}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const n=a[t];if(fCe(null!=n,`Previous layout not found for panel index ${t}`),bCe(n,u)){const a=n-r;yCe(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}}{const t=e<0?1:-1;let i=e<0?l:s,r=0;for(;;){const e=a[i];fCe(null!=e,`Previous layout not found for panel index ${i}`);if(r+=SCe({panelConstraints:n,panelIndex:i,size:100})-e,i+=t,i<0||i>=n.length)break}const o=Math.min(Math.abs(e),Math.abs(r));e=e<0?0-o:o}{let t=e<0?s:l;for(;t>=0&&t<n.length;){const i=Math.abs(e)-Math.abs(u),r=a[t];fCe(null!=r,`Previous layout not found for panel index ${t}`);const s=SCe({panelConstraints:n,panelIndex:t,size:r-i});if(!bCe(r,s)&&(u+=r-s,o[t]=s,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(function(e,a,n){if(e.length!==a.length)return!1;for(let t=0;t<e.length;t++)if(!bCe(e[t],a[t],n))return!1;return!0}(i,o))return i;{const t=e<0?l:s,i=a[t];fCe(null!=i,`Previous layout not found for panel index ${t}`);const r=i+u,c=SCe({panelConstraints:n,panelIndex:t,size:r});if(o[t]=c,!bCe(c,r)){let a=r-c;let t=e<0?l:s;for(;t>=0&&t<n.length;){const i=o[t];fCe(null!=i,`Previous layout not found for panel index ${t}`);const r=SCe({panelConstraints:n,panelIndex:t,size:i+a});if(bCe(i,r)||(a-=r-i,o[t]=r),bCe(a,0))break;e>0?t--:t++}}}return bCe(o.reduce(((e,a)=>a+e),0),100)?o:i}function wCe({layout:e,panelsArray:a,pivotIndices:n}){let t=0,i=100,r=0,o=0;const s=n[0];fCe(null!=s,"No pivot index found"),a.forEach(((e,a)=>{const{constraints:n}=e,{maxSize:l=100,minSize:u=0}=n;a===s?(t=u,i=l):(r+=u,o+=l)}));return{valueMax:Math.min(i,100-r),valueMin:Math.max(t,100-o),valueNow:e[s]}}function CCe(e,a=document){return Array.from(a.querySelectorAll(`[${xwe}][data-panel-group-id="${e}"]`))}function MCe(e,a,n=document){const t=CCe(e,n).findIndex((e=>e.getAttribute(xwe)===a));return null!=t?t:null}function TCe(e,a,n){const t=MCe(e,a,n);return null!=t?[t,t+1]:[-1,-1]}function ECe(e,a=document){var n;if(a instanceof HTMLElement&&(null==a||null===(n=a.dataset)||void 0===n?void 0:n.panelGroupId)==e)return a;const t=a.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return t||null}function xCe(e,a=document){const n=a.querySelector(`[${xwe}="${e}"]`);return n||null}function NCe({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:i,panelDataArray:r,panelGroupElement:o,setLayout:s}){a.useRef({didWarnAboutMissingResizeHandle:!1}),_we((()=>{if(!o)return;const e=CCe(t,o);for(let a=0;a<r.length-1;a++){const{valueMax:n,valueMin:t,valueNow:o}=wCe({layout:i,panelsArray:r,pivotIndices:[a,a+1]}),s=e[a];if(null==s);else{const e=r[a];fCe(e,`No panel data found for index "${a}"`),s.setAttribute("aria-controls",e.id),s.setAttribute("aria-valuemax",""+Math.round(n)),s.setAttribute("aria-valuemin",""+Math.round(t)),s.setAttribute("aria-valuenow",null!=o?""+Math.round(o):"")}}return()=>{e.forEach(((e,a)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")}))}}),[t,i,r,o]),a.useEffect((()=>{if(!o)return;const e=n.current;fCe(e,"Eager values not found");const{panelDataArray:a}=e;fCe(null!=ECe(t,o),`No group found for id "${t}"`);const r=CCe(t,o);fCe(r,`No resize handles found for group id "${t}"`);const l=r.map((e=>{const n=e.getAttribute(xwe);fCe(n,"Resize handle element has no handle id attribute");const[r,l]=function(e,a,n,t=document){var i,r,o,s;const l=xCe(a,t),u=CCe(e,t),c=l?u.indexOf(l):-1;return[null!==(i=null===(r=n[c])||void 0===r?void 0:r.id)&&void 0!==i?i:null,null!==(o=null===(s=n[c+1])||void 0===s?void 0:s.id)&&void 0!==o?o:null]}(t,n,a,o);if(null==r||null==l)return()=>{};const u=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=a.findIndex((e=>e.id===r));if(l>=0){const e=a[l];fCe(e,`No panel data found for index ${l}`);const r=i[l],{collapsedSize:u=0,collapsible:c,minSize:d=0}=e.constraints;if(null!=r&&c){const e=ACe({delta:bCe(r,u)?d-u:u-r,initialLayout:i,panelConstraints:a.map((e=>e.constraints)),pivotIndices:TCe(t,n,o),prevLayout:i,trigger:"keyboard"});i!==e&&s(e)}}break}}};return e.addEventListener("keydown",u),()=>{e.removeEventListener("keydown",u)}}));return()=>{l.forEach((e=>e()))}}),[o,e,n,t,i,r,s])}function _Ce(e,a){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==a[n])return!1;return!0}function PCe(e,a){const n="horizontal"===e,{x:t,y:i}=Vwe(a);return n?t:i}function LCe(e,a,n,t,i,r){if(Iwe(e)){const a="horizontal"===n;let t=0;t=e.shiftKey?100:null!=i?i:10;let r=0;switch(e.key){case"ArrowDown":r=a?0:t;break;case"ArrowLeft":r=a?-t:0;break;case"ArrowRight":r=a?t:0;break;case"ArrowUp":r=a?0:-t;break;case"End":r=100;break;case"Home":r=-100}return r}return null==t?0:function(e,a,n,t,i){const r="horizontal"===n,o=xCe(a,i);fCe(o,`No resize handle element found for id "${a}"`);const s=o.getAttribute(bwe);fCe(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=t;const u=PCe(n,e),c=ECe(s,i);fCe(c,`No group element found for id "${s}"`);const d=c.getBoundingClientRect();return(u-l)/(r?d.width:d.height)*100}(e,a,n,t,r)}function jCe(e,a,n){a.forEach(((a,t)=>{const i=e[t];fCe(i,`Panel data not found for index ${t}`);const{callbacks:r,constraints:o,id:s}=i,{collapsedSize:l=0,collapsible:u}=o,c=n[s];if(null==c||a!==c){n[s]=a;const{onCollapse:e,onExpand:t,onResize:i}=r;i&&i(a,c),u&&(e||t)&&(!t||null!=c&&!kCe(c,l)||kCe(a,l)||t(),!e||null!=c&&kCe(c,l)||!kCe(a,l)||e())}}))}function BCe(e,a){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=a[n])return!1;return!0}function RCe(e){try{if("undefined"==typeof localStorage)throw new Error("localStorage not supported in this environment");e.getItem=e=>localStorage.getItem(e),e.setItem=(e,a)=>{localStorage.setItem(e,a)}}catch(a){e.getItem=()=>null,e.setItem=()=>{}}}function zCe(e){return`react-resizable-panels:${e}`}function DCe(e){return e.map((e=>{const{constraints:a,id:n,idIsFromProps:t,order:i}=e;return t?n:i?`${i}:${JSON.stringify(a)}`:JSON.stringify(a)})).sort(((e,a)=>e.localeCompare(a))).join(",")}function KCe(e,a){try{const n=zCe(e),t=a.getItem(n);if(t){const e=JSON.parse(t);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function OCe(e,a,n,t,i){var r;const o=zCe(e),s=DCe(a),l=null!==(r=KCe(e,i))&&void 0!==r?r:{};l[s]={expandToSizes:Object.fromEntries(n.entries()),layout:t};try{i.setItem(o,JSON.stringify(l))}catch(u){}}function HCe({layout:e,panelConstraints:a}){const n=[...e],t=n.reduce(((e,a)=>e+a),0);if(n.length!==a.length)throw Error(`Invalid ${a.length} panel layout: ${n.map((e=>`${e}%`)).join(", ")}`);if(!bCe(t,100)&&n.length>0)for(let r=0;r<a.length;r++){const e=n[r];fCe(null!=e,`No layout data found for index ${r}`);n[r]=100/t*e}let i=0;for(let r=0;r<a.length;r++){const e=n[r];fCe(null!=e,`No layout data found for index ${r}`);const t=SCe({panelConstraints:a,panelIndex:r,size:e});e!=t&&(i+=e-t,n[r]=t)}if(!bCe(i,0))for(let r=0;r<a.length;r++){const e=n[r];fCe(null!=e,`No layout data found for index ${r}`);const t=SCe({panelConstraints:a,panelIndex:r,size:e+i});if(e!==t&&(i-=t-e,n[r]=t,bCe(i,0)))break}return n}const ICe={getItem:e=>(RCe(ICe),ICe.getItem(e)),setItem:(e,a)=>{RCe(ICe),ICe.setItem(e,a)}},GCe={};function FCe({autoSaveId:e=null,children:n,className:t="",direction:i,forwardedRef:r,id:o=null,onLayout:s=null,keyboardResizeBy:l=null,storage:u=ICe,style:c,tagName:d="div",...m}){const h=Bwe(o),p=a.useRef(null),[g,v]=a.useState(null),[f,y]=a.useState([]),k=function(){const[e,n]=a.useState(0);return a.useCallback((()=>n((e=>e+1))),[])}(),b=a.useRef({}),S=a.useRef(new Map),A=a.useRef(0),w=a.useRef({autoSaveId:e,direction:i,dragState:g,id:h,keyboardResizeBy:l,onLayout:s,storage:u}),C=a.useRef({layout:f,panelDataArray:[],panelDataArrayChanged:!1});a.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),a.useImperativeHandle(r,(()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:e}=C.current;return e},setLayout:e=>{const{onLayout:a}=w.current,{layout:n,panelDataArray:t}=C.current,i=HCe({layout:e,panelConstraints:t.map((e=>e.constraints))});_Ce(n,i)||(y(i),C.current.layout=i,a&&a(i),jCe(t,i,b.current))}})),[]),_we((()=>{w.current.autoSaveId=e,w.current.direction=i,w.current.dragState=g,w.current.id=h,w.current.onLayout=s,w.current.storage=u})),NCe({committedValuesRef:w,eagerValuesRef:C,groupId:h,layout:f,panelDataArray:C.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),a.useEffect((()=>{const{panelDataArray:a}=C.current;if(e){if(0===f.length||f.length!==a.length)return;let n=GCe[e];null==n&&(n=function(e,a=10){let n=null;return(...t)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...t)}),a)}}(OCe,100),GCe[e]=n);const t=[...a],i=new Map(S.current);n(e,t,i,f,u)}}),[e,f,u]),a.useEffect((()=>{}));const M=a.useCallback((e=>{const{onLayout:a}=w.current,{layout:n,panelDataArray:t}=C.current;if(e.constraints.collapsible){const i=t.map((e=>e.constraints)),{collapsedSize:r=0,panelSize:o,pivotIndices:s}=UCe(t,e,n);if(fCe(null!=o,`Panel size not found for panel "${e.id}"`),!kCe(o,r)){S.current.set(e.id,o);const l=ACe({delta:JCe(t,e)===t.length-1?o-r:r-o,initialLayout:n,panelConstraints:i,pivotIndices:s,prevLayout:n,trigger:"imperative-api"});BCe(n,l)||(y(l),C.current.layout=l,a&&a(l),jCe(t,l,b.current))}}}),[]),T=a.useCallback(((e,a)=>{const{onLayout:n}=w.current,{layout:t,panelDataArray:i}=C.current;if(e.constraints.collapsible){const r=i.map((e=>e.constraints)),{collapsedSize:o=0,panelSize:s=0,minSize:l=0,pivotIndices:u}=UCe(i,e,t),c=null!=a?a:l;if(kCe(s,o)){const a=S.current.get(e.id),o=null!=a&&a>=c?a:c,l=ACe({delta:JCe(i,e)===i.length-1?s-o:o-s,initialLayout:t,panelConstraints:r,pivotIndices:u,prevLayout:t,trigger:"imperative-api"});BCe(t,l)||(y(l),C.current.layout=l,n&&n(l),jCe(i,l,b.current))}}}),[]),E=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{panelSize:t}=UCe(n,e,a);return fCe(null!=t,`Panel size not found for panel "${e.id}"`),t}),[]),x=a.useCallback(((e,a)=>{const{panelDataArray:n}=C.current,t=JCe(n,e);return function({defaultSize:e,dragState:a,layout:n,panelData:t,panelIndex:i,precision:r=3}){const o=n[i];let s;return s=null==o?null!=e?e.toPrecision(r):"1":1===t.length?"1":o.toPrecision(r),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:null!==a?"none":void 0}}({defaultSize:a,dragState:g,layout:f,panelData:n,panelIndex:t})}),[g,f]),N=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{collapsedSize:t=0,collapsible:i,panelSize:r}=UCe(n,e,a);return fCe(null!=r,`Panel size not found for panel "${e.id}"`),!0===i&&kCe(r,t)}),[]),_=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{collapsedSize:t=0,collapsible:i,panelSize:r}=UCe(n,e,a);return fCe(null!=r,`Panel size not found for panel "${e.id}"`),!i||yCe(r,t)>0}),[]),P=a.useCallback((e=>{const{panelDataArray:a}=C.current;a.push(e),a.sort(((e,a)=>{const n=e.order,t=a.order;return null==n&&null==t?0:null==n?-1:null==t?1:n-t})),C.current.panelDataArrayChanged=!0,k()}),[k]);_we((()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:a,storage:n}=w.current,{layout:t,panelDataArray:i}=C.current;let r=null;if(e){const a=function(e,a,n){var t,i;return null!==(i=(null!==(t=KCe(e,n))&&void 0!==t?t:{})[DCe(a)])&&void 0!==i?i:null}(e,i,n);a&&(S.current=new Map(Object.entries(a.expandToSizes)),r=a.layout)}null==r&&(r=function({panelDataArray:e}){const a=Array(e.length),n=e.map((e=>e.constraints));let t=0,i=100;for(let r=0;r<e.length;r++){const e=n[r];fCe(e,`Panel constraints not found for index ${r}`);const{defaultSize:o}=e;null!=o&&(t++,a[r]=o,i-=o)}for(let r=0;r<e.length;r++){const o=n[r];fCe(o,`Panel constraints not found for index ${r}`);const{defaultSize:s}=o;if(null!=s)continue;const l=i/(e.length-t);t++,a[r]=l,i-=l}return a}({panelDataArray:i}));const o=HCe({layout:r,panelConstraints:i.map((e=>e.constraints))});_Ce(t,o)||(y(o),C.current.layout=o,a&&a(o),jCe(i,o,b.current))}})),_we((()=>{const e=C.current;return()=>{e.layout=[]}}),[]);const L=a.useCallback((e=>{let a=!1;const n=p.current;if(n){"rtl"===window.getComputedStyle(n,null).getPropertyValue("direction")&&(a=!0)}return function(n){n.preventDefault();const t=p.current;if(!t)return()=>null;const{direction:i,dragState:r,id:o,keyboardResizeBy:s,onLayout:l}=w.current,{layout:u,panelDataArray:c}=C.current,{initialLayout:d}=null!=r?r:{},m=TCe(o,e,t);let h=LCe(n,e,i,r,s,t);const g="horizontal"===i;g&&a&&(h=-h);const v=ACe({delta:h,initialLayout:null!=d?d:u,panelConstraints:c.map((e=>e.constraints)),pivotIndices:m,prevLayout:u,trigger:Iwe(n)?"keyboard":"mouse-or-touch"}),f=!BCe(u,v);(Gwe(n)||Fwe(n))&&A.current!=h&&(A.current=h,mCe(e,f||0===h?0:g?h<0?Ywe:Qwe:h<0?Xwe:eCe)),f&&(y(v),C.current.layout=v,l&&l(v),jCe(c,v,b.current))}}),[]),j=a.useCallback(((e,a)=>{const{onLayout:n}=w.current,{layout:t,panelDataArray:i}=C.current,r=i.map((e=>e.constraints)),{panelSize:o,pivotIndices:s}=UCe(i,e,t);fCe(null!=o,`Panel size not found for panel "${e.id}"`);const l=ACe({delta:JCe(i,e)===i.length-1?o-a:a-o,initialLayout:t,panelConstraints:r,pivotIndices:s,prevLayout:t,trigger:"imperative-api"});BCe(t,l)||(y(l),C.current.layout=l,n&&n(l),jCe(i,l,b.current))}),[]),B=a.useCallback(((e,a)=>{const{layout:n,panelDataArray:t}=C.current,{collapsedSize:i=0,collapsible:r}=a,{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:u=0}=e.constraints,{panelSize:c}=UCe(t,e,n);null!=c&&(r&&s&&kCe(c,i)?kCe(i,o)||j(e,o):c<u?j(e,u):c>l&&j(e,l))}),[j]),R=a.useCallback(((e,a)=>{const{direction:n}=w.current,{layout:t}=C.current;if(!p.current)return;const i=xCe(e,p.current);fCe(i,`Drag handle element not found for id "${e}"`);const r=PCe(n,a);v({dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:r,initialLayout:t})}),[]),z=a.useCallback((()=>{v(null)}),[]),D=a.useCallback((e=>{const{panelDataArray:a}=C.current,n=JCe(a,e);n>=0&&(a.splice(n,1),delete b.current[e.id],C.current.panelDataArrayChanged=!0,k())}),[k]),K=a.useMemo((()=>({collapsePanel:M,direction:i,dragState:g,expandPanel:T,getPanelSize:E,getPanelStyle:x,groupId:h,isPanelCollapsed:N,isPanelExpanded:_,reevaluatePanelConstraints:B,registerPanel:P,registerResizeHandle:L,resizePanel:j,startDragging:R,stopDragging:z,unregisterPanel:D,panelGroupElement:p.current})),[M,g,i,T,E,x,h,N,_,B,P,L,j,R,z,D]);return a.createElement(fwe.Provider,{value:K},a.createElement(d,{...m,children:n,className:t,id:o,ref:p,style:{...{display:"flex",flexDirection:"horizontal"===i?"row":"column",height:"100%",overflow:"hidden",width:"100%"},...c},[ywe]:"",[kwe]:i,[bwe]:h}))}const VCe=a.forwardRef(((e,n)=>a.createElement(FCe,{...e,forwardedRef:n})));function JCe(e,a){return e.findIndex((e=>e===a||e.id===a.id))}function UCe(e,a,n){const t=JCe(e,a);return{...a.constraints,panelSize:n[t],pivotIndices:t===e.length-1?[t-1,t]:[t,t+1]}}function WCe({children:e=null,className:n="",disabled:t=!1,hitAreaMargins:i,id:r,onBlur:o,onClick:s,onDragging:l,onFocus:u,onPointerDown:c,onPointerUp:d,style:m={},tabIndex:h=0,tagName:p="div",...g}){var v,f;const y=a.useRef(null),k=a.useRef({onClick:s,onDragging:l,onPointerDown:c,onPointerUp:d});a.useEffect((()=>{k.current.onClick=s,k.current.onDragging=l,k.current.onPointerDown=c,k.current.onPointerUp=d}));const b=a.useContext(fwe);if(null===b)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:A,registerResizeHandle:w,startDragging:C,stopDragging:M,panelGroupElement:T}=b,E=Bwe(r),[x,N]=a.useState("inactive"),[_,P]=a.useState(!1),[L,j]=a.useState(null),B=a.useRef({state:x});_we((()=>{B.current.state=x})),a.useEffect((()=>{if(t)j(null);else{const e=w(E);j((()=>e))}}),[t,E,w]);const R=null!==(v=null==i?void 0:i.coarse)&&void 0!==v?v:15,z=null!==(f=null==i?void 0:i.fine)&&void 0!==f?f:5;a.useEffect((()=>{if(t||null==L)return;const e=y.current;fCe(e,"Element ref not attached");let a=!1;return function(e,a,n,t,i){var r;const{ownerDocument:o}=a,s={direction:n,element:a,hitAreaMargins:t,setResizeHandlerState:i},l=null!==(r=iCe.get(o))&&void 0!==r?r:0;return iCe.set(o,l+1),oCe.add(s),gCe(),function(){var a;rCe.delete(e),oCe.delete(s);const n=null!==(a=iCe.get(o))&&void 0!==a?a:1;if(iCe.set(o,n-1),gCe(),1===n&&iCe.delete(o),nCe.includes(s)){const e=nCe.indexOf(s);e>=0&&nCe.splice(e,1),hCe(),i("up",!0,null)}}}(E,e,S,{coarse:R,fine:z},((e,n,t)=>{if(n)switch(e){case"down":{N("drag"),a=!1,fCe(t,'Expected event to be defined for "down" action'),C(E,t);const{onDragging:e,onPointerDown:n}=k.current;null==e||e(!0),null==n||n();break}case"move":{const{state:e}=B.current;a=!0,"drag"!==e&&N("hover"),fCe(t,'Expected event to be defined for "move" action'),L(t);break}case"up":{N("hover"),M();const{onClick:e,onDragging:n,onPointerUp:t}=k.current;null==n||n(!1),null==t||t(),a||null==e||e();break}}else N("inactive")}))}),[R,S,t,z,w,E,L,C,M]),function({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:i}){a.useEffect((()=>{if(e||null==t||null==i)return;const a=xCe(n,i);if(null==a)return;const r=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),t(e);break;case"F6":{e.preventDefault();const t=a.getAttribute(bwe);fCe(t,`No group element found for id "${t}"`);const r=CCe(t,i),o=MCe(t,n,i);fCe(null!==o,`No resize element found for id "${n}"`),r[e.shiftKey?o>0?o-1:r.length-1:o+1<r.length?o+1:0].focus();break}}};return a.addEventListener("keydown",r),()=>{a.removeEventListener("keydown",r)}}),[i,e,n,t])}({disabled:t,handleId:E,resizeHandler:L,panelGroupElement:T});return a.createElement(p,{...g,children:e,className:n,id:r,onBlur:()=>{P(!1),null==o||o()},onFocus:()=>{P(!0),null==u||u()},ref:y,role:"separator",style:{touchAction:"none",userSelect:"none",...m},tabIndex:h,[kwe]:S,[bwe]:A,[Mwe]:"",[Twe]:"drag"===x?"pointer":_?"keyboard":void 0,[Ewe]:!t,[xwe]:E,[Nwe]:x})}FCe.displayName="PanelGroup",VCe.displayName="forwardRef(PanelGroup)",WCe.displayName="PanelResizeHandle";const qCe=({className:e,...a})=>n.jsx(VCe,{className:P$("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...a}),ZCe=zwe,$Ce=({withHandle:e,className:a,...t})=>n.jsx(WCe,{className:P$("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...t,children:e&&n.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:n.jsx(Vc,{className:"h-2.5 w-2.5"})})}),YCe=({copyText:e})=>n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),QCe="rgba(245, 246, 247, 1)",XCe={[ca.SEND_COMMUNICATION]:{color:{bg:QCe},clickable:!0},[ca.WAIT_UNTIL_NEXT_FIXED_TIME]:{color:{bg:QCe},clickable:!1}},eMe={[ca.SEND_COMMUNICATION]:"Send Email & SMS",[ca.WAIT_UNTIL_NEXT_FIXED_TIME]:"Wait"},aMe=({children:e,onClick:a,iconBgColor:t,iconStrokeColor:i,Icon:r,disabled:o=!1,selected:s=!1})=>{const l=r;return n.jsxs(K4.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},style:{backgroundColor:s?t:QCe},onClick:a,className:vm("flex gap-2 items-center rounded-md transition-colors group","p-2 border-2 border-transparent overflow-hidden",!o&&"hover:border-primary cursor-pointer",s&&"border-primary"),children:[n.jsx("div",{className:vm("bg-purple-50 rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 transition-colors",!o&&"group-hover/trigger-audience:bg-background",t),children:n.jsx(l,{className:vm("w-4 h-4 stroke-purple-500 group-hover/trigger-audience:fill-purple-50 transition-colors",i)})}),e]})},nMe=({segmentName:e})=>n.jsx("span",{className:"inline-flex items-center bg-white border border-gray-200 rounded-md px-2 py-0.5 text-sm font-medium shadow-sm",children:e}),tMe=()=>{const e=d5(),{setActionId:t,state:{selectedActionId:i}}=a.useContext(Q4),[r,o]=a.useState(e?.includeSegmentIds||null),[s,l]=a.useState(e?.excludeSegmentIds||null),{segments:u}=t5(),c=a.useCallback((()=>u?.find((e=>e.type===l5.ALL_USERS))),[u]);return a.useEffect((()=>{e&&u&&(null===r&&null===s?(o(e?.includeSegmentIds||null),l(e?.excludeSegmentIds||null),0===e.includeSegmentIds.length&&0===e.excludeSegmentIds.length&&(o([c()?.id||""]),l([]))):(JSON.stringify(e.includeSegmentIds)!==JSON.stringify(r)&&o(e.includeSegmentIds),JSON.stringify(e.excludeSegmentIds)!==JSON.stringify(s)&&l(e.excludeSegmentIds)))}),[e,s,r,u,c]),e&&r&&s?n.jsx(n.Fragment,{children:n.jsx(aMe,{selected:i===bme.EditAudience,iconBgColor:"bg-purple-50",iconStrokeColor:"stroke-purple-500",onClick:()=>{t(bme.EditAudience)},Icon:w5.AudienceIcon,children:n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Lye,{children:"Audience"}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(YCe,{copyText:`Send to all ${_h("engage:user",{count:2})} in ${1===r.length?"this":"these"} ${_h("engage:segment",{count:r.length}).toLowerCase()}`}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map((e=>{const a=u?.find((a=>a.id===e));return a?n.jsx(nMe,{segmentName:a.name},e):null}))})]})]})})}):null},iMe=()=>{const e=d5(),{setActionId:t,state:{selectedActionId:i}}=a.useContext(Q4),{segments:r}=t5(),o=_h(e?.triggerType===sa.TRIGGER_BASED?"engage:automation":"engage:broadcast"),s=`Start this ${o?.toLowerCase()}`;if(!e||!r)return null;return n.jsx(n.Fragment,{children:(()=>{switch(e.triggerType){case sa.TRIGGER_BASED:{if(e.triggerMetadata&&e.triggerMetadata.triggerType!==sa.TRIGGER_BASED||!e.triggerMetadata||e.triggerMetadata.eventName!==la.USER_ENTERS_SEGMENT||!e.triggerMetadata.eventFilter.segment_id)return null;const a=e.triggerMetadata.eventFilter.segment_id,t=r.find((e=>e.id===a))?.name;return t?n.jsx(aMe,{iconBgColor:"bg-amber-100",disabled:!0,iconStrokeColor:"stroke-amber-500",onClick:()=>{},Icon:w5.TriggerIcon,children:n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Lye,{children:s}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(YCe,{copyText:`When ${_h("engage:user").toLowerCase()} joins the`}),n.jsx(nMe,{segmentName:t})]})]})}):null}case sa.ONE_TIME:{const a=!e.triggerMetadata||!("scheduledAt"in e.triggerMetadata);return n.jsxs(aMe,{iconBgColor:"bg-amber-100",iconStrokeColor:"stroke-amber-500",onClick:()=>{t(bme.EditTime)},selected:i===bme.EditTime,Icon:w5.TriggerIcon,children:[n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Lye,{children:s}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(YCe,a?{copyText:`Click to set the date and time for this ${_h("engage:broadcast")}`}:{copyText:"Bulk send at"}),!1===a&&e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&e.triggerMetadata.scheduledAt&&n.jsx("div",{className:"text-xs font-medium",children:n.jsx(nMe,{segmentName:"now"===e.triggerMetadata.scheduledAt?"5 minutes after send":eue(new Date(e.triggerMetadata.scheduledAt),"h:mma MM/dd/yy")})})]})]}),n.jsx("div",{className:"",children:a&&n.jsx(pue,{title:`Please select a time before sending this ${_h("engage:broadcast")}.`,alertText:`A scheduled time is needed before sending this ${_h("engage:broadcast")}.`,Icon:w5.AlertTriangleIcon,iconColor:"text-red-500",size:"large"})})]})}default:throw ire(e.triggerType,sa)}})()})},rMe=({type:e,disabled:t=!1,actionId:i})=>{const{state:{selectedSubStepType:r},setSelectedSubStepType:o,setActionId:s}=a.useContext(Q4),l=m5(),u=r===e,c=a.useCallback((()=>{if(!l)return"Need to select a channel";switch(e){case Sme.EMAIL:return l.emailChannelSenderId?l.emailHtmlBody?!!l.emailSubject||"Please add a subject to the email":"Please add content to the email":"Please select a email sender";case Sme.SMS:return l.smsChannelSenderId?!!l.smsMessageBody||"Please add content to the sms":"Please select a sms sender"}}),[l,e]);if(t)return null;const d=c();return n.jsx(K4.div,{layout:!0,initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15,ease:"easeInOut"},className:vm("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group","border-2 border-transparent",u&&"border-primary",!t&&"hover:border-muted-foreground/30",t&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:u?"#f5f6f7":QCe},onClick:()=>{t||(s(i),o(e))},children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"rounded-md p-1.5 flex items-center justify-center w-6 h-6 flex-shrink-0 bg-white border",children:((e,a)=>{switch(e){case Sme.EMAIL:return n.jsx(w5.EmailIcon,{className:vm("w-6 h-6",a?"text-primary":"text-gray-400")});case Sme.SMS:return n.jsx(w5.SmsIcon,{className:vm("w-6 h-6",a?"text-primary":"text-gray-400")})}})(e,u)}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("div",{style:{color:u?"#3b82f6":"#64748b"},children:n.jsx(Lye,{className:"text-xs",children:(()=>{switch(e){case Sme.EMAIL:return"Email";case Sme.SMS:return"SMS"}})()})}),n.jsx("div",{className:"text-[10px] font-medium text-muted-foreground",children:(()=>{if(!l)return"";switch(e){case Sme.EMAIL:return l.emailSubject||"No subject set";case Sme.SMS:return l.smsMessageBody?`${l.smsMessageBody.substring(0,40)}${l.smsMessageBody.length>40?"...":""}`:"No message set"}})()}),!0!==d&&n.jsx("div",{className:"text-[10px] text-amber-600 font-medium",children:d})]})]})})},oMe=e=>{switch(e){case ca.SEND_COMMUNICATION:return"Send Communication";case ca.WAIT_UNTIL_NEXT_FIXED_TIME:return"Wait";default:throw U4(e,ca)}},sMe=e=>{switch(e){case ca.SEND_COMMUNICATION:return n.jsx(w5.CommunicationIcon,{className:"w-4 h-4"});case ca.WAIT_UNTIL_NEXT_FIXED_TIME:return n.jsx(w5.WaitUntilNextFixedTimeIcon,{className:"w-4 h-4"});default:throw ire(e,ca)}},lMe=e=>{if(!(e&&e.actionType===ca.WAIT_UNTIL_NEXT_FIXED_TIME&&"hour"in e&&"minute"in e&&"timezone"in e))return null;const{hour:a,minute:n,timezone:t}=e;return`Wait until next ${`${a?.toString().padStart(2,"0")}:${n?.toString().padStart(2,"0")}`} ${t}`},uMe=({actionDataWithMetadata:e})=>{const{actionData:t,communicationGroup:i}=e,{state:{selectedActionId:r},setActionId:o,setSelectedCommunicationGroupId:s}=a.useContext(Q4),l=a.useMemo((()=>r===t.actionMetadata.currentActionId),[r,t.actionMetadata.currentActionId]),u=XCe[t.actionType],c=u.color,d=u.clickable;return n.jsxs(K4.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},className:vm("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group"," border-2 border-transparent",l&&"border-primary",t.actionType!==ca.WAIT_UNTIL_NEXT_FIXED_TIME&&"hover:border-primary"),style:{backgroundColor:l?c.bg:c.bgUnselected??QCe},onClick:()=>{d&&(o(t.actionMetadata.currentActionId),t.actionType===ca.SEND_COMMUNICATION&&s(t.actionMetadata.communicationGroupId))},children:[n.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[n.jsx("div",{className:"rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 bg-white",children:sMe(t.actionType)}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{style:{color:l?c.text:c.textUnselected},children:n.jsx(Lye,{children:eMe[t.actionType]})}),n.jsx("div",t.actionType===ca.WAIT_UNTIL_NEXT_FIXED_TIME?{className:"text-[11px] text-muted-foreground font-normal rounded bg-muted/40 w-fit max-w-full truncate",children:lMe(t.actionMetadata)}:{className:"text-xs font-medium text-muted-foreground",children:t.actionType===ca.SEND_COMMUNICATION&&i?.emailSubject?i?.emailSubject:oMe(t.actionType)})]})]}),t.actionType===ca.SEND_COMMUNICATION&&n.jsx("div",{className:"flex items-center pr-2",children:n.jsx(w5.NextButton,l?{className:"w-4 h-4 text-muted-foreground rotate-90 transition-transform duration-200"}:{className:"w-4 h-4 text-muted-foreground transition-transform duration-200"})})]})},cMe=()=>{const e=m5(),[t,i]=a.useState(!1),[r,o]=a.useState(void 0),s=d5(),{setActionId:l,setSelectedSubStepType:u,state:{selectedActionId:c,selectedSubStepType:d}}=a.useContext(Q4);if(ta(s?.id||""),a.useEffect((()=>{if(!s)return;if(c)return;const e=s.actionData?.find((e=>"send_communication"===e.actionType));e&&l(e.actionMetadata.currentActionId)}),[s,l,c]),a.useEffect((()=>{if(!s)return;(async()=>{const e=[];for(const a of s.actionData??[])switch(a.actionType){case ca.SEND_COMMUNICATION:{const n=await Fe(a.actionMetadata.communicationGroupId);e.push({actionData:a,communicationGroup:n});break}case ca.WAIT_UNTIL_NEXT_FIXED_TIME:e.push({actionData:a});break;default:throw U4(a.actionType,ca)}o(e)})()}),[s]),a.useEffect((()=>{if(c&&r&&e&&null===d){const a=r.find((e=>e.actionData.actionMetadata.currentActionId===c));"send_communication"===a?.actionData.actionType&&u(e?.emailChannelSenderId?Sme.EMAIL:Sme.SMS)}}),[c,r,u,e,d]),!s||!r)return null;const m=(e=>{const{steps:a,rootActionId:n}=e;if(!a||!n)return a??[];const t=new Map(a.map((e=>[e.actionData.actionMetadata.currentActionId,e]))),i=t.get(n);if(!i)return a;const r=[];let o=i;for(;o;){r.push(o);const e=o.actionData.actionMetadata.nextActionId;if(!e)break;o=t.get(e)}return r})({steps:r,rootActionId:s.triggerMetadata?.triggerType===sa.TRIGGER_BASED?s.triggerMetadata.rootActionId:void 0}).filter((e=>!!t||"send_communication"===e.actionData.actionType));let h=()=>n.jsx("div",{},"empty-trigger-audience");return(t||s.triggerType===sa.ONE_TIME)&&(h=()=>n.jsxs("div",{className:"flex flex-col gap-3",children:[s.triggerType===sa.ONE_TIME&&n.jsx(tMe,{}),s.triggerType!==sa.ONE_TIME&&n.jsx(iMe,{})]})),n.jsxs("div",{className:"flex-1 flex flex-col gap-2 w-full overflow-visible",children:[s.triggerType===sa.TRIGGER_BASED&&n.jsxs("div",{className:"flex gap-2 items-center justify-between",children:[n.jsx("div",{className:"text-[13px] text-muted-foreground",children:"Messages sent in listed order"}),n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx("div",{className:"text-[13px] font-medium",children:"Show all details"}),n.jsx(XSe,{defaultChecked:t,onCheckedChange:()=>{i(!t)}})]})]}),n.jsx("div",{className:"flex-1 flex flex-col gap-3",children:n.jsxs(eY,{mode:"popLayout",children:[h(),m.map(((a,t)=>n.jsx(K4.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,delay:.05*t,ease:"easeInOut"},children:n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(uMe,{actionDataWithMetadata:a}),"send_communication"===a.actionData.actionType&&c===a.actionData.actionMetadata.currentActionId&&a.actionData.actionMetadata.currentActionId&&n.jsxs("div",{className:"flex gap-3",children:[n.jsx(K4.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,delay:.25*m.length,ease:"easeInOut"},className:"w-12 flex justify-end items-center",children:n.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full rounded-full"})}),n.jsxs("div",{className:"flex flex-col gap-3 flex-1",children:[e?.emailChannelSenderId&&n.jsx(rMe,{type:Sme.EMAIL,actionId:a.actionData.actionMetadata.currentActionId}),e?.smsChannelSenderId&&n.jsx(rMe,{type:Sme.SMS,actionId:a.actionData.actionMetadata.currentActionId})]})]})]})},a.actionData.actionMetadata?.currentActionId??t))),s.triggerType===sa.ONE_TIME&&n.jsx("div",{className:"flex flex-col gap-3",children:n.jsx(iMe,{})},"one-time-trigger")]})})]})},dMe=()=>{const e=d5(),{segments:a}=t5();return n.jsx("div",e&&a?{className:"h-full pt-4 relative",children:n.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col gap-3",children:n.jsx(cMe,{})})}:{className:"flex h-full items-center justify-center",children:n.jsx(v5,{text:[`Getting details on your ${_h("engage:automation",{count:1}).toLowerCase()}`,"Finishing up"]})})},mMe=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1,hideSms:r=!1})=>{const{state:{selectedSubStepType:o}}=a.useContext(Q4);if(!m5())return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx(v5,{text:["Loading..."]})});if(!o)return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"text-center",children:[n.jsx("h3",{className:"text-lg font-medium text-muted-foreground mb-2",children:"Select Communication Type"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose Email or SMS from the steps on the left to preview and edit content"})]})})});const s={disablePreview:e,disableEditContent:t,disablePreviewSubtext:i};return n.jsxs("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:[o===Sme.EMAIL&&n.jsx(Sye,{...s}),o===Sme.SMS&&!r&&n.jsx(Mye,{...s})]})},hMe=()=>{const{state:{selectedActionId:e}}=a.useContext(Q4),{state:{hideSms:t}}=a.useContext(uq);return n.jsx("div",{className:"flex flex-col gap-4 h-full w-full",children:n.jsx(eY,{mode:"wait",children:e===bme.EditTime?n.jsx(RSe,{}):e===bme.EditAudience?n.jsx(fAe,{}):n.jsx(mMe,{hideSms:t})})})},pMe=()=>n.jsxs(qCe,{direction:"horizontal",className:"flex-1",children:[n.jsx(ZCe,{defaultSize:30,minSize:16,maxSize:48,children:n.jsx("aside",{className:"h-full",children:n.jsx(dMe,{})})}),n.jsx($Ce,{className:"px-1 opacity-0 hover:opacity-100 transition-opacity duration-200 mx-1"}),n.jsx(ZCe,{defaultSize:70,children:n.jsx("main",{className:"h-full",children:n.jsx(hMe,{})})})]}),gMe=()=>{const[e,t]=a.useState("workflow"),i=[{id:"workflow",label:"Workflow",content:n.jsx(pMe,{})},{id:"recipients",label:"Recipients",content:n.jsx(vwe,{})},{id:"insights",label:_h("engage:insight",{count:2}),content:n.jsx(pwe,{})}];return n.jsx(PAe,{tabs:i,activeTab:e,onTabChange:t,tabsLocation:"left"})},vMe=({showBackButton:e=!1,onDuplicationCreated:t,onBeforeSchedule:i,getExtraMergeFields:r,hideSms:o,hideSales:s,replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d})=>{const m=d5(),h=m5(),{updateCommunicationGroup:p}=$e(),{toast:g}=Ge(),{channelSenders:v}=fre(),f=a.useRef("");return a.useEffect((()=>{if(h&&r){(async()=>{const e=await r(),a=JSON.stringify(e);a!==f.current&&(f.current=a,p({groupId:h?.id,params:{extraMergeFields:e}},{onError:()=>{g({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}}))})()}}),[h,r,p,g]),a.useEffect((()=>{if(m&&h&&v&&m.automationType===ua.MANAGED&&null===h.emailChannelSenderId&&null===h.smsChannelSenderId){if(!h.emailChannelSenderId){const e=v.results.filter((e=>e.channelSenderMetadata.userPart));e.length>0&&p({groupId:h.id,params:{emailChannelSenderId:e[0].id}})}if(!h.smsChannelSenderId){const e=v.results.filter((e=>e.channelSenderMetadata.from||e.channelSenderMetadata.messageServiceSid));e.length>0&&p({groupId:h.id,params:{smsChannelSenderId:e[0].id}})}}}),[m,h,v,p]),m&&h?n.jsx(cq,{children:n.jsx(dq,{replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d,hideSms:o,hideSales:s,children:n.jsxs("div",{className:"h-full flex flex-col gap-4",children:[n.jsx(hwe,{showBackButton:e,onDuplicationCreated:t,onBeforeSchedule:i}),n.jsx("div",{className:"flex-1 border-t",children:n.jsx(gMe,{})})]})})}):n.jsx("div",{className:"flex h-screen items-center justify-center",children:n.jsx(v5,{text:[`Fetching ${_h("engage:automation").toLowerCase()} data`,"Finishing up"]})})},fMe=({...e})=>{const a=function(){let{matches:e}=r.useContext(Gne),a=e[e.length-1];return a?a.params:{}}(),[t]=Lte(),i=e.automationId||a?.automationId||t.get("automationId")||"",o="true"===t.get("showBackButton")||e.showBackButton;return n.jsx(p5,{automationId:i,children:n.jsx("div",{className:"bg-background h-full",children:n.jsx(vMe,{...e,showBackButton:o})})})};Object.values(Object.assign({}));var yMe=e=>null!=e;var kMe=e=>"function"!=typeof e||e.length?e:e(),bMe=e=>Array.isArray(e)?e:e?[e]:[];var SMe=Ha;var AMe,wMe=function(e){const[a,n]=Pa(),t=e?.throw?(e,a)=>{throw n(e instanceof Error?e:new Error(a)),e}:(e,a)=>{n(e instanceof Error?e:new Error(a))},i=e?.api?Array.isArray(e.api)?e.api:[e.api]:[globalThis.localStorage].filter(Boolean),r=e?.prefix?`${e.prefix}.`:"",o=new Map,s=new Proxy({},{get(a,n){let s=o.get(n);s||(s=Pa(void 0,{equals:!1}),o.set(n,s)),s[0]();const l=i.reduce(((e,a)=>{if(null!==e||!a)return e;try{return a.getItem(`${r}${n}`)}catch(QHe){return t(QHe,`Error reading ${r}${n} from ${a.name}`),null}}),null);return null!==l&&e?.deserializer?e.deserializer(l,n,e.options):l}});return!1!==e?.sync&&Oa((()=>{const e=e=>{let a=!1;i.forEach((n=>{try{n!==e.storageArea&&e.key&&e.newValue!==n.getItem(e.key)&&(e.newValue?n.setItem(e.key,e.newValue):n.removeItem(e.key),a=!0)}catch(QHe){t(QHe,`Error synching api ${n.name} from storage event (${e.key}=${e.newValue})`)}})),a&&e.key&&o.get(e.key)?.[1]()};"addEventListener"in globalThis?(globalThis.addEventListener("storage",e),Ha((()=>globalThis.removeEventListener("storage",e)))):(i.forEach((a=>a.addEventListener?.("storage",e))),Ha((()=>i.forEach((a=>a.removeEventListener?.("storage",e))))))})),[s,(a,n,s)=>{const l=e?.serializer?e.serializer(n,a,s??e.options):n,u=`${r}${a}`;i.forEach((e=>{try{e.getItem(u)!==l&&e.setItem(u,l)}catch(QHe){t(QHe,`Error setting ${r}${a} to ${l} in ${e.name}`)}}));const c=o.get(a);c&&c[1]()},{clear:()=>i.forEach((e=>{try{e.clear()}catch(QHe){t(QHe,`Error clearing ${e.name}`)}})),error:a,remove:e=>i.forEach((a=>{try{a.removeItem(`${r}${e}`)}catch(QHe){t(QHe,`Error removing ${r}${e} from ${a.name}`)}})),toJSON:()=>{const a={},n=(n,t)=>{if(!a.hasOwnProperty(n)){const i=t&&e?.deserializer?e.deserializer(t,n,e.options):t;i&&(a[n]=i)}};return i.forEach((e=>{if("function"==typeof e.getAll){let a;try{a=e.getAll()}catch(QHe){t(QHe,`Error getting all values from in ${e.name}`)}for(const e of a)n(e,a[e])}else{let i,r=0;try{for(;i=e.key(r++);)a.hasOwnProperty(i)||n(i,e.getItem(i))}catch(QHe){t(QHe,`Error getting all values from ${e.name}`)}}})),a}}]},CMe=e=>{if(!e)return"";let a="";for(const n in e){if(!e.hasOwnProperty(n))continue;const t=e[n];a+=t instanceof Date?`; ${n}=${t.toUTCString()}`:"boolean"==typeof t?`; ${n}`:`; ${n}=${t}`}return a},MMe=("function"==typeof(AMe={_cookies:[globalThis.document,"cookie"],getItem:e=>MMe._cookies[0][MMe._cookies[1]].match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)")?.pop()??null,setItem:(e,a,n)=>{const t=MMe.getItem(e);MMe._cookies[0][MMe._cookies[1]]=`${e}=${a}${CMe(n)}`;const i=Object.assign(new Event("storage"),{key:e,oldValue:t,newValue:a,url:globalThis.document.URL,storageArea:MMe});window.dispatchEvent(i)},removeItem:e=>{MMe._cookies[0][MMe._cookies[1]]=`${e}=deleted${CMe({expires:new Date(0)})}`},key:e=>{let a=null,n=0;return MMe._cookies[0][MMe._cookies[1]].replace(/(?:^|;)\s*(.+?)\s*=\s*[^;]+/g,((t,i)=>(!a&&i&&n++===e&&(a=i),""))),a},get length(){let e=0;return MMe._cookies[0][MMe._cookies[1]].replace(/(?:^|;)\s*.+?\s*=\s*[^;]+/g,(a=>(e+=a?1:0,""))),e}}).clear||(AMe.clear=()=>{let e;for(;e=AMe.key(0);)AMe.removeItem(e)}),AMe),TMe=796,EMe="bottom",xMe="system",NMe=Object.keys(Xt)[0],_Me=Object.keys(ni)[0],PMe=Ja({client:void 0,onlineManager:void 0,queryFlavor:"",version:"",shadowDOMTarget:void 0});function LMe(){return Ua(PMe)}var jMe=Ja(void 0),BMe=e=>{const[a,n]=Pa(null),t=()=>{const e=a();null!=e&&(e.close(),n(null))},i=(t,i)=>{if(null!=a())return;const r=window.open("","TSQD-Devtools-Panel",`width=${t},height=${i},popup`);if(!r)throw new Error("Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.");r.document.head.innerHTML="",r.document.body.innerHTML="",function(e=window.document){if(e[Rn]){for(let a of e[Rn].keys())e.removeEventListener(a,Zn);delete e[Rn]}}(r.document),r.document.title="TanStack Query Devtools",r.document.body.style.margin="0",r.addEventListener("pagehide",(()=>{e.setLocalStore("pip_open","false"),n(null)})),[...(LMe().shadowDOMTarget||document).styleSheets].forEach((e=>{try{const a=[...e.cssRules].map((e=>e.cssText)).join(""),n=document.createElement("style"),t=e.ownerNode;let i="";t&&"id"in t&&(i=t.id),i&&n.setAttribute("id",i),n.textContent=a,r.document.head.appendChild(n)}catch(YHe){const n=document.createElement("link");if(null==e.href)return;n.rel="stylesheet",n.type=e.type,n.media=e.media.toString(),n.href=e.href,r.document.head.appendChild(n)}})),Kn(["focusin","focusout","pointermove","keydown","pointerdown","pointerup","click","mousedown","input"],r.document),e.setLocalStore("pip_open","true"),n(r)};Ba((()=>{"true"!==(e.localStore.pip_open??"false")||e.disabled||i(Number(window.innerWidth),Number(e.localStore.height||500))})),Ba((()=>{const e=(LMe().shadowDOMTarget||document).querySelector("#_goober"),n=a();if(e&&n){const a=new MutationObserver((()=>{const a=(LMe().shadowDOMTarget||n.document).querySelector("#_goober");a&&(a.textContent=e.textContent)}));a.observe(e,{childList:!0,subtree:!0,characterDataOldValue:!0}),Ha((()=>{a.disconnect()}))}}));const r=Ra((()=>({pipWindow:a(),requestPipWindow:i,closePipWindow:t,disabled:e.disabled??!1})));return mn(jMe.Provider,{value:r,get children(){return e.children}})},RMe=()=>Ra((()=>{const e=Ua(jMe);if(!e)throw new Error("usePiPWindow must be used within a PiPProvider");return e()})),zMe=Ja((()=>"dark"));function DMe(){return Ua(zMe)}var KMe={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Ấ":"A","Ắ":"A","Ẳ":"A","Ẵ":"A","Ặ":"A","Æ":"AE","Ầ":"A","Ằ":"A","Ȃ":"A","Ç":"C","Ḉ":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ế":"E","Ḗ":"E","Ề":"E","Ḕ":"E","Ḝ":"E","Ȇ":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ḯ":"I","Ȋ":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ố":"O","Ṍ":"O","Ṓ":"O","Ȏ":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","ấ":"a","ắ":"a","ẳ":"a","ẵ":"a","ặ":"a","æ":"ae","ầ":"a","ằ":"a","ȃ":"a","ç":"c","ḉ":"c","è":"e","é":"e","ê":"e","ë":"e","ế":"e","ḗ":"e","ề":"e","ḕ":"e","ḝ":"e","ȇ":"e","ì":"i","í":"i","î":"i","ï":"i","ḯ":"i","ȋ":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ố":"o","ṍ":"o","ṓ":"o","ȏ":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","C̆":"C","c̆":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","Ǵ":"G","ĝ":"g","ǵ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ḫ":"H","ḫ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","Ḱ":"K","ḱ":"k","K̆":"K","k̆":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"l","ł":"l","Ḿ":"M","ḿ":"m","M̆":"M","m̆":"m","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"n","N̆":"N","n̆":"n","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","P̆":"P","p̆":"p","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","R̆":"R","r̆":"r","Ȓ":"R","ȓ":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","Ș":"S","ș":"s","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","ț":"t","Ț":"T","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","T̆":"T","t̆":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ȗ":"U","ȗ":"u","V̆":"V","v̆":"v","Ŵ":"W","ŵ":"w","Ẃ":"W","ẃ":"w","X̆":"X","x̆":"x","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Y̆":"Y","y̆":"y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ſ":"s","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Ǎ":"A","ǎ":"a","Ǐ":"I","ǐ":"i","Ǒ":"O","ǒ":"o","Ǔ":"U","ǔ":"u","Ǖ":"U","ǖ":"u","Ǘ":"U","ǘ":"u","Ǚ":"U","ǚ":"u","Ǜ":"U","ǜ":"u","Ứ":"U","ứ":"u","Ṹ":"U","ṹ":"u","Ǻ":"A","ǻ":"a","Ǽ":"AE","ǽ":"ae","Ǿ":"O","ǿ":"o","Þ":"TH","þ":"th","Ṕ":"P","ṕ":"p","Ṥ":"S","ṥ":"s","X́":"X","x́":"x","Ѓ":"Г","ѓ":"г","Ќ":"К","ќ":"к","A̋":"A","a̋":"a","E̋":"E","e̋":"e","I̋":"I","i̋":"i","Ǹ":"N","ǹ":"n","Ồ":"O","ồ":"o","Ṑ":"O","ṑ":"o","Ừ":"U","ừ":"u","Ẁ":"W","ẁ":"w","Ỳ":"Y","ỳ":"y","Ȁ":"A","ȁ":"a","Ȅ":"E","ȅ":"e","Ȉ":"I","ȉ":"i","Ȍ":"O","ȍ":"o","Ȑ":"R","ȑ":"r","Ȕ":"U","ȕ":"u","B̌":"B","b̌":"b","Č̣":"C","č̣":"c","Ê̌":"E","ê̌":"e","F̌":"F","f̌":"f","Ǧ":"G","ǧ":"g","Ȟ":"H","ȟ":"h","J̌":"J","ǰ":"j","Ǩ":"K","ǩ":"k","M̌":"M","m̌":"m","P̌":"P","p̌":"p","Q̌":"Q","q̌":"q","Ř̩":"R","ř̩":"r","Ṧ":"S","ṧ":"s","V̌":"V","v̌":"v","W̌":"W","w̌":"w","X̌":"X","x̌":"x","Y̌":"Y","y̌":"y","A̧":"A","a̧":"a","B̧":"B","b̧":"b","Ḑ":"D","ḑ":"d","Ȩ":"E","ȩ":"e","Ɛ̧":"E","ɛ̧":"e","Ḩ":"H","ḩ":"h","I̧":"I","i̧":"i","Ɨ̧":"I","ɨ̧":"i","M̧":"M","m̧":"m","O̧":"O","o̧":"o","Q̧":"Q","q̧":"q","U̧":"U","u̧":"u","X̧":"X","x̧":"x","Z̧":"Z","z̧":"z"},OMe=Object.keys(KMe).join("|"),HMe=new RegExp(OMe,"g");var IMe=7,GMe=6,FMe=5,VMe=4,JMe=3,UMe=2,WMe=1,qMe=0;function ZMe(e,a,n){var t;if((n=n||{}).threshold=null!=(t=n.threshold)?t:WMe,!n.accessors){const t=$Me(e,a,n);return{rankedValue:e,rank:t,accessorIndex:-1,accessorThreshold:n.threshold,passed:t>=n.threshold}}const i=function(e,a){const n=[];for(let t=0,i=a.length;t<i;t++){const i=a[t],r=eTe(i),o=QMe(e,i);for(let e=0,a=o.length;e<a;e++)n.push({itemValue:o[e],attributes:r})}return n}(e,n.accessors),r={rankedValue:e,rank:qMe,accessorIndex:-1,accessorThreshold:n.threshold,passed:!1};for(let o=0;o<i.length;o++){const e=i[o];let t=$Me(e.itemValue,a,n);const{minRanking:s,maxRanking:l,threshold:u=n.threshold}=e.attributes;t<s&&t>=WMe?t=s:t>l&&(t=l),t=Math.min(t,l),t>=u&&t>r.rank&&(r.rank=t,r.passed=!0,r.accessorIndex=o,r.accessorThreshold=u,r.rankedValue=e.itemValue)}return r}function $Me(e,a,n){return e=YMe(e,n),(a=YMe(a,n)).length>e.length?qMe:e===a?IMe:(e=e.toLowerCase())===(a=a.toLowerCase())?GMe:e.startsWith(a)?FMe:e.includes(` ${a}`)?VMe:e.includes(a)?JMe:1===a.length?qMe:function(e){let a="";return e.split(" ").forEach((e=>{e.split("-").forEach((e=>{a+=e.substr(0,1)}))})),a}(e).includes(a)?UMe:function(e,a){let n=0,t=0;function i(e,a,t){for(let i=t,r=a.length;i<r;i++){if(a[i]===e)return n+=1,i+1}return-1}function r(e){return WMe+n/a.length*(1/e)}const o=i(a[0],e,0);if(o<0)return qMe;t=o;for(let s=1,l=a.length;s<l;s++){t=i(a[s],e,t);if(!(t>-1))return qMe}return r(t-o)}(e,a)}function YMe(e,a){let{keepDiacritics:n}=a;return e=`${e}`,n||(e=e.replace(HMe,(e=>KMe[e]))),e}function QMe(e,a){let n=a;"object"==typeof a&&(n=a.accessor);const t=n(e);return null==t?[]:Array.isArray(t)?t:[String(t)]}var XMe={maxRanking:1/0,minRanking:-1/0};function eTe(e){return"function"==typeof e?XMe:{...XMe,...e}}var aTe={data:""},nTe=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,tTe=/\/\*[^]*?\*\/| +/g,iTe=/\n+/g,rTe=(e,a)=>{let n="",t="",i="";for(let r in e){let o=e[r];"@"==r[0]?"i"==r[1]?n=r+" "+o+";":t+="f"==r[1]?rTe(o,r):r+"{"+rTe(o,"k"==r[1]?"":a)+"}":"object"==typeof o?t+=rTe(o,a?a.replace(/([^,])+/g,(e=>r.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,(a=>/&/.test(a)?a.replace(/&/g,e):e?e+" "+a:a)))):r):null!=o&&(r=/^--/.test(r)?r:r.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=rTe.p?rTe.p(r,o):r+":"+o+";")}return n+(a&&i?a+"{"+i+"}":i)+t},oTe={},sTe=e=>{if("object"==typeof e){let a="";for(let n in e)a+=n+sTe(e[n]);return a}return e};function lTe(e){let a=this||{},n=e.call?e(a.p):e;return((e,a,n,t,i)=>{let r=sTe(e),o=oTe[r]||(oTe[r]=(e=>{let a=0,n=11;for(;a<e.length;)n=101*n+e.charCodeAt(a++)>>>0;return"go"+n})(r));if(!oTe[o]){let a=r!==e?e:(e=>{let a,n,t=[{}];for(;a=nTe.exec(e.replace(tTe,""));)a[4]?t.shift():a[3]?(n=a[3].replace(iTe," ").trim(),t.unshift(t[0][n]=t[0][n]||{})):t[0][a[1]]=a[2].replace(iTe," ").trim();return t[0]})(e);oTe[o]=rTe(i?{["@keyframes "+o]:a}:a,n?"":"."+o)}let s=n&&oTe.g?oTe.g:null;return n&&(oTe.g=oTe[o]),l=oTe[o],u=a,c=t,(d=s)?u.data=u.data.replace(d,l):-1===u.data.indexOf(l)&&(u.data=c?l+u.data:u.data+l),o;var l,u,c,d})(n.unshift?n.raw?((e,a,n)=>e.reduce(((e,t,i)=>{let r=a[i];if(r&&r.call){let e=r(n),a=e&&e.props&&e.props.className||/^go/.test(e)&&e;r=a?"."+a:e&&"object"==typeof e?e.props?"":rTe(e,""):!1===e?"":e}return e+t+(null==r?"":r)}),""))(n,[].slice.call(arguments,1),a.p):n.reduce(((e,n)=>Object.assign(e,n&&n.call?n(a.p):n)),{}):n,(e=>"object"==typeof window?((e?e.querySelector("#_goober"):window._goober)||Object.assign((e||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:e||aTe)(a.target),a.g,a.o,a.k)}function uTe(e){var a,n,t="";if("string"==typeof e||"number"==typeof e)t+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(a=0;a<i;a++)e[a]&&(n=uTe(e[a]))&&(t&&(t+=" "),t+=n)}else for(n in e)e[n]&&(t&&(t+=" "),t+=n);return t}function cTe(){for(var e,a,n=0,t="",i=arguments.length;n<i;n++)(e=arguments[n])&&(a=uTe(e))&&(t&&(t+=" "),t+=a);return t}function dTe(e,a){const n=Da(e),{onChange:t}=a;let i=new Set(a.appear?void 0:n);const r=new WeakSet,[o,s]=Pa([],{equals:!1}),[l]=[Fa,Ga],u=e=>{s((a=>(a.push.apply(a,e),a)));for(const a of e)r.delete(a)},c=(e,a,n)=>e.splice(n,0,a);return Ra((a=>{const n=o(),s=e();if(Da(l))return l(),a;if(n.length){const e=a.filter((e=>!n.includes(e)));return n.length=0,t({list:e,added:[],removed:[],unchanged:e,finishRemoved:u}),e}return Da((()=>{const e=new Set(s),n=s.slice(),o=[],l=[],d=[];for(const a of s)(i.has(a)?d:o).push(a);let m=!o.length;for(let t=0;t<a.length;t++){const i=a[t];e.has(i)||(r.has(i)||(l.push(i),r.add(i)),c(n,i,t)),m&&i!==n[t]&&(m=!1)}return!l.length&&m?a:(t({list:n,added:o,removed:l,unchanged:d,finishRemoved:u}),i=e,n)}))}),a.appear?[]:n.slice())}function mTe(...e){return a=e,(...e)=>{for(const n of a)n&&n(...e)};var a}lTe.bind({g:1}),lTe.bind({k:1});var hTe=e=>e instanceof Element;function pTe(e,a){if(a(e))return e;if("function"==typeof e&&!e.length)return pTe(e(),a);if(Array.isArray(e)){const n=[];for(const t of e){const e=pTe(t,a);e&&(Array.isArray(e)?n.push.apply(n,e):n.push(e))}return n.length?n:null}return null}function gTe(e,a=hTe,n=hTe){const t=Ra(e),i=Ra((()=>pTe(t(),a)));return i.toArray=()=>{const e=i();return Array.isArray(e)?e:e?[e]:[]},i}function vTe(e){requestAnimationFrame((()=>requestAnimationFrame(e)))}function fTe(e,a,n,t){const{onBeforeEnter:i,onEnter:r,onAfterEnter:o}=a;function s(a){a&&a.target!==n||(n.removeEventListener("transitionend",s),n.removeEventListener("animationend",s),n.classList.remove(...e.enterActive),n.classList.remove(...e.enterTo),o?.(n))}i?.(n),n.classList.add(...e.enter),n.classList.add(...e.enterActive),queueMicrotask((()=>{if(!n.parentNode)return t?.();r?.(n,(()=>s()))})),vTe((()=>{n.classList.remove(...e.enter),n.classList.add(...e.enterTo),(!r||r.length<2)&&(n.addEventListener("transitionend",s),n.addEventListener("animationend",s))}))}function yTe(e,a,n,t){const{onBeforeExit:i,onExit:r,onAfterExit:o}=a;if(!n.parentNode)return t?.();function s(a){a&&a.target!==n||(t?.(),n.removeEventListener("transitionend",s),n.removeEventListener("animationend",s),n.classList.remove(...e.exitActive),n.classList.remove(...e.exitTo),o?.(n))}i?.(n),n.classList.add(...e.exit),n.classList.add(...e.exitActive),r?.(n,(()=>s())),vTe((()=>{n.classList.remove(...e.exit),n.classList.add(...e.exitTo),(!r||r.length<2)&&(n.addEventListener("transitionend",s),n.addEventListener("animationend",s))}))}var kTe=e=>{const a=function(e){return Ra((()=>{const a=e.name||"s";return{enterActive:(e.enterActiveClass||a+"-enter-active").split(" "),enter:(e.enterClass||a+"-enter").split(" "),enterTo:(e.enterToClass||a+"-enter-to").split(" "),exitActive:(e.exitActiveClass||a+"-exit-active").split(" "),exit:(e.exitClass||a+"-exit").split(" "),exitTo:(e.exitToClass||a+"-exit-to").split(" "),move:(e.moveClass||a+"-move").split(" ")}}))}(e);return dTe(gTe((()=>e.children)).toArray,{appear:e.appear,onChange({added:n,removed:t,finishRemoved:i,list:r}){const o=a();for(const a of n)fTe(o,e,a);const s=[];for(const e of r)e.isConnected&&(e instanceof HTMLElement||e instanceof SVGElement)&&s.push({el:e,rect:e.getBoundingClientRect()});queueMicrotask((()=>{const e=[];for(const{el:a,rect:n}of s)if(a.isConnected){const t=a.getBoundingClientRect(),i=n.left-t.left,r=n.top-t.top;(i||r)&&(a.style.transform=`translate(${i}px, ${r}px)`,a.style.transitionDuration="0s",e.push(a))}document;for(const a of e){let e=function(n){(n.target===a||/transform$/.test(n.propertyName))&&(a.removeEventListener("transitionend",e),a.classList.remove(...o.move))};a.classList.add(...o.move),a.style.transform=a.style.transitionDuration="",a.addEventListener("transitionend",e)}}));for(const a of t)yTe(o,e,a,(()=>i([a])))}})},bTe=Symbol("fallback");function STe(e){for(const a of e)a.dispose()}function ATe(e){const{by:a}=e;return Ra(function(e,a,n,t={}){const i=new Map;return Ha((()=>STe(i.values()))),()=>{const n=e()||[];return Da((()=>{if(!n.length)return STe(i.values()),i.clear(),t.fallback?[_a((e=>(i.set(bTe,{dispose:e}),t.fallback())))]:[];const e=new Array(n.length),o=i.get(bTe);if(!i.size||o){o?.dispose(),i.delete(bTe);for(let t=0;t<n.length;t++){const i=n[t];r(e,i,t,a(i,t))}return e}const s=new Set(i.keys());for(let t=0;t<n.length;t++){const o=n[t],l=a(o,t);s.delete(l);const u=i.get(l);u?(e[t]=u.mapped,u.setIndex?.(t),u.setItem((()=>o))):r(e,o,t,l)}for(const a of s)i.get(a)?.dispose(),i.delete(a);return e}))};function r(e,a,t,r){_a((o=>{const[s,l]=Pa(a),u={setItem:l,dispose:o};if(n.length>1){const[e,a]=Pa(t);u.setIndex=a,u.mapped=n(s,e)}else u.mapped=n(s);i.set(r,u),e[t]=u.mapped}))}}((()=>e.each),"function"==typeof a?a:e=>e[a],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}function wTe(e,a,n,t){const i=()=>{bMe(kMe(e)).forEach((e=>{e&&bMe(kMe(a)).forEach((a=>function(e,a,n,t){return e.addEventListener(a,n,t),SMe(e.removeEventListener.bind(e,a,n,t))}(e,a,n,t)))}))};"function"==typeof e?Ba(i):ja(i)}function CTe(e,a,n){const t=new WeakMap,{observe:i,unobserve:r}=function(e,a){const n=new ResizeObserver(e);return Ha(n.disconnect.bind(n)),{observe:e=>n.observe(e,a),unobserve:n.unobserve.bind(n)}}((e=>{for(const n of e){const{contentRect:e,target:i}=n,r=Math.round(e.width),o=Math.round(e.height),s=t.get(i);s&&s.width===r&&s.height===o||(a(e,i,n),t.set(i,{width:r,height:o}))}}),n);Ba((a=>{const n=bMe(kMe(e)).filter(yMe);return function(e,a,n,t){const i=e.length,r=a.length;let o,s,l=0;if(r)if(i){for(;l<r&&a[l]===e[l];l++);for(o of(a=a.slice(l),e=e.slice(l),a))e.includes(o)||t(o);for(s of e)a.includes(s)||n(s)}else for(;l<r;l++)t(a[l]);else for(;l<i;l++)n(e[l])}(n,a,i,r),n}),[])}var MTe=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function TTe(e){const a={};let n;for(;n=MTe.exec(e);)a[n[1]]=n[2];return a}function ETe(e,a){if("string"==typeof e){if("string"==typeof a)return`${e};${a}`;e=TTe(e)}else"string"==typeof a&&(a=TTe(a));return{...e,...a}}function xTe(e,a){const n=[...e],t=n.indexOf(a);return-1!==t&&n.splice(t,1),n}function NTe(e){return"[object String]"===Object.prototype.toString.call(e)}function _Te(e){return a=>`${e()}-${a}`}function PTe(e,a){return!!e&&(e===a||e.contains(a))}function LTe(e,a=!1){const{activeElement:n}=jTe(e);if(!n?.nodeName)return null;if(BTe(n)&&n.contentDocument)return LTe(n.contentDocument.body,a);if(a){const e=n.getAttribute("aria-activedescendant");if(e){const a=jTe(n).getElementById(e);if(a)return a}}return n}function jTe(e){return e?e.ownerDocument||e:document}function BTe(e){return"IFRAME"===e.tagName}var RTe=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(RTe||{});function zTe(e){return"undefined"!=typeof window&&null!=window.navigator&&e.test(window.navigator.userAgentData?.platform||window.navigator.platform)}function DTe(){return zTe(/^Mac/i)}function KTe(){return zTe(/^iPhone/i)||zTe(/^iPad/i)||DTe()&&navigator.maxTouchPoints>1}function OTe(e,a){return a&&("function"==typeof a?a(e):a[0](a[1],e)),e?.defaultPrevented}function HTe(e){return a=>{for(const n of e)OTe(a,n)}}function ITe(e){return DTe()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function GTe(e){if(e)if(function(){if(null==FTe){FTe=!1;try{document.createElement("div").focus({get preventScroll(){return FTe=!0,!0}})}catch(YHe){}}return FTe}())e.focus({preventScroll:!0});else{const a=function(e){let a=e.parentNode;const n=[],t=document.scrollingElement||document.documentElement;for(;a instanceof HTMLElement&&a!==t;)(a.offsetHeight<a.scrollHeight||a.offsetWidth<a.scrollWidth)&&n.push({element:a,scrollTop:a.scrollTop,scrollLeft:a.scrollLeft}),a=a.parentNode;t instanceof HTMLElement&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft});return n}(e);e.focus(),function(e){for(const{element:a,scrollTop:n,scrollLeft:t}of e)a.scrollTop=n,a.scrollLeft=t}(a)}}var FTe=null;var VTe=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],JTe=[...VTe,'[tabindex]:not([tabindex="-1"]):not([disabled])'],UTe=VTe.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])",WTe=JTe.join(':not([hidden]):not([tabindex="-1"]),');function qTe(e,a){const n=Array.from(e.querySelectorAll(UTe)).filter(ZTe);return a&&ZTe(e)&&n.unshift(e),n.forEach(((e,a)=>{if(BTe(e)&&e.contentDocument){const t=qTe(e.contentDocument.body,!1);n.splice(a,1,...t)}})),n}function ZTe(e){return $Te(e)&&!function(e){const a=parseInt(e.getAttribute("tabindex")||"0",10);return a<0}(e)}function $Te(e){return e.matches(UTe)&&YTe(e)}function YTe(e,a){return"#comment"!==e.nodeName&&function(e){if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const{display:a,visibility:n}=e.style;let t="none"!==a&&"hidden"!==n&&"collapse"!==n;if(t){if(!e.ownerDocument.defaultView)return t;const{getComputedStyle:a}=e.ownerDocument.defaultView,{display:n,visibility:i}=a(e);t="none"!==n&&"hidden"!==i&&"collapse"!==i}return t}(e)&&function(e,a){return!e.hasAttribute("hidden")&&("DETAILS"!==e.nodeName||!a||"SUMMARY"===a.nodeName||e.hasAttribute("open"))}(e,a)&&(!e.parentElement||YTe(e.parentElement,e))}function QTe(e){for(;e&&!XTe(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}function XTe(e){const a=window.getComputedStyle(e);return/(auto|scroll)/.test(a.overflow+a.overflowX+a.overflowY)}function eEe(){}function aEe(e,a){return fn(e,a)}var nEe=new Map,tEe=new Set;function iEe(){if("undefined"==typeof window)return;const e=a=>{if(!a.target)return;const n=nEe.get(a.target);if(n&&(n.delete(a.propertyName),0===n.size&&(a.target.removeEventListener("transitioncancel",e),nEe.delete(a.target)),0===nEe.size)){for(const e of tEe)e();tEe.clear()}};document.body.addEventListener("transitionrun",(a=>{if(!a.target)return;let n=nEe.get(a.target);n||(n=new Set,nEe.set(a.target,n),a.target.addEventListener("transitioncancel",e)),n.add(a.propertyName)})),document.body.addEventListener("transitionend",e)}function rEe(e,a){const n=oEe(e,a,"left"),t=oEe(e,a,"top"),i=a.offsetWidth,r=a.offsetHeight;let o=e.scrollLeft,s=e.scrollTop;const l=o+e.offsetWidth,u=s+e.offsetHeight;n<=o?o=n:n+i>l&&(o+=n+i-l),t<=s?s=t:t+r>u&&(s+=t+r-u),e.scrollLeft=o,e.scrollTop=s}function oEe(e,a,n){const t="left"===n?"offsetLeft":"offsetTop";let i=0;for(;a.offsetParent&&(i+=a[t],a.offsetParent!==e);){if(a.offsetParent.contains(e)){i-=e[t];break}a=a.offsetParent}return i}"undefined"!=typeof document&&("loading"!==document.readyState?iEe():document.addEventListener("DOMContentLoaded",iEe));var sEe={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"};function lEe(e){return a=>(e(a),()=>e(void 0))}function uEe(e,a){const[n,t]=Pa(cEe(a?.()));return Ba((()=>{t(e()?.tagName.toLowerCase()||cEe(a?.()))})),n}function cEe(e){return NTe(e)?e:void 0}function dEe(e){const[a,n]=yn(e,["as"]);if(!a.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return mn(nt,fn(n,{get component(){return a.as}}))}var mEe=["id","name","validationState","required","disabled","readOnly"];var hEe=Ja();function pEe(){const e=Ua(hEe);if(void 0===e)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function gEe(e){const a=pEe(),n=aEe({id:a.generateId("description")},e);return Ba((()=>Ha(a.registerDescription(n.id)))),mn(dEe,fn({as:"div"},(()=>a.dataset()),n))}function vEe(e){const a=pEe(),n=aEe({id:a.generateId("error-message")},e),[t,i]=yn(n,["forceMount"]),r=()=>"invalid"===a.validationState();return Ba((()=>{r()&&Ha(a.registerErrorMessage(i.id))})),mn(Mn,{get when(){return t.forceMount||r()},get children(){return mn(dEe,fn({as:"div"},(()=>a.dataset()),i))}})}function fEe(e){let a;const n=pEe(),t=aEe({id:n.generateId("label")},e),[i,r]=yn(t,["ref"]),o=uEe((()=>a),(()=>"label"));return Ba((()=>Ha(n.registerLabel(r.id)))),mn(dEe,fn({as:"label",ref(e){const n=mTe((e=>a=e),i.ref);"function"==typeof n&&n(e)},get for(){return Ra((()=>"label"===o()))()?n.fieldId():void 0}},(()=>n.dataset()),r))}function yEe(e,a){Ba(Ka(e,(e=>{if(null==e)return;const n=function(e){return function(e){return e.matches("textarea, input, select, button")}(e)?e.form:e.closest("form")}(e);null!=n&&(n.addEventListener("reset",a,{passive:!0}),Ha((()=>{n.removeEventListener("reset",a)})))})))}function kEe(e){const[a,n]=Pa(e.defaultValue?.()),t=Ra((()=>void 0!==e.value?.())),i=Ra((()=>t()?e.value?.():a()));return[i,a=>{Da((()=>{const r=function(e,...a){return"function"==typeof e?e(...a):e}(a,i());return Object.is(r,i())||(t()||n(r),e.onChange?.(r)),r}))}]}function bEe(e){const[a,n]=kEe(e);return[()=>a()??!1,n]}var SEe=Object.defineProperty,AEe=(e,a)=>{for(var n in a)SEe(e,n,{get:a[n],enumerable:!0})},wEe=Ja();function CEe(){return Ua(wEe)}function MEe(e,a){return Boolean(a.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function TEe(e,a){const n=function(e){const a=e.map(((e,a)=>[a,e]));let n=!1;return a.sort((([e,a],[t,i])=>{const r=a.ref(),o=i.ref();return r===o?0:r&&o?MEe(r,o)?(e>t&&(n=!0),-1):(e<t&&(n=!0),1):0})),n?a.map((([e,a])=>a)):e}(e);e!==n&&a(n)}function EEe(e,a){if("function"!=typeof IntersectionObserver)return void function(e,a){Ba((()=>{const n=setTimeout((()=>{TEe(e(),a)}));Ha((()=>clearTimeout(n)))}))}(e,a);let n=[];Ba((()=>{const t=function(e){const a=e[0],n=e[e.length-1]?.ref();let t=a?.ref()?.parentElement;for(;t;){if(n&&t.contains(n))return t;t=t.parentElement}return jTe(t).body}(e()),i=new IntersectionObserver((()=>{const t=!!n.length;n=e(),t&&TEe(e(),a)}),{root:t});for(const a of e()){const e=a.ref();e&&i.observe(e)}Ha((()=>i.disconnect()))}))}function xEe(e={}){const[a,n]=function(e){const[a,n]=kEe(e);return[()=>a()??[],n]}({value:()=>kMe(e.items),onChange:a=>e.onItemsChange?.(a)});EEe(a,n);const t=e=>(n((a=>{const n=function(e,a){const n=a.ref();if(!n)return-1;let t=e.length;if(!t)return-1;for(;t--;){const a=e[t]?.ref();if(a&&MEe(a,n))return t+1}return 0}(a,e);return function(e,a,n=-1){return n in e?[...e.slice(0,n),a,...e.slice(n)]:[...e,a]}(a,e,n)})),()=>{n((a=>{const n=a.filter((a=>a.ref()!==e.ref()));return a.length===n.length?a:n}))});return{DomCollectionProvider:e=>mn(wEe.Provider,{value:{registerItem:t},get children(){return e.children}})}}function NEe(e){const a=function(){const e=CEe();if(void 0===e)throw new Error("[kobalte]: `useDomCollectionContext` must be used within a `DomCollectionProvider` component");return e}(),n=aEe({shouldRegisterItem:!0},e);Ba((()=>{if(!n.shouldRegisterItem)return;Ha(a.registerItem(n.getItem()))}))}function _Ee(e){let a=e.startIndex??0;const n=e.startLevel??0,t=[],i=a=>{if(null==a)return"";const n=e.getKey??"key",t=NTe(n)?a[n]:n(a);return null!=t?String(t):""},r=a=>{if(null==a)return"";const n=e.getTextValue??"textValue",t=NTe(n)?a[n]:n(a);return null!=t?String(t):""},o=a=>{if(null==a)return!1;const n=e.getDisabled??"disabled";return(NTe(n)?a[n]:n(a))??!1},s=a=>{if(null!=a)return NTe(e.getSectionChildren)?a[e.getSectionChildren]:e.getSectionChildren?.(a)};for(const l of e.dataSource)if(NTe(l)||"number"==typeof l)t.push({type:"item",rawValue:l,key:String(l),textValue:String(l),disabled:o(l),level:n,index:a}),a++;else if(null!=s(l)){t.push({type:"section",rawValue:l,key:"",textValue:"",disabled:!1,level:n,index:a}),a++;const i=s(l)??[];if(i.length>0){const r=_Ee({dataSource:i,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:a,startLevel:n+1});t.push(...r),a+=r.length}}else t.push({type:"item",rawValue:l,key:i(l),textValue:r(l),disabled:o(l),level:n,index:a}),a++;return t}function PEe(e,a=[]){return Ra((()=>{const n=_Ee({dataSource:kMe(e.dataSource),getKey:kMe(e.getKey),getTextValue:kMe(e.getTextValue),getDisabled:kMe(e.getDisabled),getSectionChildren:kMe(e.getSectionChildren)});for(let e=0;e<a.length;e++)a[e]();return e.factory(n)}))}var LEe=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),jEe=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function BEe(e){return function(e){if(Intl.Locale){const a=new Intl.Locale(e).maximize().script??"";return LEe.has(a)}const a=e.split("-")[0];return jEe.has(a)}(e)?"rtl":"ltr"}function REe(){let e="undefined"!=typeof navigator&&(navigator.language||navigator.userLanguage)||"en-US";return{locale:e,direction:BEe(e)}}var zEe=REe(),DEe=new Set;function KEe(){zEe=REe();for(const e of DEe)e(zEe)}var OEe=Ja();function HEe(){const e=function(){const[e,a]=Pa(zEe),n=Ra((()=>e()));return Oa((()=>{0===DEe.size&&window.addEventListener("languagechange",KEe),DEe.add(a),Ha((()=>{DEe.delete(a),0===DEe.size&&window.removeEventListener("languagechange",KEe)}))})),{locale:()=>n().locale,direction:()=>n().direction}}();return Ua(OEe)||e}var IEe=new Map;var GEe=class e extends Set{anchorKey;currentKey;constructor(a,n,t){super(a),a instanceof e?(this.anchorKey=n||a.anchorKey,this.currentKey=t||a.currentKey):(this.anchorKey=n,this.currentKey=t)}};function FEe(e){return DTe()||KTe()?e.altKey:e.ctrlKey}function VEe(e){return DTe()?e.metaKey:e.ctrlKey}function JEe(e){return new GEe(e)}function UEe(e){const a=aEe({selectionMode:"none",selectionBehavior:"toggle"},e),[n,t]=Pa(!1),[i,r]=Pa(),o=Ra((()=>{const e=kMe(a.selectedKeys);return null!=e?JEe(e):e})),s=Ra((()=>{const e=kMe(a.defaultSelectedKeys);return null!=e?JEe(e):new GEe})),[l,u]=function(e){const[a,n]=kEe(e);return[()=>a()??new GEe,n]}({value:o,defaultValue:s,onChange:e=>a.onSelectionChange?.(e)}),[c,d]=Pa(kMe(a.selectionBehavior));return Ba((()=>{const e=l();"replace"===kMe(a.selectionBehavior)&&"toggle"===c()&&"object"==typeof e&&0===e.size&&d("replace")})),Ba((()=>{d(kMe(a.selectionBehavior)??"toggle")})),{selectionMode:()=>kMe(a.selectionMode),disallowEmptySelection:()=>kMe(a.disallowEmptySelection)??!1,selectionBehavior:c,setSelectionBehavior:d,isFocused:n,setFocused:t,focusedKey:i,setFocusedKey:r,selectedKeys:l,setSelectedKeys:e=>{!kMe(a.allowDuplicateSelectionEvents)&&function(e,a){if(e.size!==a.size)return!1;for(const n of e)if(!a.has(n))return!1;return!0}(e,l())||u(e)}}}function WEe(e,a,n){const t=fn({selectOnFocus:()=>"replace"===kMe(e.selectionManager).selectionBehavior()},e),i=()=>a(),{direction:r}=HEe();let o={top:0,left:0};wTe((()=>kMe(t.isVirtualized)?void 0:i()),"scroll",(()=>{const e=i();e&&(o={top:e.scrollTop,left:e.scrollLeft})}));const{typeSelectHandlers:s}=function(e){const[a,n]=Pa(""),[t,i]=Pa(-1);return{typeSelectHandlers:{onKeyDown:r=>{if(kMe(e.isDisabled))return;const o=kMe(e.keyboardDelegate),s=kMe(e.selectionManager);if(!o.getKeyForSearch)return;const l=function(e){return 1!==e.length&&/^[A-Z]/i.test(e)?"":e}(r.key);if(!l||r.ctrlKey||r.metaKey)return;" "===l&&a().trim().length>0&&(r.preventDefault(),r.stopPropagation());let u=n((e=>e+l)),c=o.getKeyForSearch(u,s.focusedKey())??o.getKeyForSearch(u);null==c&&function(e){return e.split("").every((a=>a===e[0]))}(u)&&(u=u[0],c=o.getKeyForSearch(u,s.focusedKey())??o.getKeyForSearch(u)),null!=c&&(s.setFocusedKey(c),e.onTypeSelect?.(c)),clearTimeout(t()),i(window.setTimeout((()=>n("")),500))}}}}({isDisabled:()=>kMe(t.disallowTypeAhead),keyboardDelegate:()=>kMe(t.keyboardDelegate),selectionManager:()=>kMe(t.selectionManager)}),l=()=>kMe(t.orientation)??"vertical",u=()=>{const e=kMe(t.autoFocus);if(!e)return;const n=kMe(t.selectionManager),i=kMe(t.keyboardDelegate);let r;"first"===e&&(r=i.getFirstKey?.()),"last"===e&&(r=i.getLastKey?.());const o=n.selectedKeys();o.size&&(r=o.values().next().value),n.setFocused(!0),n.setFocusedKey(r);const s=a();s&&null==r&&!kMe(t.shouldUseVirtualFocus)&&GTe(s)};Oa((()=>{t.deferAutoFocus?setTimeout(u,0):u()})),Ba(Ka([i,()=>kMe(t.isVirtualized),()=>kMe(t.selectionManager).focusedKey()],(e=>{const[a,n,i]=e;if(n)i&&t.scrollToKey?.(i);else if(i&&a){const e=a.querySelector(`[data-key="${i}"]`);e&&rEe(a,e)}})));return{tabIndex:Ra((()=>{if(!kMe(t.shouldUseVirtualFocus))return null==kMe(t.selectionManager).focusedKey()?0:-1})),onKeyDown:e=>{OTe(e,s.onKeyDown),e.altKey&&"Tab"===e.key&&e.preventDefault();const n=a();if(!n?.contains(e.target))return;const i=kMe(t.selectionManager),o=kMe(t.selectOnFocus),u=a=>{null!=a&&(i.setFocusedKey(a),e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&!FEe(e)&&i.replaceSelection(a))},c=kMe(t.keyboardDelegate),d=kMe(t.shouldFocusWrap),m=i.focusedKey();switch(e.key){case"vertical"===l()?"ArrowDown":"ArrowRight":if(c.getKeyBelow){let a;e.preventDefault(),a=null!=m?c.getKeyBelow(m):c.getFirstKey?.(),null==a&&d&&(a=c.getFirstKey?.(m)),u(a)}break;case"vertical"===l()?"ArrowUp":"ArrowLeft":if(c.getKeyAbove){let a;e.preventDefault(),a=null!=m?c.getKeyAbove(m):c.getLastKey?.(),null==a&&d&&(a=c.getLastKey?.(m)),u(a)}break;case"vertical"===l()?"ArrowLeft":"ArrowUp":if(c.getKeyLeftOf){e.preventDefault();const a="rtl"===r();let n;n=null!=m?c.getKeyLeftOf(m):a?c.getFirstKey?.():c.getLastKey?.(),u(n)}break;case"vertical"===l()?"ArrowRight":"ArrowDown":if(c.getKeyRightOf){e.preventDefault();const a="rtl"===r();let n;n=null!=m?c.getKeyRightOf(m):a?c.getLastKey?.():c.getFirstKey?.(),u(n)}break;case"Home":if(c.getFirstKey){e.preventDefault();const a=c.getFirstKey(m,VEe(e));null!=a&&(i.setFocusedKey(a),VEe(e)&&e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&i.replaceSelection(a))}break;case"End":if(c.getLastKey){e.preventDefault();const a=c.getLastKey(m,VEe(e));null!=a&&(i.setFocusedKey(a),VEe(e)&&e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&i.replaceSelection(a))}break;case"PageDown":if(c.getKeyPageBelow&&null!=m){e.preventDefault();u(c.getKeyPageBelow(m))}break;case"PageUp":if(c.getKeyPageAbove&&null!=m){e.preventDefault();u(c.getKeyPageAbove(m))}break;case"a":VEe(e)&&"multiple"===i.selectionMode()&&!0!==kMe(t.disallowSelectAll)&&(e.preventDefault(),i.selectAll());break;case"Escape":e.defaultPrevented||(e.preventDefault(),kMe(t.disallowEmptySelection)||i.clearSelection());break;case"Tab":if(!kMe(t.allowsTabNavigation)){if(e.shiftKey)n.focus();else{const e=function(e,a){const n=a?.tabbable?WTe:UTe,t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>a?.from?.contains(e)?NodeFilter.FILTER_REJECT:e.matches(n)&&YTe(e)&&(!a?.accept||a.accept(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});return a?.from&&(t.currentNode=a.from),t}(n,{tabbable:!0});let a,t;do{t=e.lastChild(),t&&(a=t)}while(t);a&&!a.contains(document.activeElement)&&GTe(a)}break}}},onMouseDown:e=>{i()===e.target&&e.preventDefault()},onFocusIn:e=>{const a=kMe(t.selectionManager),n=kMe(t.keyboardDelegate),r=kMe(t.selectOnFocus);if(a.isFocused())e.currentTarget.contains(e.target)||a.setFocused(!1);else if(e.currentTarget.contains(e.target))if(a.setFocused(!0),null==a.focusedKey()){const t=e=>{null!=e&&(a.setFocusedKey(e),r&&a.replaceSelection(e))},i=e.relatedTarget;i&&e.currentTarget.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING?t(a.lastSelectedKey()??n.getLastKey?.()):t(a.firstSelectedKey()??n.getFirstKey?.())}else if(!kMe(t.isVirtualized)){const e=i();if(e){e.scrollTop=o.top,e.scrollLeft=o.left;const n=e.querySelector(`[data-key="${a.focusedKey()}"]`);n&&(GTe(n),rEe(e,n))}}},onFocusOut:e=>{const a=kMe(t.selectionManager);e.currentTarget.contains(e.relatedTarget)||a.setFocused(!1)}}}function qEe(e,a){const n=()=>kMe(e.selectionManager),t=()=>kMe(e.key),i=()=>kMe(e.shouldUseVirtualFocus),r=e=>{"none"!==n().selectionMode()&&("single"===n().selectionMode()?n().isSelected(t())&&!n().disallowEmptySelection()?n().toggleSelection(t()):n().replaceSelection(t()):e?.shiftKey?n().extendSelection(t()):"toggle"===n().selectionBehavior()||VEe(e)||"pointerType"in e&&"touch"===e.pointerType?n().toggleSelection(t()):n().replaceSelection(t()))},o=()=>kMe(e.disabled)||n().isDisabled(t()),s=()=>!o()&&n().canSelectItem(t());let l=null;const u=Ra((()=>{if(!i()&&!o())return t()===n().focusedKey()?0:-1})),c=Ra((()=>kMe(e.virtualized)?void 0:t()));return Ba(Ka([a,t,i,()=>n().focusedKey(),()=>n().isFocused()],(([a,n,t,i,r])=>{a&&n===i&&r&&!t&&document.activeElement!==a&&(e.focus?e.focus():GTe(a))}))),{isSelected:()=>n().isSelected(t()),isDisabled:o,allowsSelection:s,tabIndex:u,dataKey:c,onPointerDown:a=>{s()&&(l=a.pointerType,"mouse"!==a.pointerType||0!==a.button||kMe(e.shouldSelectOnPressUp)||r(a))},onPointerUp:a=>{s()&&"mouse"===a.pointerType&&0===a.button&&kMe(e.shouldSelectOnPressUp)&&kMe(e.allowsDifferentPressOrigin)&&r(a)},onClick:a=>{s()&&(kMe(e.shouldSelectOnPressUp)&&!kMe(e.allowsDifferentPressOrigin)||"mouse"!==l)&&r(a)},onKeyDown:e=>{s()&&["Enter"," "].includes(e.key)&&(FEe(e)?n().toggleSelection(t()):r(e))},onMouseDown:e=>{o()&&e.preventDefault()},onFocus:e=>{const r=a();i()||o()||!r||e.target===r&&n().setFocusedKey(t())}}}var ZEe=class{collection;state;constructor(e,a){this.collection=e,this.state=a}selectionMode(){return this.state.selectionMode()}disallowEmptySelection(){return this.state.disallowEmptySelection()}selectionBehavior(){return this.state.selectionBehavior()}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}isFocused(){return this.state.isFocused()}setFocused(e){this.state.setFocused(e)}focusedKey(){return this.state.focusedKey()}setFocusedKey(e){(null==e||this.collection().getItem(e))&&this.state.setFocusedKey(e)}selectedKeys(){return this.state.selectedKeys()}isSelected(e){if("none"===this.state.selectionMode())return!1;const a=this.getKey(e);return null!=a&&this.state.selectedKeys().has(a)}isEmpty(){return 0===this.state.selectedKeys().size}isSelectAll(){if(this.isEmpty())return!1;const e=this.state.selectedKeys();return this.getAllSelectableKeys().every((a=>e.has(a)))}firstSelectedKey(){let e;for(const a of this.state.selectedKeys()){const n=this.collection().getItem(a);e&&!(null!=n?.index&&null!=e?.index&&n.index<e.index)||(e=n)}return e?.key}lastSelectedKey(){let e;for(const a of this.state.selectedKeys()){const n=this.collection().getItem(a);e&&!(null!=n?.index&&null!=e?.index&&n.index>e.index)||(e=n)}return e?.key}extendSelection(e){if("none"===this.selectionMode())return;if("single"===this.selectionMode())return void this.replaceSelection(e);const a=this.getKey(e);if(null==a)return;const n=this.state.selectedKeys(),t=n.anchorKey||a,i=new GEe(n,t,a);for(const r of this.getKeyRange(t,n.currentKey||a))i.delete(r);for(const r of this.getKeyRange(a,t))this.canSelectItem(r)&&i.add(r);this.state.setSelectedKeys(i)}getKeyRange(e,a){const n=this.collection().getItem(e),t=this.collection().getItem(a);return n&&t?null!=n.index&&null!=t.index&&n.index<=t.index?this.getKeyRangeInternal(e,a):this.getKeyRangeInternal(a,e):[]}getKeyRangeInternal(e,a){const n=[];let t=e;for(;null!=t;){const e=this.collection().getItem(t);if(e&&"item"===e.type&&n.push(t),t===a)return n;t=this.collection().getKeyAfter(t)}return[]}getKey(e){const a=this.collection().getItem(e);return a?a&&"item"===a.type?a.key:null:e}toggleSelection(e){if("none"===this.selectionMode())return;if("single"===this.selectionMode()&&!this.isSelected(e))return void this.replaceSelection(e);const a=this.getKey(e);if(null==a)return;const n=new GEe(this.state.selectedKeys());n.has(a)?n.delete(a):this.canSelectItem(a)&&(n.add(a),n.anchorKey=a,n.currentKey=a),this.disallowEmptySelection()&&0===n.size||this.state.setSelectedKeys(n)}replaceSelection(e){if("none"===this.selectionMode())return;const a=this.getKey(e);if(null==a)return;const n=this.canSelectItem(a)?new GEe([a],a,a):new GEe;this.state.setSelectedKeys(n)}setSelectedKeys(e){if("none"===this.selectionMode())return;const a=new GEe;for(const n of e){const e=this.getKey(n);if(null!=e&&(a.add(e),"single"===this.selectionMode()))break}this.state.setSelectedKeys(a)}selectAll(){"multiple"===this.selectionMode()&&this.state.setSelectedKeys(new Set(this.getAllSelectableKeys()))}clearSelection(){const e=this.state.selectedKeys();!this.disallowEmptySelection()&&e.size>0&&this.state.setSelectedKeys(new GEe)}toggleSelectAll(){this.isSelectAll()?this.clearSelection():this.selectAll()}select(e,a){"none"!==this.selectionMode()&&("single"===this.selectionMode()?this.isSelected(e)&&!this.disallowEmptySelection()?this.toggleSelection(e):this.replaceSelection(e):"toggle"===this.selectionBehavior()||a&&"touch"===a.pointerType?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys())return!0;const a=this.selectedKeys();if(e.size!==a.size)return!1;for(const n of e)if(!a.has(n))return!1;for(const n of a)if(!e.has(n))return!1;return!0}canSelectItem(e){if("none"===this.state.selectionMode())return!1;const a=this.collection().getItem(e);return null!=a&&!a.disabled}isDisabled(e){const a=this.collection().getItem(e);return!a||a.disabled}getAllSelectableKeys(){const e=[];return(a=>{for(;null!=a;){if(this.canSelectItem(a)){const n=this.collection().getItem(a);if(!n)continue;"item"===n.type&&e.push(a)}a=this.collection().getKeyAfter(a)}})(this.collection().getFirstKey()),e}},$Ee=class{keyMap=new Map;iterable;firstKey;lastKey;constructor(e){this.iterable=e;for(const t of e)this.keyMap.set(t.key,t);if(0===this.keyMap.size)return;let a,n=0;for(const[t,i]of this.keyMap)a?(a.nextKey=t,i.prevKey=a.key):(this.firstKey=t,i.prevKey=void 0),"item"===i.type&&(i.index=n++),a=i,a.nextKey=void 0;this.lastKey=a.key}*[Symbol.iterator](){yield*this.iterable}getSize(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(e){return this.keyMap.get(e)?.prevKey}getKeyAfter(e){return this.keyMap.get(e)?.nextKey}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(e){return this.keyMap.get(e)}at(e){const a=[...this.getKeys()];return this.getItem(a[e])}};var YEe,QEe=e=>"function"==typeof e?e():e,XEe=e=>{const a=Ra((()=>{const a=QEe(e.element);if(a)return getComputedStyle(a)})),n=()=>a()?.animationName??"none",[t,i]=Pa(QEe(e.show)?"present":"hidden");let r="none";return Ba((t=>{const o=QEe(e.show);return Da((()=>{if(t===o)return o;const e=r,s=n();if(o)i("present");else if("none"===s||"none"===a()?.display)i("hidden");else{i(!0===t&&e!==s?"hiding":"hidden")}})),o})),Ba((()=>{const a=QEe(e.element);if(!a)return;const o=e=>{e.target===a&&(r=n())},s=e=>{const r=n().includes(e.animationName);e.target===a&&r&&"hiding"===t()&&i("hidden")};a.addEventListener("animationstart",o),a.addEventListener("animationcancel",s),a.addEventListener("animationend",s),Ha((()=>{a.removeEventListener("animationstart",o),a.removeEventListener("animationcancel",s),a.removeEventListener("animationend",s)}))})),{present:()=>"present"===t()||"hiding"===t(),state:t}},exe="data-kb-top-layer",axe=!1,nxe=[];function txe(e){return nxe.findIndex((a=>a.node===e))}function ixe(){return nxe.filter((e=>e.isPointerBlocking))}function rxe(){return ixe().length>0}function oxe(e){const a=txe([...ixe()].slice(-1)[0]?.node);return txe(e)<a}var sxe={layers:nxe,isTopMostLayer:function(e){return nxe[nxe.length-1].node===e},hasPointerBlockingLayer:rxe,isBelowPointerBlockingLayer:oxe,addLayer:function(e){nxe.push(e)},removeLayer:function(e){const a=txe(e);a<0||nxe.splice(a,1)},indexOf:txe,find:function(e){return nxe[txe(e)]},assignPointerEventToLayers:function(){for(const{node:e}of nxe)e.style.pointerEvents=oxe(e)?"none":"auto"},disableBodyPointerEvents:function(e){if(rxe()&&!axe){const a=jTe(e);YEe=document.body.style.pointerEvents,a.body.style.pointerEvents="none",axe=!0}},restoreBodyPointerEvents:function(e){if(rxe())return;const a=jTe(e);a.body.style.pointerEvents=YEe,0===a.body.style.length&&a.body.removeAttribute("style"),axe=!1}};AEe({},{Button:()=>cxe,Root:()=>uxe});var lxe=["button","color","file","image","reset","submit"];function uxe(e){let a;const n=aEe({type:"button"},e),[t,i]=yn(n,["ref","type","disabled"]),r=uEe((()=>a),(()=>"button")),o=Ra((()=>{const e=r();return null!=e&&function(e){const a=e.tagName.toLowerCase();return"button"===a||!("input"!==a||!e.type)&&-1!==lxe.indexOf(e.type)}({tagName:e,type:t.type})})),s=Ra((()=>"input"===r())),l=Ra((()=>"a"===r()&&null!=a?.getAttribute("href")));return mn(dEe,fn({as:"button",ref(e){const n=mTe((e=>a=e),t.ref);"function"==typeof n&&n(e)},get type(){return o()||s()?t.type:void 0},get role(){return o()||l()?void 0:"button"},get tabIndex(){return o()||l()||t.disabled?void 0:0},get disabled(){return o()||s()?t.disabled:void 0},get"aria-disabled"(){return!(o()||s()||!t.disabled)||void 0},get"data-disabled"(){return t.disabled?"":void 0}},i))}var cxe=uxe,dxe=["top","right","bottom","left"],mxe=Math.min,hxe=Math.max,pxe=Math.round,gxe=Math.floor,vxe=e=>({x:e,y:e}),fxe={left:"right",right:"left",bottom:"top",top:"bottom"},yxe={start:"end",end:"start"};function kxe(e,a,n){return hxe(e,mxe(a,n))}function bxe(e,a){return"function"==typeof e?e(a):e}function Sxe(e){return e.split("-")[0]}function Axe(e){return e.split("-")[1]}function wxe(e){return"x"===e?"y":"x"}function Cxe(e){return"y"===e?"height":"width"}function Mxe(e){return["top","bottom"].includes(Sxe(e))?"y":"x"}function Txe(e){return wxe(Mxe(e))}function Exe(e){return e.replace(/start|end/g,(e=>yxe[e]))}function xxe(e){return e.replace(/left|right|bottom|top/g,(e=>fxe[e]))}function Nxe(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function _xe(e){const{x:a,y:n,width:t,height:i}=e;return{width:t,height:i,top:n,left:a,right:a+t,bottom:n+i,x:a,y:n}}function Pxe(e,a,n){let{reference:t,floating:i}=e;const r=Mxe(a),o=Txe(a),s=Cxe(o),l=Sxe(a),u="y"===r,c=t.x+t.width/2-i.width/2,d=t.y+t.height/2-i.height/2,m=t[s]/2-i[s]/2;let h;switch(l){case"top":h={x:c,y:t.y-i.height};break;case"bottom":h={x:c,y:t.y+t.height};break;case"right":h={x:t.x+t.width,y:d};break;case"left":h={x:t.x-i.width,y:d};break;default:h={x:t.x,y:t.y}}switch(Axe(a)){case"start":h[o]-=m*(n&&u?-1:1);break;case"end":h[o]+=m*(n&&u?-1:1)}return h}async function Lxe(e,a){var n;void 0===a&&(a={});const{x:t,y:i,platform:r,rects:o,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:m=!1,padding:h=0}=bxe(a,e),p=Nxe(h),g=s[m?"floating"===d?"reference":"floating":d],v=_xe(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(g)))||n?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),f="floating"===d?{x:t,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),k=await(null==r.isElement?void 0:r.isElement(y))&&await(null==r.getScale?void 0:r.getScale(y))||{x:1,y:1},b=_xe(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:f,offsetParent:y,strategy:l}):f);return{top:(v.top-b.top+p.top)/k.y,bottom:(b.bottom-v.bottom+p.bottom)/k.y,left:(v.left-b.left+p.left)/k.x,right:(b.right-v.right+p.right)/k.x}}function jxe(e,a){return{top:e.top-a.height,right:e.right-a.width,bottom:e.bottom-a.height,left:e.left-a.width}}function Bxe(e){return dxe.some((a=>e[a]>=0))}function Rxe(e){return Kxe(e)?(e.nodeName||"").toLowerCase():"#document"}function zxe(e){var a;return(null==e||null==(a=e.ownerDocument)?void 0:a.defaultView)||window}function Dxe(e){var a;return null==(a=(Kxe(e)?e.ownerDocument:e.document)||window.document)?void 0:a.documentElement}function Kxe(e){return e instanceof Node||e instanceof zxe(e).Node}function Oxe(e){return e instanceof Element||e instanceof zxe(e).Element}function Hxe(e){return e instanceof HTMLElement||e instanceof zxe(e).HTMLElement}function Ixe(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof zxe(e).ShadowRoot)}function Gxe(e){const{overflow:a,overflowX:n,overflowY:t,display:i}=qxe(e);return/auto|scroll|overlay|hidden|clip/.test(a+t+n)&&!["inline","contents"].includes(i)}function Fxe(e){return["table","td","th"].includes(Rxe(e))}function Vxe(e){return[":popover-open",":modal"].some((a=>{try{return e.matches(a)}catch(YHe){return!1}}))}function Jxe(e){const a=Uxe(),n=Oxe(e)?qxe(e):e;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!a&&!!n.backdropFilter&&"none"!==n.backdropFilter||!a&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function Uxe(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function Wxe(e){return["html","body","#document"].includes(Rxe(e))}function qxe(e){return zxe(e).getComputedStyle(e)}function Zxe(e){return Oxe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $xe(e){if("html"===Rxe(e))return e;const a=e.assignedSlot||e.parentNode||Ixe(e)&&e.host||Dxe(e);return Ixe(a)?a.host:a}function Yxe(e){const a=$xe(e);return Wxe(a)?e.ownerDocument?e.ownerDocument.body:e.body:Hxe(a)&&Gxe(a)?a:Yxe(a)}function Qxe(e,a,n){var t;void 0===a&&(a=[]),void 0===n&&(n=!0);const i=Yxe(e),r=i===(null==(t=e.ownerDocument)?void 0:t.body),o=zxe(i);return r?a.concat(o,o.visualViewport||[],Gxe(i)?i:[],o.frameElement&&n?Qxe(o.frameElement):[]):a.concat(i,Qxe(i,[],n))}function Xxe(e){const a=qxe(e);let n=parseFloat(a.width)||0,t=parseFloat(a.height)||0;const i=Hxe(e),r=i?e.offsetWidth:n,o=i?e.offsetHeight:t,s=pxe(n)!==r||pxe(t)!==o;return s&&(n=r,t=o),{width:n,height:t,$:s}}function eNe(e){return Oxe(e)?e:e.contextElement}function aNe(e){const a=eNe(e);if(!Hxe(a))return vxe(1);const n=a.getBoundingClientRect(),{width:t,height:i,$:r}=Xxe(a);let o=(r?pxe(n.width):n.width)/t,s=(r?pxe(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var nNe=vxe(0);function tNe(e){const a=zxe(e);return Uxe()&&a.visualViewport?{x:a.visualViewport.offsetLeft,y:a.visualViewport.offsetTop}:nNe}function iNe(e,a,n,t){void 0===a&&(a=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),r=eNe(e);let o=vxe(1);a&&(t?Oxe(t)&&(o=aNe(t)):o=aNe(e));const s=function(e,a,n){return void 0===a&&(a=!1),!(!n||a&&n!==zxe(e))&&a}(r,n,t)?tNe(r):vxe(0);let l=(i.left+s.x)/o.x,u=(i.top+s.y)/o.y,c=i.width/o.x,d=i.height/o.y;if(r){const e=zxe(r),a=t&&Oxe(t)?zxe(t):t;let n=e,i=n.frameElement;for(;i&&t&&a!==n;){const e=aNe(i),a=i.getBoundingClientRect(),t=qxe(i),r=a.left+(i.clientLeft+parseFloat(t.paddingLeft))*e.x,o=a.top+(i.clientTop+parseFloat(t.paddingTop))*e.y;l*=e.x,u*=e.y,c*=e.x,d*=e.y,l+=r,u+=o,n=zxe(i),i=n.frameElement}}return _xe({width:c,height:d,x:l,y:u})}function rNe(e){return iNe(Dxe(e)).left+Zxe(e).scrollLeft}function oNe(e,a,n){let t;if("viewport"===a)t=function(e,a){const n=zxe(e),t=Dxe(e),i=n.visualViewport;let r=t.clientWidth,o=t.clientHeight,s=0,l=0;if(i){r=i.width,o=i.height;const e=Uxe();(!e||e&&"fixed"===a)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:o,x:s,y:l}}(e,n);else if("document"===a)t=function(e){const a=Dxe(e),n=Zxe(e),t=e.ownerDocument.body,i=hxe(a.scrollWidth,a.clientWidth,t.scrollWidth,t.clientWidth),r=hxe(a.scrollHeight,a.clientHeight,t.scrollHeight,t.clientHeight);let o=-n.scrollLeft+rNe(e);const s=-n.scrollTop;return"rtl"===qxe(t).direction&&(o+=hxe(a.clientWidth,t.clientWidth)-i),{width:i,height:r,x:o,y:s}}(Dxe(e));else if(Oxe(a))t=function(e,a){const n=iNe(e,!0,"fixed"===a),t=n.top+e.clientTop,i=n.left+e.clientLeft,r=Hxe(e)?aNe(e):vxe(1);return{width:e.clientWidth*r.x,height:e.clientHeight*r.y,x:i*r.x,y:t*r.y}}(a,n);else{const n=tNe(e);t={...a,x:a.x-n.x,y:a.y-n.y}}return _xe(t)}function sNe(e,a){const n=$xe(e);return!(n===a||!Oxe(n)||Wxe(n))&&("fixed"===qxe(n).position||sNe(n,a))}function lNe(e,a,n){const t=Hxe(a),i=Dxe(a),r="fixed"===n,o=iNe(e,!0,r,a);let s={scrollLeft:0,scrollTop:0};const l=vxe(0);if(t||!t&&!r)if(("body"!==Rxe(a)||Gxe(i))&&(s=Zxe(a)),t){const e=iNe(a,!0,r,a);l.x=e.x+a.clientLeft,l.y=e.y+a.clientTop}else i&&(l.x=rNe(i));return{x:o.left+s.scrollLeft-l.x,y:o.top+s.scrollTop-l.y,width:o.width,height:o.height}}function uNe(e){return"static"===qxe(e).position}function cNe(e,a){return Hxe(e)&&"fixed"!==qxe(e).position?a?a(e):e.offsetParent:null}function dNe(e,a){const n=zxe(e);if(Vxe(e))return n;if(!Hxe(e)){let a=$xe(e);for(;a&&!Wxe(a);){if(Oxe(a)&&!uNe(a))return a;a=$xe(a)}return n}let t=cNe(e,a);for(;t&&Fxe(t)&&uNe(t);)t=cNe(t,a);return t&&Wxe(t)&&uNe(t)&&!Jxe(t)?n:t||function(e){let a=$xe(e);for(;Hxe(a)&&!Wxe(a);){if(Jxe(a))return a;if(Vxe(a))return null;a=$xe(a)}return null}(e)||n}var mNe={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:a,rect:n,offsetParent:t,strategy:i}=e;const r="fixed"===i,o=Dxe(t),s=!!a&&Vxe(a.floating);if(t===o||s&&r)return n;let l={scrollLeft:0,scrollTop:0},u=vxe(1);const c=vxe(0),d=Hxe(t);if((d||!d&&!r)&&(("body"!==Rxe(t)||Gxe(o))&&(l=Zxe(t)),Hxe(t))){const e=iNe(t);u=aNe(t),c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x,y:n.y*u.y-l.scrollTop*u.y+c.y}},getDocumentElement:Dxe,getClippingRect:function(e){let{element:a,boundary:n,rootBoundary:t,strategy:i}=e;const r=[..."clippingAncestors"===n?Vxe(a)?[]:function(e,a){const n=a.get(e);if(n)return n;let t=Qxe(e,[],!1).filter((e=>Oxe(e)&&"body"!==Rxe(e))),i=null;const r="fixed"===qxe(e).position;let o=r?$xe(e):e;for(;Oxe(o)&&!Wxe(o);){const a=qxe(o),n=Jxe(o);n||"fixed"!==a.position||(i=null),(r?!n&&!i:!n&&"static"===a.position&&i&&["absolute","fixed"].includes(i.position)||Gxe(o)&&!n&&sNe(e,o))?t=t.filter((e=>e!==o)):i=a,o=$xe(o)}return a.set(e,t),t}(a,this._c):[].concat(n),t],o=r.reduce(((e,n)=>{const t=oNe(a,n,i);return e.top=hxe(t.top,e.top),e.right=mxe(t.right,e.right),e.bottom=mxe(t.bottom,e.bottom),e.left=hxe(t.left,e.left),e}),oNe(a,r[0],i));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:dNe,getElementRects:async function(e){const a=this.getOffsetParent||dNe,n=this.getDimensions,t=await n(e.floating);return{reference:lNe(e.reference,await a(e.floating),e.strategy),floating:{x:0,y:0,width:t.width,height:t.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:a,height:n}=Xxe(e);return{width:a,height:n}},getScale:aNe,isElement:Oxe,isRTL:function(e){return"rtl"===qxe(e).direction}};function hNe(e,a,n,t){void 0===t&&(t={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:l=!1}=t,u=eNe(e),c=i||r?[...u?Qxe(u):[],...Qxe(a)]:[];c.forEach((e=>{i&&e.addEventListener("scroll",n,{passive:!0}),r&&e.addEventListener("resize",n)}));const d=u&&s?function(e,a){let n,t=null;const i=Dxe(e);function r(){var e;clearTimeout(n),null==(e=t)||e.disconnect(),t=null}return function o(s,l){void 0===s&&(s=!1),void 0===l&&(l=1),r();const{left:u,top:c,width:d,height:m}=e.getBoundingClientRect();if(s||a(),!d||!m)return;const h={rootMargin:-gxe(c)+"px "+-gxe(i.clientWidth-(u+d))+"px "+-gxe(i.clientHeight-(c+m))+"px "+-gxe(u)+"px",threshold:hxe(0,mxe(1,l))||1};let p=!0;function g(e){const a=e[0].intersectionRatio;if(a!==l){if(!p)return o();a?o(!1,a):n=setTimeout((()=>{o(!1,1e-7)}),1e3)}p=!1}try{t=new IntersectionObserver(g,{...h,root:i.ownerDocument})}catch(YHe){t=new IntersectionObserver(g,h)}t.observe(e)}(!0),r}(u,n):null;let m,h=-1,p=null;o&&(p=new ResizeObserver((e=>{let[t]=e;t&&t.target===u&&p&&(p.unobserve(a),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(a)}))),n()})),u&&!l&&p.observe(u),p.observe(a));let g=l?iNe(e):null;return l&&function a(){const t=iNe(e);!g||t.x===g.x&&t.y===g.y&&t.width===g.width&&t.height===g.height||n();g=t,m=requestAnimationFrame(a)}(),n(),()=>{var e;c.forEach((e=>{i&&e.removeEventListener("scroll",n),r&&e.removeEventListener("resize",n)})),null==d||d(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(m)}}var pNe=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(a){var n,t;const{x:i,y:r,placement:o,middlewareData:s}=a,l=await async function(e,a){const{placement:n,platform:t,elements:i}=e,r=await(null==t.isRTL?void 0:t.isRTL(i.floating)),o=Sxe(n),s=Axe(n),l="y"===Mxe(n),u=["left","top"].includes(o)?-1:1,c=r&&l?-1:1,d=bxe(a,e);let{mainAxis:m,crossAxis:h,alignmentAxis:p}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return s&&"number"==typeof p&&(h="end"===s?-1*p:p),l?{x:h*c,y:m*u}:{x:m*u,y:h*c}}(a,e);return o===(null==(n=s.offset)?void 0:n.placement)&&null!=(t=s.arrow)&&t.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:{...l,placement:o}}}}},gNe=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(a){const{x:n,y:t,placement:i}=a,{mainAxis:r=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:a,y:n}=e;return{x:a,y:n}}},...l}=bxe(e,a),u={x:n,y:t},c=await Lxe(a,l),d=Mxe(Sxe(i)),m=wxe(d);let h=u[m],p=u[d];if(r){h=kxe(h+c["y"===m?"top":"left"],h,h-c["y"===m?"bottom":"right"])}if(o){p=kxe(p+c["y"===d?"top":"left"],p,p-c["y"===d?"bottom":"right"])}const g=s.fn({...a,[m]:h,[d]:p});return{...g,data:{x:g.x-n,y:g.y-t}}}}},vNe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(a){var n,t;const{placement:i,middlewareData:r,rects:o,initialPlacement:s,platform:l,elements:u}=a,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...v}=bxe(e,a);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const f=Sxe(i),y=Mxe(s),k=Sxe(s)===s,b=await(null==l.isRTL?void 0:l.isRTL(u.floating)),S=m||(k||!g?[xxe(s)]:function(e){const a=xxe(e);return[Exe(e),a,Exe(a)]}(s)),A="none"!==p;!m&&A&&S.push(...function(e,a,n,t){const i=Axe(e);let r=function(e,a,n){const t=["left","right"],i=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(e){case"top":case"bottom":return n?a?i:t:a?t:i;case"left":case"right":return a?r:o;default:return[]}}(Sxe(e),"start"===n,t);return i&&(r=r.map((e=>e+"-"+i)),a&&(r=r.concat(r.map(Exe)))),r}(s,g,p,b));const w=[s,...S],C=await Lxe(a,v),M=[];let T=(null==(t=r.flip)?void 0:t.overflows)||[];if(c&&M.push(C[f]),d){const e=function(e,a,n){void 0===n&&(n=!1);const t=Axe(e),i=Txe(e),r=Cxe(i);let o="x"===i?t===(n?"end":"start")?"right":"left":"start"===t?"bottom":"top";return a.reference[r]>a.floating[r]&&(o=xxe(o)),[o,xxe(o)]}(i,o,b);M.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:i,overflows:M}],!M.every((e=>e<=0))){var E,x;const e=((null==(E=r.flip)?void 0:E.index)||0)+1,a=w[e];if(a)return{data:{index:e,overflows:T},reset:{placement:a}};let n=null==(x=T.filter((e=>e.overflows[0]<=0)).sort(((e,a)=>e.overflows[1]-a.overflows[1]))[0])?void 0:x.placement;if(!n)switch(h){case"bestFit":{var N;const e=null==(N=T.filter((e=>{if(A){const a=Mxe(e.placement);return a===y||"y"===a}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,a)=>e+a),0)])).sort(((e,a)=>e[1]-a[1]))[0])?void 0:N[0];e&&(n=e);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}},fNe=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(a){const{placement:n,rects:t,platform:i,elements:r}=a,{apply:o=()=>{},...s}=bxe(e,a),l=await Lxe(a,s),u=Sxe(n),c=Axe(n),d="y"===Mxe(n),{width:m,height:h}=t.floating;let p,g;"top"===u||"bottom"===u?(p=u,g=c===(await(null==i.isRTL?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(g=u,p="end"===c?"top":"bottom");const v=h-l.top-l.bottom,f=m-l.left-l.right,y=mxe(h-l[p],v),k=mxe(m-l[g],f),b=!a.middlewareData.shift;let S=y,A=k;if(d?A=c||b?mxe(k,f):f:S=c||b?mxe(y,v):v,b&&!c){const e=hxe(l.left,0),a=hxe(l.right,0),n=hxe(l.top,0),t=hxe(l.bottom,0);d?A=m-2*(0!==e||0!==a?e+a:hxe(l.left,l.right)):S=h-2*(0!==n||0!==t?n+t:hxe(l.top,l.bottom))}await o({...a,availableWidth:A,availableHeight:S});const w=await i.getDimensions(r.floating);return m!==w.width||h!==w.height?{reset:{rects:!0}}:{}}}},yNe=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(a){const{rects:n}=a,{strategy:t="referenceHidden",...i}=bxe(e,a);switch(t){case"referenceHidden":{const e=jxe(await Lxe(a,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Bxe(e)}}}case"escaped":{const e=jxe(await Lxe(a,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Bxe(e)}}}default:return{}}}}},kNe=e=>({name:"arrow",options:e,async fn(a){const{x:n,y:t,placement:i,rects:r,platform:o,elements:s,middlewareData:l}=a,{element:u,padding:c=0}=bxe(e,a)||{};if(null==u)return{};const d=Nxe(c),m={x:n,y:t},h=Txe(i),p=Cxe(h),g=await o.getDimensions(u),v="y"===h,f=v?"top":"left",y=v?"bottom":"right",k=v?"clientHeight":"clientWidth",b=r.reference[p]+r.reference[h]-m[h]-r.floating[p],S=m[h]-r.reference[h],A=await(null==o.getOffsetParent?void 0:o.getOffsetParent(u));let w=A?A[k]:0;w&&await(null==o.isElement?void 0:o.isElement(A))||(w=s.floating[k]||r.floating[p]);const C=b/2-S/2,M=w/2-g[p]/2-1,T=mxe(d[f],M),E=mxe(d[y],M),x=T,N=w-g[p]-E,_=w/2-g[p]/2+C,P=kxe(x,_,N),L=!l.arrow&&null!=Axe(i)&&_!==P&&r.reference[p]/2-(_<x?T:E)-g[p]/2<0,j=L?_<x?_-x:_-N:0;return{[h]:m[h]+j,data:{[h]:P,centerOffset:_-P-j,...L&&{alignmentOffset:j}},reset:L}}}),bNe=(e,a,n)=>{const t={platform:mNe,...n},i={...t.platform,_c:new Map};return(async(e,a,n)=>{const{placement:t="bottom",strategy:i="absolute",middleware:r=[],platform:o}=n,s=r.filter(Boolean),l=await(null==o.isRTL?void 0:o.isRTL(a));let u=await o.getElementRects({reference:e,floating:a,strategy:i}),{x:c,y:d}=Pxe(u,t,l),m=t,h={},p=0;for(let g=0;g<s.length;g++){const{name:n,fn:r}=s[g],{x:v,y:f,data:y,reset:k}=await r({x:c,y:d,initialPlacement:t,placement:m,strategy:i,middlewareData:h,rects:u,platform:o,elements:{reference:e,floating:a}});c=null!=v?v:c,d=null!=f?f:d,h={...h,[n]:{...h[n],...y}},k&&p<=50&&(p++,"object"==typeof k&&(k.placement&&(m=k.placement),k.rects&&(u=!0===k.rects?await o.getElementRects({reference:e,floating:a,strategy:i}):k.rects),({x:c,y:d}=Pxe(u,m,l))),g=-1)}return{x:c,y:d,placement:m,strategy:i,middlewareData:h}})(e,a,{...t,platform:i})},SNe=Ja();function ANe(){const e=Ua(SNe);if(void 0===e)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var wNe=Dn('<svg display="block" viewBox="0 0 30 30" style="transform:scale(1.02)"><g><path fill="none" d="M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z"></path><path stroke="none" d="M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z">'),CNe={top:180,right:-90,bottom:0,left:90};function MNe(e){const a=ANe(),n=aEe({size:30},e),[t,i]=yn(n,["ref","style","size"]),r=()=>a.currentPlacement().split("-")[0],o=function(e){const[a,n]=Pa();return Ba((()=>{const a=e();var t;a&&n((t=a,jTe(t).defaultView||window).getComputedStyle(a))})),a}(a.contentRef),s=()=>2*Number.parseInt(o()?.getPropertyValue(`border-${r()}-width`)||"0px")*(30/t.size);return mn(dEe,fn({as:"div",ref(e){const n=mTe(a.setArrowRef,t.ref);"function"==typeof n&&n(e)},"aria-hidden":"true",get style(){return ETe({position:"absolute","font-size":`${t.size}px`,width:"1em",height:"1em","pointer-events":"none",fill:o()?.getPropertyValue("background-color")||"none",stroke:o()?.getPropertyValue(`border-${r()}-color`)||"none","stroke-width":s()},t.style)}},i,{get children(){const e=wNe(),a=e.firstChild;return ja((()=>On(a,"transform",`rotate(${CNe[r()]} 15 15) translate(0 2)`))),e}}))}function TNe(e){const{x:a=0,y:n=0,width:t=0,height:i=0}=e??{};if("function"==typeof DOMRect)return new DOMRect(a,n,t,i);const r={x:a,y:n,width:t,height:i,top:n,right:a+t,bottom:n+i,left:a};return{...r,toJSON:()=>r}}function ENe(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var xNe={top:"bottom",right:"left",bottom:"top",left:"right"};var NNe=Object.assign((function(e){const a=aEe({getAnchorRect:e=>e?.getBoundingClientRect(),placement:"bottom",gutter:0,shift:0,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,hideWhenDetached:!1,detachedPadding:0,arrowPadding:4,overflowPadding:8},e),[n,t]=Pa(),[i,r]=Pa(),[o,s]=Pa(a.placement),l=()=>{return e=a.anchorRef?.(),n=a.getAnchorRect,{contextElement:e,getBoundingClientRect:()=>{const a=n(e);return a?TNe(a):e?e.getBoundingClientRect():TNe()}};var e,n},{direction:u}=HEe();async function c(){const e=l(),t=n(),r=i();if(!e||!t)return;const o=(r?.clientHeight||0)/2,c="number"==typeof a.gutter?a.gutter+o:a.gutter??o;t.style.setProperty("--kb-popper-content-overflow-padding",`${a.overflowPadding}px`),e.getBoundingClientRect();const d=[pNe((({placement:e})=>{const n=!!e.split("-")[1];return{mainAxis:c,crossAxis:n?void 0:a.shift,alignmentAxis:a.shift}}))];if(!1!==a.flip){const e="string"==typeof a.flip?a.flip.split(" "):void 0;if(void 0!==e&&!e.every(ENe))throw new Error("`flip` expects a spaced-delimited list of placements");d.push(vNe({padding:a.overflowPadding,fallbackPlacements:e}))}(a.slide||a.overlap)&&d.push(gNe({mainAxis:a.slide,crossAxis:a.overlap,padding:a.overflowPadding})),d.push(fNe({padding:a.overflowPadding,apply({availableWidth:e,availableHeight:n,rects:i}){const r=Math.round(i.reference.width);e=Math.floor(e),n=Math.floor(n),t.style.setProperty("--kb-popper-anchor-width",`${r}px`),t.style.setProperty("--kb-popper-content-available-width",`${e}px`),t.style.setProperty("--kb-popper-content-available-height",`${n}px`),a.sameWidth&&(t.style.width=`${r}px`),a.fitViewport&&(t.style.maxWidth=`${e}px`,t.style.maxHeight=`${n}px`)}})),a.hideWhenDetached&&d.push(yNe({padding:a.detachedPadding})),r&&d.push(kNe({element:r,padding:a.arrowPadding}));const m=await bNe(e,t,{placement:a.placement,strategy:"absolute",middleware:d,platform:{...mNe,isRTL:()=>"rtl"===u()}});if(s(m.placement),a.onCurrentPlacementChange?.(m.placement),!t)return;t.style.setProperty("--kb-popper-content-transform-origin",function(e,a){const[n,t]=e.split("-"),i=xNe[n];return t?"left"===n||"right"===n?`${i} ${"start"===t?"top":"bottom"}`:"start"===t?`${i} ${"rtl"===a?"right":"left"}`:`${i} ${"rtl"===a?"left":"right"}`:`${i} center`}(m.placement,u()));const h=Math.round(m.x),p=Math.round(m.y);let g;if(a.hideWhenDetached&&(g=m.middlewareData.hide?.referenceHidden?"hidden":"visible"),Object.assign(t.style,{top:"0",left:"0",transform:`translate3d(${h}px, ${p}px, 0)`,visibility:g}),r&&m.middlewareData.arrow){const{x:e,y:a}=m.middlewareData.arrow,n=m.placement.split("-")[0];Object.assign(r.style,{left:null!=e?`${e}px`:"",top:null!=a?`${a}px`:"",[n]:"100%"})}}return Ba((()=>{const e=l(),a=n();if(!e||!a)return;Ha(hNe(e,a,c,{elementResize:"function"==typeof ResizeObserver}))})),Ba((()=>{const e=n(),t=a.contentRef?.();e&&t&&queueMicrotask((()=>{e.style.zIndex=getComputedStyle(t).zIndex}))})),mn(SNe.Provider,{value:{currentPlacement:o,contentRef:()=>a.contentRef?.(),setPositionerRef:t,setArrowRef:r},get children(){return a.children}})}),{Arrow:MNe,Context:SNe,usePopperContext:ANe,Positioner:function(e){const a=ANe(),[n,t]=yn(e,["ref","style"]);return mn(dEe,fn({as:"div",ref(e){const t=mTe(a.setPositionerRef,n.ref);"function"==typeof t&&t(e)},"data-popper-positioner":"",get style(){return ETe({position:"absolute",top:0,left:0,"min-width":"max-content"},n.style)}},t))}});var _Ne="interactOutside.pointerDownOutside",PNe="interactOutside.focusOutside";var LNe=Ja();function jNe(e){let a;const n=Ua(LNe),[t,i]=yn(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]);!function(e,a){let n,t=eEe;const i=()=>jTe(a()),r=a=>e.onPointerDownOutside?.(a),o=a=>e.onFocusOutside?.(a),s=a=>e.onInteractOutside?.(a),l=n=>{const t=n.target;return t instanceof HTMLElement&&!t.closest(`[${exe}]`)&&!!PTe(i(),t)&&!PTe(a(),t)&&!e.shouldExcludeElement?.(t)},u=e=>{function n(){const n=a(),t=e.target;if(!n||!t||!l(e))return;const i=HTe([r,s]);t.addEventListener(_Ne,i,{once:!0});const o=new CustomEvent(_Ne,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:2===e.button||ITe(e)&&0===e.button}});t.dispatchEvent(o)}"touch"===e.pointerType?(i().removeEventListener("click",n),t=n,i().addEventListener("click",n,{once:!0})):n()},c=e=>{const n=a(),t=e.target;if(!n||!t||!l(e))return;const i=HTe([o,s]);t.addEventListener(PNe,i,{once:!0});const r=new CustomEvent(PNe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:!1}});t.dispatchEvent(r)};Ba((()=>{kMe(e.isDisabled)||(n=window.setTimeout((()=>{i().addEventListener("pointerdown",u,!0)}),0),i().addEventListener("focusin",c,!0),Ha((()=>{window.clearTimeout(n),i().removeEventListener("click",t),i().removeEventListener("pointerdown",u,!0),i().removeEventListener("focusin",c,!0)})))}))}({shouldExcludeElement:e=>!!a&&(t.excludedElements?.some((a=>PTe(a(),e)))||[...r].some((a=>PTe(a,e)))),onPointerDownOutside:e=>{a&&!sxe.isBelowPointerBlockingLayer(a)&&(t.bypassTopMostLayerCheck||sxe.isTopMostLayer(a))&&(t.onPointerDownOutside?.(e),t.onInteractOutside?.(e),e.defaultPrevented||t.onDismiss?.())},onFocusOutside:e=>{t.onFocusOutside?.(e),t.onInteractOutside?.(e),e.defaultPrevented||t.onDismiss?.()}},(()=>a)),function(e){const a=a=>{a.key===RTe.Escape&&e.onEscapeKeyDown?.(a)};Ba((()=>{if(kMe(e.isDisabled))return;const n=e.ownerDocument?.()??jTe();n.addEventListener("keydown",a),Ha((()=>{n.removeEventListener("keydown",a)}))}))}({ownerDocument:()=>jTe(a),onEscapeKeyDown:e=>{a&&sxe.isTopMostLayer(a)&&(t.onEscapeKeyDown?.(e),!e.defaultPrevented&&t.onDismiss&&(e.preventDefault(),t.onDismiss()))}}),Oa((()=>{if(!a)return;sxe.addLayer({node:a,isPointerBlocking:t.disableOutsidePointerEvents,dismiss:t.onDismiss});const e=n?.registerNestedLayer(a);sxe.assignPointerEventToLayers(),sxe.disableBodyPointerEvents(a),Ha((()=>{a&&(sxe.removeLayer(a),e?.(),sxe.assignPointerEventToLayers(),sxe.restoreBodyPointerEvents(a))}))})),Ba(Ka([()=>a,()=>t.disableOutsidePointerEvents],(([e,a])=>{if(!e)return;const n=sxe.find(e);n&&n.isPointerBlocking!==a&&(n.isPointerBlocking=a,sxe.assignPointerEventToLayers()),a&&sxe.disableBodyPointerEvents(e),Ha((()=>{sxe.restoreBodyPointerEvents(e)}))}),{defer:!0}));return mn(LNe.Provider,{value:{registerNestedLayer:e=>{r.add(e);const a=n?.registerNestedLayer(e);return()=>{r.delete(e),a?.()}}},get children(){return mn(dEe,fn({as:"div",ref(e){const n=mTe((e=>a=e),t.ref);"function"==typeof n&&n(e)}},i))}})}function BNe(e={}){const[a,n]=bEe({value:()=>kMe(e.open),defaultValue:()=>!!kMe(e.defaultOpen),onChange:a=>e.onOpenChange?.(a)}),t=()=>{n(!0)},i=()=>{n(!1)};return{isOpen:a,setIsOpen:n,open:t,close:i,toggle:()=>{a()?i():t()}}}var RNe={};AEe(RNe,{Description:()=>gEe,ErrorMessage:()=>vEe,Item:()=>HNe,ItemControl:()=>INe,ItemDescription:()=>GNe,ItemIndicator:()=>FNe,ItemInput:()=>VNe,ItemLabel:()=>JNe,Label:()=>UNe,RadioGroup:()=>qNe,Root:()=>WNe});var zNe=Ja();function DNe(){const e=Ua(zNe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupContext` must be used within a `RadioGroup` component");return e}var KNe=Ja();function ONe(){const e=Ua(KNe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupItemContext` must be used within a `RadioGroup.Item` component");return e}function HNe(e){const a=pEe(),n=DNe(),t=aEe({id:`${a.generateId("item")}-${Sn()}`},e),[i,r]=yn(t,["value","disabled","onPointerDown"]),[o,s]=Pa(),[l,u]=Pa(),[c,d]=Pa(),[m,h]=Pa(),[p,g]=Pa(!1),v=Ra((()=>n.isSelectedValue(i.value))),f=Ra((()=>i.disabled||a.isDisabled()||!1)),y=e=>{OTe(e,i.onPointerDown),p()&&e.preventDefault()},k=Ra((()=>({...a.dataset(),"data-disabled":f()?"":void 0,"data-checked":v()?"":void 0}))),b={value:()=>i.value,dataset:k,isSelected:v,isDisabled:f,inputId:o,labelId:l,descriptionId:c,inputRef:m,select:()=>n.setSelectedValue(i.value),generateId:_Te((()=>r.id)),registerInput:lEe(s),registerLabel:lEe(u),registerDescription:lEe(d),setIsFocused:g,setInputRef:h};return mn(KNe.Provider,{value:b,get children(){return mn(dEe,fn({as:"div",role:"group",onPointerDown:y},k,r))}})}function INe(e){const a=ONe(),n=aEe({id:a.generateId("control")},e),[t,i]=yn(n,["onClick","onKeyDown"]);return mn(dEe,fn({as:"div",onClick:e=>{OTe(e,t.onClick),a.select(),a.inputRef()?.focus()},onKeyDown:e=>{OTe(e,t.onKeyDown),e.key===RTe.Space&&(a.select(),a.inputRef()?.focus())}},(()=>a.dataset()),i))}function GNe(e){const a=ONe(),n=aEe({id:a.generateId("description")},e);return Ba((()=>Ha(a.registerDescription(n.id)))),mn(dEe,fn({as:"div"},(()=>a.dataset()),n))}function FNe(e){const a=ONe(),n=aEe({id:a.generateId("indicator")},e),[t,i]=yn(n,["ref","forceMount"]),[r,o]=Pa(),{present:s}=XEe({show:()=>t.forceMount||a.isSelected(),element:()=>r()??null});return mn(Mn,{get when(){return s()},get children(){return mn(dEe,fn({as:"div",ref(e){const a=mTe(o,t.ref);"function"==typeof a&&a(e)}},(()=>a.dataset()),i))}})}function VNe(e){const a=pEe(),n=DNe(),t=ONe(),i=aEe({id:t.generateId("input")},e),[r,o]=yn(i,["ref","style","aria-labelledby","aria-describedby","onChange","onFocus","onBlur"]),[s,l]=Pa(!1);return Ba(Ka([()=>t.isSelected(),()=>t.value()],(e=>{if(!e[0]&&e[1]===t.value())return;l(!0);const a=t.inputRef();a?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),a?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))}),{defer:!0})),Ba((()=>Ha(t.registerInput(o.id)))),mn(dEe,fn({as:"input",ref(e){const a=mTe(t.setInputRef,r.ref);"function"==typeof a&&a(e)},type:"radio",get name(){return a.name()},get value(){return t.value()},get checked(){return t.isSelected()},get required(){return a.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return a.isReadOnly()},get style(){return ETe({...sEe},r.style)},get"aria-labelledby"(){return[r["aria-labelledby"],t.labelId(),null!=r["aria-labelledby"]&&null!=o["aria-label"]?o.id:void 0].filter(Boolean).join(" ")||void 0},get"aria-describedby"(){return[r["aria-describedby"],t.descriptionId(),n.ariaDescribedBy()].filter(Boolean).join(" ")||void 0},onChange:e=>{if(OTe(e,r.onChange),e.stopPropagation(),!s()){n.setSelectedValue(t.value());e.target.checked=t.isSelected()}l(!1)},onFocus:e=>{OTe(e,r.onFocus),t.setIsFocused(!0)},onBlur:e=>{OTe(e,r.onBlur),t.setIsFocused(!1)}},(()=>t.dataset()),o))}function JNe(e){const a=ONe(),n=aEe({id:a.generateId("label")},e);return Ba((()=>Ha(a.registerLabel(n.id)))),mn(dEe,fn({as:"label",get for(){return a.inputId()}},(()=>a.dataset()),n))}function UNe(e){return mn(fEe,fn({as:"span"},e))}function WNe(e){let a;const n=aEe({id:`radiogroup-${Sn()}`,orientation:"vertical"},e),[t,i,r]=yn(n,["ref","value","defaultValue","onChange","orientation","aria-labelledby","aria-describedby"],mEe),[o,s]=kEe({value:()=>t.value,defaultValue:()=>t.defaultValue,onChange:e=>t.onChange?.(e)}),{formControlContext:l}=function(e){const a=aEe({id:`form-control-${Sn()}`},e),[n,t]=Pa(),[i,r]=Pa(),[o,s]=Pa(),[l,u]=Pa();return{formControlContext:{name:()=>kMe(a.name)??kMe(a.id),dataset:Ra((()=>({"data-valid":"valid"===kMe(a.validationState)?"":void 0,"data-invalid":"invalid"===kMe(a.validationState)?"":void 0,"data-required":kMe(a.required)?"":void 0,"data-disabled":kMe(a.disabled)?"":void 0,"data-readonly":kMe(a.readOnly)?"":void 0}))),validationState:()=>kMe(a.validationState),isRequired:()=>kMe(a.required),isDisabled:()=>kMe(a.disabled),isReadOnly:()=>kMe(a.readOnly),labelId:n,fieldId:i,descriptionId:o,errorMessageId:l,getAriaLabelledBy:(e,a,t)=>{const i=null!=t||null!=n();return[t,n(),i&&null!=a?e:void 0].filter(Boolean).join(" ")||void 0},getAriaDescribedBy:e=>[o(),l(),e].filter(Boolean).join(" ")||void 0,generateId:_Te((()=>kMe(a.id))),registerLabel:lEe(t),registerField:lEe(r),registerDescription:lEe(s),registerErrorMessage:lEe(u)}}}(i);yEe((()=>a),(()=>s(t.defaultValue??"")));const u=()=>l.getAriaDescribedBy(t["aria-describedby"]),c=e=>e===o(),d={ariaDescribedBy:u,isSelectedValue:c,setSelectedValue:e=>{if(!l.isReadOnly()&&!l.isDisabled()&&(s(e),a))for(const n of a.querySelectorAll("[type='radio']")){n.checked=c(n.value)}}};return mn(hEe.Provider,{value:l,get children(){return mn(zNe.Provider,{value:d,get children(){return mn(dEe,fn({as:"div",ref(e){const n=mTe((e=>a=e),t.ref);"function"==typeof n&&n(e)},role:"radiogroup",get id(){return kMe(i.id)},get"aria-invalid"(){return"invalid"===l.validationState()||void 0},get"aria-required"(){return l.isRequired()||void 0},get"aria-disabled"(){return l.isDisabled()||void 0},get"aria-readonly"(){return l.isReadOnly()||void 0},get"aria-orientation"(){return t.orientation},get"aria-labelledby"(){return l.getAriaLabelledBy(kMe(i.id),r["aria-label"],t["aria-labelledby"])},get"aria-describedby"(){return u()}},(()=>l.dataset()),r))}})}})}var qNe=Object.assign(WNe,{Description:gEe,ErrorMessage:vEe,Item:HNe,ItemControl:INe,ItemDescription:GNe,ItemIndicator:FNe,ItemInput:VNe,ItemLabel:JNe,Label:UNe}),ZNe=class{collection;ref;collator;constructor(e,a,n){this.collection=e,this.ref=a,this.collator=n}getKeyBelow(e){let a=this.collection().getKeyAfter(e);for(;null!=a;){const e=this.collection().getItem(a);if(e&&"item"===e.type&&!e.disabled)return a;a=this.collection().getKeyAfter(a)}}getKeyAbove(e){let a=this.collection().getKeyBefore(e);for(;null!=a;){const e=this.collection().getItem(a);if(e&&"item"===e.type&&!e.disabled)return a;a=this.collection().getKeyBefore(a)}}getFirstKey(){let e=this.collection().getFirstKey();for(;null!=e;){const a=this.collection().getItem(e);if(a&&"item"===a.type&&!a.disabled)return e;e=this.collection().getKeyAfter(e)}}getLastKey(){let e=this.collection().getLastKey();for(;null!=e;){const a=this.collection().getItem(e);if(a&&"item"===a.type&&!a.disabled)return e;e=this.collection().getKeyBefore(e)}}getItem(e){return this.ref?.()?.querySelector(`[data-key="${e}"]`)??null}getKeyPageAbove(e){const a=this.ref?.();let n=this.getItem(e);if(!a||!n)return;const t=Math.max(0,n.offsetTop+n.offsetHeight-a.offsetHeight);let i=e;for(;i&&n&&n.offsetTop>t;)i=this.getKeyAbove(i),n=null!=i?this.getItem(i):null;return i}getKeyPageBelow(e){const a=this.ref?.();let n=this.getItem(e);if(!a||!n)return;const t=Math.min(a.scrollHeight,n.offsetTop-n.offsetHeight+a.offsetHeight);let i=e;for(;i&&n&&n.offsetTop<t;)i=this.getKeyBelow(i),n=null!=i?this.getItem(i):null;return i}getKeyForSearch(e,a){const n=this.collator?.();if(!n)return;let t=null!=a?this.getKeyBelow(a):this.getFirstKey();for(;null!=t;){const a=this.collection().getItem(t);if(a){const i=a.textValue.slice(0,e.length);if(a.textValue&&0===n.compare(i,e))return t}t=this.getKeyBelow(t)}}};function $Ne(e,a,n){const t=function(e){const{locale:a}=HEe(),n=Ra((()=>a()+(e?Object.entries(e).sort(((e,a)=>e[0]<a[0]?-1:1)).join():"")));return Ra((()=>{const t=n();let i;return IEe.has(t)&&(i=IEe.get(t)),i||(i=new Intl.Collator(a(),e),IEe.set(t,i)),i}))}({usage:"search",sensitivity:"base"});return WEe({selectionManager:()=>kMe(e.selectionManager),keyboardDelegate:Ra((()=>{const n=kMe(e.keyboardDelegate);return n||new ZNe(e.collection,a,t)})),autoFocus:()=>kMe(e.autoFocus),deferAutoFocus:()=>kMe(e.deferAutoFocus),shouldFocusWrap:()=>kMe(e.shouldFocusWrap),disallowEmptySelection:()=>kMe(e.disallowEmptySelection),selectOnFocus:()=>kMe(e.selectOnFocus),disallowTypeAhead:()=>kMe(e.disallowTypeAhead),shouldUseVirtualFocus:()=>kMe(e.shouldUseVirtualFocus),allowsTabNavigation:()=>kMe(e.allowsTabNavigation),isVirtualized:()=>kMe(e.isVirtualized),scrollToKey:a=>kMe(e.scrollToKey)?.(a),orientation:()=>kMe(e.orientation)},a)}var YNe="focusScope.autoFocusOnMount",QNe="focusScope.autoFocusOnUnmount",XNe={bubbles:!1,cancelable:!0},e_e={stack:[],active(){return this.stack[0]},add(e){e!==this.active()&&this.active()?.pause(),this.stack=xTe(this.stack,e),this.stack.unshift(e)},remove(e){this.stack=xTe(this.stack,e),this.active()?.resume()}};function a_e(e,a){const[n,t]=Pa(!1),i={pause(){t(!0)},resume(){t(!1)}};let r=null;const o=a=>e.onMountAutoFocus?.(a),s=a=>e.onUnmountAutoFocus?.(a),l=()=>jTe(a()),u=()=>{const e=l().createElement("span");return e.setAttribute("data-focus-trap",""),e.tabIndex=0,Object.assign(e.style,sEe),e},c=()=>{const e=a();return e?qTe(e,!0).filter((e=>!e.hasAttribute("data-focus-trap"))):[]},d=()=>{const e=c();return e.length>0?e[0]:null};Ba((()=>{const e=a();if(!e)return;e_e.add(i);const n=LTe(e);if(!PTe(e,n)){const a=new CustomEvent(YNe,XNe);e.addEventListener(YNe,o),e.dispatchEvent(a),a.defaultPrevented||setTimeout((()=>{GTe(d()),LTe(e)===n&&GTe(e)}),0)}Ha((()=>{e.removeEventListener(YNe,o),setTimeout((()=>{const t=new CustomEvent(QNe,XNe);(()=>{const e=a();if(!e)return!1;const n=LTe(e);return!!n&&!PTe(e,n)&&$Te(n)})()&&t.preventDefault(),e.addEventListener(QNe,s),e.dispatchEvent(t),t.defaultPrevented||GTe(n??l().body),e.removeEventListener(QNe,s),e_e.remove(i)}),0)}))})),Ba((()=>{const t=a();if(!t||!kMe(e.trapFocus)||n())return;const i=e=>{const a=e.target;a?.closest(`[${exe}]`)||(PTe(t,a)?r=a:GTe(r))},o=e=>{const a=e.relatedTarget??LTe(t);a?.closest(`[${exe}]`)||PTe(t,a)||GTe(r)};l().addEventListener("focusin",i),l().addEventListener("focusout",o),Ha((()=>{l().removeEventListener("focusin",i),l().removeEventListener("focusout",o)}))})),Ba((()=>{const t=a();if(!t||!kMe(e.trapFocus)||n())return;const i=u();t.insertAdjacentElement("afterbegin",i);const r=u();function o(e){const a=d(),n=(()=>{const e=c();return e.length>0?e[e.length-1]:null})();GTe(e.relatedTarget===a?n:a)}t.insertAdjacentElement("beforeend",r),i.addEventListener("focusin",o),r.addEventListener("focusin",o);const s=new MutationObserver((e=>{for(const a of e)a.previousSibling===r&&(r.remove(),t.insertAdjacentElement("beforeend",r)),a.nextSibling===i&&(i.remove(),t.insertAdjacentElement("afterbegin",i))}));s.observe(t,{childList:!0,subtree:!1}),Ha((()=>{i.removeEventListener("focusin",o),r.removeEventListener("focusin",o),i.remove(),r.remove(),s.disconnect()}))}))}var n_e="data-live-announcer";function t_e(e){Ba((()=>{kMe(e.isDisabled)||Ha(function(e,a=document.body){const n=new Set(e),t=new Set,i=e=>{for(const t of e.querySelectorAll(`[${n_e}], [${exe}]`))n.add(t);const a=e=>{if(n.has(e)||e.parentElement&&t.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(const a of n)if(e.contains(a))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a}),o=a(e);if(o===NodeFilter.FILTER_ACCEPT&&r(e),o!==NodeFilter.FILTER_REJECT){let e=i.nextNode();for(;null!=e;)r(e),e=i.nextNode()}},r=e=>{const a=i_e.get(e)??0;"true"===e.getAttribute("aria-hidden")&&0===a||(0===a&&e.setAttribute("aria-hidden","true"),t.add(e),i_e.set(e,a+1))};r_e.length&&r_e[r_e.length-1].disconnect();i(a);const o=new MutationObserver((e=>{for(const a of e)if("childList"===a.type&&0!==a.addedNodes.length&&![...n,...t].some((e=>e.contains(a.target)))){for(const e of a.removedNodes)e instanceof Element&&(n.delete(e),t.delete(e));for(const e of a.addedNodes)!(e instanceof HTMLElement||e instanceof SVGElement)||"true"!==e.dataset.liveAnnouncer&&"true"!==e.dataset.reactAriaTopLayer?e instanceof Element&&i(e):n.add(e)}}));o.observe(a,{childList:!0,subtree:!0});const s={observe(){o.observe(a,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return r_e.push(s),()=>{o.disconnect();for(const e of t){const a=i_e.get(e);if(null==a)return;1===a?(e.removeAttribute("aria-hidden"),i_e.delete(e)):i_e.set(e,a-1)}s===r_e[r_e.length-1]?(r_e.pop(),r_e.length&&r_e[r_e.length-1].observe()):r_e.splice(r_e.indexOf(s),1)}}(kMe(e.targets),kMe(e.root)))}))}var i_e=new WeakMap,r_e=[];var o_e=new Map,s_e=e=>{Ba((()=>{const a=QEe(e.style)??{},n=QEe(e.properties)??[],t={};for(const r in a)t[r]=e.element.style[r];const i=o_e.get(e.key);i?i.activeCount++:o_e.set(e.key,{activeCount:1,originalStyles:t,properties:n.map((e=>e.key))}),Object.assign(e.element.style,e.style);for(const r of n)e.element.style.setProperty(r.key,r.value);Ha((()=>{const a=o_e.get(e.key);if(a)if(1===a.activeCount){o_e.delete(e.key);for(const[n,t]of Object.entries(a.originalStyles))e.element.style[n]=t;for(const n of a.properties)e.element.style.removeProperty(n);0===e.element.style.length&&e.element.removeAttribute("style"),e.cleanup?.()}else a.activeCount--}))}))},l_e=(e,a)=>{switch(a){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},u_e=(e,a)=>{const n=getComputedStyle(e),t="x"===a?n.overflowX:n.overflowY;return"auto"===t||"scroll"===t||"HTML"===e.tagName&&"visible"===t},[c_e,d_e]=Pa([]),m_e=e=>[e.deltaX,e.deltaY],h_e=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],p_e=(e,a,n,t)=>{const i=null!==t&&g_e(t,e),[r,o]=((e,a,n)=>{const t="x"===a&&"rtl"===window.getComputedStyle(e).direction?-1:1;let i=e,r=0,o=0,s=!1;do{const[e,l,u]=l_e(i,a),c=u-e-t*l;0===l&&0===c||!u_e(i,a)||(r+=c,o+=l),i===(n??document.documentElement)?s=!0:i=i._$host??i.parentElement}while(i&&!s);return[r,o]})(e,a,i?t:void 0);return!(n>0&&Math.abs(r)<=1)&&!(n<0&&Math.abs(o)<1)},g_e=(e,a)=>{if(e.contains(a))return!0;let n=a;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},v_e=e=>{const a=fn({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=Sn();let t=[0,0],i=null,r=null;Ba((()=>{QEe(a.enabled)&&(d_e((e=>[...e,n])),Ha((()=>{d_e((e=>e.filter((e=>e!==n))))})))})),Ba((()=>{if(!QEe(a.enabled)||!QEe(a.hideScrollbar))return;const{body:e}=document,n=window.innerWidth-e.offsetWidth;if(QEe(a.preventScrollbarShift)){const t={overflow:"hidden"},i=[];n>0&&("padding"===QEe(a.preventScrollbarShiftMode)?t.paddingRight=`calc(${window.getComputedStyle(e).paddingRight} + ${n}px)`:t.marginRight=`calc(${window.getComputedStyle(e).marginRight} + ${n}px)`,i.push({key:"--scrollbar-width",value:`${n}px`}));const r=window.scrollY,o=window.scrollX;s_e({key:"prevent-scroll",element:e,style:t,properties:i,cleanup:()=>{QEe(a.restoreScrollPosition)&&n>0&&window.scrollTo(o,r)}})}else s_e({key:"prevent-scroll",element:e,style:{overflow:"hidden"}})})),Ba((()=>{var e;(e=n,c_e().indexOf(e)===c_e().length-1&&QEe(a.enabled))&&(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Ha((()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)})))}));const o=e=>{t=h_e(e),i=null,r=null},s=e=>{const n=e.target,t=QEe(a.element),i=m_e(e),r=Math.abs(i[0])>Math.abs(i[1])?"x":"y",o=p_e(n,r,"x"===r?i[0]:i[1],t);let s;s=!t||!g_e(t,n)||!o,s&&e.cancelable&&e.preventDefault()},l=e=>{const n=QEe(a.element),o=e.target;let s;if(2===e.touches.length)s=!QEe(a.allowPinchZoom);else{if(null==i||null===r){const a=h_e(e).map(((e,a)=>t[a]-e)),n=Math.abs(a[0])>Math.abs(a[1])?"x":"y";i=n,r="x"===n?a[0]:a[1]}if("range"===o.type)s=!1;else{const e=p_e(o,i,r,n);s=!n||!g_e(n,o)||!e}}s&&e.cancelable&&e.preventDefault()}},f_e=v_e,y_e=Ja();function k_e(){return Ua(y_e)}function b_e(){const e=k_e();if(void 0===e)throw new Error("[kobalte]: `useMenuContext` must be used within a `Menu` component");return e}var S_e=Ja();function A_e(){const e=Ua(S_e);if(void 0===e)throw new Error("[kobalte]: `useMenuItemContext` must be used within a `Menu.Item` component");return e}var w_e=Ja();function C_e(){const e=Ua(w_e);if(void 0===e)throw new Error("[kobalte]: `useMenuRootContext` must be used within a `MenuRoot` component");return e}function M_e(e){let a;const n=C_e(),t=b_e(),i=aEe({id:n.generateId(`item-${Sn()}`)},e),[r,o]=yn(i,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[s,l]=Pa(),[u,c]=Pa(),[d,m]=Pa(),h=()=>t.listState().selectionManager(),p=()=>o.id,g=()=>{r.onSelect?.(),r.closeOnSelect&&setTimeout((()=>{t.close(!0)}))};NEe({getItem:()=>({ref:()=>a,type:"item",key:p(),textValue:r.textValue??d()?.textContent??a?.textContent??"",disabled:r.disabled??!1})});const v=qEe({key:p,selectionManager:h,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),f=e=>{OTe(e,r.onPointerMove),"mouse"===e.pointerType&&(r.disabled?t.onItemLeave(e):(t.onItemEnter(e),e.defaultPrevented||(GTe(e.currentTarget),t.listState().selectionManager().setFocused(!0),t.listState().selectionManager().setFocusedKey(p()))))},y=e=>{OTe(e,r.onPointerLeave),"mouse"===e.pointerType&&t.onItemLeave(e)},k=e=>{OTe(e,r.onPointerUp),r.disabled||0!==e.button||g()},b=e=>{if(OTe(e,r.onKeyDown),!e.repeat&&!r.disabled)switch(e.key){case"Enter":case" ":g()}},S=Ra((()=>r.indeterminate?"mixed":null!=r.checked?r.checked:void 0)),A=Ra((()=>({"data-indeterminate":r.indeterminate?"":void 0,"data-checked":r.checked&&!r.indeterminate?"":void 0,"data-disabled":r.disabled?"":void 0,"data-highlighted":h().focusedKey()===p()?"":void 0}))),w={isChecked:()=>r.checked,dataset:A,setLabelRef:m,generateId:_Te((()=>o.id)),registerLabel:lEe(l),registerDescription:lEe(c)};return mn(S_e.Provider,{value:w,get children(){return mn(dEe,fn({as:"div",ref(e){const n=mTe((e=>a=e),r.ref);"function"==typeof n&&n(e)},get tabIndex(){return v.tabIndex()},get"aria-checked"(){return S()},get"aria-disabled"(){return r.disabled},get"aria-labelledby"(){return s()},get"aria-describedby"(){return u()},get"data-key"(){return v.dataKey()},get onPointerDown(){return HTe([r.onPointerDown,v.onPointerDown])},get onPointerUp(){return HTe([k,v.onPointerUp])},get onClick(){return HTe([r.onClick,v.onClick])},get onKeyDown(){return HTe([b,v.onKeyDown])},get onMouseDown(){return HTe([r.onMouseDown,v.onMouseDown])},get onFocus(){return HTe([r.onFocus,v.onFocus])},onPointerMove:f,onPointerLeave:y},A,o))}})}function T_e(e){const a=aEe({closeOnSelect:!1},e),[n,t]=yn(a,["checked","defaultChecked","onChange","onSelect"]),i=function(e={}){const[a,n]=bEe({value:()=>kMe(e.isSelected),defaultValue:()=>!!kMe(e.defaultIsSelected),onChange:a=>e.onSelectedChange?.(a)});return{isSelected:a,setIsSelected:a=>{kMe(e.isReadOnly)||kMe(e.isDisabled)||n(a)},toggle:()=>{kMe(e.isReadOnly)||kMe(e.isDisabled)||n(!a())}}}({isSelected:()=>n.checked,defaultIsSelected:()=>n.defaultChecked,onSelectedChange:e=>n.onChange?.(e),isDisabled:()=>t.disabled});return mn(M_e,fn({role:"menuitemcheckbox",get checked(){return i.isSelected()},onSelect:()=>{n.onSelect?.(),i.toggle()}},t))}var E_e=Ja();function x_e(){return Ua(E_e)}var N_e={next:(e,a)=>"ltr"===e?"horizontal"===a?"ArrowRight":"ArrowDown":"horizontal"===a?"ArrowLeft":"ArrowUp",previous:(e,a)=>N_e.next("ltr"===e?"rtl":"ltr",a)},__e=e=>"horizontal"===e?"ArrowDown":"ArrowRight",P_e=e=>"horizontal"===e?"ArrowUp":"ArrowLeft";function L_e(e){const a=C_e(),n=b_e(),t=x_e(),{direction:i}=HEe(),r=aEe({id:a.generateId("trigger")},e),[o,s]=yn(r,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let l=()=>a.value();void 0!==t&&(l=()=>a.value()??o.id,void 0===t.lastValue()&&t.setLastValue(l));const u=uEe((()=>n.triggerRef()),(()=>"button")),c=Ra((()=>"a"===u()&&null!=n.triggerRef()?.getAttribute("href")));Ba(Ka((()=>t?.value()),(e=>{c()&&e===l()&&n.triggerRef()?.focus()})));const d=()=>{void 0!==t?n.isOpen()?t.value()===l()&&t.closeMenu():(t.autoFocusMenu()||t.setAutoFocusMenu(!0),n.open(!1)):n.toggle(!0)};return Ba((()=>Ha(n.registerTriggerId(o.id)))),mn(uxe,fn({ref(e){const a=mTe(n.setTriggerRef,o.ref);"function"==typeof a&&a(e)},get"data-kb-menu-value-trigger"(){return a.value()},get id(){return o.id},get disabled(){return o.disabled},"aria-haspopup":"true",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return Ra((()=>!!n.isOpen()))()?n.contentId():void 0},get"data-highlighted"(){return void 0!==l()&&t?.value()===l()||void 0},get tabIndex(){return void 0!==t?t.value()===l()||t.lastValue()===l()?0:-1:void 0},onPointerDown:e=>{OTe(e,o.onPointerDown),e.currentTarget.dataset.pointerType=e.pointerType,o.disabled||"touch"===e.pointerType||0!==e.button||d()},onMouseOver:e=>{OTe(e,o.onMouseOver),"touch"!==n.triggerRef()?.dataset.pointerType&&(o.disabled||void 0===t||void 0===t.value()||t.setValue(l))},onClick:e=>{OTe(e,o.onClick),o.disabled||"touch"===e.currentTarget.dataset.pointerType&&d()},onKeyDown:e=>{if(OTe(e,o.onKeyDown),!o.disabled){if(c())switch(e.key){case"Enter":case" ":return}switch(e.key){case"Enter":case" ":case __e(a.orientation()):e.stopPropagation(),e.preventDefault(),function(e){if(document.contains(e)){const a=document.scrollingElement||document.documentElement;if("hidden"===window.getComputedStyle(a).overflow){let n=QTe(e);for(;e&&n&&e!==a&&n!==a;)rEe(n,e),n=QTe(e=n)}else{const{left:a,top:n}=e.getBoundingClientRect();e?.scrollIntoView?.({block:"nearest"});const{left:t,top:i}=e.getBoundingClientRect();(Math.abs(a-t)>1||Math.abs(n-i)>1)&&e.scrollIntoView?.({block:"nearest"})}}}(e.currentTarget),n.open("first"),t?.setAutoFocusMenu(!0),t?.setValue(l);break;case P_e(a.orientation()):e.stopPropagation(),e.preventDefault(),n.open("last");break;case N_e.next(i(),a.orientation()):if(void 0===t)break;e.stopPropagation(),e.preventDefault(),t.nextMenu();break;case N_e.previous(i(),a.orientation()):if(void 0===t)break;e.stopPropagation(),e.preventDefault(),t.previousMenu()}}},onFocus:e=>{OTe(e,o.onFocus),void 0!==t&&"touch"!==e.currentTarget.dataset.pointerType&&t.setValue(l)},role:void 0!==t?"menuitem":void 0},(()=>n.dataset()),s))}var j_e=Ja();function B_e(){return Ua(j_e)}function R_e(e){let a;const n=C_e(),t=b_e(),i=x_e(),r=B_e(),{direction:o}=HEe(),s=aEe({id:n.generateId(`content-${Sn()}`)},e),[l,u]=yn(s,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let c=0;const d=()=>null==t.parentMenuContext()&&void 0===i&&n.isModal(),m=$Ne({selectionManager:t.listState().selectionManager,collection:t.listState().collection,autoFocus:t.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!t.listState().selectionManager().isFocused(),orientation:()=>"horizontal"===n.orientation()?"vertical":"horizontal"},(()=>a));a_e({trapFocus:()=>d()&&t.isOpen(),onMountAutoFocus:e=>{void 0===i&&l.onOpenAutoFocus?.(e)},onUnmountAutoFocus:l.onCloseAutoFocus},(()=>a));const h=e=>{l.onEscapeKeyDown?.(e),i?.setAutoFocusMenu(!1),t.close(!0)},p=e=>{l.onFocusOutside?.(e),n.isModal()&&e.preventDefault()};Ba((()=>Ha(t.registerContentId(l.id))));const g={ref:mTe((e=>{t.setContentRef(e),a=e}),l.ref),role:"menu",get id(){return l.id},get tabIndex(){return m.tabIndex()},get"aria-labelledby"(){return t.triggerId()},onKeyDown:HTe([l.onKeyDown,m.onKeyDown,e=>{if(PTe(e.currentTarget,e.target)&&("Tab"===e.key&&t.isOpen()&&e.preventDefault(),void 0!==i&&"true"!==e.currentTarget.getAttribute("aria-haspopup")))switch(e.key){case N_e.next(o(),n.orientation()):e.stopPropagation(),e.preventDefault(),t.close(!0),i.setAutoFocusMenu(!0),i.nextMenu();break;case N_e.previous(o(),n.orientation()):if(e.currentTarget.hasAttribute("data-closed"))break;e.stopPropagation(),e.preventDefault(),t.close(!0),i.setAutoFocusMenu(!0),i.previousMenu()}}]),onMouseDown:HTe([l.onMouseDown,m.onMouseDown]),onFocusIn:HTe([l.onFocusIn,m.onFocusIn]),onFocusOut:HTe([l.onFocusOut,m.onFocusOut]),onPointerEnter:e=>{OTe(e,l.onPointerEnter),t.isOpen()&&(t.parentMenuContext()?.listState().selectionManager().setFocused(!1),t.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},onPointerMove:e=>{if(OTe(e,l.onPointerMove),"mouse"!==e.pointerType)return;const a=c!==e.clientX;PTe(e.currentTarget,e.target)&&a&&(t.setPointerDir(e.clientX>c?"right":"left"),c=e.clientX)},get"data-orientation"(){return n.orientation()}};return mn(Mn,{get when(){return t.contentPresent()},get children(){return mn(Mn,{get when(){return void 0===r||null!=t.parentMenuContext()},get fallback(){return mn(dEe,fn({as:"div"},(()=>t.dataset()),g,u))},get children(){return mn(NNe.Positioner,{get children(){return mn(jNe,fn({get disableOutsidePointerEvents(){return Ra((()=>!!d()))()&&t.isOpen()},get excludedElements(){return[t.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return ETe({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},l.style)},onEscapeKeyDown:h,onFocusOutside:p,get onDismiss(){return t.close}},(()=>t.dataset()),g,u))}})}})}})}function z_e(e){let a;const n=C_e(),t=b_e(),[i,r]=yn(e,["ref"]);return f_e({element:()=>a??null,enabled:()=>t.contentPresent()&&n.preventScroll()}),mn(R_e,fn({ref(e){const n=mTe((e=>{a=e}),i.ref);"function"==typeof n&&n(e)}},r))}var D_e=Ja();function K_e(e){const a=aEe({id:C_e().generateId(`group-${Sn()}`)},e),[n,t]=Pa(),i={generateId:_Te((()=>a.id)),registerLabelId:lEe(t)};return mn(D_e.Provider,{value:i,get children(){return mn(dEe,fn({as:"div",role:"group",get"aria-labelledby"(){return n()}},a))}})}function O_e(e){const a=function(){const e=Ua(D_e);if(void 0===e)throw new Error("[kobalte]: `useMenuGroupContext` must be used within a `Menu.Group` component");return e}(),n=aEe({id:a.generateId("label")},e),[t,i]=yn(n,["id"]);return Ba((()=>Ha(a.registerLabelId(t.id)))),mn(dEe,fn({as:"span",get id(){return t.id},"aria-hidden":"true"},i))}function H_e(e){const a=b_e();return mn(dEe,fn({as:"span","aria-hidden":"true"},(()=>a.dataset()),aEe({children:"▼"},e)))}function I_e(e){return mn(M_e,fn({role:"menuitem",closeOnSelect:!0},e))}function G_e(e){const a=A_e(),n=aEe({id:a.generateId("description")},e),[t,i]=yn(n,["id"]);return Ba((()=>Ha(a.registerDescription(t.id)))),mn(dEe,fn({as:"div",get id(){return t.id}},(()=>a.dataset()),i))}function F_e(e){const a=A_e(),n=aEe({id:a.generateId("indicator")},e),[t,i]=yn(n,["forceMount"]);return mn(Mn,{get when(){return t.forceMount||a.isChecked()},get children(){return mn(dEe,fn({as:"div"},(()=>a.dataset()),i))}})}function V_e(e){const a=A_e(),n=aEe({id:a.generateId("label")},e),[t,i]=yn(n,["ref","id"]);return Ba((()=>Ha(a.registerLabel(t.id)))),mn(dEe,fn({as:"div",ref(e){const n=mTe(a.setLabelRef,t.ref);"function"==typeof n&&n(e)},get id(){return t.id}},(()=>a.dataset()),i))}function J_e(e){const a=b_e();return mn(Mn,{get when(){return a.contentPresent()},get children(){return mn(at,e)}})}var U_e=Ja();function W_e(e){const a=aEe({id:C_e().generateId(`radiogroup-${Sn()}`)},e),[n,t]=yn(a,["value","defaultValue","onChange","disabled"]),[i,r]=kEe({value:()=>n.value,defaultValue:()=>n.defaultValue,onChange:e=>n.onChange?.(e)});return mn(U_e.Provider,{value:{isDisabled:()=>n.disabled,isSelectedValue:e=>e===i(),setSelectedValue:r},get children(){return mn(K_e,t)}})}function q_e(e){const a=function(){const e=Ua(U_e);if(void 0===e)throw new Error("[kobalte]: `useMenuRadioGroupContext` must be used within a `Menu.RadioGroup` component");return e}(),n=aEe({closeOnSelect:!1},e),[t,i]=yn(n,["value","onSelect"]);return mn(M_e,fn({role:"menuitemradio",get checked(){return a.isSelectedValue(t.value)},onSelect:()=>{t.onSelect?.(),a.setSelectedValue(t.value)}},i))}function Z_e(e,a,n){const t=e.split("-")[0],i=n.getBoundingClientRect(),r=[],o=a.clientX,s=a.clientY;switch(t){case"top":r.push([o,s+5]),r.push([i.left,i.bottom]),r.push([i.left,i.top]),r.push([i.right,i.top]),r.push([i.right,i.bottom]);break;case"right":r.push([o-5,s]),r.push([i.left,i.top]),r.push([i.right,i.top]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]);break;case"bottom":r.push([o,s-5]),r.push([i.right,i.top]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]),r.push([i.left,i.top]);break;case"left":r.push([o+5,s]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]),r.push([i.left,i.top]),r.push([i.right,i.top])}return r}function $_e(e){const a=C_e(),n=CEe(),t=k_e(),i=x_e(),r=B_e(),o=aEe({placement:"horizontal"===a.orientation()?"bottom-start":"right-start"},e),[s,l]=yn(o,["open","defaultOpen","onOpenChange"]);let u=0,c=null,d="right";const[m,h]=Pa(),[p,g]=Pa(),[v,f]=Pa(),[y,k]=Pa(),[b,S]=Pa(!0),[A,w]=Pa(l.placement),[C,M]=Pa([]),[T,E]=Pa([]),{DomCollectionProvider:x}=xEe({items:T,onItemsChange:E}),N=BNe({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:e=>s.onOpenChange?.(e)}),{present:_}=XEe({show:()=>a.forceMount()||N.isOpen(),element:()=>y()??null}),P=function(e){const a=UEe(e),n=PEe({dataSource:()=>kMe(e.dataSource),getKey:()=>kMe(e.getKey),getTextValue:()=>kMe(e.getTextValue),getDisabled:()=>kMe(e.getDisabled),getSectionChildren:()=>kMe(e.getSectionChildren),factory:a=>new $Ee(e.filter?e.filter(a):a)},[()=>e.filter]),t=new ZEe(n,a);return La((()=>{const e=a.focusedKey();null==e||n().getItem(e)||a.setFocusedKey(void 0)})),{collection:n,selectionManager:()=>t}}({selectionMode:"none",dataSource:T}),L=e=>{S(e),N.open()},j=(e=!1)=>{N.close(),e&&t&&t.close(!0)},B=()=>{const e=y();e&&(GTe(e),P.selectionManager().setFocused(!0),P.selectionManager().setFocusedKey(void 0))},R=()=>{null!=r?setTimeout((()=>B())):B()},z=e=>{return d===c?.side&&(a=e,n=c?.area,!!n&&function(e,a){const[n,t]=e;let i=!1;for(let r=a.length,o=0,s=r-1;o<r;s=o++){const[e,l]=a[o],[u,c]=a[s],[,d]=a[0===s?r-1:s-1]||[0,0],m=(l-c)*(n-e)-(e-u)*(t-l);if(c<l){if(t>=c&&t<l){if(0===m)return!0;m>0&&(t===c?t>d&&(i=!i):i=!i)}}else if(l<c){if(t>l&&t<=c){if(0===m)return!0;m<0&&(t===c?t<d&&(i=!i):i=!i)}}else if(t==l&&(n>=u&&n<=e||n>=e&&n<=u))return!0}return i}([a.clientX,a.clientY],n));var a,n};t_e({isDisabled:()=>!(null==t&&N.isOpen()&&a.isModal()),targets:()=>[y(),...C()].filter(Boolean)}),Ba((()=>{const e=y();if(!e||!t)return;const a=t.registerNestedMenu(e);Ha((()=>{a()}))})),Ba((()=>{void 0===t&&i?.registerMenu(a.value(),[y(),...C()])})),Ba((()=>{void 0===t&&void 0!==i&&(i.value()===a.value()?(v()?.focus(),i.autoFocusMenu()&&L(!0)):j())})),Ba((()=>{void 0===t&&void 0!==i&&N.isOpen()&&i.setValue(a.value())})),Ha((()=>{void 0===t&&i?.unregisterMenu(a.value())}));const D={dataset:Ra((()=>({"data-expanded":N.isOpen()?"":void 0,"data-closed":N.isOpen()?void 0:""}))),isOpen:N.isOpen,contentPresent:_,nestedMenus:C,currentPlacement:A,pointerGraceTimeoutId:()=>u,autoFocus:b,listState:()=>P,parentMenuContext:()=>t,triggerRef:v,contentRef:y,triggerId:m,contentId:p,setTriggerRef:f,setContentRef:k,open:L,close:j,toggle:e=>{S(e),N.toggle()},focusContent:R,onItemEnter:e=>{z(e)&&e.preventDefault()},onItemLeave:e=>{z(e)||R()},onTriggerLeave:e=>{z(e)&&e.preventDefault()},setPointerDir:e=>d=e,setPointerGraceTimeoutId:e=>u=e,setPointerGraceIntent:e=>c=e,registerNestedMenu:e=>{M((a=>[...a,e]));const a=t?.registerNestedMenu(e);return()=>{M((a=>xTe(a,e))),a?.()}},registerItemToParentDomCollection:n?.registerItem,registerTriggerId:lEe(h),registerContentId:lEe(g)};return mn(x,{get children(){return mn(y_e.Provider,{value:D,get children(){return mn(Mn,{when:void 0===r,get fallback(){return l.children},get children(){return mn(NNe,fn({anchorRef:v,contentRef:y,onCurrentPlacementChange:w},l))}})}})}})}function Y_e(e){const{direction:a}=HEe();return mn($_e,fn({get placement(){return"rtl"===a()?"left-start":"right-start"},flip:!0},e))}var Q_e=(e,a)=>"ltr"===e?["horizontal"===a?"ArrowLeft":"ArrowUp"]:["horizontal"===a?"ArrowRight":"ArrowDown"];function X_e(e){const a=b_e(),n=C_e(),[t,i]=yn(e,["onFocusOutside","onKeyDown"]),{direction:r}=HEe();return mn(R_e,fn({onOpenAutoFocus:e=>{e.preventDefault()},onCloseAutoFocus:e=>{e.preventDefault()},onFocusOutside:e=>{t.onFocusOutside?.(e);const n=e.target;PTe(a.triggerRef(),n)||a.close()},onKeyDown:e=>{OTe(e,t.onKeyDown);const i=PTe(e.currentTarget,e.target),o=Q_e(r(),n.orientation()).includes(e.key),s=null!=a.parentMenuContext();i&&o&&s&&(a.close(),GTe(a.triggerRef()))}},i))}var ePe=["Enter"," "],aPe=(e,a)=>"ltr"===e?[...ePe,"horizontal"===a?"ArrowRight":"ArrowDown"]:[...ePe,"horizontal"===a?"ArrowLeft":"ArrowUp"];function nPe(e){let a;const n=C_e(),t=b_e(),i=aEe({id:n.generateId(`sub-trigger-${Sn()}`)},e),[r,o]=yn(i,["ref","id","textValue","disabled","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]);let s=null;const l=()=>{s&&window.clearTimeout(s),s=null},{direction:u}=HEe(),c=()=>r.id,d=()=>{const e=t.parentMenuContext();if(null==e)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");return e.listState().selectionManager()},m=qEe({key:c,selectionManager:d,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),h=e=>{OTe(e,r.onClick),t.isOpen()||r.disabled||t.open(!0)},p=e=>{OTe(e,r.onKeyDown),e.repeat||r.disabled||aPe(u(),n.orientation()).includes(e.key)&&(e.stopPropagation(),e.preventDefault(),d().setFocused(!1),d().setFocusedKey(void 0),t.isOpen()||t.open("first"),t.focusContent(),t.listState().selectionManager().setFocused(!0),t.listState().selectionManager().setFocusedKey(t.listState().collection().getFirstKey()))};return Ba((()=>{if(null==t.registerItemToParentDomCollection)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");Ha(t.registerItemToParentDomCollection({ref:()=>a,type:"item",key:c(),textValue:r.textValue??a?.textContent??"",disabled:r.disabled??!1}))})),Ba(Ka((()=>t.parentMenuContext()?.pointerGraceTimeoutId()),(e=>{Ha((()=>{window.clearTimeout(e),t.parentMenuContext()?.setPointerGraceIntent(null)}))}))),Ba((()=>Ha(t.registerTriggerId(r.id)))),Ha((()=>{l()})),mn(dEe,fn({as:"div",ref(e){const n=mTe((e=>{t.setTriggerRef(e),a=e}),r.ref);"function"==typeof n&&n(e)},get id(){return r.id},role:"menuitem",get tabIndex(){return m.tabIndex()},"aria-haspopup":"true",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return Ra((()=>!!t.isOpen()))()?t.contentId():void 0},get"aria-disabled"(){return r.disabled},get"data-key"(){return m.dataKey()},get"data-highlighted"(){return d().focusedKey()===c()?"":void 0},get"data-disabled"(){return r.disabled?"":void 0},get onPointerDown(){return HTe([r.onPointerDown,m.onPointerDown])},get onPointerUp(){return HTe([r.onPointerUp,m.onPointerUp])},get onClick(){return HTe([h,m.onClick])},get onKeyDown(){return HTe([p,m.onKeyDown])},get onMouseDown(){return HTe([r.onMouseDown,m.onMouseDown])},get onFocus(){return HTe([r.onFocus,m.onFocus])},onPointerMove:e=>{if(OTe(e,r.onPointerMove),"mouse"!==e.pointerType)return;const a=t.parentMenuContext();a?.onItemEnter(e),e.defaultPrevented||(r.disabled?a?.onItemLeave(e):(t.isOpen()||s||(t.parentMenuContext()?.setPointerGraceIntent(null),s=window.setTimeout((()=>{t.open(!1),l()}),100)),a?.onItemEnter(e),e.defaultPrevented||(t.listState().selectionManager().isFocused()&&(t.listState().selectionManager().setFocused(!1),t.listState().selectionManager().setFocusedKey(void 0)),GTe(e.currentTarget),a?.listState().selectionManager().setFocused(!0),a?.listState().selectionManager().setFocusedKey(c()))))},onPointerLeave:e=>{if(OTe(e,r.onPointerLeave),"mouse"!==e.pointerType)return;l();const a=t.parentMenuContext(),n=t.contentRef();if(n){a?.setPointerGraceIntent({area:Z_e(t.currentPlacement(),e,n),side:t.currentPlacement().split("-")[0]}),window.clearTimeout(a?.pointerGraceTimeoutId());const i=window.setTimeout((()=>{a?.setPointerGraceIntent(null)}),300);a?.setPointerGraceTimeoutId(i)}else{if(a?.onTriggerLeave(e),e.defaultPrevented)return;a?.setPointerGraceIntent(null)}a?.onItemLeave(e)}},(()=>t.dataset()),o))}function tPe(e){const a=x_e(),n=aEe({id:`menu-${Sn()}`,modal:!0},e),[t,i]=yn(n,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value","orientation"]),r=BNe({open:()=>t.open,defaultOpen:()=>t.defaultOpen,onOpenChange:e=>t.onOpenChange?.(e)}),o={isModal:()=>t.modal??!0,preventScroll:()=>t.preventScroll??o.isModal(),forceMount:()=>t.forceMount??!1,generateId:_Te((()=>t.id)),value:()=>t.value,orientation:()=>t.orientation??a?.orientation()??"horizontal"};return mn(w_e.Provider,{value:o,get children(){return mn($_e,fn({get open(){return r.isOpen()},get onOpenChange(){return r.setIsOpen}},i))}})}function iPe(e){let a;const n=aEe({orientation:"horizontal"},e),[t,i]=yn(n,["ref","orientation"]),r=uEe((()=>a),(()=>"hr"));return mn(dEe,fn({as:"hr",ref(e){const n=mTe((e=>a=e),t.ref);"function"==typeof n&&n(e)},get role(){return"hr"!==r()?"separator":void 0},get"aria-orientation"(){return"vertical"===t.orientation?"vertical":void 0},get"data-orientation"(){return t.orientation}},i))}AEe({},{Root:()=>iPe,Separator:()=>rPe});var rPe=iPe,oPe={};function sPe(e){const a=C_e(),n=b_e(),[t,i]=yn(e,["onCloseAutoFocus","onInteractOutside"]);let r=!1;return mn(z_e,fn({onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),r||GTe(n.triggerRef()),r=!1,e.preventDefault()},onInteractOutside:e=>{t.onInteractOutside?.(e),a.isModal()&&!e.detail.isContextMenu||(r=!0)}},i))}function lPe(e){return mn(tPe,aEe({id:`dropdownmenu-${Sn()}`},e))}AEe(oPe,{Arrow:()=>MNe,CheckboxItem:()=>T_e,Content:()=>sPe,DropdownMenu:()=>uPe,Group:()=>K_e,GroupLabel:()=>O_e,Icon:()=>H_e,Item:()=>I_e,ItemDescription:()=>G_e,ItemIndicator:()=>F_e,ItemLabel:()=>V_e,Portal:()=>J_e,RadioGroup:()=>W_e,RadioItem:()=>q_e,Root:()=>lPe,Separator:()=>iPe,Sub:()=>Y_e,SubContent:()=>X_e,SubTrigger:()=>nPe,Trigger:()=>L_e});var uPe=Object.assign(lPe,{Arrow:MNe,CheckboxItem:T_e,Content:sPe,Group:K_e,GroupLabel:O_e,Icon:H_e,Item:I_e,ItemDescription:G_e,ItemIndicator:F_e,ItemLabel:V_e,Portal:J_e,RadioGroup:W_e,RadioItem:q_e,Separator:iPe,Sub:Y_e,SubContent:X_e,SubTrigger:nPe,Trigger:L_e}),cPe={colors:{inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000000",white:"#ffffff",neutral:{50:"#f9fafb",100:"#f2f4f7",200:"#eaecf0",300:"#d0d5dd",400:"#98a2b3",500:"#667085",600:"#475467",700:"#344054",800:"#1d2939",900:"#101828"},darkGray:{50:"#525c7a",100:"#49536e",200:"#414962",300:"#394056",400:"#313749",500:"#292e3d",600:"#212530",700:"#191c24",800:"#111318",900:"#0b0d10"},gray:{50:"#f9fafb",100:"#f2f4f7",200:"#eaecf0",300:"#d0d5dd",400:"#98a2b3",500:"#667085",600:"#475467",700:"#344054",800:"#1d2939",900:"#101828"},blue:{25:"#F5FAFF",50:"#EFF8FF",100:"#D1E9FF",200:"#B2DDFF",300:"#84CAFF",400:"#53B1FD",500:"#2E90FA",600:"#1570EF",700:"#175CD3",800:"#1849A9",900:"#194185"},green:{25:"#F6FEF9",50:"#ECFDF3",100:"#D1FADF",200:"#A6F4C5",300:"#6CE9A6",400:"#32D583",500:"#12B76A",600:"#039855",700:"#027A48",800:"#05603A",900:"#054F31"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},yellow:{25:"#FFFCF5",50:"#FFFAEB",100:"#FEF0C7",200:"#FEDF89",300:"#FEC84B",400:"#FDB022",500:"#F79009",600:"#DC6803",700:"#B54708",800:"#93370D",900:"#7A2E0E"},purple:{25:"#FAFAFF",50:"#F4F3FF",100:"#EBE9FE",200:"#D9D6FE",300:"#BDB4FE",400:"#9B8AFB",500:"#7A5AF8",600:"#6938EF",700:"#5925DC",800:"#4A1FB8",900:"#3E1C96"},teal:{25:"#F6FEFC",50:"#F0FDF9",100:"#CCFBEF",200:"#99F6E0",300:"#5FE9D0",400:"#2ED3B7",500:"#15B79E",600:"#0E9384",700:"#107569",800:"#125D56",900:"#134E48"},pink:{25:"#fdf2f8",50:"#fce7f3",100:"#fbcfe8",200:"#f9a8d4",300:"#f472b6",400:"#ec4899",500:"#db2777",600:"#be185d",700:"#9d174d",800:"#831843",900:"#500724"},cyan:{25:"#ecfeff",50:"#cffafe",100:"#a5f3fc",200:"#67e8f9",300:"#22d3ee",400:"#06b6d4",500:"#0891b2",600:"#0e7490",700:"#155e75",800:"#164e63",900:"#083344"}},alpha:{90:"e5",80:"cc"},font:{size:{xs:"calc(var(--tsqd-font-size) * 0.75)",sm:"calc(var(--tsqd-font-size) * 0.875)",md:"var(--tsqd-font-size)"},lineHeight:{xs:"calc(var(--tsqd-font-size) * 1)",sm:"calc(var(--tsqd-font-size) * 1.25)",md:"calc(var(--tsqd-font-size) * 1.5)"},weight:{medium:"500",semibold:"600",bold:"700"}},border:{radius:{xs:"calc(var(--tsqd-font-size) * 0.125)",sm:"calc(var(--tsqd-font-size) * 0.25)",full:"9999px"}},size:{.25:"calc(var(--tsqd-font-size) * 0.0625)",.5:"calc(var(--tsqd-font-size) * 0.125)",1:"calc(var(--tsqd-font-size) * 0.25)",1.5:"calc(var(--tsqd-font-size) * 0.375)",2:"calc(var(--tsqd-font-size) * 0.5)",2.5:"calc(var(--tsqd-font-size) * 0.625)",3:"calc(var(--tsqd-font-size) * 0.75)",3.5:"calc(var(--tsqd-font-size) * 0.875)",4:"calc(var(--tsqd-font-size) * 1)",4.5:"calc(var(--tsqd-font-size) * 1.125)",5:"calc(var(--tsqd-font-size) * 1.25)",6:"calc(var(--tsqd-font-size) * 1.5)",6.5:"calc(var(--tsqd-font-size) * 1.625)",14:"calc(var(--tsqd-font-size) * 3.5)"},shadow:{xs:(e="rgb(0 0 0 / 0.1)")=>"0 1px 2px 0 rgb(0 0 0 / 0.05)",sm:(e="rgb(0 0 0 / 0.1)")=>`0 1px 3px 0 ${e}, 0 1px 2px -1px ${e}`,md:(e="rgb(0 0 0 / 0.1)")=>`0 4px 6px -1px ${e}, 0 2px 4px -2px ${e}`,lg:(e="rgb(0 0 0 / 0.1)")=>`0 10px 15px -3px ${e}, 0 4px 6px -4px ${e}`,xl:(e="rgb(0 0 0 / 0.1)")=>`0 20px 25px -5px ${e}, 0 8px 10px -6px ${e}`,"2xl":(e="rgb(0 0 0 / 0.25)")=>`0 25px 50px -12px ${e}`,inner:(e="rgb(0 0 0 / 0.05)")=>`inset 0 2px 4px 0 ${e}`,none:()=>"none"}},dPe=Dn('<svg width=14 height=14 viewBox="0 0 14 14"fill=none xmlns=http://www.w3.org/2000/svg><path d="M13 13L9.00007 9M10.3333 5.66667C10.3333 8.244 8.244 10.3333 5.66667 10.3333C3.08934 10.3333 1 8.244 1 5.66667C1 3.08934 3.08934 1 5.66667 1C8.244 1 10.3333 3.08934 10.3333 5.66667Z"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),mPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9 3H15M3 6H21M19 6L18.2987 16.5193C18.1935 18.0975 18.1409 18.8867 17.8 19.485C17.4999 20.0118 17.0472 20.4353 16.5017 20.6997C15.882 21 15.0911 21 13.5093 21H10.4907C8.90891 21 8.11803 21 7.49834 20.6997C6.95276 20.4353 6.50009 20.0118 6.19998 19.485C5.85911 18.8867 5.8065 18.0975 5.70129 16.5193L5 6M10 10.5V15.5M14 10.5V15.5"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),hPe=Dn('<svg width=10 height=6 viewBox="0 0 10 6"fill=none xmlns=http://www.w3.org/2000/svg><path d="M1 1L5 5L9 1"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),pPe=Dn('<svg width=12 height=12 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 13.3333V2.66667M8 2.66667L4 6.66667M8 2.66667L12 6.66667"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),gPe=Dn('<svg width=12 height=12 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 2.66667V13.3333M8 13.3333L4 9.33333M8 13.3333L12 9.33333"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),vPe=Dn('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M12 2v2m0 16v2M4 12H2m4.314-5.686L4.9 4.9m12.786 1.414L19.1 4.9M6.314 17.69 4.9 19.104m12.786-1.414 1.414 1.414M22 12h-2m-3 0a5 5 0 1 1-10 0 5 5 0 0 1 10 0Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),fPe=Dn('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M22 15.844a10.424 10.424 0 0 1-4.306.925c-5.779 0-10.463-4.684-10.463-10.462 0-1.536.33-2.994.925-4.307A10.464 10.464 0 0 0 2 11.538C2 17.316 6.684 22 12.462 22c4.243 0 7.896-2.526 9.538-6.156Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),yPe=Dn('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 21h8m-4-4v4m-5.2-4h10.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C22 14.72 22 13.88 22 12.2V7.8c0-1.68 0-2.52-.327-3.162a3 3 0 0 0-1.311-1.311C19.72 3 18.88 3 17.2 3H6.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C2 5.28 2 6.12 2 7.8v4.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C4.28 17 5.12 17 6.8 17Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),kPe=Dn('<svg stroke=currentColor fill=currentColor stroke-width=0 viewBox="0 0 24 24"height=1em width=1em xmlns=http://www.w3.org/2000/svg><path fill=none d="M0 0h24v24H0z"></path><path d="M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3a4.237 4.237 0 00-6 0zm-4-4l2 2a7.074 7.074 0 0110 0l2-2C15.14 9.14 8.87 9.14 5 13z">'),bPe=Dn('<svg stroke-width=0 viewBox="0 0 24 24"height=1em width=1em xmlns=http://www.w3.org/2000/svg><path fill=none d="M24 .01c0-.01 0-.01 0 0L0 0v24h24V.01zM0 0h24v24H0V0zm0 0h24v24H0V0z"></path><path d="M22.99 9C19.15 5.16 13.8 3.76 8.84 4.78l2.52 2.52c3.47-.17 6.99 1.05 9.63 3.7l2-2zm-4 4a9.793 9.793 0 00-4.49-2.56l3.53 3.53.96-.97zM2 3.05L5.07 6.1C3.6 6.82 2.22 7.78 1 9l1.99 2c1.24-1.24 2.67-2.16 4.2-2.77l2.24 2.24A9.684 9.684 0 005 13v.01L6.99 15a7.042 7.042 0 014.92-2.06L18.98 20l1.27-1.26L3.29 1.79 2 3.05zM9 17l3 3 3-3a4.237 4.237 0 00-6 0z">'),SPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9.3951 19.3711L9.97955 20.6856C10.1533 21.0768 10.4368 21.4093 10.7958 21.6426C11.1547 21.8759 11.5737 22.0001 12.0018 22C12.4299 22.0001 12.8488 21.8759 13.2078 21.6426C13.5667 21.4093 13.8503 21.0768 14.024 20.6856L14.6084 19.3711C14.8165 18.9047 15.1664 18.5159 15.6084 18.26C16.0532 18.0034 16.5678 17.8941 17.0784 17.9478L18.5084 18.1C18.9341 18.145 19.3637 18.0656 19.7451 17.8713C20.1265 17.6771 20.4434 17.3763 20.6573 17.0056C20.8715 16.635 20.9735 16.2103 20.9511 15.7829C20.9286 15.3555 20.7825 14.9438 20.5307 14.5978L19.684 13.4344C19.3825 13.0171 19.2214 12.5148 19.224 12C19.2239 11.4866 19.3865 10.9864 19.6884 10.5711L20.5351 9.40778C20.787 9.06175 20.933 8.65007 20.9555 8.22267C20.978 7.79528 20.8759 7.37054 20.6618 7C20.4479 6.62923 20.131 6.32849 19.7496 6.13423C19.3681 5.93997 18.9386 5.86053 18.5129 5.90556L17.0829 6.05778C16.5722 6.11141 16.0577 6.00212 15.6129 5.74556C15.17 5.48825 14.82 5.09736 14.6129 4.62889L14.024 3.31444C13.8503 2.92317 13.5667 2.59072 13.2078 2.3574C12.8488 2.12408 12.4299 1.99993 12.0018 2C11.5737 1.99993 11.1547 2.12408 10.7958 2.3574C10.4368 2.59072 10.1533 2.92317 9.97955 3.31444L9.3951 4.62889C9.18803 5.09736 8.83798 5.48825 8.3951 5.74556C7.95032 6.00212 7.43577 6.11141 6.9251 6.05778L5.49066 5.90556C5.06499 5.86053 4.6354 5.93997 4.25397 6.13423C3.87255 6.32849 3.55567 6.62923 3.34177 7C3.12759 7.37054 3.02555 7.79528 3.04804 8.22267C3.07052 8.65007 3.21656 9.06175 3.46844 9.40778L4.3151 10.5711C4.61704 10.9864 4.77964 11.4866 4.77955 12C4.77964 12.5134 4.61704 13.0137 4.3151 13.4289L3.46844 14.5922C3.21656 14.9382 3.07052 15.3499 3.04804 15.7773C3.02555 16.2047 3.12759 16.6295 3.34177 17C3.55589 17.3706 3.8728 17.6712 4.25417 17.8654C4.63554 18.0596 5.06502 18.1392 5.49066 18.0944L6.92066 17.9422C7.43133 17.8886 7.94587 17.9979 8.39066 18.2544C8.83519 18.511 9.18687 18.902 9.3951 19.3711Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path><path d="M12 15C13.6568 15 15 13.6569 15 12C15 10.3431 13.6568 9 12 9C10.3431 9 8.99998 10.3431 8.99998 12C8.99998 13.6569 10.3431 15 12 15Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),APe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M16 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V8M11.5 12.5L17 7M17 7H12M17 7V12M6.2 21H8.8C9.9201 21 10.4802 21 10.908 20.782C11.2843 20.5903 11.5903 20.2843 11.782 19.908C12 19.4802 12 18.9201 12 17.8V15.2C12 14.0799 12 13.5198 11.782 13.092C11.5903 12.7157 11.2843 12.4097 10.908 12.218C10.4802 12 9.92011 12 8.8 12H6.2C5.0799 12 4.51984 12 4.09202 12.218C3.71569 12.4097 3.40973 12.7157 3.21799 13.092C3 13.5198 3 14.0799 3 15.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),wPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path class=copier d="M8 8V5.2C8 4.0799 8 3.51984 8.21799 3.09202C8.40973 2.71569 8.71569 2.40973 9.09202 2.21799C9.51984 2 10.0799 2 11.2 2H18.8C19.9201 2 20.4802 2 20.908 2.21799C21.2843 2.40973 21.5903 2.71569 21.782 3.09202C22 3.51984 22 4.0799 22 5.2V12.8C22 13.9201 22 14.4802 21.782 14.908C21.5903 15.2843 21.2843 15.5903 20.908 15.782C20.4802 16 19.9201 16 18.8 16H16M5.2 22H12.8C13.9201 22 14.4802 22 14.908 21.782C15.2843 21.5903 15.5903 21.2843 15.782 20.908C16 20.4802 16 19.9201 16 18.8V11.2C16 10.0799 16 9.51984 15.782 9.09202C15.5903 8.71569 15.2843 8.40973 14.908 8.21799C14.4802 8 13.9201 8 12.8 8H5.2C4.0799 8 3.51984 8 3.09202 8.21799C2.71569 8.40973 2.40973 8.71569 2.21799 9.09202C2 9.51984 2 10.0799 2 11.2V18.8C2 19.9201 2 20.4802 2.21799 20.908C2.40973 21.2843 2.71569 21.5903 3.09202 21.782C3.51984 22 4.07989 22 5.2 22Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round stroke=currentColor>'),CPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M2.5 21.4998L8.04927 19.3655C8.40421 19.229 8.58168 19.1607 8.74772 19.0716C8.8952 18.9924 9.0358 18.901 9.16804 18.7984C9.31692 18.6829 9.45137 18.5484 9.72028 18.2795L21 6.99982C22.1046 5.89525 22.1046 4.10438 21 2.99981C19.8955 1.89525 18.1046 1.89524 17 2.99981L5.72028 14.2795C5.45138 14.5484 5.31692 14.6829 5.20139 14.8318C5.09877 14.964 5.0074 15.1046 4.92823 15.2521C4.83911 15.4181 4.77085 15.5956 4.63433 15.9506L2.5 21.4998ZM2.5 21.4998L4.55812 16.1488C4.7054 15.7659 4.77903 15.5744 4.90534 15.4867C5.01572 15.4101 5.1523 15.3811 5.2843 15.4063C5.43533 15.4351 5.58038 15.5802 5.87048 15.8703L8.12957 18.1294C8.41967 18.4195 8.56472 18.5645 8.59356 18.7155C8.61877 18.8475 8.58979 18.9841 8.51314 19.0945C8.42545 19.2208 8.23399 19.2944 7.85107 19.4417L2.5 21.4998Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),MPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M7.5 12L10.5 15L16.5 9M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),TPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9 9L15 15M15 9L9 15M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"stroke=#F04438 stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),EPe=Dn('<svg width=24 height=24 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 xmlns=http://www.w3.org/2000/svg><rect class=list width=20 height=20 y=2 x=2 rx=2></rect><line class=list-item y1=7 y2=7 x1=6 x2=18></line><line class=list-item y2=12 y1=12 x1=6 x2=18></line><line class=list-item y1=17 y2=17 x1=6 x2=18>'),xPe=Dn('<svg viewBox="0 0 24 24"height=20 width=20 fill=none xmlns=http://www.w3.org/2000/svg><path d="M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),NPe=Dn('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M7.5 12L10.5 15L16.5 9M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),_Pe=Dn('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M12 2V6M12 18V22M6 12H2M22 12H18M19.0784 19.0784L16.25 16.25M19.0784 4.99994L16.25 7.82837M4.92157 19.0784L7.75 16.25M4.92157 4.99994L7.75 7.82837"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path><animateTransform attributeName=transform attributeType=XML type=rotate from=0 to=360 dur=2s repeatCount=indefinite>'),PPe=Dn('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M15 9L9 15M9 9L15 15M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),LPe=Dn('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9.5 15V9M14.5 15V9M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),jPe=Dn('<svg version=1.0 viewBox="0 0 633 633"><linearGradient x1=-666.45 x2=-666.45 y1=163.28 y2=163.99 gradientTransform="matrix(633 0 0 633 422177 -103358)"gradientUnits=userSpaceOnUse><stop stop-color=#6BDAFF offset=0></stop><stop stop-color=#F9FFB5 offset=.32></stop><stop stop-color=#FFA770 offset=.71></stop><stop stop-color=#FF7373 offset=1></stop></linearGradient><circle cx=316.5 cy=316.5 r=316.5></circle><defs><filter x=-137.5 y=412 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=412 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=610.5 rx=214.5 ry=186 fill=#015064 stroke=#00CFE2 stroke-width=25></ellipse></g><defs><filter x=316.5 y=412 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=412 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=610.5 rx=214.5 ry=186 fill=#015064 stroke=#00CFE2 stroke-width=25></ellipse></g><defs><filter x=-137.5 y=450 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=450 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=648.5 rx=214.5 ry=186 fill=#015064 stroke=#00A8B8 stroke-width=25></ellipse></g><defs><filter x=316.5 y=450 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=450 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=648.5 rx=214.5 ry=186 fill=#015064 stroke=#00A8B8 stroke-width=25></ellipse></g><defs><filter x=-137.5 y=486 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=486 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=684.5 rx=214.5 ry=186 fill=#015064 stroke=#007782 stroke-width=25></ellipse></g><defs><filter x=316.5 y=486 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=486 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=684.5 rx=214.5 ry=186 fill=#015064 stroke=#007782 stroke-width=25></ellipse></g><defs><filter x=272.2 y=308 width=176.9 height=129.3 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=272.2 y=308 width=176.9 height=129.3 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><line x1=436 x2=431 y1=403.2 y2=431.8 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><line x1=291 x2=280 y1=341.5 y2=403.5 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><line x1=332.9 x2=328.6 y1=384.1 y2=411.2 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><linearGradient x1=-670.75 x2=-671.59 y1=164.4 y2=164.49 gradientTransform="matrix(-184.16 -32.472 -11.461 64.997 -121359 -32126)"gradientUnits=userSpaceOnUse><stop stop-color=#EE2700 offset=0></stop><stop stop-color=#FF008E offset=1></stop></linearGradient><path d="m344.1 363 97.7 17.2c5.8 2.1 8.2 6.1 7.1 12.1s-4.7 9.2-11 9.9l-106-18.7-57.5-59.2c-3.2-4.8-2.9-9.1 0.8-12.8s8.3-4.4 13.7-2.1l55.2 53.6z"clip-rule=evenodd fill-rule=evenodd></path><line x1=428.2 x2=429.1 y1=384.5 y2=378 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=395.2 x2=396.1 y1=379.5 y2=373 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=362.2 x2=363.1 y1=373.5 y2=367.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=324.2 x2=328.4 y1=351.3 y2=347.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=303.2 x2=307.4 y1=331.3 y2=327.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line></g><defs><filter x=73.2 y=113.8 width=280.6 height=317.4 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=73.2 y=113.8 width=280.6 height=317.4 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-672.16 x2=-672.16 y1=165.03 y2=166.03 gradientTransform="matrix(-100.18 48.861 97.976 200.88 -83342 -93.059)"gradientUnits=userSpaceOnUse><stop stop-color=#A17500 offset=0></stop><stop stop-color=#5D2100 offset=1></stop></linearGradient><path d="m192.3 203c8.1 37.3 14 73.6 17.8 109.1 3.8 35.4 2.8 75.1-3 119.2l61.2-16.7c-15.6-59-25.2-97.9-28.6-116.6s-10.8-51.9-22.1-99.6l-25.3 4.6"clip-rule=evenodd fill-rule=evenodd></path><g stroke=#2F8A00><linearGradient x1=-660.23 x2=-660.23 y1=166.72 y2=167.72 gradientTransform="matrix(92.683 4.8573 -2.0259 38.657 61680 -3088.6)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m195 183.9s-12.6-22.1-36.5-29.9c-15.9-5.2-34.4-1.5-55.5 11.1 15.9 14.3 29.5 22.6 40.7 24.9 16.8 3.6 51.3-6.1 51.3-6.1z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-661.36 x2=-661.36 y1=164.18 y2=165.18 gradientTransform="matrix(110 5.7648 -6.3599 121.35 73933 -15933)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5s-47.5-8.5-83.2 15.7c-23.8 16.2-34.3 49.3-31.6 99.4 30.3-27.8 52.1-48.5 65.2-61.9 19.8-20.2 49.6-53.2 49.6-53.2z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-656.79 x2=-656.79 y1=165.15 y2=166.15 gradientTransform="matrix(62.954 3.2993 -3.5023 66.828 42156 -8754.1)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m195 183.9c-0.8-21.9 6-38 20.6-48.2s29.8-15.4 45.5-15.3c-6.1 21.4-14.5 35.8-25.2 43.4s-24.4 14.2-40.9 20.1z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-663.07 x2=-663.07 y1=165.44 y2=166.44 gradientTransform="matrix(152.47 7.9907 -3.0936 59.029 101884 -4318.7)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c31.9-30 64.1-39.7 96.7-29s50.8 30.4 54.6 59.1c-35.2-5.5-60.4-9.6-75.8-12.1-15.3-2.6-40.5-8.6-75.5-18z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-662.57 x2=-662.57 y1=164.44 y2=165.44 gradientTransform="matrix(136.46 7.1517 -5.2163 99.533 91536 -11442)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c35.8-7.6 65.6-0.2 89.2 22s37.7 49 42.3 80.3c-39.8-9.7-68.3-23.8-85.5-42.4s-32.5-38.5-46-59.9z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-656.43 x2=-656.43 y1=163.86 y2=164.86 gradientTransform="matrix(60.866 3.1899 -8.7773 167.48 41560 -25168)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c-33.6 13.8-53.6 35.7-60.1 65.6s-3.6 63.1 8.7 99.6c27.4-40.3 43.2-69.6 47.4-88s5.6-44.1 4-77.2z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><path d="m196.5 182.3c-14.8 21.6-25.1 41.4-30.8 59.4s-9.5 33-11.1 45.1"fill=none stroke-linecap=round stroke-width=8></path><path d="m194.9 185.7c-24.4 1.7-43.8 9-58.1 21.8s-24.7 25.4-31.3 37.8"fill=none stroke-linecap=round stroke-width=8></path><path d="m204.5 176.4c29.7-6.7 52-8.4 67-5.1s26.9 8.6 35.8 15.9"fill=none stroke-linecap=round stroke-width=8></path><path d="m196.5 181.4c20.3 9.9 38.2 20.5 53.9 31.9s27.4 22.1 35.1 32"fill=none stroke-linecap=round stroke-width=8></path></g></g><defs><filter x=50.5 y=399 width=532 height=633 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=50.5 y=399 width=532 height=633 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-666.06 x2=-666.23 y1=163.36 y2=163.75 gradientTransform="matrix(532 0 0 633 354760 -102959)"gradientUnits=userSpaceOnUse><stop stop-color=#FFF400 offset=0></stop><stop stop-color=#3C8700 offset=1></stop></linearGradient><ellipse cx=316.5 cy=715.5 rx=266 ry=316.5></ellipse></g><defs><filter x=391 y=-24 width=288 height=283 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=391 y=-24 width=288 height=283 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-664.56 x2=-664.56 y1=163.79 y2=164.79 gradientTransform="matrix(227 0 0 227 151421 -37204)"gradientUnits=userSpaceOnUse><stop stop-color=#FFDF00 offset=0></stop><stop stop-color=#FF9D00 offset=1></stop></linearGradient><circle cx=565.5 cy=89.5 r=113.5></circle><linearGradient x1=-644.5 x2=-645.77 y1=342 y2=342 gradientTransform="matrix(30 0 0 1 19770 -253)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=427 x2=397 y1=89 y2=89 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-641.56 x2=-642.83 y1=196.02 y2=196.07 gradientTransform="matrix(26.5 0 0 5.5 17439 -1025.5)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=430.5 x2=404 y1=55.5 y2=50 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-643.73 x2=-645 y1=185.83 y2=185.9 gradientTransform="matrix(29 0 0 8 19107 -1361)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=431 x2=402 y1=122 y2=130 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-638.94 x2=-640.22 y1=177.09 y2=177.39 gradientTransform="matrix(24 0 0 13 15783 -2145)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=442 x2=418 y1=153 y2=166 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-633.42 x2=-634.7 y1=172.41 y2=173.31 gradientTransform="matrix(20 0 0 19 13137 -3096)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=464 x2=444 y1=180 y2=199 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-619.05 x2=-619.52 y1=170.82 y2=171.82 gradientTransform="matrix(13.83 0 0 22.85 9050 -3703.4)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=491.4 x2=477.5 y1=203 y2=225.9 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-578.5 x2=-578.63 y1=170.31 y2=171.31 gradientTransform="matrix(7.5 0 0 24.5 4860 -3953)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=524.5 x2=517 y1=219.5 y2=244 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=666.5 x2=666.5 y1=170.31 y2=171.31 gradientTransform="matrix(.5 0 0 24.5 231.5 -3944)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=564.5 x2=565 y1=228.5 y2=253 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12>');function BPe(){return dPe()}function RPe(){return mPe()}function zPe(){return hPe()}function DPe(){return pPe()}function KPe(){return gPe()}function OPe(){return(e=gPe()).style.setProperty("transform","rotate(90deg)"),e;var e}function HPe(){return(e=gPe()).style.setProperty("transform","rotate(-90deg)"),e;var e}function IPe(){return vPe()}function GPe(){return fPe()}function FPe(){return yPe()}function VPe(){return kPe()}function JPe(){return bPe()}function UPe(){return SPe()}function WPe(){return APe()}function qPe(){return wPe()}function ZPe(){return CPe()}function $Pe(e){return a=MPe(),n=a.firstChild,ja((()=>On(n,"stroke","dark"===e.theme?"#12B76A":"#027A48"))),a;var a,n}function YPe(){return TPe()}function QPe(){return EPe()}function XPe(e){return[mn(Mn,{get when(){return e.checked},get children(){var a=MPe(),n=a.firstChild;return ja((()=>On(n,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}}),mn(Mn,{get when(){return!e.checked},get children(){var a=xPe(),n=a.firstChild;return ja((()=>On(n,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}})]}function eLe(){return NPe()}function aLe(){return _Pe()}function nLe(){return PPe()}function tLe(){return LPe()}function iLe(){const e=Sn();return a=jPe(),r=(i=(t=(n=a.firstChild).nextSibling).nextSibling).firstChild,s=(o=i.nextSibling).firstChild,c=(u=(l=o.nextSibling).nextSibling).firstChild,m=(d=u.nextSibling).firstChild,g=(p=(h=d.nextSibling).nextSibling).firstChild,f=(v=p.nextSibling).firstChild,b=(k=(y=v.nextSibling).nextSibling).firstChild,A=(S=k.nextSibling).firstChild,M=(C=(w=S.nextSibling).nextSibling).firstChild,E=(T=C.nextSibling).firstChild,_=(N=(x=T.nextSibling).nextSibling).firstChild,L=(P=N.nextSibling).firstChild,R=(B=(j=P.nextSibling).nextSibling).firstChild,D=(z=B.nextSibling).firstChild,H=(O=(K=z.nextSibling).firstChild.nextSibling.nextSibling.nextSibling).nextSibling,G=(I=K.nextSibling).firstChild,V=(F=I.nextSibling).firstChild,re=(ie=(te=(ne=(ae=(ee=(X=(Q=(Y=($=(Z=(q=(W=(U=(J=F.nextSibling).firstChild).nextSibling).nextSibling.firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,se=(oe=J.nextSibling).firstChild,ue=(le=oe.nextSibling).firstChild,me=(de=(ce=le.nextSibling).firstChild).nextSibling,pe=(he=ce.nextSibling).firstChild,ve=(ge=he.nextSibling).firstChild,Re=(Be=(je=(Le=(Pe=(_e=(Ne=(xe=(Ee=(Te=(Me=(Ce=(we=(Ae=(Se=(be=(ke=(ye=(fe=ge.nextSibling).firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,On(n,"id",`a-${e}`),On(t,"fill",`url(#a-${e})`),On(r,"id",`am-${e}`),On(o,"id",`b-${e}`),On(s,"filter",`url(#am-${e})`),On(l,"mask",`url(#b-${e})`),On(c,"id",`ah-${e}`),On(d,"id",`k-${e}`),On(m,"filter",`url(#ah-${e})`),On(h,"mask",`url(#k-${e})`),On(g,"id",`ae-${e}`),On(v,"id",`j-${e}`),On(f,"filter",`url(#ae-${e})`),On(y,"mask",`url(#j-${e})`),On(b,"id",`ai-${e}`),On(S,"id",`i-${e}`),On(A,"filter",`url(#ai-${e})`),On(w,"mask",`url(#i-${e})`),On(M,"id",`aj-${e}`),On(T,"id",`h-${e}`),On(E,"filter",`url(#aj-${e})`),On(x,"mask",`url(#h-${e})`),On(_,"id",`ag-${e}`),On(P,"id",`g-${e}`),On(L,"filter",`url(#ag-${e})`),On(j,"mask",`url(#g-${e})`),On(R,"id",`af-${e}`),On(z,"id",`f-${e}`),On(D,"filter",`url(#af-${e})`),On(K,"mask",`url(#f-${e})`),On(O,"id",`m-${e}`),On(H,"fill",`url(#m-${e})`),On(G,"id",`ak-${e}`),On(F,"id",`e-${e}`),On(V,"filter",`url(#ak-${e})`),On(J,"mask",`url(#e-${e})`),On(U,"id",`n-${e}`),On(W,"fill",`url(#n-${e})`),On(q,"id",`r-${e}`),On(Z,"fill",`url(#r-${e})`),On($,"id",`s-${e}`),On(Y,"fill",`url(#s-${e})`),On(Q,"id",`q-${e}`),On(X,"fill",`url(#q-${e})`),On(ee,"id",`p-${e}`),On(ae,"fill",`url(#p-${e})`),On(ne,"id",`o-${e}`),On(te,"fill",`url(#o-${e})`),On(ie,"id",`l-${e}`),On(re,"fill",`url(#l-${e})`),On(se,"id",`al-${e}`),On(le,"id",`d-${e}`),On(ue,"filter",`url(#al-${e})`),On(ce,"mask",`url(#d-${e})`),On(de,"id",`u-${e}`),On(me,"fill",`url(#u-${e})`),On(pe,"id",`ad-${e}`),On(ge,"id",`c-${e}`),On(ve,"filter",`url(#ad-${e})`),On(fe,"mask",`url(#c-${e})`),On(ye,"id",`t-${e}`),On(ke,"fill",`url(#t-${e})`),On(be,"id",`v-${e}`),On(Se,"stroke",`url(#v-${e})`),On(Ae,"id",`aa-${e}`),On(we,"stroke",`url(#aa-${e})`),On(Ce,"id",`w-${e}`),On(Me,"stroke",`url(#w-${e})`),On(Te,"id",`ac-${e}`),On(Ee,"stroke",`url(#ac-${e})`),On(xe,"id",`ab-${e}`),On(Ne,"stroke",`url(#ab-${e})`),On(_e,"id",`y-${e}`),On(Pe,"stroke",`url(#y-${e})`),On(Le,"id",`x-${e}`),On(je,"stroke",`url(#x-${e})`),On(Be,"id",`z-${e}`),On(Re,"stroke",`url(#z-${e})`),a;var a,n,t,i,r,o,s,l,u,c,d,m,h,p,g,v,f,y,k,b,S,A,w,C,M,T,E,x,N,_,P,L,j,B,R,z,D,K,O,H,I,G,F,V,J,U,W,q,Z,$,Y,Q,X,ee,ae,ne,te,ie,re,oe,se,le,ue,ce,de,me,he,pe,ge,ve,fe,ye,ke,be,Se,Ae,we,Ce,Me,Te,Ee,xe,Ne,_e,Pe,Le,je,Be,Re}var rLe=Dn('<span><svg width=16 height=16 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M6 12L10 8L6 4"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),oLe=Dn('<button title="Copy object to clipboard">'),sLe=Dn('<button title="Remove all items"aria-label="Remove all items">'),lLe=Dn('<button title="Delete item"aria-label="Delete item">'),uLe=Dn('<button title="Toggle value"aria-label="Toggle value">'),cLe=Dn('<button title="Bulk Edit Data"aria-label="Bulk Edit Data">'),dLe=Dn("<div>"),mLe=Dn("<div><button> <span></span> <span> "),hLe=Dn("<input>"),pLe=Dn("<span>"),gLe=Dn("<div><span>:"),vLe=Dn("<div><div><button> [<!>...<!>]");var fLe=e=>{const a=DMe(),n=LMe().shadowDOMTarget?lTe.bind({target:LMe().shadowDOMTarget}):lTe,t=Ra((()=>"dark"===a()?TLe(n):MLe(n)));return i=rLe(),ja((()=>Hn(i,cTe(t().expander,n`
115
115
  transform: rotate(${e.expanded?90:0}deg);
116
116
  `,e.expanded&&n`
117
117
  & svg {