/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{ref as e,computed as o,onMounted as r,onBeforeUnmount as l,openBlock as n,createElementBlock as t,createElementVNode as u,normalizeClass as i,unref as a,withDirectives as s,withKeys as d,vModelText as v,createCommentVNode as c,vShow as p,nextTick as b}from"vue";import{linkIcon as f}from"./icons.js";import './LinkPopover.css';/* empty css                */import k from"../../../_virtual/_plugin-vue_export-helper.js";const m=["disabled"],L=["innerHTML"],g={class:"popover-menu absolute right-0 top-full z-[1000] mt-1"},h={class:"flex gap-2"},_=/* @__PURE__ */k({__name:"LinkPopover",props:{editor:{type:Object,required:!0},disabled:{type:Boolean,default:!1}},setup(k){const _=k,y=e(null),x=e(null),j=e(!1),R=e(""),C=o(()=>_.editor?.isActive("link")),E=()=>{if(j.value)j.value=!1;else{const e=_.editor?.getAttributes("link");R.value=e?.href||"",j.value=!0,b(()=>{x.value?.focus()})}},A=()=>{R.value?_.editor?.chain().focus().setLink({href:R.value}).run():_.editor?.chain().focus().unsetLink().run(),j.value=!1},H=()=>{_.editor?.chain().focus().unsetLink().run(),j.value=!1},K=e=>{y.value&&!y.value.contains(e.target)&&(j.value=!1)};return r(()=>{document.addEventListener("click",K)}),l(()=>{document.removeEventListener("click",K)}),(e,o)=>(n(),t("div",{ref_key:"popoverRef",ref:y,class:"relative"},[u("button",{class:i([{"is-active":C.value,"is-disabled":k.disabled}]),disabled:k.disabled,title:"Link",onClick:E},[u("span",{innerHTML:a(f)},null,8,L)],10,m),s(u("div",g,[u("div",h,[s(u("input",{ref_key:"inputRef",ref:x,"onUpdate:modelValue":o[0]||(o[0]=e=>R.value=e),type:"text",class:"flex-1 border border-gray-300 rounded p-1.5 outline-none focus:border-blue-500",placeholder:"Enter URL",onKeydown:d(A,["enter"])},null,544),[[v,R.value]]),u("button",{class:"cursor-pointer rounded border-none bg-blue-500 p-1.5 px-3 hover:bg-blue-400",onClick:A}," OK "),C.value?(n(),t("button",{key:0,class:"cursor-pointer rounded border-none bg-red-500 p-1.5 px-3 hover:bg-red-400",onClick:H}," Remove ")):c("",!0)])],512),[[p,j.value]])],512))}},[["__scopeId","data-v-37d2f9ee"]]);export{_ as default};