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