randmarcomps 1.403.0 → 1.404.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/randmarcomps.js
CHANGED
|
@@ -62605,7 +62605,7 @@ const fetchGeminiResponse = async (t, e, n, o, l = 3) => {
|
|
|
62605
62605
|
onKeyDown: (it) => {
|
|
62606
62606
|
it.key !== "Enter" || it.shiftKey || (it.preventDefault(), mr());
|
|
62607
62607
|
},
|
|
62608
|
-
className: Zt != null && Zt.pending ? "collapse" : "flex-1 resize-none",
|
|
62608
|
+
className: Zt != null && Zt.pending ? "collapse" : "flex-1 resize-none field-sizing-content max-h-[30em]",
|
|
62609
62609
|
disabled: !Ne || (Zt == null ? void 0 : Zt.pending)
|
|
62610
62610
|
}
|
|
62611
62611
|
),
|
|
@@ -1144,7 +1144,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
|
|
|
1144
1144
|
- **Crucially, do not use any placeholders, brackets, or instructions for the user to fill in.** Use the context provided to craft the final text.
|
|
1145
1145
|
- Keep it to 1-2 concise, engaging sentences.
|
|
1146
1146
|
- Output only the plain text of the message itself.
|
|
1147
|
-
`,In=await Q(bn);if(In){const Hn=(sn=(await te({routeApplicationId:t,partnerId:"2"})).data)==null?void 0:sn.ConversationId;if(Hn)await S(),Jt(Hn,In);else throw new Error("Failed to retrieve conversation ID after creation.")}}catch(mn){console.error("Error during 'Chat with Randmar' initiation:",mn),rt({title:"Error",description:"Could not initiate chat. Please try again later.",variant:"destructive"})}finally{V.current&&(V.current.disabled=!1),F(!1)}},An=()=>{Qe(it=>it.map(Xt=>Xt.partner1!==ASSISTANT_ID&&Xt.partner2!==ASSISTANT_ID?Xt:{...Xt,messages:[]})),$t([]),Le()},jn=()=>{$e&&E({routeApplicationId:t,partnerId:$e[0]==t?$e[1]:$e[0]}).then(()=>{Be("approved")})},Zt=st(),en=Ge.filter(it=>it.pending).length,nn=(it,Ht)=>{M(Xt=>({...Xt,[it]:Ht})),An()},Kt=React.useRef(null);React.useEffect(()=>{var it;(it=Kt.current)==null||it.scrollIntoView({behavior:"smooth"})},[ge]);const Yt=({className:it="h-4 w-4"})=>jsxRuntime.jsxs("svg",{style:{flex:"none",lineHeight:1},viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",className:it,children:[jsxRuntime.jsx("title",{children:"Gemini"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-0)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-1)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-2)"}),jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"#08B962"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[jsxRuntime.jsx("stop",{stopColor:"#F94543"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"#FABC12"}),jsxRuntime.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]}),xn=jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsxs("div",{className:"text-center text-muted-foreground",children:[jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})});return jsxRuntime.jsxs("div",{className:cn("flex overflow-hidden",l),children:[o!==!0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"w-[260px] p-4 pt-3 flex flex-col border-r",children:[jsxRuntime.jsx("div",{className:"p-4 font-semibold border-b",children:"Communications"}),Ge.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Search,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx(Input,{placeholder:"Search chats...",className:"pl-8 h-9",value:Xe,onChange:it=>ot(it.target.value)})]})}),jsxRuntime.jsx(Tabs,{value:qe,onValueChange:Be,className:"w-full mb-1",children:jsxRuntime.jsxs(TabsList,{className:"grid grid-cols-6 h-9 mx-2",children:[jsxRuntime.jsx(TabsTrigger,{value:"approved",className:"text-xs col-span-3",children:"Approved"}),jsxRuntime.jsxs(TabsTrigger,{value:"pending",className:"text-xs col-span-3",children:["Pending ",en>0&&`(${en})`]})]})})]}),jsxRuntime.jsx("div",{className:"mt-1 mb-1",children:Ge.findIndex(it=>it.partner1==="2"||it.partner2==="2")<0?jsxRuntime.jsx(Button$1,{className:"w-full",ref:V,disabled:j,onClick:Cn,children:j?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Starting Chat..."]}):"Chat with Randmar"},"b1"):qe==="approved"&&Ge.length>=5?null:jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/ExploreManufacturers`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsx(Button$1,{className:"w-full",children:"Explore Manufacturers"},"b2")})}),jsxRuntime.jsx(ScrollArea,{className:"flex-1",children:Ge.length>0&&jsxRuntime.jsx(ChatList,{userId:t,chats:dt.filter(it=>it.partner1!==ASSISTANT_ID&&it.partner2!==ASSISTANT_ID),activeChat:Zt??null,onSelectChat:He})}),jsxRuntime.jsx(Separator$1,{className:"mt-auto"}),jsxRuntime.jsx("div",{className:"pt-1",children:Ge.find(it=>it.partner1===ASSISTANT_ID||it.partner2===ASSISTANT_ID)&&jsxRuntime.jsx(ChatList,{userId:t,chats:dt.filter(it=>it.partner1===ASSISTANT_ID||it.partner2===ASSISTANT_ID),activeChat:Zt??null,onSelectChat:He,assistantStickyMode:!0})})]})}),jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:$e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex items-center p-4 border-b",children:$e[0]==ASSISTANT_ID||$e[1]==ASSISTANT_ID?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:"Randmar Assistant"}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"ml-auto",confirmationDialog:{title:"Report Issue",content:"This action will send a copy of your chat to Randmar. Send it?",onConfirm:()=>Sn()},disabled:_,children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-5 w-5 mr-2 animate-spin"}),"Sending Feedback..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MessageSquareShare,{className:"h-5 w-5 mr-2"}),"Report Issue"]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"ml-1",onClick:()=>An(),children:jsxRuntime.jsx(MessageCircleX,{className:"h-5 w-5"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Reset Chat"})})]})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:$e[0]===t?$e[1]:$e[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:Zt==null?void 0:Zt.name}),jsxRuntime.jsx("div",{className:"flex items-center space-x-2 ml-auto",children:jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/Partner/${$e[0]===t?$e[1]:$e[0]}`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsx(Button$1,{children:"View Partner"})})})]})}),Zt!=null&&Zt.pending&&Zt.partner1==t?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:Ne?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ChatMessages,{messages:(Zt==null?void 0:Zt.messages)??[],currentUserId:t,isAssistantChat:pt(),botStatus:pt()?Ve:""}),jsxRuntime.jsx("div",{ref:lt})]}):xn}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(Zt==null?void 0:Zt.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:A,onClick:()=>jn(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:Vt,placeholder:"Type a message...",value:We,onPaste:pn,onChange:it=>Ue(it.target.value),onKeyDown:it=>{it.key!=="Enter"||it.shiftKey||(it.preventDefault(),vn())},className:Zt!=null&&Zt.pending?"collapse":"flex-1 resize-none",disabled:!Ne||(Zt==null?void 0:Zt.pending)}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:Zt!=null&&Zt.pending?"collapse":"ml-2 h-8 w-8",disabled:!Ne||!!Ve||(Zt==null?void 0:Zt.pending),onClick:vn,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),pt()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Input,{type:"file",onChange:qt,className:"hidden",ref:Je}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:En,className:Zt!=null&&Zt.pending?"collapse":"ml-2 h-8 w-8",disabled:!Ne||Ve!==""||(Zt==null?void 0:Zt.pending)||!!yt,children:jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"})}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:Rn,className:Zt!=null&&Zt.pending?"collapse":"ml-2 h-8 w-8",disabled:!Ne||Ve!==""||(Zt==null?void 0:Zt.pending)||!yt,children:jsxRuntime.jsx(Trash,{className:"h-5 w-5"})})]})]})]})]})]}):jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:Ne?"Select a chat to start messaging":xn})}),jsxRuntime.jsx("div",{"data-thin":pt(),className:"w-[480px] flex flex-col border-l flex-5 data-[thin=true]:flex-3",children:pt()?jsxRuntime.jsxs("div",{className:"flex h-full flex-col border-r bg-slate-50 text-slate-800 rounded-r-lg",children:[jsxRuntime.jsxs("div",{className:"p-4 space-y-4 border-b border-slate-200/80",children:[jsxRuntime.jsxs("h4",{className:"flex items-center text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(Settings,{className:"w-4 h-4 mr-2"}),"Assistant Settings"]}),jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1.5 pr-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"preload-bestsellers-switch",children:"Preload Best-Sellers"}),jsxRuntime.jsx("p",{className:"text-xs text-slate-600",children:"Adds top products to the AI's context for faster answers."})]}),jsxRuntime.jsx(Switch,{id:"preload-bestsellers-switch",checked:I.assistantCachedPreloading,onCheckedChange:it=>nn("assistantCachedPreloading",it)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1.5 pr-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"proactive-context-switch",children:"Proactive Context Fetch"}),jsxRuntime.jsx("p",{className:"text-xs text-slate-600",children:"Loads your initial data at the start of a new conversation."})]}),jsxRuntime.jsx(Switch,{id:"proactive-context-switch",checked:I.assistantDynamicPreloading,onCheckedChange:it=>nn("assistantDynamicPreloading",it)})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col border-b border-slate-200/80 h-32",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(File,{className:"w-4 h-4 mr-2"}),"Attached Files"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsx("div",{className:"py-2 text-sm",children:yt||Rt.length>0?jsxRuntime.jsxs("div",{className:"space-y-2",children:[yt&&jsxRuntime.jsxs("div",{className:"flex items-center text-blue-600",children:[jsxRuntime.jsx(File,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsxs("span",{className:"truncate",children:[yt.name," (pending)"]})]}),Rt.slice().reverse().map((it,Ht)=>jsxRuntime.jsxs("div",{className:"flex items-center text-slate-700 hover:text-slate-900 transition-colors duration-150",children:[jsxRuntime.jsx(File,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsx("span",{className:"truncate",children:it})]},Ht))]}):jsxRuntime.jsx("p",{className:"text-slate-500 text-xs italic",children:"No files attached yet."})})})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(CodeXml,{className:"w-4 h-4 mr-2"}),"Developer Log"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-xs font-mono",children:[jsxRuntime.jsx(DebugMessageDisplay,{debugMessages:ge}),jsxRuntime.jsx("div",{ref:Kt})]})})]}),jsxRuntime.jsx("div",{className:"mt-auto p-3 border-t border-slate-200/80",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-xs text-slate-500",children:"Powered by Gemini"}),jsxRuntime.jsx(Yt,{})]})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex items-center p-4 border-b",children:jsxRuntime.jsx("p",{className:"h-9 text-base/9",children:"Partner Overview"})}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(PartnerRelationshipPage,{applicationId:t,partnerId:(($e==null?void 0:$e[0])===t?$e[1]:$e==null?void 0:$e[0])??t,userEmail:e,shopifyHostName:void 0,isSuperAdmin:!1})})})]})})]})});function UnsavedChangesDialog({isOpen:t,onClose:e,onConfirm:n,title:o,description:l,confirmText:d="Confirm",cancelText:f="Cancel"}){return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:o}),jsxRuntime.jsx(DialogDescription,{children:l})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:e,children:f}),jsxRuntime.jsx(Button$1,{onClick:n,children:d})]})]})})}function useRouterNavigationGuard(t){const[e,n]=React.useState(!1),o=reactRouterDom.useBlocker(React.useCallback(({currentLocation:g,nextLocation:b})=>{const S=g.pathname!==b.pathname||g.search!==b.search||g.hash!==b.hash;return t()&&S},[t]));React.useEffect(()=>{o.state==="blocked"&&n(!0)},[o]),React.useEffect(()=>{const g=b=>{if(t())return b.preventDefault(),"You have unsaved changes. Are you sure you want to leave?"};return window.addEventListener("beforeunload",g),()=>{window.removeEventListener("beforeunload",g)}},[t]);const l=React.useCallback(()=>{n(!1),o.state==="blocked"&&o.proceed()},[o]),d=React.useCallback(()=>{n(!1),o.state==="blocked"&&o.reset()},[o]),f=React.useCallback(()=>jsxRuntime.jsx(UnsavedChangesDialog,{isOpen:e,onClose:d,onConfirm:l,title:"Unsaved Changes",description:"You have unsaved changes. Are you sure you want to leave? Your changes will be lost.",confirmText:"Discard Changes",cancelText:"Stay on Page"}),[e,d,l]);return{showDialog:e,handleConfirm:l,handleCancel:d,NavigationGuardDialog:f}}var isCheckBoxInput=t=>t.type==="checkbox",isDateObject=t=>t instanceof Date,isNullOrUndefined=t=>t==null;const isObjectType=t=>typeof t=="object";var isObject=t=>!isNullOrUndefined(t)&&!Array.isArray(t)&&isObjectType(t)&&!isDateObject(t),getEventValue=t=>isObject(t)&&t.target?isCheckBoxInput(t.target)?t.target.checked:t.target.value:t,getNodeParentName=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,isNameInFieldArray=(t,e)=>t.has(getNodeParentName(e)),isPlainObject$1=t=>{const e=t.constructor&&t.constructor.prototype;return isObject(e)&&e.hasOwnProperty("isPrototypeOf")},isWeb=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function cloneObject(t){let e;const n=Array.isArray(t),o=typeof FileList<"u"?t instanceof FileList:!1;if(t instanceof Date)e=new Date(t);else if(!(isWeb&&(t instanceof Blob||o))&&(n||isObject(t)))if(e=n?[]:Object.create(Object.getPrototypeOf(t)),!n&&!isPlainObject$1(t))e=t;else for(const l in t)t.hasOwnProperty(l)&&(e[l]=cloneObject(t[l]));else return t;return e}var isKey=t=>/^\w*$/.test(t),isUndefined=t=>t===void 0,compact=t=>Array.isArray(t)?t.filter(Boolean):[],stringToPath=t=>compact(t.replace(/["|']|\]/g,"").split(/\.|\[/)),get=(t,e,n)=>{if(!e||!isObject(t))return n;const o=(isKey(e)?[e]:stringToPath(e)).reduce((l,d)=>isNullOrUndefined(l)?l:l[d],t);return isUndefined(o)||o===t?isUndefined(t[e])?n:t[e]:o},isBoolean=t=>typeof t=="boolean",set=(t,e,n)=>{let o=-1;const l=isKey(e)?[e]:stringToPath(e),d=l.length,f=d-1;for(;++o<d;){const g=l[o];let b=n;if(o!==f){const S=t[g];b=isObject(S)||Array.isArray(S)?S:isNaN(+l[o+1])?{}:[]}if(g==="__proto__"||g==="constructor"||g==="prototype")return;t[g]=b,t=t[g]}};const EVENTS={BLUR:"blur",FOCUS_OUT:"focusout"},VALIDATION_MODE={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},INPUT_VALIDATION_RULES={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},HookFormContext=React.createContext(null);HookFormContext.displayName="HookFormContext";var getProxyFormState=(t,e,n,o=!0)=>{const l={defaultValues:e._defaultValues};for(const d in t)Object.defineProperty(l,d,{get:()=>{const f=d;return e._proxyFormState[f]!==VALIDATION_MODE.all&&(e._proxyFormState[f]=!o||VALIDATION_MODE.all),t[f]}});return l};const useIsomorphicLayoutEffect$1=typeof window<"u"?React.useLayoutEffect:React.useEffect;var isString=t=>typeof t=="string",generateWatchOutput=(t,e,n,o,l)=>isString(t)?(o&&e.watch.add(t),get(n,t,l)):Array.isArray(t)?t.map(d=>(o&&e.watch.add(d),get(n,d))):(o&&(e.watchAll=!0),n),isPrimitive=t=>isNullOrUndefined(t)||!isObjectType(t);function deepEqual$1(t,e,n=new WeakSet){if(isPrimitive(t)||isPrimitive(e))return t===e;if(isDateObject(t)&&isDateObject(e))return t.getTime()===e.getTime();const o=Object.keys(t),l=Object.keys(e);if(o.length!==l.length)return!1;if(n.has(t)||n.has(e))return!0;n.add(t),n.add(e);for(const d of o){const f=t[d];if(!l.includes(d))return!1;if(d!=="ref"){const g=e[d];if(isDateObject(f)&&isDateObject(g)||isObject(f)&&isObject(g)||Array.isArray(f)&&Array.isArray(g)?!deepEqual$1(f,g,n):f!==g)return!1}}return!0}var appendErrors=(t,e,n,o,l)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[o]:l||!0}}:{},convertToArrayPayload=t=>Array.isArray(t)?t:[t],createSubject=()=>{let t=[];return{get observers(){return t},next:l=>{for(const d of t)d.next&&d.next(l)},subscribe:l=>(t.push(l),{unsubscribe:()=>{t=t.filter(d=>d!==l)}}),unsubscribe:()=>{t=[]}}};function extractFormValues(t,e){const n={};for(const o in t)if(t.hasOwnProperty(o)){const l=t[o],d=e[o];if(l&&isObject(l)&&d){const f=extractFormValues(l,d);isObject(f)&&(n[o]=f)}else t[o]&&(n[o]=d)}return n}var isEmptyObject$1=t=>isObject(t)&&!Object.keys(t).length,isFileInput=t=>t.type==="file",isFunction$3=t=>typeof t=="function",isHTMLElement=t=>{if(!isWeb)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},isMultipleSelect=t=>t.type==="select-multiple",isRadioInput=t=>t.type==="radio",isRadioOrCheckbox=t=>isRadioInput(t)||isCheckBoxInput(t),live=t=>isHTMLElement(t)&&t.isConnected;function baseGet(t,e){const n=e.slice(0,-1).length;let o=0;for(;o<n;)t=isUndefined(t)?o++:t[e[o++]];return t}function isEmptyArray(t){for(const e in t)if(t.hasOwnProperty(e)&&!isUndefined(t[e]))return!1;return!0}function unset(t,e){const n=Array.isArray(e)?e:isKey(e)?[e]:stringToPath(e),o=n.length===1?t:baseGet(t,n),l=n.length-1,d=n[l];return o&&delete o[d],l!==0&&(isObject(o)&&isEmptyObject$1(o)||Array.isArray(o)&&isEmptyArray(o))&&unset(t,n.slice(0,-1)),t}var objectHasFunction=t=>{for(const e in t)if(isFunction$3(t[e]))return!0;return!1};function isTraversable(t){return Array.isArray(t)||isObject(t)&&!objectHasFunction(t)}function markFieldsDirty(t,e={}){for(const n in t)isTraversable(t[n])?(e[n]=Array.isArray(t[n])?[]:{},markFieldsDirty(t[n],e[n])):isNullOrUndefined(t[n])||(e[n]=!0);return e}function getDirtyFields(t,e,n){n||(n=markFieldsDirty(e));for(const o in t)isTraversable(t[o])?isUndefined(e)||isPrimitive(n[o])?n[o]=markFieldsDirty(t[o],Array.isArray(t[o])?[]:{}):getDirtyFields(t[o],isNullOrUndefined(e)?{}:e[o],n[o]):n[o]=!deepEqual$1(t[o],e[o]);return n}const defaultResult={value:!1,isValid:!1},validResult={value:!0,isValid:!0};var getCheckboxValue=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!isUndefined(t[0].attributes.value)?isUndefined(t[0].value)||t[0].value===""?validResult:{value:t[0].value,isValid:!0}:validResult:defaultResult}return defaultResult},getFieldValueAs=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:o})=>isUndefined(t)?t:e?t===""?NaN:t&&+t:n&&isString(t)?new Date(t):o?o(t):t;const defaultReturn={isValid:!1,value:null};var getRadioValue=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,defaultReturn):defaultReturn;function getFieldValue(t){const e=t.ref;return isFileInput(e)?e.files:isRadioInput(e)?getRadioValue(t.refs).value:isMultipleSelect(e)?[...e.selectedOptions].map(({value:n})=>n):isCheckBoxInput(e)?getCheckboxValue(t.refs).value:getFieldValueAs(isUndefined(e.value)?t.ref.value:e.value,t)}var getResolverOptions=(t,e,n,o)=>{const l={};for(const d of t){const f=get(e,d);f&&set(l,d,f._f)}return{criteriaMode:n,names:[...t],fields:l,shouldUseNativeValidation:o}},isRegex=t=>t instanceof RegExp,getRuleValue=t=>isUndefined(t)?t:isRegex(t)?t.source:isObject(t)?isRegex(t.value)?t.value.source:t.value:t,getValidationModes=t=>({isOnSubmit:!t||t===VALIDATION_MODE.onSubmit,isOnBlur:t===VALIDATION_MODE.onBlur,isOnChange:t===VALIDATION_MODE.onChange,isOnAll:t===VALIDATION_MODE.all,isOnTouch:t===VALIDATION_MODE.onTouched});const ASYNC_FUNCTION="AsyncFunction";var hasPromiseValidation=t=>!!t&&!!t.validate&&!!(isFunction$3(t.validate)&&t.validate.constructor.name===ASYNC_FUNCTION||isObject(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===ASYNC_FUNCTION)),hasValidation=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),isWatched=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(o=>t.startsWith(o)&&/^\.\w+/.test(t.slice(o.length))));const iterateFieldsByAction=(t,e,n,o)=>{for(const l of n||Object.keys(t)){const d=get(t,l);if(d){const{_f:f,...g}=d;if(f){if(f.refs&&f.refs[0]&&e(f.refs[0],l)&&!o)return!0;if(f.ref&&e(f.ref,f.name)&&!o)return!0;if(iterateFieldsByAction(g,e))break}else if(isObject(g)&&iterateFieldsByAction(g,e))break}}};function schemaErrorLookup(t,e,n){const o=get(t,n);if(o||isKey(n))return{error:o,name:n};const l=n.split(".");for(;l.length;){const d=l.join("."),f=get(e,d),g=get(t,d);if(f&&!Array.isArray(f)&&n!==d)return{name:n};if(g&&g.type)return{name:d,error:g};if(g&&g.root&&g.root.type)return{name:`${d}.root`,error:g.root};l.pop()}return{name:n}}var shouldRenderFormState=(t,e,n,o)=>{n(t);const{name:l,...d}=t;return isEmptyObject$1(d)||Object.keys(d).length>=Object.keys(e).length||Object.keys(d).find(f=>e[f]===(!o||VALIDATION_MODE.all))},shouldSubscribeByName=(t,e,n)=>!t||!e||t===e||convertToArrayPayload(t).some(o=>o&&(n?o===e:o.startsWith(e)||e.startsWith(o))),skipValidation=(t,e,n,o,l)=>l.isOnAll?!1:!n&&l.isOnTouch?!(e||t):(n?o.isOnBlur:l.isOnBlur)?!t:(n?o.isOnChange:l.isOnChange)?t:!0,unsetEmptyArray=(t,e)=>!compact(get(t,e)).length&&unset(t,e),updateFieldArrayRootError=(t,e,n)=>{const o=convertToArrayPayload(get(t,n));return set(o,"root",e[n]),set(t,n,o),t};function getValidateError(t,e,n="validate"){if(isString(t)||Array.isArray(t)&&t.every(isString)||isBoolean(t)&&!t)return{type:n,message:isString(t)?t:"",ref:e}}var getValueAndMessage=t=>isObject(t)&&!isRegex(t)?t:{value:t,message:""},validateField=async(t,e,n,o,l,d)=>{const{ref:f,refs:g,required:b,maxLength:S,minLength:_,min:R,max:C,pattern:E,validate:A,name:I,valueAsNumber:M,mount:V}=t._f,O=get(n,I);if(!V||e.has(I))return{};const z=g?g[0]:f,Q=se=>{l&&z.reportValidity&&(z.setCustomValidity(isBoolean(se)?"":se||""),z.reportValidity())},j={},F=isRadioInput(f),te=isCheckBoxInput(f),ne=F||te,ae=(M||isFileInput(f))&&isUndefined(f.value)&&isUndefined(O)||isHTMLElement(f)&&f.value===""||O===""||Array.isArray(O)&&!O.length,je=appendErrors.bind(null,I,o,j),Ae=(se,Ne,ge,Ve=INPUT_VALIDATION_RULES.maxLength,Le=INPUT_VALIDATION_RULES.minLength)=>{const qe=se?Ne:ge;j[I]={type:se?Ve:Le,message:qe,ref:f,...je(se?Ve:Le,qe)}};if(d?!Array.isArray(O)||!O.length:b&&(!ne&&(ae||isNullOrUndefined(O))||isBoolean(O)&&!O||te&&!getCheckboxValue(g).isValid||F&&!getRadioValue(g).isValid)){const{value:se,message:Ne}=isString(b)?{value:!!b,message:b}:getValueAndMessage(b);if(se&&(j[I]={type:INPUT_VALIDATION_RULES.required,message:Ne,ref:z,...je(INPUT_VALIDATION_RULES.required,Ne)},!o))return Q(Ne),j}if(!ae&&(!isNullOrUndefined(R)||!isNullOrUndefined(C))){let se,Ne;const ge=getValueAndMessage(C),Ve=getValueAndMessage(R);if(!isNullOrUndefined(O)&&!isNaN(O)){const Le=f.valueAsNumber||O&&+O;isNullOrUndefined(ge.value)||(se=Le>ge.value),isNullOrUndefined(Ve.value)||(Ne=Le<Ve.value)}else{const Le=f.valueAsDate||new Date(O),qe=He=>new Date(new Date().toDateString()+" "+He),Be=f.type=="time",$e=f.type=="week";isString(ge.value)&&O&&(se=Be?qe(O)>qe(ge.value):$e?O>ge.value:Le>new Date(ge.value)),isString(Ve.value)&&O&&(Ne=Be?qe(O)<qe(Ve.value):$e?O<Ve.value:Le<new Date(Ve.value))}if((se||Ne)&&(Ae(!!se,ge.message,Ve.message,INPUT_VALIDATION_RULES.max,INPUT_VALIDATION_RULES.min),!o))return Q(j[I].message),j}if((S||_)&&!ae&&(isString(O)||d&&Array.isArray(O))){const se=getValueAndMessage(S),Ne=getValueAndMessage(_),ge=!isNullOrUndefined(se.value)&&O.length>+se.value,Ve=!isNullOrUndefined(Ne.value)&&O.length<+Ne.value;if((ge||Ve)&&(Ae(ge,se.message,Ne.message),!o))return Q(j[I].message),j}if(E&&!ae&&isString(O)){const{value:se,message:Ne}=getValueAndMessage(E);if(isRegex(se)&&!O.match(se)&&(j[I]={type:INPUT_VALIDATION_RULES.pattern,message:Ne,ref:f,...je(INPUT_VALIDATION_RULES.pattern,Ne)},!o))return Q(Ne),j}if(A){if(isFunction$3(A)){const se=await A(O,n),Ne=getValidateError(se,z);if(Ne&&(j[I]={...Ne,...je(INPUT_VALIDATION_RULES.validate,Ne.message)},!o))return Q(Ne.message),j}else if(isObject(A)){let se={};for(const Ne in A){if(!isEmptyObject$1(se)&&!o)break;const ge=getValidateError(await A[Ne](O,n),z,Ne);ge&&(se={...ge,...je(Ne,ge.message)},Q(ge.message),o&&(j[I]=se))}if(!isEmptyObject$1(se)&&(j[I]={ref:z,...se},!o))return j}}return Q(!0),j};const defaultOptions$1={mode:VALIDATION_MODE.onSubmit,reValidateMode:VALIDATION_MODE.onChange,shouldFocusError:!0};function createFormControl(t={}){let e={...defaultOptions$1,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:isFunction$3(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},o={},l=isObject(e.defaultValues)||isObject(e.values)?cloneObject(e.defaultValues||e.values)||{}:{},d=e.shouldUnregister?{}:cloneObject(l),f={action:!1,mount:!1,watch:!1},g={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},b,S=0;const _={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let R={..._};const C={array:createSubject(),state:createSubject()},E=e.criteriaMode===VALIDATION_MODE.all,A=Je=>rt=>{clearTimeout(S),S=setTimeout(Je,rt)},I=async Je=>{if(!e.disabled&&(_.isValid||R.isValid||Je)){const rt=e.resolver?isEmptyObject$1((await te()).errors):await ae(o,!0);rt!==n.isValid&&C.state.next({isValid:rt})}},M=(Je,rt)=>{!e.disabled&&(_.isValidating||_.validatingFields||R.isValidating||R.validatingFields)&&((Je||Array.from(g.mount)).forEach(st=>{st&&(rt?set(n.validatingFields,st,rt):unset(n.validatingFields,st))}),C.state.next({validatingFields:n.validatingFields,isValidating:!isEmptyObject$1(n.validatingFields)}))},V=(Je,rt=[],st,pt,ft=!0,dt=!0)=>{if(pt&&st&&!e.disabled){if(f.action=!0,dt&&Array.isArray(get(o,Je))){const mt=st(get(o,Je),pt.argA,pt.argB);ft&&set(o,Je,mt)}if(dt&&Array.isArray(get(n.errors,Je))){const mt=st(get(n.errors,Je),pt.argA,pt.argB);ft&&set(n.errors,Je,mt),unsetEmptyArray(n.errors,Je)}if((_.touchedFields||R.touchedFields)&&dt&&Array.isArray(get(n.touchedFields,Je))){const mt=st(get(n.touchedFields,Je),pt.argA,pt.argB);ft&&set(n.touchedFields,Je,mt)}(_.dirtyFields||R.dirtyFields)&&(n.dirtyFields=getDirtyFields(l,d)),C.state.next({name:Je,isDirty:Ae(Je,rt),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else set(d,Je,rt)},O=(Je,rt)=>{set(n.errors,Je,rt),C.state.next({errors:n.errors})},z=Je=>{n.errors=Je,C.state.next({errors:n.errors,isValid:!1})},Q=(Je,rt,st,pt)=>{const ft=get(o,Je);if(ft){const dt=get(d,Je,isUndefined(st)?get(l,Je):st);isUndefined(dt)||pt&&pt.defaultChecked||rt?set(d,Je,rt?dt:getFieldValue(ft._f)):ge(Je,dt),f.mount&&I()}},j=(Je,rt,st,pt,ft)=>{let dt=!1,mt=!1;const Ut={name:Je};if(!e.disabled){if(!st||pt){(_.isDirty||R.isDirty)&&(mt=n.isDirty,n.isDirty=Ut.isDirty=Ae(),dt=mt!==Ut.isDirty);const Jt=deepEqual$1(get(l,Je),rt);mt=!!get(n.dirtyFields,Je),Jt?unset(n.dirtyFields,Je):set(n.dirtyFields,Je,!0),Ut.dirtyFields=n.dirtyFields,dt=dt||(_.dirtyFields||R.dirtyFields)&&mt!==!Jt}if(st){const Jt=get(n.touchedFields,Je);Jt||(set(n.touchedFields,Je,st),Ut.touchedFields=n.touchedFields,dt=dt||(_.touchedFields||R.touchedFields)&&Jt!==st)}dt&&ft&&C.state.next(Ut)}return dt?Ut:{}},F=(Je,rt,st,pt)=>{const ft=get(n.errors,Je),dt=(_.isValid||R.isValid)&&isBoolean(rt)&&n.isValid!==rt;if(e.delayError&&st?(b=A(()=>O(Je,st)),b(e.delayError)):(clearTimeout(S),b=null,st?set(n.errors,Je,st):unset(n.errors,Je)),(st?!deepEqual$1(ft,st):ft)||!isEmptyObject$1(pt)||dt){const mt={...pt,...dt&&isBoolean(rt)?{isValid:rt}:{},errors:n.errors,name:Je};n={...n,...mt},C.state.next(mt)}},te=async Je=>{M(Je,!0);const rt=await e.resolver(d,e.context,getResolverOptions(Je||g.mount,o,e.criteriaMode,e.shouldUseNativeValidation));return M(Je),rt},ne=async Je=>{const{errors:rt}=await te(Je);if(Je)for(const st of Je){const pt=get(rt,st);pt?set(n.errors,st,pt):unset(n.errors,st)}else n.errors=rt;return rt},ae=async(Je,rt,st={valid:!0})=>{for(const pt in Je){const ft=Je[pt];if(ft){const{_f:dt,...mt}=ft;if(dt){const Ut=g.array.has(dt.name),Jt=ft._f&&hasPromiseValidation(ft._f);Jt&&_.validatingFields&&M([dt.name],!0);const pn=await validateField(ft,g.disabled,d,E,e.shouldUseNativeValidation&&!rt,Ut);if(Jt&&_.validatingFields&&M([dt.name]),pn[dt.name]&&(st.valid=!1,rt))break;!rt&&(get(pn,dt.name)?Ut?updateFieldArrayRootError(n.errors,pn,dt.name):set(n.errors,dt.name,pn[dt.name]):unset(n.errors,dt.name))}!isEmptyObject$1(mt)&&await ae(mt,rt,st)}}return st.valid},je=()=>{for(const Je of g.unMount){const rt=get(o,Je);rt&&(rt._f.refs?rt._f.refs.every(st=>!live(st)):!live(rt._f.ref))&&Xe(Je)}g.unMount=new Set},Ae=(Je,rt)=>!e.disabled&&(Je&&rt&&set(d,Je,rt),!deepEqual$1(He(),l)),se=(Je,rt,st)=>generateWatchOutput(Je,g,{...f.mount?d:isUndefined(rt)?l:isString(Je)?{[Je]:rt}:rt},st,rt),Ne=Je=>compact(get(f.mount?d:l,Je,e.shouldUnregister?get(l,Je,[]):[])),ge=(Je,rt,st={})=>{const pt=get(o,Je);let ft=rt;if(pt){const dt=pt._f;dt&&(!dt.disabled&&set(d,Je,getFieldValueAs(rt,dt)),ft=isHTMLElement(dt.ref)&&isNullOrUndefined(rt)?"":rt,isMultipleSelect(dt.ref)?[...dt.ref.options].forEach(mt=>mt.selected=ft.includes(mt.value)):dt.refs?isCheckBoxInput(dt.ref)?dt.refs.forEach(mt=>{(!mt.defaultChecked||!mt.disabled)&&(Array.isArray(ft)?mt.checked=!!ft.find(Ut=>Ut===mt.value):mt.checked=ft===mt.value||!!ft)}):dt.refs.forEach(mt=>mt.checked=mt.value===ft):isFileInput(dt.ref)?dt.ref.value="":(dt.ref.value=ft,dt.ref.type||C.state.next({name:Je,values:cloneObject(d)})))}(st.shouldDirty||st.shouldTouch)&&j(Je,ft,st.shouldTouch,st.shouldDirty,!0),st.shouldValidate&&$e(Je)},Ve=(Je,rt,st)=>{for(const pt in rt){if(!rt.hasOwnProperty(pt))return;const ft=rt[pt],dt=Je+"."+pt,mt=get(o,dt);(g.array.has(Je)||isObject(ft)||mt&&!mt._f)&&!isDateObject(ft)?Ve(dt,ft,st):ge(dt,ft,st)}},Le=(Je,rt,st={})=>{const pt=get(o,Je),ft=g.array.has(Je),dt=cloneObject(rt);set(d,Je,dt),ft?(C.array.next({name:Je,values:cloneObject(d)}),(_.isDirty||_.dirtyFields||R.isDirty||R.dirtyFields)&&st.shouldDirty&&C.state.next({name:Je,dirtyFields:getDirtyFields(l,d),isDirty:Ae(Je,dt)})):pt&&!pt._f&&!isNullOrUndefined(dt)?Ve(Je,dt,st):ge(Je,dt,st),isWatched(Je,g)&&C.state.next({...n,name:Je}),C.state.next({name:f.mount?Je:void 0,values:cloneObject(d)})},qe=async Je=>{f.mount=!0;const rt=Je.target;let st=rt.name,pt=!0;const ft=get(o,st),dt=Jt=>{pt=Number.isNaN(Jt)||isDateObject(Jt)&&isNaN(Jt.getTime())||deepEqual$1(Jt,get(d,st,Jt))},mt=getValidationModes(e.mode),Ut=getValidationModes(e.reValidateMode);if(ft){let Jt,pn;const vn=rt.type?getFieldValue(ft._f):getEventValue(Je),qt=Je.type===EVENTS.BLUR||Je.type===EVENTS.FOCUS_OUT,En=!hasValidation(ft._f)&&!e.resolver&&!get(n.errors,st)&&!ft._f.deps||skipValidation(qt,get(n.touchedFields,st),n.isSubmitted,Ut,mt),Rn=isWatched(st,g,qt);set(d,st,vn),qt?(!rt||!rt.readOnly)&&(ft._f.onBlur&&ft._f.onBlur(Je),b&&b(0)):ft._f.onChange&&ft._f.onChange(Je);const Sn=j(st,vn,qt),Cn=!isEmptyObject$1(Sn)||Rn;if(!qt&&C.state.next({name:st,type:Je.type,values:cloneObject(d)}),En)return(_.isValid||R.isValid)&&(e.mode==="onBlur"?qt&&I():qt||I()),Cn&&C.state.next({name:st,...Rn?{}:Sn});if(!qt&&Rn&&C.state.next({...n}),e.resolver){const{errors:An}=await te([st]);if(dt(vn),pt){const jn=schemaErrorLookup(n.errors,o,st),Zt=schemaErrorLookup(An,o,jn.name||st);Jt=Zt.error,st=Zt.name,pn=isEmptyObject$1(An)}}else M([st],!0),Jt=(await validateField(ft,g.disabled,d,E,e.shouldUseNativeValidation))[st],M([st]),dt(vn),pt&&(Jt?pn=!1:(_.isValid||R.isValid)&&(pn=await ae(o,!0)));pt&&(ft._f.deps&&(!Array.isArray(ft._f.deps)||ft._f.deps.length>0)&&$e(ft._f.deps),F(st,pn,Jt,Sn))}},Be=(Je,rt)=>{if(get(n.errors,rt)&&Je.focus)return Je.focus(),1},$e=async(Je,rt={})=>{let st,pt;const ft=convertToArrayPayload(Je);if(e.resolver){const dt=await ne(isUndefined(Je)?Je:ft);st=isEmptyObject$1(dt),pt=Je?!ft.some(mt=>get(dt,mt)):st}else Je?(pt=(await Promise.all(ft.map(async dt=>{const mt=get(o,dt);return await ae(mt&&mt._f?{[dt]:mt}:mt)}))).every(Boolean),!(!pt&&!n.isValid)&&I()):pt=st=await ae(o);return C.state.next({...!isString(Je)||(_.isValid||R.isValid)&&st!==n.isValid?{}:{name:Je},...e.resolver||!Je?{isValid:st}:{},errors:n.errors}),rt.shouldFocus&&!pt&&iterateFieldsByAction(o,Be,Je?ft:g.mount),pt},He=(Je,rt)=>{let st={...f.mount?d:l};return rt&&(st=extractFormValues(rt.dirtyFields?n.dirtyFields:n.touchedFields,st)),isUndefined(Je)?st:isString(Je)?get(st,Je):Je.map(pt=>get(st,pt))},We=(Je,rt)=>({invalid:!!get((rt||n).errors,Je),isDirty:!!get((rt||n).dirtyFields,Je),error:get((rt||n).errors,Je),isValidating:!!get(n.validatingFields,Je),isTouched:!!get((rt||n).touchedFields,Je)}),Ue=Je=>{Je&&convertToArrayPayload(Je).forEach(rt=>unset(n.errors,rt)),C.state.next({errors:Je?n.errors:{}})},Ke=(Je,rt,st)=>{const pt=(get(o,Je,{_f:{}})._f||{}).ref,ft=get(n.errors,Je)||{},{ref:dt,message:mt,type:Ut,...Jt}=ft;set(n.errors,Je,{...Jt,...rt,ref:pt}),C.state.next({name:Je,errors:n.errors,isValid:!1}),st&&st.shouldFocus&&pt&&pt.focus&&pt.focus()},tt=(Je,rt)=>isFunction$3(Je)?C.state.subscribe({next:st=>"values"in st&&Je(se(void 0,rt),st)}):se(Je,rt,!0),Ge=Je=>C.state.subscribe({next:rt=>{shouldSubscribeByName(Je.name,rt.name,Je.exact)&&shouldRenderFormState(rt,Je.formState||_,Ft,Je.reRenderRoot)&&Je.callback({values:{...d},...n,...rt,defaultValues:l})}}).unsubscribe,Qe=Je=>(f.mount=!0,R={...R,...Je.formState},Ge({...Je,formState:R})),Xe=(Je,rt={})=>{for(const st of Je?convertToArrayPayload(Je):g.mount)g.mount.delete(st),g.array.delete(st),rt.keepValue||(unset(o,st),unset(d,st)),!rt.keepError&&unset(n.errors,st),!rt.keepDirty&&unset(n.dirtyFields,st),!rt.keepTouched&&unset(n.touchedFields,st),!rt.keepIsValidating&&unset(n.validatingFields,st),!e.shouldUnregister&&!rt.keepDefaultValue&&unset(l,st);C.state.next({values:cloneObject(d)}),C.state.next({...n,...rt.keepDirty?{isDirty:Ae()}:{}}),!rt.keepIsValid&&I()},ot=({disabled:Je,name:rt})=>{(isBoolean(Je)&&f.mount||Je||g.disabled.has(rt))&&(Je?g.disabled.add(rt):g.disabled.delete(rt))},Ze=(Je,rt={})=>{let st=get(o,Je);const pt=isBoolean(rt.disabled)||isBoolean(e.disabled);return set(o,Je,{...st||{},_f:{...st&&st._f?st._f:{ref:{name:Je}},name:Je,mount:!0,...rt}}),g.mount.add(Je),st?ot({disabled:isBoolean(rt.disabled)?rt.disabled:e.disabled,name:Je}):Q(Je,!0,rt.value),{...pt?{disabled:rt.disabled||e.disabled}:{},...e.progressive?{required:!!rt.required,min:getRuleValue(rt.min),max:getRuleValue(rt.max),minLength:getRuleValue(rt.minLength),maxLength:getRuleValue(rt.maxLength),pattern:getRuleValue(rt.pattern)}:{},name:Je,onChange:qe,onBlur:qe,ref:ft=>{if(ft){Ze(Je,rt),st=get(o,Je);const dt=isUndefined(ft.value)&&ft.querySelectorAll&&ft.querySelectorAll("input,select,textarea")[0]||ft,mt=isRadioOrCheckbox(dt),Ut=st._f.refs||[];if(mt?Ut.find(Jt=>Jt===dt):dt===st._f.ref)return;set(o,Je,{_f:{...st._f,...mt?{refs:[...Ut.filter(live),dt,...Array.isArray(get(l,Je))?[{}]:[]],ref:{type:dt.type,name:Je}}:{ref:dt}}}),Q(Je,!1,void 0,dt)}else st=get(o,Je,{}),st._f&&(st._f.mount=!1),(e.shouldUnregister||rt.shouldUnregister)&&!(isNameInFieldArray(g.array,Je)&&f.action)&&g.unMount.add(Je)}}},at=()=>e.shouldFocusError&&iterateFieldsByAction(o,Be,g.mount),lt=Je=>{isBoolean(Je)&&(C.state.next({disabled:Je}),iterateFieldsByAction(o,(rt,st)=>{const pt=get(o,st);pt&&(rt.disabled=pt._f.disabled||Je,Array.isArray(pt._f.refs)&&pt._f.refs.forEach(ft=>{ft.disabled=pt._f.disabled||Je}))},0,!1))},ze=(Je,rt)=>async st=>{let pt;st&&(st.preventDefault&&st.preventDefault(),st.persist&&st.persist());let ft=cloneObject(d);if(C.state.next({isSubmitting:!0}),e.resolver){const{errors:dt,values:mt}=await te();n.errors=dt,ft=cloneObject(mt)}else await ae(o);if(g.disabled.size)for(const dt of g.disabled)unset(ft,dt);if(unset(n.errors,"root"),isEmptyObject$1(n.errors)){C.state.next({errors:{}});try{await Je(ft,st)}catch(dt){pt=dt}}else rt&&await rt({...n.errors},st),at(),setTimeout(at);if(C.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:isEmptyObject$1(n.errors)&&!pt,submitCount:n.submitCount+1,errors:n.errors}),pt)throw pt},yt=(Je,rt={})=>{get(o,Je)&&(isUndefined(rt.defaultValue)?Le(Je,cloneObject(get(l,Je))):(Le(Je,rt.defaultValue),set(l,Je,cloneObject(rt.defaultValue))),rt.keepTouched||unset(n.touchedFields,Je),rt.keepDirty||(unset(n.dirtyFields,Je),n.isDirty=rt.defaultValue?Ae(Je,cloneObject(get(l,Je))):Ae()),rt.keepError||(unset(n.errors,Je),_.isValid&&I()),C.state.next({...n}))},et=(Je,rt={})=>{const st=Je?cloneObject(Je):l,pt=cloneObject(st),ft=isEmptyObject$1(Je),dt=ft?l:pt;if(rt.keepDefaultValues||(l=st),!rt.keepValues){if(rt.keepDirtyValues){const mt=new Set([...g.mount,...Object.keys(getDirtyFields(l,d))]);for(const Ut of Array.from(mt))get(n.dirtyFields,Ut)?set(dt,Ut,get(d,Ut)):Le(Ut,get(dt,Ut))}else{if(isWeb&&isUndefined(Je))for(const mt of g.mount){const Ut=get(o,mt);if(Ut&&Ut._f){const Jt=Array.isArray(Ut._f.refs)?Ut._f.refs[0]:Ut._f.ref;if(isHTMLElement(Jt)){const pn=Jt.closest("form");if(pn){pn.reset();break}}}}if(rt.keepFieldsRef)for(const mt of g.mount)Le(mt,get(dt,mt));else o={}}d=e.shouldUnregister?rt.keepDefaultValues?cloneObject(l):{}:cloneObject(dt),C.array.next({values:{...dt}}),C.state.next({values:{...dt}})}g={mount:rt.keepDirtyValues?g.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},f.mount=!_.isValid||!!rt.keepIsValid||!!rt.keepDirtyValues,f.watch=!!e.shouldUnregister,C.state.next({submitCount:rt.keepSubmitCount?n.submitCount:0,isDirty:ft?!1:rt.keepDirty?n.isDirty:!!(rt.keepDefaultValues&&!deepEqual$1(Je,l)),isSubmitted:rt.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ft?{}:rt.keepDirtyValues?rt.keepDefaultValues&&d?getDirtyFields(l,d):n.dirtyFields:rt.keepDefaultValues&&Je?getDirtyFields(l,Je):rt.keepDirty?n.dirtyFields:{},touchedFields:rt.keepTouched?n.touchedFields:{},errors:rt.keepErrors?n.errors:{},isSubmitSuccessful:rt.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:l})},Rt=(Je,rt)=>et(isFunction$3(Je)?Je(d):Je,rt),$t=(Je,rt={})=>{const st=get(o,Je),pt=st&&st._f;if(pt){const ft=pt.refs?pt.refs[0]:pt.ref;ft.focus&&(ft.focus(),rt.shouldSelect&&isFunction$3(ft.select)&&ft.select())}},Ft=Je=>{n={...n,...Je}},Vt={control:{register:Ze,unregister:Xe,getFieldState:We,handleSubmit:ze,setError:Ke,_subscribe:Ge,_runSchema:te,_focusError:at,_getWatch:se,_getDirty:Ae,_setValid:I,_setFieldArray:V,_setDisabledField:ot,_setErrors:z,_getFieldArray:Ne,_reset:et,_resetDefaultValues:()=>isFunction$3(e.defaultValues)&&e.defaultValues().then(Je=>{Rt(Je,e.resetOptions),C.state.next({isLoading:!1})}),_removeUnmounted:je,_disableForm:lt,_subjects:C,_proxyFormState:_,get _fields(){return o},get _formValues(){return d},get _state(){return f},set _state(Je){f=Je},get _defaultValues(){return l},get _names(){return g},set _names(Je){g=Je},get _formState(){return n},get _options(){return e},set _options(Je){e={...e,...Je}}},subscribe:Qe,trigger:$e,register:Ze,handleSubmit:ze,watch:tt,setValue:Le,getValues:He,reset:Rt,resetField:yt,clearErrors:Ue,unregister:Xe,setError:Ke,setFocus:$t,getFieldState:We};return{...Vt,formControl:Vt}}function useForm(t={}){const e=React.useRef(void 0),n=React.useRef(void 0),[o,l]=React.useState({isDirty:!1,isValidating:!1,isLoading:isFunction$3(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:isFunction$3(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:o},t.defaultValues&&!isFunction$3(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:f,...g}=createFormControl(t);e.current={...g,formState:o}}const d=e.current.control;return d._options=t,useIsomorphicLayoutEffect$1(()=>{const f=d._subscribe({formState:d._proxyFormState,callback:()=>l({...d._formState}),reRenderRoot:!0});return l(g=>({...g,isReady:!0})),d._formState.isReady=!0,f},[d]),React.useEffect(()=>d._disableForm(t.disabled),[d,t.disabled]),React.useEffect(()=>{t.mode&&(d._options.mode=t.mode),t.reValidateMode&&(d._options.reValidateMode=t.reValidateMode)},[d,t.mode,t.reValidateMode]),React.useEffect(()=>{t.errors&&(d._setErrors(t.errors),d._focusError())},[d,t.errors]),React.useEffect(()=>{t.shouldUnregister&&d._subjects.state.next({values:d._getWatch()})},[d,t.shouldUnregister]),React.useEffect(()=>{if(d._proxyFormState.isDirty){const f=d._getDirty();f!==o.isDirty&&d._subjects.state.next({isDirty:f})}},[d,o.isDirty]),React.useEffect(()=>{t.values&&!deepEqual$1(t.values,n.current)?(d._reset(t.values,{keepFieldsRef:!0,...d._options.resetOptions}),n.current=t.values,l(f=>({...f}))):d._resetDefaultValues()},[d,t.values]),React.useEffect(()=>{d._state.mount||(d._setValid(),d._state.mount=!0),d._state.watch&&(d._state.watch=!1,d._subjects.state.next({...d._formState})),d._removeUnmounted()}),e.current.formState=getProxyFormState(o,d),e.current}var defaultErrorHandler=function(t){process.env.NODE_ENV!=="production"&&console.error(t)},defaultWarnHandler=function(t){process.env.NODE_ENV!=="production"&&console.warn(t)},DEFAULT_INTL_CONFIG={formats:{},messages:{},timeZone:void 0,defaultLocale:"en",defaultFormats:{},fallbackOnEmptyString:!0,onError:defaultErrorHandler,onWarn:defaultWarnHandler};function invariant(t,e,n){if(n===void 0&&(n=Error),!t)throw new n(e)}function invariantIntlContext(t){invariant(t,"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.")}__assign$1(__assign$1({},DEFAULT_INTL_CONFIG),{textComponent:React__namespace.Fragment});var reactIs={exports:{}},reactIs_production_min={};/** @license React v16.13.1
|
|
1147
|
+
`,In=await Q(bn);if(In){const Hn=(sn=(await te({routeApplicationId:t,partnerId:"2"})).data)==null?void 0:sn.ConversationId;if(Hn)await S(),Jt(Hn,In);else throw new Error("Failed to retrieve conversation ID after creation.")}}catch(mn){console.error("Error during 'Chat with Randmar' initiation:",mn),rt({title:"Error",description:"Could not initiate chat. Please try again later.",variant:"destructive"})}finally{V.current&&(V.current.disabled=!1),F(!1)}},An=()=>{Qe(it=>it.map(Xt=>Xt.partner1!==ASSISTANT_ID&&Xt.partner2!==ASSISTANT_ID?Xt:{...Xt,messages:[]})),$t([]),Le()},jn=()=>{$e&&E({routeApplicationId:t,partnerId:$e[0]==t?$e[1]:$e[0]}).then(()=>{Be("approved")})},Zt=st(),en=Ge.filter(it=>it.pending).length,nn=(it,Ht)=>{M(Xt=>({...Xt,[it]:Ht})),An()},Kt=React.useRef(null);React.useEffect(()=>{var it;(it=Kt.current)==null||it.scrollIntoView({behavior:"smooth"})},[ge]);const Yt=({className:it="h-4 w-4"})=>jsxRuntime.jsxs("svg",{style:{flex:"none",lineHeight:1},viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",className:it,children:[jsxRuntime.jsx("title",{children:"Gemini"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-0)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-1)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-2)"}),jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"#08B962"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[jsxRuntime.jsx("stop",{stopColor:"#F94543"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"#FABC12"}),jsxRuntime.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]}),xn=jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsxs("div",{className:"text-center text-muted-foreground",children:[jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})});return jsxRuntime.jsxs("div",{className:cn("flex overflow-hidden",l),children:[o!==!0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"w-[260px] p-4 pt-3 flex flex-col border-r",children:[jsxRuntime.jsx("div",{className:"p-4 font-semibold border-b",children:"Communications"}),Ge.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Search,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx(Input,{placeholder:"Search chats...",className:"pl-8 h-9",value:Xe,onChange:it=>ot(it.target.value)})]})}),jsxRuntime.jsx(Tabs,{value:qe,onValueChange:Be,className:"w-full mb-1",children:jsxRuntime.jsxs(TabsList,{className:"grid grid-cols-6 h-9 mx-2",children:[jsxRuntime.jsx(TabsTrigger,{value:"approved",className:"text-xs col-span-3",children:"Approved"}),jsxRuntime.jsxs(TabsTrigger,{value:"pending",className:"text-xs col-span-3",children:["Pending ",en>0&&`(${en})`]})]})})]}),jsxRuntime.jsx("div",{className:"mt-1 mb-1",children:Ge.findIndex(it=>it.partner1==="2"||it.partner2==="2")<0?jsxRuntime.jsx(Button$1,{className:"w-full",ref:V,disabled:j,onClick:Cn,children:j?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Starting Chat..."]}):"Chat with Randmar"},"b1"):qe==="approved"&&Ge.length>=5?null:jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/ExploreManufacturers`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsx(Button$1,{className:"w-full",children:"Explore Manufacturers"},"b2")})}),jsxRuntime.jsx(ScrollArea,{className:"flex-1",children:Ge.length>0&&jsxRuntime.jsx(ChatList,{userId:t,chats:dt.filter(it=>it.partner1!==ASSISTANT_ID&&it.partner2!==ASSISTANT_ID),activeChat:Zt??null,onSelectChat:He})}),jsxRuntime.jsx(Separator$1,{className:"mt-auto"}),jsxRuntime.jsx("div",{className:"pt-1",children:Ge.find(it=>it.partner1===ASSISTANT_ID||it.partner2===ASSISTANT_ID)&&jsxRuntime.jsx(ChatList,{userId:t,chats:dt.filter(it=>it.partner1===ASSISTANT_ID||it.partner2===ASSISTANT_ID),activeChat:Zt??null,onSelectChat:He,assistantStickyMode:!0})})]})}),jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:$e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex items-center p-4 border-b",children:$e[0]==ASSISTANT_ID||$e[1]==ASSISTANT_ID?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:"Randmar Assistant"}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"ml-auto",confirmationDialog:{title:"Report Issue",content:"This action will send a copy of your chat to Randmar. Send it?",onConfirm:()=>Sn()},disabled:_,children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-5 w-5 mr-2 animate-spin"}),"Sending Feedback..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MessageSquareShare,{className:"h-5 w-5 mr-2"}),"Report Issue"]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"ml-1",onClick:()=>An(),children:jsxRuntime.jsx(MessageCircleX,{className:"h-5 w-5"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Reset Chat"})})]})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:$e[0]===t?$e[1]:$e[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:Zt==null?void 0:Zt.name}),jsxRuntime.jsx("div",{className:"flex items-center space-x-2 ml-auto",children:jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/Partner/${$e[0]===t?$e[1]:$e[0]}`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsx(Button$1,{children:"View Partner"})})})]})}),Zt!=null&&Zt.pending&&Zt.partner1==t?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:Ne?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ChatMessages,{messages:(Zt==null?void 0:Zt.messages)??[],currentUserId:t,isAssistantChat:pt(),botStatus:pt()?Ve:""}),jsxRuntime.jsx("div",{ref:lt})]}):xn}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(Zt==null?void 0:Zt.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:A,onClick:()=>jn(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:Vt,placeholder:"Type a message...",value:We,onPaste:pn,onChange:it=>Ue(it.target.value),onKeyDown:it=>{it.key!=="Enter"||it.shiftKey||(it.preventDefault(),vn())},className:Zt!=null&&Zt.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:!Ne||(Zt==null?void 0:Zt.pending)}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:Zt!=null&&Zt.pending?"collapse":"ml-2 h-8 w-8",disabled:!Ne||!!Ve||(Zt==null?void 0:Zt.pending),onClick:vn,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),pt()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Input,{type:"file",onChange:qt,className:"hidden",ref:Je}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:En,className:Zt!=null&&Zt.pending?"collapse":"ml-2 h-8 w-8",disabled:!Ne||Ve!==""||(Zt==null?void 0:Zt.pending)||!!yt,children:jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"})}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:Rn,className:Zt!=null&&Zt.pending?"collapse":"ml-2 h-8 w-8",disabled:!Ne||Ve!==""||(Zt==null?void 0:Zt.pending)||!yt,children:jsxRuntime.jsx(Trash,{className:"h-5 w-5"})})]})]})]})]})]}):jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:Ne?"Select a chat to start messaging":xn})}),jsxRuntime.jsx("div",{"data-thin":pt(),className:"w-[480px] flex flex-col border-l flex-5 data-[thin=true]:flex-3",children:pt()?jsxRuntime.jsxs("div",{className:"flex h-full flex-col border-r bg-slate-50 text-slate-800 rounded-r-lg",children:[jsxRuntime.jsxs("div",{className:"p-4 space-y-4 border-b border-slate-200/80",children:[jsxRuntime.jsxs("h4",{className:"flex items-center text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(Settings,{className:"w-4 h-4 mr-2"}),"Assistant Settings"]}),jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1.5 pr-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"preload-bestsellers-switch",children:"Preload Best-Sellers"}),jsxRuntime.jsx("p",{className:"text-xs text-slate-600",children:"Adds top products to the AI's context for faster answers."})]}),jsxRuntime.jsx(Switch,{id:"preload-bestsellers-switch",checked:I.assistantCachedPreloading,onCheckedChange:it=>nn("assistantCachedPreloading",it)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1.5 pr-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"proactive-context-switch",children:"Proactive Context Fetch"}),jsxRuntime.jsx("p",{className:"text-xs text-slate-600",children:"Loads your initial data at the start of a new conversation."})]}),jsxRuntime.jsx(Switch,{id:"proactive-context-switch",checked:I.assistantDynamicPreloading,onCheckedChange:it=>nn("assistantDynamicPreloading",it)})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col border-b border-slate-200/80 h-32",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(File,{className:"w-4 h-4 mr-2"}),"Attached Files"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsx("div",{className:"py-2 text-sm",children:yt||Rt.length>0?jsxRuntime.jsxs("div",{className:"space-y-2",children:[yt&&jsxRuntime.jsxs("div",{className:"flex items-center text-blue-600",children:[jsxRuntime.jsx(File,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsxs("span",{className:"truncate",children:[yt.name," (pending)"]})]}),Rt.slice().reverse().map((it,Ht)=>jsxRuntime.jsxs("div",{className:"flex items-center text-slate-700 hover:text-slate-900 transition-colors duration-150",children:[jsxRuntime.jsx(File,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsx("span",{className:"truncate",children:it})]},Ht))]}):jsxRuntime.jsx("p",{className:"text-slate-500 text-xs italic",children:"No files attached yet."})})})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(CodeXml,{className:"w-4 h-4 mr-2"}),"Developer Log"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-xs font-mono",children:[jsxRuntime.jsx(DebugMessageDisplay,{debugMessages:ge}),jsxRuntime.jsx("div",{ref:Kt})]})})]}),jsxRuntime.jsx("div",{className:"mt-auto p-3 border-t border-slate-200/80",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-xs text-slate-500",children:"Powered by Gemini"}),jsxRuntime.jsx(Yt,{})]})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex items-center p-4 border-b",children:jsxRuntime.jsx("p",{className:"h-9 text-base/9",children:"Partner Overview"})}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(PartnerRelationshipPage,{applicationId:t,partnerId:(($e==null?void 0:$e[0])===t?$e[1]:$e==null?void 0:$e[0])??t,userEmail:e,shopifyHostName:void 0,isSuperAdmin:!1})})})]})})]})});function UnsavedChangesDialog({isOpen:t,onClose:e,onConfirm:n,title:o,description:l,confirmText:d="Confirm",cancelText:f="Cancel"}){return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:o}),jsxRuntime.jsx(DialogDescription,{children:l})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:e,children:f}),jsxRuntime.jsx(Button$1,{onClick:n,children:d})]})]})})}function useRouterNavigationGuard(t){const[e,n]=React.useState(!1),o=reactRouterDom.useBlocker(React.useCallback(({currentLocation:g,nextLocation:b})=>{const S=g.pathname!==b.pathname||g.search!==b.search||g.hash!==b.hash;return t()&&S},[t]));React.useEffect(()=>{o.state==="blocked"&&n(!0)},[o]),React.useEffect(()=>{const g=b=>{if(t())return b.preventDefault(),"You have unsaved changes. Are you sure you want to leave?"};return window.addEventListener("beforeunload",g),()=>{window.removeEventListener("beforeunload",g)}},[t]);const l=React.useCallback(()=>{n(!1),o.state==="blocked"&&o.proceed()},[o]),d=React.useCallback(()=>{n(!1),o.state==="blocked"&&o.reset()},[o]),f=React.useCallback(()=>jsxRuntime.jsx(UnsavedChangesDialog,{isOpen:e,onClose:d,onConfirm:l,title:"Unsaved Changes",description:"You have unsaved changes. Are you sure you want to leave? Your changes will be lost.",confirmText:"Discard Changes",cancelText:"Stay on Page"}),[e,d,l]);return{showDialog:e,handleConfirm:l,handleCancel:d,NavigationGuardDialog:f}}var isCheckBoxInput=t=>t.type==="checkbox",isDateObject=t=>t instanceof Date,isNullOrUndefined=t=>t==null;const isObjectType=t=>typeof t=="object";var isObject=t=>!isNullOrUndefined(t)&&!Array.isArray(t)&&isObjectType(t)&&!isDateObject(t),getEventValue=t=>isObject(t)&&t.target?isCheckBoxInput(t.target)?t.target.checked:t.target.value:t,getNodeParentName=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,isNameInFieldArray=(t,e)=>t.has(getNodeParentName(e)),isPlainObject$1=t=>{const e=t.constructor&&t.constructor.prototype;return isObject(e)&&e.hasOwnProperty("isPrototypeOf")},isWeb=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function cloneObject(t){let e;const n=Array.isArray(t),o=typeof FileList<"u"?t instanceof FileList:!1;if(t instanceof Date)e=new Date(t);else if(!(isWeb&&(t instanceof Blob||o))&&(n||isObject(t)))if(e=n?[]:Object.create(Object.getPrototypeOf(t)),!n&&!isPlainObject$1(t))e=t;else for(const l in t)t.hasOwnProperty(l)&&(e[l]=cloneObject(t[l]));else return t;return e}var isKey=t=>/^\w*$/.test(t),isUndefined=t=>t===void 0,compact=t=>Array.isArray(t)?t.filter(Boolean):[],stringToPath=t=>compact(t.replace(/["|']|\]/g,"").split(/\.|\[/)),get=(t,e,n)=>{if(!e||!isObject(t))return n;const o=(isKey(e)?[e]:stringToPath(e)).reduce((l,d)=>isNullOrUndefined(l)?l:l[d],t);return isUndefined(o)||o===t?isUndefined(t[e])?n:t[e]:o},isBoolean=t=>typeof t=="boolean",set=(t,e,n)=>{let o=-1;const l=isKey(e)?[e]:stringToPath(e),d=l.length,f=d-1;for(;++o<d;){const g=l[o];let b=n;if(o!==f){const S=t[g];b=isObject(S)||Array.isArray(S)?S:isNaN(+l[o+1])?{}:[]}if(g==="__proto__"||g==="constructor"||g==="prototype")return;t[g]=b,t=t[g]}};const EVENTS={BLUR:"blur",FOCUS_OUT:"focusout"},VALIDATION_MODE={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},INPUT_VALIDATION_RULES={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},HookFormContext=React.createContext(null);HookFormContext.displayName="HookFormContext";var getProxyFormState=(t,e,n,o=!0)=>{const l={defaultValues:e._defaultValues};for(const d in t)Object.defineProperty(l,d,{get:()=>{const f=d;return e._proxyFormState[f]!==VALIDATION_MODE.all&&(e._proxyFormState[f]=!o||VALIDATION_MODE.all),t[f]}});return l};const useIsomorphicLayoutEffect$1=typeof window<"u"?React.useLayoutEffect:React.useEffect;var isString=t=>typeof t=="string",generateWatchOutput=(t,e,n,o,l)=>isString(t)?(o&&e.watch.add(t),get(n,t,l)):Array.isArray(t)?t.map(d=>(o&&e.watch.add(d),get(n,d))):(o&&(e.watchAll=!0),n),isPrimitive=t=>isNullOrUndefined(t)||!isObjectType(t);function deepEqual$1(t,e,n=new WeakSet){if(isPrimitive(t)||isPrimitive(e))return t===e;if(isDateObject(t)&&isDateObject(e))return t.getTime()===e.getTime();const o=Object.keys(t),l=Object.keys(e);if(o.length!==l.length)return!1;if(n.has(t)||n.has(e))return!0;n.add(t),n.add(e);for(const d of o){const f=t[d];if(!l.includes(d))return!1;if(d!=="ref"){const g=e[d];if(isDateObject(f)&&isDateObject(g)||isObject(f)&&isObject(g)||Array.isArray(f)&&Array.isArray(g)?!deepEqual$1(f,g,n):f!==g)return!1}}return!0}var appendErrors=(t,e,n,o,l)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[o]:l||!0}}:{},convertToArrayPayload=t=>Array.isArray(t)?t:[t],createSubject=()=>{let t=[];return{get observers(){return t},next:l=>{for(const d of t)d.next&&d.next(l)},subscribe:l=>(t.push(l),{unsubscribe:()=>{t=t.filter(d=>d!==l)}}),unsubscribe:()=>{t=[]}}};function extractFormValues(t,e){const n={};for(const o in t)if(t.hasOwnProperty(o)){const l=t[o],d=e[o];if(l&&isObject(l)&&d){const f=extractFormValues(l,d);isObject(f)&&(n[o]=f)}else t[o]&&(n[o]=d)}return n}var isEmptyObject$1=t=>isObject(t)&&!Object.keys(t).length,isFileInput=t=>t.type==="file",isFunction$3=t=>typeof t=="function",isHTMLElement=t=>{if(!isWeb)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},isMultipleSelect=t=>t.type==="select-multiple",isRadioInput=t=>t.type==="radio",isRadioOrCheckbox=t=>isRadioInput(t)||isCheckBoxInput(t),live=t=>isHTMLElement(t)&&t.isConnected;function baseGet(t,e){const n=e.slice(0,-1).length;let o=0;for(;o<n;)t=isUndefined(t)?o++:t[e[o++]];return t}function isEmptyArray(t){for(const e in t)if(t.hasOwnProperty(e)&&!isUndefined(t[e]))return!1;return!0}function unset(t,e){const n=Array.isArray(e)?e:isKey(e)?[e]:stringToPath(e),o=n.length===1?t:baseGet(t,n),l=n.length-1,d=n[l];return o&&delete o[d],l!==0&&(isObject(o)&&isEmptyObject$1(o)||Array.isArray(o)&&isEmptyArray(o))&&unset(t,n.slice(0,-1)),t}var objectHasFunction=t=>{for(const e in t)if(isFunction$3(t[e]))return!0;return!1};function isTraversable(t){return Array.isArray(t)||isObject(t)&&!objectHasFunction(t)}function markFieldsDirty(t,e={}){for(const n in t)isTraversable(t[n])?(e[n]=Array.isArray(t[n])?[]:{},markFieldsDirty(t[n],e[n])):isNullOrUndefined(t[n])||(e[n]=!0);return e}function getDirtyFields(t,e,n){n||(n=markFieldsDirty(e));for(const o in t)isTraversable(t[o])?isUndefined(e)||isPrimitive(n[o])?n[o]=markFieldsDirty(t[o],Array.isArray(t[o])?[]:{}):getDirtyFields(t[o],isNullOrUndefined(e)?{}:e[o],n[o]):n[o]=!deepEqual$1(t[o],e[o]);return n}const defaultResult={value:!1,isValid:!1},validResult={value:!0,isValid:!0};var getCheckboxValue=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!isUndefined(t[0].attributes.value)?isUndefined(t[0].value)||t[0].value===""?validResult:{value:t[0].value,isValid:!0}:validResult:defaultResult}return defaultResult},getFieldValueAs=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:o})=>isUndefined(t)?t:e?t===""?NaN:t&&+t:n&&isString(t)?new Date(t):o?o(t):t;const defaultReturn={isValid:!1,value:null};var getRadioValue=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,defaultReturn):defaultReturn;function getFieldValue(t){const e=t.ref;return isFileInput(e)?e.files:isRadioInput(e)?getRadioValue(t.refs).value:isMultipleSelect(e)?[...e.selectedOptions].map(({value:n})=>n):isCheckBoxInput(e)?getCheckboxValue(t.refs).value:getFieldValueAs(isUndefined(e.value)?t.ref.value:e.value,t)}var getResolverOptions=(t,e,n,o)=>{const l={};for(const d of t){const f=get(e,d);f&&set(l,d,f._f)}return{criteriaMode:n,names:[...t],fields:l,shouldUseNativeValidation:o}},isRegex=t=>t instanceof RegExp,getRuleValue=t=>isUndefined(t)?t:isRegex(t)?t.source:isObject(t)?isRegex(t.value)?t.value.source:t.value:t,getValidationModes=t=>({isOnSubmit:!t||t===VALIDATION_MODE.onSubmit,isOnBlur:t===VALIDATION_MODE.onBlur,isOnChange:t===VALIDATION_MODE.onChange,isOnAll:t===VALIDATION_MODE.all,isOnTouch:t===VALIDATION_MODE.onTouched});const ASYNC_FUNCTION="AsyncFunction";var hasPromiseValidation=t=>!!t&&!!t.validate&&!!(isFunction$3(t.validate)&&t.validate.constructor.name===ASYNC_FUNCTION||isObject(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===ASYNC_FUNCTION)),hasValidation=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),isWatched=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(o=>t.startsWith(o)&&/^\.\w+/.test(t.slice(o.length))));const iterateFieldsByAction=(t,e,n,o)=>{for(const l of n||Object.keys(t)){const d=get(t,l);if(d){const{_f:f,...g}=d;if(f){if(f.refs&&f.refs[0]&&e(f.refs[0],l)&&!o)return!0;if(f.ref&&e(f.ref,f.name)&&!o)return!0;if(iterateFieldsByAction(g,e))break}else if(isObject(g)&&iterateFieldsByAction(g,e))break}}};function schemaErrorLookup(t,e,n){const o=get(t,n);if(o||isKey(n))return{error:o,name:n};const l=n.split(".");for(;l.length;){const d=l.join("."),f=get(e,d),g=get(t,d);if(f&&!Array.isArray(f)&&n!==d)return{name:n};if(g&&g.type)return{name:d,error:g};if(g&&g.root&&g.root.type)return{name:`${d}.root`,error:g.root};l.pop()}return{name:n}}var shouldRenderFormState=(t,e,n,o)=>{n(t);const{name:l,...d}=t;return isEmptyObject$1(d)||Object.keys(d).length>=Object.keys(e).length||Object.keys(d).find(f=>e[f]===(!o||VALIDATION_MODE.all))},shouldSubscribeByName=(t,e,n)=>!t||!e||t===e||convertToArrayPayload(t).some(o=>o&&(n?o===e:o.startsWith(e)||e.startsWith(o))),skipValidation=(t,e,n,o,l)=>l.isOnAll?!1:!n&&l.isOnTouch?!(e||t):(n?o.isOnBlur:l.isOnBlur)?!t:(n?o.isOnChange:l.isOnChange)?t:!0,unsetEmptyArray=(t,e)=>!compact(get(t,e)).length&&unset(t,e),updateFieldArrayRootError=(t,e,n)=>{const o=convertToArrayPayload(get(t,n));return set(o,"root",e[n]),set(t,n,o),t};function getValidateError(t,e,n="validate"){if(isString(t)||Array.isArray(t)&&t.every(isString)||isBoolean(t)&&!t)return{type:n,message:isString(t)?t:"",ref:e}}var getValueAndMessage=t=>isObject(t)&&!isRegex(t)?t:{value:t,message:""},validateField=async(t,e,n,o,l,d)=>{const{ref:f,refs:g,required:b,maxLength:S,minLength:_,min:R,max:C,pattern:E,validate:A,name:I,valueAsNumber:M,mount:V}=t._f,O=get(n,I);if(!V||e.has(I))return{};const z=g?g[0]:f,Q=se=>{l&&z.reportValidity&&(z.setCustomValidity(isBoolean(se)?"":se||""),z.reportValidity())},j={},F=isRadioInput(f),te=isCheckBoxInput(f),ne=F||te,ae=(M||isFileInput(f))&&isUndefined(f.value)&&isUndefined(O)||isHTMLElement(f)&&f.value===""||O===""||Array.isArray(O)&&!O.length,je=appendErrors.bind(null,I,o,j),Ae=(se,Ne,ge,Ve=INPUT_VALIDATION_RULES.maxLength,Le=INPUT_VALIDATION_RULES.minLength)=>{const qe=se?Ne:ge;j[I]={type:se?Ve:Le,message:qe,ref:f,...je(se?Ve:Le,qe)}};if(d?!Array.isArray(O)||!O.length:b&&(!ne&&(ae||isNullOrUndefined(O))||isBoolean(O)&&!O||te&&!getCheckboxValue(g).isValid||F&&!getRadioValue(g).isValid)){const{value:se,message:Ne}=isString(b)?{value:!!b,message:b}:getValueAndMessage(b);if(se&&(j[I]={type:INPUT_VALIDATION_RULES.required,message:Ne,ref:z,...je(INPUT_VALIDATION_RULES.required,Ne)},!o))return Q(Ne),j}if(!ae&&(!isNullOrUndefined(R)||!isNullOrUndefined(C))){let se,Ne;const ge=getValueAndMessage(C),Ve=getValueAndMessage(R);if(!isNullOrUndefined(O)&&!isNaN(O)){const Le=f.valueAsNumber||O&&+O;isNullOrUndefined(ge.value)||(se=Le>ge.value),isNullOrUndefined(Ve.value)||(Ne=Le<Ve.value)}else{const Le=f.valueAsDate||new Date(O),qe=He=>new Date(new Date().toDateString()+" "+He),Be=f.type=="time",$e=f.type=="week";isString(ge.value)&&O&&(se=Be?qe(O)>qe(ge.value):$e?O>ge.value:Le>new Date(ge.value)),isString(Ve.value)&&O&&(Ne=Be?qe(O)<qe(Ve.value):$e?O<Ve.value:Le<new Date(Ve.value))}if((se||Ne)&&(Ae(!!se,ge.message,Ve.message,INPUT_VALIDATION_RULES.max,INPUT_VALIDATION_RULES.min),!o))return Q(j[I].message),j}if((S||_)&&!ae&&(isString(O)||d&&Array.isArray(O))){const se=getValueAndMessage(S),Ne=getValueAndMessage(_),ge=!isNullOrUndefined(se.value)&&O.length>+se.value,Ve=!isNullOrUndefined(Ne.value)&&O.length<+Ne.value;if((ge||Ve)&&(Ae(ge,se.message,Ne.message),!o))return Q(j[I].message),j}if(E&&!ae&&isString(O)){const{value:se,message:Ne}=getValueAndMessage(E);if(isRegex(se)&&!O.match(se)&&(j[I]={type:INPUT_VALIDATION_RULES.pattern,message:Ne,ref:f,...je(INPUT_VALIDATION_RULES.pattern,Ne)},!o))return Q(Ne),j}if(A){if(isFunction$3(A)){const se=await A(O,n),Ne=getValidateError(se,z);if(Ne&&(j[I]={...Ne,...je(INPUT_VALIDATION_RULES.validate,Ne.message)},!o))return Q(Ne.message),j}else if(isObject(A)){let se={};for(const Ne in A){if(!isEmptyObject$1(se)&&!o)break;const ge=getValidateError(await A[Ne](O,n),z,Ne);ge&&(se={...ge,...je(Ne,ge.message)},Q(ge.message),o&&(j[I]=se))}if(!isEmptyObject$1(se)&&(j[I]={ref:z,...se},!o))return j}}return Q(!0),j};const defaultOptions$1={mode:VALIDATION_MODE.onSubmit,reValidateMode:VALIDATION_MODE.onChange,shouldFocusError:!0};function createFormControl(t={}){let e={...defaultOptions$1,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:isFunction$3(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},o={},l=isObject(e.defaultValues)||isObject(e.values)?cloneObject(e.defaultValues||e.values)||{}:{},d=e.shouldUnregister?{}:cloneObject(l),f={action:!1,mount:!1,watch:!1},g={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},b,S=0;const _={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let R={..._};const C={array:createSubject(),state:createSubject()},E=e.criteriaMode===VALIDATION_MODE.all,A=Je=>rt=>{clearTimeout(S),S=setTimeout(Je,rt)},I=async Je=>{if(!e.disabled&&(_.isValid||R.isValid||Je)){const rt=e.resolver?isEmptyObject$1((await te()).errors):await ae(o,!0);rt!==n.isValid&&C.state.next({isValid:rt})}},M=(Je,rt)=>{!e.disabled&&(_.isValidating||_.validatingFields||R.isValidating||R.validatingFields)&&((Je||Array.from(g.mount)).forEach(st=>{st&&(rt?set(n.validatingFields,st,rt):unset(n.validatingFields,st))}),C.state.next({validatingFields:n.validatingFields,isValidating:!isEmptyObject$1(n.validatingFields)}))},V=(Je,rt=[],st,pt,ft=!0,dt=!0)=>{if(pt&&st&&!e.disabled){if(f.action=!0,dt&&Array.isArray(get(o,Je))){const mt=st(get(o,Je),pt.argA,pt.argB);ft&&set(o,Je,mt)}if(dt&&Array.isArray(get(n.errors,Je))){const mt=st(get(n.errors,Je),pt.argA,pt.argB);ft&&set(n.errors,Je,mt),unsetEmptyArray(n.errors,Je)}if((_.touchedFields||R.touchedFields)&&dt&&Array.isArray(get(n.touchedFields,Je))){const mt=st(get(n.touchedFields,Je),pt.argA,pt.argB);ft&&set(n.touchedFields,Je,mt)}(_.dirtyFields||R.dirtyFields)&&(n.dirtyFields=getDirtyFields(l,d)),C.state.next({name:Je,isDirty:Ae(Je,rt),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else set(d,Je,rt)},O=(Je,rt)=>{set(n.errors,Je,rt),C.state.next({errors:n.errors})},z=Je=>{n.errors=Je,C.state.next({errors:n.errors,isValid:!1})},Q=(Je,rt,st,pt)=>{const ft=get(o,Je);if(ft){const dt=get(d,Je,isUndefined(st)?get(l,Je):st);isUndefined(dt)||pt&&pt.defaultChecked||rt?set(d,Je,rt?dt:getFieldValue(ft._f)):ge(Je,dt),f.mount&&I()}},j=(Je,rt,st,pt,ft)=>{let dt=!1,mt=!1;const Ut={name:Je};if(!e.disabled){if(!st||pt){(_.isDirty||R.isDirty)&&(mt=n.isDirty,n.isDirty=Ut.isDirty=Ae(),dt=mt!==Ut.isDirty);const Jt=deepEqual$1(get(l,Je),rt);mt=!!get(n.dirtyFields,Je),Jt?unset(n.dirtyFields,Je):set(n.dirtyFields,Je,!0),Ut.dirtyFields=n.dirtyFields,dt=dt||(_.dirtyFields||R.dirtyFields)&&mt!==!Jt}if(st){const Jt=get(n.touchedFields,Je);Jt||(set(n.touchedFields,Je,st),Ut.touchedFields=n.touchedFields,dt=dt||(_.touchedFields||R.touchedFields)&&Jt!==st)}dt&&ft&&C.state.next(Ut)}return dt?Ut:{}},F=(Je,rt,st,pt)=>{const ft=get(n.errors,Je),dt=(_.isValid||R.isValid)&&isBoolean(rt)&&n.isValid!==rt;if(e.delayError&&st?(b=A(()=>O(Je,st)),b(e.delayError)):(clearTimeout(S),b=null,st?set(n.errors,Je,st):unset(n.errors,Je)),(st?!deepEqual$1(ft,st):ft)||!isEmptyObject$1(pt)||dt){const mt={...pt,...dt&&isBoolean(rt)?{isValid:rt}:{},errors:n.errors,name:Je};n={...n,...mt},C.state.next(mt)}},te=async Je=>{M(Je,!0);const rt=await e.resolver(d,e.context,getResolverOptions(Je||g.mount,o,e.criteriaMode,e.shouldUseNativeValidation));return M(Je),rt},ne=async Je=>{const{errors:rt}=await te(Je);if(Je)for(const st of Je){const pt=get(rt,st);pt?set(n.errors,st,pt):unset(n.errors,st)}else n.errors=rt;return rt},ae=async(Je,rt,st={valid:!0})=>{for(const pt in Je){const ft=Je[pt];if(ft){const{_f:dt,...mt}=ft;if(dt){const Ut=g.array.has(dt.name),Jt=ft._f&&hasPromiseValidation(ft._f);Jt&&_.validatingFields&&M([dt.name],!0);const pn=await validateField(ft,g.disabled,d,E,e.shouldUseNativeValidation&&!rt,Ut);if(Jt&&_.validatingFields&&M([dt.name]),pn[dt.name]&&(st.valid=!1,rt))break;!rt&&(get(pn,dt.name)?Ut?updateFieldArrayRootError(n.errors,pn,dt.name):set(n.errors,dt.name,pn[dt.name]):unset(n.errors,dt.name))}!isEmptyObject$1(mt)&&await ae(mt,rt,st)}}return st.valid},je=()=>{for(const Je of g.unMount){const rt=get(o,Je);rt&&(rt._f.refs?rt._f.refs.every(st=>!live(st)):!live(rt._f.ref))&&Xe(Je)}g.unMount=new Set},Ae=(Je,rt)=>!e.disabled&&(Je&&rt&&set(d,Je,rt),!deepEqual$1(He(),l)),se=(Je,rt,st)=>generateWatchOutput(Je,g,{...f.mount?d:isUndefined(rt)?l:isString(Je)?{[Je]:rt}:rt},st,rt),Ne=Je=>compact(get(f.mount?d:l,Je,e.shouldUnregister?get(l,Je,[]):[])),ge=(Je,rt,st={})=>{const pt=get(o,Je);let ft=rt;if(pt){const dt=pt._f;dt&&(!dt.disabled&&set(d,Je,getFieldValueAs(rt,dt)),ft=isHTMLElement(dt.ref)&&isNullOrUndefined(rt)?"":rt,isMultipleSelect(dt.ref)?[...dt.ref.options].forEach(mt=>mt.selected=ft.includes(mt.value)):dt.refs?isCheckBoxInput(dt.ref)?dt.refs.forEach(mt=>{(!mt.defaultChecked||!mt.disabled)&&(Array.isArray(ft)?mt.checked=!!ft.find(Ut=>Ut===mt.value):mt.checked=ft===mt.value||!!ft)}):dt.refs.forEach(mt=>mt.checked=mt.value===ft):isFileInput(dt.ref)?dt.ref.value="":(dt.ref.value=ft,dt.ref.type||C.state.next({name:Je,values:cloneObject(d)})))}(st.shouldDirty||st.shouldTouch)&&j(Je,ft,st.shouldTouch,st.shouldDirty,!0),st.shouldValidate&&$e(Je)},Ve=(Je,rt,st)=>{for(const pt in rt){if(!rt.hasOwnProperty(pt))return;const ft=rt[pt],dt=Je+"."+pt,mt=get(o,dt);(g.array.has(Je)||isObject(ft)||mt&&!mt._f)&&!isDateObject(ft)?Ve(dt,ft,st):ge(dt,ft,st)}},Le=(Je,rt,st={})=>{const pt=get(o,Je),ft=g.array.has(Je),dt=cloneObject(rt);set(d,Je,dt),ft?(C.array.next({name:Je,values:cloneObject(d)}),(_.isDirty||_.dirtyFields||R.isDirty||R.dirtyFields)&&st.shouldDirty&&C.state.next({name:Je,dirtyFields:getDirtyFields(l,d),isDirty:Ae(Je,dt)})):pt&&!pt._f&&!isNullOrUndefined(dt)?Ve(Je,dt,st):ge(Je,dt,st),isWatched(Je,g)&&C.state.next({...n,name:Je}),C.state.next({name:f.mount?Je:void 0,values:cloneObject(d)})},qe=async Je=>{f.mount=!0;const rt=Je.target;let st=rt.name,pt=!0;const ft=get(o,st),dt=Jt=>{pt=Number.isNaN(Jt)||isDateObject(Jt)&&isNaN(Jt.getTime())||deepEqual$1(Jt,get(d,st,Jt))},mt=getValidationModes(e.mode),Ut=getValidationModes(e.reValidateMode);if(ft){let Jt,pn;const vn=rt.type?getFieldValue(ft._f):getEventValue(Je),qt=Je.type===EVENTS.BLUR||Je.type===EVENTS.FOCUS_OUT,En=!hasValidation(ft._f)&&!e.resolver&&!get(n.errors,st)&&!ft._f.deps||skipValidation(qt,get(n.touchedFields,st),n.isSubmitted,Ut,mt),Rn=isWatched(st,g,qt);set(d,st,vn),qt?(!rt||!rt.readOnly)&&(ft._f.onBlur&&ft._f.onBlur(Je),b&&b(0)):ft._f.onChange&&ft._f.onChange(Je);const Sn=j(st,vn,qt),Cn=!isEmptyObject$1(Sn)||Rn;if(!qt&&C.state.next({name:st,type:Je.type,values:cloneObject(d)}),En)return(_.isValid||R.isValid)&&(e.mode==="onBlur"?qt&&I():qt||I()),Cn&&C.state.next({name:st,...Rn?{}:Sn});if(!qt&&Rn&&C.state.next({...n}),e.resolver){const{errors:An}=await te([st]);if(dt(vn),pt){const jn=schemaErrorLookup(n.errors,o,st),Zt=schemaErrorLookup(An,o,jn.name||st);Jt=Zt.error,st=Zt.name,pn=isEmptyObject$1(An)}}else M([st],!0),Jt=(await validateField(ft,g.disabled,d,E,e.shouldUseNativeValidation))[st],M([st]),dt(vn),pt&&(Jt?pn=!1:(_.isValid||R.isValid)&&(pn=await ae(o,!0)));pt&&(ft._f.deps&&(!Array.isArray(ft._f.deps)||ft._f.deps.length>0)&&$e(ft._f.deps),F(st,pn,Jt,Sn))}},Be=(Je,rt)=>{if(get(n.errors,rt)&&Je.focus)return Je.focus(),1},$e=async(Je,rt={})=>{let st,pt;const ft=convertToArrayPayload(Je);if(e.resolver){const dt=await ne(isUndefined(Je)?Je:ft);st=isEmptyObject$1(dt),pt=Je?!ft.some(mt=>get(dt,mt)):st}else Je?(pt=(await Promise.all(ft.map(async dt=>{const mt=get(o,dt);return await ae(mt&&mt._f?{[dt]:mt}:mt)}))).every(Boolean),!(!pt&&!n.isValid)&&I()):pt=st=await ae(o);return C.state.next({...!isString(Je)||(_.isValid||R.isValid)&&st!==n.isValid?{}:{name:Je},...e.resolver||!Je?{isValid:st}:{},errors:n.errors}),rt.shouldFocus&&!pt&&iterateFieldsByAction(o,Be,Je?ft:g.mount),pt},He=(Je,rt)=>{let st={...f.mount?d:l};return rt&&(st=extractFormValues(rt.dirtyFields?n.dirtyFields:n.touchedFields,st)),isUndefined(Je)?st:isString(Je)?get(st,Je):Je.map(pt=>get(st,pt))},We=(Je,rt)=>({invalid:!!get((rt||n).errors,Je),isDirty:!!get((rt||n).dirtyFields,Je),error:get((rt||n).errors,Je),isValidating:!!get(n.validatingFields,Je),isTouched:!!get((rt||n).touchedFields,Je)}),Ue=Je=>{Je&&convertToArrayPayload(Je).forEach(rt=>unset(n.errors,rt)),C.state.next({errors:Je?n.errors:{}})},Ke=(Je,rt,st)=>{const pt=(get(o,Je,{_f:{}})._f||{}).ref,ft=get(n.errors,Je)||{},{ref:dt,message:mt,type:Ut,...Jt}=ft;set(n.errors,Je,{...Jt,...rt,ref:pt}),C.state.next({name:Je,errors:n.errors,isValid:!1}),st&&st.shouldFocus&&pt&&pt.focus&&pt.focus()},tt=(Je,rt)=>isFunction$3(Je)?C.state.subscribe({next:st=>"values"in st&&Je(se(void 0,rt),st)}):se(Je,rt,!0),Ge=Je=>C.state.subscribe({next:rt=>{shouldSubscribeByName(Je.name,rt.name,Je.exact)&&shouldRenderFormState(rt,Je.formState||_,Ft,Je.reRenderRoot)&&Je.callback({values:{...d},...n,...rt,defaultValues:l})}}).unsubscribe,Qe=Je=>(f.mount=!0,R={...R,...Je.formState},Ge({...Je,formState:R})),Xe=(Je,rt={})=>{for(const st of Je?convertToArrayPayload(Je):g.mount)g.mount.delete(st),g.array.delete(st),rt.keepValue||(unset(o,st),unset(d,st)),!rt.keepError&&unset(n.errors,st),!rt.keepDirty&&unset(n.dirtyFields,st),!rt.keepTouched&&unset(n.touchedFields,st),!rt.keepIsValidating&&unset(n.validatingFields,st),!e.shouldUnregister&&!rt.keepDefaultValue&&unset(l,st);C.state.next({values:cloneObject(d)}),C.state.next({...n,...rt.keepDirty?{isDirty:Ae()}:{}}),!rt.keepIsValid&&I()},ot=({disabled:Je,name:rt})=>{(isBoolean(Je)&&f.mount||Je||g.disabled.has(rt))&&(Je?g.disabled.add(rt):g.disabled.delete(rt))},Ze=(Je,rt={})=>{let st=get(o,Je);const pt=isBoolean(rt.disabled)||isBoolean(e.disabled);return set(o,Je,{...st||{},_f:{...st&&st._f?st._f:{ref:{name:Je}},name:Je,mount:!0,...rt}}),g.mount.add(Je),st?ot({disabled:isBoolean(rt.disabled)?rt.disabled:e.disabled,name:Je}):Q(Je,!0,rt.value),{...pt?{disabled:rt.disabled||e.disabled}:{},...e.progressive?{required:!!rt.required,min:getRuleValue(rt.min),max:getRuleValue(rt.max),minLength:getRuleValue(rt.minLength),maxLength:getRuleValue(rt.maxLength),pattern:getRuleValue(rt.pattern)}:{},name:Je,onChange:qe,onBlur:qe,ref:ft=>{if(ft){Ze(Je,rt),st=get(o,Je);const dt=isUndefined(ft.value)&&ft.querySelectorAll&&ft.querySelectorAll("input,select,textarea")[0]||ft,mt=isRadioOrCheckbox(dt),Ut=st._f.refs||[];if(mt?Ut.find(Jt=>Jt===dt):dt===st._f.ref)return;set(o,Je,{_f:{...st._f,...mt?{refs:[...Ut.filter(live),dt,...Array.isArray(get(l,Je))?[{}]:[]],ref:{type:dt.type,name:Je}}:{ref:dt}}}),Q(Je,!1,void 0,dt)}else st=get(o,Je,{}),st._f&&(st._f.mount=!1),(e.shouldUnregister||rt.shouldUnregister)&&!(isNameInFieldArray(g.array,Je)&&f.action)&&g.unMount.add(Je)}}},at=()=>e.shouldFocusError&&iterateFieldsByAction(o,Be,g.mount),lt=Je=>{isBoolean(Je)&&(C.state.next({disabled:Je}),iterateFieldsByAction(o,(rt,st)=>{const pt=get(o,st);pt&&(rt.disabled=pt._f.disabled||Je,Array.isArray(pt._f.refs)&&pt._f.refs.forEach(ft=>{ft.disabled=pt._f.disabled||Je}))},0,!1))},ze=(Je,rt)=>async st=>{let pt;st&&(st.preventDefault&&st.preventDefault(),st.persist&&st.persist());let ft=cloneObject(d);if(C.state.next({isSubmitting:!0}),e.resolver){const{errors:dt,values:mt}=await te();n.errors=dt,ft=cloneObject(mt)}else await ae(o);if(g.disabled.size)for(const dt of g.disabled)unset(ft,dt);if(unset(n.errors,"root"),isEmptyObject$1(n.errors)){C.state.next({errors:{}});try{await Je(ft,st)}catch(dt){pt=dt}}else rt&&await rt({...n.errors},st),at(),setTimeout(at);if(C.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:isEmptyObject$1(n.errors)&&!pt,submitCount:n.submitCount+1,errors:n.errors}),pt)throw pt},yt=(Je,rt={})=>{get(o,Je)&&(isUndefined(rt.defaultValue)?Le(Je,cloneObject(get(l,Je))):(Le(Je,rt.defaultValue),set(l,Je,cloneObject(rt.defaultValue))),rt.keepTouched||unset(n.touchedFields,Je),rt.keepDirty||(unset(n.dirtyFields,Je),n.isDirty=rt.defaultValue?Ae(Je,cloneObject(get(l,Je))):Ae()),rt.keepError||(unset(n.errors,Je),_.isValid&&I()),C.state.next({...n}))},et=(Je,rt={})=>{const st=Je?cloneObject(Je):l,pt=cloneObject(st),ft=isEmptyObject$1(Je),dt=ft?l:pt;if(rt.keepDefaultValues||(l=st),!rt.keepValues){if(rt.keepDirtyValues){const mt=new Set([...g.mount,...Object.keys(getDirtyFields(l,d))]);for(const Ut of Array.from(mt))get(n.dirtyFields,Ut)?set(dt,Ut,get(d,Ut)):Le(Ut,get(dt,Ut))}else{if(isWeb&&isUndefined(Je))for(const mt of g.mount){const Ut=get(o,mt);if(Ut&&Ut._f){const Jt=Array.isArray(Ut._f.refs)?Ut._f.refs[0]:Ut._f.ref;if(isHTMLElement(Jt)){const pn=Jt.closest("form");if(pn){pn.reset();break}}}}if(rt.keepFieldsRef)for(const mt of g.mount)Le(mt,get(dt,mt));else o={}}d=e.shouldUnregister?rt.keepDefaultValues?cloneObject(l):{}:cloneObject(dt),C.array.next({values:{...dt}}),C.state.next({values:{...dt}})}g={mount:rt.keepDirtyValues?g.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},f.mount=!_.isValid||!!rt.keepIsValid||!!rt.keepDirtyValues,f.watch=!!e.shouldUnregister,C.state.next({submitCount:rt.keepSubmitCount?n.submitCount:0,isDirty:ft?!1:rt.keepDirty?n.isDirty:!!(rt.keepDefaultValues&&!deepEqual$1(Je,l)),isSubmitted:rt.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ft?{}:rt.keepDirtyValues?rt.keepDefaultValues&&d?getDirtyFields(l,d):n.dirtyFields:rt.keepDefaultValues&&Je?getDirtyFields(l,Je):rt.keepDirty?n.dirtyFields:{},touchedFields:rt.keepTouched?n.touchedFields:{},errors:rt.keepErrors?n.errors:{},isSubmitSuccessful:rt.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:l})},Rt=(Je,rt)=>et(isFunction$3(Je)?Je(d):Je,rt),$t=(Je,rt={})=>{const st=get(o,Je),pt=st&&st._f;if(pt){const ft=pt.refs?pt.refs[0]:pt.ref;ft.focus&&(ft.focus(),rt.shouldSelect&&isFunction$3(ft.select)&&ft.select())}},Ft=Je=>{n={...n,...Je}},Vt={control:{register:Ze,unregister:Xe,getFieldState:We,handleSubmit:ze,setError:Ke,_subscribe:Ge,_runSchema:te,_focusError:at,_getWatch:se,_getDirty:Ae,_setValid:I,_setFieldArray:V,_setDisabledField:ot,_setErrors:z,_getFieldArray:Ne,_reset:et,_resetDefaultValues:()=>isFunction$3(e.defaultValues)&&e.defaultValues().then(Je=>{Rt(Je,e.resetOptions),C.state.next({isLoading:!1})}),_removeUnmounted:je,_disableForm:lt,_subjects:C,_proxyFormState:_,get _fields(){return o},get _formValues(){return d},get _state(){return f},set _state(Je){f=Je},get _defaultValues(){return l},get _names(){return g},set _names(Je){g=Je},get _formState(){return n},get _options(){return e},set _options(Je){e={...e,...Je}}},subscribe:Qe,trigger:$e,register:Ze,handleSubmit:ze,watch:tt,setValue:Le,getValues:He,reset:Rt,resetField:yt,clearErrors:Ue,unregister:Xe,setError:Ke,setFocus:$t,getFieldState:We};return{...Vt,formControl:Vt}}function useForm(t={}){const e=React.useRef(void 0),n=React.useRef(void 0),[o,l]=React.useState({isDirty:!1,isValidating:!1,isLoading:isFunction$3(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:isFunction$3(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:o},t.defaultValues&&!isFunction$3(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:f,...g}=createFormControl(t);e.current={...g,formState:o}}const d=e.current.control;return d._options=t,useIsomorphicLayoutEffect$1(()=>{const f=d._subscribe({formState:d._proxyFormState,callback:()=>l({...d._formState}),reRenderRoot:!0});return l(g=>({...g,isReady:!0})),d._formState.isReady=!0,f},[d]),React.useEffect(()=>d._disableForm(t.disabled),[d,t.disabled]),React.useEffect(()=>{t.mode&&(d._options.mode=t.mode),t.reValidateMode&&(d._options.reValidateMode=t.reValidateMode)},[d,t.mode,t.reValidateMode]),React.useEffect(()=>{t.errors&&(d._setErrors(t.errors),d._focusError())},[d,t.errors]),React.useEffect(()=>{t.shouldUnregister&&d._subjects.state.next({values:d._getWatch()})},[d,t.shouldUnregister]),React.useEffect(()=>{if(d._proxyFormState.isDirty){const f=d._getDirty();f!==o.isDirty&&d._subjects.state.next({isDirty:f})}},[d,o.isDirty]),React.useEffect(()=>{t.values&&!deepEqual$1(t.values,n.current)?(d._reset(t.values,{keepFieldsRef:!0,...d._options.resetOptions}),n.current=t.values,l(f=>({...f}))):d._resetDefaultValues()},[d,t.values]),React.useEffect(()=>{d._state.mount||(d._setValid(),d._state.mount=!0),d._state.watch&&(d._state.watch=!1,d._subjects.state.next({...d._formState})),d._removeUnmounted()}),e.current.formState=getProxyFormState(o,d),e.current}var defaultErrorHandler=function(t){process.env.NODE_ENV!=="production"&&console.error(t)},defaultWarnHandler=function(t){process.env.NODE_ENV!=="production"&&console.warn(t)},DEFAULT_INTL_CONFIG={formats:{},messages:{},timeZone:void 0,defaultLocale:"en",defaultFormats:{},fallbackOnEmptyString:!0,onError:defaultErrorHandler,onWarn:defaultWarnHandler};function invariant(t,e,n){if(n===void 0&&(n=Error),!t)throw new n(e)}function invariantIntlContext(t){invariant(t,"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.")}__assign$1(__assign$1({},DEFAULT_INTL_CONFIG),{textComponent:React__namespace.Fragment});var reactIs={exports:{}},reactIs_production_min={};/** @license React v16.13.1
|
|
1148
1148
|
* react-is.production.min.js
|
|
1149
1149
|
*
|
|
1150
1150
|
* Copyright (c) Facebook, Inc. and its affiliates.
|