1import{d as ge,r as d,c as h,X as xe,w as we,o as ye,a as be,D as ke,K as Ee,B as s,z as m,k as M,G as l,u as p,L as q,S as X,F as Ce,W as De,E as G,H as J,V as Z,U as Pe,C as c,A as Se,n as ee}from"./vendor-vue-DxUQLZnu.js";import{b as Ie}from"./vendor-ui-C7CjkN8p.js";import{a as Me,u as Be,b as $e,a1 as Re,_ as B,n as te,B as Te}from"./index-DhA09J0K.js";import{_ as Ue}from"./AppLayout.vue_vue_type_script_setup_true_lang-CN9199pM.js";import{d as Ae,p as Ye}from"./vendor-misc-CWmGef59.js";import{u as Le}from"./vendor-i18n-CyaH1tU0.js";import"./AppHeader.vue_vue_type_style_index_0_scoped_59fb3e77_lang-CYBdylsh.js";import"./LocaleSwitcher-BVzrKb9Q.js";/* empty css */const ze="user_id",He="token",je="theme",Ne="lang",Oe="ui_mode",Ve="embedded",We="src_host",Fe="src_url";function Ke(y,a,$,A="light",x){if(!y)return y;try{const r=new URL(y);return a&&r.searchParams.set(ze,String(a)),$&&r.searchParams.set(He,$),r.searchParams.set(je,A),x&&r.searchParams.set(Ne,x),r.searchParams.set(Oe,Ve),typeof window<"u"&&(r.searchParams.set(We,window.location.origin),r.searchParams.set(Fe,window.location.href)),r.toString()}catch{return y}}function ne(){return typeof document>"u"?"light":document.documentElement.classList.contains("dark")?"dark":"light"}const Qe={class:"custom-page-layout"},qe={class:"card flex-1 min-h-0 overflow-hidden"},Xe={key:0,class:"flex h-full items-center justify-center py-12"},Ge={key:1,class:"flex h-full items-center justify-center p-10 text-center"},Je={class:"max-w-md"},Ze={class:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-gray-100 dark:bg-dark-700"},et={class:"text-lg font-semibold text-gray-900 dark:text-white"},tt={class:"mt-2 text-sm text-gray-500 dark:text-dark-400"},nt={key:2,class:"flex h-full overflow-hidden"},ot={class:"toc-sidebar"},st={class:"toc-header"},at={class:"toc-title"},rt={class:"toc-nav"},it=["href","onClick"],lt={class:"ml-1 text-xs"},ct=["innerHTML"],ut={key:3,class:"flex h-full items-center justify-center p-10 text-center"},dt={class:"max-w-md"},mt={class:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-gray-100 dark:bg-dark-700"},ft={class:"text-lg font-semibold text-gray-900 dark:text-white"},pt={class:"mt-2 text-sm text-gray-500 dark:text-dark-400"},ht=["href"],vt={key:4,class:"flex h-full items-center justify-center p-10 text-center"},_t={class:"max-w-md"},gt={class:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-gray-100 dark:bg-dark-700"},xt={class:"text-lg font-semibold text-gray-900 dark:text-white"},wt={class:"mt-2 text-sm text-gray-500 dark:text-dark-400"},yt=["href"],bt=["src"],kt=ge({__name:"CustomPageView",setup(y){const{t:a,locale:$}=Le(),A=xe(),x=Me(),r=Be(),oe=$e(),b=d(!1),Y=d("light"),k=d(""),R=d(null),v=d([]),E=d(typeof window<"u"?window.innerWidth>768:!0),T=d("");let C=null;const L=d(null),_=d(null),g=d(null);let u=null,D=!1;function N(e,t){const n=L.value,o=_.value;!n||!o||(g.value={x:Math.max(0,Math.min(e,n.clientWidth-o.offsetWidth)),y:Math.max(0,Math.min(t,n.clientHeight-o.offsetHeight))})}function se(e){if(e.button!==0||!e.isPrimary||!_.value)return;const t=_.value;D=!1,u={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,x:t.offsetLeft,y:t.offsetTop},t.setPointerCapture(e.pointerId)}function ae(e){if(!u||e.pointerId!==u.pointerId)return;const t=e.clientX-u.startX,n=e.clientY-u.startY;!D&&Math.hypot(t,n)<4||(D=!0,N(u.x+t,u.y+n),e.preventDefault())}function z(e){var t;!u||e.pointerId!==u.pointerId||(u=null,(t=_.value)!=null&&t.hasPointerCapture(e.pointerId)&&_.value.releasePointerCapture(e.pointerId))}function re(e){D&&e.detail!==0&&e.preventDefault(),D=!1}Ie([L,_],()=>{g.value&&N(g.value.x,g.value.y)});const ie=h(()=>A.params.id),f=h(()=>{var o;const e=ie.value,n=(((o=x.cachedPublicSettings)==null?void 0:o.custom_menu_items)??[]).find(i=>i.id===e)??null;return n||(r.isAdmin?oe.customMenuItems.find(i=>i.id===e)??null:null)}),O=h(()=>{var t;const e=f.value;return e?e.page_slug?e.page_slug:(t=e.url)!=null&&t.startsWith("md:")?e.url.slice(3):"":""}),U=h(()=>!!O.value),V=h(()=>{var e;return!U.value&&((e=f.value)==null?void 0:e.open_type)==="new_tab"}),W=h(()=>!V.value||!f.value?"":Re(f.value.url)),H=h(()=>{var e;return!f.value||U.value?"":Ke(f.value.url,(e=r.user)==null?void 0:e.id,r.token,Y.value,$.value)}),le=h(()=>
1{if(U.value)return!1;const e=H.value;return e.startsWith("http://")||e.startsWith("https://")});function ce(e,t){const n=e.toLowerCase().replace(/[^\wä¸-é¿¿]+/g,"-").replace(/^-+|-+$/g,"");return n?`${n}-${t}`:`heading-${t}`}function ue(e){const t=e.trim();if(!t||/^[a-z][a-z0-9+.-]*:/i.test(t)||t.startsWith("//")||t.startsWith("/"))return!1;const[n]=t.split(/([?#].*)/,2);return n.split("/").filter(o=>o&&o!==".").every(o=>o!==".."&&!o.includes("\\"))}function de(e,t){const n=t.trim(),[o,i=""]=n.split(/([?#].*)/,2),P=o.split("/").filter(w=>w&&w!==".").map(w=>encodeURIComponent(w)).join("/");return te(`/pages/${encodeURIComponent(e)}/images/${P}${i}`)}async function me(e){b.value=!0,v.value=[],T.value="";try{const t=await fetch(te(`/pages/${encodeURIComponent(e)}`),{headers:r.token?{Authorization:`Bearer ${r.token}`}:{}});if(!t.ok){k.value=`<p class="text-red-500">${a("common.pageNotFound")}</p>`;return}let n=await t.text();n=n.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(F,S,I)=>ue(I)?`})`:F);const o=Ae.parse(n),i=Ye.sanitize(o,{ADD_TAGS:["iframe"],ADD_ATTR:["allowfullscreen","frameborder","src"]}),P=[];let w=0;const ve=i.replace(/<(h[1-4])[^>]*>(.*?)<\/h[1-4]>/gi,(F,S,I)=>{const _e=parseInt(S[1]),K=I.replace(/<[^>]+>/g,"").trim(),Q=ce(K,w++);return P.push({id:Q,text:K,level:_e}),`<${S} id="${Q}">${I}</${S}>`});k.value=ve,v.value=P}catch{k.value='<p class="text-red-500">Failed to load page</p>'}finally{b.value=!1,await ee(),await ee(),he()}}function fe(e){const t=R.value;if(!t)return;const n=t.querySelector(`#${CSS.escape(e)}`);n&&(n.scrollIntoView({behavior:"smooth",block:"start"}),T.value=e,window.innerWidth<=640&&(E.value=!1))}let j=0;function pe(){j||(j=requestAnimationFrame(()=>{j=0;const e=R.value;if(!e||v.value.length===0)return;const t=e.getBoundingClientRect();let n="";for(const o of v.value){const i=e.querySelector(`#${CSS.escape(o.id)}`);i&&i.getBoundingClientRect().top-t.top<=100&&(n=o.id)}T.value=n}))}function he(){const e=R.value;e&&e.querySelectorAll("pre").forEach(t=>{if(t.querySelector(".copy-btn"))return;const n=document.createElement("button");n.className="copy-btn",n.textContent=a("customPage.copyCode"),n.addEventListener("click",async()=>{var i;const o=((i=t.querySelector("code"))==null?void 0:i.textContent)??t.textContent??"";try{await navigator.clipboard.writeText(o),n.textContent=a("customPage.copiedCode"),setTimeout(()=>{n.textContent=a("customPage.copyCode")},2e3)}catch{n.textContent=a("customPage.copyCodeFailed"),setTimeout(()=>{n.textContent=a("customPage.copyCode")},2e3)}}),t.style.position="relative",t.appendChild(n)})}return we(O,e=>{e?me(e):(k.value="",v.value=[])},{immediate:!0}),ye(async()=>{if(Y.value=ne(),typeof document<"u"&&(C=new MutationObserver(()=>{Y.value=ne()}),C.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})),!x.publicSettingsLoaded){b.value=!0;try{await x.fetchPublicSettings()}finally{b.value=!1}}}),be(()=>{C&&(C.disconnect(),C=null)}),(e,t)=>(c(),ke(Ue,null,{default:Ee(()=>{var n;return[s("div",Qe,[s("div",qe,[b.value?(c(),m("div",Xe,[...t[3]||(t[3]=[s("div",{class:"h-8 w-8 animate-spin rounded-full border-2 border-primary-500 border-t-transparent"},null,-1)])])):f.value?U.value?(c(),m("div",nt,[q(s("aside",ot,[s("div",st,[s("span",at,l(p(a)("customPage.tableOfContents")),1),s("button",{class:"toc-close-btn",onClick:t[0]||(t[0]=o=>E.value=!1)},[...t[4]||(t[4]=[s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[s("path",{d:"M15 18l-6-6 6-6"})],-1)])])]),s("nav",rt,[(c(!0),m(Ce,null,De(v.value,o=>(c(),m("a",{key:o.id,href:"#"+o.id,class:Se(["toc-item",[`toc-level-${o.level}`,{"toc-active":T.value===o.id}]]),onClick:Z(i=>fe(o.id),["prevent"])},l(o.text),11,it))),128))])],512),[[X,E.value]]),q(s("button",{class:"toc-toggle-btn",onClick:t[1]||(t[1]=o=>E.value=!0)},[t[5]||(t[5]=s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[s("path",{d:"M3 12h18M3 6h18M3 18h18"})],-1)),s("span",lt,l(p(a)("customPage.tableOfContents")),1)],512),[[X,!E.value&&v.value.length>0]]),s("div",{ref_key:"markdownContainer",ref:R,class:"markdown-page-content flex-1 h-full overflow-auto p-6 md:p-10",innerHTML:k.value,onScroll:pe},null,40,ct)])):V.value?(c(),m("div",ut,[s("div",dt,[s("div",mt,[M(B,{name:"externalLink",size:"lg",class:"text-gray-400"})]),s("h3",ft,l(f.value.label),1),s("p",pt,l(p(a)("customPage.newTabDesc")),1
1),W.value?(c(),m("a",{key:0,href:W.value,target:"_blank",rel:"noopener noreferrer",class:"btn btn-primary mt-5 inline-flex items-center"},[M(B,{name:"externalLink",size:"sm",class:"mr-1.5","stroke-width":2}),J(" "+l(p(a)("customPage.openInNewTab")),1)],8,ht)):G("",!0)])])):le.value?(c(),m("div",{key:5,ref_key:"embedShell",ref:L,class:"custom-embed-shell"},[(n=f.value)!=null&&n.hide_open_button?G("",!0):(c(),m("a",{key:0,ref_key:"openButton",ref:_,href:H.value,target:"_blank",rel:"noopener noreferrer",class:"btn btn-secondary btn-sm custom-open-fab",style:Pe(g.value?{left:`${g.value.x}px`,top:`${g.value.y}px`,right:"auto"}:void 0),onPointerdown:se,onPointermove:ae,onPointerup:z,onPointercancel:z,onLostpointercapture:z,onDragstart:t[2]||(t[2]=Z(()=>{},["prevent"])),onClick:re},[M(B,{name:"externalLink",size:"sm",class:"mr-1.5","stroke-width":2}),J(" "+l(p(a)("customPage.openInNewTab")),1)],44,yt)),s("iframe",{src:H.value,class:"custom-embed-frame",allowfullscreen:""},null,8,bt)],512)):(c(),m("div",vt,[s("div",_t,[s("div",gt,[M(B,{name:"link",size:"lg",class:"text-gray-400"})]),s("h3",xt,l(p(a)("customPage.notConfiguredTitle")),1),s("p",wt,l(p(a)("customPage.notConfiguredDesc")),1)])])):(c(),m("div",Ge,[s("div",Je,[s("div",Ze,[M(B,{name:"link",size:"lg",class:"text-gray-400"})]),s("h3",et,l(p(a)("customPage.notFoundTitle")),1),s("p",tt,l(p(a)("customPage.notFoundDesc")),1)])]))])])]}),_:1}))}}),Rt=Te(kt,[["__scopeId","data-v-b278b1e3"]]);export{Rt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.