import{d as e,m as t,s as n,t as r,y as i}from"./hooks.module-5xe-uC6c.js";import{E as a,Y as o,ct as s,q as c}from"./content_renderer-CoENEE63.js";import{t as l}from"./jsxRuntime.module--xb8gfv5.js";import{E as u,P as d,S as f,U as p,b as m,p as h,w as g}from"./hooks-CSTgmcXO.js";import{t as _}from"./Icon-rHGhZ_GT.js";e();function v({className:e,containerClassName:i,notePath:a,showNotePath:s,showNoteIcon:c,style:u,noPreview:d,noTnLink:f,highlightedTokens:m,title:g,viewScope:_,noContextMenu:v,onContextMenu:y}){let b=Array.isArray(a)?a.join(`/`):a,x=b.split(`/`).at(-1),S=r(null),[C,w]=n(),T=h(m),[E,D]=n();t(()=>{o.createLink(b,{title:g,showNotePath:s,showNoteIcon:c,viewScope:_}).then(w)},[b,s,g,_,E]),t(()=>{let e=C?.[0];if(!(!e||!y))return e.addEventListener(`contextmenu`,y),()=>e.removeEventListener(`contextmenu`,y)},[C,y]),t(()=>{!S.current||!C||(S.current.replaceChildren(C[0]),T(S.current))},[C,m]),p(`entitiesReloaded`,({loadResults:e})=>{if(!g&&x){let t=e.getEntityRow(`notes`,x);t&&D(t.title)}}),u&&C?.css(u);let O=C?.find(`a`);return d&&O?.addClass(`no-tooltip-preview`),f||O?.addClass(`tn-link`),v&&O?.attr(`data-no-context-menu`,`true`),e&&O?.addClass(e),l(`span`,{className:i,ref:S})}function y({notePath:e,viewScope:t,noContextMenu:n,showNoteIcon:r,noPreview:o,...p}){let{noteId:h,parentNoteId:v}=s.getNoteIdAndParentIdFromUrl(e),y=m(h),b=d(h,v),x=g(r?y:null),S=f(y),[C]=u(y,`archived`);return l(`a`,{className:a(`tn-link`,S,{"no-tooltip-preview":o,archived:C}),href:c({notePath:e,viewScope:t}),"data-no-context-menu":n,...p,children:[x&&l(i,{children:[l(_,{icon:x}),`\xA0`]}),b]})}export{v as n,y as t};