"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1992],{61992:(e,o,t)=>{t.r(o),t.d(o,{LinkToolbar:()=>L});var n=t(57505),l=t(16697),a=t(17603),r=t(3066),i=t.n(r),d=t(49355),s=t(78473),c=t(96633),f=t(50245),u=t(52066),h=t(47429),p=t(77658),b=t(77445),g=t(8904),k=t(42753),w=t(72764),N=t(20360);let x=({opensLinkInNewTab:e,noFollow:o,hrefInput:t,onToggleTarget:l,onToggleNoFollow:a,onChangeLink:r,onSetLink:i,onDeleteLink:d,onDocSelected:s,onHidePopover:c})=>{let f=(0,h.d)(),u=(0,w.bz)(f.spaceId),p=f.editorId.startsWith(k.Hr);return(0,n.jsx)(N.X,{linkHref:t,opensLinkInNewTab:e,noFollow:o,currentDoc:{docId:"",docAnchorId:"",label:""},onDeleteLink:d,onDocAnchorIdChange:()=>{},onDocDataClear:()=>{},onHidePopover:c,onLinkSelected:s,onLinkHrefChange:r,onSetLink:i,onToggleLinkTarget:l,onToggleNoFollow:a,isDisplayedOnPublicPortal:u,selectedTab:k.mN,isQnaEditor:p})};var v=t(10615);let I=(0,f.forwardRef)(({className:e,children:o,...t},a)=>(0,n.jsx)("div",{...t,ref:a,className:(0,l.cn)("flex flex-col absolute select-none","shadow-2xl border rounded-2xl","border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",e,(0,v.AH)({top:-1e4,left:-1e4,zIndex:1e4})),children:o})),L=()=>{let[e,o]=(0,f.useState)(),[t,r]=(0,f.useState)(!0),[k,w]=(0,f.useState)(!1),[N,v]=(0,f.useState)(""),L=(0,f.useRef)(null),P=(0,s.er)(),{spaceId:T}=(0,h.d)(),D=(0,c.cQ)(),{selection:S,isOpen:y}=(e=>{let[o,t]=(0,f.useState)(),n=(0,s.er)(),l=(0,b.md)(p.GQ,{store:(0,p.$H)()})===n.id;return(0,f.useEffect)(()=>{let o=e.current;if(o&&n.selection){if(!n.selection||n.api.isCollapsed()||""===n.api.string(n.selection))return void(0,g.BP)(n.id,o);n.selection&&t(n.selection)}}),{isOpen:l,selection:o}})(L);return(0,f.useEffect)(()=>{y||v("")},[y]),(0,n.jsx)(I,{ref:L,className:(0,l.cn)(g.el,y?"flex":"hidden"),children:y&&(0,n.jsx)(x,{opensLinkInNewTab:t,noFollow:!k,hrefInput:N,onToggleTarget:e=>{r(e)},onToggleNoFollow:e=>{w(!e)},onChangeLink:e=>{D||v(e)},onSetLink:()=>{let n,l,s;e?(()=>{let o=P.api.findPath(e);if(!o)return;let n={href:i()(N)?N:"",newTab:t,hasDisabledNofollow:k};P.tf.setNodes({data:n},{at:o})})():(n={href:(0,g.he)(N)?N:"",newTab:t,hasDisabledNofollow:k},l=P.api.string(S),o(s={id:(0,d.Ak)(),type:a.Pf.link,data:n,children:[{text:l}]}),P.tf.wrapNodes(s,{split:!0,at:S})),v(""),o(void 0),r(!0),(0,g.BP)(P.id),!S||P.api.start(S?.focus.path,{next:!0})&&(0,u.F)(P)},onDeleteLink:()=>(0,g.BP)(P.id),onDocSelected:e=>{let o={id:(0,d.Ak)(),type:a.Pf.mentionDoc,data:{label:e.label,spaceId:T,docId:e.value,version:"v2",docAnchorId:"",loadingMethod:"dynamic",overridedLabel:""},children:[{text:""}]};P.tf.wrapNodes(o,{split:!0,at:S}),(0,g.BP)(P.id)},onHidePopover:()=>{v(""),o(void 0),r(!0),(0,g.BP)(P.id)}})})}}}]);