@embedreach/components 0.3.4 → 0.3.5
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/chunks/index.js +4 -4
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/chunks/index.js
CHANGED
|
@@ -93348,7 +93348,7 @@ const EmailPreview = ({
|
|
|
93348
93348
|
const [cancelClicked, setCancelClicked] = useState(false);
|
|
93349
93349
|
const [fromName, setFromName] = useState("");
|
|
93350
93350
|
const [replyToEmail, setReplyToEmail] = useState("");
|
|
93351
|
-
const [showHelpDialog, setShowHelpDialog] = useState(
|
|
93351
|
+
const [showHelpDialog, setShowHelpDialog] = useState(null);
|
|
93352
93352
|
const initialRenderRef = useRef(true);
|
|
93353
93353
|
const [isFormLoading, setIsFormLoading] = useState(true);
|
|
93354
93354
|
const [userModifiedEmail, setUserModifiedEmail] = useState(false);
|
|
@@ -93358,10 +93358,10 @@ const EmailPreview = ({
|
|
|
93358
93358
|
});
|
|
93359
93359
|
useEffect(() => {
|
|
93360
93360
|
if (!business) return;
|
|
93361
|
-
if (
|
|
93362
|
-
if (!showStripoEditor) {
|
|
93361
|
+
if (showStripoEditor === false) {
|
|
93363
93362
|
return;
|
|
93364
93363
|
}
|
|
93364
|
+
if (showHelpDialog !== null) return;
|
|
93365
93365
|
if (!business?.uiDefaults) {
|
|
93366
93366
|
setShowHelpDialog(true);
|
|
93367
93367
|
return;
|
|
@@ -93511,7 +93511,7 @@ const EmailPreview = ({
|
|
|
93511
93511
|
return /* @__PURE__ */ 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: /* @__PURE__ */ jsx(BasicLoader, { text: ["Fetching Email Preview..."] }) });
|
|
93512
93512
|
}
|
|
93513
93513
|
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
93514
|
-
/* @__PURE__ */ jsx(Dialog, { open: showHelpDialog, onOpenChange: setShowHelpDialog, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[86vh] gap-0 overflow-visible max-w-3xl w-full h-full", children: [
|
|
93514
|
+
/* @__PURE__ */ jsx(Dialog, { open: showHelpDialog ?? false, onOpenChange: setShowHelpDialog, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[86vh] gap-0 overflow-visible max-w-3xl w-full h-full", children: [
|
|
93515
93515
|
/* @__PURE__ */ jsxs(VisuallyHidden$2, { children: [
|
|
93516
93516
|
/* @__PURE__ */ jsx(DialogTitle, { children: "Email Preview Help" }),
|
|
93517
93517
|
/* @__PURE__ */ jsx(DialogDescription, { children: "Learn more about the email preview and how to use it to create your email." })
|
package/dist/index.umd.js
CHANGED
|
@@ -80,7 +80,7 @@ function s9(e,a){return e?function(e){return"function"==typeof e&&(()=>{const a=
|
|
|
80
80
|
*
|
|
81
81
|
* This source code is licensed under the MIT license found in the
|
|
82
82
|
* LICENSE file in the root directory of this source tree.
|
|
83
|
-
*/$ve.exports="production"===process.env.NODE_ENV?function(){if(Uve)return Zve;Uve=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},t=Hve.useSyncExternalStore,n=a.useRef,i=a.useEffect,r=a.useMemo,o=a.useDebugValue;return Zve.useSyncExternalStoreWithSelector=function(a,s,l,u,c){var d=n(null);if(null===d.current){var m={hasValue:!1,value:null};d.current=m}else m=d.current;d=r((function(){function a(a){if(!i){if(i=!0,t=a,a=u(a),void 0!==c&&m.hasValue){var r=m.value;if(c(r,a))return n=r}return n=a}if(r=n,e(t,a))return r;var o=u(a);return void 0!==c&&c(r,o)?r:(t=a,n=o)}var t,n,i=!1,r=void 0===l?null:l;return[function(){return a(s())},null===r?void 0:function(){return a(r())}]}),[s,l,u,c]);var h=t(a,d[0],d[1]);return i((function(){m.hasValue=!0,m.value=h}),[h]),o(h),h},Zve}():(Yve||(Yve=1,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},t=Hve.useSyncExternalStore,n=a.useRef,i=a.useEffect,r=a.useMemo,o=a.useDebugValue;Qve.useSyncExternalStoreWithSelector=function(a,s,l,u,c){var d,m=n(null);null===m.current?m.current=d={hasValue:!1,value:null}:d=m.current;var h=r((function(){var a,t,n=!1,i=function(i){if(!n){n=!0,a=i;var r=u(i);if(void 0!==c&&d.hasValue){var o=d.value;if(c(o,r))return t=o,o}return t=r,r}var s=t;if(e(a,i))return s;var l=u(i);return void 0!==c&&c(s,l)?s:(a=i,t=l,l)},r=void 0===l?null:l;return[function(){return i(s())},null===r?void 0:function(){return i(r())}]}),[s,l,u,c]),p=t(a,h[0],h[1]);return i((function(){d.hasValue=!0,d.value=p}),[p]),o(p),p},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Qve);var Xve=$ve.exports;const eye="undefined"!=typeof window?a.useLayoutEffect:a.useEffect;class aye{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach((e=>e()))},a=this.editor;return a.on("transaction",e),()=>{a.off("transaction",e)}}}}const tye="production"!==process.env.NODE_ENV,nye="undefined"==typeof window,iye=nye||Boolean("undefined"!=typeof window&&window.next);class rye{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((e=>e()))}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return nye||iye?null:this.createEditor();if(this.options.current.immediatelyRender&&nye&&tye)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...e)=>{var a,t;return null===(t=(a=this.options.current).onBeforeCreate)||void 0===t?void 0:t.call(a,...e)},onBlur:(...e)=>{var a,t;return null===(t=(a=this.options.current).onBlur)||void 0===t?void 0:t.call(a,...e)},onCreate:(...e)=>{var a,t;return null===(t=(a=this.options.current).onCreate)||void 0===t?void 0:t.call(a,...e)},onDestroy:(...e)=>{var a,t;return null===(t=(a=this.options.current).onDestroy)||void 0===t?void 0:t.call(a,...e)},onFocus:(...e)=>{var a,t;return null===(t=(a=this.options.current).onFocus)||void 0===t?void 0:t.call(a,...e)},onSelectionUpdate:(...e)=>{var a,t;return null===(t=(a=this.options.current).onSelectionUpdate)||void 0===t?void 0:t.call(a,...e)},onTransaction:(...e)=>{var a,t;return null===(t=(a=this.options.current).onTransaction)||void 0===t?void 0:t.call(a,...e)},onUpdate:(...e)=>{var a,t;return null===(t=(a=this.options.current).onUpdate)||void 0===t?void 0:t.call(a,...e)},onContentError:(...e)=>{var a,t;return null===(t=(a=this.options.current).onContentError)||void 0===t?void 0:t.call(a,...e)},onDrop:(...e)=>{var a,t;return null===(t=(a=this.options.current).onDrop)||void 0===t?void 0:t.call(a,...e)},onPaste:(...e)=>{var a,t;return null===(t=(a=this.options.current).onPaste)||void 0===t?void 0:t.call(a,...e)}};return new xve(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,a){return Object.keys(e).every((t=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(t)||("extensions"===t&&e.extensions&&a.extensions?e.extensions.length===a.extensions.length&&e.extensions.every(((e,t)=>{var n;return e===(null===(n=a.extensions)||void 0===n?void 0:n[t])})):e[t]===a[t])))}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===e.length?rye.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=e);if(this.previousDeps.length===e.length&&this.previousDeps.every(((a,t)=>a===e[t])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,a=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===e?a&&a.setOptions(this.options.current):a&&!a.isDestroyed&&(a.destroy(),this.instanceId===e&&this.setEditor(null))}),1)}}function oye(e={},t=[]){const n=a.useRef(e);n.current=e;const[i]=a.useState((()=>new rye(n))),r=Hve.useSyncExternalStore(i.subscribe,i.getEditor,i.getServerSnapshot);return a.useDebugValue(r),a.useEffect(i.onRender(t)),function(e){var t;const[n]=a.useState((()=>new aye(e.editor))),i=Xve.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!==(t=e.equalityFn)&&void 0!==t?t:qve);eye((()=>n.watch(e.editor)),[e.editor,n]),a.useDebugValue(i)}({editor:r,selector:({transactionNumber:a})=>!1===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===a?0:a+1}),r}a.createContext({editor:null});const sye=a.createContext({onDragStart:void 0}),lye=a.forwardRef(((e,t)=>{const{onDragStart:n}=a.useContext(sye);return a.createElement(e.as||"div",{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})}));function uye(e){return!("function"!=typeof e||!e.prototype||!e.prototype.isReactComponent)}function cye(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.forward_ref)"!==e.$$typeof.toString()&&"react.forward_ref"!==e.$$typeof.description)}class dye{constructor(e,{editor:a,props:t={},as:i="div",className:r=""}){this.ref=null,this.id=Math.floor(4294967295*Math.random()).toString(),this.component=e,this.editor=a,this.props=t,this.element=document.createElement(i),this.element.classList.add("react-renderer"),r&&this.element.classList.add(...r.split(" ")),this.editor.isInitialized?n.flushSync((()=>{this.render()})):this.render()}render(){var e;const t=this.component,n=this.props,i=this.editor,r=function(){try{if(a.version)return parseInt(a.version.split(".")[0],10)>=19}catch{}return!1}(),o=function(e){if(uye(e))return!0;if(cye(e))return!0;if(function(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.memo)"!==e.$$typeof.toString()&&"react.memo"!==e.$$typeof.description)}(e)){const a=e.type;if(a)return uye(a)||cye(a)}return!1}(t),s={...n};!s.ref||r||o||delete s.ref,s.ref||!r&&!o||(s.ref=e=>{this.ref=e}),this.reactElement=a.createElement(t,{...s}),null===(e=null==i?void 0:i.contentComponent)||void 0===e||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const a=this.editor;null===(e=null==a?void 0:a.contentComponent)||void 0===e||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach((a=>{this.element.setAttribute(a,e[a])}))}}class mye extends jve{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:a.createRef()};if(!this.component.displayName){this.component.displayName=(e=>e.charAt(0).toUpperCase()+e.substring(1))(this.extension.name)}const t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&e.appendChild(this.contentDOMElement)}},n=this.component,i=a.memo((e=>a.createElement(sye.Provider,{value:t},a.createElement(n,e))));i.displayName="ReactNodeView",this.contentDOMElement=this.node.isLeaf?null:this.options.contentDOMElementTag?document.createElement(this.options.contentDOMElementTag):document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.style.whiteSpace="inherit");let r=this.node.isInline?"span":"div";this.options.as&&(r=this.options.as);const{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new dye(i,{editor:this.editor,props:e,as:r,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null===(e=this.renderer.element.firstElementChild)||void 0===e?void 0:e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:a}=this.editor.state.selection,t=this.getPos();if("number"==typeof t)if(e<=t&&a>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,a,t){const n=e=>{this.renderer.updateProps(e),"function"==typeof this.options.attrs&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){const i=this.node,r=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=a,this.innerDecorations=t,this.options.update({oldNode:i,oldDecorations:r,newNode:e,newDecorations:a,oldInnerDecorations:o,innerDecorations:t,updateProps:()=>n({node:e,decorations:a,innerDecorations:t})})}return e===this.node&&this.decorations===a&&this.innerDecorations===t||(this.node=e,this.decorations=a,this.innerDecorations=t,n({node:e,decorations:a,innerDecorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if("function"==typeof this.options.attrs){const a=yfe(this.node,this.editor.extensionManager.attributes);e=this.options.attrs({node:this.node,HTMLAttributes:a})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function hye(e,a){return t=>t.editor.contentComponent?new mye(e,t,a):{}}const pye=/^\s*>\s$/,gye=Pve.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return["blockquote",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[_ve({find:pye,type:this.type})]}}),fye=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,vye=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,yye=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,bye=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,kye=jfe.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Eve({find:fye,type:this.type}),Eve({find:yye,type:this.type})]},addPasteRules(){return[Lve({find:vye,type:this.type}),Lve({find:bye,type:this.type})]}}),Sye="textStyle",wye=/^\s*([-+*])\s$/,Aye=Pve.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:a})=>this.options.keepAttributes?a().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Sye)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=_ve({find:wye,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=_ve({find:wye,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Sye),editor:this.editor})),[e]}}),Cye=/(^|[^`])`([^`]+)`(?!`)/,Mye=/(^|[^`])`([^`]+)`(?!`)/g,Tye=jfe.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Eve({find:Cye,type:this.type})]},addPasteRules(){return[Lve({find:Mye,type:this.type})]}}),xye=/^```([a-z]+)?[\s\n]$/,Eye=/^~~~([a-z]+)?[\s\n]$/,Nye=Pve.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var a;const{languageClassPrefix:t}=this.options,n=[...(null===(a=e.firstElementChild)||void 0===a?void 0:a.classList)||[]].filter((e=>e.startsWith(t))).map((e=>e.replace(t,"")))[0];return n||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:a}){return["pre",vfe(this.options.HTMLAttributes,a),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:a})=>a.setNode(this.name,e),toggleCodeBlock:e=>({commands:a})=>a.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:a}=this.editor.state.selection;return!(!e||a.parent.type.name!==this.name)&&(!(!(1===a.pos)&&a.parent.textContent.length)&&this.editor.commands.clearNodes())},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:a}=e,{selection:t}=a,{$from:n,empty:i}=t;if(!i||n.parent.type!==this.type)return!1;const r=n.parentOffset===n.parent.nodeSize-2,o=n.parent.textContent.endsWith("\n\n");return!(!r||!o)&&e.chain().command((({tr:e})=>(e.delete(n.pos-2,n.pos),!0))).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:a}=e,{selection:t,doc:n}=a,{$from:i,empty:r}=t;if(!r||i.parent.type!==this.type)return!1;if(!(i.parentOffset===i.parent.nodeSize-2))return!1;const o=i.after();if(void 0===o)return!1;return n.nodeAt(o)?e.commands.command((({tr:e})=>(e.setSelection(Vde.near(n.resolve(o))),!0))):e.commands.exitCode()}}},addInputRules(){return[Nve({find:xye,type:this.type,getAttributes:e=>({language:e[1]})}),Nve({find:Eye,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new ume({key:new mme("codeBlockVSCodeHandler"),props:{handlePaste:(e,a)=>{if(!a.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const t=a.clipboardData.getData("text/plain"),n=a.clipboardData.getData("vscode-editor-data"),i=n?JSON.parse(n):void 0,r=null==i?void 0:i.mode;if(!t||!r)return!1;const{tr:o,schema:s}=e.state,l=s.text(t.replace(/\r\n?/g,"\n"));return o.replaceSelectionWith(this.type.create({language:r},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(qde.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),e.dispatch(o),!0}}})]}}),_ye=Pve.create({name:"doc",topNode:!0,content:"block+"});function Pye(e={}){return new ume({view:a=>new jye(a,e)})}class jye{constructor(e,a){var t;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(t=a.width)&&void 0!==t?t:1,this.color=!1===a.color?void 0:a.color||"black",this.class=a.class,this.handlers=["dragover","dragend","drop","dragleave"].map((a=>{let t=e=>{this[a](e)};return e.dom.addEventListener(a,t),{name:a,handler:t}}))}destroy(){this.handlers.forEach((({name:e,handler:a})=>this.editorView.dom.removeEventListener(e,a)))}update(e,a){null!=this.cursorPos&&a.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,a=this.editorView.state.doc.resolve(this.cursorPos),t=!a.parent.inlineContent,n=this.editorView.dom,i=n.getBoundingClientRect(),r=i.width/n.offsetWidth,o=i.height/n.offsetHeight;if(t){let t=a.nodeBefore,n=a.nodeAfter;if(t||n){let a=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(a){let i=a.getBoundingClientRect(),r=t?i.bottom:i.top;t&&n&&(r=(r+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;e={left:i.left,right:i.right,top:r-s,bottom:r+s}}}}if(!e){let a=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*r;e={left:a.left-t,right:a.left+t,top:a.top,bottom:a.bottom}}let s,l,u=this.editorView.dom.offsetParent;if(this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t),!u||u==document.body&&"static"==getComputedStyle(u).position)s=-pageXOffset,l=-pageYOffset;else{let e=u.getBoundingClientRect();s=e.left-u.scrollLeft*(e.width/u.offsetWidth),l=e.top-u.scrollTop*(e.height/u.offsetHeight)}this.element.style.left=(e.left-s)/r+"px",this.element.style.top=(e.top-l)/o+"px",this.element.style.width=(e.right-e.left)/r+"px",this.element.style.height=(e.bottom-e.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let a=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),t=a&&a.inside>=0&&this.editorView.state.doc.nodeAt(a.inside),n=t&&t.type.spec.disableDropCursor,i="function"==typeof n?n(this.editorView,a,e):n;if(a&&!i){let e=a.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Ede(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=a&&(e=a)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Lye=Ofe.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Pye(this.options)]}});class Bye extends Vde{constructor(e){super(e,e)}map(e,a){let t=e.resolve(a.map(this.head));return Bye.valid(t)?new Bye(t):Vde.near(t)}content(){return ece.empty}eq(e){return e instanceof Bye&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,a){if("number"!=typeof a.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Bye(e.resolve(a.pos))}getBookmark(){return new Rye(this.anchor)}static valid(e){let a=e.parent;if(a.isTextblock||!function(e){for(let a=e.depth;a>=0;a--){let t=e.index(a),n=e.node(a);if(0!=t)for(let e=n.child(t-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(n.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let a=e.depth;a>=0;a--){let t=e.indexAfter(a),n=e.node(a);if(t!=n.childCount)for(let e=n.child(t);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(n.type.spec.isolating)return!0}return!0}(e))return!1;let t=a.type.spec.allowGapCursor;if(null!=t)return t;let n=a.contentMatchAt(e.index()).defaultType;return n&&n.isTextblock}static findGapCursorFrom(e,a,t=!1){e:for(;;){if(!t&&Bye.valid(e))return e;let n=e.pos,i=null;for(let t=e.depth;;t--){let r=e.node(t);if(a>0?e.indexAfter(t)<r.childCount:e.index(t)>0){i=r.child(a>0?e.indexAfter(t):e.index(t)-1);break}if(0==t)return null;n+=a;let o=e.doc.resolve(n);if(Bye.valid(o))return o}for(;;){let r=a>0?i.firstChild:i.lastChild;if(!r){if(i.isAtom&&!i.isText&&!Zde.isSelectable(i)){e=e.doc.resolve(n+i.nodeSize*a),t=!1;continue e}break}i=r,n+=a;let o=e.doc.resolve(n);if(Bye.valid(o))return o}return null}}}Bye.prototype.visible=!1,Bye.findFrom=Bye.findGapCursorFrom,Vde.jsonID("gapcursor",Bye);class Rye{constructor(e){this.pos=e}map(e){return new Rye(e.map(this.pos))}resolve(e){let a=e.resolve(this.pos);return Bye.valid(a)?new Bye(a):Vde.near(a)}}const Dye=Kge({ArrowLeft:zye("horiz",-1),ArrowRight:zye("horiz",1),ArrowUp:zye("vert",-1),ArrowDown:zye("vert",1)});function zye(e,a){const t="vert"==e?a>0?"down":"up":a>0?"right":"left";return function(e,n,i){let r=e.selection,o=a>0?r.$to:r.$from,s=r.empty;if(r instanceof qde){if(!i.endOfTextblock(t)||0==o.depth)return!1;s=!1,o=e.doc.resolve(a>0?o.after():o.before())}let l=Bye.findGapCursorFrom(o,a,s);return!!l&&(n&&n(e.tr.setSelection(new Bye(l))),!0)}}function Oye(e,a,t){if(!e||!e.editable)return!1;let n=e.state.doc.resolve(a);if(!Bye.valid(n))return!1;let i=e.posAtCoords({left:t.clientX,top:t.clientY});return!(i&&i.inside>-1&&Zde.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new Bye(n))),!0)}function Kye(e,a){if("insertCompositionText"!=a.inputType||!(e.state.selection instanceof Bye))return!1;let{$from:t}=e.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(e.state.schema.nodes.text);if(!n)return!1;let i=que.empty;for(let o=n.length-1;o>=0;o--)i=que.from(n[o].createAndFill(null,i));let r=e.state.tr.replace(t.pos,t.pos,new ece(i,0,0));return r.setSelection(qde.near(r.doc.resolve(t.pos+1))),e.dispatch(r),!1}function Hye(e){if(!(e.selection instanceof Bye))return null;let a=document.createElement("div");return a.className="ProseMirror-gapcursor",Qpe.create(e.doc,[$pe.widget(e.selection.head,a,{key:"gapcursor"})])}const Iye=Ofe.create({name:"gapCursor",addProseMirrorPlugins:()=>[new ume({props:{decorations:Hye,createSelectionBetween:(e,a,t)=>a.pos==t.pos&&Bye.valid(t)?new Bye(t):null,handleClick:Oye,handleKeyDown:Dye,handleDOMEvents:{beforeinput:Kye}}})],extendNodeSchema(e){var a;return{allowGapCursor:null!==(a=kfe(hfe(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==a?a:null}}}),Fye=Pve.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",vfe(this.options.HTMLAttributes,e)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:e,chain:a,state:t,editor:n})=>e.first([()=>e.exitCode(),()=>e.command((()=>{const{selection:e,storedMarks:i}=t;if(e.$from.parent.type.spec.isolating)return!1;const{keepMarks:r}=this.options,{splittableMarks:o}=n.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return a().insertContent({type:this.name}).command((({tr:e,dispatch:a})=>{if(a&&s&&r){const a=s.filter((e=>o.includes(e.type.name)));e.ensureMarks(a)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Gye=Pve.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((e=>({tag:`h${e}`,attrs:{level:e}})))},renderHTML({node:e,HTMLAttributes:a}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,vfe(this.options.HTMLAttributes,a),0]},addCommands(){return{setHeading:e=>({commands:a})=>!!this.options.levels.includes(e.level)&&a.setNode(this.name,e),toggleHeading:e=>({commands:a})=>!!this.options.levels.includes(e.level)&&a.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce(((e,a)=>({...e,[`Mod-Alt-${a}`]:()=>this.editor.commands.toggleHeading({level:a})})),{})},addInputRules(){return this.options.levels.map((e=>Nve({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}})))}});var Vye=200,Jye=function(){};Jye.prototype.append=function(e){return e.length?(e=Jye.from(e),!this.length&&e||e.length<Vye&&this.leafAppend(e)||this.length<Vye&&e.leafPrepend(this)||this.appendInner(e)):this},Jye.prototype.prepend=function(e){return e.length?Jye.from(e).append(this):this},Jye.prototype.appendInner=function(e){return new Wye(this,e)},Jye.prototype.slice=function(e,a){return void 0===e&&(e=0),void 0===a&&(a=this.length),e>=a?Jye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,a))},Jye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Jye.prototype.forEach=function(e,a,t){void 0===a&&(a=0),void 0===t&&(t=this.length),a<=t?this.forEachInner(e,a,t,0):this.forEachInvertedInner(e,a,t,0)},Jye.prototype.map=function(e,a,t){void 0===a&&(a=0),void 0===t&&(t=this.length);var n=[];return this.forEach((function(a,t){return n.push(e(a,t))}),a,t),n},Jye.from=function(e){return e instanceof Jye?e:e&&e.length?new Uye(e):Jye.empty};var Uye=function(e){function a(a){e.call(this),this.values=a}e&&(a.__proto__=e),(a.prototype=Object.create(e&&e.prototype)).constructor=a;var t={length:{configurable:!0},depth:{configurable:!0}};return a.prototype.flatten=function(){return this.values},a.prototype.sliceInner=function(e,t){return 0==e&&t==this.length?this:new a(this.values.slice(e,t))},a.prototype.getInner=function(e){return this.values[e]},a.prototype.forEachInner=function(e,a,t,n){for(var i=a;i<t;i++)if(!1===e(this.values[i],n+i))return!1},a.prototype.forEachInvertedInner=function(e,a,t,n){for(var i=a-1;i>=t;i--)if(!1===e(this.values[i],n+i))return!1},a.prototype.leafAppend=function(e){if(this.length+e.length<=Vye)return new a(this.values.concat(e.flatten()))},a.prototype.leafPrepend=function(e){if(this.length+e.length<=Vye)return new a(e.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(a.prototype,t),a}(Jye);Jye.empty=new Uye([]);var Wye=function(e){function a(a,t){e.call(this),this.left=a,this.right=t,this.length=a.length+t.length,this.depth=Math.max(a.depth,t.depth)+1}return e&&(a.__proto__=e),(a.prototype=Object.create(e&&e.prototype)).constructor=a,a.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},a.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},a.prototype.forEachInner=function(e,a,t,n){var i=this.left.length;return!(a<i&&!1===this.left.forEachInner(e,a,Math.min(t,i),n))&&(!(t>i&&!1===this.right.forEachInner(e,Math.max(a-i,0),Math.min(this.length,t)-i,n+i))&&void 0)},a.prototype.forEachInvertedInner=function(e,a,t,n){var i=this.left.length;return!(a>i&&!1===this.right.forEachInvertedInner(e,a-i,Math.max(t,i)-i,n+i))&&(!(t<i&&!1===this.left.forEachInvertedInner(e,Math.min(a,i),t,n))&&void 0)},a.prototype.sliceInner=function(e,a){if(0==e&&a==this.length)return this;var t=this.left.length;return a<=t?this.left.slice(e,a):e>=t?this.right.slice(e-t,a-t):this.left.slice(e,t).append(this.right.slice(0,a-t))},a.prototype.leafAppend=function(e){var t=this.right.leafAppend(e);if(t)return new a(this.left,t)},a.prototype.leafPrepend=function(e){var t=this.left.leafPrepend(e);if(t)return new a(t,this.right)},a.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new a(this.left,new a(this.right,e)):new a(this,e)},a}(Jye);class qye{constructor(e,a){this.items=e,this.eventCount=a}popEvent(e,a){if(0==this.eventCount)return null;let t,n,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}a&&(t=this.remapping(i,this.items.length),n=t.maps.length);let r,o,s=e.tr,l=[],u=[];return this.items.forEach(((e,a)=>{if(!e.step)return t||(t=this.remapping(i,a+1),n=t.maps.length),n--,void u.push(e);if(t){u.push(new $ye(e.map));let a,i=e.step.map(t.slice(n));i&&s.maybeStep(i).doc&&(a=s.mapping.maps[s.mapping.maps.length-1],l.push(new $ye(a,void 0,void 0,l.length+u.length))),n--,a&&t.appendMap(a,n)}else s.maybeStep(e.step);return e.selection?(r=t?e.selection.map(t.slice(n)):e.selection,o=new qye(this.items.slice(0,i).append(u.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:s,selection:r}}addTransform(e,a,t,n){let i=[],r=this.eventCount,o=this.items,s=!n&&o.length?o.get(o.length-1):null;for(let u=0;u<e.steps.length;u++){let t,l=e.steps[u].invert(e.docs[u]),c=new $ye(e.mapping.maps[u],l,a);(t=s&&s.merge(c))&&(c=t,u?i.pop():o=o.slice(0,o.length-1)),i.push(c),a&&(r++,a=void 0),n||(s=c)}let l=r-t.depth;return l>Yye&&(o=function(e,a){let t;return e.forEach(((e,n)=>{if(e.selection&&0==a--)return t=n,!1})),e.slice(t)}(o,l),r-=l),new qye(o.append(i),r)}remapping(e,a){let t=new rde;return this.items.forEach(((a,n)=>{t.appendMap(a.map,null!=a.mirrorOffset&&n-a.mirrorOffset>=e?t.maps.length-a.mirrorOffset:void 0)}),e,a),t}addMaps(e){return 0==this.eventCount?this:new qye(this.items.append(e.map((e=>new $ye(e)))),this.eventCount)}rebased(e,a){if(!this.eventCount)return this;let t=[],n=Math.max(0,this.items.length-a),i=e.mapping,r=e.steps.length,o=this.eventCount;this.items.forEach((e=>{e.selection&&o--}),n);let s=a;this.items.forEach((a=>{let n=i.getMirror(--s);if(null==n)return;r=Math.min(r,n);let l=i.maps[n];if(a.step){let r=e.steps[n].invert(e.docs[n]),u=a.selection&&a.selection.map(i.slice(s+1,n));u&&o++,t.push(new $ye(l,r,u))}else t.push(new $ye(l))}),n);let l=[];for(let d=a;d<r;d++)l.push(new $ye(i.maps[d]));let u=this.items.slice(0,n).append(l).append(t),c=new qye(u,o);return c.emptyItemCount()>500&&(c=c.compress(this.items.length-t.length)),c}emptyItemCount(){let e=0;return this.items.forEach((a=>{a.step||e++})),e}compress(e=this.items.length){let a=this.remapping(0,e),t=a.maps.length,n=[],i=0;return this.items.forEach(((r,o)=>{if(o>=e)n.push(r),r.selection&&i++;else if(r.step){let e=r.step.map(a.slice(t)),o=e&&e.getMap();if(t--,o&&a.appendMap(o,t),e){let s=r.selection&&r.selection.map(a.slice(t));s&&i++;let l,u=new $ye(o.invert(),e,s),c=n.length-1;(l=n.length&&n[c].merge(u))?n[c]=l:n.push(u)}}else r.map&&t--}),this.items.length,0),new qye(Jye.from(n.reverse()),i)}}qye.empty=new qye(Jye.empty,0);let $ye=class e{constructor(e,a,t,n){this.map=e,this.step=a,this.selection=t,this.mirrorOffset=n}merge(a){if(this.step&&a.step&&!a.selection){let t=a.step.merge(this.step);if(t)return new e(t.getMap().invert(),t,this.selection)}}};class Zye{constructor(e,a,t,n,i){this.done=e,this.undone=a,this.prevRanges=t,this.prevTime=n,this.prevComposition=i}}const Yye=20;function Qye(e){let a=[];for(let t=e.length-1;t>=0&&0==a.length;t--)e[t].forEach(((e,t,n,i)=>a.push(n,i)));return a}function Xye(e,a){if(!e)return null;let t=[];for(let n=0;n<e.length;n+=2){let i=a.map(e[n],1),r=a.map(e[n+1],-1);i<=r&&t.push(i,r)}return t}let ebe=!1,abe=null;function tbe(e){let a=e.plugins;if(abe!=a){ebe=!1,abe=a;for(let e=0;e<a.length;e++)if(a[e].spec.historyPreserveItems){ebe=!0;break}}return ebe}const nbe=new mme("history"),ibe=new mme("closeHistory");function rbe(e={}){return new ume({key:nbe,state:{init:()=>new Zye(qye.empty,qye.empty,null,0,-1),apply:(a,t,n)=>function(e,a,t,n){let i,r=t.getMeta(nbe);if(r)return r.historyState;t.getMeta(ibe)&&(e=new Zye(e.done,e.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(0==t.steps.length)return e;if(o&&o.getMeta(nbe))return o.getMeta(nbe).redo?new Zye(e.done.addTransform(t,void 0,n,tbe(a)),e.undone,Qye(t.mapping.maps),e.prevTime,e.prevComposition):new Zye(e.done,e.undone.addTransform(t,void 0,n,tbe(a)),null,e.prevTime,e.prevComposition);if(!1===t.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=t.getMeta("rebased"))?new Zye(e.done.rebased(t,i),e.undone.rebased(t,i),Xye(e.prevRanges,t.mapping),e.prevTime,e.prevComposition):new Zye(e.done.addMaps(t.mapping.maps),e.undone.addMaps(t.mapping.maps),Xye(e.prevRanges,t.mapping),e.prevTime,e.prevComposition);{let i=t.getMeta("composition"),r=0==e.prevTime||!o&&e.prevComposition!=i&&(e.prevTime<(t.time||0)-n.newGroupDelay||!function(e,a){if(!a)return!1;if(!e.docChanged)return!0;let t=!1;return e.mapping.maps[0].forEach(((e,n)=>{for(let i=0;i<a.length;i+=2)e<=a[i+1]&&n>=a[i]&&(t=!0)})),t}(t,e.prevRanges)),s=o?Xye(e.prevRanges,t.mapping):Qye(t.mapping.maps);return new Zye(e.done.addTransform(t,r?a.selection.getBookmark():void 0,n,tbe(a)),qye.empty,s,t.time,null==i?e.prevComposition:i)}}(t,n,a,e)},config:e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(e,a){let t=a.inputType,n="historyUndo"==t?sbe:"historyRedo"==t?lbe:null;return!!n&&(a.preventDefault(),n(e.state,e.dispatch))}}}})}function obe(e,a){return(t,n)=>{let i=nbe.getState(t);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(n){let r=function(e,a,t){let n=tbe(a),i=nbe.get(a).spec.config,r=(t?e.undone:e.done).popEvent(a,n);if(!r)return null;let o=r.selection.resolve(r.transform.doc),s=(t?e.done:e.undone).addTransform(r.transform,a.selection.getBookmark(),i,n),l=new Zye(t?s:r.remaining,t?r.remaining:s,null,0,-1);return r.transform.setSelection(o).setMeta(nbe,{redo:t,historyState:l})}(i,t,e);r&&n(a?r.scrollIntoView():r)}return!0}}const sbe=obe(!1,!0),lbe=obe(!0,!0),ube=Ofe.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:a})=>sbe(e,a),redo:()=>({state:e,dispatch:a})=>lbe(e,a)}),addProseMirrorPlugins(){return[rbe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),cbe=Pve.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",vfe(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:a})=>{const{selection:t}=a,{$from:n,$to:i}=t,r=e();return 0===n.parentOffset?r.insertContentAt({from:Math.max(n.pos-1,0),to:i.pos},{type:this.name}):t instanceof Zde?r.insertContentAt(i.pos,{type:this.name}):r.insertContent({type:this.name}),r.command((({tr:e,dispatch:a})=>{var t;if(a){const{$to:a}=e.selection,n=a.end();if(a.nodeAfter)e.setSelection(a.nodeAfter.isTextblock?qde.create(e.doc,a.pos+1):a.nodeAfter.isBlock?Zde.create(e.doc,a.pos):qde.create(e.doc,a.pos));else{const i=null===(t=a.parent.type.contentMatch.defaultType)||void 0===t?void 0:t.create();i&&(e.insert(n,i),e.setSelection(qde.create(e.doc,n+1)))}e.scrollIntoView()}return!0})).run()}}},addInputRules(){return[(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type},new xfe({find:e.find,handler:({state:a,range:t,match:n})=>{const i=kfe(e.getAttributes,void 0,n)||{},{tr:r}=a,o=t.from;let s=t.to;const l=e.type.create(i);if(n[1]){let e=o+n[0].lastIndexOf(n[1]);e>s?e=s:s=e+n[1].length,r.insertText(n[0][n[0].length-1],o+n[0].length-1),r.replaceWith(e,s,l)}else n[0]&&r.insert(e.type.isInline?o:o-1,e.type.create(i)).delete(r.mapping.map(o),r.mapping.map(s));r.scrollIntoView()}}))];var e}}),dbe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,mbe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,hbe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,pbe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,gbe=jfe.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Eve({find:dbe,type:this.type}),Eve({find:hbe,type:this.type})]},addPasteRules(){return[Lve({find:mbe,type:this.type}),Lve({find:pbe,type:this.type})]}}),fbe=Pve.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",vfe(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),vbe="textStyle",ybe=/^(\d+)\.\s$/,bbe=Pve.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){const{start:a,...t}=e;return 1===a?["ol",vfe(this.options.HTMLAttributes,t),0]:["ol",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:a})=>this.options.keepAttributes?a().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(vbe)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=_ve({find:ybe,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,a)=>a.childCount+a.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=_ve({find:ybe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(vbe)}),joinPredicate:(e,a)=>a.childCount+a.attrs.start===+e[1],editor:this.editor})),[e]}}),kbe=Pve.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Sbe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,wbe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Abe=jfe.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Eve({find:Sbe,type:this.type})]},addPasteRules(){return[Lve({find:wbe,type:this.type})]}}),Cbe=Pve.create({name:"text",group:"inline"}),Mbe=Ofe.create({name:"starterKit",addExtensions(){const e=[];return!1!==this.options.bold&&e.push(kye.configure(this.options.bold)),!1!==this.options.blockquote&&e.push(gye.configure(this.options.blockquote)),!1!==this.options.bulletList&&e.push(Aye.configure(this.options.bulletList)),!1!==this.options.code&&e.push(Tye.configure(this.options.code)),!1!==this.options.codeBlock&&e.push(Nye.configure(this.options.codeBlock)),!1!==this.options.document&&e.push(_ye.configure(this.options.document)),!1!==this.options.dropcursor&&e.push(Lye.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&e.push(Iye.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&e.push(Fye.configure(this.options.hardBreak)),!1!==this.options.heading&&e.push(Gye.configure(this.options.heading)),!1!==this.options.history&&e.push(ube.configure(this.options.history)),!1!==this.options.horizontalRule&&e.push(cbe.configure(this.options.horizontalRule)),!1!==this.options.italic&&e.push(gbe.configure(this.options.italic)),!1!==this.options.listItem&&e.push(fbe.configure(this.options.listItem)),!1!==this.options.orderedList&&e.push(bbe.configure(this.options.orderedList)),!1!==this.options.paragraph&&e.push(kbe.configure(this.options.paragraph)),!1!==this.options.strike&&e.push(Abe.configure(this.options.strike)),!1!==this.options.text&&e.push(Cbe.configure(this.options.text)),e}}),Tbe=e=>t.jsx(lye,{as:"span",className:"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200",children:e.node.attrs.displayName}),xbe=Pve.create({name:"mergeField",group:"inline",inline:!0,atom:!0,addAttributes:()=>({templateName:{default:null,parseHTML:e=>e.getAttribute("data-template-name")},displayName:{default:null,parseHTML:e=>e.getAttribute("data-display-name")}}),parseHTML:()=>[{tag:"span[data-merge-field]"}],renderHTML:({HTMLAttributes:e})=>["span",vfe(e,{"data-merge-field":"true"})],renderText:({node:e})=>e.attrs.templateName,addNodeView:()=>hye(Tbe)}),Ebe=({value:e,onChange:n,className:i="",mergeFieldsResponse:r,placeholder:o="Enter text",ariaLabel:s="Insert merge field",icon:l="MergeField"})=>{const[u,c]=a.useState(!1),d=a.useRef(null),m=a.useRef(null),h=a.useMemo((()=>r?.mergeFields?.flatMap((e=>e.entries))??[]),[r]),p=a.useCallback((e=>{if(!e)return"";return e.replace(/\{\{.*?\}\}/g,(e=>{const a=h.find((a=>a.value===e));return a?`<span class="inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200" data-merge-field="true" data-template-name="${a.value}" data-display-name="${a.label}">${a.label}</span>`:e}))}),[h]),g=oye({extensions:[Mbe,xbe],content:"",editorProps:{attributes:{class:`min-h-[40px] px-3 py-2 border border-input bg-background hover:bg-accent/50 focus:bg-accent transition-colors placeholder:text-muted-foreground/50 rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent resize-none prose prose-sm max-w-none ${i}`,placeholder:o}},onUpdate:({editor:e})=>{const a=e.getText();n(a)}});a.useEffect((()=>{if(g&&e){if(g.getText()!==e){const a=p(e);g.commands.setContent(a,!1)}}}),[g,e,p]);const f=a.useCallback((e=>{if(g){const a=h.find((a=>a.value===e));a&&g.chain().focus().insertContent({type:"mergeField",attrs:{templateName:a.value,displayName:a.label}}).run()}c(!1)}),[g,h]);if(a.useEffect((()=>{if(u)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){const a=e.target;m.current&&!m.current.contains(a)&&d.current&&!d.current.contains(a)&&c(!1)}}),[u]),!g)return t.jsx("div",{children:"Loading editor..."});const v=V5[l]||V5.MergeField;return t.jsx("div",{className:"relative",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-1",children:t.jsx(Jve,{editor:g})}),r&&t.jsxs(t.Fragment,{children:[t.jsx(H5,{ref:d,type:"button",variant:"ghost",size:"icon",className:"ml-2 h-10 w-7 p-0 rounded-md border border-input shadow-sm hover:bg-accent/60 focus:bg-accent/80 transition-colors","aria-label":s,onClick:()=>c((e=>!e)),children:t.jsx(v,{className:"w-4 h-4"})}),u&&t.jsx("div",{ref:m,className:"absolute z-50 mt-2 right-0 w-56 bg-white border border-gray-200 rounded-lg shadow-lg p-1",style:{top:"100%"},children:0===h.length?t.jsx("div",{className:"px-4 py-2 text-muted-foreground text-sm",children:"No merge fields found"}):t.jsx("ul",{className:"py-1",children:h.map((e=>t.jsx("li",{children:t.jsx("button",{className:"w-full text-left px-4 py-2 hover:bg-accent/40 rounded text-sm transition-colors",onClick:()=>f(e.value),type:"button",children:e.label})},e.value)))})})]})]})})},Nbe=()=>{const[e,n]=a.useState("desktop"),i=a.useRef(null),r=a.useRef(null);return a.useEffect((()=>{const e=()=>n("desktop"),a=()=>n("mobile"),t=i.current,o=r.current;return t&&t.addEventListener("click",e),o&&o.addEventListener("click",a),()=>{t&&t.removeEventListener("click",e),o&&o.removeEventListener("click",a)}}),[]),t.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-0.5 shadow-inner border w-fit",children:[t.jsxs(H5,{ref:i,type:"button","aria-pressed":"desktop"===e,"aria-label":"Show desktop preview",className:"desktop-view-button toggle-desktop-button relative flex items-center justify-center px-2 py-0 rounded-md transition-colors duration-200"+("desktop"===e?" bg-background shadow text-primary":" bg-transparent text-muted-foreground hover:bg-accent"),variant:"ghost",style:{minWidth:32,minHeight:32},children:["desktop"===e&&t.jsx(o5.span,{layoutId:"toggle-indicator",className:"absolute inset-0 rounded-md border-2 bg-background/80 z-0 border-[color:var(--reach-primary)]",transition:{type:"spring",stiffness:400,damping:30}}),t.jsx("span",{className:"relative z-10 flex items-center justify-center",children:t.jsx(V5.DesktopIcon,{className:"w-4 h-4"})})]}),t.jsxs(H5,{ref:r,type:"button","aria-pressed":"mobile"===e,"aria-label":"Show mobile preview",className:"mobile-view-button toggle-mobile-button relative flex items-center justify-center px-2 py-0 rounded-md transition-colors duration-200"+("mobile"===e?" bg-background shadow text-primary":" bg-transparent text-muted-foreground hover:bg-accent"),variant:"ghost",style:{minWidth:32,minHeight:32},children:["mobile"===e&&t.jsx(o5.span,{layoutId:"toggle-indicator",className:"absolute inset-0 rounded-md border-2 bg-background/80 z-0 border-[color:var(--reach-primary)]",transition:{type:"spring",stiffness:400,damping:30}}),t.jsx("span",{className:"relative z-10 flex items-center justify-center",children:t.jsx(V5.MobileIcon,{className:"w-4 h-4"})})]})]})};function _be(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function Pbe(e){const a=jbe(e),n=r.forwardRef(((e,n)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Bbe);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 t.jsx(a,{...o,ref:n,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return t.jsx(a,{...o,ref:n,children:i})}));return n.displayName=`${e}.Slot`,n}function jbe(e){const a=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?function(...e){return a=>{let t=!1;const n=e.map((e=>{const n=_be(e,a);return t||"function"!=typeof n||(t=!0),n}));if(t)return()=>{for(let a=0;a<n.length;a++){const t=n[a];"function"==typeof t?t():_be(e[a],null)}}}}(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var Lbe=Symbol("radix.slottable");function Bbe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Lbe}var Rbe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const n=Pbe(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?n:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),Dbe=r.forwardRef(((e,a)=>t.jsx(Rbe.label,{...e,ref:a,onMouseDown:a=>{a.target.closest("button, input, select, textarea")||(e.onMouseDown?.(a),!a.defaultPrevented&&a.detail>1&&a.preventDefault())}})));Dbe.displayName="Label";var zbe=Dbe;const Obe=GD("text-foreground text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Kbe=r.forwardRef((({className:e,...a},n)=>t.jsx(zbe,{ref:n,className:XO(Obe(),e),...a})));function Hbe(e,[a,t]){return Math.min(t,Math.max(a,e))}function Ibe(e,a,{checkForDefaultPrevented:t=!0}={}){return function(n){if(e?.(n),!1===t||!n.defaultPrevented)return a?.(n)}}function Fbe(e,a=[]){let n=[];const i=()=>{const a=n.map((e=>r.createContext(e)));return function(t){const n=t?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...t,[e]:n}})),[t,n])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=n.length;n=[...n,i];const l=a=>{const{scope:n,children:i,...l}=a,u=n?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return t.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(t,n){const l=r.useContext(n?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${a}\``)}]},Gbe(i,...a)]}function Gbe(...e){const a=e[0];if(1===e.length)return a;const t=()=>{const t=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const n=t.reduce(((a,{useScope:t,scopeName:n})=>({...a,...t(e)[`__scope${n}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:n})),[n])}};return t.scopeName=a.scopeName,t}function Vbe(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function Jbe(...e){return a=>{let t=!1;const n=e.map((e=>{const n=Vbe(e,a);return t||"function"!=typeof n||(t=!0),n}));if(t)return()=>{for(let a=0;a<n.length;a++){const t=n[a];"function"==typeof t?t():Vbe(e[a],null)}}}}function Ube(...e){return r.useCallback(Jbe(...e),e)}function Wbe(e){const a=qbe(e),n=r.forwardRef(((e,n)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Zbe);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 t.jsx(a,{...o,ref:n,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return t.jsx(a,{...o,ref:n,children:i})}));return n.displayName=`${e}.Slot`,n}function qbe(e){const a=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?Jbe(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}Kbe.displayName=zbe.displayName;var $be=Symbol("radix.slottable");function Zbe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===$be}var Ybe=r.createContext(void 0);var Qbe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const n=Wbe(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?n:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});function Xbe(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}var eke,ake="dismissableLayer.update",tke="dismissableLayer.pointerDownOutside",nke="dismissableLayer.focusOutside",ike=r.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),rke=r.forwardRef(((e,a)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:l,onDismiss:u,...c}=e,d=r.useContext(ike),[m,h]=r.useState(null),p=m?.ownerDocument??globalThis?.document,[,g]=r.useState({}),f=Ube(a,(e=>h(e))),v=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),k=m?v.indexOf(m):-1,S=d.layersWithOutsidePointerEventsDisabled.size>0,w=k>=b,A=function(e,a=globalThis?.document){const t=Xbe(e),n=r.useRef(!1),i=r.useRef((()=>{}));return r.useEffect((()=>{const e=e=>{if(e.target&&!n.current){let n=function(){ske(tke,t,r,{discrete:!0})};const r={originalEvent:e};"touch"===e.pointerType?(a.removeEventListener("click",i.current),i.current=n,a.addEventListener("click",i.current,{once:!0})):n()}else a.removeEventListener("click",i.current);n.current=!1},r=window.setTimeout((()=>{a.addEventListener("pointerdown",e)}),0);return()=>{window.clearTimeout(r),a.removeEventListener("pointerdown",e),a.removeEventListener("click",i.current)}}),[a,t]),{onPointerDownCapture:()=>n.current=!0}}((e=>{const a=e.target,t=[...d.branches].some((e=>e.contains(a)));w&&!t&&(o?.(e),l?.(e),e.defaultPrevented||u?.())}),p),C=function(e,a=globalThis?.document){const t=Xbe(e),n=r.useRef(!1);return r.useEffect((()=>{const e=e=>{if(e.target&&!n.current){ske(nke,t,{originalEvent:e},{discrete:!1})}};return a.addEventListener("focusin",e),()=>a.removeEventListener("focusin",e)}),[a,t]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}((e=>{const a=e.target;[...d.branches].some((e=>e.contains(a)))||(s?.(e),l?.(e),e.defaultPrevented||u?.())}),p);return function(e,a=globalThis?.document){const t=Xbe(e);r.useEffect((()=>{const e=e=>{"Escape"===e.key&&t(e)};return a.addEventListener("keydown",e,{capture:!0}),()=>a.removeEventListener("keydown",e,{capture:!0})}),[t,a])}((e=>{k===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))}),p),r.useEffect((()=>{if(m)return n&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(eke=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),oke(),()=>{n&&1===d.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=eke)}}),[m,p,n,d]),r.useEffect((()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),oke())}),[m,d]),r.useEffect((()=>{const e=()=>g({});return document.addEventListener(ake,e),()=>document.removeEventListener(ake,e)}),[]),t.jsx(Qbe.div,{...c,ref:f,style:{pointerEvents:S?w?"auto":"none":void 0,...e.style},onFocusCapture:Ibe(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Ibe(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Ibe(e.onPointerDownCapture,A.onPointerDownCapture)})}));rke.displayName="DismissableLayer";function oke(){const e=new CustomEvent(ake);document.dispatchEvent(e)}function ske(e,a,t,{discrete:n}){const i=t.originalEvent.target,r=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:t});a&&i.addEventListener(e,a,{once:!0}),n?function(e,a){e&&o.flushSync((()=>e.dispatchEvent(a)))}(i,r):i.dispatchEvent(r)}r.forwardRef(((e,a)=>{const n=r.useContext(ike),i=r.useRef(null),o=Ube(a,i);return r.useEffect((()=>{const e=i.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}}),[n.branches]),t.jsx(Qbe.div,{...e,ref:o})})).displayName="DismissableLayerBranch";var lke=0;function uke(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var cke="focusScope.autoFocusOnMount",dke="focusScope.autoFocusOnUnmount",mke={bubbles:!1,cancelable:!0},hke=r.forwardRef(((e,a)=>{const{loop:n=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...l}=e,[u,c]=r.useState(null),d=Xbe(o),m=Xbe(s),h=r.useRef(null),p=Ube(a,(e=>c(e))),g=r.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;r.useEffect((()=>{if(i){let e=function(e){if(g.paused||!u)return;const a=e.target;u.contains(a)?h.current=a:vke(h.current,{select:!0})},a=function(e){if(g.paused||!u)return;const a=e.relatedTarget;null!==a&&(u.contains(a)||vke(h.current,{select:!0}))},t=function(e){if(document.activeElement===document.body)for(const a of e)a.removedNodes.length>0&&vke(u)};document.addEventListener("focusin",e),document.addEventListener("focusout",a);const n=new MutationObserver(t);return u&&n.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",a),n.disconnect()}}}),[i,u,g.paused]),r.useEffect((()=>{if(u){yke.add(g);const a=document.activeElement;if(!u.contains(a)){const t=new CustomEvent(cke,mke);u.addEventListener(cke,d),u.dispatchEvent(t),t.defaultPrevented||(!function(e,{select:a=!1}={}){const t=document.activeElement;for(const n of e)if(vke(n,{select:a}),document.activeElement!==t)return}((e=pke(u),e.filter((e=>"A"!==e.tagName))),{select:!0}),document.activeElement===a&&vke(u))}return()=>{u.removeEventListener(cke,d),setTimeout((()=>{const e=new CustomEvent(dke,mke);u.addEventListener(dke,m),u.dispatchEvent(e),e.defaultPrevented||vke(a??document.body,{select:!0}),u.removeEventListener(dke,m),yke.remove(g)}),0)}}var e}),[u,d,m,g]);const f=r.useCallback((e=>{if(!n&&!i)return;if(g.paused)return;const a=document.activeElement;if("Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&a){const t=e.currentTarget,[i,r]=function(e){const a=pke(e),t=gke(a,e),n=gke(a.reverse(),e);return[t,n]}(t);i&&r?e.shiftKey||a!==r?e.shiftKey&&a===i&&(e.preventDefault(),n&&vke(r,{select:!0})):(e.preventDefault(),n&&vke(i,{select:!0})):a===t&&e.preventDefault()}}),[n,i,g.paused]);return t.jsx(Qbe.div,{tabIndex:-1,...l,ref:p,onKeyDown:f})}));function pke(e){const a=[],t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.disabled||e.hidden||"INPUT"===e.tagName&&"hidden"===e.type?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;t.nextNode();)a.push(t.currentNode);return a}function gke(e,a){for(const t of e)if(!fke(t,{upTo:a}))return t}function fke(e,{upTo:a}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==a&&e===a)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function vke(e,{select:a=!1}={}){if(e&&e.focus){const t=document.activeElement;e.focus({preventScroll:!0}),e!==t&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&a&&e.select()}}hke.displayName="FocusScope";var yke=function(){let e=[];return{add(a){const t=e[0];a!==t&&t?.pause(),e=bke(e,a),e.unshift(a)},remove(a){e=bke(e,a),e[0]?.resume()}}}();function bke(e,a){const t=[...e],n=t.indexOf(a);return-1!==n&&t.splice(n,1),t}var kke=globalThis?.document?r.useLayoutEffect:()=>{},Ske=r[" useId ".trim().toString()]||(()=>{}),wke=0;function Ake(e){const[a,t]=r.useState(Ske());return kke((()=>{t((e=>e??String(wke++)))}),[e]),e||(a?`radix-${a}`:"")}var Cke=r.forwardRef(((e,a)=>{const{children:n,width:i=10,height:r=5,...o}=e;return t.jsx(Qbe.svg,{...o,ref:a,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:t.jsx("polygon",{points:"0,0 30,0 15,10"})})}));Cke.displayName="Arrow";var Mke=Cke;var Tke="Popper",[xke,Eke]=Fbe(Tke),[Nke,_ke]=xke(Tke),Pke=e=>{const{__scopePopper:a,children:n}=e,[i,o]=r.useState(null);return t.jsx(Nke,{scope:a,anchor:i,onAnchorChange:o,children:n})};Pke.displayName=Tke;var jke="PopperAnchor",Lke=r.forwardRef(((e,a)=>{const{__scopePopper:n,virtualRef:i,...o}=e,s=_ke(jke,n),l=r.useRef(null),u=Ube(a,l);return r.useEffect((()=>{s.onAnchorChange(i?.current||l.current)})),i?null:t.jsx(Qbe.div,{...o,ref:u})}));Lke.displayName=jke;var Bke="PopperContent",[Rke,Dke]=xke(Bke),zke=r.forwardRef(((e,a)=>{const{__scopePopper:n,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:m=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:f,...v}=e,y=_ke(Bke,n),[b,k]=r.useState(null),S=Ube(a,(e=>k(e))),[w,A]=r.useState(null),C=function(e){const[a,t]=r.useState(void 0);return kke((()=>{if(e){t({width:e.offsetWidth,height:e.offsetHeight});const a=new ResizeObserver((a=>{if(!Array.isArray(a))return;if(!a.length)return;const n=a[0];let i,r;if("borderBoxSize"in n){const e=n.borderBoxSize,a=Array.isArray(e)?e[0]:e;i=a.inlineSize,r=a.blockSize}else i=e.offsetWidth,r=e.offsetHeight;t({width:i,height:r})}));return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}t(void 0)}),[e]),a}(w),M=C?.width??0,T=C?.height??0,x=i+("center"!==s?"-"+s:""),E="number"==typeof m?m:{top:0,right:0,bottom:0,left:0,...m},N=Array.isArray(d)?d:[d],_=N.length>0,P={padding:E,boundary:N.filter(Ike),altBoundary:_},{refs:j,floatingStyles:L,placement:B,isPositioned:R,middlewareData:D}=p7({strategy:"fixed",placement:x,whileElementsMounted:(...e)=>e7(...e,{animationFrame:"always"===g}),elements:{reference:y.anchor},middleware:[f7({mainAxis:o+T,alignmentAxis:l}),c&&v7({mainAxis:!0,crossAxis:!1,limiter:"partial"===h?y7():void 0,...P}),c&&b7({...P}),k7({...P,apply:({elements:e,rects:a,availableWidth:t,availableHeight:n})=>{const{width:i,height:r}=a.reference,o=e.floating.style;o.setProperty("--radix-popper-available-width",`${t}px`),o.setProperty("--radix-popper-available-height",`${n}px`),o.setProperty("--radix-popper-anchor-width",`${i}px`),o.setProperty("--radix-popper-anchor-height",`${r}px`)}}),w&&w7({element:w,padding:u}),Fke({arrowWidth:M,arrowHeight:T}),p&&S7({strategy:"referenceHidden",...P})]}),[z,O]=Gke(B),K=Xbe(f);kke((()=>{R&&K?.()}),[R,K]);const H=D.arrow?.x,I=D.arrow?.y,F=0!==D.arrow?.centerOffset,[G,V]=r.useState();return kke((()=>{b&&V(window.getComputedStyle(b).zIndex)}),[b]),t.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:R?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:G,"--radix-popper-transform-origin":[D.transformOrigin?.x,D.transformOrigin?.y].join(" "),...D.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(Rke,{scope:n,placedSide:z,onArrowChange:A,arrowX:H,arrowY:I,shouldHideArrow:F,children:t.jsx(Qbe.div,{"data-side":z,"data-align":O,...v,ref:S,style:{...v.style,animation:R?void 0:"none"}})})})}));zke.displayName=Bke;var Oke="PopperArrow",Kke={top:"bottom",right:"left",bottom:"top",left:"right"},Hke=r.forwardRef((function(e,a){const{__scopePopper:n,...i}=e,r=Dke(Oke,n),o=Kke[r.placedSide];return t.jsx("span",{ref:r.onArrowChange,style:{position:"absolute",left:r.arrowX,top:r.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[r.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[r.placedSide],visibility:r.shouldHideArrow?"hidden":void 0},children:t.jsx(Mke,{...i,ref:a,style:{...i.style,display:"block"}})})}));function Ike(e){return null!==e}Hke.displayName=Oke;var Fke=e=>({name:"transformOrigin",options:e,fn(a){const{placement:t,rects:n,middlewareData:i}=a,r=0!==i.arrow?.centerOffset,o=r?0:e.arrowWidth,s=r?0:e.arrowHeight,[l,u]=Gke(t),c={start:"0%",center:"50%",end:"100%"}[u],d=(i.arrow?.x??0)+o/2,m=(i.arrow?.y??0)+s/2;let h="",p="";return"bottom"===l?(h=r?c:`${d}px`,p=-s+"px"):"top"===l?(h=r?c:`${d}px`,p=`${n.floating.height+s}px`):"right"===l?(h=-s+"px",p=r?c:`${m}px`):"left"===l&&(h=`${n.floating.width+s}px`,p=r?c:`${m}px`),{data:{x:h,y:p}}}});function Gke(e){const[a,t="center"]=e.split("-");return[a,t]}var Vke=Pke,Jke=Lke,Uke=zke,Wke=Hke,qke=r.forwardRef(((e,a)=>{const{container:i,...o}=e,[s,l]=r.useState(!1);kke((()=>l(!0)),[]);const u=i||s&&globalThis?.document?.body;return u?n.createPortal(t.jsx(Qbe.div,{...o,ref:a}),u):null}));qke.displayName="Portal";var $ke=r[" useInsertionEffect ".trim().toString()]||kke;function Zke({prop:e,defaultProp:a,onChange:t=()=>{},caller:n}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[t,n]=r.useState(e),i=r.useRef(t),o=r.useRef(a);return $ke((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==t&&(o.current?.(t),i.current=t)}),[t,i]),[t,n,o]}({defaultProp:a,onChange:t}),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,n])}const c=r.useCallback((a=>{if(l){const t=function(e){return"function"==typeof e}(a)?a(e):a;t!==e&&s.current?.(t)}else o(a)}),[l,e,o,s]);return[u,c]}var Yke=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});r.forwardRef(((e,a)=>t.jsx(Qbe.span,{...e,ref:a,style:{...Yke,...e.style}}))).displayName="VisuallyHidden";var Qke=[" ","Enter","ArrowUp","ArrowDown"],Xke=[" ","Enter"],eSe="Select",[aSe,tSe,nSe]=function(e){const n=e+"CollectionProvider",[i,r]=Fbe(n),[o,s]=i(n,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:n,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return t.jsx(o,{scope:n,itemMap:s,collectionRef:r,children:i})};l.displayName=n;const u=e+"CollectionSlot",c=Wbe(u),d=a.forwardRef(((e,a)=>{const{scope:n,children:i}=e,r=Ube(a,s(u,n).collectionRef);return t.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=Wbe(m),g=a.forwardRef(((e,n)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=Ube(n,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),t.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(t){const n=s(e+"CollectionConsumer",t);return a.useCallback((()=>{const e=n.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(n.itemMap.values()).sort(((e,t)=>a.indexOf(e.ref.current)-a.indexOf(t.ref.current)))}),[n.collectionRef,n.itemMap])},r]}(eSe),[iSe,rSe]=Fbe(eSe,[nSe,Eke]),oSe=Eke(),[sSe,lSe]=iSe(eSe),[uSe,cSe]=iSe(eSe),dSe=e=>{const{__scopeSelect:a,children:n,open:i,defaultOpen:o,onOpenChange:s,value:l,defaultValue:u,onValueChange:c,dir:d,name:m,autoComplete:h,disabled:p,required:g,form:f}=e,v=oSe(a),[y,b]=r.useState(null),[k,S]=r.useState(null),[w,A]=r.useState(!1),C=function(e){const a=r.useContext(Ybe);return e||a||"ltr"}(d),[M,T]=Zke({prop:i,defaultProp:o??!1,onChange:s,caller:eSe}),[x,E]=Zke({prop:l,defaultProp:u,onChange:c,caller:eSe}),N=r.useRef(null),_=!y||(f||!!y.closest("form")),[P,j]=r.useState(new Set),L=Array.from(P).map((e=>e.props.value)).join(";");return t.jsx(Vke,{...v,children:t.jsxs(sSe,{required:g,scope:a,trigger:y,onTriggerChange:b,valueNode:k,onValueNodeChange:S,valueNodeHasChildren:w,onValueNodeHasChildrenChange:A,contentId:Ake(),value:x,onValueChange:E,open:M,onOpenChange:T,dir:C,triggerPointerDownPosRef:N,disabled:p,children:[t.jsx(aSe.Provider,{scope:a,children:t.jsx(uSe,{scope:e.__scopeSelect,onNativeOptionAdd:r.useCallback((e=>{j((a=>new Set(a).add(e)))}),[]),onNativeOptionRemove:r.useCallback((e=>{j((a=>{const t=new Set(a);return t.delete(e),t}))}),[]),children:n})}),_?t.jsxs(QSe,{"aria-hidden":!0,required:g,tabIndex:-1,name:m,autoComplete:h,value:x,onChange:e=>E(e.target.value),disabled:p,form:f,children:[void 0===x?t.jsx("option",{value:""}):null,Array.from(P)]},L):null]})})};dSe.displayName=eSe;var mSe="SelectTrigger",hSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,disabled:i=!1,...o}=e,s=oSe(n),l=lSe(mSe,n),u=l.disabled||i,c=Ube(a,l.onTriggerChange),d=tSe(n),m=r.useRef("touch"),[h,p,g]=ewe((e=>{const a=d().filter((e=>!e.disabled)),t=a.find((e=>e.value===l.value)),n=awe(a,e,t);void 0!==n&&l.onValueChange(n.value)})),f=e=>{u||(l.onOpenChange(!0),g()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return t.jsx(Jke,{asChild:!0,...s,children:t.jsx(Qbe.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":XSe(l.value)?"":void 0,...o,ref:c,onClick:Ibe(o.onClick,(e=>{e.currentTarget.focus(),"mouse"!==m.current&&f(e)})),onPointerDown:Ibe(o.onPointerDown,(e=>{m.current=e.pointerType;const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(f(e),e.preventDefault())})),onKeyDown:Ibe(o.onKeyDown,(e=>{const a=""!==h.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),a&&" "===e.key||Qke.includes(e.key)&&(f(),e.preventDefault())}))})})}));hSe.displayName=mSe;var pSe="SelectValue",gSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,className:i,style:r,children:o,placeholder:s="",...l}=e,u=lSe(pSe,n),{onValueNodeHasChildrenChange:c}=u,d=void 0!==o,m=Ube(a,u.onValueNodeChange);return kke((()=>{c(d)}),[c,d]),t.jsx(Qbe.span,{...l,ref:m,style:{pointerEvents:"none"},children:XSe(u.value)?t.jsx(t.Fragment,{children:s}):o})}));gSe.displayName=pSe;var fSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,children:i,...r}=e;return t.jsx(Qbe.span,{"aria-hidden":!0,...r,ref:a,children:i||"▼"})}));fSe.displayName="SelectIcon";var vSe=e=>t.jsx(qke,{asChild:!0,...e});vSe.displayName="SelectPortal";var ySe="SelectContent",bSe=r.forwardRef(((e,a)=>{const n=lSe(ySe,e.__scopeSelect),[i,s]=r.useState();if(kke((()=>{s(new DocumentFragment)}),[]),!n.open){const a=i;return a?o.createPortal(t.jsx(SSe,{scope:e.__scopeSelect,children:t.jsx(aSe.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),a):null}return t.jsx(CSe,{...e,ref:a})}));bSe.displayName=ySe;var kSe=10,[SSe,wSe]=iSe(ySe),ASe=Wbe("SelectContent.RemoveScroll"),CSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:l,side:u,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:f,hideWhenDetached:v,avoidCollisions:y,...b}=e,k=lSe(ySe,n),[S,w]=r.useState(null),[A,C]=r.useState(null),M=Ube(a,(e=>w(e))),[T,x]=r.useState(null),[E,N]=r.useState(null),_=tSe(n),[P,j]=r.useState(!1),L=r.useRef(!1);r.useEffect((()=>{if(S)return Q$(S)}),[S]),r.useEffect((()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??uke()),document.body.insertAdjacentElement("beforeend",e[1]??uke()),lke++,()=>{1===lke&&document.querySelectorAll("[data-radix-focus-guard]").forEach((e=>e.remove())),lke--}}),[]);const B=r.useCallback((e=>{const[a,...t]=_().map((e=>e.ref.current)),[n]=t.slice(-1),i=document.activeElement;for(const r of e){if(r===i)return;if(r?.scrollIntoView({block:"nearest"}),r===a&&A&&(A.scrollTop=0),r===n&&A&&(A.scrollTop=A.scrollHeight),r?.focus(),document.activeElement!==i)return}}),[_,A]),R=r.useCallback((()=>B([T,S])),[B,T,S]);r.useEffect((()=>{P&&R()}),[P,R]);const{onOpenChange:D,triggerPointerDownPosRef:z}=k;r.useEffect((()=>{if(S){let e={x:0,y:0};const a=a=>{e={x:Math.abs(Math.round(a.pageX)-(z.current?.x??0)),y:Math.abs(Math.round(a.pageY)-(z.current?.y??0))}},t=t=>{e.x<=10&&e.y<=10?t.preventDefault():S.contains(t.target)||D(!1),document.removeEventListener("pointermove",a),z.current=null};return null!==z.current&&(document.addEventListener("pointermove",a),document.addEventListener("pointerup",t,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",t,{capture:!0})}}}),[S,D,z]),r.useEffect((()=>{const e=()=>D(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}}),[D]);const[O,K]=ewe((e=>{const a=_().filter((e=>!e.disabled)),t=a.find((e=>e.ref.current===document.activeElement)),n=awe(a,e,t);n&&setTimeout((()=>n.ref.current.focus()))})),H=r.useCallback(((e,a,t)=>{const n=!L.current&&!t;(void 0!==k.value&&k.value===a||n)&&(x(e),n&&(L.current=!0))}),[k.value]),I=r.useCallback((()=>S?.focus()),[S]),F=r.useCallback(((e,a,t)=>{(void 0!==k.value&&k.value===a||!L.current&&!t)&&N(e)}),[k.value]),G="popper"===i?TSe:MSe,V=G===TSe?{side:u,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:f,hideWhenDetached:v,avoidCollisions:y}:{};return t.jsx(SSe,{scope:n,content:S,viewport:A,onViewportChange:C,itemRefCallback:H,selectedItem:T,onItemLeave:I,itemTextRefCallback:F,focusSelectedItem:R,selectedItemText:E,position:i,isPositioned:P,searchRef:O,children:t.jsx(J$,{as:ASe,allowPinchZoom:!0,children:t.jsx(hke,{asChild:!0,trapped:k.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Ibe(o,(e=>{k.trigger?.focus({preventScroll:!0}),e.preventDefault()})),children:t.jsx(rke,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>k.onOpenChange(!1),children:t.jsx(G,{role:"listbox",id:k.contentId,"data-state":k.open?"open":"closed",dir:k.dir,onContextMenu:e=>e.preventDefault(),...b,...V,onPlaced:()=>j(!0),ref:M,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Ibe(b.onKeyDown,(e=>{const a=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),a||1!==e.key.length||K(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let a=_().filter((e=>!e.disabled)).map((e=>e.ref.current));if(["ArrowUp","End"].includes(e.key)&&(a=a.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const t=a.indexOf(e.target);a=a.slice(t+1)}setTimeout((()=>B(a))),e.preventDefault()}}))})})})})})}));CSe.displayName="SelectContentImpl";var MSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,onPlaced:i,...o}=e,s=lSe(ySe,n),l=wSe(ySe,n),[u,c]=r.useState(null),[d,m]=r.useState(null),h=Ube(a,(e=>m(e))),p=tSe(n),g=r.useRef(!1),f=r.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:k}=l,S=r.useCallback((()=>{if(s.trigger&&s.valueNode&&u&&d&&v&&y&&b){const e=s.trigger.getBoundingClientRect(),a=d.getBoundingClientRect(),t=s.valueNode.getBoundingClientRect(),n=b.getBoundingClientRect();if("rtl"!==s.dir){const i=t.left-(n.left-a.left),r=e.width+(e.left-i),o=Math.max(r,a.width),s=window.innerWidth-kSe,l=Hbe(i,[kSe,Math.max(kSe,s-o)]);u.style.minWidth=r+"px",u.style.left=l+"px"}else{const i=window.innerWidth-t.right-(a.right-n.right),r=window.innerWidth-e.right-i,o=e.width+r,s=Math.max(o,a.width),l=window.innerWidth-kSe,c=Hbe(i,[kSe,Math.max(kSe,l-s)]);u.style.minWidth=o+"px",u.style.right=c+"px"}const r=p(),o=window.innerHeight-2*kSe,l=v.scrollHeight,c=window.getComputedStyle(d),m=parseInt(c.borderTopWidth,10),h=parseInt(c.paddingTop,10),f=parseInt(c.borderBottomWidth,10),k=m+h+l+parseInt(c.paddingBottom,10)+f,S=Math.min(5*y.offsetHeight,k),w=window.getComputedStyle(v),A=parseInt(w.paddingTop,10),C=parseInt(w.paddingBottom,10),M=e.top+e.height/2-kSe,T=o-M,x=y.offsetHeight/2,E=m+h+(y.offsetTop+x),N=k-E;if(E<=M){const e=r.length>0&&y===r[r.length-1].ref.current;u.style.bottom="0px";const a=Math.max(T,x+(e?C:0)+(d.clientHeight-v.offsetTop-v.offsetHeight)+f);u.style.height=E+a+"px"}else{const e=r.length>0&&y===r[0].ref.current;u.style.top="0px";const a=Math.max(M,m+v.offsetTop+(e?A:0)+x);u.style.height=a+N+"px",v.scrollTop=E-M+v.offsetTop}u.style.margin=`${kSe}px 0`,u.style.minHeight=S+"px",u.style.maxHeight=o+"px",i?.(),requestAnimationFrame((()=>g.current=!0))}}),[p,s.trigger,s.valueNode,u,d,v,y,b,s.dir,i]);kke((()=>S()),[S]);const[w,A]=r.useState();kke((()=>{d&&A(window.getComputedStyle(d).zIndex)}),[d]);const C=r.useCallback((e=>{e&&!0===f.current&&(S(),k?.(),f.current=!1)}),[S,k]);return t.jsx(xSe,{scope:n,contentWrapper:u,shouldExpandOnScrollRef:g,onScrollButtonChange:C,children:t.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:t.jsx(Qbe.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})}));MSe.displayName="SelectItemAlignedPosition";var TSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,align:i="start",collisionPadding:r=kSe,...o}=e,s=oSe(n);return t.jsx(Uke,{...s,...o,ref:a,align:i,collisionPadding:r,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})}));TSe.displayName="SelectPopperPosition";var[xSe,ESe]=iSe(ySe,{}),NSe="SelectViewport",_Se=r.forwardRef(((e,a)=>{const{__scopeSelect:n,nonce:i,...o}=e,s=wSe(NSe,n),l=ESe(NSe,n),u=Ube(a,s.onViewportChange),c=r.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),t.jsx(aSe.Slot,{scope:n,children:t.jsx(Qbe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ibe(o.onScroll,(e=>{const a=e.currentTarget,{contentWrapper:t,shouldExpandOnScrollRef:n}=l;if(n?.current&&t){const e=Math.abs(c.current-a.scrollTop);if(e>0){const n=window.innerHeight-2*kSe,i=parseFloat(t.style.minHeight),r=parseFloat(t.style.height),o=Math.max(i,r);if(o<n){const i=o+e,r=Math.min(n,i),s=i-r;t.style.height=r+"px","0px"===t.style.bottom&&(a.scrollTop=s>0?s:0,t.style.justifyContent="flex-end")}}}c.current=a.scrollTop}))})})]})}));_Se.displayName=NSe;var PSe="SelectGroup",[jSe,LSe]=iSe(PSe),BSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e,r=Ake();return t.jsx(jSe,{scope:n,id:r,children:t.jsx(Qbe.div,{role:"group","aria-labelledby":r,...i,ref:a})})}));BSe.displayName=PSe;var RSe="SelectLabel",DSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e,r=LSe(RSe,n);return t.jsx(Qbe.div,{id:r.id,...i,ref:a})}));DSe.displayName=RSe;var zSe="SelectItem",[OSe,KSe]=iSe(zSe),HSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,value:i,disabled:o=!1,textValue:s,...l}=e,u=lSe(zSe,n),c=wSe(zSe,n),d=u.value===i,[m,h]=r.useState(s??""),[p,g]=r.useState(!1),f=Ube(a,(e=>c.itemRefCallback?.(e,i,o))),v=Ake(),y=r.useRef("touch"),b=()=>{o||(u.onValueChange(i),u.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return t.jsx(OSe,{scope:n,value:i,disabled:o,textId:v,isSelected:d,onItemTextChange:r.useCallback((e=>{h((a=>a||(e?.textContent??"").trim()))}),[]),children:t.jsx(aSe.ItemSlot,{scope:n,value:i,disabled:o,textValue:m,children:t.jsx(Qbe.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":d&&p,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:f,onFocus:Ibe(l.onFocus,(()=>g(!0))),onBlur:Ibe(l.onBlur,(()=>g(!1))),onClick:Ibe(l.onClick,(()=>{"mouse"!==y.current&&b()})),onPointerUp:Ibe(l.onPointerUp,(()=>{"mouse"===y.current&&b()})),onPointerDown:Ibe(l.onPointerDown,(e=>{y.current=e.pointerType})),onPointerMove:Ibe(l.onPointerMove,(e=>{y.current=e.pointerType,o?c.onItemLeave?.():"mouse"===y.current&&e.currentTarget.focus({preventScroll:!0})})),onPointerLeave:Ibe(l.onPointerLeave,(e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()})),onKeyDown:Ibe(l.onKeyDown,(e=>{""!==c.searchRef?.current&&" "===e.key||(Xke.includes(e.key)&&b()," "===e.key&&e.preventDefault())}))})})})}));HSe.displayName=zSe;var ISe="SelectItemText",FSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,className:i,style:s,...l}=e,u=lSe(ISe,n),c=wSe(ISe,n),d=KSe(ISe,n),m=cSe(ISe,n),[h,p]=r.useState(null),g=Ube(a,(e=>p(e)),d.onItemTextChange,(e=>c.itemTextRefCallback?.(e,d.value,d.disabled))),f=h?.textContent,v=r.useMemo((()=>t.jsx("option",{value:d.value,disabled:d.disabled,children:f},d.value)),[d.disabled,d.value,f]),{onNativeOptionAdd:y,onNativeOptionRemove:b}=m;return kke((()=>(y(v),()=>b(v))),[y,b,v]),t.jsxs(t.Fragment,{children:[t.jsx(Qbe.span,{id:d.textId,...l,ref:g}),d.isSelected&&u.valueNode&&!u.valueNodeHasChildren?o.createPortal(l.children,u.valueNode):null]})}));FSe.displayName=ISe;var GSe="SelectItemIndicator",VSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e;return KSe(GSe,n).isSelected?t.jsx(Qbe.span,{"aria-hidden":!0,...i,ref:a}):null}));VSe.displayName=GSe;var JSe="SelectScrollUpButton",USe=r.forwardRef(((e,a)=>{const n=wSe(JSe,e.__scopeSelect),i=ESe(JSe,e.__scopeSelect),[o,s]=r.useState(!1),l=Ube(a,i.onScrollButtonChange);return kke((()=>{if(n.viewport&&n.isPositioned){let e=function(){s(a.scrollTop>0)};const a=n.viewport;return e(),a.addEventListener("scroll",e),()=>a.removeEventListener("scroll",e)}}),[n.viewport,n.isPositioned]),o?t.jsx($Se,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:a}=n;e&&a&&(e.scrollTop=e.scrollTop-a.offsetHeight)}}):null}));USe.displayName=JSe;var WSe="SelectScrollDownButton",qSe=r.forwardRef(((e,a)=>{const n=wSe(WSe,e.__scopeSelect),i=ESe(WSe,e.__scopeSelect),[o,s]=r.useState(!1),l=Ube(a,i.onScrollButtonChange);return kke((()=>{if(n.viewport&&n.isPositioned){let e=function(){const e=a.scrollHeight-a.clientHeight,t=Math.ceil(a.scrollTop)<e;s(t)};const a=n.viewport;return e(),a.addEventListener("scroll",e),()=>a.removeEventListener("scroll",e)}}),[n.viewport,n.isPositioned]),o?t.jsx($Se,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:a}=n;e&&a&&(e.scrollTop=e.scrollTop+a.offsetHeight)}}):null}));qSe.displayName=WSe;var $Se=r.forwardRef(((e,a)=>{const{__scopeSelect:n,onAutoScroll:i,...o}=e,s=wSe("SelectScrollButton",n),l=r.useRef(null),u=tSe(n),c=r.useCallback((()=>{null!==l.current&&(window.clearInterval(l.current),l.current=null)}),[]);return r.useEffect((()=>()=>c()),[c]),kke((()=>{const e=u().find((e=>e.ref.current===document.activeElement));e?.ref.current?.scrollIntoView({block:"nearest"})}),[u]),t.jsx(Qbe.div,{"aria-hidden":!0,...o,ref:a,style:{flexShrink:0,...o.style},onPointerDown:Ibe(o.onPointerDown,(()=>{null===l.current&&(l.current=window.setInterval(i,50))})),onPointerMove:Ibe(o.onPointerMove,(()=>{s.onItemLeave?.(),null===l.current&&(l.current=window.setInterval(i,50))})),onPointerLeave:Ibe(o.onPointerLeave,(()=>{c()}))})})),ZSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e;return t.jsx(Qbe.div,{"aria-hidden":!0,...i,ref:a})}));ZSe.displayName="SelectSeparator";var YSe="SelectArrow";r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e,r=oSe(n),o=lSe(YSe,n),s=wSe(YSe,n);return o.open&&"popper"===s.position?t.jsx(Wke,{...r,...i,ref:a}):null})).displayName=YSe;var QSe=r.forwardRef((({__scopeSelect:e,value:a,...n},i)=>{const o=r.useRef(null),s=Ube(i,o),l=function(e){const a=r.useRef({value:e,previous:e});return r.useMemo((()=>(a.current.value!==e&&(a.current.previous=a.current.value,a.current.value=e),a.current.previous)),[e])}(a);return r.useEffect((()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,"value").set;if(l!==a&&n){const t=new Event("change",{bubbles:!0});n.call(e,a),e.dispatchEvent(t)}}),[l,a]),t.jsx(Qbe.select,{...n,style:{...Yke,...n.style},ref:s,defaultValue:a})}));function XSe(e){return""===e||void 0===e}function ewe(e){const a=Xbe(e),t=r.useRef(""),n=r.useRef(0),i=r.useCallback((e=>{const i=t.current+e;a(i),function e(a){t.current=a,window.clearTimeout(n.current),""!==a&&(n.current=window.setTimeout((()=>e("")),1e3))}(i)}),[a]),o=r.useCallback((()=>{t.current="",window.clearTimeout(n.current)}),[]);return r.useEffect((()=>()=>window.clearTimeout(n.current)),[]),[t,i,o]}function awe(e,a,t){const n=a.length>1&&Array.from(a).every((e=>e===a[0]))?a[0]:a,i=t?e.indexOf(t):-1;let r=(o=e,s=Math.max(i,0),o.map(((e,a)=>o[(s+a)%o.length])));var o,s;1===n.length&&(r=r.filter((e=>e!==t)));const l=r.find((e=>e.textValue.toLowerCase().startsWith(n.toLowerCase())));return l!==t?l:void 0}QSe.displayName="SelectBubbleInput";var twe=hSe,nwe=fSe,iwe=vSe,rwe=bSe,owe=_Se,swe=DSe,lwe=HSe,uwe=FSe,cwe=VSe,dwe=USe,mwe=qSe,hwe=ZSe;const pwe=dSe,gwe=BSe,fwe=gSe,vwe=r.forwardRef((({className:e,children:a,...n},i)=>t.jsxs(twe,{ref:i,className:XO("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-border/10 px-3 py-2 text-sm shadow-sm ring-offset-background !placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[a,t.jsx(nwe,{asChild:!0,children:t.jsx(nz,{className:"h-4 w-4 opacity-50"})})]})));vwe.displayName=twe.displayName;const ywe=r.forwardRef((({className:e,...a},n)=>t.jsx(dwe,{ref:n,className:XO("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(oz,{className:"h-4 w-4"})})));ywe.displayName=dwe.displayName;const bwe=r.forwardRef((({className:e,...a},n)=>t.jsx(mwe,{ref:n,className:XO("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(nz,{className:"h-4 w-4"})})));bwe.displayName=mwe.displayName;const kwe=r.forwardRef((({className:e,children:a,position:n="popper",...i},r)=>t.jsx(iwe,{children:t.jsxs(rwe,{ref:r,className:XO("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...i,children:[t.jsx(ywe,{}),t.jsx(owe,{className:XO("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),t.jsx(bwe,{})]})})));kwe.displayName=rwe.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(swe,{ref:n,className:XO("px-2 py-1.5 text-sm font-semibold text-muted-foreground",e),...a}))).displayName=swe.displayName;const Swe=r.forwardRef((({className:e,children:a,...n},i)=>t.jsxs(lwe,{ref:i,className:XO("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[t.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(cwe,{children:t.jsx(tz,{className:"h-4 w-4"})})}),t.jsx(uwe,{children:a})]})));Swe.displayName=lwe.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(hwe,{ref:n,className:XO("-mx-1 my-1 h-px bg-muted",e),...a}))).displayName=hwe.displayName;const wwe=(e,t)=>{const[n,i]=a.useState(e);return a.useEffect((()=>{const a=setTimeout((()=>{i(e)}),t);return()=>clearTimeout(a)}),[e,t]),n},Awe=async()=>(await Le(s)).data,Cwe=async(e,a)=>(await Le(s,{method:"PATCH",body:JSON.stringify({uiDefaults:{[e]:a}})})).data,Mwe=["me"],Twe=()=>ye({queryKey:Mwe,queryFn:Awe,...Ae}),xwe=()=>{const e=ce(),{toast:a}=Ve(),t=Twe(),n=be({mutationFn:e=>(async e=>(await Le(s,{method:"PATCH",body:JSON.stringify({website:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Website updated 🚀"})},onError:()=>{a({title:"Failed to update website",description:"Please try again",variant:"destructive"})}}),i=be({mutationFn:e=>(async e=>(await Le(s,{method:"PATCH",body:JSON.stringify({locations:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Locations updated 🚀"})},onError:()=>{a({title:"Failed to update locations",description:"Please try again",variant:"destructive"})}}),r=be({mutationFn:e=>(async e=>(await Le(s,{method:"PATCH",body:JSON.stringify({branding:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Brand settings saved 🚀"})},onError:()=>{a({title:"Failed to save brand settings",description:"Please try again",variant:"destructive"})}}),o=be({mutationFn:e=>(async e=>{const a=e.company.address1?.trim()||e.company.city?.trim()||e.company.stateProvince?.trim()||e.company.zipCode?.trim(),t=e.company.name?.trim();if(!a&&!t)return{success:!0,message:"No updates needed"};const n={locations:[{addressLine1:e.company.address1?.trim()||"",addressLine2:e.company.address2?.trim(),locality:e.company.city?.trim()||"",district:e.company.stateProvince?.trim()||"",postalCode:e.company.zipCode?.trim()||"",countryCode:e.company.country?.trim()||""}],...t&&{name:e.company.name?.trim()}};try{return(await Le(s,{method:"PATCH",body:JSON.stringify(n)})).data}catch(i){throw i}})(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Business settings saved 🚀"})},onError:()=>{a({title:"Failed to save business settings",description:"Please try again",variant:"destructive"})}}),l=be({mutationFn:e=>(async e=>(await Le(s,{method:"PATCH",body:JSON.stringify({uiDefaults:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Business UI defaults updated 🚀"})},onError:()=>{a({title:"Failed to update business UI defaults",description:"Please try again",variant:"destructive"})}}),u=be({mutationFn:e=>Cwe(e.key,e.value),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe})},onError:()=>{a({title:"Failed to update business UI defaults",description:"Please try again",variant:"destructive"})}}),c=be({mutationFn:e=>(async e=>Cwe("emailHelpDialogShow",e))(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe})},onError:()=>{a({title:"Failed to update dialog state",description:"Please try again",variant:"destructive"})}});return{data:t.data,isLoading:t.isLoading,error:t.error,refetch:t.refetch,updateWebsite:n.mutate,updateLocations:i.mutate,updateBrandSettings:r.mutate,updateBusinessSettings:o.mutate,updateBusinessSettingsAsync:o.mutateAsync,updateBusinessUiDefaults:l.mutate,updateBusinessUiDefaultsAsync:l.mutateAsync,updateBusinessUiDefaultProperty:u.mutate,updateBusinessUiDefaultPropertyAsync:u.mutateAsync,toggleEmailHelpDialog:c.mutate,toggleEmailHelpDialogAsync:c.mutateAsync,isUpdatingWebsite:n.isPending,isUpdatingLocations:i.isPending,isUpdatingBrandSettings:r.isPending,isUpdatingBusinessSettings:o.isPending,isUpdatingBusinessUiDefaults:l.isPending,isUpdatingBusinessUiDefaultProperty:u.isPending,isTogglingEmailHelpDialog:c.isPending}},Ewe=({type:e})=>t.jsxs("div",{className:"w-full h-full min-h-[300px] flex flex-col items-center justify-center bg-gradient-to-b from-gray-50 to-white p-8",children:[t.jsx("div",{className:"mb-4 text-gray-300",children:t.jsx("svg",{className:"w-16 h-16",fill:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z"})})}),t.jsxs("p",{className:"text-gray-400 font-medium text-lg text-center mb-2",children:["No ","email"===e?"Email":"SMS"," Preview Available"]}),t.jsxs("p",{className:"text-gray-400 text-sm text-center",children:["Edit your ","email"===e?"Email":"SMS"," template to see a preview here"]})]});var Nwe=(e=>(e.WORKFLOW="workflow",e.RECIPIENTS="recipients",e.INSIGHTS="insights",e))(Nwe||{}),_we=(e=>(e.EMAIL="email",e.SMS="sms",e))(_we||{});const Pwe=[0,100,500],jwe=320;const Lwe=({html:e,onHeightChange:n})=>{const i=a.useRef(null),[r,o]=a.useState(200),s=R5(),{getMergeFields:l,isGetting:u}=Qe(s?.id??void 0),c=function(e,a){return e?e.replace(/\{\{.*?\}\}/g,(e=>{const t=a?.find((a=>a.value===e));return`<span class="merge-field-pill">${t?t.label:e}</span>`})):""}(e,l?.mergeFields?.flatMap((e=>e.entries))??[]);return a.useEffect((()=>{if(!c||!i.current)return;const e=i.current,a=()=>{const a=e.contentDocument||e.contentWindow?.document;if(!a)return;const t=a.createElement("style");t.textContent="html, body { height: auto !important; min-height: 0 !important; }",a.head.appendChild(t);const n=a.createElement("style");n.textContent="\n .merge-field-pill {\n display: inline-block;\n padding: 1px 6px;\n border-radius: 5px;\n background: #f3f4f6;\n color: #6b7280;\n font-size: 0.92em;\n border: 1px solid #e5e7eb;\n font-weight: 500;\n margin: 0 2px;\n vertical-align: middle;\n }\n ",a.head.appendChild(n);const i=a.createElement("script");i.textContent=`\n (function() {\n let lastHeight = 0;\n \n // Calculate max height from various measurements\n function getContentHeight() {\n const { body, documentElement: html } = document;\n return Math.max(\n body.scrollHeight,\n body.offsetHeight,\n html.clientHeight,\n html.scrollHeight,\n html.offsetHeight\n );\n }\n \n function reportHeight() {\n const height = getContentHeight();\n if (height !== lastHeight && height > 0) {\n lastHeight = height;\n window.parent.postMessage({\n type: 'IFRAME_HEIGHT_UPDATE',\n height: height + 10\n }, '*');\n }\n }\n \n // Setup observers for real-time monitoring\n if (window.ResizeObserver) {\n const observer = new ResizeObserver(() => requestAnimationFrame(reportHeight));\n observer.observe(document.body);\n observer.observe(document.documentElement);\n }\n \n // Handle image loading\n document.querySelectorAll('img').forEach(img => {\n if (!img.complete) {\n img.addEventListener('load', reportHeight);\n img.addEventListener('error', reportHeight);\n }\n });\n \n // Watch for DOM changes\n new MutationObserver(() => requestAnimationFrame(reportHeight))\n .observe(document.body, { childList: true, subtree: true });\n \n // Initial checks with progressive delays\n window.addEventListener('load', () => setTimeout(reportHeight, 100));\n document.addEventListener('DOMContentLoaded', reportHeight);\n ${Pwe.map((e=>`setTimeout(reportHeight, ${e});`)).join("\n ")}\n })();\n `,a.body.appendChild(i)},t=a=>{if("IFRAME_HEIGHT_UPDATE"===a.data?.type&&a.source===e.contentWindow){const e=a.data.height;e>0&&(o(e),n?.(e))}};return e.addEventListener("load",a),window.addEventListener("message",t),()=>{e.removeEventListener("load",a),window.removeEventListener("message",t)}}),[c,n,l,u]),t.jsx("div",u&&void 0===l?{className:"flex items-center justify-center py-5",children:t.jsx(lY,{text:["Fetching merge fields..."]})}:{className:"w-full h-full bg-white rounded-lg border-0 overflow-visible",children:e?t.jsx("iframe",{ref:i,title:lH("engage:states.email_preview_title","Email Preview"),srcDoc:c,className:"w-full block",style:{border:"none",backgroundColor:"white",width:"100%",height:`${r}px`,minHeight:"200px",overflow:"hidden"}}):t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(Ewe,{type:"email"})})})},Bwe=[{id:"dynamic-content",title:"Dynamic Content",image:"https://cdn.embedreach.com/assets/engage/merge-tags-demo.gif",imageAlt:"Merge Tags Demo",imageDesc:"Demonstration: Adding merge tags to personalize your emails",selectorTitle:"Dynamic Content",selectorSubtitle:"Dynamic content is a way to insert dynamic content into your email like name, email, or other details.",selectorIcon:t.jsx(Nz,{})},{id:"responsive-design",title:"Responsive Design",image:"https://cdn.embedreach.com/assets/engage/layout-mobile-desktop.gif",imageAlt:"Mobile Desktop Switch Demo",imageDesc:"Demonstration: Switching between mobile and desktop preview modes",selectorTitle:"Responsive Design",selectorSubtitle:"Switch between mobile and desktop preview modes to ensure your emails look great on all devices.",selectorIcon:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(qz,{className:"w-4 h-4"}),t.jsx(jz,{className:"w-4 h-4"})]})}],Rwe=()=>{const{toggleEmailHelpDialog:e,data:n}=xwe(),{toast:i}=Ve(),[r,o]=a.useState("dynamic-content"),s=!1!==n?.uiDefaults?.emailHelpDialogShow,l=Bwe.find((e=>e.id===r))??Bwe[0];return t.jsxs("div",{className:"p-6 overflow-y-auto",children:[t.jsxs("div",{className:"mb-8 text-center",children:[t.jsx("h2",{className:"text-2xl font-semibold mb-2",children:"Email Editor Help Center"}),t.jsx("p",{className:"text-gray-500",children:"Learn how to use our email editor's powerful features"})]}),t.jsx("div",{className:"mb-8 flex flex-col items-center min-h-[340px]",children:t.jsx(wY,{mode:"wait",children:t.jsxs(o5.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},exit:{opacity:0,y:-24},transition:{duration:.3},className:"w-full flex flex-col items-center",children:[t.jsx("h3",{className:"text-lg font-medium mb-2",children:l.title}),t.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-gray-50 w-full max-w-2xl",children:[t.jsx("img",{src:l.image,alt:l.imageAlt,className:"w-full shadow-lg max-w-md mx-auto"}),t.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/50 to-transparent p-4",children:t.jsx("p",{className:"text-white text-sm",children:l.imageDesc})})]})]},l.id)})}),t.jsx("div",{className:"flex flex-col gap-4 sm:flex-row sm:gap-6 max-w-xl mx-auto",children:Bwe.map((e=>t.jsx("div",{className:"flex-1",children:t.jsx(G5,{onClick:()=>o(e.id),title:e.selectorTitle,subtitle:e.selectorSubtitle,icon:e.selectorIcon,selected:r===e.id})},e.id)))}),s&&t.jsx("div",{className:"flex justify-center pt-4",children:t.jsx(H5,{size:"sm",onClick:()=>{e(!1),i({title:"Email editor help dialog will not show again!"})},children:"Don't show me again"})})]})},Dwe=({type:e})=>t.jsxs("div",{className:"flex items-start space-x-2 text-sm text-gray-600",children:[t.jsx("svg",{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),t.jsxs("span",{children:["Please configure at least one ",e," sender before editing the template"]})]}),zwe=({containerRef:e,stripoDialogDimensions:n,showSaving:i})=>(a.useEffect((()=>{const a=a=>{const t=e.current;if(!t)return;const n=t.querySelector("ui-editor");if(!n)return;const i=n.shadowRoot;if(!i)return;const r=i.host.getBoundingClientRect();const o=function(e){for(;e;){const a=getComputedStyle(e);if(("auto"===a.overflowY||"scroll"===a.overflowY)&&e.scrollHeight>e.clientHeight)return e;e=e.parentElement}return null}(i.elementFromPoint(a.clientX-r.left,a.clientY-r.top))||i.firstElementChild;o&&(o.scrollTop+=a.deltaY,o.scrollLeft+=a.deltaX,a.preventDefault())},t=e.current;return t&&t.addEventListener("wheel",a,{passive:!1}),()=>{t&&t.removeEventListener("wheel",a)}}),[e]),a.useEffect((()=>{const e="stripo-service-element-hider";let a=document.getElementById(e);return a||(a=document.createElement("style"),a.id=e,document.head.appendChild(a)),a.textContent='\n /* Hide service elements with title attributes */\n #stripoEditorContainer small.service-element[title],\n #stripoEditorContainer .service-element[title],\n #stripoEditorContainer span.service-element[title],\n #stripoEditorContainer [class*="service-element"][title] {\n display: none !important;\n visibility: hidden !important;\n opacity: 0 !important;\n position: absolute !important;\n left: -9999px !important;\n top: -9999px !important;\n width: 0 !important;\n height: 0 !important;\n overflow: hidden !important;\n pointer-events: none !important;\n }\n \n /* Also hide elements with our custom class */\n .stripo-hidden-service-element {\n display: none !important;\n visibility: hidden !important;\n opacity: 0 !important;\n position: absolute !important;\n left: -9999px !important;\n top: -9999px !important;\n width: 0 !important;\n height: 0 !important;\n overflow: hidden !important;\n pointer-events: none !important;\n }\n ',()=>{a&&a.parentNode&&a.parentNode.removeChild(a)}}),[]),a.useEffect((()=>{const a=e.current;if(!a)return;const t=()=>{const e=a.querySelector("ui-editor");if(!e)return null;const t=e.shadowRoot;return t||null},n=()=>{const e=t();if(!e)return;["small.service-element[title]",".service-element[title]","span.service-element[title]",'[class*="service-element"][title]'].forEach((a=>{e.querySelectorAll(a).forEach((e=>{const a=e,t=a.getAttribute("title")||"";/^\{\{.*\}\}$/.test(t.trim())&&(a.style.display="none",a.style.visibility="hidden",a.style.opacity="0",a.style.position="absolute",a.style.left="-9999px",a.style.top="-9999px",a.classList.add("stripo-hidden-service-element"),a.setAttribute("style",a.getAttribute("style")+"; display: none !important; visibility: hidden !important; opacity: 0 !important;"))}))}))};let i=null;let r=0;const o=setInterval((()=>{t()?(n(),(()=>{const e=t();e&&(i&&i.disconnect(),i=new MutationObserver((e=>{let a=!1;e.forEach(((e,t)=>{"childList"===e.type&&e.addedNodes.length>0&&(a=!0)})),a&&setTimeout((()=>{n()}),10)})),i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","title"]}))})(),clearInterval(o)):(r++,r>20&&clearInterval(o))}),100),s=setInterval((()=>{n()}),2e3);return()=>{i&&i.disconnect(),clearInterval(s),clearInterval(o)}}),[e]),t.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center",children:[t.jsx("div",{id:"externalSystemContainer",className:"flex items-center px-4 py-2"}),i&&t.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-black/50 flex items-center justify-center z-50",children:t.jsx(lY,{textColor:"text-white",text:["Saving..."]})}),t.jsx("div",{id:"stripoEditorContainer",ref:e,style:{width:n.width-75,height:n.height-75},className:"z-10"})]})),Owe="UiEditorScript",Kwe=e=>new Promise(((a,t)=>{const n=()=>{let t;e.forceRecreate&&(t=!0),window.UIEditor&&(window.UIEditor.initEditor(e.container,{...t&&{forceRecreate:t},metadata:{emailId:e.emailId},html:e.html,css:e.css,locale:"en",onTokenRefreshRequest:e=>{Promise.resolve().then((async()=>{try{const{token:a}=await(async()=>(await Le(`${m}/token`)).data)();e(a)}catch(a){}}))},messageSettingsEnabled:!1,conditionsEnabled:!1,syncModulesEnabled:!1,notifications:{info:console.info,error:console.error,warn:console.warn,success:console.log},mergeTags:e.mergeFields,mobileViewButtonSelector:".toggle-mobile-button",desktopViewButtonSelector:".toggle-desktop-button"}),a(void 0))};if(document.getElementById(Owe))n();else{const e=document.createElement("script");e.id=Owe,e.type="module",e.src="https://plugins.stripo.email/resources/uieditor/rev/2.21.0/UIEditor.js",e.onload=()=>{window.UIEditor?n():t(new Error("UIEditor not found after script load"))},e.onerror=e=>{t(e)},document.head.appendChild(e)}})),Hwe=({automation:e,setShowStripoEditor:n,saveClicked:i,setSaveClicked:r,stripoDialogDimensions:o,mergeFieldsResponse:s,cancelClicked:l,setCancelClicked:u,actionId:c})=>{const d=a.useRef(!1),m=a.useRef(null),{data:h,isLoading:p}=(e=>{const{automationId:a,actionId:t}=e;return ye({queryKey:Ue.templateForActionId(a,t),queryFn:()=>qe({automationId:a,actionId:t}),...Ce})})({automationId:e.id,actionId:c}),{data:g,isLoading:f}=(()=>{const e=ce();return{...ye({queryKey:Ue.editorData(),queryFn:We,...Ae}),invalidateEditorData:()=>e.invalidateQueries({queryKey:Ue.editorData()})}})(),[v,y]=a.useState(!1),[b,k]=a.useState(!1),{updateCommunicationGroup:S}=Ye(),w=a.useCallback((()=>{r(!1),u(!1),y(!1),k(!1),n(!1)}),[r,u,y,k,n]);return a.useEffect((()=>{if(i&&window.UIEditor&&h?.communicationGroupId&&window.StripoEditorApi?.actionsApi){window.StripoEditorApi.actionsApi.compileEmail({callback:function(e,a){e||(S({groupId:h.communicationGroupId,params:{emailHtmlBody:a}}),k(!0))},minimize:!0,mergeTags:[],forceAmp:!1,resetDataSavedFlag:!1,disableLineHeightsReplace:!0});window.StripoEditorApi.actionsApi.save((function(e){e||y(!0)}))}}),[i,m,r,n,h,S]),a.useEffect((()=>{(async()=>{v&&b&&(window.UIEditor&&window.UIEditor.removeEditor&&"function"==typeof window.UIEditor.removeEditor&&window.UIEditor.removeEditor(),w())})()}),[v,b,n,r,w]),a.useEffect((()=>{l&&(window.UIEditor&&window.UIEditor.removeEditor&&"function"==typeof window.UIEditor.removeEditor&&window.UIEditor.removeEditor(),w())}),[l,w]),a.useEffect((()=>{g?.businessId&&m.current&&h&&(d.current||(Kwe({emailId:h.communicationGroupId,html:h.html||"<div></div>",css:h.css||"",container:m.current,businessId:g.businessId,mergeFields:s.mergeFields||[],forceRecreate:h.forceRecreate}).catch((e=>{})),d.current=!0))}),[g,s,h]),t.jsx("div",p||f||!g||!h?{className:"w-full h-full flex flex-col items-center justify-center",children:t.jsx(lY,{text:["Loading editor..."]})}:{className:"w-full h-full flex flex-col",children:t.jsx(zwe,{containerRef:m,stripoDialogDimensions:o,showSaving:i})})},Iwe=({mergeFieldsResponse:e,emailChannelSendersWithChannelAccounts:n})=>{const i=R5(),r=B5(),{updateCommunicationGroup:o}=Ye(),{refetchAutomation:s}=ta(r?.id||""),{channelSenders:l}=Jre(),{channelAccounts:u}=Fre(),{state:{selectedActionId:c}}=a.useContext(S5),{state:{replyToSettingsText:d,replyToSettingsLink:m,fromNameSettingsText:h,fromNameSettingsLink:p}}=a.useContext(rY),{data:g,isLoading:f}=xwe(),[v,y]=a.useState(!1),[b,k]=a.useState(i?.emailChannelSenderId||null),[S,w]=a.useState(i?.emailSubject||null),[A,C]=a.useState(i?.emailPreviewText||null),[M,T]=a.useState(i?.emailHtmlBody||null),[x,E]=a.useState(!1),[N,_]=a.useState(!1),[P,j]=a.useState(!1),[L,B]=a.useState(""),[R,D]=a.useState(""),[z,O]=a.useState(!1),K=a.useRef(!0),[H,I]=a.useState(!0),[F,G]=a.useState(!1),[V,J]=a.useState({width:0,height:0});a.useEffect((()=>{g&&null===z&&x&&(g?.uiDefaults?g?.uiDefaults?.emailHelpDialogShow&&!z&&O(!0):O(!0))}),[g,g?.uiDefaults?.emailHelpDialogShow,z,x]);const U=wwe(S,500),W=wwe(A,500),q=a.useMemo((()=>n||l?.results?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=u?.results?.find((a=>a.id===e.channelAccountId));return a&&(a.channelAccountMetadata.type===Gre.REACH_MANAGED||a.channelAccountMetadata.type===Gre.REACH_MANAGED_SES)?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`}]:[]}))||[]),[n,l?.results,u?.results]),$=a.useRef(null);return a.useEffect((()=>{const e=setTimeout((()=>{K.current=!1}),500);return()=>clearTimeout(e)}),[]),a.useEffect((()=>{i?.emailHtmlBody&&T(i.emailHtmlBody)}),[i?.emailHtmlBody,s]),a.useEffect((()=>{if(v){const e=setTimeout((()=>{y(!1)}),2e3);return()=>clearTimeout(e)}}),[v]),a.useEffect((()=>{const e=()=>{J({width:window.innerWidth,height:window.innerHeight})};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),a.useEffect((()=>{if(!K.current&&b&&U&&M&&i?.id){y(!0);(async()=>{try{o({groupId:i.id,params:{emailChannelSenderId:b,emailHtmlBody:M,emailSubject:U,...W&&{emailPreviewText:W}}})}catch(e){}finally{y(!1)}})()}}),[b,U,W,M,i?.id,o]),a.useEffect((()=>{if(l?.results&&b){const e=l.results.find((e=>e.id===b));e&&(F&&!H||D(e.channelSenderMetadata.emailReplyTo),H&&B(e.channelSenderMetadata.emailFromName),I(!1))}}),[l?.results,b,F,H]),a.useEffect((()=>{if(l?.results&&!b){const e=l.results.filter((e=>e.channelSenderMetadata.userPart));if(e[0]){const a=e[0];k(a.id),o({groupId:i?.id||"",params:{emailChannelSenderId:a.id}})}}}),[l?.results,b,i?.id,o]),a.useEffect((()=>{!1===x&&i?.id&&s()}),[x,i?.id,s]),u&&l&&c&&!f?t.jsxs("div",{className:"relative",children:[t.jsx(ZZ,{open:z,onOpenChange:O,children:t.jsxs(eY,{className:"max-h-[86vh] gap-0 overflow-visible max-w-3xl w-full h-full",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Email Preview Help"}),t.jsx(iY,{children:"Learn more about the email preview and how to use it to create your email."})]}),t.jsx(Rwe,{})]})}),t.jsx(ZZ,{open:x,onOpenChange:E,children:t.jsxs(eY,{className:"min-w-[100vw] min-h-[100vh]",hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault()},children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Email Editor"}),t.jsx(iY,{children:"Learn more about the email editor and how to use it to create your email."})]}),t.jsxs("div",{className:"w-full h-full",children:[t.jsxs("div",{className:"flex justify-between items-center p-1 border-b",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h2",{className:"text-lg font-medium",children:"Email Editor"}),t.jsx(H5,{size:"sm",onClick:()=>O(!0),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium text-sm",children:"Help"}),t.jsx(V5.InfoIcon,{className:"w-4 h-4"})]})})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(Nbe,{})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(H5,{variant:"destructive",onClick:()=>{j(!0)},className:"text-sm px-3 py-1 rounded",children:"Cancel"}),t.jsx(H5,{onClick:()=>_(!0),className:"text-sm px-3 py-1 rounded",children:"Save"})]})]}),r&&t.jsx(Hwe,{cancelClicked:P,setCancelClicked:j,showStripoEditor:x,automation:r,setShowStripoEditor:E,saveClicked:N,setSaveClicked:_,stripoDialogDimensions:V,mergeFieldsResponse:e,actionId:c})]})]})}),t.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(Kbe,{className:"text-foreground",children:"From Email"}),t.jsxs(pwe,{onValueChange:e=>{k(e),I(!0),G(!1)},value:b??void 0,disabled:v,children:[t.jsx(vwe,{children:t.jsx(fwe,{placeholder:"Select email",className:"text-muted-foreground",children:b?q?.find((e=>e.channelSenderId===b))?.fullDomain:""})}),t.jsx(kwe,{children:q?.map((e=>t.jsx(Swe,{value:e.channelSenderId,children:e.fullDomain},e.channelSenderId)))})]})]}),t.jsxs("div",{children:[t.jsx(Kbe,{children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:["From Name",t.jsx(Fue,{title:h||"From name can be configured under settings in the home screen",link:p?{url:p}:void 0})]})}),t.jsx(gte,{value:L??"",className:"text-muted-foreground",disabled:!0})]}),t.jsxs("div",{children:[t.jsx(Kbe,{children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:["Reply To Email",t.jsx(Fue,{title:d||"Reply to email can be configured under settings in the home screen",link:m?{url:m}:void 0})]})}),t.jsx(gte,{value:R??(b?q?.find((e=>e.channelSenderId===b))?.fullDomain:""),className:"text-muted-foreground",disabled:!0})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-0 py-1",children:[t.jsx(Kbe,{className:"text-foreground",children:"Subject"}),t.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),t.jsx(Ebe,{value:S,onChange:w,mergeFieldsResponse:e,placeholder:"Enter email subject",className:"text-muted-foreground",ariaLabel:"Insert merge field into subject"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsx(Kbe,{className:"text-foreground",children:"Preview Text"}),t.jsx(Fue,{title:"This text will be used for the preview text of the email in the inbox"})]}),t.jsx(Ebe,{value:A,onChange:C,className:"text-muted-foreground",mergeFieldsResponse:e})]})]}),t.jsxs("div",{className:"rounded-none p-4 h-full flex flex-col",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h3",{className:"font-medium",children:"Preview"}),t.jsxs("div",{children:[t.jsx(H5,{onClick:()=>E(!0),className:"text-sm px-3 py-1 rounded",disabled:v||0===(n?.length??0),children:"Edit"}),0===(n?.length??0)&&t.jsx("div",{className:"relative inline-block",children:t.jsx("div",{className:"absolute right-0 top-full mt-2 w-64 p-3 bg-white border rounded-lg shadow-lg z-10",children:t.jsx(Dwe,{type:"email"})})})]})]}),t.jsx("div",{className:"flex-1 w-full overflow-auto",ref:$,children:t.jsx(Lwe,{html:M??""})})]})]})]}):t.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:t.jsx(lY,{text:["Fetching Email Preview..."]})})};var Fwe=(e=>(e.CUSTOM="custom",e.MANAGED="managed",e))(Fwe||{}),Gwe=(e=>(e.EditAudience="edit-audience",e.EditTime="edit-time",e))(Gwe||{}),Vwe=(e=>(e.EMAIL="email",e.SMS="sms",e))(Vwe||{});const Jwe=({title:e,type:n})=>{const i=R5(),r=B5(),{toast:o}=Ve(),[s,l]=a.useState(!1),{resetCommunicationGroupToDefault:u,isPending:c}=ea(),d=!!i&&(i.type===Fwe.MANAGED&&(n===_we.SMS?i.updatedFromDefault?.text_message_body:i.updatedFromDefault?.email_text_body||i.updatedFromDefault?.email_html_body)),m=n===_we.EMAIL?"Email":"SMS";return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h4",{className:"text-xl font-medium text-foreground",children:e}),t.jsx("div",{className:"flex items-center gap-2",children:d&&t.jsx(t.Fragment,{children:c?t.jsx(lY,{}):t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>l(!0),children:"Reset To Default"})})})]}),t.jsx(ZZ,{open:s,onOpenChange:l,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsxs(aY,{children:[t.jsx(nY,{className:"text-xl font-semibold",children:"Reset To Default"}),t.jsxs(iY,{className:"text-base text-muted-foreground",children:["Are you sure you want to reset this ",m.toLowerCase()," ","template to its default state? This action cannot be undone."]})]}),t.jsxs(tY,{className:"flex flex-row justify-end gap-3 mt-6",children:[t.jsx(H5,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),t.jsx(H5,{variant:"destructive",onClick:async()=>{i&&r?u({communicationGroupId:i.id,automationId:r.id,type:n===_we.EMAIL?"email":"sms"},{onSuccess:()=>{o({title:lH("engage:success.communication_reset","Communication reset to default!")}),l(!1)},onSettled:()=>{l(!1)},onError:()=>{o({title:"Error updating",description:"No sender found",variant:"destructive"})}}):o({title:"Error updating",description:"No sender found",variant:"destructive"})},children:"Reset To Default"})]})]})})]})},Uwe=e=>{const{channelSenders:a,channelAccounts:t}=e;return a?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=t?.find((a=>a.id===e.channelAccountId));return a&&a.channelAccountMetadata.type===Gre.REACH_MANAGED?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,baseDomain:e.channelSenderMetadata.baseDomain??void 0,channelSender:e}]:[]}))||[]},Wwe=()=>{const e=a.useRef(null),n=R5(),{channelSenders:i}=Jre(),{channelAccounts:r}=Fre(),{getMergeFields:o,isGetting:s}=Qe(n?.id??void 0),l=a.useMemo((()=>Uwe({channelSenders:i?.results??[],channelAccounts:r?.results??[]})),[i?.results,r?.results]);return!s&&o&&l?t.jsxs("div",{className:"bg-card text-card-foreground rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",ref:e,children:[t.jsx(Jwe,{title:"Email Campaign",type:_we.EMAIL}),t.jsx(Iwe,{mergeFieldsResponse:o,emailChannelSendersWithChannelAccounts:l})]}):t.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-card text-card-foreground rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:t.jsx(lY,{text:["Fetching Content..."]})})};var qwe=e=>"checkbox"===e.type,$we=e=>e instanceof Date,Zwe=e=>null==e;const Ywe=e=>"object"==typeof e;var Qwe=e=>!Zwe(e)&&!Array.isArray(e)&&Ywe(e)&&!$we(e),Xwe=e=>Qwe(e)&&e.target?qwe(e.target)?e.target.checked:e.target.value:e,eAe=(e,a)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(a)),aAe="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function tAe(e){let a;const t=Array.isArray(e),n="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)a=new Date(e);else if(e instanceof Set)a=new Set(e);else{if(aAe&&(e instanceof Blob||n)||!t&&!Qwe(e))return e;if(a=t?[]:{},t||(e=>{const a=e.constructor&&e.constructor.prototype;return Qwe(a)&&a.hasOwnProperty("isPrototypeOf")})(e))for(const t in e)e.hasOwnProperty(t)&&(a[t]=tAe(e[t]));else a=e}return a}var nAe=e=>Array.isArray(e)?e.filter(Boolean):[],iAe=e=>void 0===e,rAe=(e,a,t)=>{if(!a||!Qwe(e))return t;const n=nAe(a.split(/[,[\].]+?/)).reduce(((e,a)=>Zwe(e)?e:e[a]),e);return iAe(n)||n===e?iAe(e[a])?t:e[a]:n},oAe=e=>"boolean"==typeof e,sAe=e=>/^\w*$/.test(e),lAe=e=>nAe(e.replace(/["|']|\]/g,"").split(/\.|\[/)),uAe=(e,a,t)=>{let n=-1;const i=sAe(a)?[a]:lAe(a),r=i.length,o=r-1;for(;++n<r;){const a=i[n];let r=t;if(n!==o){const t=e[a];r=Qwe(t)||Array.isArray(t)?t:isNaN(+i[n+1])?{}:[]}if("__proto__"===a||"constructor"===a||"prototype"===a)return;e[a]=r,e=e[a]}};const cAe="blur",dAe="focusout",mAe="change",hAe="onBlur",pAe="onChange",gAe="onSubmit",fAe="onTouched",vAe="all",yAe="max",bAe="min",kAe="maxLength",SAe="minLength",wAe="pattern",AAe="required",CAe="validate",MAe=a.createContext(null),TAe=()=>a.useContext(MAe);var xAe=(e,a,t,n=!0)=>{const i={defaultValues:a._defaultValues};for(const r in e)Object.defineProperty(i,r,{get:()=>{const i=r;return a._proxyFormState[i]!==vAe&&(a._proxyFormState[i]=!n||vAe),t&&(t[i]=!0),e[i]}});return i},EAe=e=>Zwe(e)||!Ywe(e);function NAe(e,a){if(EAe(e)||EAe(a))return e===a;if($we(e)&&$we(a))return e.getTime()===a.getTime();const t=Object.keys(e),n=Object.keys(a);if(t.length!==n.length)return!1;for(const i of t){const t=e[i];if(!n.includes(i))return!1;if("ref"!==i){const e=a[i];if($we(t)&&$we(e)||Qwe(t)&&Qwe(e)||Array.isArray(t)&&Array.isArray(e)?!NAe(t,e):t!==e)return!1}}return!0}const _Ae=(e,t)=>{const n=a.useRef(t);NAe(t,n.current)||(n.current=t),a.useEffect(e,n.current)};var PAe=e=>"string"==typeof e,jAe=(e,a,t,n,i)=>PAe(e)?(n&&a.watch.add(e),rAe(t,e,i)):Array.isArray(e)?e.map((e=>(n&&a.watch.add(e),rAe(t,e)))):(n&&(a.watchAll=!0),t);function LAe(e){const t=TAe(),{name:n,disabled:i,control:r=t.control,shouldUnregister:o}=e,s=eAe(r._names.array,n),l=function(e){const t=TAe(),{control:n=t.control,name:i,defaultValue:r,disabled:o,exact:s}=e||{},[l,u]=a.useState(n._getWatch(i,r));return _Ae((()=>n._subscribe({name:i,formState:{values:!0},exact:s,callback:e=>!o&&u(jAe(i,n._names,e.values||n._formValues,!1,r))})),[i,r,o,s]),a.useEffect((()=>n._removeUnmounted())),l}({control:r,name:n,defaultValue:rAe(r._formValues,n,rAe(r._defaultValues,n,e.defaultValue)),exact:!0}),u=function(e){const t=TAe(),{control:n=t.control,disabled:i,name:r,exact:o}=e||{},[s,l]=a.useState(n._formState),u=a.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return _Ae((()=>n._subscribe({name:r,formState:u.current,exact:o,callback:e=>{!i&&l({...n._formState,...e})}})),[r,i,o]),a.useEffect((()=>{u.current.isValid&&n._setValid(!0)}),[n]),a.useMemo((()=>xAe(s,n,u.current,!1)),[s,n])}({control:r,name:n,exact:!0}),c=a.useRef(e),d=a.useRef(r.register(n,{...e.rules,value:l,...oAe(e.disabled)?{disabled:e.disabled}:{}})),m=a.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!rAe(u.errors,n)},isDirty:{enumerable:!0,get:()=>!!rAe(u.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!rAe(u.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!rAe(u.validatingFields,n)},error:{enumerable:!0,get:()=>rAe(u.errors,n)}})),[u,n]),h=a.useCallback((e=>d.current.onChange({target:{value:Xwe(e),name:n},type:mAe})),[n]),p=a.useCallback((()=>d.current.onBlur({target:{value:rAe(r._formValues,n),name:n},type:cAe})),[n,r._formValues]),g=a.useCallback((e=>{const a=rAe(r._fields,n);a&&e&&(a._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:a=>e.setCustomValidity(a),reportValidity:()=>e.reportValidity()})}),[r._fields,n]),f=a.useMemo((()=>({name:n,value:l,...oAe(i)||u.disabled?{disabled:u.disabled||i}:{},onChange:h,onBlur:p,ref:g})),[n,i,u.disabled,h,p,g,l]);return a.useEffect((()=>{const e=r._options.shouldUnregister||o;r.register(n,{...c.current.rules,...oAe(c.current.disabled)?{disabled:c.current.disabled}:{}});const a=(e,a)=>{const t=rAe(r._fields,e);t&&t._f&&(t._f.mount=a)};if(a(n,!0),e){const e=tAe(rAe(r._options.defaultValues,n));uAe(r._defaultValues,n,e),iAe(rAe(r._formValues,n))&&uAe(r._formValues,n,e)}return!s&&r.register(n),()=>{(s?e&&!r._state.action:e)?r.unregister(n):a(n,!1)}}),[n,r,s,o]),a.useEffect((()=>{r._setDisabledField({disabled:i,name:n})}),[i,n,r]),a.useMemo((()=>({field:f,formState:u,fieldState:m})),[f,u,m])}const BAe=e=>e.render(LAe(e));var RAe=(e,a,t,n,i)=>a?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[n]:i||!0}}:{},DAe=e=>Array.isArray(e)?e:[e],zAe=()=>{let e=[];return{get observers(){return e},next:a=>{for(const t of e)t.next&&t.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter((e=>e!==a))}}),unsubscribe:()=>{e=[]}}},OAe=e=>Qwe(e)&&!Object.keys(e).length,KAe=e=>"file"===e.type,HAe=e=>"function"==typeof e,IAe=e=>{if(!aAe)return!1;const a=e?e.ownerDocument:0;return e instanceof(a&&a.defaultView?a.defaultView.HTMLElement:HTMLElement)},FAe=e=>"select-multiple"===e.type,GAe=e=>"radio"===e.type,VAe=e=>IAe(e)&&e.isConnected;function JAe(e,a){const t=Array.isArray(a)?a:sAe(a)?[a]:lAe(a),n=1===t.length?e:function(e,a){const t=a.slice(0,-1).length;let n=0;for(;n<t;)e=iAe(e)?n++:e[a[n++]];return e}(e,t),i=t.length-1;return n&&delete n[t[i]],0!==i&&(Qwe(n)&&OAe(n)||Array.isArray(n)&&function(e){for(const a in e)if(e.hasOwnProperty(a)&&!iAe(e[a]))return!1;return!0}(n))&&JAe(e,t.slice(0,-1)),e}var UAe=e=>{for(const a in e)if(HAe(e[a]))return!0;return!1};function WAe(e,a={}){const t=Array.isArray(e);if(Qwe(e)||t)for(const n in e)Array.isArray(e[n])||Qwe(e[n])&&!UAe(e[n])?(a[n]=Array.isArray(e[n])?[]:{},WAe(e[n],a[n])):Zwe(e[n])||(a[n]=!0);return a}function qAe(e,a,t){const n=Array.isArray(e);if(Qwe(e)||n)for(const i in e)Array.isArray(e[i])||Qwe(e[i])&&!UAe(e[i])?iAe(a)||EAe(t[i])?t[i]=Array.isArray(e[i])?WAe(e[i],[]):{...WAe(e[i])}:qAe(e[i],Zwe(a)?{}:a[i],t[i]):t[i]=!NAe(e[i],a[i]);return t}var $Ae=(e,a)=>qAe(e,a,WAe(a));const ZAe={value:!1,isValid:!1},YAe={value:!0,isValid:!0};var QAe=e=>{if(Array.isArray(e)){if(e.length>1){const a=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:a,isValid:!!a.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!iAe(e[0].attributes.value)?iAe(e[0].value)||""===e[0].value?YAe:{value:e[0].value,isValid:!0}:YAe:ZAe}return ZAe},XAe=(e,{valueAsNumber:a,valueAsDate:t,setValueAs:n})=>iAe(e)?e:a?""===e?NaN:e?+e:e:t&&PAe(e)?new Date(e):n?n(e):e;const eCe={isValid:!1,value:null};var aCe=e=>Array.isArray(e)?e.reduce(((e,a)=>a&&a.checked&&!a.disabled?{isValid:!0,value:a.value}:e),eCe):eCe;function tCe(e){const a=e.ref;return KAe(a)?a.files:GAe(a)?aCe(e.refs).value:FAe(a)?[...a.selectedOptions].map((({value:e})=>e)):qwe(a)?QAe(e.refs).value:XAe(iAe(a.value)?e.ref.value:a.value,e)}var nCe=e=>e instanceof RegExp,iCe=e=>iAe(e)?e:nCe(e)?e.source:Qwe(e)?nCe(e.value)?e.value.source:e.value:e,rCe=e=>({isOnSubmit:!e||e===gAe,isOnBlur:e===hAe,isOnChange:e===pAe,isOnAll:e===vAe,isOnTouch:e===fAe});const oCe="AsyncFunction";var sCe=(e,a,t)=>!t&&(a.watchAll||a.watch.has(e)||[...a.watch].some((a=>e.startsWith(a)&&/^\.\w+/.test(e.slice(a.length)))));const lCe=(e,a,t,n)=>{for(const i of t||Object.keys(e)){const t=rAe(e,i);if(t){const{_f:e,...r}=t;if(e){if(e.refs&&e.refs[0]&&a(e.refs[0],i)&&!n)return!0;if(e.ref&&a(e.ref,e.name)&&!n)return!0;if(lCe(r,a))break}else if(Qwe(r)&&lCe(r,a))break}}};function uCe(e,a,t){const n=rAe(e,t);if(n||sAe(t))return{error:n,name:t};const i=t.split(".");for(;i.length;){const n=i.join("."),r=rAe(a,n),o=rAe(e,n);if(r&&!Array.isArray(r)&&t!==n)return{name:t};if(o&&o.type)return{name:n,error:o};i.pop()}return{name:t}}var cCe=(e,a,t)=>{const n=DAe(rAe(e,t));return uAe(n,"root",a[t]),uAe(e,t,n),e},dCe=e=>PAe(e);function mCe(e,a,t="validate"){if(dCe(e)||Array.isArray(e)&&e.every(dCe)||oAe(e)&&!e)return{type:t,message:dCe(e)?e:"",ref:a}}var hCe=e=>Qwe(e)&&!nCe(e)?e:{value:e,message:""},pCe=async(e,a,t,n,i,r)=>{const{ref:o,refs:s,required:l,maxLength:u,minLength:c,min:d,max:m,pattern:h,validate:p,name:g,valueAsNumber:f,mount:v}=e._f,y=rAe(t,g);if(!v||a.has(g))return{};const b=s?s[0]:o,k=e=>{i&&b.reportValidity&&(b.setCustomValidity(oAe(e)?"":e||""),b.reportValidity())},S={},w=GAe(o),A=qwe(o),C=w||A,M=(f||KAe(o))&&iAe(o.value)&&iAe(y)||IAe(o)&&""===o.value||""===y||Array.isArray(y)&&!y.length,T=RAe.bind(null,g,n,S),x=(e,a,t,n=kAe,i=SAe)=>{const r=e?a:t;S[g]={type:e?n:i,message:r,ref:o,...T(e?n:i,r)}};if(r?!Array.isArray(y)||!y.length:l&&(!C&&(M||Zwe(y))||oAe(y)&&!y||A&&!QAe(s).isValid||w&&!aCe(s).isValid)){const{value:e,message:a}=dCe(l)?{value:!!l,message:l}:hCe(l);if(e&&(S[g]={type:AAe,message:a,ref:b,...T(AAe,a)},!n))return k(a),S}if(!(M||Zwe(d)&&Zwe(m))){let e,a;const t=hCe(m),i=hCe(d);if(Zwe(y)||isNaN(y)){const n=o.valueAsDate||new Date(y),r=e=>new Date((new Date).toDateString()+" "+e),s="time"==o.type,l="week"==o.type;PAe(t.value)&&y&&(e=s?r(y)>r(t.value):l?y>t.value:n>new Date(t.value)),PAe(i.value)&&y&&(a=s?r(y)<r(i.value):l?y<i.value:n<new Date(i.value))}else{const n=o.valueAsNumber||(y?+y:y);Zwe(t.value)||(e=n>t.value),Zwe(i.value)||(a=n<i.value)}if((e||a)&&(x(!!e,t.message,i.message,yAe,bAe),!n))return k(S[g].message),S}if((u||c)&&!M&&(PAe(y)||r&&Array.isArray(y))){const e=hCe(u),a=hCe(c),t=!Zwe(e.value)&&y.length>+e.value,i=!Zwe(a.value)&&y.length<+a.value;if((t||i)&&(x(t,e.message,a.message),!n))return k(S[g].message),S}if(h&&!M&&PAe(y)){const{value:e,message:a}=hCe(h);if(nCe(e)&&!y.match(e)&&(S[g]={type:wAe,message:a,ref:o,...T(wAe,a)},!n))return k(a),S}if(p)if(HAe(p)){const e=mCe(await p(y,t),b);if(e&&(S[g]={...e,...T(CAe,e.message)},!n))return k(e.message),S}else if(Qwe(p)){let e={};for(const a in p){if(!OAe(e)&&!n)break;const i=mCe(await p[a](y,t),b,a);i&&(e={...i,...T(a,i.message)},k(i.message),n&&(S[g]=e))}if(!OAe(e)&&(S[g]={ref:b,...e},!n))return S}return k(!0),S};const gCe={mode:gAe,reValidateMode:pAe,shouldFocusError:!0};function fCe(e={}){let a={...gCe,...e},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:HAe(a.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:a.errors||{},disabled:a.disabled||!1};const n={};let i,r=(Qwe(a.defaultValues)||Qwe(a.values))&&tAe(a.values||a.defaultValues)||{},o=a.shouldUnregister?{}:tAe(r),s={action:!1,mount:!1,watch:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0;const c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let d={...c};const m={array:zAe(),state:zAe()},h=rCe(a.mode),p=rCe(a.reValidateMode),g=a.criteriaMode===vAe,f=async e=>{if(!a.disabled&&(c.isValid||d.isValid||e)){const e=a.resolver?OAe((await S()).errors):await w(n,!0);e!==t.isValid&&m.state.next({isValid:e})}},v=(e,n)=>{!a.disabled&&(c.isValidating||c.validatingFields||d.isValidating||d.validatingFields)&&((e||Array.from(l.mount)).forEach((e=>{e&&(n?uAe(t.validatingFields,e,n):JAe(t.validatingFields,e))})),m.state.next({validatingFields:t.validatingFields,isValidating:!OAe(t.validatingFields)}))},y=(e,a,t,i)=>{const l=rAe(n,e);if(l){const n=rAe(o,e,iAe(t)?rAe(r,e):t);iAe(n)||i&&i.defaultChecked||a?uAe(o,e,a?n:tCe(l._f)):M(e,n),s.mount&&f()}},b=(e,n,i,o,s)=>{let l=!1,u=!1;const h={name:e};if(!a.disabled){if(!i||o){(c.isDirty||d.isDirty)&&(u=t.isDirty,t.isDirty=h.isDirty=A(),l=u!==h.isDirty);const a=NAe(rAe(r,e),n);u=!!rAe(t.dirtyFields,e),a?JAe(t.dirtyFields,e):uAe(t.dirtyFields,e,!0),h.dirtyFields=t.dirtyFields,l=l||(c.dirtyFields||d.dirtyFields)&&u!==!a}if(i){const a=rAe(t.touchedFields,e);a||(uAe(t.touchedFields,e,i),h.touchedFields=t.touchedFields,l=l||(c.touchedFields||d.touchedFields)&&a!==i)}l&&s&&m.state.next(h)}return l?h:{}},k=(e,n,r,o)=>{const s=rAe(t.errors,e),l=(c.isValid||d.isValid)&&oAe(n)&&t.isValid!==n;if(a.delayError&&r?(i=(e=>a=>{clearTimeout(u),u=setTimeout(e,a)})((()=>((e,a)=>{uAe(t.errors,e,a),m.state.next({errors:t.errors})})(e,r))),i(a.delayError)):(clearTimeout(u),i=null,r?uAe(t.errors,e,r):JAe(t.errors,e)),(r?!NAe(s,r):s)||!OAe(o)||l){const a={...o,...l&&oAe(n)?{isValid:n}:{},errors:t.errors,name:e};t={...t,...a},m.state.next(a)}},S=async e=>{v(e,!0);const t=await a.resolver(o,a.context,((e,a,t,n)=>{const i={};for(const r of e){const e=rAe(a,r);e&&uAe(i,r,e._f)}return{criteriaMode:t,names:[...e],fields:i,shouldUseNativeValidation:n}})(e||l.mount,n,a.criteriaMode,a.shouldUseNativeValidation));return v(e),t},w=async(e,n,i={valid:!0})=>{for(const s in e){const u=e[s];if(u){const{_f:e,...d}=u;if(e){const d=l.array.has(e.name),m=u._f&&(!!(r=u._f)&&!!r.validate&&!!(HAe(r.validate)&&r.validate.constructor.name===oCe||Qwe(r.validate)&&Object.values(r.validate).find((e=>e.constructor.name===oCe))));m&&c.validatingFields&&v([s],!0);const h=await pCe(u,l.disabled,o,g,a.shouldUseNativeValidation&&!n,d);if(m&&c.validatingFields&&v([s]),h[e.name]&&(i.valid=!1,n))break;!n&&(rAe(h,e.name)?d?cCe(t.errors,h,e.name):uAe(t.errors,e.name,h[e.name]):JAe(t.errors,e.name))}!OAe(d)&&await w(d,n,i)}}var r;return i.valid},A=(e,t)=>!a.disabled&&(e&&t&&uAe(o,e,t),!NAe(P(),r)),C=(e,a,t)=>jAe(e,l,{...s.mount?o:iAe(a)?r:PAe(e)?{[e]:a}:a},t,a),M=(e,a,t={})=>{const i=rAe(n,e);let r=a;if(i){const t=i._f;t&&(!t.disabled&&uAe(o,e,XAe(a,t)),r=IAe(t.ref)&&Zwe(a)?"":a,FAe(t.ref)?[...t.ref.options].forEach((e=>e.selected=r.includes(e.value))):t.refs?qwe(t.ref)?t.refs.length>1?t.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(r)?!!r.find((a=>a===e.value)):r===e.value))):t.refs[0]&&(t.refs[0].checked=!!r):t.refs.forEach((e=>e.checked=e.value===r)):KAe(t.ref)?t.ref.value="":(t.ref.value=r,t.ref.type||m.state.next({name:e,values:tAe(o)})))}(t.shouldDirty||t.shouldTouch)&&b(e,r,t.shouldTouch,t.shouldDirty,!0),t.shouldValidate&&_(e)},T=(e,a,t)=>{for(const i in a){const r=a[i],o=`${e}.${i}`,s=rAe(n,o);(l.array.has(e)||Qwe(r)||s&&!s._f)&&!$we(r)?T(o,r,t):M(o,r,t)}},x=(e,a,i={})=>{const u=rAe(n,e),h=l.array.has(e),p=tAe(a);uAe(o,e,p),h?(m.array.next({name:e,values:tAe(o)}),(c.isDirty||c.dirtyFields||d.isDirty||d.dirtyFields)&&i.shouldDirty&&m.state.next({name:e,dirtyFields:$Ae(r,o),isDirty:A(e,p)})):!u||u._f||Zwe(p)?M(e,p,i):T(e,p,i),sCe(e,l)&&m.state.next({...t}),m.state.next({name:s.mount?e:void 0,values:tAe(o)})},E=async e=>{s.mount=!0;const r=e.target;let u=r.name,y=!0;const A=rAe(n,u),C=e=>{y=Number.isNaN(e)||$we(e)&&isNaN(e.getTime())||NAe(e,rAe(o,u,e))};if(A){let s,T;const x=r.type?tCe(A._f):Xwe(e),E=e.type===cAe||e.type===dAe,N=!((M=A._f).mount&&(M.required||M.min||M.max||M.maxLength||M.minLength||M.pattern||M.validate)||a.resolver||rAe(t.errors,u)||A._f.deps)||((e,a,t,n,i)=>!i.isOnAll&&(!t&&i.isOnTouch?!(a||e):(t?n.isOnBlur:i.isOnBlur)?!e:!(t?n.isOnChange:i.isOnChange)||e))(E,rAe(t.touchedFields,u),t.isSubmitted,p,h),P=sCe(u,l,E);uAe(o,u,x),E?(A._f.onBlur&&A._f.onBlur(e),i&&i(0)):A._f.onChange&&A._f.onChange(e);const j=b(u,x,E),L=!OAe(j)||P;if(!E&&m.state.next({name:u,type:e.type,values:tAe(o)}),N)return(c.isValid||d.isValid)&&("onBlur"===a.mode?E&&f():E||f()),L&&m.state.next({name:u,...P?{}:j});if(!E&&P&&m.state.next({...t}),a.resolver){const{errors:e}=await S([u]);if(C(x),y){const a=uCe(t.errors,n,u),i=uCe(e,n,a.name||u);s=i.error,u=i.name,T=OAe(e)}}else v([u],!0),s=(await pCe(A,l.disabled,o,g,a.shouldUseNativeValidation))[u],v([u]),C(x),y&&(s?T=!1:(c.isValid||d.isValid)&&(T=await w(n,!0)));y&&(A._f.deps&&_(A._f.deps),k(u,T,s,j))}var M},N=(e,a)=>{if(rAe(t.errors,a)&&e.focus)return e.focus(),1},_=async(e,i={})=>{let r,o;const s=DAe(e);if(a.resolver){const a=await(async e=>{const{errors:a}=await S(e);if(e)for(const n of e){const e=rAe(a,n);e?uAe(t.errors,n,e):JAe(t.errors,n)}else t.errors=a;return a})(iAe(e)?e:s);r=OAe(a),o=e?!s.some((e=>rAe(a,e))):r}else e?(o=(await Promise.all(s.map((async e=>{const a=rAe(n,e);return await w(a&&a._f?{[e]:a}:a)})))).every(Boolean),(o||t.isValid)&&f()):o=r=await w(n);return m.state.next({...!PAe(e)||(c.isValid||d.isValid)&&r!==t.isValid?{}:{name:e},...a.resolver||!e?{isValid:r}:{},errors:t.errors}),i.shouldFocus&&!o&&lCe(n,N,e?s:l.mount),o},P=e=>{const a={...s.mount?o:r};return iAe(e)?a:PAe(e)?rAe(a,e):e.map((e=>rAe(a,e)))},j=(e,a)=>({invalid:!!rAe((a||t).errors,e),isDirty:!!rAe((a||t).dirtyFields,e),error:rAe((a||t).errors,e),isValidating:!!rAe(t.validatingFields,e),isTouched:!!rAe((a||t).touchedFields,e)}),L=(e,a,i)=>{const r=(rAe(n,e,{_f:{}})._f||{}).ref,o=rAe(t.errors,e)||{},{ref:s,message:l,type:u,...c}=o;uAe(t.errors,e,{...c,...a,ref:r}),m.state.next({name:e,errors:t.errors,isValid:!1}),i&&i.shouldFocus&&r&&r.focus&&r.focus()},B=e=>m.state.subscribe({next:a=>{var n,i,r;i=a.name,r=e.exact,(n=e.name)&&i&&n!==i&&!DAe(n).some((e=>e&&(r?e===i:e.startsWith(i)||i.startsWith(e))))||!((e,a,t,n)=>{t(e);const{name:i,...r}=e;return OAe(r)||Object.keys(r).length>=Object.keys(a).length||Object.keys(r).find((e=>a[e]===(!n||vAe)))})(a,e.formState||c,F,e.reRenderRoot)||e.callback({values:{...o},...t,...a})}}).unsubscribe,R=(e,i={})=>{for(const s of e?DAe(e):l.mount)l.mount.delete(s),l.array.delete(s),i.keepValue||(JAe(n,s),JAe(o,s)),!i.keepError&&JAe(t.errors,s),!i.keepDirty&&JAe(t.dirtyFields,s),!i.keepTouched&&JAe(t.touchedFields,s),!i.keepIsValidating&&JAe(t.validatingFields,s),!a.shouldUnregister&&!i.keepDefaultValue&&JAe(r,s);m.state.next({values:tAe(o)}),m.state.next({...t,...i.keepDirty?{isDirty:A()}:{}}),!i.keepIsValid&&f()},D=({disabled:e,name:a})=>{(oAe(e)&&s.mount||e||l.disabled.has(a))&&(e?l.disabled.add(a):l.disabled.delete(a))},z=(e,t={})=>{let i=rAe(n,e);const o=oAe(t.disabled)||oAe(a.disabled);return uAe(n,e,{...i||{},_f:{...i&&i._f?i._f:{ref:{name:e}},name:e,mount:!0,...t}}),l.mount.add(e),i?D({disabled:oAe(t.disabled)?t.disabled:a.disabled,name:e}):y(e,!0,t.value),{...o?{disabled:t.disabled||a.disabled}:{},...a.progressive?{required:!!t.required,min:iCe(t.min),max:iCe(t.max),minLength:iCe(t.minLength),maxLength:iCe(t.maxLength),pattern:iCe(t.pattern)}:{},name:e,onChange:E,onBlur:E,ref:o=>{if(o){z(e,t),i=rAe(n,e);const a=iAe(o.value)&&o.querySelectorAll&&o.querySelectorAll("input,select,textarea")[0]||o,s=(e=>GAe(e)||qwe(e))(a),l=i._f.refs||[];if(s?l.find((e=>e===a)):a===i._f.ref)return;uAe(n,e,{_f:{...i._f,...s?{refs:[...l.filter(VAe),a,...Array.isArray(rAe(r,e))?[{}]:[]],ref:{type:a.type,name:e}}:{ref:a}}}),y(e,!1,void 0,a)}else i=rAe(n,e,{}),i._f&&(i._f.mount=!1),(a.shouldUnregister||t.shouldUnregister)&&(!eAe(l.array,e)||!s.action)&&l.unMount.add(e)}}},O=()=>a.shouldFocusError&&lCe(n,N,l.mount),K=(e,i)=>async r=>{let s;r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let u=tAe(o);if(m.state.next({isSubmitting:!0}),a.resolver){const{errors:e,values:a}=await S();t.errors=e,u=a}else await w(n);if(l.disabled.size)for(const e of l.disabled)uAe(u,e,void 0);if(JAe(t.errors,"root"),OAe(t.errors)){m.state.next({errors:{}});try{await e(u,r)}catch(c){s=c}}else i&&await i({...t.errors},r),O(),setTimeout(O);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:OAe(t.errors)&&!s,submitCount:t.submitCount+1,errors:t.errors}),s)throw s},H=(e,i={})=>{const u=e?tAe(e):r,d=tAe(u),h=OAe(e),p=h?r:d;if(i.keepDefaultValues||(r=u),!i.keepValues){if(i.keepDirtyValues){const e=new Set([...l.mount,...Object.keys($Ae(r,o))]);for(const a of Array.from(e))rAe(t.dirtyFields,a)?uAe(p,a,rAe(o,a)):x(a,rAe(p,a))}else{if(aAe&&iAe(e))for(const e of l.mount){const a=rAe(n,e);if(a&&a._f){const e=Array.isArray(a._f.refs)?a._f.refs[0]:a._f.ref;if(IAe(e)){const a=e.closest("form");if(a){a.reset();break}}}}for(const e of l.mount)x(e,rAe(p,e))}o=tAe(p),m.array.next({values:{...p}}),m.state.next({values:{...p}})}l={mount:i.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},s.mount=!c.isValid||!!i.keepIsValid||!!i.keepDirtyValues,s.watch=!!a.shouldUnregister,m.state.next({submitCount:i.keepSubmitCount?t.submitCount:0,isDirty:!h&&(i.keepDirty?t.isDirty:!(!i.keepDefaultValues||NAe(e,r))),isSubmitted:!!i.keepIsSubmitted&&t.isSubmitted,dirtyFields:h?{}:i.keepDirtyValues?i.keepDefaultValues&&o?$Ae(r,o):t.dirtyFields:i.keepDefaultValues&&e?$Ae(r,e):i.keepDirty?t.dirtyFields:{},touchedFields:i.keepTouched?t.touchedFields:{},errors:i.keepErrors?t.errors:{},isSubmitSuccessful:!!i.keepIsSubmitSuccessful&&t.isSubmitSuccessful,isSubmitting:!1})},I=(e,a)=>H(HAe(e)?e(o):e,a),F=e=>{t={...t,...e}},G={control:{register:z,unregister:R,getFieldState:j,handleSubmit:K,setError:L,_subscribe:B,_runSchema:S,_getWatch:C,_getDirty:A,_setValid:f,_setFieldArray:(e,i=[],l,u,h=!0,p=!0)=>{if(u&&l&&!a.disabled){if(s.action=!0,p&&Array.isArray(rAe(n,e))){const a=l(rAe(n,e),u.argA,u.argB);h&&uAe(n,e,a)}if(p&&Array.isArray(rAe(t.errors,e))){const a=l(rAe(t.errors,e),u.argA,u.argB);h&&uAe(t.errors,e,a),((e,a)=>{!nAe(rAe(e,a)).length&&JAe(e,a)})(t.errors,e)}if((c.touchedFields||d.touchedFields)&&p&&Array.isArray(rAe(t.touchedFields,e))){const a=l(rAe(t.touchedFields,e),u.argA,u.argB);h&&uAe(t.touchedFields,e,a)}(c.dirtyFields||d.dirtyFields)&&(t.dirtyFields=$Ae(r,o)),m.state.next({name:e,isDirty:A(e,i),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else uAe(o,e,i)},_setDisabledField:D,_setErrors:e=>{t.errors=e,m.state.next({errors:t.errors,isValid:!1})},_getFieldArray:e=>nAe(rAe(s.mount?o:r,e,a.shouldUnregister?rAe(r,e,[]):[])),_reset:H,_resetDefaultValues:()=>HAe(a.defaultValues)&&a.defaultValues().then((e=>{I(e,a.resetOptions),m.state.next({isLoading:!1})})),_removeUnmounted:()=>{for(const e of l.unMount){const a=rAe(n,e);a&&(a._f.refs?a._f.refs.every((e=>!VAe(e))):!VAe(a._f.ref))&&R(e)}l.unMount=new Set},_disableForm:e=>{oAe(e)&&(m.state.next({disabled:e}),lCe(n,((a,t)=>{const i=rAe(n,t);i&&(a.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach((a=>{a.disabled=i._f.disabled||e})))}),0,!1))},_subjects:m,_proxyFormState:c,get _fields(){return n},get _formValues(){return o},get _state(){return s},set _state(e){s=e},get _defaultValues(){return r},get _names(){return l},set _names(e){l=e},get _formState(){return t},get _options(){return a},set _options(e){a={...a,...e}}},subscribe:e=>(s.mount=!0,d={...d,...e.formState},B({...e,formState:d})),trigger:_,register:z,handleSubmit:K,watch:(e,a)=>HAe(e)?m.state.subscribe({next:t=>e(C(void 0,a),t)}):C(e,a,!0),setValue:x,getValues:P,reset:I,resetField:(e,a={})=>{rAe(n,e)&&(iAe(a.defaultValue)?x(e,tAe(rAe(r,e))):(x(e,a.defaultValue),uAe(r,e,tAe(a.defaultValue))),a.keepTouched||JAe(t.touchedFields,e),a.keepDirty||(JAe(t.dirtyFields,e),t.isDirty=a.defaultValue?A(e,tAe(rAe(r,e))):A()),a.keepError||(JAe(t.errors,e),c.isValid&&f()),m.state.next({...t}))},clearErrors:e=>{e&&DAe(e).forEach((e=>JAe(t.errors,e))),m.state.next({errors:e?t.errors:{}})},unregister:R,setError:L,setFocus:(e,a={})=>{const t=rAe(n,e),i=t&&t._f;if(i){const e=i.refs?i.refs[0]:i.ref;e.focus&&(e.focus(),a.shouldSelect&&HAe(e.select)&&e.select())}},getFieldState:j};return{...G,formControl:G}}const vCe="undefined"!=typeof window?a.useLayoutEffect:a.useEffect;function yCe(e={}){const t=a.useRef(void 0),n=a.useRef(void 0),[i,r]=a.useState({isDirty:!1,isValidating:!1,isLoading:HAe(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:HAe(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...e.formControl?e.formControl:fCe(e),formState:i},e.formControl&&e.defaultValues&&!HAe(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions));const o=t.current.control;return o._options=e,vCe((()=>{const e=o._subscribe({formState:o._proxyFormState,callback:()=>r({...o._formState}),reRenderRoot:!0});return r((e=>({...e,isReady:!0}))),e}),[o]),a.useEffect((()=>o._disableForm(e.disabled)),[o,e.disabled]),a.useEffect((()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode),e.errors&&!OAe(e.errors)&&o._setErrors(e.errors)}),[o,e.errors,e.mode,e.reValidateMode]),a.useEffect((()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})}),[o,e.shouldUnregister]),a.useEffect((()=>{if(o._proxyFormState.isDirty){const e=o._getDirty();e!==i.isDirty&&o._subjects.state.next({isDirty:e})}}),[o,i.isDirty]),a.useEffect((()=>{e.values&&!NAe(e.values,n.current)?(o._reset(e.values,o._options.resetOptions),n.current=e.values,r((e=>({...e})))):o._resetDefaultValues()}),[o,e.values]),a.useEffect((()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()})),t.current.formState=xAe(i,o),t.current}const bCe=e=>{const{children:t,...n}=e;return a.createElement(MAe.Provider,{value:n},t)},kCe=r.createContext({}),SCe=({...e})=>t.jsx(kCe.Provider,{value:{name:e.name},children:t.jsx(BAe,{...e})}),wCe=()=>{const e=r.useContext(kCe),a=r.useContext(ACe),{getFieldState:t,formState:n}=TAe(),i=t(e.name,n);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:o}=a;return{id:o,name:e.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...i}},ACe=r.createContext({}),CCe=r.forwardRef((({className:e,...a},n)=>{const i=r.useId();return t.jsx(ACe.Provider,{value:{id:i},children:t.jsx("div",{ref:n,className:XO("space-y-2",e),...a})})}));CCe.displayName="FormItem";const MCe=r.forwardRef((({className:e,...a},n)=>{const{error:i,formItemId:r}=wCe();return t.jsx(Kbe,{ref:n,className:XO(i&&"text-destructive",e),htmlFor:r,...a})}));MCe.displayName="FormLabel";const TCe=r.forwardRef((({...e},a)=>{const{error:n,formItemId:i,formDescriptionId:r,formMessageId:o}=wCe();return t.jsx(GZ,{ref:a,id:i,"aria-describedby":n?`${r} ${o}`:`${r}`,"aria-invalid":!!n,...e})}));TCe.displayName="FormControl";r.forwardRef((({className:e,...a},n)=>{const{formDescriptionId:i}=wCe();return t.jsx("p",{ref:n,id:i,className:XO("text-[0.8rem] text-muted-foreground",e),...a})})).displayName="FormDescription";const xCe=r.forwardRef((({className:e,children:a,...n},i)=>{const{error:r,formMessageId:o}=wCe(),s=r?String(r?.message):a;return s?t.jsx("p",{ref:i,id:o,className:XO("text-[0.8rem] font-medium text-destructive",e),...n,children:s}):null}));xCe.displayName="FormMessage";const ECe="onboarding",NCe="settings",_Ce="todo",PCe="active",jCe="done",LCe={[jCe]:{icon:cz,className:"w-5 h-5 fill-green-500 text-background",style:{width:"1.5rem",height:"1.5rem"}},[PCe]:{icon:mz,className:"w-5 h-5 text-primary"},[_Ce]:{icon:dz,className:"w-5 h-5 text-muted-foreground/60"}},BCe=a.createContext(null);function RCe({config:e,onStepChange:t,onClose:n}){const i=e.steps.map((e=>e.key)),[r,o]=a.useState(e.initialStep||i[0]),[s,l]=a.useState(new Set),[u,c]=a.useState(new Set([r])),[d,m]=a.useState({}),h=i.indexOf(r),p=0===h,g=h===i.length-1,f=!g,v=!p,y=a.useCallback((e=>{i.includes(e)&&(o(e),c((a=>new Set([...a,e]))),t?.(e))}),[i,t]),b=a.useCallback((()=>{if(f){y(i[h+1])}else g&&n&&n()}),[f,h,i,y,g,n]),k=a.useCallback((()=>{if(v){y(i[h-1])}}),[v,h,i,y]),S=a.useCallback((e=>{l((a=>new Set([...a,e])))}),[]),w=a.useCallback(((e,a)=>{m((t=>({...t,[e]:a}))),S(e)}),[S]),A=a.useCallback((e=>s.has(e)),[s]),C=a.useCallback((e=>u.has(e)),[u]);return{navigation:{currentStep:r,steps:i,goToStep:y,goToNextStep:b,goToPreviousStep:k,canGoNext:f,canGoPrevious:v,currentStepIndex:h,isFirstStep:p,isLastStep:g},state:{completedSteps:Array.from(s),visitedSteps:Array.from(u),formData:d,markStepComplete:S,isStepComplete:A,isStepVisited:C,updateFormData:w}}}const DCe=jZ,zCe=LZ,OCe=BZ,KCe=r.forwardRef((({className:e,...a},n)=>t.jsx(RZ,{className:XO("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...a,ref:n})));KCe.displayName=RZ.displayName;const HCe=GD("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ICe=r.forwardRef((({side:e="right",className:a,children:n,...i},r)=>t.jsxs(OCe,{children:[t.jsx(KCe,{}),t.jsxs(DZ,{ref:r,className:XO(HCe({side:e}),a),"data-reach-root":!0,...i,children:[n,t.jsxs(KZ,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[t.jsx(rO,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})));ICe.displayName=DZ.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(zZ,{ref:n,className:XO("text-lg font-semibold text-foreground",e),...a}))).displayName=zZ.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(OZ,{ref:n,className:XO("text-sm text-muted-foreground",e),...a}))).displayName=OZ.displayName;const FCe=GD("py-6 px-4 border-r",{variants:{mode:{onboarding:"w-56 bg-muted/30",settings:"w-64 bg-muted/50"}},defaultVariants:{mode:ECe}}),GCe=GD("w-full justify-start gap-3 h-auto text-left",{variants:{mode:{onboarding:"py-2 px-3 min-h-none leading-none gap-1",settings:"py-3 px-3"},isActive:{true:"",false:""}},compoundVariants:[{mode:ECe,isActive:!0,class:"bg-muted"},{mode:NCe,isActive:!0,class:"bg-background"}],defaultVariants:{mode:ECe,isActive:!1}}),VCe=({status:e})=>{const a=LCe[e]??LCe[_Ce];return t.jsx(a.icon,{className:a.className,...a.style&&{style:a.style}})},JCe=({items:e,currentItem:a,onItemChange:n,completedItems:i=[],mode:r=ECe,className:o})=>t.jsx("div",{className:XO(FCe({mode:r}),o,r===ECe?"":"max-w-[22ch]"),children:t.jsx("div",{className:XO(r===ECe?"space-y-1":"space-y-2"),children:e.map((e=>{const o=e.status||((e,a,t=[])=>t.includes(e)?jCe:e===a?PCe:_Ce)(e.key,a,i),s=a===e.key,l=e.icon;return t.jsxs(H5,{variant:s?"secondary":"ghost",onClick:()=>n(e.key),className:XO(GCe({mode:r,isActive:s}),"group"),children:[r===ECe&&t.jsx("div",{className:"w-7 h-7 flex items-center justify-center flex-shrink-0",children:t.jsx(VCe,{status:o})}),r===NCe&&l&&t.jsx(l,{className:"w-4 h-4 text-muted-foreground/50 group-hover:text-foreground transition-colors"}),t.jsx("span",{className:XO("text-sm font-medium",r===ECe&&{"text-foreground":o===PCe,"text-muted-foreground":o===jCe||o===_Ce}),children:e.label})]},e.key)}))})}),UCe=({open:e,onOpenChange:n,title:i,description:r,sidebarItems:o,currentStep:s,onStepChange:l,completedSteps:u=[],mode:c="onboarding",showSidebar:d=!0,showMobileNav:m=!0,children:h,className:p,contentClassName:g})=>{const[f,v]=a.useState(!1);return t.jsx(ZZ,{open:e,onOpenChange:n,modal:!0,children:t.jsxs(eY,{className:XO("@container/wizard w-[90vw] max-h-[90vh] h-full flex flex-col gap-0 overflow-hidden sm:max-w-xl md:max-w-3xl lg:max-w-4xl p-0",p),onEscapeKeyDown:()=>{n(!1)},onPointerDownOutside:e=>{const a=e.target;(a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},onInteractOutside:e=>{const a=e.target;(e.composedPath().some((e=>"classList"in e&&Array.from(e.classList).includes("pac-item")))||a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},onFocusOutside:e=>{const a=e.target;(a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:i}),t.jsx(iY,{children:r})]}),t.jsxs("div",{className:"flex-1 min-h-0 flex",children:[d&&t.jsxs(t.Fragment,{children:[t.jsx(JCe,{mode:c,items:o,currentItem:s,onItemChange:l,completedItems:u,className:"hidden @lg/wizard:block"}),m&&t.jsxs(DCe,{open:f,onOpenChange:v,children:[t.jsx(zCe,{asChild:!0,children:t.jsx(H5,{variant:"ghost",size:"icon",className:"flex @lg/wizard:hidden absolute top-4 left-4 z-10",children:t.jsx(Ez,{className:"h-4 w-4"})})}),t.jsx(ICe,{side:"left",className:"w-64 p-0",children:t.jsx(JCe,{mode:c,items:o,currentItem:s,onItemChange:e=>{l(e),m&&v(!1)},completedItems:u,className:"border-r-0"})})]})]}),t.jsx("div",{className:XO("flex-1 min-h-0",g),children:h})]})]})})},WCe=({title:e,description:a,className:n})=>t.jsxs("div",{className:XO("px-8",n),children:[t.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:e}),a&&t.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:a})]}),qCe=({control:e,name:a,label:n,placeholder:i,type:r="text",disabled:o})=>t.jsx(SCe,{control:e,name:a,render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:n}),t.jsx(TCe,{children:t.jsx(gte,{...e,type:r,placeholder:i,disabled:o,className:"bg-background"})}),t.jsx(xCe,{})]})}),$Ce=({control:e,name:a,label:n,placeholder:i,options:r,disabled:o})=>t.jsx(SCe,{control:e,name:a,render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:n}),t.jsxs(pwe,{onValueChange:e.onChange,value:e.value,disabled:o,children:[t.jsx(TCe,{children:t.jsx(vwe,{className:"bg-background",children:t.jsx(fwe,{placeholder:i})})}),t.jsx(kwe,{children:r.map((e=>t.jsx(Swe,{value:e.value,children:t.jsxs("div",{className:"flex flex-col text-left",children:[t.jsx("span",{children:e.label}),e.description&&t.jsx("span",{className:"text-xs text-muted-foreground",children:e.description})]})},e.value)))})]}),t.jsx(xCe,{})]})}),ZCe=({title:e,description:a,children:n,variant:i="default"})=>t.jsxs("div",{className:"highlighted"===i?"bg-muted/50 p-6 rounded-lg border border-muted space-y-4":"space-y-4",children:[e&&t.jsx("h3",{className:"text-lg font-medium text-foreground",children:e}),a&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a}),t.jsx("div",{className:"space-y-4",children:n})]}),YCe=({variant:e="default",onBack:a,onNext:n,onSkip:i,isSubmitting:r=!1,canGoBack:o=!0,canGoNext:s=!0,backLabel:l="Back",nextLabel:u="Next",skipLabel:c="Skip",className:d,mode:m})=>{const h="compact"===e?"sm":"default",p="default"===e?"text-sm":"";return t.jsxs("div",{className:XO("flex items-center","compact"===e?"gap-2":"justify-between gap-4",d),children:[a&&t.jsxs(H5,{variant:"outline",size:h,onClick:a,disabled:r||!o,className:XO("flex items-center gap-2",p),children:[t.jsx(iz,{className:"w-4 h-4"}),l]}),t.jsxs("div",{className:"flex items-center gap-4 ml-auto",children:[i&&t.jsx(H5,{variant:"outline",size:h,onClick:i,disabled:r,className:XO("flex items-center gap-2",p),children:c}),n&&t.jsx(H5,{size:h,onClick:n,disabled:r||!s,className:XO("flex items-center gap-2",p),children:t.jsxs(t.Fragment,r?{children:[t.jsx(Cz,{className:"w-4 h-4 animate-spin"}),"Saving..."]}:{children:[u,"onboarding"===m&&t.jsx(ZD,{className:"w-4 h-4"})]})})]})]})},QCe=a.forwardRef((({children:e,className:a,showNavigation:n=!0,mode:i="onboarding",...r},o)=>{const s="settings"!==i&&r.onBack;return t.jsxs("div",{ref:o,className:XO("h-full flex flex-col",a),children:[t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-y-auto pt-10 @lg/onboarding-sidebar:pt-16",children:[t.jsx(WCe,{title:r.title,description:r.description}),t.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e})]}),n&&t.jsx("div",{className:"border-t border-border py-6 px-8 bg-background",children:t.jsx(YCe,{onBack:s?r.onBack:void 0,onNext:r.onNext,onSkip:r.onSkip,isSubmitting:r.isSubmitting,canGoBack:r.canGoBack,canGoNext:r.canGoNext,backLabel:r.backLabel||"Previous Step",nextLabel:r.submitLabel||"Next step",skipLabel:r.skipLabel||"Not now",mode:i})})]})}));QCe.displayName="WizardFormWrapper";const XCe=(e,a,t)=>{if(e&&"reportValidity"in e){const n=rAe(t,a);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},eMe=(e,a)=>{for(const t in a.fields){const n=a.fields[t];n&&n.ref&&"reportValidity"in n.ref?XCe(n.ref,t,e):n.refs&&n.refs.forEach((a=>XCe(a,t,e)))}},aMe=(e,a)=>{a.shouldUseNativeValidation&&eMe(e,a);const t={};for(const n in e){const i=rAe(a.fields,n),r=Object.assign(e[n]||{},{ref:i&&i.ref});if(tMe(a.names||Object.keys(e),n)){const e=Object.assign({},rAe(t,n));uAe(e,"root",r),uAe(t,n,e)}else uAe(t,n,r)}return t},tMe=(e,a)=>e.some((e=>e.startsWith(a+".")));var nMe=function(e,a){for(var t={};e.length;){var n=e[0],i=n.code,r=n.message,o=n.path.join(".");if(!t[o])if("unionErrors"in n){var s=n.unionErrors[0].errors[0];t[o]={message:s.message,type:s.code}}else t[o]={message:r,type:i};if("unionErrors"in n&&n.unionErrors.forEach((function(a){return a.errors.forEach((function(a){return e.push(a)}))})),a){var l=t[o].types,u=l&&l[n.code];t[o]=RAe(o,a,t,i,u?[].concat(u,n.message):n.message)}e.shift()}return t},iMe=function(e,a,t){return void 0===t&&(t={}),function(n,i,r){try{return Promise.resolve(function(i,o){try{var s=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](n,a)).then((function(e){return r.shouldUseNativeValidation&&eMe({},r),{errors:{},values:t.raw?n:e}}))}catch(XZe){return o(XZe)}return s&&s.then?s.then(void 0,o):s}(0,(function(e){if(a=e,Array.isArray(null==a?void 0:a.errors))return{values:{},errors:aMe(nMe(e.errors,!r.shouldUseNativeValidation&&"all"===r.criteriaMode),r)};var a;throw e})))}catch(XZe){return Promise.reject(XZe)}}};const rMe=[{code:"US",name:"United States"},{code:"AE",name:"United Arab Emirates"},{code:"AF",name:"Afghanistan"},{code:"AM",name:"Armenia"},{code:"AR",name:"Argentina"},{code:"AT",name:"Austria"},{code:"AU",name:"Australia"},{code:"AZ",name:"Azerbaijan"},{code:"BD",name:"Bangladesh"},{code:"BE",name:"Belgium"},{code:"BF",name:"Burkina Faso"},{code:"BG",name:"Bulgaria"},{code:"BH",name:"Bahrain"},{code:"BI",name:"Burundi"},{code:"BJ",name:"Benin"},{code:"BO",name:"Bolivia"},{code:"BR",name:"Brazil"},{code:"BT",name:"Bhutan"},{code:"BW",name:"Botswana"},{code:"BY",name:"Belarus"},{code:"CA",name:"Canada"},{code:"CD",name:"Democratic Republic of the Congo"},{code:"CF",name:"Central African Republic"},{code:"CG",name:"Republic of the Congo"},{code:"CH",name:"Switzerland"},{code:"CI",name:"Ivory Coast"},{code:"CL",name:"Chile"},{code:"CM",name:"Cameroon"},{code:"CN",name:"China"},{code:"CO",name:"Colombia"},{code:"CV",name:"Cape Verde"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czech Republic"},{code:"DE",name:"Germany"},{code:"DJ",name:"Djibouti"},{code:"DK",name:"Denmark"},{code:"DZ",name:"Algeria"},{code:"EC",name:"Ecuador"},{code:"EE",name:"Estonia"},{code:"EG",name:"Egypt"},{code:"ER",name:"Eritrea"},{code:"ES",name:"Spain"},{code:"ET",name:"Ethiopia"},{code:"FI",name:"Finland"},{code:"FJ",name:"Fiji"},{code:"FK",name:"Falkland Islands"},{code:"FR",name:"France"},{code:"GA",name:"Gabon"},{code:"GB",name:"United Kingdom"},{code:"GE",name:"Georgia"},{code:"GF",name:"French Guiana"},{code:"GH",name:"Ghana"},{code:"GM",name:"Gambia"},{code:"GN",name:"Guinea"},{code:"GQ",name:"Equatorial Guinea"},{code:"GR",name:"Greece"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HK",name:"Hong Kong"},{code:"HR",name:"Croatia"},{code:"HU",name:"Hungary"},{code:"ID",name:"Indonesia"},{code:"IE",name:"Ireland"},{code:"IL",name:"Israel"},{code:"IN",name:"India"},{code:"IQ",name:"Iraq"},{code:"IR",name:"Iran"},{code:"IS",name:"Iceland"},{code:"IT",name:"Italy"},{code:"JO",name:"Jordan"},{code:"JP",name:"Japan"},{code:"KE",name:"Kenya"},{code:"KG",name:"Kyrgyzstan"},{code:"KM",name:"Comoros"},{code:"KR",name:"South Korea"},{code:"KW",name:"Kuwait"},{code:"KZ",name:"Kazakhstan"},{code:"LB",name:"Lebanon"},{code:"LK",name:"Sri Lanka"},{code:"LR",name:"Liberia"},{code:"LS",name:"Lesotho"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"LV",name:"Latvia"},{code:"LY",name:"Libya"},{code:"MA",name:"Morocco"},{code:"MD",name:"Moldova"},{code:"MG",name:"Madagascar"},{code:"ML",name:"Mali"},{code:"MO",name:"Macau"},{code:"MR",name:"Mauritania"},{code:"MT",name:"Malta"},{code:"MU",name:"Mauritius"},{code:"MV",name:"Maldives"},{code:"MW",name:"Malawi"},{code:"MX",name:"Mexico"},{code:"MY",name:"Malaysia"},{code:"MZ",name:"Mozambique"},{code:"NA",name:"Namibia"},{code:"NC",name:"New Caledonia"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NL",name:"Netherlands"},{code:"NO",name:"Norway"},{code:"NP",name:"Nepal"},{code:"NZ",name:"New Zealand"},{code:"OM",name:"Oman"},{code:"PE",name:"Peru"},{code:"PF",name:"French Polynesia"},{code:"PG",name:"Papua New Guinea"},{code:"PH",name:"Philippines"},{code:"PK",name:"Pakistan"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PY",name:"Paraguay"},{code:"QA",name:"Qatar"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"SA",name:"Saudi Arabia"},{code:"SC",name:"Seychelles"},{code:"SD",name:"Sudan"},{code:"SE",name:"Sweden"},{code:"SG",name:"Singapore"},{code:"SI",name:"Slovenia"},{code:"SK",name:"Slovakia"},{code:"SL",name:"Sierra Leone"},{code:"SN",name:"Senegal"},{code:"SO",name:"Somalia"},{code:"SR",name:"Suriname"},{code:"SS",name:"South Sudan"},{code:"ST",name:"São Tomé and Príncipe"},{code:"SY",name:"Syria"},{code:"SZ",name:"Eswatini"},{code:"TD",name:"Chad"},{code:"TG",name:"Togo"},{code:"TH",name:"Thailand"},{code:"TJ",name:"Tajikistan"},{code:"TM",name:"Turkmenistan"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Turkey"},{code:"TW",name:"Taiwan"},{code:"TZ",name:"Tanzania"},{code:"UA",name:"Ukraine"},{code:"UG",name:"Uganda"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"YE",name:"Yemen"},{code:"ZA",name:"South Africa"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}];var oMe=(e=>(e.BRAND="brand",e.BUSINESS="business",e.EMAIL="email",e.SMS="sms",e.SPLASH="splash",e.BUSINESS_SKIP_INTERSTITIAL="business-skip-interstitial",e.SMS_INTERSTITIAL="sms-interstitial",e.COMPLETION="completion",e))(oMe||{});const sMe="Engage Settings",lMe="Configure your brand, business, and channel settings",uMe="Engage Setup",cMe="Set up your brand and channels for email and SMS marketing",dMe="Brand Settings",mMe="Business Information",hMe="Email Channel",pMe="SMS Channel",gMe="Customize Your Brand",fMe="Business Settings",vMe="Email Channel Settings",yMe="Connect Your SMS",bMe="DBA legal name",kMe="ZIP Code",SMe="ZIP code",wMe="Select country",AMe="First Name",CMe="First name",MMe="Last Name",TMe="Last name",xMe="Email address",EMe="Contact Phone",NMe="Auto Parse",_Me={brand:{label:dMe},business:{label:mMe},email:{label:hMe},sms:{label:pMe}},PMe=[{key:"brand",label:_Me.brand.label},{key:"business",label:_Me.business.label},{key:"email",label:_Me.email.label},{key:"sms",label:_Me.sms.label}],jMe=[{key:"brand",label:_Me.brand.label},{key:"email",label:_Me.email.label},{key:"business",label:_Me.business.label},{key:"sms",label:_Me.sms.label},{key:"completion",label:"Completion"}],LMe=({control:e,disabled:a=!1,namePrefix:n="company",context:i="email"})=>{const r="email"===i,o=rMe.map((e=>({value:e.code,label:e.name})));return t.jsxs(t.Fragment,{children:[r&&t.jsx("div",{className:"rounded-lg border border-blue-100 bg-blue-50 p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-blue-100",children:t.jsx(Tz,{className:"w-4 h-4 text-blue-600"})})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h4",{className:"text-sm font-medium text-blue-900 mb-1",children:"Email Footer Information"}),t.jsx("p",{className:"text-sm text-blue-700",children:"Your business address will be included in email footers as required by law. This ensures compliance with email marketing regulations and provides recipients with your business contact information."})]})]})}),t.jsx(qCe,{control:e,name:`${n}.name`,label:bMe,placeholder:"Enter your DBA or legal business name",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.address1`,label:"Business Address",placeholder:"Street address",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.address2`,label:"Business Address Line 2",placeholder:"Apartment, suite, unit, etc. (optional)",disabled:a}),t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsx(qCe,{control:e,name:`${n}.city`,label:"City",placeholder:"City",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.stateProvince`,label:"State/Province",placeholder:"State/Province",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.zipCode`,label:kMe,placeholder:SMe,disabled:a})]}),t.jsx($Ce,{control:e,name:`${n}.country`,label:"Country",placeholder:wMe,options:o,disabled:a})]})},BMe=({control:e,disabled:a=!1,namePrefix:n="contact"})=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(qCe,{control:e,name:`${n}.firstName`,label:AMe,placeholder:CMe,disabled:a}),t.jsx(qCe,{control:e,name:`${n}.lastName`,label:MMe,placeholder:TMe,disabled:a})]}),t.jsx(qCe,{control:e,name:`${n}.email`,label:"Email",placeholder:xMe,type:"email",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.phoneNumber`,label:EMe,placeholder:"+1234567890",description:"Must start with + and country code",type:"tel",disabled:a})]}),RMe=xle,DMe=a.forwardRef((({isSubmitting:e,onSubmit:n,hideSubmitButton:i=!1},r)=>{const o=yCe({resolver:iMe(RMe),defaultValues:{type:Cle.AWS_TOLL_FREE_NUMBER,tollFreeNumber:"",company:{name:"",website:"",address1:"",address2:"",city:"",stateProvince:"",zipCode:"",country:""},contact:{firstName:"",lastName:"",email:"",phoneNumber:""},messagingUseCase:{monthlyVolume:0,category:Mle.PROMOTIONS_MARKETING,useCaseDetails:""},messageSamples:[""]},values:void 0}),s=o.watch("messageSamples");a.useImperativeHandle(r,(()=>({submit:()=>{o.handleSubmit(l)()}})));const l=async e=>{const a={...e,messagingUseCase:{...e.messagingUseCase,monthlyVolume:Number(e.messagingUseCase.monthlyVolume)}};await n(a)};return t.jsx("div",{className:"w-full max-w-4xl text-left",children:t.jsx(bCe,{...o,children:t.jsxs("form",{onSubmit:o.handleSubmit(l),className:"space-y-6",children:[t.jsx(ZCe,{title:"Legal Business Settings",description:"Provide your legal business information required for SMS channel verification and future communications.",children:t.jsx(LMe,{control:o.control,disabled:e,context:"sms"})}),t.jsx(ZCe,{title:"Contact Information",description:"Provide the contact information of the person authorized to represent your business.",children:t.jsx(BMe,{control:o.control,disabled:e})}),t.jsxs(ZCe,{title:"Messaging Use Case",description:"Tell us about how you plan to use SMS messaging.",children:[t.jsx(qCe,{control:o.control,name:"messagingUseCase.monthlyVolume",label:"Expected Monthly Volume",placeholder:"1000",type:"number",disabled:e}),t.jsx(qCe,{control:o.control,name:"messagingUseCase.useCaseDetails",label:"Use Case Details",placeholder:"Describe your use case in detail",disabled:e})]}),t.jsxs(ZCe,{title:"Message Samples",description:"Provide examples of messages you plan to send (up to 3 samples).",children:[t.jsx(wY,{children:s.map(((a,n)=>t.jsxs(o5.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},className:"relative",children:[t.jsx(qCe,{control:o.control,name:`messageSamples.${n}`,label:`Sample Message ${n+1}`,placeholder:"Enter a sample message",disabled:e}),s.length>1&&t.jsx(o5.button,{type:"button",onClick:()=>(e=>{if(s.length>1){const a=s.filter(((a,t)=>t!==e));o.setValue("messageSamples",a)}})(n),className:"absolute -right-2 -top-2 rounded-full bg-destructive/10 p-1 text-destructive hover:bg-destructive/20",whileHover:{scale:1.1},whileTap:{scale:.9},children:t.jsx(V5.CloseButton,{className:"h-4 w-4"})})]},n)))}),s.length<3&&t.jsxs(o5.button,{type:"button",onClick:()=>{s.length<3&&o.setValue("messageSamples",[...s,""])},className:"mt-4 flex items-center gap-2 rounded-lg border border-dashed border-border px-4 py-2 text-sm text-muted-foreground hover:border-border/80 hover:text-foreground",whileHover:{scale:1.02},whileTap:{scale:.98},children:[t.jsx(V5.PlusIcon,{className:"h-4 w-4"}),"Add another sample"]})]}),!i&&t.jsx("div",{className:"flex gap-3 pt-4 justify-end",children:t.jsx(H5,{type:"submit",disabled:e,children:e?"Submitting...":"Submit for approval"})})]})})})})),zMe=({onSubmit:e,onApplicationSubmit:n,hideSubmitButton:i=!1,formRef:r,onFormVisibilityChange:o})=>{const[s,l]=a.useState(!1),{data:u,isLoading:c}=$re(),{createSmsRegistrationApplication:d,isCreating:m}=Zre();a.useEffect((()=>{o?.(s)}),[s,o]);if(!u||c)return t.jsx("div",{className:"flex flex-col items-center justify-center p-8",children:t.jsx(lY,{text:["Loading business information..."]})});const h={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}},p=u&&u.status===Ele.PENDING;return t.jsxs(o5.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:XO("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl p-6 gap-3 border border-border mx-auto","bg-background"),children:[t.jsx(o5.div,{variants:h,className:"w-16 h-16 rounded-xl flex items-center justify-center",children:t.jsx(V5.SmsIcon,{})}),t.jsx(o5.h2,{variants:h,className:"text-sm font-medium text-foreground",children:"Request your SMS sending number"}),t.jsxs(o5.div,{variants:h,className:"max-w-xl mx-auto",children:[t.jsx("p",{className:"text-sm font-normal text-muted-foreground mb-2",children:"Before you can send messages, we need to verify your business info with our SMS provider. Once approved, we'll assign you a phone number to send SMS campaigns."}),t.jsx("p",{className:"text-sm font-normal text-muted-foreground",children:"This usually takes 3-7 business days."})]}),t.jsx(wY,{mode:"wait",children:s?t.jsx(o5.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.3,ease:[.4,0,.2,1]},className:"w-full",children:t.jsx(DMe,{isSubmitting:m,onSubmit:async a=>{if(n)await n(a);else try{d({application:a,onSuccess:()=>{l(!1),e?.()}})}catch(t){}},hideSubmitButton:i,ref:r})},"form"):p?t.jsxs(o5.div,{variants:h,className:"flex items-center gap-2 px-3 py-1.5 bg-orange-50 border border-orange-200 rounded-full",children:[t.jsx(o5.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-orange-500 rounded-full"}),t.jsx("span",{className:"text-sm font-medium text-orange-800",children:"Pending approval"})]},"pending"):t.jsx(o5.div,{variants:h,children:t.jsx(H5,{variant:"outline",className:"bg-background",onClick:()=>l(!0),children:"Request approval"})},"button")})]})},OMe=e=>{const{companyName:a,smsBody:t}=e;return a&&t?`${a}:\n${t}`:t??""},KMe="undefined"!=typeof window&&"undefined"!=typeof document;async function HMe(e){if(!KMe)throw new Error("Image conversion is only supported in browser environments");return new Promise(((a,t)=>{try{const n=new window.Image;n.crossOrigin="anonymous",n.onload=()=>{try{const e=document.createElement("canvas");e.width=n.naturalWidth,e.height=n.naturalHeight;const i=e.getContext("2d");if(!i)return void t(new Error("Failed to get canvas context"));i.drawImage(n,0,0);const r=e.toDataURL("image/png",1);a(r)}catch(e){t(e)}},n.onerror=()=>{t(new Error("Failed to load image"))},n.src=e}catch(n){t(n)}}))}function IMe(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]}const FMe=e=>{const{channelSenderId:a,smsChannelSenders:t}=e;return t?.find((e=>e.channelSender.id===a))?.channelSender.channelSenderMetadata.friendlyName??t?.find((e=>e.channelSender.id===a))?.channelSender.channelSenderMetadata.from??a},GMe=e=>{switch(e){case"default":default:return"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200";case"subtle":return"inline-flex items-center font-medium mx-[1px] leading-none align-middle px-1 py-0.5 rounded-md bg-white/30 text-inherit shadow-[0_0_0_1px_rgba(0,0,0,0.05)]";case"minimal":return"inline-flex items-center px-1.5 py-0.5 rounded text-xs bg-gray-50 text-gray-700 font-medium border border-gray-200";case"inline":return"inline-flex items-center px-1 py-0.5 rounded text-xs bg-gray-100 text-gray-800 font-medium";case"badge":return"inline-flex items-center px-2 py-1 rounded-full text-xs bg-indigo-100 text-indigo-800 font-medium border border-indigo-200"}},VMe=({content:e,mergeFieldsResponse:n,variant:i="default",className:r="",asHtml:o=!0})=>{const s=a.useMemo((()=>n?.mergeFields?.flatMap((e=>e.entries))??[]),[n]),l=a.useMemo((()=>((e,a,t)=>e?e.replace(/\{\{.*?\}\}/g,(e=>{const n=a.find((a=>a.value===e));return n?`<span class="${GMe(t)}" data-merge-field="true" data-template-name="${n.value}" data-display-name="${n.label}">${n.label}</span>`:e})):"")(e,s,i)),[e,s,i]);if(!o){const a=e?.replace(/\{\{.*?\}\}/g,(e=>{const a=s.find((a=>a.value===e));return a?a.label:e}))||"";return t.jsx("span",{className:r,children:a})}return t.jsx("span",{className:r,dangerouslySetInnerHTML:{__html:l}})},JMe=({body:e,imageUrls:a})=>{const n=R5(),{getMergeFields:i,isGetting:r}=Qe(n?.id??void 0);return r||void 0===i?null:t.jsx("div",{className:"sms-preview-outer @container",children:t.jsxs("div",{className:"sms-phone-mockup",children:[t.jsx("div",{className:"sms-phone-notch"}),t.jsxs("div",{className:"sms-phone-inner",children:[a&&a.length>0&&a.map(((e,a)=>t.jsx("div",{className:"sms-message-row",children:t.jsx("div",{className:"sms-message-bubble",children:t.jsx("img",{src:e,alt:"MMS attachment",className:"sms-message-image",loading:"lazy"})})},e+a))),t.jsx("div",{className:"sms-message-row",children:t.jsx("div",{className:"sms-message-bubble",children:t.jsx(VMe,{content:e,mergeFieldsResponse:i,variant:"subtle",className:"text-white"})})})]}),t.jsx("div",{className:"sms-phone-home-indicator"})]})})};function UMe(e){const a=r.useRef({value:e,previous:e});return r.useMemo((()=>(a.current.value!==e&&(a.current.previous=a.current.value,a.current.value=e),a.current.previous)),[e])}var WMe="Checkbox",[qMe,$Me]=u9(WMe),[ZMe,YMe]=qMe(WMe),QMe=r.forwardRef(((e,a)=>{const{__scopeCheckbox:n,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),f=FZ(a,(e=>g(e))),v=r.useRef(!1),y=!p||(m||!!p.closest("form")),[b=!1,k]=m9({prop:o,defaultProp:s,onChange:d}),S=r.useRef(b);return r.useEffect((()=>{const e=p?.form;if(e){const a=()=>k(S.current);return e.addEventListener("reset",a),()=>e.removeEventListener("reset",a)}}),[p,k]),t.jsxs(ZMe,{scope:n,state:b,disabled:u,children:[t.jsx(y9.button,{type:"button",role:"checkbox","aria-checked":tTe(b)?"mixed":b,"aria-required":l,"data-state":nTe(b),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:f,onKeyDown:l9(e.onKeyDown,(e=>{"Enter"===e.key&&e.preventDefault()})),onClick:l9(e.onClick,(e=>{k((e=>!!tTe(e)||!e)),y&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())}))}),y&&t.jsx(aTe,{control:p,bubbles:!v.current,name:i,value:c,checked:b,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"},defaultChecked:!tTe(s)&&s})]})}));QMe.displayName=WMe;var XMe="CheckboxIndicator",eTe=r.forwardRef(((e,a)=>{const{__scopeCheckbox:n,forceMount:i,...r}=e,o=YMe(XMe,n);return t.jsx($7,{present:i||tTe(o.state)||!0===o.state,children:t.jsx(y9.span,{"data-state":nTe(o.state),"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{pointerEvents:"none",...e.style}})})}));eTe.displayName=XMe;var aTe=e=>{const{control:a,checked:n,bubbles:i=!0,defaultChecked:o,...s}=e,l=r.useRef(null),u=UMe(n),c=M7(a);r.useEffect((()=>{const e=l.current,a=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(a,"checked").set;if(u!==n&&t){const a=new Event("click",{bubbles:i});e.indeterminate=tTe(n),t.call(e,!tTe(n)&&n),e.dispatchEvent(a)}}),[u,n,i]);const d=r.useRef(!tTe(n)&&n);return t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??d.current,...s,tabIndex:-1,ref:l,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function tTe(e){return"indeterminate"===e}function nTe(e){return tTe(e)?"indeterminate":e?"checked":"unchecked"}var iTe=QMe,rTe=eTe;const oTe=r.forwardRef((({className:e,...a},n)=>t.jsx(iTe,{ref:n,className:XO("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...a,children:t.jsx(rTe,{className:XO("flex items-center justify-center text-current"),children:t.jsx(tz,{className:"h-4 w-4"})})})));oTe.displayName=iTe.displayName;var sTe=.999,lTe=/[\\\/_+.#"@\[\(\{&]/,uTe=/[\\\/_+.#"@\[\(\{&]/g,cTe=/[\s-]/,dTe=/[\s-]/g;function mTe(e,a,t,n,i,r,o){if(r===a.length)return i===e.length?1:.99;var s=`${i},${r}`;if(void 0!==o[s])return o[s];for(var l,u,c,d,m=n.charAt(r),h=t.indexOf(m,i),p=0;h>=0;)(l=mTe(e,a,t,n,h+1,r+1,o))>p&&(h===i?l*=1:lTe.test(e.charAt(h-1))?(l*=.8,(c=e.slice(i,h-1).match(uTe))&&i>0&&(l*=Math.pow(sTe,c.length))):cTe.test(e.charAt(h-1))?(l*=.9,(d=e.slice(i,h-1).match(dTe))&&i>0&&(l*=Math.pow(sTe,d.length))):(l*=.17,i>0&&(l*=Math.pow(sTe,h-i))),e.charAt(h)!==a.charAt(r)&&(l*=.9999)),(l<.1&&t.charAt(h-1)===n.charAt(r+1)||n.charAt(r+1)===n.charAt(r)&&t.charAt(h-1)!==n.charAt(r))&&(.1*(u=mTe(e,a,t,n,h+1,r+2,o))>l&&(l=.1*u)),l>p&&(p=l),h=t.indexOf(m,h+1);return o[s]=p,p}function hTe(e){return e.toLowerCase().replace(dTe," ")}function pTe(e,a,t){return mTe(e=t&&t.length>0?""+(e+" "+t.join(" ")):e,a,hTe(e),hTe(a),0,0,{})}var gTe,fTe={exports:{}},vTe={};var yTe,bTe={};
|
|
83
|
+
*/$ve.exports="production"===process.env.NODE_ENV?function(){if(Uve)return Zve;Uve=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},t=Hve.useSyncExternalStore,n=a.useRef,i=a.useEffect,r=a.useMemo,o=a.useDebugValue;return Zve.useSyncExternalStoreWithSelector=function(a,s,l,u,c){var d=n(null);if(null===d.current){var m={hasValue:!1,value:null};d.current=m}else m=d.current;d=r((function(){function a(a){if(!i){if(i=!0,t=a,a=u(a),void 0!==c&&m.hasValue){var r=m.value;if(c(r,a))return n=r}return n=a}if(r=n,e(t,a))return r;var o=u(a);return void 0!==c&&c(r,o)?r:(t=a,n=o)}var t,n,i=!1,r=void 0===l?null:l;return[function(){return a(s())},null===r?void 0:function(){return a(r())}]}),[s,l,u,c]);var h=t(a,d[0],d[1]);return i((function(){m.hasValue=!0,m.value=h}),[h]),o(h),h},Zve}():(Yve||(Yve=1,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},t=Hve.useSyncExternalStore,n=a.useRef,i=a.useEffect,r=a.useMemo,o=a.useDebugValue;Qve.useSyncExternalStoreWithSelector=function(a,s,l,u,c){var d,m=n(null);null===m.current?m.current=d={hasValue:!1,value:null}:d=m.current;var h=r((function(){var a,t,n=!1,i=function(i){if(!n){n=!0,a=i;var r=u(i);if(void 0!==c&&d.hasValue){var o=d.value;if(c(o,r))return t=o,o}return t=r,r}var s=t;if(e(a,i))return s;var l=u(i);return void 0!==c&&c(s,l)?s:(a=i,t=l,l)},r=void 0===l?null:l;return[function(){return i(s())},null===r?void 0:function(){return i(r())}]}),[s,l,u,c]),p=t(a,h[0],h[1]);return i((function(){d.hasValue=!0,d.value=p}),[p]),o(p),p},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Qve);var Xve=$ve.exports;const eye="undefined"!=typeof window?a.useLayoutEffect:a.useEffect;class aye{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach((e=>e()))},a=this.editor;return a.on("transaction",e),()=>{a.off("transaction",e)}}}}const tye="production"!==process.env.NODE_ENV,nye="undefined"==typeof window,iye=nye||Boolean("undefined"!=typeof window&&window.next);class rye{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((e=>e()))}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return nye||iye?null:this.createEditor();if(this.options.current.immediatelyRender&&nye&&tye)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...e)=>{var a,t;return null===(t=(a=this.options.current).onBeforeCreate)||void 0===t?void 0:t.call(a,...e)},onBlur:(...e)=>{var a,t;return null===(t=(a=this.options.current).onBlur)||void 0===t?void 0:t.call(a,...e)},onCreate:(...e)=>{var a,t;return null===(t=(a=this.options.current).onCreate)||void 0===t?void 0:t.call(a,...e)},onDestroy:(...e)=>{var a,t;return null===(t=(a=this.options.current).onDestroy)||void 0===t?void 0:t.call(a,...e)},onFocus:(...e)=>{var a,t;return null===(t=(a=this.options.current).onFocus)||void 0===t?void 0:t.call(a,...e)},onSelectionUpdate:(...e)=>{var a,t;return null===(t=(a=this.options.current).onSelectionUpdate)||void 0===t?void 0:t.call(a,...e)},onTransaction:(...e)=>{var a,t;return null===(t=(a=this.options.current).onTransaction)||void 0===t?void 0:t.call(a,...e)},onUpdate:(...e)=>{var a,t;return null===(t=(a=this.options.current).onUpdate)||void 0===t?void 0:t.call(a,...e)},onContentError:(...e)=>{var a,t;return null===(t=(a=this.options.current).onContentError)||void 0===t?void 0:t.call(a,...e)},onDrop:(...e)=>{var a,t;return null===(t=(a=this.options.current).onDrop)||void 0===t?void 0:t.call(a,...e)},onPaste:(...e)=>{var a,t;return null===(t=(a=this.options.current).onPaste)||void 0===t?void 0:t.call(a,...e)}};return new xve(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,a){return Object.keys(e).every((t=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(t)||("extensions"===t&&e.extensions&&a.extensions?e.extensions.length===a.extensions.length&&e.extensions.every(((e,t)=>{var n;return e===(null===(n=a.extensions)||void 0===n?void 0:n[t])})):e[t]===a[t])))}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===e.length?rye.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=e);if(this.previousDeps.length===e.length&&this.previousDeps.every(((a,t)=>a===e[t])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,a=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===e?a&&a.setOptions(this.options.current):a&&!a.isDestroyed&&(a.destroy(),this.instanceId===e&&this.setEditor(null))}),1)}}function oye(e={},t=[]){const n=a.useRef(e);n.current=e;const[i]=a.useState((()=>new rye(n))),r=Hve.useSyncExternalStore(i.subscribe,i.getEditor,i.getServerSnapshot);return a.useDebugValue(r),a.useEffect(i.onRender(t)),function(e){var t;const[n]=a.useState((()=>new aye(e.editor))),i=Xve.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!==(t=e.equalityFn)&&void 0!==t?t:qve);eye((()=>n.watch(e.editor)),[e.editor,n]),a.useDebugValue(i)}({editor:r,selector:({transactionNumber:a})=>!1===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===a?0:a+1}),r}a.createContext({editor:null});const sye=a.createContext({onDragStart:void 0}),lye=a.forwardRef(((e,t)=>{const{onDragStart:n}=a.useContext(sye);return a.createElement(e.as||"div",{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})}));function uye(e){return!("function"!=typeof e||!e.prototype||!e.prototype.isReactComponent)}function cye(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.forward_ref)"!==e.$$typeof.toString()&&"react.forward_ref"!==e.$$typeof.description)}class dye{constructor(e,{editor:a,props:t={},as:i="div",className:r=""}){this.ref=null,this.id=Math.floor(4294967295*Math.random()).toString(),this.component=e,this.editor=a,this.props=t,this.element=document.createElement(i),this.element.classList.add("react-renderer"),r&&this.element.classList.add(...r.split(" ")),this.editor.isInitialized?n.flushSync((()=>{this.render()})):this.render()}render(){var e;const t=this.component,n=this.props,i=this.editor,r=function(){try{if(a.version)return parseInt(a.version.split(".")[0],10)>=19}catch{}return!1}(),o=function(e){if(uye(e))return!0;if(cye(e))return!0;if(function(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.memo)"!==e.$$typeof.toString()&&"react.memo"!==e.$$typeof.description)}(e)){const a=e.type;if(a)return uye(a)||cye(a)}return!1}(t),s={...n};!s.ref||r||o||delete s.ref,s.ref||!r&&!o||(s.ref=e=>{this.ref=e}),this.reactElement=a.createElement(t,{...s}),null===(e=null==i?void 0:i.contentComponent)||void 0===e||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const a=this.editor;null===(e=null==a?void 0:a.contentComponent)||void 0===e||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach((a=>{this.element.setAttribute(a,e[a])}))}}class mye extends jve{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:a.createRef()};if(!this.component.displayName){this.component.displayName=(e=>e.charAt(0).toUpperCase()+e.substring(1))(this.extension.name)}const t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&e.appendChild(this.contentDOMElement)}},n=this.component,i=a.memo((e=>a.createElement(sye.Provider,{value:t},a.createElement(n,e))));i.displayName="ReactNodeView",this.contentDOMElement=this.node.isLeaf?null:this.options.contentDOMElementTag?document.createElement(this.options.contentDOMElementTag):document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.style.whiteSpace="inherit");let r=this.node.isInline?"span":"div";this.options.as&&(r=this.options.as);const{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new dye(i,{editor:this.editor,props:e,as:r,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null===(e=this.renderer.element.firstElementChild)||void 0===e?void 0:e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:a}=this.editor.state.selection,t=this.getPos();if("number"==typeof t)if(e<=t&&a>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,a,t){const n=e=>{this.renderer.updateProps(e),"function"==typeof this.options.attrs&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){const i=this.node,r=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=a,this.innerDecorations=t,this.options.update({oldNode:i,oldDecorations:r,newNode:e,newDecorations:a,oldInnerDecorations:o,innerDecorations:t,updateProps:()=>n({node:e,decorations:a,innerDecorations:t})})}return e===this.node&&this.decorations===a&&this.innerDecorations===t||(this.node=e,this.decorations=a,this.innerDecorations=t,n({node:e,decorations:a,innerDecorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if("function"==typeof this.options.attrs){const a=yfe(this.node,this.editor.extensionManager.attributes);e=this.options.attrs({node:this.node,HTMLAttributes:a})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function hye(e,a){return t=>t.editor.contentComponent?new mye(e,t,a):{}}const pye=/^\s*>\s$/,gye=Pve.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return["blockquote",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[_ve({find:pye,type:this.type})]}}),fye=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,vye=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,yye=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,bye=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,kye=jfe.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Eve({find:fye,type:this.type}),Eve({find:yye,type:this.type})]},addPasteRules(){return[Lve({find:vye,type:this.type}),Lve({find:bye,type:this.type})]}}),Sye="textStyle",wye=/^\s*([-+*])\s$/,Aye=Pve.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:a})=>this.options.keepAttributes?a().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Sye)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=_ve({find:wye,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=_ve({find:wye,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Sye),editor:this.editor})),[e]}}),Cye=/(^|[^`])`([^`]+)`(?!`)/,Mye=/(^|[^`])`([^`]+)`(?!`)/g,Tye=jfe.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Eve({find:Cye,type:this.type})]},addPasteRules(){return[Lve({find:Mye,type:this.type})]}}),xye=/^```([a-z]+)?[\s\n]$/,Eye=/^~~~([a-z]+)?[\s\n]$/,Nye=Pve.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var a;const{languageClassPrefix:t}=this.options,n=[...(null===(a=e.firstElementChild)||void 0===a?void 0:a.classList)||[]].filter((e=>e.startsWith(t))).map((e=>e.replace(t,"")))[0];return n||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:a}){return["pre",vfe(this.options.HTMLAttributes,a),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:a})=>a.setNode(this.name,e),toggleCodeBlock:e=>({commands:a})=>a.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:a}=this.editor.state.selection;return!(!e||a.parent.type.name!==this.name)&&(!(!(1===a.pos)&&a.parent.textContent.length)&&this.editor.commands.clearNodes())},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:a}=e,{selection:t}=a,{$from:n,empty:i}=t;if(!i||n.parent.type!==this.type)return!1;const r=n.parentOffset===n.parent.nodeSize-2,o=n.parent.textContent.endsWith("\n\n");return!(!r||!o)&&e.chain().command((({tr:e})=>(e.delete(n.pos-2,n.pos),!0))).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:a}=e,{selection:t,doc:n}=a,{$from:i,empty:r}=t;if(!r||i.parent.type!==this.type)return!1;if(!(i.parentOffset===i.parent.nodeSize-2))return!1;const o=i.after();if(void 0===o)return!1;return n.nodeAt(o)?e.commands.command((({tr:e})=>(e.setSelection(Vde.near(n.resolve(o))),!0))):e.commands.exitCode()}}},addInputRules(){return[Nve({find:xye,type:this.type,getAttributes:e=>({language:e[1]})}),Nve({find:Eye,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new ume({key:new mme("codeBlockVSCodeHandler"),props:{handlePaste:(e,a)=>{if(!a.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const t=a.clipboardData.getData("text/plain"),n=a.clipboardData.getData("vscode-editor-data"),i=n?JSON.parse(n):void 0,r=null==i?void 0:i.mode;if(!t||!r)return!1;const{tr:o,schema:s}=e.state,l=s.text(t.replace(/\r\n?/g,"\n"));return o.replaceSelectionWith(this.type.create({language:r},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(qde.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),e.dispatch(o),!0}}})]}}),_ye=Pve.create({name:"doc",topNode:!0,content:"block+"});function Pye(e={}){return new ume({view:a=>new jye(a,e)})}class jye{constructor(e,a){var t;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(t=a.width)&&void 0!==t?t:1,this.color=!1===a.color?void 0:a.color||"black",this.class=a.class,this.handlers=["dragover","dragend","drop","dragleave"].map((a=>{let t=e=>{this[a](e)};return e.dom.addEventListener(a,t),{name:a,handler:t}}))}destroy(){this.handlers.forEach((({name:e,handler:a})=>this.editorView.dom.removeEventListener(e,a)))}update(e,a){null!=this.cursorPos&&a.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,a=this.editorView.state.doc.resolve(this.cursorPos),t=!a.parent.inlineContent,n=this.editorView.dom,i=n.getBoundingClientRect(),r=i.width/n.offsetWidth,o=i.height/n.offsetHeight;if(t){let t=a.nodeBefore,n=a.nodeAfter;if(t||n){let a=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(a){let i=a.getBoundingClientRect(),r=t?i.bottom:i.top;t&&n&&(r=(r+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;e={left:i.left,right:i.right,top:r-s,bottom:r+s}}}}if(!e){let a=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*r;e={left:a.left-t,right:a.left+t,top:a.top,bottom:a.bottom}}let s,l,u=this.editorView.dom.offsetParent;if(this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t),!u||u==document.body&&"static"==getComputedStyle(u).position)s=-pageXOffset,l=-pageYOffset;else{let e=u.getBoundingClientRect();s=e.left-u.scrollLeft*(e.width/u.offsetWidth),l=e.top-u.scrollTop*(e.height/u.offsetHeight)}this.element.style.left=(e.left-s)/r+"px",this.element.style.top=(e.top-l)/o+"px",this.element.style.width=(e.right-e.left)/r+"px",this.element.style.height=(e.bottom-e.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let a=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),t=a&&a.inside>=0&&this.editorView.state.doc.nodeAt(a.inside),n=t&&t.type.spec.disableDropCursor,i="function"==typeof n?n(this.editorView,a,e):n;if(a&&!i){let e=a.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Ede(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=a&&(e=a)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Lye=Ofe.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Pye(this.options)]}});class Bye extends Vde{constructor(e){super(e,e)}map(e,a){let t=e.resolve(a.map(this.head));return Bye.valid(t)?new Bye(t):Vde.near(t)}content(){return ece.empty}eq(e){return e instanceof Bye&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,a){if("number"!=typeof a.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Bye(e.resolve(a.pos))}getBookmark(){return new Rye(this.anchor)}static valid(e){let a=e.parent;if(a.isTextblock||!function(e){for(let a=e.depth;a>=0;a--){let t=e.index(a),n=e.node(a);if(0!=t)for(let e=n.child(t-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(n.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let a=e.depth;a>=0;a--){let t=e.indexAfter(a),n=e.node(a);if(t!=n.childCount)for(let e=n.child(t);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(n.type.spec.isolating)return!0}return!0}(e))return!1;let t=a.type.spec.allowGapCursor;if(null!=t)return t;let n=a.contentMatchAt(e.index()).defaultType;return n&&n.isTextblock}static findGapCursorFrom(e,a,t=!1){e:for(;;){if(!t&&Bye.valid(e))return e;let n=e.pos,i=null;for(let t=e.depth;;t--){let r=e.node(t);if(a>0?e.indexAfter(t)<r.childCount:e.index(t)>0){i=r.child(a>0?e.indexAfter(t):e.index(t)-1);break}if(0==t)return null;n+=a;let o=e.doc.resolve(n);if(Bye.valid(o))return o}for(;;){let r=a>0?i.firstChild:i.lastChild;if(!r){if(i.isAtom&&!i.isText&&!Zde.isSelectable(i)){e=e.doc.resolve(n+i.nodeSize*a),t=!1;continue e}break}i=r,n+=a;let o=e.doc.resolve(n);if(Bye.valid(o))return o}return null}}}Bye.prototype.visible=!1,Bye.findFrom=Bye.findGapCursorFrom,Vde.jsonID("gapcursor",Bye);class Rye{constructor(e){this.pos=e}map(e){return new Rye(e.map(this.pos))}resolve(e){let a=e.resolve(this.pos);return Bye.valid(a)?new Bye(a):Vde.near(a)}}const Dye=Kge({ArrowLeft:zye("horiz",-1),ArrowRight:zye("horiz",1),ArrowUp:zye("vert",-1),ArrowDown:zye("vert",1)});function zye(e,a){const t="vert"==e?a>0?"down":"up":a>0?"right":"left";return function(e,n,i){let r=e.selection,o=a>0?r.$to:r.$from,s=r.empty;if(r instanceof qde){if(!i.endOfTextblock(t)||0==o.depth)return!1;s=!1,o=e.doc.resolve(a>0?o.after():o.before())}let l=Bye.findGapCursorFrom(o,a,s);return!!l&&(n&&n(e.tr.setSelection(new Bye(l))),!0)}}function Oye(e,a,t){if(!e||!e.editable)return!1;let n=e.state.doc.resolve(a);if(!Bye.valid(n))return!1;let i=e.posAtCoords({left:t.clientX,top:t.clientY});return!(i&&i.inside>-1&&Zde.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new Bye(n))),!0)}function Kye(e,a){if("insertCompositionText"!=a.inputType||!(e.state.selection instanceof Bye))return!1;let{$from:t}=e.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(e.state.schema.nodes.text);if(!n)return!1;let i=que.empty;for(let o=n.length-1;o>=0;o--)i=que.from(n[o].createAndFill(null,i));let r=e.state.tr.replace(t.pos,t.pos,new ece(i,0,0));return r.setSelection(qde.near(r.doc.resolve(t.pos+1))),e.dispatch(r),!1}function Hye(e){if(!(e.selection instanceof Bye))return null;let a=document.createElement("div");return a.className="ProseMirror-gapcursor",Qpe.create(e.doc,[$pe.widget(e.selection.head,a,{key:"gapcursor"})])}const Iye=Ofe.create({name:"gapCursor",addProseMirrorPlugins:()=>[new ume({props:{decorations:Hye,createSelectionBetween:(e,a,t)=>a.pos==t.pos&&Bye.valid(t)?new Bye(t):null,handleClick:Oye,handleKeyDown:Dye,handleDOMEvents:{beforeinput:Kye}}})],extendNodeSchema(e){var a;return{allowGapCursor:null!==(a=kfe(hfe(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==a?a:null}}}),Fye=Pve.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",vfe(this.options.HTMLAttributes,e)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:e,chain:a,state:t,editor:n})=>e.first([()=>e.exitCode(),()=>e.command((()=>{const{selection:e,storedMarks:i}=t;if(e.$from.parent.type.spec.isolating)return!1;const{keepMarks:r}=this.options,{splittableMarks:o}=n.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return a().insertContent({type:this.name}).command((({tr:e,dispatch:a})=>{if(a&&s&&r){const a=s.filter((e=>o.includes(e.type.name)));e.ensureMarks(a)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Gye=Pve.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((e=>({tag:`h${e}`,attrs:{level:e}})))},renderHTML({node:e,HTMLAttributes:a}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,vfe(this.options.HTMLAttributes,a),0]},addCommands(){return{setHeading:e=>({commands:a})=>!!this.options.levels.includes(e.level)&&a.setNode(this.name,e),toggleHeading:e=>({commands:a})=>!!this.options.levels.includes(e.level)&&a.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce(((e,a)=>({...e,[`Mod-Alt-${a}`]:()=>this.editor.commands.toggleHeading({level:a})})),{})},addInputRules(){return this.options.levels.map((e=>Nve({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}})))}});var Vye=200,Jye=function(){};Jye.prototype.append=function(e){return e.length?(e=Jye.from(e),!this.length&&e||e.length<Vye&&this.leafAppend(e)||this.length<Vye&&e.leafPrepend(this)||this.appendInner(e)):this},Jye.prototype.prepend=function(e){return e.length?Jye.from(e).append(this):this},Jye.prototype.appendInner=function(e){return new Wye(this,e)},Jye.prototype.slice=function(e,a){return void 0===e&&(e=0),void 0===a&&(a=this.length),e>=a?Jye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,a))},Jye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Jye.prototype.forEach=function(e,a,t){void 0===a&&(a=0),void 0===t&&(t=this.length),a<=t?this.forEachInner(e,a,t,0):this.forEachInvertedInner(e,a,t,0)},Jye.prototype.map=function(e,a,t){void 0===a&&(a=0),void 0===t&&(t=this.length);var n=[];return this.forEach((function(a,t){return n.push(e(a,t))}),a,t),n},Jye.from=function(e){return e instanceof Jye?e:e&&e.length?new Uye(e):Jye.empty};var Uye=function(e){function a(a){e.call(this),this.values=a}e&&(a.__proto__=e),(a.prototype=Object.create(e&&e.prototype)).constructor=a;var t={length:{configurable:!0},depth:{configurable:!0}};return a.prototype.flatten=function(){return this.values},a.prototype.sliceInner=function(e,t){return 0==e&&t==this.length?this:new a(this.values.slice(e,t))},a.prototype.getInner=function(e){return this.values[e]},a.prototype.forEachInner=function(e,a,t,n){for(var i=a;i<t;i++)if(!1===e(this.values[i],n+i))return!1},a.prototype.forEachInvertedInner=function(e,a,t,n){for(var i=a-1;i>=t;i--)if(!1===e(this.values[i],n+i))return!1},a.prototype.leafAppend=function(e){if(this.length+e.length<=Vye)return new a(this.values.concat(e.flatten()))},a.prototype.leafPrepend=function(e){if(this.length+e.length<=Vye)return new a(e.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(a.prototype,t),a}(Jye);Jye.empty=new Uye([]);var Wye=function(e){function a(a,t){e.call(this),this.left=a,this.right=t,this.length=a.length+t.length,this.depth=Math.max(a.depth,t.depth)+1}return e&&(a.__proto__=e),(a.prototype=Object.create(e&&e.prototype)).constructor=a,a.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},a.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},a.prototype.forEachInner=function(e,a,t,n){var i=this.left.length;return!(a<i&&!1===this.left.forEachInner(e,a,Math.min(t,i),n))&&(!(t>i&&!1===this.right.forEachInner(e,Math.max(a-i,0),Math.min(this.length,t)-i,n+i))&&void 0)},a.prototype.forEachInvertedInner=function(e,a,t,n){var i=this.left.length;return!(a>i&&!1===this.right.forEachInvertedInner(e,a-i,Math.max(t,i)-i,n+i))&&(!(t<i&&!1===this.left.forEachInvertedInner(e,Math.min(a,i),t,n))&&void 0)},a.prototype.sliceInner=function(e,a){if(0==e&&a==this.length)return this;var t=this.left.length;return a<=t?this.left.slice(e,a):e>=t?this.right.slice(e-t,a-t):this.left.slice(e,t).append(this.right.slice(0,a-t))},a.prototype.leafAppend=function(e){var t=this.right.leafAppend(e);if(t)return new a(this.left,t)},a.prototype.leafPrepend=function(e){var t=this.left.leafPrepend(e);if(t)return new a(t,this.right)},a.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new a(this.left,new a(this.right,e)):new a(this,e)},a}(Jye);class qye{constructor(e,a){this.items=e,this.eventCount=a}popEvent(e,a){if(0==this.eventCount)return null;let t,n,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}a&&(t=this.remapping(i,this.items.length),n=t.maps.length);let r,o,s=e.tr,l=[],u=[];return this.items.forEach(((e,a)=>{if(!e.step)return t||(t=this.remapping(i,a+1),n=t.maps.length),n--,void u.push(e);if(t){u.push(new $ye(e.map));let a,i=e.step.map(t.slice(n));i&&s.maybeStep(i).doc&&(a=s.mapping.maps[s.mapping.maps.length-1],l.push(new $ye(a,void 0,void 0,l.length+u.length))),n--,a&&t.appendMap(a,n)}else s.maybeStep(e.step);return e.selection?(r=t?e.selection.map(t.slice(n)):e.selection,o=new qye(this.items.slice(0,i).append(u.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:s,selection:r}}addTransform(e,a,t,n){let i=[],r=this.eventCount,o=this.items,s=!n&&o.length?o.get(o.length-1):null;for(let u=0;u<e.steps.length;u++){let t,l=e.steps[u].invert(e.docs[u]),c=new $ye(e.mapping.maps[u],l,a);(t=s&&s.merge(c))&&(c=t,u?i.pop():o=o.slice(0,o.length-1)),i.push(c),a&&(r++,a=void 0),n||(s=c)}let l=r-t.depth;return l>Yye&&(o=function(e,a){let t;return e.forEach(((e,n)=>{if(e.selection&&0==a--)return t=n,!1})),e.slice(t)}(o,l),r-=l),new qye(o.append(i),r)}remapping(e,a){let t=new rde;return this.items.forEach(((a,n)=>{t.appendMap(a.map,null!=a.mirrorOffset&&n-a.mirrorOffset>=e?t.maps.length-a.mirrorOffset:void 0)}),e,a),t}addMaps(e){return 0==this.eventCount?this:new qye(this.items.append(e.map((e=>new $ye(e)))),this.eventCount)}rebased(e,a){if(!this.eventCount)return this;let t=[],n=Math.max(0,this.items.length-a),i=e.mapping,r=e.steps.length,o=this.eventCount;this.items.forEach((e=>{e.selection&&o--}),n);let s=a;this.items.forEach((a=>{let n=i.getMirror(--s);if(null==n)return;r=Math.min(r,n);let l=i.maps[n];if(a.step){let r=e.steps[n].invert(e.docs[n]),u=a.selection&&a.selection.map(i.slice(s+1,n));u&&o++,t.push(new $ye(l,r,u))}else t.push(new $ye(l))}),n);let l=[];for(let d=a;d<r;d++)l.push(new $ye(i.maps[d]));let u=this.items.slice(0,n).append(l).append(t),c=new qye(u,o);return c.emptyItemCount()>500&&(c=c.compress(this.items.length-t.length)),c}emptyItemCount(){let e=0;return this.items.forEach((a=>{a.step||e++})),e}compress(e=this.items.length){let a=this.remapping(0,e),t=a.maps.length,n=[],i=0;return this.items.forEach(((r,o)=>{if(o>=e)n.push(r),r.selection&&i++;else if(r.step){let e=r.step.map(a.slice(t)),o=e&&e.getMap();if(t--,o&&a.appendMap(o,t),e){let s=r.selection&&r.selection.map(a.slice(t));s&&i++;let l,u=new $ye(o.invert(),e,s),c=n.length-1;(l=n.length&&n[c].merge(u))?n[c]=l:n.push(u)}}else r.map&&t--}),this.items.length,0),new qye(Jye.from(n.reverse()),i)}}qye.empty=new qye(Jye.empty,0);let $ye=class e{constructor(e,a,t,n){this.map=e,this.step=a,this.selection=t,this.mirrorOffset=n}merge(a){if(this.step&&a.step&&!a.selection){let t=a.step.merge(this.step);if(t)return new e(t.getMap().invert(),t,this.selection)}}};class Zye{constructor(e,a,t,n,i){this.done=e,this.undone=a,this.prevRanges=t,this.prevTime=n,this.prevComposition=i}}const Yye=20;function Qye(e){let a=[];for(let t=e.length-1;t>=0&&0==a.length;t--)e[t].forEach(((e,t,n,i)=>a.push(n,i)));return a}function Xye(e,a){if(!e)return null;let t=[];for(let n=0;n<e.length;n+=2){let i=a.map(e[n],1),r=a.map(e[n+1],-1);i<=r&&t.push(i,r)}return t}let ebe=!1,abe=null;function tbe(e){let a=e.plugins;if(abe!=a){ebe=!1,abe=a;for(let e=0;e<a.length;e++)if(a[e].spec.historyPreserveItems){ebe=!0;break}}return ebe}const nbe=new mme("history"),ibe=new mme("closeHistory");function rbe(e={}){return new ume({key:nbe,state:{init:()=>new Zye(qye.empty,qye.empty,null,0,-1),apply:(a,t,n)=>function(e,a,t,n){let i,r=t.getMeta(nbe);if(r)return r.historyState;t.getMeta(ibe)&&(e=new Zye(e.done,e.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(0==t.steps.length)return e;if(o&&o.getMeta(nbe))return o.getMeta(nbe).redo?new Zye(e.done.addTransform(t,void 0,n,tbe(a)),e.undone,Qye(t.mapping.maps),e.prevTime,e.prevComposition):new Zye(e.done,e.undone.addTransform(t,void 0,n,tbe(a)),null,e.prevTime,e.prevComposition);if(!1===t.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=t.getMeta("rebased"))?new Zye(e.done.rebased(t,i),e.undone.rebased(t,i),Xye(e.prevRanges,t.mapping),e.prevTime,e.prevComposition):new Zye(e.done.addMaps(t.mapping.maps),e.undone.addMaps(t.mapping.maps),Xye(e.prevRanges,t.mapping),e.prevTime,e.prevComposition);{let i=t.getMeta("composition"),r=0==e.prevTime||!o&&e.prevComposition!=i&&(e.prevTime<(t.time||0)-n.newGroupDelay||!function(e,a){if(!a)return!1;if(!e.docChanged)return!0;let t=!1;return e.mapping.maps[0].forEach(((e,n)=>{for(let i=0;i<a.length;i+=2)e<=a[i+1]&&n>=a[i]&&(t=!0)})),t}(t,e.prevRanges)),s=o?Xye(e.prevRanges,t.mapping):Qye(t.mapping.maps);return new Zye(e.done.addTransform(t,r?a.selection.getBookmark():void 0,n,tbe(a)),qye.empty,s,t.time,null==i?e.prevComposition:i)}}(t,n,a,e)},config:e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(e,a){let t=a.inputType,n="historyUndo"==t?sbe:"historyRedo"==t?lbe:null;return!!n&&(a.preventDefault(),n(e.state,e.dispatch))}}}})}function obe(e,a){return(t,n)=>{let i=nbe.getState(t);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(n){let r=function(e,a,t){let n=tbe(a),i=nbe.get(a).spec.config,r=(t?e.undone:e.done).popEvent(a,n);if(!r)return null;let o=r.selection.resolve(r.transform.doc),s=(t?e.done:e.undone).addTransform(r.transform,a.selection.getBookmark(),i,n),l=new Zye(t?s:r.remaining,t?r.remaining:s,null,0,-1);return r.transform.setSelection(o).setMeta(nbe,{redo:t,historyState:l})}(i,t,e);r&&n(a?r.scrollIntoView():r)}return!0}}const sbe=obe(!1,!0),lbe=obe(!0,!0),ube=Ofe.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:a})=>sbe(e,a),redo:()=>({state:e,dispatch:a})=>lbe(e,a)}),addProseMirrorPlugins(){return[rbe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),cbe=Pve.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",vfe(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:a})=>{const{selection:t}=a,{$from:n,$to:i}=t,r=e();return 0===n.parentOffset?r.insertContentAt({from:Math.max(n.pos-1,0),to:i.pos},{type:this.name}):t instanceof Zde?r.insertContentAt(i.pos,{type:this.name}):r.insertContent({type:this.name}),r.command((({tr:e,dispatch:a})=>{var t;if(a){const{$to:a}=e.selection,n=a.end();if(a.nodeAfter)e.setSelection(a.nodeAfter.isTextblock?qde.create(e.doc,a.pos+1):a.nodeAfter.isBlock?Zde.create(e.doc,a.pos):qde.create(e.doc,a.pos));else{const i=null===(t=a.parent.type.contentMatch.defaultType)||void 0===t?void 0:t.create();i&&(e.insert(n,i),e.setSelection(qde.create(e.doc,n+1)))}e.scrollIntoView()}return!0})).run()}}},addInputRules(){return[(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type},new xfe({find:e.find,handler:({state:a,range:t,match:n})=>{const i=kfe(e.getAttributes,void 0,n)||{},{tr:r}=a,o=t.from;let s=t.to;const l=e.type.create(i);if(n[1]){let e=o+n[0].lastIndexOf(n[1]);e>s?e=s:s=e+n[1].length,r.insertText(n[0][n[0].length-1],o+n[0].length-1),r.replaceWith(e,s,l)}else n[0]&&r.insert(e.type.isInline?o:o-1,e.type.create(i)).delete(r.mapping.map(o),r.mapping.map(s));r.scrollIntoView()}}))];var e}}),dbe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,mbe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,hbe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,pbe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,gbe=jfe.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Eve({find:dbe,type:this.type}),Eve({find:hbe,type:this.type})]},addPasteRules(){return[Lve({find:mbe,type:this.type}),Lve({find:pbe,type:this.type})]}}),fbe=Pve.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",vfe(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),vbe="textStyle",ybe=/^(\d+)\.\s$/,bbe=Pve.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){const{start:a,...t}=e;return 1===a?["ol",vfe(this.options.HTMLAttributes,t),0]:["ol",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:a})=>this.options.keepAttributes?a().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(vbe)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=_ve({find:ybe,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,a)=>a.childCount+a.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=_ve({find:ybe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(vbe)}),joinPredicate:(e,a)=>a.childCount+a.attrs.start===+e[1],editor:this.editor})),[e]}}),kbe=Pve.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Sbe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,wbe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Abe=jfe.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",vfe(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Eve({find:Sbe,type:this.type})]},addPasteRules(){return[Lve({find:wbe,type:this.type})]}}),Cbe=Pve.create({name:"text",group:"inline"}),Mbe=Ofe.create({name:"starterKit",addExtensions(){const e=[];return!1!==this.options.bold&&e.push(kye.configure(this.options.bold)),!1!==this.options.blockquote&&e.push(gye.configure(this.options.blockquote)),!1!==this.options.bulletList&&e.push(Aye.configure(this.options.bulletList)),!1!==this.options.code&&e.push(Tye.configure(this.options.code)),!1!==this.options.codeBlock&&e.push(Nye.configure(this.options.codeBlock)),!1!==this.options.document&&e.push(_ye.configure(this.options.document)),!1!==this.options.dropcursor&&e.push(Lye.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&e.push(Iye.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&e.push(Fye.configure(this.options.hardBreak)),!1!==this.options.heading&&e.push(Gye.configure(this.options.heading)),!1!==this.options.history&&e.push(ube.configure(this.options.history)),!1!==this.options.horizontalRule&&e.push(cbe.configure(this.options.horizontalRule)),!1!==this.options.italic&&e.push(gbe.configure(this.options.italic)),!1!==this.options.listItem&&e.push(fbe.configure(this.options.listItem)),!1!==this.options.orderedList&&e.push(bbe.configure(this.options.orderedList)),!1!==this.options.paragraph&&e.push(kbe.configure(this.options.paragraph)),!1!==this.options.strike&&e.push(Abe.configure(this.options.strike)),!1!==this.options.text&&e.push(Cbe.configure(this.options.text)),e}}),Tbe=e=>t.jsx(lye,{as:"span",className:"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200",children:e.node.attrs.displayName}),xbe=Pve.create({name:"mergeField",group:"inline",inline:!0,atom:!0,addAttributes:()=>({templateName:{default:null,parseHTML:e=>e.getAttribute("data-template-name")},displayName:{default:null,parseHTML:e=>e.getAttribute("data-display-name")}}),parseHTML:()=>[{tag:"span[data-merge-field]"}],renderHTML:({HTMLAttributes:e})=>["span",vfe(e,{"data-merge-field":"true"})],renderText:({node:e})=>e.attrs.templateName,addNodeView:()=>hye(Tbe)}),Ebe=({value:e,onChange:n,className:i="",mergeFieldsResponse:r,placeholder:o="Enter text",ariaLabel:s="Insert merge field",icon:l="MergeField"})=>{const[u,c]=a.useState(!1),d=a.useRef(null),m=a.useRef(null),h=a.useMemo((()=>r?.mergeFields?.flatMap((e=>e.entries))??[]),[r]),p=a.useCallback((e=>{if(!e)return"";return e.replace(/\{\{.*?\}\}/g,(e=>{const a=h.find((a=>a.value===e));return a?`<span class="inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200" data-merge-field="true" data-template-name="${a.value}" data-display-name="${a.label}">${a.label}</span>`:e}))}),[h]),g=oye({extensions:[Mbe,xbe],content:"",editorProps:{attributes:{class:`min-h-[40px] px-3 py-2 border border-input bg-background hover:bg-accent/50 focus:bg-accent transition-colors placeholder:text-muted-foreground/50 rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent resize-none prose prose-sm max-w-none ${i}`,placeholder:o}},onUpdate:({editor:e})=>{const a=e.getText();n(a)}});a.useEffect((()=>{if(g&&e){if(g.getText()!==e){const a=p(e);g.commands.setContent(a,!1)}}}),[g,e,p]);const f=a.useCallback((e=>{if(g){const a=h.find((a=>a.value===e));a&&g.chain().focus().insertContent({type:"mergeField",attrs:{templateName:a.value,displayName:a.label}}).run()}c(!1)}),[g,h]);if(a.useEffect((()=>{if(u)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){const a=e.target;m.current&&!m.current.contains(a)&&d.current&&!d.current.contains(a)&&c(!1)}}),[u]),!g)return t.jsx("div",{children:"Loading editor..."});const v=V5[l]||V5.MergeField;return t.jsx("div",{className:"relative",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-1",children:t.jsx(Jve,{editor:g})}),r&&t.jsxs(t.Fragment,{children:[t.jsx(H5,{ref:d,type:"button",variant:"ghost",size:"icon",className:"ml-2 h-10 w-7 p-0 rounded-md border border-input shadow-sm hover:bg-accent/60 focus:bg-accent/80 transition-colors","aria-label":s,onClick:()=>c((e=>!e)),children:t.jsx(v,{className:"w-4 h-4"})}),u&&t.jsx("div",{ref:m,className:"absolute z-50 mt-2 right-0 w-56 bg-white border border-gray-200 rounded-lg shadow-lg p-1",style:{top:"100%"},children:0===h.length?t.jsx("div",{className:"px-4 py-2 text-muted-foreground text-sm",children:"No merge fields found"}):t.jsx("ul",{className:"py-1",children:h.map((e=>t.jsx("li",{children:t.jsx("button",{className:"w-full text-left px-4 py-2 hover:bg-accent/40 rounded text-sm transition-colors",onClick:()=>f(e.value),type:"button",children:e.label})},e.value)))})})]})]})})},Nbe=()=>{const[e,n]=a.useState("desktop"),i=a.useRef(null),r=a.useRef(null);return a.useEffect((()=>{const e=()=>n("desktop"),a=()=>n("mobile"),t=i.current,o=r.current;return t&&t.addEventListener("click",e),o&&o.addEventListener("click",a),()=>{t&&t.removeEventListener("click",e),o&&o.removeEventListener("click",a)}}),[]),t.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-0.5 shadow-inner border w-fit",children:[t.jsxs(H5,{ref:i,type:"button","aria-pressed":"desktop"===e,"aria-label":"Show desktop preview",className:"desktop-view-button toggle-desktop-button relative flex items-center justify-center px-2 py-0 rounded-md transition-colors duration-200"+("desktop"===e?" bg-background shadow text-primary":" bg-transparent text-muted-foreground hover:bg-accent"),variant:"ghost",style:{minWidth:32,minHeight:32},children:["desktop"===e&&t.jsx(o5.span,{layoutId:"toggle-indicator",className:"absolute inset-0 rounded-md border-2 bg-background/80 z-0 border-[color:var(--reach-primary)]",transition:{type:"spring",stiffness:400,damping:30}}),t.jsx("span",{className:"relative z-10 flex items-center justify-center",children:t.jsx(V5.DesktopIcon,{className:"w-4 h-4"})})]}),t.jsxs(H5,{ref:r,type:"button","aria-pressed":"mobile"===e,"aria-label":"Show mobile preview",className:"mobile-view-button toggle-mobile-button relative flex items-center justify-center px-2 py-0 rounded-md transition-colors duration-200"+("mobile"===e?" bg-background shadow text-primary":" bg-transparent text-muted-foreground hover:bg-accent"),variant:"ghost",style:{minWidth:32,minHeight:32},children:["mobile"===e&&t.jsx(o5.span,{layoutId:"toggle-indicator",className:"absolute inset-0 rounded-md border-2 bg-background/80 z-0 border-[color:var(--reach-primary)]",transition:{type:"spring",stiffness:400,damping:30}}),t.jsx("span",{className:"relative z-10 flex items-center justify-center",children:t.jsx(V5.MobileIcon,{className:"w-4 h-4"})})]})]})};function _be(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function Pbe(e){const a=jbe(e),n=r.forwardRef(((e,n)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Bbe);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 t.jsx(a,{...o,ref:n,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return t.jsx(a,{...o,ref:n,children:i})}));return n.displayName=`${e}.Slot`,n}function jbe(e){const a=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?function(...e){return a=>{let t=!1;const n=e.map((e=>{const n=_be(e,a);return t||"function"!=typeof n||(t=!0),n}));if(t)return()=>{for(let a=0;a<n.length;a++){const t=n[a];"function"==typeof t?t():_be(e[a],null)}}}}(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var Lbe=Symbol("radix.slottable");function Bbe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Lbe}var Rbe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const n=Pbe(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?n:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),Dbe=r.forwardRef(((e,a)=>t.jsx(Rbe.label,{...e,ref:a,onMouseDown:a=>{a.target.closest("button, input, select, textarea")||(e.onMouseDown?.(a),!a.defaultPrevented&&a.detail>1&&a.preventDefault())}})));Dbe.displayName="Label";var zbe=Dbe;const Obe=GD("text-foreground text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Kbe=r.forwardRef((({className:e,...a},n)=>t.jsx(zbe,{ref:n,className:XO(Obe(),e),...a})));function Hbe(e,[a,t]){return Math.min(t,Math.max(a,e))}function Ibe(e,a,{checkForDefaultPrevented:t=!0}={}){return function(n){if(e?.(n),!1===t||!n.defaultPrevented)return a?.(n)}}function Fbe(e,a=[]){let n=[];const i=()=>{const a=n.map((e=>r.createContext(e)));return function(t){const n=t?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...t,[e]:n}})),[t,n])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=n.length;n=[...n,i];const l=a=>{const{scope:n,children:i,...l}=a,u=n?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return t.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(t,n){const l=r.useContext(n?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${a}\``)}]},Gbe(i,...a)]}function Gbe(...e){const a=e[0];if(1===e.length)return a;const t=()=>{const t=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const n=t.reduce(((a,{useScope:t,scopeName:n})=>({...a,...t(e)[`__scope${n}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:n})),[n])}};return t.scopeName=a.scopeName,t}function Vbe(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function Jbe(...e){return a=>{let t=!1;const n=e.map((e=>{const n=Vbe(e,a);return t||"function"!=typeof n||(t=!0),n}));if(t)return()=>{for(let a=0;a<n.length;a++){const t=n[a];"function"==typeof t?t():Vbe(e[a],null)}}}}function Ube(...e){return r.useCallback(Jbe(...e),e)}function Wbe(e){const a=qbe(e),n=r.forwardRef(((e,n)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Zbe);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 t.jsx(a,{...o,ref:n,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return t.jsx(a,{...o,ref:n,children:i})}));return n.displayName=`${e}.Slot`,n}function qbe(e){const a=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?Jbe(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}Kbe.displayName=zbe.displayName;var $be=Symbol("radix.slottable");function Zbe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===$be}var Ybe=r.createContext(void 0);var Qbe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const n=Wbe(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?n:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});function Xbe(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}var eke,ake="dismissableLayer.update",tke="dismissableLayer.pointerDownOutside",nke="dismissableLayer.focusOutside",ike=r.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),rke=r.forwardRef(((e,a)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:l,onDismiss:u,...c}=e,d=r.useContext(ike),[m,h]=r.useState(null),p=m?.ownerDocument??globalThis?.document,[,g]=r.useState({}),f=Ube(a,(e=>h(e))),v=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),k=m?v.indexOf(m):-1,S=d.layersWithOutsidePointerEventsDisabled.size>0,w=k>=b,A=function(e,a=globalThis?.document){const t=Xbe(e),n=r.useRef(!1),i=r.useRef((()=>{}));return r.useEffect((()=>{const e=e=>{if(e.target&&!n.current){let n=function(){ske(tke,t,r,{discrete:!0})};const r={originalEvent:e};"touch"===e.pointerType?(a.removeEventListener("click",i.current),i.current=n,a.addEventListener("click",i.current,{once:!0})):n()}else a.removeEventListener("click",i.current);n.current=!1},r=window.setTimeout((()=>{a.addEventListener("pointerdown",e)}),0);return()=>{window.clearTimeout(r),a.removeEventListener("pointerdown",e),a.removeEventListener("click",i.current)}}),[a,t]),{onPointerDownCapture:()=>n.current=!0}}((e=>{const a=e.target,t=[...d.branches].some((e=>e.contains(a)));w&&!t&&(o?.(e),l?.(e),e.defaultPrevented||u?.())}),p),C=function(e,a=globalThis?.document){const t=Xbe(e),n=r.useRef(!1);return r.useEffect((()=>{const e=e=>{if(e.target&&!n.current){ske(nke,t,{originalEvent:e},{discrete:!1})}};return a.addEventListener("focusin",e),()=>a.removeEventListener("focusin",e)}),[a,t]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}((e=>{const a=e.target;[...d.branches].some((e=>e.contains(a)))||(s?.(e),l?.(e),e.defaultPrevented||u?.())}),p);return function(e,a=globalThis?.document){const t=Xbe(e);r.useEffect((()=>{const e=e=>{"Escape"===e.key&&t(e)};return a.addEventListener("keydown",e,{capture:!0}),()=>a.removeEventListener("keydown",e,{capture:!0})}),[t,a])}((e=>{k===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))}),p),r.useEffect((()=>{if(m)return n&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(eke=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),oke(),()=>{n&&1===d.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=eke)}}),[m,p,n,d]),r.useEffect((()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),oke())}),[m,d]),r.useEffect((()=>{const e=()=>g({});return document.addEventListener(ake,e),()=>document.removeEventListener(ake,e)}),[]),t.jsx(Qbe.div,{...c,ref:f,style:{pointerEvents:S?w?"auto":"none":void 0,...e.style},onFocusCapture:Ibe(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Ibe(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Ibe(e.onPointerDownCapture,A.onPointerDownCapture)})}));rke.displayName="DismissableLayer";function oke(){const e=new CustomEvent(ake);document.dispatchEvent(e)}function ske(e,a,t,{discrete:n}){const i=t.originalEvent.target,r=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:t});a&&i.addEventListener(e,a,{once:!0}),n?function(e,a){e&&o.flushSync((()=>e.dispatchEvent(a)))}(i,r):i.dispatchEvent(r)}r.forwardRef(((e,a)=>{const n=r.useContext(ike),i=r.useRef(null),o=Ube(a,i);return r.useEffect((()=>{const e=i.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}}),[n.branches]),t.jsx(Qbe.div,{...e,ref:o})})).displayName="DismissableLayerBranch";var lke=0;function uke(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var cke="focusScope.autoFocusOnMount",dke="focusScope.autoFocusOnUnmount",mke={bubbles:!1,cancelable:!0},hke=r.forwardRef(((e,a)=>{const{loop:n=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...l}=e,[u,c]=r.useState(null),d=Xbe(o),m=Xbe(s),h=r.useRef(null),p=Ube(a,(e=>c(e))),g=r.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;r.useEffect((()=>{if(i){let e=function(e){if(g.paused||!u)return;const a=e.target;u.contains(a)?h.current=a:vke(h.current,{select:!0})},a=function(e){if(g.paused||!u)return;const a=e.relatedTarget;null!==a&&(u.contains(a)||vke(h.current,{select:!0}))},t=function(e){if(document.activeElement===document.body)for(const a of e)a.removedNodes.length>0&&vke(u)};document.addEventListener("focusin",e),document.addEventListener("focusout",a);const n=new MutationObserver(t);return u&&n.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",a),n.disconnect()}}}),[i,u,g.paused]),r.useEffect((()=>{if(u){yke.add(g);const a=document.activeElement;if(!u.contains(a)){const t=new CustomEvent(cke,mke);u.addEventListener(cke,d),u.dispatchEvent(t),t.defaultPrevented||(!function(e,{select:a=!1}={}){const t=document.activeElement;for(const n of e)if(vke(n,{select:a}),document.activeElement!==t)return}((e=pke(u),e.filter((e=>"A"!==e.tagName))),{select:!0}),document.activeElement===a&&vke(u))}return()=>{u.removeEventListener(cke,d),setTimeout((()=>{const e=new CustomEvent(dke,mke);u.addEventListener(dke,m),u.dispatchEvent(e),e.defaultPrevented||vke(a??document.body,{select:!0}),u.removeEventListener(dke,m),yke.remove(g)}),0)}}var e}),[u,d,m,g]);const f=r.useCallback((e=>{if(!n&&!i)return;if(g.paused)return;const a=document.activeElement;if("Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&a){const t=e.currentTarget,[i,r]=function(e){const a=pke(e),t=gke(a,e),n=gke(a.reverse(),e);return[t,n]}(t);i&&r?e.shiftKey||a!==r?e.shiftKey&&a===i&&(e.preventDefault(),n&&vke(r,{select:!0})):(e.preventDefault(),n&&vke(i,{select:!0})):a===t&&e.preventDefault()}}),[n,i,g.paused]);return t.jsx(Qbe.div,{tabIndex:-1,...l,ref:p,onKeyDown:f})}));function pke(e){const a=[],t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.disabled||e.hidden||"INPUT"===e.tagName&&"hidden"===e.type?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;t.nextNode();)a.push(t.currentNode);return a}function gke(e,a){for(const t of e)if(!fke(t,{upTo:a}))return t}function fke(e,{upTo:a}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==a&&e===a)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function vke(e,{select:a=!1}={}){if(e&&e.focus){const t=document.activeElement;e.focus({preventScroll:!0}),e!==t&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&a&&e.select()}}hke.displayName="FocusScope";var yke=function(){let e=[];return{add(a){const t=e[0];a!==t&&t?.pause(),e=bke(e,a),e.unshift(a)},remove(a){e=bke(e,a),e[0]?.resume()}}}();function bke(e,a){const t=[...e],n=t.indexOf(a);return-1!==n&&t.splice(n,1),t}var kke=globalThis?.document?r.useLayoutEffect:()=>{},Ske=r[" useId ".trim().toString()]||(()=>{}),wke=0;function Ake(e){const[a,t]=r.useState(Ske());return kke((()=>{t((e=>e??String(wke++)))}),[e]),e||(a?`radix-${a}`:"")}var Cke=r.forwardRef(((e,a)=>{const{children:n,width:i=10,height:r=5,...o}=e;return t.jsx(Qbe.svg,{...o,ref:a,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:t.jsx("polygon",{points:"0,0 30,0 15,10"})})}));Cke.displayName="Arrow";var Mke=Cke;var Tke="Popper",[xke,Eke]=Fbe(Tke),[Nke,_ke]=xke(Tke),Pke=e=>{const{__scopePopper:a,children:n}=e,[i,o]=r.useState(null);return t.jsx(Nke,{scope:a,anchor:i,onAnchorChange:o,children:n})};Pke.displayName=Tke;var jke="PopperAnchor",Lke=r.forwardRef(((e,a)=>{const{__scopePopper:n,virtualRef:i,...o}=e,s=_ke(jke,n),l=r.useRef(null),u=Ube(a,l);return r.useEffect((()=>{s.onAnchorChange(i?.current||l.current)})),i?null:t.jsx(Qbe.div,{...o,ref:u})}));Lke.displayName=jke;var Bke="PopperContent",[Rke,Dke]=xke(Bke),zke=r.forwardRef(((e,a)=>{const{__scopePopper:n,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:m=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:f,...v}=e,y=_ke(Bke,n),[b,k]=r.useState(null),S=Ube(a,(e=>k(e))),[w,A]=r.useState(null),C=function(e){const[a,t]=r.useState(void 0);return kke((()=>{if(e){t({width:e.offsetWidth,height:e.offsetHeight});const a=new ResizeObserver((a=>{if(!Array.isArray(a))return;if(!a.length)return;const n=a[0];let i,r;if("borderBoxSize"in n){const e=n.borderBoxSize,a=Array.isArray(e)?e[0]:e;i=a.inlineSize,r=a.blockSize}else i=e.offsetWidth,r=e.offsetHeight;t({width:i,height:r})}));return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}t(void 0)}),[e]),a}(w),M=C?.width??0,T=C?.height??0,x=i+("center"!==s?"-"+s:""),E="number"==typeof m?m:{top:0,right:0,bottom:0,left:0,...m},N=Array.isArray(d)?d:[d],_=N.length>0,P={padding:E,boundary:N.filter(Ike),altBoundary:_},{refs:j,floatingStyles:L,placement:B,isPositioned:R,middlewareData:D}=p7({strategy:"fixed",placement:x,whileElementsMounted:(...e)=>e7(...e,{animationFrame:"always"===g}),elements:{reference:y.anchor},middleware:[f7({mainAxis:o+T,alignmentAxis:l}),c&&v7({mainAxis:!0,crossAxis:!1,limiter:"partial"===h?y7():void 0,...P}),c&&b7({...P}),k7({...P,apply:({elements:e,rects:a,availableWidth:t,availableHeight:n})=>{const{width:i,height:r}=a.reference,o=e.floating.style;o.setProperty("--radix-popper-available-width",`${t}px`),o.setProperty("--radix-popper-available-height",`${n}px`),o.setProperty("--radix-popper-anchor-width",`${i}px`),o.setProperty("--radix-popper-anchor-height",`${r}px`)}}),w&&w7({element:w,padding:u}),Fke({arrowWidth:M,arrowHeight:T}),p&&S7({strategy:"referenceHidden",...P})]}),[z,O]=Gke(B),K=Xbe(f);kke((()=>{R&&K?.()}),[R,K]);const H=D.arrow?.x,I=D.arrow?.y,F=0!==D.arrow?.centerOffset,[G,V]=r.useState();return kke((()=>{b&&V(window.getComputedStyle(b).zIndex)}),[b]),t.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:R?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:G,"--radix-popper-transform-origin":[D.transformOrigin?.x,D.transformOrigin?.y].join(" "),...D.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(Rke,{scope:n,placedSide:z,onArrowChange:A,arrowX:H,arrowY:I,shouldHideArrow:F,children:t.jsx(Qbe.div,{"data-side":z,"data-align":O,...v,ref:S,style:{...v.style,animation:R?void 0:"none"}})})})}));zke.displayName=Bke;var Oke="PopperArrow",Kke={top:"bottom",right:"left",bottom:"top",left:"right"},Hke=r.forwardRef((function(e,a){const{__scopePopper:n,...i}=e,r=Dke(Oke,n),o=Kke[r.placedSide];return t.jsx("span",{ref:r.onArrowChange,style:{position:"absolute",left:r.arrowX,top:r.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[r.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[r.placedSide],visibility:r.shouldHideArrow?"hidden":void 0},children:t.jsx(Mke,{...i,ref:a,style:{...i.style,display:"block"}})})}));function Ike(e){return null!==e}Hke.displayName=Oke;var Fke=e=>({name:"transformOrigin",options:e,fn(a){const{placement:t,rects:n,middlewareData:i}=a,r=0!==i.arrow?.centerOffset,o=r?0:e.arrowWidth,s=r?0:e.arrowHeight,[l,u]=Gke(t),c={start:"0%",center:"50%",end:"100%"}[u],d=(i.arrow?.x??0)+o/2,m=(i.arrow?.y??0)+s/2;let h="",p="";return"bottom"===l?(h=r?c:`${d}px`,p=-s+"px"):"top"===l?(h=r?c:`${d}px`,p=`${n.floating.height+s}px`):"right"===l?(h=-s+"px",p=r?c:`${m}px`):"left"===l&&(h=`${n.floating.width+s}px`,p=r?c:`${m}px`),{data:{x:h,y:p}}}});function Gke(e){const[a,t="center"]=e.split("-");return[a,t]}var Vke=Pke,Jke=Lke,Uke=zke,Wke=Hke,qke=r.forwardRef(((e,a)=>{const{container:i,...o}=e,[s,l]=r.useState(!1);kke((()=>l(!0)),[]);const u=i||s&&globalThis?.document?.body;return u?n.createPortal(t.jsx(Qbe.div,{...o,ref:a}),u):null}));qke.displayName="Portal";var $ke=r[" useInsertionEffect ".trim().toString()]||kke;function Zke({prop:e,defaultProp:a,onChange:t=()=>{},caller:n}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[t,n]=r.useState(e),i=r.useRef(t),o=r.useRef(a);return $ke((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==t&&(o.current?.(t),i.current=t)}),[t,i]),[t,n,o]}({defaultProp:a,onChange:t}),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,n])}const c=r.useCallback((a=>{if(l){const t=function(e){return"function"==typeof e}(a)?a(e):a;t!==e&&s.current?.(t)}else o(a)}),[l,e,o,s]);return[u,c]}var Yke=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});r.forwardRef(((e,a)=>t.jsx(Qbe.span,{...e,ref:a,style:{...Yke,...e.style}}))).displayName="VisuallyHidden";var Qke=[" ","Enter","ArrowUp","ArrowDown"],Xke=[" ","Enter"],eSe="Select",[aSe,tSe,nSe]=function(e){const n=e+"CollectionProvider",[i,r]=Fbe(n),[o,s]=i(n,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:n,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return t.jsx(o,{scope:n,itemMap:s,collectionRef:r,children:i})};l.displayName=n;const u=e+"CollectionSlot",c=Wbe(u),d=a.forwardRef(((e,a)=>{const{scope:n,children:i}=e,r=Ube(a,s(u,n).collectionRef);return t.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=Wbe(m),g=a.forwardRef(((e,n)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=Ube(n,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),t.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(t){const n=s(e+"CollectionConsumer",t);return a.useCallback((()=>{const e=n.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(n.itemMap.values()).sort(((e,t)=>a.indexOf(e.ref.current)-a.indexOf(t.ref.current)))}),[n.collectionRef,n.itemMap])},r]}(eSe),[iSe,rSe]=Fbe(eSe,[nSe,Eke]),oSe=Eke(),[sSe,lSe]=iSe(eSe),[uSe,cSe]=iSe(eSe),dSe=e=>{const{__scopeSelect:a,children:n,open:i,defaultOpen:o,onOpenChange:s,value:l,defaultValue:u,onValueChange:c,dir:d,name:m,autoComplete:h,disabled:p,required:g,form:f}=e,v=oSe(a),[y,b]=r.useState(null),[k,S]=r.useState(null),[w,A]=r.useState(!1),C=function(e){const a=r.useContext(Ybe);return e||a||"ltr"}(d),[M,T]=Zke({prop:i,defaultProp:o??!1,onChange:s,caller:eSe}),[x,E]=Zke({prop:l,defaultProp:u,onChange:c,caller:eSe}),N=r.useRef(null),_=!y||(f||!!y.closest("form")),[P,j]=r.useState(new Set),L=Array.from(P).map((e=>e.props.value)).join(";");return t.jsx(Vke,{...v,children:t.jsxs(sSe,{required:g,scope:a,trigger:y,onTriggerChange:b,valueNode:k,onValueNodeChange:S,valueNodeHasChildren:w,onValueNodeHasChildrenChange:A,contentId:Ake(),value:x,onValueChange:E,open:M,onOpenChange:T,dir:C,triggerPointerDownPosRef:N,disabled:p,children:[t.jsx(aSe.Provider,{scope:a,children:t.jsx(uSe,{scope:e.__scopeSelect,onNativeOptionAdd:r.useCallback((e=>{j((a=>new Set(a).add(e)))}),[]),onNativeOptionRemove:r.useCallback((e=>{j((a=>{const t=new Set(a);return t.delete(e),t}))}),[]),children:n})}),_?t.jsxs(QSe,{"aria-hidden":!0,required:g,tabIndex:-1,name:m,autoComplete:h,value:x,onChange:e=>E(e.target.value),disabled:p,form:f,children:[void 0===x?t.jsx("option",{value:""}):null,Array.from(P)]},L):null]})})};dSe.displayName=eSe;var mSe="SelectTrigger",hSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,disabled:i=!1,...o}=e,s=oSe(n),l=lSe(mSe,n),u=l.disabled||i,c=Ube(a,l.onTriggerChange),d=tSe(n),m=r.useRef("touch"),[h,p,g]=ewe((e=>{const a=d().filter((e=>!e.disabled)),t=a.find((e=>e.value===l.value)),n=awe(a,e,t);void 0!==n&&l.onValueChange(n.value)})),f=e=>{u||(l.onOpenChange(!0),g()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return t.jsx(Jke,{asChild:!0,...s,children:t.jsx(Qbe.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":XSe(l.value)?"":void 0,...o,ref:c,onClick:Ibe(o.onClick,(e=>{e.currentTarget.focus(),"mouse"!==m.current&&f(e)})),onPointerDown:Ibe(o.onPointerDown,(e=>{m.current=e.pointerType;const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(f(e),e.preventDefault())})),onKeyDown:Ibe(o.onKeyDown,(e=>{const a=""!==h.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),a&&" "===e.key||Qke.includes(e.key)&&(f(),e.preventDefault())}))})})}));hSe.displayName=mSe;var pSe="SelectValue",gSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,className:i,style:r,children:o,placeholder:s="",...l}=e,u=lSe(pSe,n),{onValueNodeHasChildrenChange:c}=u,d=void 0!==o,m=Ube(a,u.onValueNodeChange);return kke((()=>{c(d)}),[c,d]),t.jsx(Qbe.span,{...l,ref:m,style:{pointerEvents:"none"},children:XSe(u.value)?t.jsx(t.Fragment,{children:s}):o})}));gSe.displayName=pSe;var fSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,children:i,...r}=e;return t.jsx(Qbe.span,{"aria-hidden":!0,...r,ref:a,children:i||"▼"})}));fSe.displayName="SelectIcon";var vSe=e=>t.jsx(qke,{asChild:!0,...e});vSe.displayName="SelectPortal";var ySe="SelectContent",bSe=r.forwardRef(((e,a)=>{const n=lSe(ySe,e.__scopeSelect),[i,s]=r.useState();if(kke((()=>{s(new DocumentFragment)}),[]),!n.open){const a=i;return a?o.createPortal(t.jsx(SSe,{scope:e.__scopeSelect,children:t.jsx(aSe.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),a):null}return t.jsx(CSe,{...e,ref:a})}));bSe.displayName=ySe;var kSe=10,[SSe,wSe]=iSe(ySe),ASe=Wbe("SelectContent.RemoveScroll"),CSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:l,side:u,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:f,hideWhenDetached:v,avoidCollisions:y,...b}=e,k=lSe(ySe,n),[S,w]=r.useState(null),[A,C]=r.useState(null),M=Ube(a,(e=>w(e))),[T,x]=r.useState(null),[E,N]=r.useState(null),_=tSe(n),[P,j]=r.useState(!1),L=r.useRef(!1);r.useEffect((()=>{if(S)return Q$(S)}),[S]),r.useEffect((()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??uke()),document.body.insertAdjacentElement("beforeend",e[1]??uke()),lke++,()=>{1===lke&&document.querySelectorAll("[data-radix-focus-guard]").forEach((e=>e.remove())),lke--}}),[]);const B=r.useCallback((e=>{const[a,...t]=_().map((e=>e.ref.current)),[n]=t.slice(-1),i=document.activeElement;for(const r of e){if(r===i)return;if(r?.scrollIntoView({block:"nearest"}),r===a&&A&&(A.scrollTop=0),r===n&&A&&(A.scrollTop=A.scrollHeight),r?.focus(),document.activeElement!==i)return}}),[_,A]),R=r.useCallback((()=>B([T,S])),[B,T,S]);r.useEffect((()=>{P&&R()}),[P,R]);const{onOpenChange:D,triggerPointerDownPosRef:z}=k;r.useEffect((()=>{if(S){let e={x:0,y:0};const a=a=>{e={x:Math.abs(Math.round(a.pageX)-(z.current?.x??0)),y:Math.abs(Math.round(a.pageY)-(z.current?.y??0))}},t=t=>{e.x<=10&&e.y<=10?t.preventDefault():S.contains(t.target)||D(!1),document.removeEventListener("pointermove",a),z.current=null};return null!==z.current&&(document.addEventListener("pointermove",a),document.addEventListener("pointerup",t,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",t,{capture:!0})}}}),[S,D,z]),r.useEffect((()=>{const e=()=>D(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}}),[D]);const[O,K]=ewe((e=>{const a=_().filter((e=>!e.disabled)),t=a.find((e=>e.ref.current===document.activeElement)),n=awe(a,e,t);n&&setTimeout((()=>n.ref.current.focus()))})),H=r.useCallback(((e,a,t)=>{const n=!L.current&&!t;(void 0!==k.value&&k.value===a||n)&&(x(e),n&&(L.current=!0))}),[k.value]),I=r.useCallback((()=>S?.focus()),[S]),F=r.useCallback(((e,a,t)=>{(void 0!==k.value&&k.value===a||!L.current&&!t)&&N(e)}),[k.value]),G="popper"===i?TSe:MSe,V=G===TSe?{side:u,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:f,hideWhenDetached:v,avoidCollisions:y}:{};return t.jsx(SSe,{scope:n,content:S,viewport:A,onViewportChange:C,itemRefCallback:H,selectedItem:T,onItemLeave:I,itemTextRefCallback:F,focusSelectedItem:R,selectedItemText:E,position:i,isPositioned:P,searchRef:O,children:t.jsx(J$,{as:ASe,allowPinchZoom:!0,children:t.jsx(hke,{asChild:!0,trapped:k.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Ibe(o,(e=>{k.trigger?.focus({preventScroll:!0}),e.preventDefault()})),children:t.jsx(rke,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>k.onOpenChange(!1),children:t.jsx(G,{role:"listbox",id:k.contentId,"data-state":k.open?"open":"closed",dir:k.dir,onContextMenu:e=>e.preventDefault(),...b,...V,onPlaced:()=>j(!0),ref:M,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Ibe(b.onKeyDown,(e=>{const a=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),a||1!==e.key.length||K(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let a=_().filter((e=>!e.disabled)).map((e=>e.ref.current));if(["ArrowUp","End"].includes(e.key)&&(a=a.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const t=a.indexOf(e.target);a=a.slice(t+1)}setTimeout((()=>B(a))),e.preventDefault()}}))})})})})})}));CSe.displayName="SelectContentImpl";var MSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,onPlaced:i,...o}=e,s=lSe(ySe,n),l=wSe(ySe,n),[u,c]=r.useState(null),[d,m]=r.useState(null),h=Ube(a,(e=>m(e))),p=tSe(n),g=r.useRef(!1),f=r.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:k}=l,S=r.useCallback((()=>{if(s.trigger&&s.valueNode&&u&&d&&v&&y&&b){const e=s.trigger.getBoundingClientRect(),a=d.getBoundingClientRect(),t=s.valueNode.getBoundingClientRect(),n=b.getBoundingClientRect();if("rtl"!==s.dir){const i=t.left-(n.left-a.left),r=e.width+(e.left-i),o=Math.max(r,a.width),s=window.innerWidth-kSe,l=Hbe(i,[kSe,Math.max(kSe,s-o)]);u.style.minWidth=r+"px",u.style.left=l+"px"}else{const i=window.innerWidth-t.right-(a.right-n.right),r=window.innerWidth-e.right-i,o=e.width+r,s=Math.max(o,a.width),l=window.innerWidth-kSe,c=Hbe(i,[kSe,Math.max(kSe,l-s)]);u.style.minWidth=o+"px",u.style.right=c+"px"}const r=p(),o=window.innerHeight-2*kSe,l=v.scrollHeight,c=window.getComputedStyle(d),m=parseInt(c.borderTopWidth,10),h=parseInt(c.paddingTop,10),f=parseInt(c.borderBottomWidth,10),k=m+h+l+parseInt(c.paddingBottom,10)+f,S=Math.min(5*y.offsetHeight,k),w=window.getComputedStyle(v),A=parseInt(w.paddingTop,10),C=parseInt(w.paddingBottom,10),M=e.top+e.height/2-kSe,T=o-M,x=y.offsetHeight/2,E=m+h+(y.offsetTop+x),N=k-E;if(E<=M){const e=r.length>0&&y===r[r.length-1].ref.current;u.style.bottom="0px";const a=Math.max(T,x+(e?C:0)+(d.clientHeight-v.offsetTop-v.offsetHeight)+f);u.style.height=E+a+"px"}else{const e=r.length>0&&y===r[0].ref.current;u.style.top="0px";const a=Math.max(M,m+v.offsetTop+(e?A:0)+x);u.style.height=a+N+"px",v.scrollTop=E-M+v.offsetTop}u.style.margin=`${kSe}px 0`,u.style.minHeight=S+"px",u.style.maxHeight=o+"px",i?.(),requestAnimationFrame((()=>g.current=!0))}}),[p,s.trigger,s.valueNode,u,d,v,y,b,s.dir,i]);kke((()=>S()),[S]);const[w,A]=r.useState();kke((()=>{d&&A(window.getComputedStyle(d).zIndex)}),[d]);const C=r.useCallback((e=>{e&&!0===f.current&&(S(),k?.(),f.current=!1)}),[S,k]);return t.jsx(xSe,{scope:n,contentWrapper:u,shouldExpandOnScrollRef:g,onScrollButtonChange:C,children:t.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:t.jsx(Qbe.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})}));MSe.displayName="SelectItemAlignedPosition";var TSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,align:i="start",collisionPadding:r=kSe,...o}=e,s=oSe(n);return t.jsx(Uke,{...s,...o,ref:a,align:i,collisionPadding:r,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})}));TSe.displayName="SelectPopperPosition";var[xSe,ESe]=iSe(ySe,{}),NSe="SelectViewport",_Se=r.forwardRef(((e,a)=>{const{__scopeSelect:n,nonce:i,...o}=e,s=wSe(NSe,n),l=ESe(NSe,n),u=Ube(a,s.onViewportChange),c=r.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),t.jsx(aSe.Slot,{scope:n,children:t.jsx(Qbe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ibe(o.onScroll,(e=>{const a=e.currentTarget,{contentWrapper:t,shouldExpandOnScrollRef:n}=l;if(n?.current&&t){const e=Math.abs(c.current-a.scrollTop);if(e>0){const n=window.innerHeight-2*kSe,i=parseFloat(t.style.minHeight),r=parseFloat(t.style.height),o=Math.max(i,r);if(o<n){const i=o+e,r=Math.min(n,i),s=i-r;t.style.height=r+"px","0px"===t.style.bottom&&(a.scrollTop=s>0?s:0,t.style.justifyContent="flex-end")}}}c.current=a.scrollTop}))})})]})}));_Se.displayName=NSe;var PSe="SelectGroup",[jSe,LSe]=iSe(PSe),BSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e,r=Ake();return t.jsx(jSe,{scope:n,id:r,children:t.jsx(Qbe.div,{role:"group","aria-labelledby":r,...i,ref:a})})}));BSe.displayName=PSe;var RSe="SelectLabel",DSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e,r=LSe(RSe,n);return t.jsx(Qbe.div,{id:r.id,...i,ref:a})}));DSe.displayName=RSe;var zSe="SelectItem",[OSe,KSe]=iSe(zSe),HSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,value:i,disabled:o=!1,textValue:s,...l}=e,u=lSe(zSe,n),c=wSe(zSe,n),d=u.value===i,[m,h]=r.useState(s??""),[p,g]=r.useState(!1),f=Ube(a,(e=>c.itemRefCallback?.(e,i,o))),v=Ake(),y=r.useRef("touch"),b=()=>{o||(u.onValueChange(i),u.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return t.jsx(OSe,{scope:n,value:i,disabled:o,textId:v,isSelected:d,onItemTextChange:r.useCallback((e=>{h((a=>a||(e?.textContent??"").trim()))}),[]),children:t.jsx(aSe.ItemSlot,{scope:n,value:i,disabled:o,textValue:m,children:t.jsx(Qbe.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":d&&p,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:f,onFocus:Ibe(l.onFocus,(()=>g(!0))),onBlur:Ibe(l.onBlur,(()=>g(!1))),onClick:Ibe(l.onClick,(()=>{"mouse"!==y.current&&b()})),onPointerUp:Ibe(l.onPointerUp,(()=>{"mouse"===y.current&&b()})),onPointerDown:Ibe(l.onPointerDown,(e=>{y.current=e.pointerType})),onPointerMove:Ibe(l.onPointerMove,(e=>{y.current=e.pointerType,o?c.onItemLeave?.():"mouse"===y.current&&e.currentTarget.focus({preventScroll:!0})})),onPointerLeave:Ibe(l.onPointerLeave,(e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()})),onKeyDown:Ibe(l.onKeyDown,(e=>{""!==c.searchRef?.current&&" "===e.key||(Xke.includes(e.key)&&b()," "===e.key&&e.preventDefault())}))})})})}));HSe.displayName=zSe;var ISe="SelectItemText",FSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,className:i,style:s,...l}=e,u=lSe(ISe,n),c=wSe(ISe,n),d=KSe(ISe,n),m=cSe(ISe,n),[h,p]=r.useState(null),g=Ube(a,(e=>p(e)),d.onItemTextChange,(e=>c.itemTextRefCallback?.(e,d.value,d.disabled))),f=h?.textContent,v=r.useMemo((()=>t.jsx("option",{value:d.value,disabled:d.disabled,children:f},d.value)),[d.disabled,d.value,f]),{onNativeOptionAdd:y,onNativeOptionRemove:b}=m;return kke((()=>(y(v),()=>b(v))),[y,b,v]),t.jsxs(t.Fragment,{children:[t.jsx(Qbe.span,{id:d.textId,...l,ref:g}),d.isSelected&&u.valueNode&&!u.valueNodeHasChildren?o.createPortal(l.children,u.valueNode):null]})}));FSe.displayName=ISe;var GSe="SelectItemIndicator",VSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e;return KSe(GSe,n).isSelected?t.jsx(Qbe.span,{"aria-hidden":!0,...i,ref:a}):null}));VSe.displayName=GSe;var JSe="SelectScrollUpButton",USe=r.forwardRef(((e,a)=>{const n=wSe(JSe,e.__scopeSelect),i=ESe(JSe,e.__scopeSelect),[o,s]=r.useState(!1),l=Ube(a,i.onScrollButtonChange);return kke((()=>{if(n.viewport&&n.isPositioned){let e=function(){s(a.scrollTop>0)};const a=n.viewport;return e(),a.addEventListener("scroll",e),()=>a.removeEventListener("scroll",e)}}),[n.viewport,n.isPositioned]),o?t.jsx($Se,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:a}=n;e&&a&&(e.scrollTop=e.scrollTop-a.offsetHeight)}}):null}));USe.displayName=JSe;var WSe="SelectScrollDownButton",qSe=r.forwardRef(((e,a)=>{const n=wSe(WSe,e.__scopeSelect),i=ESe(WSe,e.__scopeSelect),[o,s]=r.useState(!1),l=Ube(a,i.onScrollButtonChange);return kke((()=>{if(n.viewport&&n.isPositioned){let e=function(){const e=a.scrollHeight-a.clientHeight,t=Math.ceil(a.scrollTop)<e;s(t)};const a=n.viewport;return e(),a.addEventListener("scroll",e),()=>a.removeEventListener("scroll",e)}}),[n.viewport,n.isPositioned]),o?t.jsx($Se,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:a}=n;e&&a&&(e.scrollTop=e.scrollTop+a.offsetHeight)}}):null}));qSe.displayName=WSe;var $Se=r.forwardRef(((e,a)=>{const{__scopeSelect:n,onAutoScroll:i,...o}=e,s=wSe("SelectScrollButton",n),l=r.useRef(null),u=tSe(n),c=r.useCallback((()=>{null!==l.current&&(window.clearInterval(l.current),l.current=null)}),[]);return r.useEffect((()=>()=>c()),[c]),kke((()=>{const e=u().find((e=>e.ref.current===document.activeElement));e?.ref.current?.scrollIntoView({block:"nearest"})}),[u]),t.jsx(Qbe.div,{"aria-hidden":!0,...o,ref:a,style:{flexShrink:0,...o.style},onPointerDown:Ibe(o.onPointerDown,(()=>{null===l.current&&(l.current=window.setInterval(i,50))})),onPointerMove:Ibe(o.onPointerMove,(()=>{s.onItemLeave?.(),null===l.current&&(l.current=window.setInterval(i,50))})),onPointerLeave:Ibe(o.onPointerLeave,(()=>{c()}))})})),ZSe=r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e;return t.jsx(Qbe.div,{"aria-hidden":!0,...i,ref:a})}));ZSe.displayName="SelectSeparator";var YSe="SelectArrow";r.forwardRef(((e,a)=>{const{__scopeSelect:n,...i}=e,r=oSe(n),o=lSe(YSe,n),s=wSe(YSe,n);return o.open&&"popper"===s.position?t.jsx(Wke,{...r,...i,ref:a}):null})).displayName=YSe;var QSe=r.forwardRef((({__scopeSelect:e,value:a,...n},i)=>{const o=r.useRef(null),s=Ube(i,o),l=function(e){const a=r.useRef({value:e,previous:e});return r.useMemo((()=>(a.current.value!==e&&(a.current.previous=a.current.value,a.current.value=e),a.current.previous)),[e])}(a);return r.useEffect((()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,"value").set;if(l!==a&&n){const t=new Event("change",{bubbles:!0});n.call(e,a),e.dispatchEvent(t)}}),[l,a]),t.jsx(Qbe.select,{...n,style:{...Yke,...n.style},ref:s,defaultValue:a})}));function XSe(e){return""===e||void 0===e}function ewe(e){const a=Xbe(e),t=r.useRef(""),n=r.useRef(0),i=r.useCallback((e=>{const i=t.current+e;a(i),function e(a){t.current=a,window.clearTimeout(n.current),""!==a&&(n.current=window.setTimeout((()=>e("")),1e3))}(i)}),[a]),o=r.useCallback((()=>{t.current="",window.clearTimeout(n.current)}),[]);return r.useEffect((()=>()=>window.clearTimeout(n.current)),[]),[t,i,o]}function awe(e,a,t){const n=a.length>1&&Array.from(a).every((e=>e===a[0]))?a[0]:a,i=t?e.indexOf(t):-1;let r=(o=e,s=Math.max(i,0),o.map(((e,a)=>o[(s+a)%o.length])));var o,s;1===n.length&&(r=r.filter((e=>e!==t)));const l=r.find((e=>e.textValue.toLowerCase().startsWith(n.toLowerCase())));return l!==t?l:void 0}QSe.displayName="SelectBubbleInput";var twe=hSe,nwe=fSe,iwe=vSe,rwe=bSe,owe=_Se,swe=DSe,lwe=HSe,uwe=FSe,cwe=VSe,dwe=USe,mwe=qSe,hwe=ZSe;const pwe=dSe,gwe=BSe,fwe=gSe,vwe=r.forwardRef((({className:e,children:a,...n},i)=>t.jsxs(twe,{ref:i,className:XO("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-border/10 px-3 py-2 text-sm shadow-sm ring-offset-background !placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[a,t.jsx(nwe,{asChild:!0,children:t.jsx(nz,{className:"h-4 w-4 opacity-50"})})]})));vwe.displayName=twe.displayName;const ywe=r.forwardRef((({className:e,...a},n)=>t.jsx(dwe,{ref:n,className:XO("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(oz,{className:"h-4 w-4"})})));ywe.displayName=dwe.displayName;const bwe=r.forwardRef((({className:e,...a},n)=>t.jsx(mwe,{ref:n,className:XO("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(nz,{className:"h-4 w-4"})})));bwe.displayName=mwe.displayName;const kwe=r.forwardRef((({className:e,children:a,position:n="popper",...i},r)=>t.jsx(iwe,{children:t.jsxs(rwe,{ref:r,className:XO("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...i,children:[t.jsx(ywe,{}),t.jsx(owe,{className:XO("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),t.jsx(bwe,{})]})})));kwe.displayName=rwe.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(swe,{ref:n,className:XO("px-2 py-1.5 text-sm font-semibold text-muted-foreground",e),...a}))).displayName=swe.displayName;const Swe=r.forwardRef((({className:e,children:a,...n},i)=>t.jsxs(lwe,{ref:i,className:XO("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[t.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(cwe,{children:t.jsx(tz,{className:"h-4 w-4"})})}),t.jsx(uwe,{children:a})]})));Swe.displayName=lwe.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(hwe,{ref:n,className:XO("-mx-1 my-1 h-px bg-muted",e),...a}))).displayName=hwe.displayName;const wwe=(e,t)=>{const[n,i]=a.useState(e);return a.useEffect((()=>{const a=setTimeout((()=>{i(e)}),t);return()=>clearTimeout(a)}),[e,t]),n},Awe=async()=>(await Le(s)).data,Cwe=async(e,a)=>(await Le(s,{method:"PATCH",body:JSON.stringify({uiDefaults:{[e]:a}})})).data,Mwe=["me"],Twe=()=>ye({queryKey:Mwe,queryFn:Awe,...Ae}),xwe=()=>{const e=ce(),{toast:a}=Ve(),t=Twe(),n=be({mutationFn:e=>(async e=>(await Le(s,{method:"PATCH",body:JSON.stringify({website:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Website updated 🚀"})},onError:()=>{a({title:"Failed to update website",description:"Please try again",variant:"destructive"})}}),i=be({mutationFn:e=>(async e=>(await Le(s,{method:"PATCH",body:JSON.stringify({locations:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Locations updated 🚀"})},onError:()=>{a({title:"Failed to update locations",description:"Please try again",variant:"destructive"})}}),r=be({mutationFn:e=>(async e=>(await Le(s,{method:"PATCH",body:JSON.stringify({branding:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Brand settings saved 🚀"})},onError:()=>{a({title:"Failed to save brand settings",description:"Please try again",variant:"destructive"})}}),o=be({mutationFn:e=>(async e=>{const a=e.company.address1?.trim()||e.company.city?.trim()||e.company.stateProvince?.trim()||e.company.zipCode?.trim(),t=e.company.name?.trim();if(!a&&!t)return{success:!0,message:"No updates needed"};const n={locations:[{addressLine1:e.company.address1?.trim()||"",addressLine2:e.company.address2?.trim(),locality:e.company.city?.trim()||"",district:e.company.stateProvince?.trim()||"",postalCode:e.company.zipCode?.trim()||"",countryCode:e.company.country?.trim()||""}],...t&&{name:e.company.name?.trim()}};try{return(await Le(s,{method:"PATCH",body:JSON.stringify(n)})).data}catch(i){throw i}})(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Business settings saved 🚀"})},onError:()=>{a({title:"Failed to save business settings",description:"Please try again",variant:"destructive"})}}),l=be({mutationFn:e=>(async e=>(await Le(s,{method:"PATCH",body:JSON.stringify({uiDefaults:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe}),a({title:"Business UI defaults updated 🚀"})},onError:()=>{a({title:"Failed to update business UI defaults",description:"Please try again",variant:"destructive"})}}),u=be({mutationFn:e=>Cwe(e.key,e.value),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe})},onError:()=>{a({title:"Failed to update business UI defaults",description:"Please try again",variant:"destructive"})}}),c=be({mutationFn:e=>(async e=>Cwe("emailHelpDialogShow",e))(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mwe})},onError:()=>{a({title:"Failed to update dialog state",description:"Please try again",variant:"destructive"})}});return{data:t.data,isLoading:t.isLoading,error:t.error,refetch:t.refetch,updateWebsite:n.mutate,updateLocations:i.mutate,updateBrandSettings:r.mutate,updateBusinessSettings:o.mutate,updateBusinessSettingsAsync:o.mutateAsync,updateBusinessUiDefaults:l.mutate,updateBusinessUiDefaultsAsync:l.mutateAsync,updateBusinessUiDefaultProperty:u.mutate,updateBusinessUiDefaultPropertyAsync:u.mutateAsync,toggleEmailHelpDialog:c.mutate,toggleEmailHelpDialogAsync:c.mutateAsync,isUpdatingWebsite:n.isPending,isUpdatingLocations:i.isPending,isUpdatingBrandSettings:r.isPending,isUpdatingBusinessSettings:o.isPending,isUpdatingBusinessUiDefaults:l.isPending,isUpdatingBusinessUiDefaultProperty:u.isPending,isTogglingEmailHelpDialog:c.isPending}},Ewe=({type:e})=>t.jsxs("div",{className:"w-full h-full min-h-[300px] flex flex-col items-center justify-center bg-gradient-to-b from-gray-50 to-white p-8",children:[t.jsx("div",{className:"mb-4 text-gray-300",children:t.jsx("svg",{className:"w-16 h-16",fill:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z"})})}),t.jsxs("p",{className:"text-gray-400 font-medium text-lg text-center mb-2",children:["No ","email"===e?"Email":"SMS"," Preview Available"]}),t.jsxs("p",{className:"text-gray-400 text-sm text-center",children:["Edit your ","email"===e?"Email":"SMS"," template to see a preview here"]})]});var Nwe=(e=>(e.WORKFLOW="workflow",e.RECIPIENTS="recipients",e.INSIGHTS="insights",e))(Nwe||{}),_we=(e=>(e.EMAIL="email",e.SMS="sms",e))(_we||{});const Pwe=[0,100,500],jwe=320;const Lwe=({html:e,onHeightChange:n})=>{const i=a.useRef(null),[r,o]=a.useState(200),s=R5(),{getMergeFields:l,isGetting:u}=Qe(s?.id??void 0),c=function(e,a){return e?e.replace(/\{\{.*?\}\}/g,(e=>{const t=a?.find((a=>a.value===e));return`<span class="merge-field-pill">${t?t.label:e}</span>`})):""}(e,l?.mergeFields?.flatMap((e=>e.entries))??[]);return a.useEffect((()=>{if(!c||!i.current)return;const e=i.current,a=()=>{const a=e.contentDocument||e.contentWindow?.document;if(!a)return;const t=a.createElement("style");t.textContent="html, body { height: auto !important; min-height: 0 !important; }",a.head.appendChild(t);const n=a.createElement("style");n.textContent="\n .merge-field-pill {\n display: inline-block;\n padding: 1px 6px;\n border-radius: 5px;\n background: #f3f4f6;\n color: #6b7280;\n font-size: 0.92em;\n border: 1px solid #e5e7eb;\n font-weight: 500;\n margin: 0 2px;\n vertical-align: middle;\n }\n ",a.head.appendChild(n);const i=a.createElement("script");i.textContent=`\n (function() {\n let lastHeight = 0;\n \n // Calculate max height from various measurements\n function getContentHeight() {\n const { body, documentElement: html } = document;\n return Math.max(\n body.scrollHeight,\n body.offsetHeight,\n html.clientHeight,\n html.scrollHeight,\n html.offsetHeight\n );\n }\n \n function reportHeight() {\n const height = getContentHeight();\n if (height !== lastHeight && height > 0) {\n lastHeight = height;\n window.parent.postMessage({\n type: 'IFRAME_HEIGHT_UPDATE',\n height: height + 10\n }, '*');\n }\n }\n \n // Setup observers for real-time monitoring\n if (window.ResizeObserver) {\n const observer = new ResizeObserver(() => requestAnimationFrame(reportHeight));\n observer.observe(document.body);\n observer.observe(document.documentElement);\n }\n \n // Handle image loading\n document.querySelectorAll('img').forEach(img => {\n if (!img.complete) {\n img.addEventListener('load', reportHeight);\n img.addEventListener('error', reportHeight);\n }\n });\n \n // Watch for DOM changes\n new MutationObserver(() => requestAnimationFrame(reportHeight))\n .observe(document.body, { childList: true, subtree: true });\n \n // Initial checks with progressive delays\n window.addEventListener('load', () => setTimeout(reportHeight, 100));\n document.addEventListener('DOMContentLoaded', reportHeight);\n ${Pwe.map((e=>`setTimeout(reportHeight, ${e});`)).join("\n ")}\n })();\n `,a.body.appendChild(i)},t=a=>{if("IFRAME_HEIGHT_UPDATE"===a.data?.type&&a.source===e.contentWindow){const e=a.data.height;e>0&&(o(e),n?.(e))}};return e.addEventListener("load",a),window.addEventListener("message",t),()=>{e.removeEventListener("load",a),window.removeEventListener("message",t)}}),[c,n,l,u]),t.jsx("div",u&&void 0===l?{className:"flex items-center justify-center py-5",children:t.jsx(lY,{text:["Fetching merge fields..."]})}:{className:"w-full h-full bg-white rounded-lg border-0 overflow-visible",children:e?t.jsx("iframe",{ref:i,title:lH("engage:states.email_preview_title","Email Preview"),srcDoc:c,className:"w-full block",style:{border:"none",backgroundColor:"white",width:"100%",height:`${r}px`,minHeight:"200px",overflow:"hidden"}}):t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(Ewe,{type:"email"})})})},Bwe=[{id:"dynamic-content",title:"Dynamic Content",image:"https://cdn.embedreach.com/assets/engage/merge-tags-demo.gif",imageAlt:"Merge Tags Demo",imageDesc:"Demonstration: Adding merge tags to personalize your emails",selectorTitle:"Dynamic Content",selectorSubtitle:"Dynamic content is a way to insert dynamic content into your email like name, email, or other details.",selectorIcon:t.jsx(Nz,{})},{id:"responsive-design",title:"Responsive Design",image:"https://cdn.embedreach.com/assets/engage/layout-mobile-desktop.gif",imageAlt:"Mobile Desktop Switch Demo",imageDesc:"Demonstration: Switching between mobile and desktop preview modes",selectorTitle:"Responsive Design",selectorSubtitle:"Switch between mobile and desktop preview modes to ensure your emails look great on all devices.",selectorIcon:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(qz,{className:"w-4 h-4"}),t.jsx(jz,{className:"w-4 h-4"})]})}],Rwe=()=>{const{toggleEmailHelpDialog:e,data:n}=xwe(),{toast:i}=Ve(),[r,o]=a.useState("dynamic-content"),s=!1!==n?.uiDefaults?.emailHelpDialogShow,l=Bwe.find((e=>e.id===r))??Bwe[0];return t.jsxs("div",{className:"p-6 overflow-y-auto",children:[t.jsxs("div",{className:"mb-8 text-center",children:[t.jsx("h2",{className:"text-2xl font-semibold mb-2",children:"Email Editor Help Center"}),t.jsx("p",{className:"text-gray-500",children:"Learn how to use our email editor's powerful features"})]}),t.jsx("div",{className:"mb-8 flex flex-col items-center min-h-[340px]",children:t.jsx(wY,{mode:"wait",children:t.jsxs(o5.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},exit:{opacity:0,y:-24},transition:{duration:.3},className:"w-full flex flex-col items-center",children:[t.jsx("h3",{className:"text-lg font-medium mb-2",children:l.title}),t.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-gray-50 w-full max-w-2xl",children:[t.jsx("img",{src:l.image,alt:l.imageAlt,className:"w-full shadow-lg max-w-md mx-auto"}),t.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/50 to-transparent p-4",children:t.jsx("p",{className:"text-white text-sm",children:l.imageDesc})})]})]},l.id)})}),t.jsx("div",{className:"flex flex-col gap-4 sm:flex-row sm:gap-6 max-w-xl mx-auto",children:Bwe.map((e=>t.jsx("div",{className:"flex-1",children:t.jsx(G5,{onClick:()=>o(e.id),title:e.selectorTitle,subtitle:e.selectorSubtitle,icon:e.selectorIcon,selected:r===e.id})},e.id)))}),s&&t.jsx("div",{className:"flex justify-center pt-4",children:t.jsx(H5,{size:"sm",onClick:()=>{e(!1),i({title:"Email editor help dialog will not show again!"})},children:"Don't show me again"})})]})},Dwe=({type:e})=>t.jsxs("div",{className:"flex items-start space-x-2 text-sm text-gray-600",children:[t.jsx("svg",{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),t.jsxs("span",{children:["Please configure at least one ",e," sender before editing the template"]})]}),zwe=({containerRef:e,stripoDialogDimensions:n,showSaving:i})=>(a.useEffect((()=>{const a=a=>{const t=e.current;if(!t)return;const n=t.querySelector("ui-editor");if(!n)return;const i=n.shadowRoot;if(!i)return;const r=i.host.getBoundingClientRect();const o=function(e){for(;e;){const a=getComputedStyle(e);if(("auto"===a.overflowY||"scroll"===a.overflowY)&&e.scrollHeight>e.clientHeight)return e;e=e.parentElement}return null}(i.elementFromPoint(a.clientX-r.left,a.clientY-r.top))||i.firstElementChild;o&&(o.scrollTop+=a.deltaY,o.scrollLeft+=a.deltaX,a.preventDefault())},t=e.current;return t&&t.addEventListener("wheel",a,{passive:!1}),()=>{t&&t.removeEventListener("wheel",a)}}),[e]),a.useEffect((()=>{const e="stripo-service-element-hider";let a=document.getElementById(e);return a||(a=document.createElement("style"),a.id=e,document.head.appendChild(a)),a.textContent='\n /* Hide service elements with title attributes */\n #stripoEditorContainer small.service-element[title],\n #stripoEditorContainer .service-element[title],\n #stripoEditorContainer span.service-element[title],\n #stripoEditorContainer [class*="service-element"][title] {\n display: none !important;\n visibility: hidden !important;\n opacity: 0 !important;\n position: absolute !important;\n left: -9999px !important;\n top: -9999px !important;\n width: 0 !important;\n height: 0 !important;\n overflow: hidden !important;\n pointer-events: none !important;\n }\n \n /* Also hide elements with our custom class */\n .stripo-hidden-service-element {\n display: none !important;\n visibility: hidden !important;\n opacity: 0 !important;\n position: absolute !important;\n left: -9999px !important;\n top: -9999px !important;\n width: 0 !important;\n height: 0 !important;\n overflow: hidden !important;\n pointer-events: none !important;\n }\n ',()=>{a&&a.parentNode&&a.parentNode.removeChild(a)}}),[]),a.useEffect((()=>{const a=e.current;if(!a)return;const t=()=>{const e=a.querySelector("ui-editor");if(!e)return null;const t=e.shadowRoot;return t||null},n=()=>{const e=t();if(!e)return;["small.service-element[title]",".service-element[title]","span.service-element[title]",'[class*="service-element"][title]'].forEach((a=>{e.querySelectorAll(a).forEach((e=>{const a=e,t=a.getAttribute("title")||"";/^\{\{.*\}\}$/.test(t.trim())&&(a.style.display="none",a.style.visibility="hidden",a.style.opacity="0",a.style.position="absolute",a.style.left="-9999px",a.style.top="-9999px",a.classList.add("stripo-hidden-service-element"),a.setAttribute("style",a.getAttribute("style")+"; display: none !important; visibility: hidden !important; opacity: 0 !important;"))}))}))};let i=null;let r=0;const o=setInterval((()=>{t()?(n(),(()=>{const e=t();e&&(i&&i.disconnect(),i=new MutationObserver((e=>{let a=!1;e.forEach(((e,t)=>{"childList"===e.type&&e.addedNodes.length>0&&(a=!0)})),a&&setTimeout((()=>{n()}),10)})),i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","title"]}))})(),clearInterval(o)):(r++,r>20&&clearInterval(o))}),100),s=setInterval((()=>{n()}),2e3);return()=>{i&&i.disconnect(),clearInterval(s),clearInterval(o)}}),[e]),t.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center",children:[t.jsx("div",{id:"externalSystemContainer",className:"flex items-center px-4 py-2"}),i&&t.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-black/50 flex items-center justify-center z-50",children:t.jsx(lY,{textColor:"text-white",text:["Saving..."]})}),t.jsx("div",{id:"stripoEditorContainer",ref:e,style:{width:n.width-75,height:n.height-75},className:"z-10"})]})),Owe="UiEditorScript",Kwe=e=>new Promise(((a,t)=>{const n=()=>{let t;e.forceRecreate&&(t=!0),window.UIEditor&&(window.UIEditor.initEditor(e.container,{...t&&{forceRecreate:t},metadata:{emailId:e.emailId},html:e.html,css:e.css,locale:"en",onTokenRefreshRequest:e=>{Promise.resolve().then((async()=>{try{const{token:a}=await(async()=>(await Le(`${m}/token`)).data)();e(a)}catch(a){}}))},messageSettingsEnabled:!1,conditionsEnabled:!1,syncModulesEnabled:!1,notifications:{info:console.info,error:console.error,warn:console.warn,success:console.log},mergeTags:e.mergeFields,mobileViewButtonSelector:".toggle-mobile-button",desktopViewButtonSelector:".toggle-desktop-button"}),a(void 0))};if(document.getElementById(Owe))n();else{const e=document.createElement("script");e.id=Owe,e.type="module",e.src="https://plugins.stripo.email/resources/uieditor/rev/2.21.0/UIEditor.js",e.onload=()=>{window.UIEditor?n():t(new Error("UIEditor not found after script load"))},e.onerror=e=>{t(e)},document.head.appendChild(e)}})),Hwe=({automation:e,setShowStripoEditor:n,saveClicked:i,setSaveClicked:r,stripoDialogDimensions:o,mergeFieldsResponse:s,cancelClicked:l,setCancelClicked:u,actionId:c})=>{const d=a.useRef(!1),m=a.useRef(null),{data:h,isLoading:p}=(e=>{const{automationId:a,actionId:t}=e;return ye({queryKey:Ue.templateForActionId(a,t),queryFn:()=>qe({automationId:a,actionId:t}),...Ce})})({automationId:e.id,actionId:c}),{data:g,isLoading:f}=(()=>{const e=ce();return{...ye({queryKey:Ue.editorData(),queryFn:We,...Ae}),invalidateEditorData:()=>e.invalidateQueries({queryKey:Ue.editorData()})}})(),[v,y]=a.useState(!1),[b,k]=a.useState(!1),{updateCommunicationGroup:S}=Ye(),w=a.useCallback((()=>{r(!1),u(!1),y(!1),k(!1),n(!1)}),[r,u,y,k,n]);return a.useEffect((()=>{if(i&&window.UIEditor&&h?.communicationGroupId&&window.StripoEditorApi?.actionsApi){window.StripoEditorApi.actionsApi.compileEmail({callback:function(e,a){e||(S({groupId:h.communicationGroupId,params:{emailHtmlBody:a}}),k(!0))},minimize:!0,mergeTags:[],forceAmp:!1,resetDataSavedFlag:!1,disableLineHeightsReplace:!0});window.StripoEditorApi.actionsApi.save((function(e){e||y(!0)}))}}),[i,m,r,n,h,S]),a.useEffect((()=>{(async()=>{v&&b&&(window.UIEditor&&window.UIEditor.removeEditor&&"function"==typeof window.UIEditor.removeEditor&&window.UIEditor.removeEditor(),w())})()}),[v,b,n,r,w]),a.useEffect((()=>{l&&(window.UIEditor&&window.UIEditor.removeEditor&&"function"==typeof window.UIEditor.removeEditor&&window.UIEditor.removeEditor(),w())}),[l,w]),a.useEffect((()=>{g?.businessId&&m.current&&h&&(d.current||(Kwe({emailId:h.communicationGroupId,html:h.html||"<div></div>",css:h.css||"",container:m.current,businessId:g.businessId,mergeFields:s.mergeFields||[],forceRecreate:h.forceRecreate}).catch((e=>{})),d.current=!0))}),[g,s,h]),t.jsx("div",p||f||!g||!h?{className:"w-full h-full flex flex-col items-center justify-center",children:t.jsx(lY,{text:["Loading editor..."]})}:{className:"w-full h-full flex flex-col",children:t.jsx(zwe,{containerRef:m,stripoDialogDimensions:o,showSaving:i})})},Iwe=({mergeFieldsResponse:e,emailChannelSendersWithChannelAccounts:n})=>{const i=R5(),r=B5(),{updateCommunicationGroup:o}=Ye(),{refetchAutomation:s}=ta(r?.id||""),{channelSenders:l}=Jre(),{channelAccounts:u}=Fre(),{state:{selectedActionId:c}}=a.useContext(S5),{state:{replyToSettingsText:d,replyToSettingsLink:m,fromNameSettingsText:h,fromNameSettingsLink:p}}=a.useContext(rY),{data:g,isLoading:f}=xwe(),[v,y]=a.useState(!1),[b,k]=a.useState(i?.emailChannelSenderId||null),[S,w]=a.useState(i?.emailSubject||null),[A,C]=a.useState(i?.emailPreviewText||null),[M,T]=a.useState(i?.emailHtmlBody||null),[x,E]=a.useState(!1),[N,_]=a.useState(!1),[P,j]=a.useState(!1),[L,B]=a.useState(""),[R,D]=a.useState(""),[z,O]=a.useState(null),K=a.useRef(!0),[H,I]=a.useState(!0),[F,G]=a.useState(!1),[V,J]=a.useState({width:0,height:0});a.useEffect((()=>{g&&!1!==x&&null===z&&(g?.uiDefaults?g?.uiDefaults?.emailHelpDialogShow&&!z&&O(!0):O(!0))}),[g,g?.uiDefaults?.emailHelpDialogShow,z,x]);const U=wwe(S,500),W=wwe(A,500),q=a.useMemo((()=>n||l?.results?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=u?.results?.find((a=>a.id===e.channelAccountId));return a&&(a.channelAccountMetadata.type===Gre.REACH_MANAGED||a.channelAccountMetadata.type===Gre.REACH_MANAGED_SES)?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`}]:[]}))||[]),[n,l?.results,u?.results]),$=a.useRef(null);return a.useEffect((()=>{const e=setTimeout((()=>{K.current=!1}),500);return()=>clearTimeout(e)}),[]),a.useEffect((()=>{i?.emailHtmlBody&&T(i.emailHtmlBody)}),[i?.emailHtmlBody,s]),a.useEffect((()=>{if(v){const e=setTimeout((()=>{y(!1)}),2e3);return()=>clearTimeout(e)}}),[v]),a.useEffect((()=>{const e=()=>{J({width:window.innerWidth,height:window.innerHeight})};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),a.useEffect((()=>{if(!K.current&&b&&U&&M&&i?.id){y(!0);(async()=>{try{o({groupId:i.id,params:{emailChannelSenderId:b,emailHtmlBody:M,emailSubject:U,...W&&{emailPreviewText:W}}})}catch(e){}finally{y(!1)}})()}}),[b,U,W,M,i?.id,o]),a.useEffect((()=>{if(l?.results&&b){const e=l.results.find((e=>e.id===b));e&&(F&&!H||D(e.channelSenderMetadata.emailReplyTo),H&&B(e.channelSenderMetadata.emailFromName),I(!1))}}),[l?.results,b,F,H]),a.useEffect((()=>{if(l?.results&&!b){const e=l.results.filter((e=>e.channelSenderMetadata.userPart));if(e[0]){const a=e[0];k(a.id),o({groupId:i?.id||"",params:{emailChannelSenderId:a.id}})}}}),[l?.results,b,i?.id,o]),a.useEffect((()=>{!1===x&&i?.id&&s()}),[x,i?.id,s]),u&&l&&c&&!f?t.jsxs("div",{className:"relative",children:[t.jsx(ZZ,{open:z??!1,onOpenChange:O,children:t.jsxs(eY,{className:"max-h-[86vh] gap-0 overflow-visible max-w-3xl w-full h-full",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Email Preview Help"}),t.jsx(iY,{children:"Learn more about the email preview and how to use it to create your email."})]}),t.jsx(Rwe,{})]})}),t.jsx(ZZ,{open:x,onOpenChange:E,children:t.jsxs(eY,{className:"min-w-[100vw] min-h-[100vh]",hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault()},children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Email Editor"}),t.jsx(iY,{children:"Learn more about the email editor and how to use it to create your email."})]}),t.jsxs("div",{className:"w-full h-full",children:[t.jsxs("div",{className:"flex justify-between items-center p-1 border-b",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h2",{className:"text-lg font-medium",children:"Email Editor"}),t.jsx(H5,{size:"sm",onClick:()=>O(!0),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium text-sm",children:"Help"}),t.jsx(V5.InfoIcon,{className:"w-4 h-4"})]})})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(Nbe,{})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(H5,{variant:"destructive",onClick:()=>{j(!0)},className:"text-sm px-3 py-1 rounded",children:"Cancel"}),t.jsx(H5,{onClick:()=>_(!0),className:"text-sm px-3 py-1 rounded",children:"Save"})]})]}),r&&t.jsx(Hwe,{cancelClicked:P,setCancelClicked:j,showStripoEditor:x,automation:r,setShowStripoEditor:E,saveClicked:N,setSaveClicked:_,stripoDialogDimensions:V,mergeFieldsResponse:e,actionId:c})]})]})}),t.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(Kbe,{className:"text-foreground",children:"From Email"}),t.jsxs(pwe,{onValueChange:e=>{k(e),I(!0),G(!1)},value:b??void 0,disabled:v,children:[t.jsx(vwe,{children:t.jsx(fwe,{placeholder:"Select email",className:"text-muted-foreground",children:b?q?.find((e=>e.channelSenderId===b))?.fullDomain:""})}),t.jsx(kwe,{children:q?.map((e=>t.jsx(Swe,{value:e.channelSenderId,children:e.fullDomain},e.channelSenderId)))})]})]}),t.jsxs("div",{children:[t.jsx(Kbe,{children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:["From Name",t.jsx(Fue,{title:h||"From name can be configured under settings in the home screen",link:p?{url:p}:void 0})]})}),t.jsx(gte,{value:L??"",className:"text-muted-foreground",disabled:!0})]}),t.jsxs("div",{children:[t.jsx(Kbe,{children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:["Reply To Email",t.jsx(Fue,{title:d||"Reply to email can be configured under settings in the home screen",link:m?{url:m}:void 0})]})}),t.jsx(gte,{value:R??(b?q?.find((e=>e.channelSenderId===b))?.fullDomain:""),className:"text-muted-foreground",disabled:!0})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-0 py-1",children:[t.jsx(Kbe,{className:"text-foreground",children:"Subject"}),t.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),t.jsx(Ebe,{value:S,onChange:w,mergeFieldsResponse:e,placeholder:"Enter email subject",className:"text-muted-foreground",ariaLabel:"Insert merge field into subject"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsx(Kbe,{className:"text-foreground",children:"Preview Text"}),t.jsx(Fue,{title:"This text will be used for the preview text of the email in the inbox"})]}),t.jsx(Ebe,{value:A,onChange:C,className:"text-muted-foreground",mergeFieldsResponse:e})]})]}),t.jsxs("div",{className:"rounded-none p-4 h-full flex flex-col",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h3",{className:"font-medium",children:"Preview"}),t.jsxs("div",{children:[t.jsx(H5,{onClick:()=>E(!0),className:"text-sm px-3 py-1 rounded",disabled:v||0===(n?.length??0),children:"Edit"}),0===(n?.length??0)&&t.jsx("div",{className:"relative inline-block",children:t.jsx("div",{className:"absolute right-0 top-full mt-2 w-64 p-3 bg-white border rounded-lg shadow-lg z-10",children:t.jsx(Dwe,{type:"email"})})})]})]}),t.jsx("div",{className:"flex-1 w-full overflow-auto",ref:$,children:t.jsx(Lwe,{html:M??""})})]})]})]}):t.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:t.jsx(lY,{text:["Fetching Email Preview..."]})})};var Fwe=(e=>(e.CUSTOM="custom",e.MANAGED="managed",e))(Fwe||{}),Gwe=(e=>(e.EditAudience="edit-audience",e.EditTime="edit-time",e))(Gwe||{}),Vwe=(e=>(e.EMAIL="email",e.SMS="sms",e))(Vwe||{});const Jwe=({title:e,type:n})=>{const i=R5(),r=B5(),{toast:o}=Ve(),[s,l]=a.useState(!1),{resetCommunicationGroupToDefault:u,isPending:c}=ea(),d=!!i&&(i.type===Fwe.MANAGED&&(n===_we.SMS?i.updatedFromDefault?.text_message_body:i.updatedFromDefault?.email_text_body||i.updatedFromDefault?.email_html_body)),m=n===_we.EMAIL?"Email":"SMS";return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h4",{className:"text-xl font-medium text-foreground",children:e}),t.jsx("div",{className:"flex items-center gap-2",children:d&&t.jsx(t.Fragment,{children:c?t.jsx(lY,{}):t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>l(!0),children:"Reset To Default"})})})]}),t.jsx(ZZ,{open:s,onOpenChange:l,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsxs(aY,{children:[t.jsx(nY,{className:"text-xl font-semibold",children:"Reset To Default"}),t.jsxs(iY,{className:"text-base text-muted-foreground",children:["Are you sure you want to reset this ",m.toLowerCase()," ","template to its default state? This action cannot be undone."]})]}),t.jsxs(tY,{className:"flex flex-row justify-end gap-3 mt-6",children:[t.jsx(H5,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),t.jsx(H5,{variant:"destructive",onClick:async()=>{i&&r?u({communicationGroupId:i.id,automationId:r.id,type:n===_we.EMAIL?"email":"sms"},{onSuccess:()=>{o({title:lH("engage:success.communication_reset","Communication reset to default!")}),l(!1)},onSettled:()=>{l(!1)},onError:()=>{o({title:"Error updating",description:"No sender found",variant:"destructive"})}}):o({title:"Error updating",description:"No sender found",variant:"destructive"})},children:"Reset To Default"})]})]})})]})},Uwe=e=>{const{channelSenders:a,channelAccounts:t}=e;return a?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=t?.find((a=>a.id===e.channelAccountId));return a&&a.channelAccountMetadata.type===Gre.REACH_MANAGED?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,baseDomain:e.channelSenderMetadata.baseDomain??void 0,channelSender:e}]:[]}))||[]},Wwe=()=>{const e=a.useRef(null),n=R5(),{channelSenders:i}=Jre(),{channelAccounts:r}=Fre(),{getMergeFields:o,isGetting:s}=Qe(n?.id??void 0),l=a.useMemo((()=>Uwe({channelSenders:i?.results??[],channelAccounts:r?.results??[]})),[i?.results,r?.results]);return!s&&o&&l?t.jsxs("div",{className:"bg-card text-card-foreground rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",ref:e,children:[t.jsx(Jwe,{title:"Email Campaign",type:_we.EMAIL}),t.jsx(Iwe,{mergeFieldsResponse:o,emailChannelSendersWithChannelAccounts:l})]}):t.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-card text-card-foreground rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:t.jsx(lY,{text:["Fetching Content..."]})})};var qwe=e=>"checkbox"===e.type,$we=e=>e instanceof Date,Zwe=e=>null==e;const Ywe=e=>"object"==typeof e;var Qwe=e=>!Zwe(e)&&!Array.isArray(e)&&Ywe(e)&&!$we(e),Xwe=e=>Qwe(e)&&e.target?qwe(e.target)?e.target.checked:e.target.value:e,eAe=(e,a)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(a)),aAe="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function tAe(e){let a;const t=Array.isArray(e),n="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)a=new Date(e);else if(e instanceof Set)a=new Set(e);else{if(aAe&&(e instanceof Blob||n)||!t&&!Qwe(e))return e;if(a=t?[]:{},t||(e=>{const a=e.constructor&&e.constructor.prototype;return Qwe(a)&&a.hasOwnProperty("isPrototypeOf")})(e))for(const t in e)e.hasOwnProperty(t)&&(a[t]=tAe(e[t]));else a=e}return a}var nAe=e=>Array.isArray(e)?e.filter(Boolean):[],iAe=e=>void 0===e,rAe=(e,a,t)=>{if(!a||!Qwe(e))return t;const n=nAe(a.split(/[,[\].]+?/)).reduce(((e,a)=>Zwe(e)?e:e[a]),e);return iAe(n)||n===e?iAe(e[a])?t:e[a]:n},oAe=e=>"boolean"==typeof e,sAe=e=>/^\w*$/.test(e),lAe=e=>nAe(e.replace(/["|']|\]/g,"").split(/\.|\[/)),uAe=(e,a,t)=>{let n=-1;const i=sAe(a)?[a]:lAe(a),r=i.length,o=r-1;for(;++n<r;){const a=i[n];let r=t;if(n!==o){const t=e[a];r=Qwe(t)||Array.isArray(t)?t:isNaN(+i[n+1])?{}:[]}if("__proto__"===a||"constructor"===a||"prototype"===a)return;e[a]=r,e=e[a]}};const cAe="blur",dAe="focusout",mAe="change",hAe="onBlur",pAe="onChange",gAe="onSubmit",fAe="onTouched",vAe="all",yAe="max",bAe="min",kAe="maxLength",SAe="minLength",wAe="pattern",AAe="required",CAe="validate",MAe=a.createContext(null),TAe=()=>a.useContext(MAe);var xAe=(e,a,t,n=!0)=>{const i={defaultValues:a._defaultValues};for(const r in e)Object.defineProperty(i,r,{get:()=>{const i=r;return a._proxyFormState[i]!==vAe&&(a._proxyFormState[i]=!n||vAe),t&&(t[i]=!0),e[i]}});return i},EAe=e=>Zwe(e)||!Ywe(e);function NAe(e,a){if(EAe(e)||EAe(a))return e===a;if($we(e)&&$we(a))return e.getTime()===a.getTime();const t=Object.keys(e),n=Object.keys(a);if(t.length!==n.length)return!1;for(const i of t){const t=e[i];if(!n.includes(i))return!1;if("ref"!==i){const e=a[i];if($we(t)&&$we(e)||Qwe(t)&&Qwe(e)||Array.isArray(t)&&Array.isArray(e)?!NAe(t,e):t!==e)return!1}}return!0}const _Ae=(e,t)=>{const n=a.useRef(t);NAe(t,n.current)||(n.current=t),a.useEffect(e,n.current)};var PAe=e=>"string"==typeof e,jAe=(e,a,t,n,i)=>PAe(e)?(n&&a.watch.add(e),rAe(t,e,i)):Array.isArray(e)?e.map((e=>(n&&a.watch.add(e),rAe(t,e)))):(n&&(a.watchAll=!0),t);function LAe(e){const t=TAe(),{name:n,disabled:i,control:r=t.control,shouldUnregister:o}=e,s=eAe(r._names.array,n),l=function(e){const t=TAe(),{control:n=t.control,name:i,defaultValue:r,disabled:o,exact:s}=e||{},[l,u]=a.useState(n._getWatch(i,r));return _Ae((()=>n._subscribe({name:i,formState:{values:!0},exact:s,callback:e=>!o&&u(jAe(i,n._names,e.values||n._formValues,!1,r))})),[i,r,o,s]),a.useEffect((()=>n._removeUnmounted())),l}({control:r,name:n,defaultValue:rAe(r._formValues,n,rAe(r._defaultValues,n,e.defaultValue)),exact:!0}),u=function(e){const t=TAe(),{control:n=t.control,disabled:i,name:r,exact:o}=e||{},[s,l]=a.useState(n._formState),u=a.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return _Ae((()=>n._subscribe({name:r,formState:u.current,exact:o,callback:e=>{!i&&l({...n._formState,...e})}})),[r,i,o]),a.useEffect((()=>{u.current.isValid&&n._setValid(!0)}),[n]),a.useMemo((()=>xAe(s,n,u.current,!1)),[s,n])}({control:r,name:n,exact:!0}),c=a.useRef(e),d=a.useRef(r.register(n,{...e.rules,value:l,...oAe(e.disabled)?{disabled:e.disabled}:{}})),m=a.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!rAe(u.errors,n)},isDirty:{enumerable:!0,get:()=>!!rAe(u.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!rAe(u.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!rAe(u.validatingFields,n)},error:{enumerable:!0,get:()=>rAe(u.errors,n)}})),[u,n]),h=a.useCallback((e=>d.current.onChange({target:{value:Xwe(e),name:n},type:mAe})),[n]),p=a.useCallback((()=>d.current.onBlur({target:{value:rAe(r._formValues,n),name:n},type:cAe})),[n,r._formValues]),g=a.useCallback((e=>{const a=rAe(r._fields,n);a&&e&&(a._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:a=>e.setCustomValidity(a),reportValidity:()=>e.reportValidity()})}),[r._fields,n]),f=a.useMemo((()=>({name:n,value:l,...oAe(i)||u.disabled?{disabled:u.disabled||i}:{},onChange:h,onBlur:p,ref:g})),[n,i,u.disabled,h,p,g,l]);return a.useEffect((()=>{const e=r._options.shouldUnregister||o;r.register(n,{...c.current.rules,...oAe(c.current.disabled)?{disabled:c.current.disabled}:{}});const a=(e,a)=>{const t=rAe(r._fields,e);t&&t._f&&(t._f.mount=a)};if(a(n,!0),e){const e=tAe(rAe(r._options.defaultValues,n));uAe(r._defaultValues,n,e),iAe(rAe(r._formValues,n))&&uAe(r._formValues,n,e)}return!s&&r.register(n),()=>{(s?e&&!r._state.action:e)?r.unregister(n):a(n,!1)}}),[n,r,s,o]),a.useEffect((()=>{r._setDisabledField({disabled:i,name:n})}),[i,n,r]),a.useMemo((()=>({field:f,formState:u,fieldState:m})),[f,u,m])}const BAe=e=>e.render(LAe(e));var RAe=(e,a,t,n,i)=>a?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[n]:i||!0}}:{},DAe=e=>Array.isArray(e)?e:[e],zAe=()=>{let e=[];return{get observers(){return e},next:a=>{for(const t of e)t.next&&t.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter((e=>e!==a))}}),unsubscribe:()=>{e=[]}}},OAe=e=>Qwe(e)&&!Object.keys(e).length,KAe=e=>"file"===e.type,HAe=e=>"function"==typeof e,IAe=e=>{if(!aAe)return!1;const a=e?e.ownerDocument:0;return e instanceof(a&&a.defaultView?a.defaultView.HTMLElement:HTMLElement)},FAe=e=>"select-multiple"===e.type,GAe=e=>"radio"===e.type,VAe=e=>IAe(e)&&e.isConnected;function JAe(e,a){const t=Array.isArray(a)?a:sAe(a)?[a]:lAe(a),n=1===t.length?e:function(e,a){const t=a.slice(0,-1).length;let n=0;for(;n<t;)e=iAe(e)?n++:e[a[n++]];return e}(e,t),i=t.length-1;return n&&delete n[t[i]],0!==i&&(Qwe(n)&&OAe(n)||Array.isArray(n)&&function(e){for(const a in e)if(e.hasOwnProperty(a)&&!iAe(e[a]))return!1;return!0}(n))&&JAe(e,t.slice(0,-1)),e}var UAe=e=>{for(const a in e)if(HAe(e[a]))return!0;return!1};function WAe(e,a={}){const t=Array.isArray(e);if(Qwe(e)||t)for(const n in e)Array.isArray(e[n])||Qwe(e[n])&&!UAe(e[n])?(a[n]=Array.isArray(e[n])?[]:{},WAe(e[n],a[n])):Zwe(e[n])||(a[n]=!0);return a}function qAe(e,a,t){const n=Array.isArray(e);if(Qwe(e)||n)for(const i in e)Array.isArray(e[i])||Qwe(e[i])&&!UAe(e[i])?iAe(a)||EAe(t[i])?t[i]=Array.isArray(e[i])?WAe(e[i],[]):{...WAe(e[i])}:qAe(e[i],Zwe(a)?{}:a[i],t[i]):t[i]=!NAe(e[i],a[i]);return t}var $Ae=(e,a)=>qAe(e,a,WAe(a));const ZAe={value:!1,isValid:!1},YAe={value:!0,isValid:!0};var QAe=e=>{if(Array.isArray(e)){if(e.length>1){const a=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:a,isValid:!!a.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!iAe(e[0].attributes.value)?iAe(e[0].value)||""===e[0].value?YAe:{value:e[0].value,isValid:!0}:YAe:ZAe}return ZAe},XAe=(e,{valueAsNumber:a,valueAsDate:t,setValueAs:n})=>iAe(e)?e:a?""===e?NaN:e?+e:e:t&&PAe(e)?new Date(e):n?n(e):e;const eCe={isValid:!1,value:null};var aCe=e=>Array.isArray(e)?e.reduce(((e,a)=>a&&a.checked&&!a.disabled?{isValid:!0,value:a.value}:e),eCe):eCe;function tCe(e){const a=e.ref;return KAe(a)?a.files:GAe(a)?aCe(e.refs).value:FAe(a)?[...a.selectedOptions].map((({value:e})=>e)):qwe(a)?QAe(e.refs).value:XAe(iAe(a.value)?e.ref.value:a.value,e)}var nCe=e=>e instanceof RegExp,iCe=e=>iAe(e)?e:nCe(e)?e.source:Qwe(e)?nCe(e.value)?e.value.source:e.value:e,rCe=e=>({isOnSubmit:!e||e===gAe,isOnBlur:e===hAe,isOnChange:e===pAe,isOnAll:e===vAe,isOnTouch:e===fAe});const oCe="AsyncFunction";var sCe=(e,a,t)=>!t&&(a.watchAll||a.watch.has(e)||[...a.watch].some((a=>e.startsWith(a)&&/^\.\w+/.test(e.slice(a.length)))));const lCe=(e,a,t,n)=>{for(const i of t||Object.keys(e)){const t=rAe(e,i);if(t){const{_f:e,...r}=t;if(e){if(e.refs&&e.refs[0]&&a(e.refs[0],i)&&!n)return!0;if(e.ref&&a(e.ref,e.name)&&!n)return!0;if(lCe(r,a))break}else if(Qwe(r)&&lCe(r,a))break}}};function uCe(e,a,t){const n=rAe(e,t);if(n||sAe(t))return{error:n,name:t};const i=t.split(".");for(;i.length;){const n=i.join("."),r=rAe(a,n),o=rAe(e,n);if(r&&!Array.isArray(r)&&t!==n)return{name:t};if(o&&o.type)return{name:n,error:o};i.pop()}return{name:t}}var cCe=(e,a,t)=>{const n=DAe(rAe(e,t));return uAe(n,"root",a[t]),uAe(e,t,n),e},dCe=e=>PAe(e);function mCe(e,a,t="validate"){if(dCe(e)||Array.isArray(e)&&e.every(dCe)||oAe(e)&&!e)return{type:t,message:dCe(e)?e:"",ref:a}}var hCe=e=>Qwe(e)&&!nCe(e)?e:{value:e,message:""},pCe=async(e,a,t,n,i,r)=>{const{ref:o,refs:s,required:l,maxLength:u,minLength:c,min:d,max:m,pattern:h,validate:p,name:g,valueAsNumber:f,mount:v}=e._f,y=rAe(t,g);if(!v||a.has(g))return{};const b=s?s[0]:o,k=e=>{i&&b.reportValidity&&(b.setCustomValidity(oAe(e)?"":e||""),b.reportValidity())},S={},w=GAe(o),A=qwe(o),C=w||A,M=(f||KAe(o))&&iAe(o.value)&&iAe(y)||IAe(o)&&""===o.value||""===y||Array.isArray(y)&&!y.length,T=RAe.bind(null,g,n,S),x=(e,a,t,n=kAe,i=SAe)=>{const r=e?a:t;S[g]={type:e?n:i,message:r,ref:o,...T(e?n:i,r)}};if(r?!Array.isArray(y)||!y.length:l&&(!C&&(M||Zwe(y))||oAe(y)&&!y||A&&!QAe(s).isValid||w&&!aCe(s).isValid)){const{value:e,message:a}=dCe(l)?{value:!!l,message:l}:hCe(l);if(e&&(S[g]={type:AAe,message:a,ref:b,...T(AAe,a)},!n))return k(a),S}if(!(M||Zwe(d)&&Zwe(m))){let e,a;const t=hCe(m),i=hCe(d);if(Zwe(y)||isNaN(y)){const n=o.valueAsDate||new Date(y),r=e=>new Date((new Date).toDateString()+" "+e),s="time"==o.type,l="week"==o.type;PAe(t.value)&&y&&(e=s?r(y)>r(t.value):l?y>t.value:n>new Date(t.value)),PAe(i.value)&&y&&(a=s?r(y)<r(i.value):l?y<i.value:n<new Date(i.value))}else{const n=o.valueAsNumber||(y?+y:y);Zwe(t.value)||(e=n>t.value),Zwe(i.value)||(a=n<i.value)}if((e||a)&&(x(!!e,t.message,i.message,yAe,bAe),!n))return k(S[g].message),S}if((u||c)&&!M&&(PAe(y)||r&&Array.isArray(y))){const e=hCe(u),a=hCe(c),t=!Zwe(e.value)&&y.length>+e.value,i=!Zwe(a.value)&&y.length<+a.value;if((t||i)&&(x(t,e.message,a.message),!n))return k(S[g].message),S}if(h&&!M&&PAe(y)){const{value:e,message:a}=hCe(h);if(nCe(e)&&!y.match(e)&&(S[g]={type:wAe,message:a,ref:o,...T(wAe,a)},!n))return k(a),S}if(p)if(HAe(p)){const e=mCe(await p(y,t),b);if(e&&(S[g]={...e,...T(CAe,e.message)},!n))return k(e.message),S}else if(Qwe(p)){let e={};for(const a in p){if(!OAe(e)&&!n)break;const i=mCe(await p[a](y,t),b,a);i&&(e={...i,...T(a,i.message)},k(i.message),n&&(S[g]=e))}if(!OAe(e)&&(S[g]={ref:b,...e},!n))return S}return k(!0),S};const gCe={mode:gAe,reValidateMode:pAe,shouldFocusError:!0};function fCe(e={}){let a={...gCe,...e},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:HAe(a.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:a.errors||{},disabled:a.disabled||!1};const n={};let i,r=(Qwe(a.defaultValues)||Qwe(a.values))&&tAe(a.values||a.defaultValues)||{},o=a.shouldUnregister?{}:tAe(r),s={action:!1,mount:!1,watch:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0;const c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let d={...c};const m={array:zAe(),state:zAe()},h=rCe(a.mode),p=rCe(a.reValidateMode),g=a.criteriaMode===vAe,f=async e=>{if(!a.disabled&&(c.isValid||d.isValid||e)){const e=a.resolver?OAe((await S()).errors):await w(n,!0);e!==t.isValid&&m.state.next({isValid:e})}},v=(e,n)=>{!a.disabled&&(c.isValidating||c.validatingFields||d.isValidating||d.validatingFields)&&((e||Array.from(l.mount)).forEach((e=>{e&&(n?uAe(t.validatingFields,e,n):JAe(t.validatingFields,e))})),m.state.next({validatingFields:t.validatingFields,isValidating:!OAe(t.validatingFields)}))},y=(e,a,t,i)=>{const l=rAe(n,e);if(l){const n=rAe(o,e,iAe(t)?rAe(r,e):t);iAe(n)||i&&i.defaultChecked||a?uAe(o,e,a?n:tCe(l._f)):M(e,n),s.mount&&f()}},b=(e,n,i,o,s)=>{let l=!1,u=!1;const h={name:e};if(!a.disabled){if(!i||o){(c.isDirty||d.isDirty)&&(u=t.isDirty,t.isDirty=h.isDirty=A(),l=u!==h.isDirty);const a=NAe(rAe(r,e),n);u=!!rAe(t.dirtyFields,e),a?JAe(t.dirtyFields,e):uAe(t.dirtyFields,e,!0),h.dirtyFields=t.dirtyFields,l=l||(c.dirtyFields||d.dirtyFields)&&u!==!a}if(i){const a=rAe(t.touchedFields,e);a||(uAe(t.touchedFields,e,i),h.touchedFields=t.touchedFields,l=l||(c.touchedFields||d.touchedFields)&&a!==i)}l&&s&&m.state.next(h)}return l?h:{}},k=(e,n,r,o)=>{const s=rAe(t.errors,e),l=(c.isValid||d.isValid)&&oAe(n)&&t.isValid!==n;if(a.delayError&&r?(i=(e=>a=>{clearTimeout(u),u=setTimeout(e,a)})((()=>((e,a)=>{uAe(t.errors,e,a),m.state.next({errors:t.errors})})(e,r))),i(a.delayError)):(clearTimeout(u),i=null,r?uAe(t.errors,e,r):JAe(t.errors,e)),(r?!NAe(s,r):s)||!OAe(o)||l){const a={...o,...l&&oAe(n)?{isValid:n}:{},errors:t.errors,name:e};t={...t,...a},m.state.next(a)}},S=async e=>{v(e,!0);const t=await a.resolver(o,a.context,((e,a,t,n)=>{const i={};for(const r of e){const e=rAe(a,r);e&&uAe(i,r,e._f)}return{criteriaMode:t,names:[...e],fields:i,shouldUseNativeValidation:n}})(e||l.mount,n,a.criteriaMode,a.shouldUseNativeValidation));return v(e),t},w=async(e,n,i={valid:!0})=>{for(const s in e){const u=e[s];if(u){const{_f:e,...d}=u;if(e){const d=l.array.has(e.name),m=u._f&&(!!(r=u._f)&&!!r.validate&&!!(HAe(r.validate)&&r.validate.constructor.name===oCe||Qwe(r.validate)&&Object.values(r.validate).find((e=>e.constructor.name===oCe))));m&&c.validatingFields&&v([s],!0);const h=await pCe(u,l.disabled,o,g,a.shouldUseNativeValidation&&!n,d);if(m&&c.validatingFields&&v([s]),h[e.name]&&(i.valid=!1,n))break;!n&&(rAe(h,e.name)?d?cCe(t.errors,h,e.name):uAe(t.errors,e.name,h[e.name]):JAe(t.errors,e.name))}!OAe(d)&&await w(d,n,i)}}var r;return i.valid},A=(e,t)=>!a.disabled&&(e&&t&&uAe(o,e,t),!NAe(P(),r)),C=(e,a,t)=>jAe(e,l,{...s.mount?o:iAe(a)?r:PAe(e)?{[e]:a}:a},t,a),M=(e,a,t={})=>{const i=rAe(n,e);let r=a;if(i){const t=i._f;t&&(!t.disabled&&uAe(o,e,XAe(a,t)),r=IAe(t.ref)&&Zwe(a)?"":a,FAe(t.ref)?[...t.ref.options].forEach((e=>e.selected=r.includes(e.value))):t.refs?qwe(t.ref)?t.refs.length>1?t.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(r)?!!r.find((a=>a===e.value)):r===e.value))):t.refs[0]&&(t.refs[0].checked=!!r):t.refs.forEach((e=>e.checked=e.value===r)):KAe(t.ref)?t.ref.value="":(t.ref.value=r,t.ref.type||m.state.next({name:e,values:tAe(o)})))}(t.shouldDirty||t.shouldTouch)&&b(e,r,t.shouldTouch,t.shouldDirty,!0),t.shouldValidate&&_(e)},T=(e,a,t)=>{for(const i in a){const r=a[i],o=`${e}.${i}`,s=rAe(n,o);(l.array.has(e)||Qwe(r)||s&&!s._f)&&!$we(r)?T(o,r,t):M(o,r,t)}},x=(e,a,i={})=>{const u=rAe(n,e),h=l.array.has(e),p=tAe(a);uAe(o,e,p),h?(m.array.next({name:e,values:tAe(o)}),(c.isDirty||c.dirtyFields||d.isDirty||d.dirtyFields)&&i.shouldDirty&&m.state.next({name:e,dirtyFields:$Ae(r,o),isDirty:A(e,p)})):!u||u._f||Zwe(p)?M(e,p,i):T(e,p,i),sCe(e,l)&&m.state.next({...t}),m.state.next({name:s.mount?e:void 0,values:tAe(o)})},E=async e=>{s.mount=!0;const r=e.target;let u=r.name,y=!0;const A=rAe(n,u),C=e=>{y=Number.isNaN(e)||$we(e)&&isNaN(e.getTime())||NAe(e,rAe(o,u,e))};if(A){let s,T;const x=r.type?tCe(A._f):Xwe(e),E=e.type===cAe||e.type===dAe,N=!((M=A._f).mount&&(M.required||M.min||M.max||M.maxLength||M.minLength||M.pattern||M.validate)||a.resolver||rAe(t.errors,u)||A._f.deps)||((e,a,t,n,i)=>!i.isOnAll&&(!t&&i.isOnTouch?!(a||e):(t?n.isOnBlur:i.isOnBlur)?!e:!(t?n.isOnChange:i.isOnChange)||e))(E,rAe(t.touchedFields,u),t.isSubmitted,p,h),P=sCe(u,l,E);uAe(o,u,x),E?(A._f.onBlur&&A._f.onBlur(e),i&&i(0)):A._f.onChange&&A._f.onChange(e);const j=b(u,x,E),L=!OAe(j)||P;if(!E&&m.state.next({name:u,type:e.type,values:tAe(o)}),N)return(c.isValid||d.isValid)&&("onBlur"===a.mode?E&&f():E||f()),L&&m.state.next({name:u,...P?{}:j});if(!E&&P&&m.state.next({...t}),a.resolver){const{errors:e}=await S([u]);if(C(x),y){const a=uCe(t.errors,n,u),i=uCe(e,n,a.name||u);s=i.error,u=i.name,T=OAe(e)}}else v([u],!0),s=(await pCe(A,l.disabled,o,g,a.shouldUseNativeValidation))[u],v([u]),C(x),y&&(s?T=!1:(c.isValid||d.isValid)&&(T=await w(n,!0)));y&&(A._f.deps&&_(A._f.deps),k(u,T,s,j))}var M},N=(e,a)=>{if(rAe(t.errors,a)&&e.focus)return e.focus(),1},_=async(e,i={})=>{let r,o;const s=DAe(e);if(a.resolver){const a=await(async e=>{const{errors:a}=await S(e);if(e)for(const n of e){const e=rAe(a,n);e?uAe(t.errors,n,e):JAe(t.errors,n)}else t.errors=a;return a})(iAe(e)?e:s);r=OAe(a),o=e?!s.some((e=>rAe(a,e))):r}else e?(o=(await Promise.all(s.map((async e=>{const a=rAe(n,e);return await w(a&&a._f?{[e]:a}:a)})))).every(Boolean),(o||t.isValid)&&f()):o=r=await w(n);return m.state.next({...!PAe(e)||(c.isValid||d.isValid)&&r!==t.isValid?{}:{name:e},...a.resolver||!e?{isValid:r}:{},errors:t.errors}),i.shouldFocus&&!o&&lCe(n,N,e?s:l.mount),o},P=e=>{const a={...s.mount?o:r};return iAe(e)?a:PAe(e)?rAe(a,e):e.map((e=>rAe(a,e)))},j=(e,a)=>({invalid:!!rAe((a||t).errors,e),isDirty:!!rAe((a||t).dirtyFields,e),error:rAe((a||t).errors,e),isValidating:!!rAe(t.validatingFields,e),isTouched:!!rAe((a||t).touchedFields,e)}),L=(e,a,i)=>{const r=(rAe(n,e,{_f:{}})._f||{}).ref,o=rAe(t.errors,e)||{},{ref:s,message:l,type:u,...c}=o;uAe(t.errors,e,{...c,...a,ref:r}),m.state.next({name:e,errors:t.errors,isValid:!1}),i&&i.shouldFocus&&r&&r.focus&&r.focus()},B=e=>m.state.subscribe({next:a=>{var n,i,r;i=a.name,r=e.exact,(n=e.name)&&i&&n!==i&&!DAe(n).some((e=>e&&(r?e===i:e.startsWith(i)||i.startsWith(e))))||!((e,a,t,n)=>{t(e);const{name:i,...r}=e;return OAe(r)||Object.keys(r).length>=Object.keys(a).length||Object.keys(r).find((e=>a[e]===(!n||vAe)))})(a,e.formState||c,F,e.reRenderRoot)||e.callback({values:{...o},...t,...a})}}).unsubscribe,R=(e,i={})=>{for(const s of e?DAe(e):l.mount)l.mount.delete(s),l.array.delete(s),i.keepValue||(JAe(n,s),JAe(o,s)),!i.keepError&&JAe(t.errors,s),!i.keepDirty&&JAe(t.dirtyFields,s),!i.keepTouched&&JAe(t.touchedFields,s),!i.keepIsValidating&&JAe(t.validatingFields,s),!a.shouldUnregister&&!i.keepDefaultValue&&JAe(r,s);m.state.next({values:tAe(o)}),m.state.next({...t,...i.keepDirty?{isDirty:A()}:{}}),!i.keepIsValid&&f()},D=({disabled:e,name:a})=>{(oAe(e)&&s.mount||e||l.disabled.has(a))&&(e?l.disabled.add(a):l.disabled.delete(a))},z=(e,t={})=>{let i=rAe(n,e);const o=oAe(t.disabled)||oAe(a.disabled);return uAe(n,e,{...i||{},_f:{...i&&i._f?i._f:{ref:{name:e}},name:e,mount:!0,...t}}),l.mount.add(e),i?D({disabled:oAe(t.disabled)?t.disabled:a.disabled,name:e}):y(e,!0,t.value),{...o?{disabled:t.disabled||a.disabled}:{},...a.progressive?{required:!!t.required,min:iCe(t.min),max:iCe(t.max),minLength:iCe(t.minLength),maxLength:iCe(t.maxLength),pattern:iCe(t.pattern)}:{},name:e,onChange:E,onBlur:E,ref:o=>{if(o){z(e,t),i=rAe(n,e);const a=iAe(o.value)&&o.querySelectorAll&&o.querySelectorAll("input,select,textarea")[0]||o,s=(e=>GAe(e)||qwe(e))(a),l=i._f.refs||[];if(s?l.find((e=>e===a)):a===i._f.ref)return;uAe(n,e,{_f:{...i._f,...s?{refs:[...l.filter(VAe),a,...Array.isArray(rAe(r,e))?[{}]:[]],ref:{type:a.type,name:e}}:{ref:a}}}),y(e,!1,void 0,a)}else i=rAe(n,e,{}),i._f&&(i._f.mount=!1),(a.shouldUnregister||t.shouldUnregister)&&(!eAe(l.array,e)||!s.action)&&l.unMount.add(e)}}},O=()=>a.shouldFocusError&&lCe(n,N,l.mount),K=(e,i)=>async r=>{let s;r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let u=tAe(o);if(m.state.next({isSubmitting:!0}),a.resolver){const{errors:e,values:a}=await S();t.errors=e,u=a}else await w(n);if(l.disabled.size)for(const e of l.disabled)uAe(u,e,void 0);if(JAe(t.errors,"root"),OAe(t.errors)){m.state.next({errors:{}});try{await e(u,r)}catch(c){s=c}}else i&&await i({...t.errors},r),O(),setTimeout(O);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:OAe(t.errors)&&!s,submitCount:t.submitCount+1,errors:t.errors}),s)throw s},H=(e,i={})=>{const u=e?tAe(e):r,d=tAe(u),h=OAe(e),p=h?r:d;if(i.keepDefaultValues||(r=u),!i.keepValues){if(i.keepDirtyValues){const e=new Set([...l.mount,...Object.keys($Ae(r,o))]);for(const a of Array.from(e))rAe(t.dirtyFields,a)?uAe(p,a,rAe(o,a)):x(a,rAe(p,a))}else{if(aAe&&iAe(e))for(const e of l.mount){const a=rAe(n,e);if(a&&a._f){const e=Array.isArray(a._f.refs)?a._f.refs[0]:a._f.ref;if(IAe(e)){const a=e.closest("form");if(a){a.reset();break}}}}for(const e of l.mount)x(e,rAe(p,e))}o=tAe(p),m.array.next({values:{...p}}),m.state.next({values:{...p}})}l={mount:i.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},s.mount=!c.isValid||!!i.keepIsValid||!!i.keepDirtyValues,s.watch=!!a.shouldUnregister,m.state.next({submitCount:i.keepSubmitCount?t.submitCount:0,isDirty:!h&&(i.keepDirty?t.isDirty:!(!i.keepDefaultValues||NAe(e,r))),isSubmitted:!!i.keepIsSubmitted&&t.isSubmitted,dirtyFields:h?{}:i.keepDirtyValues?i.keepDefaultValues&&o?$Ae(r,o):t.dirtyFields:i.keepDefaultValues&&e?$Ae(r,e):i.keepDirty?t.dirtyFields:{},touchedFields:i.keepTouched?t.touchedFields:{},errors:i.keepErrors?t.errors:{},isSubmitSuccessful:!!i.keepIsSubmitSuccessful&&t.isSubmitSuccessful,isSubmitting:!1})},I=(e,a)=>H(HAe(e)?e(o):e,a),F=e=>{t={...t,...e}},G={control:{register:z,unregister:R,getFieldState:j,handleSubmit:K,setError:L,_subscribe:B,_runSchema:S,_getWatch:C,_getDirty:A,_setValid:f,_setFieldArray:(e,i=[],l,u,h=!0,p=!0)=>{if(u&&l&&!a.disabled){if(s.action=!0,p&&Array.isArray(rAe(n,e))){const a=l(rAe(n,e),u.argA,u.argB);h&&uAe(n,e,a)}if(p&&Array.isArray(rAe(t.errors,e))){const a=l(rAe(t.errors,e),u.argA,u.argB);h&&uAe(t.errors,e,a),((e,a)=>{!nAe(rAe(e,a)).length&&JAe(e,a)})(t.errors,e)}if((c.touchedFields||d.touchedFields)&&p&&Array.isArray(rAe(t.touchedFields,e))){const a=l(rAe(t.touchedFields,e),u.argA,u.argB);h&&uAe(t.touchedFields,e,a)}(c.dirtyFields||d.dirtyFields)&&(t.dirtyFields=$Ae(r,o)),m.state.next({name:e,isDirty:A(e,i),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else uAe(o,e,i)},_setDisabledField:D,_setErrors:e=>{t.errors=e,m.state.next({errors:t.errors,isValid:!1})},_getFieldArray:e=>nAe(rAe(s.mount?o:r,e,a.shouldUnregister?rAe(r,e,[]):[])),_reset:H,_resetDefaultValues:()=>HAe(a.defaultValues)&&a.defaultValues().then((e=>{I(e,a.resetOptions),m.state.next({isLoading:!1})})),_removeUnmounted:()=>{for(const e of l.unMount){const a=rAe(n,e);a&&(a._f.refs?a._f.refs.every((e=>!VAe(e))):!VAe(a._f.ref))&&R(e)}l.unMount=new Set},_disableForm:e=>{oAe(e)&&(m.state.next({disabled:e}),lCe(n,((a,t)=>{const i=rAe(n,t);i&&(a.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach((a=>{a.disabled=i._f.disabled||e})))}),0,!1))},_subjects:m,_proxyFormState:c,get _fields(){return n},get _formValues(){return o},get _state(){return s},set _state(e){s=e},get _defaultValues(){return r},get _names(){return l},set _names(e){l=e},get _formState(){return t},get _options(){return a},set _options(e){a={...a,...e}}},subscribe:e=>(s.mount=!0,d={...d,...e.formState},B({...e,formState:d})),trigger:_,register:z,handleSubmit:K,watch:(e,a)=>HAe(e)?m.state.subscribe({next:t=>e(C(void 0,a),t)}):C(e,a,!0),setValue:x,getValues:P,reset:I,resetField:(e,a={})=>{rAe(n,e)&&(iAe(a.defaultValue)?x(e,tAe(rAe(r,e))):(x(e,a.defaultValue),uAe(r,e,tAe(a.defaultValue))),a.keepTouched||JAe(t.touchedFields,e),a.keepDirty||(JAe(t.dirtyFields,e),t.isDirty=a.defaultValue?A(e,tAe(rAe(r,e))):A()),a.keepError||(JAe(t.errors,e),c.isValid&&f()),m.state.next({...t}))},clearErrors:e=>{e&&DAe(e).forEach((e=>JAe(t.errors,e))),m.state.next({errors:e?t.errors:{}})},unregister:R,setError:L,setFocus:(e,a={})=>{const t=rAe(n,e),i=t&&t._f;if(i){const e=i.refs?i.refs[0]:i.ref;e.focus&&(e.focus(),a.shouldSelect&&HAe(e.select)&&e.select())}},getFieldState:j};return{...G,formControl:G}}const vCe="undefined"!=typeof window?a.useLayoutEffect:a.useEffect;function yCe(e={}){const t=a.useRef(void 0),n=a.useRef(void 0),[i,r]=a.useState({isDirty:!1,isValidating:!1,isLoading:HAe(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:HAe(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...e.formControl?e.formControl:fCe(e),formState:i},e.formControl&&e.defaultValues&&!HAe(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions));const o=t.current.control;return o._options=e,vCe((()=>{const e=o._subscribe({formState:o._proxyFormState,callback:()=>r({...o._formState}),reRenderRoot:!0});return r((e=>({...e,isReady:!0}))),e}),[o]),a.useEffect((()=>o._disableForm(e.disabled)),[o,e.disabled]),a.useEffect((()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode),e.errors&&!OAe(e.errors)&&o._setErrors(e.errors)}),[o,e.errors,e.mode,e.reValidateMode]),a.useEffect((()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})}),[o,e.shouldUnregister]),a.useEffect((()=>{if(o._proxyFormState.isDirty){const e=o._getDirty();e!==i.isDirty&&o._subjects.state.next({isDirty:e})}}),[o,i.isDirty]),a.useEffect((()=>{e.values&&!NAe(e.values,n.current)?(o._reset(e.values,o._options.resetOptions),n.current=e.values,r((e=>({...e})))):o._resetDefaultValues()}),[o,e.values]),a.useEffect((()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()})),t.current.formState=xAe(i,o),t.current}const bCe=e=>{const{children:t,...n}=e;return a.createElement(MAe.Provider,{value:n},t)},kCe=r.createContext({}),SCe=({...e})=>t.jsx(kCe.Provider,{value:{name:e.name},children:t.jsx(BAe,{...e})}),wCe=()=>{const e=r.useContext(kCe),a=r.useContext(ACe),{getFieldState:t,formState:n}=TAe(),i=t(e.name,n);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:o}=a;return{id:o,name:e.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...i}},ACe=r.createContext({}),CCe=r.forwardRef((({className:e,...a},n)=>{const i=r.useId();return t.jsx(ACe.Provider,{value:{id:i},children:t.jsx("div",{ref:n,className:XO("space-y-2",e),...a})})}));CCe.displayName="FormItem";const MCe=r.forwardRef((({className:e,...a},n)=>{const{error:i,formItemId:r}=wCe();return t.jsx(Kbe,{ref:n,className:XO(i&&"text-destructive",e),htmlFor:r,...a})}));MCe.displayName="FormLabel";const TCe=r.forwardRef((({...e},a)=>{const{error:n,formItemId:i,formDescriptionId:r,formMessageId:o}=wCe();return t.jsx(GZ,{ref:a,id:i,"aria-describedby":n?`${r} ${o}`:`${r}`,"aria-invalid":!!n,...e})}));TCe.displayName="FormControl";r.forwardRef((({className:e,...a},n)=>{const{formDescriptionId:i}=wCe();return t.jsx("p",{ref:n,id:i,className:XO("text-[0.8rem] text-muted-foreground",e),...a})})).displayName="FormDescription";const xCe=r.forwardRef((({className:e,children:a,...n},i)=>{const{error:r,formMessageId:o}=wCe(),s=r?String(r?.message):a;return s?t.jsx("p",{ref:i,id:o,className:XO("text-[0.8rem] font-medium text-destructive",e),...n,children:s}):null}));xCe.displayName="FormMessage";const ECe="onboarding",NCe="settings",_Ce="todo",PCe="active",jCe="done",LCe={[jCe]:{icon:cz,className:"w-5 h-5 fill-green-500 text-background",style:{width:"1.5rem",height:"1.5rem"}},[PCe]:{icon:mz,className:"w-5 h-5 text-primary"},[_Ce]:{icon:dz,className:"w-5 h-5 text-muted-foreground/60"}},BCe=a.createContext(null);function RCe({config:e,onStepChange:t,onClose:n}){const i=e.steps.map((e=>e.key)),[r,o]=a.useState(e.initialStep||i[0]),[s,l]=a.useState(new Set),[u,c]=a.useState(new Set([r])),[d,m]=a.useState({}),h=i.indexOf(r),p=0===h,g=h===i.length-1,f=!g,v=!p,y=a.useCallback((e=>{i.includes(e)&&(o(e),c((a=>new Set([...a,e]))),t?.(e))}),[i,t]),b=a.useCallback((()=>{if(f){y(i[h+1])}else g&&n&&n()}),[f,h,i,y,g,n]),k=a.useCallback((()=>{if(v){y(i[h-1])}}),[v,h,i,y]),S=a.useCallback((e=>{l((a=>new Set([...a,e])))}),[]),w=a.useCallback(((e,a)=>{m((t=>({...t,[e]:a}))),S(e)}),[S]),A=a.useCallback((e=>s.has(e)),[s]),C=a.useCallback((e=>u.has(e)),[u]);return{navigation:{currentStep:r,steps:i,goToStep:y,goToNextStep:b,goToPreviousStep:k,canGoNext:f,canGoPrevious:v,currentStepIndex:h,isFirstStep:p,isLastStep:g},state:{completedSteps:Array.from(s),visitedSteps:Array.from(u),formData:d,markStepComplete:S,isStepComplete:A,isStepVisited:C,updateFormData:w}}}const DCe=jZ,zCe=LZ,OCe=BZ,KCe=r.forwardRef((({className:e,...a},n)=>t.jsx(RZ,{className:XO("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...a,ref:n})));KCe.displayName=RZ.displayName;const HCe=GD("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ICe=r.forwardRef((({side:e="right",className:a,children:n,...i},r)=>t.jsxs(OCe,{children:[t.jsx(KCe,{}),t.jsxs(DZ,{ref:r,className:XO(HCe({side:e}),a),"data-reach-root":!0,...i,children:[n,t.jsxs(KZ,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[t.jsx(rO,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})));ICe.displayName=DZ.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(zZ,{ref:n,className:XO("text-lg font-semibold text-foreground",e),...a}))).displayName=zZ.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(OZ,{ref:n,className:XO("text-sm text-muted-foreground",e),...a}))).displayName=OZ.displayName;const FCe=GD("py-6 px-4 border-r",{variants:{mode:{onboarding:"w-56 bg-muted/30",settings:"w-64 bg-muted/50"}},defaultVariants:{mode:ECe}}),GCe=GD("w-full justify-start gap-3 h-auto text-left",{variants:{mode:{onboarding:"py-2 px-3 min-h-none leading-none gap-1",settings:"py-3 px-3"},isActive:{true:"",false:""}},compoundVariants:[{mode:ECe,isActive:!0,class:"bg-muted"},{mode:NCe,isActive:!0,class:"bg-background"}],defaultVariants:{mode:ECe,isActive:!1}}),VCe=({status:e})=>{const a=LCe[e]??LCe[_Ce];return t.jsx(a.icon,{className:a.className,...a.style&&{style:a.style}})},JCe=({items:e,currentItem:a,onItemChange:n,completedItems:i=[],mode:r=ECe,className:o})=>t.jsx("div",{className:XO(FCe({mode:r}),o,r===ECe?"":"max-w-[22ch]"),children:t.jsx("div",{className:XO(r===ECe?"space-y-1":"space-y-2"),children:e.map((e=>{const o=e.status||((e,a,t=[])=>t.includes(e)?jCe:e===a?PCe:_Ce)(e.key,a,i),s=a===e.key,l=e.icon;return t.jsxs(H5,{variant:s?"secondary":"ghost",onClick:()=>n(e.key),className:XO(GCe({mode:r,isActive:s}),"group"),children:[r===ECe&&t.jsx("div",{className:"w-7 h-7 flex items-center justify-center flex-shrink-0",children:t.jsx(VCe,{status:o})}),r===NCe&&l&&t.jsx(l,{className:"w-4 h-4 text-muted-foreground/50 group-hover:text-foreground transition-colors"}),t.jsx("span",{className:XO("text-sm font-medium",r===ECe&&{"text-foreground":o===PCe,"text-muted-foreground":o===jCe||o===_Ce}),children:e.label})]},e.key)}))})}),UCe=({open:e,onOpenChange:n,title:i,description:r,sidebarItems:o,currentStep:s,onStepChange:l,completedSteps:u=[],mode:c="onboarding",showSidebar:d=!0,showMobileNav:m=!0,children:h,className:p,contentClassName:g})=>{const[f,v]=a.useState(!1);return t.jsx(ZZ,{open:e,onOpenChange:n,modal:!0,children:t.jsxs(eY,{className:XO("@container/wizard w-[90vw] max-h-[90vh] h-full flex flex-col gap-0 overflow-hidden sm:max-w-xl md:max-w-3xl lg:max-w-4xl p-0",p),onEscapeKeyDown:()=>{n(!1)},onPointerDownOutside:e=>{const a=e.target;(a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},onInteractOutside:e=>{const a=e.target;(e.composedPath().some((e=>"classList"in e&&Array.from(e.classList).includes("pac-item")))||a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},onFocusOutside:e=>{const a=e.target;(a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:i}),t.jsx(iY,{children:r})]}),t.jsxs("div",{className:"flex-1 min-h-0 flex",children:[d&&t.jsxs(t.Fragment,{children:[t.jsx(JCe,{mode:c,items:o,currentItem:s,onItemChange:l,completedItems:u,className:"hidden @lg/wizard:block"}),m&&t.jsxs(DCe,{open:f,onOpenChange:v,children:[t.jsx(zCe,{asChild:!0,children:t.jsx(H5,{variant:"ghost",size:"icon",className:"flex @lg/wizard:hidden absolute top-4 left-4 z-10",children:t.jsx(Ez,{className:"h-4 w-4"})})}),t.jsx(ICe,{side:"left",className:"w-64 p-0",children:t.jsx(JCe,{mode:c,items:o,currentItem:s,onItemChange:e=>{l(e),m&&v(!1)},completedItems:u,className:"border-r-0"})})]})]}),t.jsx("div",{className:XO("flex-1 min-h-0",g),children:h})]})]})})},WCe=({title:e,description:a,className:n})=>t.jsxs("div",{className:XO("px-8",n),children:[t.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:e}),a&&t.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:a})]}),qCe=({control:e,name:a,label:n,placeholder:i,type:r="text",disabled:o})=>t.jsx(SCe,{control:e,name:a,render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:n}),t.jsx(TCe,{children:t.jsx(gte,{...e,type:r,placeholder:i,disabled:o,className:"bg-background"})}),t.jsx(xCe,{})]})}),$Ce=({control:e,name:a,label:n,placeholder:i,options:r,disabled:o})=>t.jsx(SCe,{control:e,name:a,render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:n}),t.jsxs(pwe,{onValueChange:e.onChange,value:e.value,disabled:o,children:[t.jsx(TCe,{children:t.jsx(vwe,{className:"bg-background",children:t.jsx(fwe,{placeholder:i})})}),t.jsx(kwe,{children:r.map((e=>t.jsx(Swe,{value:e.value,children:t.jsxs("div",{className:"flex flex-col text-left",children:[t.jsx("span",{children:e.label}),e.description&&t.jsx("span",{className:"text-xs text-muted-foreground",children:e.description})]})},e.value)))})]}),t.jsx(xCe,{})]})}),ZCe=({title:e,description:a,children:n,variant:i="default"})=>t.jsxs("div",{className:"highlighted"===i?"bg-muted/50 p-6 rounded-lg border border-muted space-y-4":"space-y-4",children:[e&&t.jsx("h3",{className:"text-lg font-medium text-foreground",children:e}),a&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a}),t.jsx("div",{className:"space-y-4",children:n})]}),YCe=({variant:e="default",onBack:a,onNext:n,onSkip:i,isSubmitting:r=!1,canGoBack:o=!0,canGoNext:s=!0,backLabel:l="Back",nextLabel:u="Next",skipLabel:c="Skip",className:d,mode:m})=>{const h="compact"===e?"sm":"default",p="default"===e?"text-sm":"";return t.jsxs("div",{className:XO("flex items-center","compact"===e?"gap-2":"justify-between gap-4",d),children:[a&&t.jsxs(H5,{variant:"outline",size:h,onClick:a,disabled:r||!o,className:XO("flex items-center gap-2",p),children:[t.jsx(iz,{className:"w-4 h-4"}),l]}),t.jsxs("div",{className:"flex items-center gap-4 ml-auto",children:[i&&t.jsx(H5,{variant:"outline",size:h,onClick:i,disabled:r,className:XO("flex items-center gap-2",p),children:c}),n&&t.jsx(H5,{size:h,onClick:n,disabled:r||!s,className:XO("flex items-center gap-2",p),children:t.jsxs(t.Fragment,r?{children:[t.jsx(Cz,{className:"w-4 h-4 animate-spin"}),"Saving..."]}:{children:[u,"onboarding"===m&&t.jsx(ZD,{className:"w-4 h-4"})]})})]})]})},QCe=a.forwardRef((({children:e,className:a,showNavigation:n=!0,mode:i="onboarding",...r},o)=>{const s="settings"!==i&&r.onBack;return t.jsxs("div",{ref:o,className:XO("h-full flex flex-col",a),children:[t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-y-auto pt-10 @lg/onboarding-sidebar:pt-16",children:[t.jsx(WCe,{title:r.title,description:r.description}),t.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e})]}),n&&t.jsx("div",{className:"border-t border-border py-6 px-8 bg-background",children:t.jsx(YCe,{onBack:s?r.onBack:void 0,onNext:r.onNext,onSkip:r.onSkip,isSubmitting:r.isSubmitting,canGoBack:r.canGoBack,canGoNext:r.canGoNext,backLabel:r.backLabel||"Previous Step",nextLabel:r.submitLabel||"Next step",skipLabel:r.skipLabel||"Not now",mode:i})})]})}));QCe.displayName="WizardFormWrapper";const XCe=(e,a,t)=>{if(e&&"reportValidity"in e){const n=rAe(t,a);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},eMe=(e,a)=>{for(const t in a.fields){const n=a.fields[t];n&&n.ref&&"reportValidity"in n.ref?XCe(n.ref,t,e):n.refs&&n.refs.forEach((a=>XCe(a,t,e)))}},aMe=(e,a)=>{a.shouldUseNativeValidation&&eMe(e,a);const t={};for(const n in e){const i=rAe(a.fields,n),r=Object.assign(e[n]||{},{ref:i&&i.ref});if(tMe(a.names||Object.keys(e),n)){const e=Object.assign({},rAe(t,n));uAe(e,"root",r),uAe(t,n,e)}else uAe(t,n,r)}return t},tMe=(e,a)=>e.some((e=>e.startsWith(a+".")));var nMe=function(e,a){for(var t={};e.length;){var n=e[0],i=n.code,r=n.message,o=n.path.join(".");if(!t[o])if("unionErrors"in n){var s=n.unionErrors[0].errors[0];t[o]={message:s.message,type:s.code}}else t[o]={message:r,type:i};if("unionErrors"in n&&n.unionErrors.forEach((function(a){return a.errors.forEach((function(a){return e.push(a)}))})),a){var l=t[o].types,u=l&&l[n.code];t[o]=RAe(o,a,t,i,u?[].concat(u,n.message):n.message)}e.shift()}return t},iMe=function(e,a,t){return void 0===t&&(t={}),function(n,i,r){try{return Promise.resolve(function(i,o){try{var s=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](n,a)).then((function(e){return r.shouldUseNativeValidation&&eMe({},r),{errors:{},values:t.raw?n:e}}))}catch(XZe){return o(XZe)}return s&&s.then?s.then(void 0,o):s}(0,(function(e){if(a=e,Array.isArray(null==a?void 0:a.errors))return{values:{},errors:aMe(nMe(e.errors,!r.shouldUseNativeValidation&&"all"===r.criteriaMode),r)};var a;throw e})))}catch(XZe){return Promise.reject(XZe)}}};const rMe=[{code:"US",name:"United States"},{code:"AE",name:"United Arab Emirates"},{code:"AF",name:"Afghanistan"},{code:"AM",name:"Armenia"},{code:"AR",name:"Argentina"},{code:"AT",name:"Austria"},{code:"AU",name:"Australia"},{code:"AZ",name:"Azerbaijan"},{code:"BD",name:"Bangladesh"},{code:"BE",name:"Belgium"},{code:"BF",name:"Burkina Faso"},{code:"BG",name:"Bulgaria"},{code:"BH",name:"Bahrain"},{code:"BI",name:"Burundi"},{code:"BJ",name:"Benin"},{code:"BO",name:"Bolivia"},{code:"BR",name:"Brazil"},{code:"BT",name:"Bhutan"},{code:"BW",name:"Botswana"},{code:"BY",name:"Belarus"},{code:"CA",name:"Canada"},{code:"CD",name:"Democratic Republic of the Congo"},{code:"CF",name:"Central African Republic"},{code:"CG",name:"Republic of the Congo"},{code:"CH",name:"Switzerland"},{code:"CI",name:"Ivory Coast"},{code:"CL",name:"Chile"},{code:"CM",name:"Cameroon"},{code:"CN",name:"China"},{code:"CO",name:"Colombia"},{code:"CV",name:"Cape Verde"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czech Republic"},{code:"DE",name:"Germany"},{code:"DJ",name:"Djibouti"},{code:"DK",name:"Denmark"},{code:"DZ",name:"Algeria"},{code:"EC",name:"Ecuador"},{code:"EE",name:"Estonia"},{code:"EG",name:"Egypt"},{code:"ER",name:"Eritrea"},{code:"ES",name:"Spain"},{code:"ET",name:"Ethiopia"},{code:"FI",name:"Finland"},{code:"FJ",name:"Fiji"},{code:"FK",name:"Falkland Islands"},{code:"FR",name:"France"},{code:"GA",name:"Gabon"},{code:"GB",name:"United Kingdom"},{code:"GE",name:"Georgia"},{code:"GF",name:"French Guiana"},{code:"GH",name:"Ghana"},{code:"GM",name:"Gambia"},{code:"GN",name:"Guinea"},{code:"GQ",name:"Equatorial Guinea"},{code:"GR",name:"Greece"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HK",name:"Hong Kong"},{code:"HR",name:"Croatia"},{code:"HU",name:"Hungary"},{code:"ID",name:"Indonesia"},{code:"IE",name:"Ireland"},{code:"IL",name:"Israel"},{code:"IN",name:"India"},{code:"IQ",name:"Iraq"},{code:"IR",name:"Iran"},{code:"IS",name:"Iceland"},{code:"IT",name:"Italy"},{code:"JO",name:"Jordan"},{code:"JP",name:"Japan"},{code:"KE",name:"Kenya"},{code:"KG",name:"Kyrgyzstan"},{code:"KM",name:"Comoros"},{code:"KR",name:"South Korea"},{code:"KW",name:"Kuwait"},{code:"KZ",name:"Kazakhstan"},{code:"LB",name:"Lebanon"},{code:"LK",name:"Sri Lanka"},{code:"LR",name:"Liberia"},{code:"LS",name:"Lesotho"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"LV",name:"Latvia"},{code:"LY",name:"Libya"},{code:"MA",name:"Morocco"},{code:"MD",name:"Moldova"},{code:"MG",name:"Madagascar"},{code:"ML",name:"Mali"},{code:"MO",name:"Macau"},{code:"MR",name:"Mauritania"},{code:"MT",name:"Malta"},{code:"MU",name:"Mauritius"},{code:"MV",name:"Maldives"},{code:"MW",name:"Malawi"},{code:"MX",name:"Mexico"},{code:"MY",name:"Malaysia"},{code:"MZ",name:"Mozambique"},{code:"NA",name:"Namibia"},{code:"NC",name:"New Caledonia"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NL",name:"Netherlands"},{code:"NO",name:"Norway"},{code:"NP",name:"Nepal"},{code:"NZ",name:"New Zealand"},{code:"OM",name:"Oman"},{code:"PE",name:"Peru"},{code:"PF",name:"French Polynesia"},{code:"PG",name:"Papua New Guinea"},{code:"PH",name:"Philippines"},{code:"PK",name:"Pakistan"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PY",name:"Paraguay"},{code:"QA",name:"Qatar"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"SA",name:"Saudi Arabia"},{code:"SC",name:"Seychelles"},{code:"SD",name:"Sudan"},{code:"SE",name:"Sweden"},{code:"SG",name:"Singapore"},{code:"SI",name:"Slovenia"},{code:"SK",name:"Slovakia"},{code:"SL",name:"Sierra Leone"},{code:"SN",name:"Senegal"},{code:"SO",name:"Somalia"},{code:"SR",name:"Suriname"},{code:"SS",name:"South Sudan"},{code:"ST",name:"São Tomé and Príncipe"},{code:"SY",name:"Syria"},{code:"SZ",name:"Eswatini"},{code:"TD",name:"Chad"},{code:"TG",name:"Togo"},{code:"TH",name:"Thailand"},{code:"TJ",name:"Tajikistan"},{code:"TM",name:"Turkmenistan"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Turkey"},{code:"TW",name:"Taiwan"},{code:"TZ",name:"Tanzania"},{code:"UA",name:"Ukraine"},{code:"UG",name:"Uganda"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"YE",name:"Yemen"},{code:"ZA",name:"South Africa"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}];var oMe=(e=>(e.BRAND="brand",e.BUSINESS="business",e.EMAIL="email",e.SMS="sms",e.SPLASH="splash",e.BUSINESS_SKIP_INTERSTITIAL="business-skip-interstitial",e.SMS_INTERSTITIAL="sms-interstitial",e.COMPLETION="completion",e))(oMe||{});const sMe="Engage Settings",lMe="Configure your brand, business, and channel settings",uMe="Engage Setup",cMe="Set up your brand and channels for email and SMS marketing",dMe="Brand Settings",mMe="Business Information",hMe="Email Channel",pMe="SMS Channel",gMe="Customize Your Brand",fMe="Business Settings",vMe="Email Channel Settings",yMe="Connect Your SMS",bMe="DBA legal name",kMe="ZIP Code",SMe="ZIP code",wMe="Select country",AMe="First Name",CMe="First name",MMe="Last Name",TMe="Last name",xMe="Email address",EMe="Contact Phone",NMe="Auto Parse",_Me={brand:{label:dMe},business:{label:mMe},email:{label:hMe},sms:{label:pMe}},PMe=[{key:"brand",label:_Me.brand.label},{key:"business",label:_Me.business.label},{key:"email",label:_Me.email.label},{key:"sms",label:_Me.sms.label}],jMe=[{key:"brand",label:_Me.brand.label},{key:"email",label:_Me.email.label},{key:"business",label:_Me.business.label},{key:"sms",label:_Me.sms.label},{key:"completion",label:"Completion"}],LMe=({control:e,disabled:a=!1,namePrefix:n="company",context:i="email"})=>{const r="email"===i,o=rMe.map((e=>({value:e.code,label:e.name})));return t.jsxs(t.Fragment,{children:[r&&t.jsx("div",{className:"rounded-lg border border-blue-100 bg-blue-50 p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-blue-100",children:t.jsx(Tz,{className:"w-4 h-4 text-blue-600"})})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h4",{className:"text-sm font-medium text-blue-900 mb-1",children:"Email Footer Information"}),t.jsx("p",{className:"text-sm text-blue-700",children:"Your business address will be included in email footers as required by law. This ensures compliance with email marketing regulations and provides recipients with your business contact information."})]})]})}),t.jsx(qCe,{control:e,name:`${n}.name`,label:bMe,placeholder:"Enter your DBA or legal business name",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.address1`,label:"Business Address",placeholder:"Street address",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.address2`,label:"Business Address Line 2",placeholder:"Apartment, suite, unit, etc. (optional)",disabled:a}),t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsx(qCe,{control:e,name:`${n}.city`,label:"City",placeholder:"City",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.stateProvince`,label:"State/Province",placeholder:"State/Province",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.zipCode`,label:kMe,placeholder:SMe,disabled:a})]}),t.jsx($Ce,{control:e,name:`${n}.country`,label:"Country",placeholder:wMe,options:o,disabled:a})]})},BMe=({control:e,disabled:a=!1,namePrefix:n="contact"})=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(qCe,{control:e,name:`${n}.firstName`,label:AMe,placeholder:CMe,disabled:a}),t.jsx(qCe,{control:e,name:`${n}.lastName`,label:MMe,placeholder:TMe,disabled:a})]}),t.jsx(qCe,{control:e,name:`${n}.email`,label:"Email",placeholder:xMe,type:"email",disabled:a}),t.jsx(qCe,{control:e,name:`${n}.phoneNumber`,label:EMe,placeholder:"+1234567890",description:"Must start with + and country code",type:"tel",disabled:a})]}),RMe=xle,DMe=a.forwardRef((({isSubmitting:e,onSubmit:n,hideSubmitButton:i=!1},r)=>{const o=yCe({resolver:iMe(RMe),defaultValues:{type:Cle.AWS_TOLL_FREE_NUMBER,tollFreeNumber:"",company:{name:"",website:"",address1:"",address2:"",city:"",stateProvince:"",zipCode:"",country:""},contact:{firstName:"",lastName:"",email:"",phoneNumber:""},messagingUseCase:{monthlyVolume:0,category:Mle.PROMOTIONS_MARKETING,useCaseDetails:""},messageSamples:[""]},values:void 0}),s=o.watch("messageSamples");a.useImperativeHandle(r,(()=>({submit:()=>{o.handleSubmit(l)()}})));const l=async e=>{const a={...e,messagingUseCase:{...e.messagingUseCase,monthlyVolume:Number(e.messagingUseCase.monthlyVolume)}};await n(a)};return t.jsx("div",{className:"w-full max-w-4xl text-left",children:t.jsx(bCe,{...o,children:t.jsxs("form",{onSubmit:o.handleSubmit(l),className:"space-y-6",children:[t.jsx(ZCe,{title:"Legal Business Settings",description:"Provide your legal business information required for SMS channel verification and future communications.",children:t.jsx(LMe,{control:o.control,disabled:e,context:"sms"})}),t.jsx(ZCe,{title:"Contact Information",description:"Provide the contact information of the person authorized to represent your business.",children:t.jsx(BMe,{control:o.control,disabled:e})}),t.jsxs(ZCe,{title:"Messaging Use Case",description:"Tell us about how you plan to use SMS messaging.",children:[t.jsx(qCe,{control:o.control,name:"messagingUseCase.monthlyVolume",label:"Expected Monthly Volume",placeholder:"1000",type:"number",disabled:e}),t.jsx(qCe,{control:o.control,name:"messagingUseCase.useCaseDetails",label:"Use Case Details",placeholder:"Describe your use case in detail",disabled:e})]}),t.jsxs(ZCe,{title:"Message Samples",description:"Provide examples of messages you plan to send (up to 3 samples).",children:[t.jsx(wY,{children:s.map(((a,n)=>t.jsxs(o5.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},className:"relative",children:[t.jsx(qCe,{control:o.control,name:`messageSamples.${n}`,label:`Sample Message ${n+1}`,placeholder:"Enter a sample message",disabled:e}),s.length>1&&t.jsx(o5.button,{type:"button",onClick:()=>(e=>{if(s.length>1){const a=s.filter(((a,t)=>t!==e));o.setValue("messageSamples",a)}})(n),className:"absolute -right-2 -top-2 rounded-full bg-destructive/10 p-1 text-destructive hover:bg-destructive/20",whileHover:{scale:1.1},whileTap:{scale:.9},children:t.jsx(V5.CloseButton,{className:"h-4 w-4"})})]},n)))}),s.length<3&&t.jsxs(o5.button,{type:"button",onClick:()=>{s.length<3&&o.setValue("messageSamples",[...s,""])},className:"mt-4 flex items-center gap-2 rounded-lg border border-dashed border-border px-4 py-2 text-sm text-muted-foreground hover:border-border/80 hover:text-foreground",whileHover:{scale:1.02},whileTap:{scale:.98},children:[t.jsx(V5.PlusIcon,{className:"h-4 w-4"}),"Add another sample"]})]}),!i&&t.jsx("div",{className:"flex gap-3 pt-4 justify-end",children:t.jsx(H5,{type:"submit",disabled:e,children:e?"Submitting...":"Submit for approval"})})]})})})})),zMe=({onSubmit:e,onApplicationSubmit:n,hideSubmitButton:i=!1,formRef:r,onFormVisibilityChange:o})=>{const[s,l]=a.useState(!1),{data:u,isLoading:c}=$re(),{createSmsRegistrationApplication:d,isCreating:m}=Zre();a.useEffect((()=>{o?.(s)}),[s,o]);if(!u||c)return t.jsx("div",{className:"flex flex-col items-center justify-center p-8",children:t.jsx(lY,{text:["Loading business information..."]})});const h={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}},p=u&&u.status===Ele.PENDING;return t.jsxs(o5.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:XO("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl p-6 gap-3 border border-border mx-auto","bg-background"),children:[t.jsx(o5.div,{variants:h,className:"w-16 h-16 rounded-xl flex items-center justify-center",children:t.jsx(V5.SmsIcon,{})}),t.jsx(o5.h2,{variants:h,className:"text-sm font-medium text-foreground",children:"Request your SMS sending number"}),t.jsxs(o5.div,{variants:h,className:"max-w-xl mx-auto",children:[t.jsx("p",{className:"text-sm font-normal text-muted-foreground mb-2",children:"Before you can send messages, we need to verify your business info with our SMS provider. Once approved, we'll assign you a phone number to send SMS campaigns."}),t.jsx("p",{className:"text-sm font-normal text-muted-foreground",children:"This usually takes 3-7 business days."})]}),t.jsx(wY,{mode:"wait",children:s?t.jsx(o5.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.3,ease:[.4,0,.2,1]},className:"w-full",children:t.jsx(DMe,{isSubmitting:m,onSubmit:async a=>{if(n)await n(a);else try{d({application:a,onSuccess:()=>{l(!1),e?.()}})}catch(t){}},hideSubmitButton:i,ref:r})},"form"):p?t.jsxs(o5.div,{variants:h,className:"flex items-center gap-2 px-3 py-1.5 bg-orange-50 border border-orange-200 rounded-full",children:[t.jsx(o5.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-orange-500 rounded-full"}),t.jsx("span",{className:"text-sm font-medium text-orange-800",children:"Pending approval"})]},"pending"):t.jsx(o5.div,{variants:h,children:t.jsx(H5,{variant:"outline",className:"bg-background",onClick:()=>l(!0),children:"Request approval"})},"button")})]})},OMe=e=>{const{companyName:a,smsBody:t}=e;return a&&t?`${a}:\n${t}`:t??""},KMe="undefined"!=typeof window&&"undefined"!=typeof document;async function HMe(e){if(!KMe)throw new Error("Image conversion is only supported in browser environments");return new Promise(((a,t)=>{try{const n=new window.Image;n.crossOrigin="anonymous",n.onload=()=>{try{const e=document.createElement("canvas");e.width=n.naturalWidth,e.height=n.naturalHeight;const i=e.getContext("2d");if(!i)return void t(new Error("Failed to get canvas context"));i.drawImage(n,0,0);const r=e.toDataURL("image/png",1);a(r)}catch(e){t(e)}},n.onerror=()=>{t(new Error("Failed to load image"))},n.src=e}catch(n){t(n)}}))}function IMe(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]}const FMe=e=>{const{channelSenderId:a,smsChannelSenders:t}=e;return t?.find((e=>e.channelSender.id===a))?.channelSender.channelSenderMetadata.friendlyName??t?.find((e=>e.channelSender.id===a))?.channelSender.channelSenderMetadata.from??a},GMe=e=>{switch(e){case"default":default:return"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200";case"subtle":return"inline-flex items-center font-medium mx-[1px] leading-none align-middle px-1 py-0.5 rounded-md bg-white/30 text-inherit shadow-[0_0_0_1px_rgba(0,0,0,0.05)]";case"minimal":return"inline-flex items-center px-1.5 py-0.5 rounded text-xs bg-gray-50 text-gray-700 font-medium border border-gray-200";case"inline":return"inline-flex items-center px-1 py-0.5 rounded text-xs bg-gray-100 text-gray-800 font-medium";case"badge":return"inline-flex items-center px-2 py-1 rounded-full text-xs bg-indigo-100 text-indigo-800 font-medium border border-indigo-200"}},VMe=({content:e,mergeFieldsResponse:n,variant:i="default",className:r="",asHtml:o=!0})=>{const s=a.useMemo((()=>n?.mergeFields?.flatMap((e=>e.entries))??[]),[n]),l=a.useMemo((()=>((e,a,t)=>e?e.replace(/\{\{.*?\}\}/g,(e=>{const n=a.find((a=>a.value===e));return n?`<span class="${GMe(t)}" data-merge-field="true" data-template-name="${n.value}" data-display-name="${n.label}">${n.label}</span>`:e})):"")(e,s,i)),[e,s,i]);if(!o){const a=e?.replace(/\{\{.*?\}\}/g,(e=>{const a=s.find((a=>a.value===e));return a?a.label:e}))||"";return t.jsx("span",{className:r,children:a})}return t.jsx("span",{className:r,dangerouslySetInnerHTML:{__html:l}})},JMe=({body:e,imageUrls:a})=>{const n=R5(),{getMergeFields:i,isGetting:r}=Qe(n?.id??void 0);return r||void 0===i?null:t.jsx("div",{className:"sms-preview-outer @container",children:t.jsxs("div",{className:"sms-phone-mockup",children:[t.jsx("div",{className:"sms-phone-notch"}),t.jsxs("div",{className:"sms-phone-inner",children:[a&&a.length>0&&a.map(((e,a)=>t.jsx("div",{className:"sms-message-row",children:t.jsx("div",{className:"sms-message-bubble",children:t.jsx("img",{src:e,alt:"MMS attachment",className:"sms-message-image",loading:"lazy"})})},e+a))),t.jsx("div",{className:"sms-message-row",children:t.jsx("div",{className:"sms-message-bubble",children:t.jsx(VMe,{content:e,mergeFieldsResponse:i,variant:"subtle",className:"text-white"})})})]}),t.jsx("div",{className:"sms-phone-home-indicator"})]})})};function UMe(e){const a=r.useRef({value:e,previous:e});return r.useMemo((()=>(a.current.value!==e&&(a.current.previous=a.current.value,a.current.value=e),a.current.previous)),[e])}var WMe="Checkbox",[qMe,$Me]=u9(WMe),[ZMe,YMe]=qMe(WMe),QMe=r.forwardRef(((e,a)=>{const{__scopeCheckbox:n,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),f=FZ(a,(e=>g(e))),v=r.useRef(!1),y=!p||(m||!!p.closest("form")),[b=!1,k]=m9({prop:o,defaultProp:s,onChange:d}),S=r.useRef(b);return r.useEffect((()=>{const e=p?.form;if(e){const a=()=>k(S.current);return e.addEventListener("reset",a),()=>e.removeEventListener("reset",a)}}),[p,k]),t.jsxs(ZMe,{scope:n,state:b,disabled:u,children:[t.jsx(y9.button,{type:"button",role:"checkbox","aria-checked":tTe(b)?"mixed":b,"aria-required":l,"data-state":nTe(b),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:f,onKeyDown:l9(e.onKeyDown,(e=>{"Enter"===e.key&&e.preventDefault()})),onClick:l9(e.onClick,(e=>{k((e=>!!tTe(e)||!e)),y&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())}))}),y&&t.jsx(aTe,{control:p,bubbles:!v.current,name:i,value:c,checked:b,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"},defaultChecked:!tTe(s)&&s})]})}));QMe.displayName=WMe;var XMe="CheckboxIndicator",eTe=r.forwardRef(((e,a)=>{const{__scopeCheckbox:n,forceMount:i,...r}=e,o=YMe(XMe,n);return t.jsx($7,{present:i||tTe(o.state)||!0===o.state,children:t.jsx(y9.span,{"data-state":nTe(o.state),"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{pointerEvents:"none",...e.style}})})}));eTe.displayName=XMe;var aTe=e=>{const{control:a,checked:n,bubbles:i=!0,defaultChecked:o,...s}=e,l=r.useRef(null),u=UMe(n),c=M7(a);r.useEffect((()=>{const e=l.current,a=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(a,"checked").set;if(u!==n&&t){const a=new Event("click",{bubbles:i});e.indeterminate=tTe(n),t.call(e,!tTe(n)&&n),e.dispatchEvent(a)}}),[u,n,i]);const d=r.useRef(!tTe(n)&&n);return t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??d.current,...s,tabIndex:-1,ref:l,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function tTe(e){return"indeterminate"===e}function nTe(e){return tTe(e)?"indeterminate":e?"checked":"unchecked"}var iTe=QMe,rTe=eTe;const oTe=r.forwardRef((({className:e,...a},n)=>t.jsx(iTe,{ref:n,className:XO("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...a,children:t.jsx(rTe,{className:XO("flex items-center justify-center text-current"),children:t.jsx(tz,{className:"h-4 w-4"})})})));oTe.displayName=iTe.displayName;var sTe=.999,lTe=/[\\\/_+.#"@\[\(\{&]/,uTe=/[\\\/_+.#"@\[\(\{&]/g,cTe=/[\s-]/,dTe=/[\s-]/g;function mTe(e,a,t,n,i,r,o){if(r===a.length)return i===e.length?1:.99;var s=`${i},${r}`;if(void 0!==o[s])return o[s];for(var l,u,c,d,m=n.charAt(r),h=t.indexOf(m,i),p=0;h>=0;)(l=mTe(e,a,t,n,h+1,r+1,o))>p&&(h===i?l*=1:lTe.test(e.charAt(h-1))?(l*=.8,(c=e.slice(i,h-1).match(uTe))&&i>0&&(l*=Math.pow(sTe,c.length))):cTe.test(e.charAt(h-1))?(l*=.9,(d=e.slice(i,h-1).match(dTe))&&i>0&&(l*=Math.pow(sTe,d.length))):(l*=.17,i>0&&(l*=Math.pow(sTe,h-i))),e.charAt(h)!==a.charAt(r)&&(l*=.9999)),(l<.1&&t.charAt(h-1)===n.charAt(r+1)||n.charAt(r+1)===n.charAt(r)&&t.charAt(h-1)!==n.charAt(r))&&(.1*(u=mTe(e,a,t,n,h+1,r+2,o))>l&&(l=.1*u)),l>p&&(p=l),h=t.indexOf(m,h+1);return o[s]=p,p}function hTe(e){return e.toLowerCase().replace(dTe," ")}function pTe(e,a,t){return mTe(e=t&&t.length>0?""+(e+" "+t.join(" ")):e,a,hTe(e),hTe(a),0,0,{})}var gTe,fTe={exports:{}},vTe={};var yTe,bTe={};
|
|
84
84
|
/**
|
|
85
85
|
* @license React
|
|
86
86
|
* use-sync-external-store-shim.development.js
|