@krantho/studio 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AssistantPanel-DpYeurU-.js → AssistantPanel-CeOJfSzu.js} +2 -2
- package/dist/assets/GraphBrowser-BNto7hgk.js +2 -0
- package/dist/assets/GraphCanvas-Wo0XaRUG.js +1 -0
- package/dist/assets/{action-button-DIrhqMRc.js → action-button-DPLZn2gk.js} +1 -1
- package/dist/assets/api-seo-CL5Gq_tK.js +1 -0
- package/dist/assets/{arduino-DKR9_xyJ.js → arduino-LsGX0_fs.js} +1 -1
- package/dist/assets/{arrow-down-B5kfR2lG.js → arrow-down-EM8VW6wf.js} +1 -1
- package/dist/assets/{arrow-left-7opbl8fu.js → arrow-left-DDRnAcp0.js} +1 -1
- package/dist/assets/{auth-CIpilSKF.js → auth-Dw_S0y7Q.js} +1 -1
- package/dist/assets/{c-CEM0h_nK.js → c-8MGCQYww.js} +1 -1
- package/dist/assets/{circle-check-big-DQjpuxcC.js → circle-check-big-BoM2gsTK.js} +1 -1
- package/dist/assets/{circle-dashed-cuYrILNo.js → circle-dashed-BrW3fkOb.js} +1 -1
- package/dist/assets/{circle-x-peGpq98w.js → circle-x-BFRqOpao.js} +1 -1
- package/dist/assets/{clike-BlGBRct5.js → clike-DDEFrJkJ.js} +1 -1
- package/dist/assets/{clock-DoBIVjZO.js → clock-D6yo3SXy.js} +1 -1
- package/dist/assets/{collection-view-Bbr6ff-2.js → collection-view-m8EZ-LL6.js} +1 -1
- package/dist/assets/{copy-V85khWct.js → copy-DLNaHdGn.js} +1 -1
- package/dist/assets/{corner-down-right-BpwOGRFR.js → corner-down-right-DjKESJQq.js} +1 -1
- package/dist/assets/{cpp-C0nea612.js → cpp-CCXrbquo.js} +1 -1
- package/dist/assets/createLucideIcon-Bepm3pPy.js +1 -0
- package/dist/assets/{csharp-C430X67Y.js → csharp-C9B8MEOG.js} +1 -1
- package/dist/assets/{data-table-B1kqxrEw.js → data-table-CkVtHoRX.js} +1 -1
- package/dist/assets/{editor-page-ydSt1TIL.js → editor-page-DygzC7e2.js} +4 -4
- package/dist/assets/{empty-state-CeUZocHx.js → empty-state-CFOGJxEy.js} +1 -1
- package/dist/assets/{export-helpers-C_HVpJN9.js → export-helpers-88w7CxCC.js} +1 -1
- package/dist/assets/{external-link-Dh7p8Ii6.js → external-link-WjUzPJ5r.js} +1 -1
- package/dist/assets/fill-job-B7N4431e.js +1 -0
- package/dist/assets/{fill-run-view-ChrOLoV4.js → fill-run-view-CwWAvqg1.js} +1 -1
- package/dist/assets/{findability-BrhtZ2yD.js → findability-CMuvomGn.js} +1 -1
- package/dist/assets/{format-C3ZX9yGM.js → format-Bm7d76kc.js} +1 -1
- package/dist/assets/{go-2ldyX7zA.js → go-C0xZKYRK.js} +1 -1
- package/dist/assets/graph-config-CkeJgPns.js +1 -0
- package/dist/assets/{image-editor-CAZbOhRZ.js → image-editor-DUnZn-si.js} +1 -1
- package/dist/assets/index-CZQJBss1.js +2 -0
- package/dist/assets/{info-Cxkabti5.js → info-C_gFhCsx.js} +1 -1
- package/dist/assets/{java-BaDy4FT-.js → java-DQEBLEMZ.js} +1 -1
- package/dist/assets/{javascript-DoKZVVG7.js → javascript-fLcGJpXd.js} +1 -1
- package/dist/assets/{kotlin-aNSUnDDr.js → kotlin-BhmBVS_0.js} +1 -1
- package/dist/assets/{layers-0VWe0rKm.js → layers-BzWhM_T4.js} +1 -1
- package/dist/assets/{list-checks-BCEhMMVY.js → list-checks-BycWtY9-.js} +1 -1
- package/dist/assets/live-markdown-editor-ColMfnPc.js +54 -0
- package/dist/assets/{markdown-ChIsYjIt.js → markdown-Cxg2MxWr.js} +1 -1
- package/dist/assets/{markup-C09yLKTH.js → markup-CaYP0gdG.js} +1 -1
- package/dist/assets/{markup-templating-DNhq-UOv.js → markup-templating-DwmVPbHS.js} +1 -1
- package/dist/assets/{media-model-D4F1Farw.js → media-model-s8-mD6gc.js} +1 -1
- package/dist/assets/media-page-BIWNwixX.js +1 -0
- package/dist/assets/{meter-ZOLJ0WhG.js → meter-ZmQjbS6d.js} +1 -1
- package/dist/assets/{objectivec-s2I4Tn1D.js → objectivec-CHvtiGZJ.js} +1 -1
- package/dist/assets/{pen-line-B524Nue8.js → pen-line-tXXn2ou2.js} +1 -1
- package/dist/assets/{pencil-xdGZtrO4.js → pencil-CGbkYPXO.js} +1 -1
- package/dist/assets/{php-B_6N-5RT.js → php-SxIHzpF9.js} +1 -1
- package/dist/assets/{pulse-page-zRYAQJh6.js → pulse-page-rQssy-k-.js} +1 -1
- package/dist/assets/rolldown-runtime-9C0vUP4u.js +1 -0
- package/dist/assets/{rotate-ccw-BgARBEK3.js → rotate-ccw-IHHFmrqQ.js} +1 -1
- package/dist/assets/{ruby-C8GJZDTg.js → ruby--MTbGwza.js} +1 -1
- package/dist/assets/{save-ClSXW9cb.js → save-DWhrs5es.js} +1 -1
- package/dist/assets/{send-kYpW5JED.js → send-Bf0SGwsO.js} +1 -1
- package/dist/assets/setup-page-C2UVL4hj.js +1 -0
- package/dist/assets/site-CI7ReWwB.js +1 -0
- package/dist/assets/site-model-DwdSKSWR.js +1 -0
- package/dist/assets/{site-overview-B0Dnsj2N.js → site-overview-BnmQMy6p.js} +1 -1
- package/dist/assets/{structure-page-DpM1G-M9.js → structure-page-Cjqo5mS4.js} +2 -2
- package/dist/assets/{trash-DzRCm500.js → trash-DFKejXb4.js} +1 -1
- package/dist/assets/{triangle-exclamation-point-ttN5lZI0.js → triangle-exclamation-point-CxTYPLt1.js} +1 -1
- package/dist/assets/{typescript-s_P45ayF.js → typescript-DuydAHsI.js} +1 -1
- package/dist/assets/{upload-CaqQJaUr.js → upload-9M4suN_I.js} +1 -1
- package/dist/assets/{use-drawer-actions-BeAi2hJS.js → use-drawer-actions-CXYpJuv5.js} +1 -1
- package/dist/assets/use-loaded-DJHzW9zx.js +1 -0
- package/dist/assets/{use-locale-versions-CcJ_us1I.js → use-locale-versions-DXUTVGkz.js} +1 -1
- package/dist/assets/{vendor-diff-DGCTJYJ4.js → vendor-diff-B5uXPOYl.js} +40 -40
- package/dist/assets/vendor-markdown-BXQo8zdD.js +79 -0
- package/dist/assets/{vendor-media-DXSmPN_d.js → vendor-media-BVfbikEZ.js} +1 -1
- package/dist/assets/vendor-react-Njf47Pb1.js +15 -0
- package/dist/assets/{vendor-react-DLioOiRN.css → vendor-react-bSyOAvy0.css} +1 -1
- package/dist/assets/vendor-reactflow-D7sfycOJ.js +1 -0
- package/dist/assets/vendor-router-Cwn5_0Pw.js +1 -0
- package/dist/index.html +9 -9
- package/package.json +23 -23
- package/dist/assets/GraphBrowser-Cm5q82MJ.js +0 -2
- package/dist/assets/GraphCanvas-CZJNUa_J.js +0 -1
- package/dist/assets/api-seo-DeG5gsh6.js +0 -1
- package/dist/assets/createLucideIcon-BklFHeMd.js +0 -1
- package/dist/assets/fill-job-CKtHKXwV.js +0 -1
- package/dist/assets/graph-config-CgXhm7XP.js +0 -1
- package/dist/assets/index-d5j-az5g.js +0 -2
- package/dist/assets/live-markdown-editor-DSsCNBWR.js +0 -54
- package/dist/assets/media-page-DuSUjFO1.js +0 -1
- package/dist/assets/rolldown-runtime-COiEfhsA.js +0 -1
- package/dist/assets/setup-page-CshRkFJ-.js +0 -1
- package/dist/assets/site-CGs9-oiw.js +0 -1
- package/dist/assets/site-model-BXHOxNij.js +0 -1
- package/dist/assets/use-loaded-BNCu0C-c.js +0 -1
- package/dist/assets/vendor-markdown-BeOOOWTF.js +0 -74
- package/dist/assets/vendor-react-CXaWJ_ii.js +0 -15
- package/dist/assets/vendor-reactflow-CMKi7AEX.js +0 -1
- package/dist/assets/vendor-router-B4czwg8X.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{c as t,d as n,i as r,l as i,n as a,o,p as s,r as c,s as l,t as u,u as d}from"./use-drawer-actions-BeAi2hJS.js";import{o as ee,s as f}from"./vendor-diff-DGCTJYJ4.js";import{A as te,C as ne,D as re,E as ie,M as ae,N as p,O as oe,P as se,S as ce,_ as le,a as ue,b as m,c as h,d as g,f as de,g as fe,h as _,i as pe,j as me,l as he,m as v,n as y,o as b,p as x,r as S,t as ge,u as C,v as _e,w as ve,x as ye,y as w}from"./media-model-D4F1Farw.js";import{i as be}from"./auth-CIpilSKF.js";import{d as xe,i as T,n as Se,u as Ce}from"./format-C3ZX9yGM.js";import{Et as we,Tt as Te,d as E,et as D,f as O,it as Ee,mt as De,tt as k}from"./index-d5j-az5g.js";import{t as Oe}from"./empty-state-CeUZocHx.js";import{i as A,n as j,r as ke,t as M}from"./createLucideIcon-BklFHeMd.js";import{t as N}from"./vendor-router-B4czwg8X.js";import{t as Ae}from"./copy-V85khWct.js";import{t as je}from"./external-link-Dh7p8Ii6.js";import{t as P}from"./trash-DzRCm500.js";import{t as F}from"./action-button-DIrhqMRc.js";import{n as Me}from"./guards-BFEDbduR.js";import{t as I}from"./save-ClSXW9cb.js";import{t as Ne}from"./layers-0VWe0rKm.js";import{t as Pe}from"./pencil-xdGZtrO4.js";import{t as Fe}from"./list-checks-BCEhMMVY.js";var L={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};L.node;var Ie=M(L),R={name:`copy-plus`,size:24,node:[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};R.node;var Le=M(R),z={name:`file-image`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]};z.node;var B=M(z),V={name:`folder-input`,size:24,node:[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]};V.node;var Re=M(V),H={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};H.node;var ze=M(H),U={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};U.node;var Be=M(U),W={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};W.node;var Ve=M(W),G=e(f(),1),K=ee();async function He(e){let[t]=e;return t&&e.length===1?(await ne(t.id),{deleted:[t.id],skipped:[]}):ye(e.map(e=>e.id))}function Ue({items:e,references:t}){let n=e.filter(e=>(x(t(e.id))??0)>0),r=e.filter(e=>x(t(e.id))===null);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ul`,{className:`media-delete-list`,children:e.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`strong`,{children:e.filename}),` — `,v(t(e.id))]},e.id))}),n.length>0&&(0,K.jsxs)(`p`,{className:`media-warning`,role:`note`,children:[h(n.length),` `,n.length===1?`is`:`are`,` used by documents. Their pages lose the image: the documents still point at a file that is gone.`]}),r.length>0&&(0,K.jsxs)(`p`,{className:`media-warning`,role:`note`,children:[`The references of `,h(r.length),` are not read yet or could not be read, so they may be in use.`]}),(0,K.jsx)(`p`,{children:`This cannot be undone.`})]})}function We({outcome:e,items:t}){let n=e=>t.find(t=>t.id===e)?.filename??e;return(0,K.jsxs)(`div`,{role:`status`,children:[(0,K.jsxs)(`p`,{children:[`Deleted `,h(e.deleted.length),`.`]}),e.skipped.length>0&&(0,K.jsx)(`ul`,{className:`media-delete-list`,children:e.skipped.map(e=>(0,K.jsxs)(`li`,{children:[n(e.id),`: `,e.reason]},e.id))})]})}function Ge({phase:e,count:t,safe:n,onClose:r,onRun:i}){if(e.name===`done`||e.name===`failed`)return(0,K.jsx)(j,{ref:n,onClick:r,children:`Close`});let a=e.name===`working`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(j,{ref:n,"aria-disabled":a,onClick:a?void 0:r,children:`Cancel`}),(0,K.jsx)(j,{variant:`danger`,"aria-disabled":a,onClick:a?void 0:i,children:a?`Deleting…`:`Delete ${h(t)}`})]})}function Ke(e){let[t,n]=(0,G.useState)({name:`ask`});async function r(){n({name:`working`});try{let t=await He(e.items);n({name:`done`,outcome:t}),e.onDone(t.deleted)}catch(e){n({name:`failed`,message:O(e,`Delete failed`)})}}return{phase:t,run:r}}function qe(e){let{phase:t,run:n}=Ke(e),r=(0,G.useRef)(null);(0,G.useEffect)(()=>{(t.name===`done`||t.name===`failed`)&&r.current?.focus()},[t.name]);let i=t.name===`working`;return(0,K.jsxs)(E,{title:e.items.length===1?`Delete file`:`Delete files`,onClose:i?()=>void 0:e.onClose,initialFocus:r,busy:i,actions:(0,K.jsx)(Ge,{phase:t,count:e.items.length,safe:r,onClose:e.onClose,onRun:()=>void n()}),children:[t.name===`done`&&(0,K.jsx)(We,{outcome:t.outcome,items:e.items}),t.name===`failed`&&(0,K.jsx)(`p`,{role:`alert`,children:t.message}),(t.name===`ask`||t.name===`working`)&&(0,K.jsx)(Ue,{items:e.items,references:e.references})]})}function Je({item:e,canEdit:t}){return t?(0,K.jsxs)(N,{to:we(e.id),className:A(`secondary`,`sm`),children:[(0,K.jsx)(n,{className:`ui-button-icon`,"aria-hidden":`true`}),`Crop & hotspot`]}):(0,K.jsx)(F,{size:`sm`,icon:n,reason:S,onClick:()=>void 0,children:`Crop & hotspot`})}function Ye({item:e,reason:t,onReplaced:n}){let a=(0,G.useRef)(null),o=r(e,n);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{ref:a,type:`file`,accept:`image/*`,hidden:!0,"aria-label":`Replace ${e.filename}`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o.run(t)}}),(0,K.jsx)(F,{size:`sm`,icon:i,reason:t??(o.busy?`Replacing…`:null),onClick:()=>a.current?.click(),children:o.busy?`Replacing…`:`Replace`})]})}function Xe({item:e}){let t=u(),n=Me(e.url);return(0,K.jsxs)(`div`,{className:`media-actions`,children:[C(e)&&(0,K.jsx)(j,{size:`sm`,icon:Ae,onClick:()=>t(_e(e),`Markdown`),children:`Copy markdown`}),(0,K.jsx)(j,{size:`sm`,variant:`ghost`,icon:Ve,onClick:()=>t(e.id,`ID`),children:`Copy ID`}),n&&(0,K.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:A(`ghost`,`sm`),children:[(0,K.jsx)(je,{className:`ui-button-icon`,"aria-hidden":`true`}),`Open original`,(0,K.jsx)(`span`,{className:`visually-hidden`,children:` (opens in a new tab)`})]})]})}function Ze(e){let{item:t,canEdit:n}=e,r=n?null:S,i=a(t,e.onDuplicated);return(0,K.jsxs)(`div`,{className:`media-actions`,children:[C(t)&&(0,K.jsx)(Je,{item:t,canEdit:n}),(0,K.jsx)(Ye,{item:t,reason:r,onReplaced:e.onReplaced}),(0,K.jsx)(F,{size:`sm`,icon:Le,reason:r??(i.busy?`Duplicating…`:null),onClick:()=>void i.run(),children:`Duplicate`}),(0,K.jsx)(F,{size:`sm`,variant:`danger`,icon:P,reason:r,onClick:e.onDelete,children:`Delete`})]})}function Qe({tags:e,disabled:t,onRemove:n}){return e.length===0?null:(0,K.jsx)(`ul`,{className:`media-tags`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`media-tag`,children:[e,(0,K.jsx)(`button`,{type:`button`,className:`media-tag-remove`,"aria-label":`Remove ${e}`,disabled:t,onClick:()=>n(e),children:(0,K.jsx)(k,{"aria-hidden":`true`})})]},e))})}function $e({id:e,known:t,tags:n}){return(0,K.jsx)(`datalist`,{id:e,children:t.filter(e=>!n.includes(e)).map(e=>(0,K.jsx)(`option`,{value:e},e))})}function et({tags:e,known:t,disabled:n,onChange:r}){let i=(0,G.useId)(),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(``);function c(t){if(t.key!==`Enter`&&t.key!==`,`)return;t.preventDefault();let n=o.trim();n&&!e.includes(n)&&r([...e,n]),s(``)}function l(t){r(e.filter(e=>e!==t)),a.current?.focus()}return(0,K.jsxs)(`div`,{className:`media-field`,children:[(0,K.jsx)(`label`,{htmlFor:i,className:`media-label`,children:`Tags`}),(0,K.jsx)(Qe,{tags:e,disabled:n,onRemove:l}),(0,K.jsx)(`input`,{ref:a,id:i,className:`media-input`,list:`${i}-known`,placeholder:`Type a tag and press Enter`,value:o,disabled:n,onChange:e=>s(e.target.value),onKeyDown:c}),(0,K.jsx)($e,{id:`${i}-known`,known:t,tags:e})]})}var tt=5e3;function q(e){if(!e||e.state===`loading`)return`wait`;if(e.state===`failed`)return{count:null};let t=e.documents.length;return t===0?`save`:{count:t}}function nt(e,t){let[n,r]=(0,G.useState)({phase:`idle`}),i=(0,G.useRef)(t);i.current=t;let a=(0,G.useCallback)(e=>{e===`wait`?r({phase:`checking`}):e===`save`?(r({phase:`idle`}),i.current()):r({phase:`confirm`,count:e.count})},[]),o=n.phase===`checking`;return(0,G.useEffect)(()=>{if(!o)return;let t=q(e);if(t!==`wait`){a(t);return}let n=setTimeout(()=>a({count:null}),tt);return()=>clearTimeout(n)},[o,e,a]),{state:n,request:()=>a(q(e)),confirm:()=>{r({phase:`idle`}),i.current()},cancel:()=>r({phase:`idle`})}}function rt({count:e,onConfirm:t,onCancel:n}){let r=(0,G.useRef)(null);return(0,K.jsx)(E,{title:`Rename a file in use`,onClose:n,initialFocus:r,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(j,{ref:r,onClick:n,children:`Cancel`}),(0,K.jsx)(j,{variant:`primary`,onClick:t,children:`Rename`})]}),children:(0,K.jsx)(`p`,{children:fe(e)})})}function J({label:e,value:t,disabled:n,note:r,onChange:i}){let a=(0,G.useId)();return(0,K.jsxs)(`div`,{className:`media-field`,children:[(0,K.jsx)(`label`,{htmlFor:a,className:`media-label`,children:e}),(0,K.jsx)(`input`,{id:a,className:`media-input`,value:t,disabled:n,"aria-describedby":r?`${a}-note`:void 0,onChange:e=>i(e.target.value)}),r&&(0,K.jsx)(`p`,{id:`${a}-note`,className:`media-note`,children:r})]})}function it({item:e,folders:t,disabled:n,onMoved:r}){let i=(0,G.useId)(),a=c(e,r);return(0,K.jsxs)(`div`,{className:`media-field`,children:[(0,K.jsx)(`label`,{htmlFor:i,className:`media-label`,children:`Folder`}),(0,K.jsxs)(`select`,{id:i,className:`media-select`,value:e.folder??``,disabled:n||a.busy,onChange:e=>void a.run(e.target.value||null),children:[(0,K.jsx)(`option`,{value:``,children:`No folder`}),t.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})}function at({canEdit:e,busy:t,checking:n}){return e?(0,K.jsx)(j,{type:`submit`,variant:`primary`,size:`sm`,icon:I,"aria-disabled":t||n,children:n?`Checking references…`:t?`Saving…`:`Save`}):(0,K.jsx)(F,{size:`sm`,icon:I,reason:S,onClick:()=>void 0,children:`Save`})}var ot=`No alt text: screen readers and search engines get no description of the image.`;function st({props:e,details:t,change:n}){let r=!e.canEdit;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{label:`Name`,value:t.filename,disabled:r,onChange:e=>n({filename:e})}),(0,K.jsx)(J,{label:`Alt text`,value:t.altText,disabled:r,note:t.altText.trim()?void 0:ot,onChange:e=>n({altText:e})}),(0,K.jsx)(et,{tags:t.tags,known:e.knownTags,disabled:r,onChange:e=>n({tags:e})}),e.folders&&e.folders.length>0&&(0,K.jsx)(it,{item:e.item,folders:e.folders,disabled:r,onMoved:e.onSaved})]})}function ct(e){let{item:t}=e,[n,r]=(0,G.useState)({filename:t.filename,altText:t.altText,tags:[...t.tags]}),i=o(t,e.onSaved),a=nt(e.references,()=>void i.run(n)),s=e=>r(t=>({...t,...e}));function c(r){r.preventDefault(),e.canEdit&&!i.busy&&a.state.phase===`idle`&&(n.filename===t.filename?i.run(n):a.request())}return(0,K.jsxs)(`form`,{className:`media-details`,"aria-label":`Details`,onSubmit:c,children:[(0,K.jsx)(st,{props:e,details:n,change:s}),(0,K.jsx)(at,{canEdit:e.canEdit,busy:i.busy,checking:a.state.phase===`checking`}),a.state.phase===`confirm`&&(0,K.jsx)(rt,{count:a.state.count,onCancel:a.cancel,onConfirm:a.confirm})]})}function lt({references:e}){return(0,K.jsxs)(`div`,{className:`media-references`,children:[(0,K.jsx)(`p`,{className:`media-references-count`,children:v(e)}),e?.state===`ready`&&e.documents.length>0&&(0,K.jsx)(`ul`,{className:`media-reference-list`,children:e.documents.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(N,{to:Te(e.collection,e.slug),className:`media-link`,children:[e.collection,`/`,e.slug]}),` `,(0,K.jsxs)(`span`,{className:`media-reference-fields`,children:[`(`,e.fields.join(`, `),`)`]})]},`${e.collection}/${e.slug}`))})]})}function ut({item:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`media-drawer-preview`,children:C(e)?(0,K.jsx)(`img`,{src:w(e,`lg`),alt:e.altText}):(0,K.jsx)(B,{"aria-hidden":`true`})}),(0,K.jsxs)(`dl`,{className:`media-facts`,children:[(0,K.jsx)(`dt`,{children:`Kind`}),(0,K.jsx)(`dd`,{children:g(e.mimeType)}),(0,K.jsx)(`dt`,{children:`Dimensions`}),(0,K.jsx)(`dd`,{children:b(e)??`None stored`}),(0,K.jsx)(`dt`,{children:`Size`}),(0,K.jsx)(`dd`,{children:T(e.size)}),(0,K.jsx)(`dt`,{children:`Uploaded`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`time`,{dateTime:e.createdAt,children:Se(e.createdAt)})}),(0,K.jsx)(`dt`,{children:`Stable URL`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`code`,{className:`media-url`,children:m(e.id)})})]})]})}function dt({titleId:e,item:t,onClose:n}){let r=(0,G.useRef)(null);return(0,G.useEffect)(()=>{r.current?.focus()},[]),(0,K.jsxs)(`div`,{className:`media-drawer-head`,children:[(0,K.jsx)(`h2`,{id:e,ref:r,tabIndex:-1,className:`media-drawer-title`,children:t.filename}),(0,K.jsx)(ke,{icon:k,label:`Close details`,onClick:n})]})}function ft(e){let{item:t,permissions:n}=e,r=(0,G.useId)();function i(t){t.key!==`Escape`||t.defaultPrevented||(t.stopPropagation(),e.onClose())}return(0,K.jsxs)(`section`,{className:`media-drawer`,"aria-labelledby":r,onKeyDown:i,children:[(0,K.jsx)(dt,{titleId:r,item:t,onClose:e.onClose}),(0,K.jsx)(ut,{item:t}),(0,K.jsx)(lt,{references:e.references}),(0,K.jsx)(Xe,{item:t}),(0,K.jsx)(Ze,{item:t,canEdit:n.canEdit,onReplaced:t=>e.onChanged(t,!0),onDuplicated:e.onDuplicated,onDelete:e.onDelete}),(0,K.jsx)(ct,{item:t,references:e.references,folders:e.folders,knownTags:e.knownTags,canEdit:n.canEdit,onSaved:t=>e.onChanged(t,!1)},`${t.id}:${t.url}`)]})}function Y(e){let{label:t,submitLabel:n,onCancel:r}=e,i=(0,G.useId)(),[a,o]=(0,G.useState)(e.initial),[s,c]=(0,G.useState)(!1);async function l(t){t.preventDefault(),a.trim()&&!s&&(c(!0),await e.onSubmit(a.trim()),c(!1))}return(0,K.jsxs)(`form`,{className:`media-folder-form`,onSubmit:e=>void l(e),children:[(0,K.jsx)(`label`,{htmlFor:i,className:`media-label`,children:t}),(0,K.jsx)(`input`,{id:i,className:`media-input`,value:a,autoFocus:!0,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Escape`&&r()}),(0,K.jsxs)(`div`,{className:`media-actions`,children:[(0,K.jsx)(j,{size:`sm`,variant:`primary`,type:`submit`,"aria-disabled":s,children:n}),(0,K.jsx)(j,{size:`sm`,variant:`ghost`,onClick:r,children:`Cancel`})]})]})}function pt({folder:e,onClose:t,onDeleted:n}){let r=D(),i=(0,G.useRef)(null);async function a(){try{await ve(e.id),r({text:`Folder ${e.name} deleted.`}),n()}catch(e){r({text:O(e,`The folder could not be deleted`),tone:`error`})}t()}return(0,K.jsx)(E,{title:`Delete folder`,onClose:t,initialFocus:i,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(j,{ref:i,onClick:t,children:`Cancel`}),(0,K.jsx)(j,{variant:`danger`,onClick:()=>void a(),children:`Delete folder`})]}),children:(0,K.jsxs)(`p`,{children:[`Delete the folder `,(0,K.jsx)(`strong`,{children:e.name}),`? Only an empty folder can be deleted; its files stay in the library.`]})})}function mt(e){let t=D();async function n(n,r){try{e(await n())}catch(e){t({text:O(e,r),tone:`error`})}}return{create:(e,t)=>n(async()=>(await ce(t,e?.id??null)).id,`The folder could not be created`),rename:(e,t)=>n(async()=>{await se(e.id,t)},`The folder could not be renamed`)}}function ht({props:e,onEdit:t}){let n=e.canEdit?null:S;return(0,K.jsxs)(`div`,{className:`media-folder-actions`,children:[(0,K.jsx)(F,{size:`sm`,icon:ze,reason:n,onClick:()=>t(`new`),children:`New folder`}),e.selected&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(F,{size:`sm`,variant:`ghost`,icon:Pe,reason:n,onClick:()=>t(`rename`),children:`Rename folder`}),(0,K.jsx)(F,{size:`sm`,variant:`ghost`,icon:P,reason:e.canAdminister?null:`Deleting several files at once, or a folder, needs the admin role.`,onClick:()=>t(`delete`),children:`Delete folder`})]})]})}function gt(e){let{selected:t,onChanged:n}=e,[r,i]=(0,G.useState)(`none`),a=()=>i(`none`),o=mt(e=>{a(),n(e)});return r===`new`?(0,K.jsx)(Y,{label:t?`New folder in ${t.name}`:`New folder`,initial:``,submitLabel:`Create`,onSubmit:e=>o.create(t,e),onCancel:a}):r===`rename`&&t?(0,K.jsx)(Y,{label:`Folder name`,initial:t.name,submitLabel:`Rename`,onSubmit:e=>o.rename(t,e),onCancel:a}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ht,{props:e,onEdit:i}),r===`delete`&&t&&(0,K.jsx)(pt,{folder:t,onClose:a,onDeleted:()=>n()})]})}function _t({value:e}){return e==null?null:(0,K.jsxs)(`span`,{className:`media-folder-count`,children:[e,(0,K.jsxs)(`span`,{className:`visually-hidden`,children:[` `,e===1?`file`:`files`]})]})}function X(e){let{icon:t}=e;function n(t){let n=t.dataTransfer.getData(y);n&&(t.preventDefault(),e.onDropMedia(n))}return(0,K.jsxs)(`button`,{type:`button`,className:`media-folder`,"aria-pressed":e.pressed,onClick:e.onSelect,onDragOver:e=>{e.dataTransfer.types.includes(`application/krantho-media-id`)&&e.preventDefault()},onDrop:n,children:[(0,K.jsx)(t,{className:`media-folder-icon`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`media-folder-name`,children:e.label}),(0,K.jsx)(_t,{value:e.count})]})}function vt({row:e,open:t,onToggle:n}){if(!e.hasChildren)return(0,K.jsx)(`span`,{className:`media-folder-toggle-space`,"aria-hidden":`true`});let r=t?s:De;return(0,K.jsx)(`button`,{type:`button`,className:`media-folder-toggle`,"aria-expanded":t,"aria-label":`Subfolders of ${e.folder.name}`,onClick:n,children:(0,K.jsx)(r,{"aria-hidden":`true`})})}function yt({props:e}){let[t,n]=(0,G.useState)(new Set),r=e=>n(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return he(e.folders,t).map(n=>(0,K.jsxs)(`li`,{className:`media-folder-row`,style:{paddingInlineStart:`calc(${n.depth} * var(--space-4))`},children:[(0,K.jsx)(vt,{row:n,open:!t.has(n.folder.id),onToggle:()=>r(n.folder.id)}),(0,K.jsx)(X,{label:n.folder.name,count:e.counts.get(n.folder.id),pressed:e.selected===n.folder.id,icon:Be,onSelect:()=>e.onSelect(n.folder.id),onDropMedia:t=>e.onMove(t,n.folder.id)})]},n.folder.id))}function bt(e){let t=e.folders.find(t=>t.id===e.selected)??null;return(0,K.jsxs)(`nav`,{className:`media-folders`,"aria-label":`Folders`,children:[(0,K.jsx)(`h2`,{className:`media-folders-title`,children:`Folders`}),(0,K.jsxs)(`ul`,{className:`media-folder-list`,children:[(0,K.jsxs)(`li`,{className:`media-folder-row`,children:[(0,K.jsx)(`span`,{className:`media-folder-toggle-space`,"aria-hidden":`true`}),(0,K.jsx)(X,{label:`All files`,count:e.total,pressed:e.selected===null,icon:Ne,onSelect:()=>e.onSelect(null),onDropMedia:t=>e.onMove(t,null)})]}),(0,K.jsx)(yt,{props:e})]}),(0,K.jsx)(gt,{selected:t,canEdit:e.permissions.canEdit,canAdminister:e.permissions.canAdminister,onChanged:e.onChanged})]})}function Z({item:e,references:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`media-tile-thumb`,children:[C(e)?(0,K.jsx)(`img`,{src:w(e,`md`),alt:``,loading:`lazy`}):(0,K.jsx)(B,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`media-tile-kind`,children:g(e.mimeType)})]}),(0,K.jsx)(`span`,{className:`media-tile-name`,children:e.filename}),(0,K.jsx)(`span`,{className:`media-tile-meta`,children:b(e)??`No pixel dimensions`}),(0,K.jsx)(`span`,{className:`media-tile-refs`,children:v(t)})]})}function xt({item:e,props:t}){let n=t.references(e.id);if(t.bulk){let r=t.selected.has(e.id);return(0,K.jsxs)(`label`,{className:`media-tile${r?` media-tile--selected`:``}`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`media-tile-check`,"aria-label":`Select ${e.filename}`,checked:r,onChange:()=>t.onToggle(e.id)}),(0,K.jsx)(Z,{item:e,references:n})]})}return(0,K.jsx)(`button`,{type:`button`,className:`media-tile`,"data-media-id":e.id,"aria-pressed":t.open===e.id,draggable:t.draggable,onDragStart:t=>{t.dataTransfer.setData(y,e.id),t.dataTransfer.effectAllowed=`move`},onClick:()=>t.onOpen(e),children:(0,K.jsx)(Z,{item:e,references:n})})}function St(e){return(0,K.jsx)(`ul`,{className:`media-grid`,"aria-label":`Files`,children:e.items.map(t=>(0,K.jsx)(`li`,{children:(0,K.jsx)(xt,{item:t,props:e})},t.id))})}function Ct({info:e,read:t}){return(0,K.jsxs)(`header`,{className:`media-header`,children:[(0,K.jsx)(`h1`,{className:`media-title`,children:`Media`}),e?(0,K.jsxs)(`p`,{className:`media-lead`,children:[`Stored in `,(0,K.jsx)(`strong`,{className:`media-store`,children:e.storageLabel}),e.storagePath&&(0,K.jsxs)(K.Fragment,{children:[` `,`at `,(0,K.jsx)(`code`,{className:`media-store-path`,children:e.storagePath})]}),(0,K.jsxs)(`span`,{children:[` `,`· `,h(e.totalItems),`, `,T(e.totalSize)]})]}):(0,K.jsx)(`p`,{className:`media-lead`,children:t?`The media store could not be read.`:`Reading the media store…`})]})}function wt({value:e,onChange:t}){let n=(0,G.useId)();return(0,K.jsxs)(`span`,{className:`media-search`,children:[(0,K.jsx)(`label`,{htmlFor:n,className:`visually-hidden`,children:`Search media`}),(0,K.jsx)(Ee,{className:`media-search-icon`,"aria-hidden":`true`}),(0,K.jsx)(`input`,{id:n,type:`search`,className:`media-input media-search-input`,placeholder:`Search by name`,value:e,onChange:e=>t(e.target.value)})]})}function Q(e){let t=(0,G.useId)();return(0,K.jsxs)(`span`,{className:`media-filter`,children:[(0,K.jsx)(`label`,{htmlFor:t,children:e.label}),(0,K.jsx)(`select`,{id:t,className:`media-select`,value:e.value,onChange:t=>{let n=e.options.find(e=>e.value===t.target.value);n&&e.onChange(n.value)},children:e.options.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function Tt(e){let{filters:t,onFilters:n,tags:r}=e,i=[{value:``,label:`All tags`},...r.map(e=>({value:e,label:e}))];return(0,K.jsxs)(`div`,{className:`media-toolbar`,children:[(0,K.jsx)(wt,{value:t.search,onChange:e=>n({search:e})}),r.length>0&&(0,K.jsx)(Q,{label:`Tag`,value:t.tag,options:i,onChange:e=>n({tag:e})}),(0,K.jsx)(Q,{label:`Order this page`,value:e.sort,options:ue.map(e=>({value:e,label:pe[e]})),onChange:e.onSort}),(0,K.jsx)(j,{size:`sm`,icon:Fe,"aria-pressed":e.bulk,onClick:e.onBulk,children:`Bulk select`})]})}function Et(e){let t=e.count===0?`Select files to delete.`:null;return(0,K.jsxs)(`section`,{className:`media-selection`,"aria-label":`Selection`,children:[(0,K.jsxs)(`p`,{className:`media-selection-count`,role:`status`,children:[(0,K.jsx)(`span`,{className:`media-figure`,children:e.count}),` selected`]}),(0,K.jsxs)(`div`,{className:`media-actions`,children:[(0,K.jsx)(F,{size:`sm`,variant:`danger`,icon:P,reason:e.canDelete?t:ge,onClick:e.onDelete,children:`Delete`}),(0,K.jsx)(j,{size:`sm`,variant:`ghost`,icon:Ie,onClick:e.onSelectPage,children:`Select this page`}),(0,K.jsx)(j,{size:`sm`,variant:`ghost`,icon:k,onClick:e.onClear,children:`Clear selection`})]})]})}function Dt({items:e,folder:t}){let n=e.length===1;return`Uploaded ${h(e.length)} to All files: an upload goes into no folder. Move ${n?`it`:`them`} to ${t.name} from ${n?`its`:`their`} details, or with Move here.`}async function Ot(e,t){let n=0;for(let r of e)await p(r.id,t.id),n++;return n}function kt({notice:e,onMoved:t,onDismiss:n}){let r=D(),[i,a]=(0,G.useState)(!1);async function o(){a(!0);try{let n=await Ot(e.items,e.folder);r({text:`Moved ${h(n)} to ${e.folder.name}.`}),t()}catch(e){r({text:O(e,`The files could not be moved`),tone:`error`}),a(!1)}}return(0,K.jsxs)(`div`,{className:`media-upload-notice`,role:`status`,children:[(0,K.jsx)(`p`,{children:Dt(e)}),(0,K.jsxs)(`div`,{className:`media-actions`,children:[(0,K.jsx)(j,{size:`sm`,variant:`primary`,icon:Re,"aria-disabled":i,onClick:i?void 0:()=>void o(),children:i?`Moving…`:`Move here`}),(0,K.jsx)(j,{size:`sm`,variant:`ghost`,icon:k,onClick:n,children:`Dismiss`})]})]})}var At={search:``,tag:``,folder:null,page:0},jt={read:!1,info:null,tags:[],folders:[],folderCounts:new Map};function Mt(e,t){return t?new Map(e.map(e=>[e.id,t.folderCounts[e.id]??0])):new Map}async function Nt(e){let[t,n,r]=await Promise.all([oe().catch(()=>null),te().catch(()=>[]),e?re().catch(()=>[]):Promise.resolve([])]);return{read:!0,info:t,tags:n,folders:r,folderCounts:Mt(r,t)}}function $(e){return ie({limit:24,offset:e.page*24,search:e.search||void 0,tag:e.tag||void 0,folder:e.folder??void 0})}function Pt(e,t){let[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(null);return(0,G.useEffect)(()=>{let t=!0;return $(e).then(e=>{t&&(r(e),a(null))}).catch(e=>t&&a(O(e,`Media could not be read`))),()=>{t=!1}},[e,t]),[n,i]}function Ft(e,t){let[n,r]=(0,G.useState)(jt);return(0,G.useEffect)(()=>{let t=!0;return Nt(e).then(e=>t&&r(e)),()=>{t=!1}},[e,t]),n}function It(e){let[t,n]=(0,G.useState)(At),[r,i]=(0,G.useState)(`newest`),[a,o]=(0,G.useState)(0),[s,c]=Pt(t,a),l=Ft(e,a),u=(0,G.useCallback)(e=>{n(t=>({...t,page:0,...e}))},[]),d=(0,G.useCallback)(()=>o(e=>e+1),[]);return{filters:t,setFilters:u,sort:r,setSort:i,listing:s,items:(0,G.useMemo)(()=>le(s?.items??[],r),[s,r]),pageCount:Math.ceil((s?.total??0)/24),library:l,error:c,reload:d}}function Lt(e){queueMicrotask(()=>{([...document.querySelectorAll(`[data-media-id]`)].find(t=>t.getAttribute(`data-media-id`)===e)??document.getElementById(`studio-main`))?.focus()})}function Rt(e){let[t,n]=(0,G.useState)(null);return(0,G.useEffect)(()=>{n(t=>(t&&e.find(e=>e.id===t.id))??t)},[e]),{item:t,open:n,close:(0,G.useCallback)(()=>{n(e=>(e&&Lt(e.id),null))},[]),drop:(0,G.useCallback)(()=>n(null),[]),update:n}}function zt(){let[e,t]=(0,G.useState)(!1),[n,r]=(0,G.useState)(new Map),i=e=>r(t=>{let n=new Map(t);return e(n),n});return{on:e,toggleMode:()=>{t(e=>!e),r(new Map)},ids:new Set(n.keys()),items:[...n.values()],toggle:e=>i(t=>{t.delete(e.id)||t.set(e.id,e)}),add:e=>i(t=>{for(let n of e)t.set(n.id,n)}),remove:e=>i(t=>{for(let n of e)t.delete(n)}),clear:()=>r(new Map)}}function Bt(e){let[t,n]=(0,G.useState)(new Map),r=(0,G.useRef)(new Set),i=(0,G.useCallback)(e=>{n(t=>{let n=new Map(t);for(let[t,r]of e)n.set(t,r);return n})},[]),a=(0,G.useCallback)(e=>{r.current.add(e),i([[e,{state:`loading`}]]),me(e).then(e=>({state:`ready`,documents:_(e.usage)})).catch(()=>({state:`failed`})).then(t=>i([[e,t]]))},[i]);return(0,G.useEffect)(()=>{let t=e.filter(e=>!r.current.has(e));if(t.length!==0){for(let e of t)r.current.add(e);i(t.map(e=>[e,{state:`loading`}])),ae(t).then(e=>t.map(t=>[t,{state:`ready`,documents:_(e[t]??[])}])).catch(()=>t.map(e=>[e,{state:`failed`}])).then(e=>i(e))}},[e,i]),{of:(0,G.useCallback)(e=>t.get(e),[t]),refresh:a}}function Vt(){setTimeout(()=>{document.activeElement!==document.body&&document.activeElement||document.getElementById(`studio-main`)?.focus()},0)}function Ht({page:e}){let{media:t,selection:n,open:r}=e;if(t.error)return(0,K.jsx)(`p`,{role:`alert`,children:t.error});if(!t.listing)return(0,K.jsx)(`p`,{role:`status`,children:`Reading media…`});if(t.items.length===0){let e=t.filters.search||t.filters.tag||t.filters.folder;return(0,K.jsx)(Oe,{icon:d,title:e?`No files match`:`No media yet`,children:e?`Nothing here matches the search, tag and folder chosen.`:`Upload an image to start the library.`})}return(0,K.jsx)(St,{items:t.items,references:e.references.of,bulk:n.on,selected:n.ids,onToggle:e=>{let r=t.items.find(t=>t.id===e);r&&n.toggle(r)},open:r.item?.id??null,onOpen:r.open,draggable:e.hasFolders&&e.permissions.canEdit})}function Ut(e){let t=D();return(n,r)=>{p(n,r).then(()=>{t({text:`Moved.`}),e()}).catch(e=>t({text:O(e,`The file could not be moved`),tone:`error`}))}}function Wt({page:e}){let{media:t}=e,{library:n,filters:r,setFilters:i,reload:a}=t,o=Ut(a),s=(0,G.useRef)(r.folder);return s.current=r.folder,(0,G.useEffect)(()=>{let e=s.current;n.read&&e!==null&&(n.folders.some(t=>t.id===e)||i({folder:null}))},[n,i]),e.hasFolders?(0,K.jsx)(bt,{folders:n.folders,counts:n.folderCounts,total:n.info?.totalItems??null,selected:r.folder,onSelect:e=>i({folder:e}),permissions:e.permissions,onChanged:e=>{a(),e&&i({folder:e})},onMove:o}):null}function Gt({page:e}){let{media:n,permissions:r}=e,[i,a]=(0,G.useState)(null);function o(e){let t=n.library.folders.find(e=>e.id===n.filters.folder);a(t?{items:e,folder:t}:null),n.setFilters({page:0}),n.reload()}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(t,{blocked:r.canEdit?null:S,onUploaded:o}),i&&(0,K.jsx)(kt,{notice:i,onDismiss:()=>a(null),onMoved:()=>{a(null),n.reload()}})]})}function Kt({page:e}){let{media:t,selection:n,permissions:r}=e;return(0,K.jsxs)(`div`,{className:`media-main`,children:[(0,K.jsx)(Gt,{page:e}),(0,K.jsx)(Tt,{filters:t.filters,onFilters:t.setFilters,tags:t.library.tags,sort:t.sort,onSort:t.setSort,bulk:n.on,onBulk:n.toggleMode}),n.on&&(0,K.jsx)(Et,{count:n.ids.size,canDelete:r.canAdminister,onDelete:()=>e.askDelete(n.items),onSelectPage:()=>n.add(t.items),onClear:n.clear}),(0,K.jsx)(Ht,{page:e}),(0,K.jsx)(l,{page:t.filters.page,count:t.pageCount,onPage:e=>t.setFilters({page:e})})]})}function qt({page:e}){let{media:t,open:n}=e,r=n.item;return r?(0,K.jsx)(ft,{item:r,references:e.references.of(r.id),folders:e.hasFolders?t.library.folders:null,knownTags:t.library.tags,permissions:e.permissions,onClose:n.close,onChanged:e=>{n.update(e),t.reload()},onDuplicated:e=>{t.reload(),n.open(e)},onDelete:()=>e.askDelete([r])},r.id):null}function Jt({page:e,items:t,onClose:n}){let{open:r,selection:i,media:a}=e;return(0,K.jsx)(qe,{items:t,references:e.references.of,onClose:()=>{n(),Vt()},onDone:e=>{r.item&&e.includes(r.item.id)&&r.drop(),i.remove(e),a.reload()}})}function Yt(){let{hasRole:e}=be(),t=Ce(xe(),`mediaFolders`),n=It(t),r=Bt((0,G.useMemo)(()=>n.items.map(e=>e.id),[n.items])),i=Rt(n.items),a=zt(),[o,s]=(0,G.useState)(null),c={media:n,references:r,open:i,selection:a,permissions:de(e),hasFolders:t,askDelete:e=>{for(let t of e)r.refresh(t.id);s(e)}};return(0,K.jsxs)(`div`,{className:`media${i.item?` media--drawer`:``}`,children:[(0,K.jsx)(Ct,{info:n.library.info,read:n.library.read}),(0,K.jsxs)(`div`,{className:`media-body`,children:[(0,K.jsx)(Wt,{page:c}),(0,K.jsx)(Kt,{page:c})]}),(0,K.jsx)(qt,{page:c}),o&&(0,K.jsx)(Jt,{page:c,items:o,onClose:()=>s(null)})]})}export{Yt as MediaPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)),u=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});export{l as i,s as n,u as r,o as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{o as t,s as n}from"./vendor-diff-DGCTJYJ4.js";import{i as r,n as i,t as a}from"./fill-run-view-ChrOLoV4.js";import{A as o,E as s,G as c,I as l,K as u,O as d,Ot as f,R as p,T as m,Tt as ee,V as te,W as ne,X as re,Z as ie,_ as ae,at as oe,b as se,ct as ce,d as h,dt as le,et as g,f as _,ft as ue,ht as de,k as v,nt as fe,o as pe,ot as me,pt as he,q as ge,rt as _e,s as y,v as ve,w as ye,y as be}from"./index-d5j-az5g.js";import{i as b}from"./auth-CIpilSKF.js";import{n as xe,t as x}from"./use-loaded-BNCu0C-c.js";import{n as S,t as C}from"./createLucideIcon-BklFHeMd.js";import{t as w}from"./trash-DzRCm500.js";import{t as T}from"./action-button-DIrhqMRc.js";import{c as Se,o as Ce,y as we}from"./api-seo-DeG5gsh6.js";import{t as Te}from"./list-checks-BCEhMMVY.js";import{a as Ee,i as De,n as Oe,r as ke,s as Ae,t as je,u as Me}from"./fill-job-CKtHKXwV.js";import{d as Ne,l as Pe,n as Fe,r as E,t as D,u as Ie}from"./format-C3ZX9yGM.js";import{t as O}from"./data-table-B1kqxrEw.js";import{t as Le}from"./empty-state-CeUZocHx.js";import{r as Re,t as ze}from"./vendor-router-B4czwg8X.js";import{t as Be}from"./guards-BFEDbduR.js";import{t as Ve}from"./source-CGZGd3Xy.js";import{t as He}from"./pencil-xdGZtrO4.js";import{t as Ue}from"./copy-V85khWct.js";import{t as We}from"./clock-DoBIVjZO.js";import{t as Ge}from"./send-kYpW5JED.js";import{i as k,t as Ke}from"./api-client-BRi_ki2Y.js";import{t as qe}from"./use-locale-versions-CcJ_us1I.js";var Je={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Je.node;var Ye=C(Je),Xe={name:`file-code`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]};Xe.node;var Ze=C(Xe),Qe={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Qe.node;var $e=C(Qe),et={name:`list-tree`,size:24,node:[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]};et.node;var tt=C(et),nt={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};nt.node;var rt=C(nt),it={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};it.node;var at=C(it),ot={name:`refresh-ccw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]};ot.node;var st=C(ot),ct={name:`user-plus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};ct.node;var lt=C(ct);async function ut(){let{users:e}=await k(`/users`);return e}async function dt(e){return k(`/users`,{method:`POST`,body:JSON.stringify(e)})}async function A(e,t){return k(`/users/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(t)})}async function ft(e){await k(`/users/${encodeURIComponent(e)}`,{method:`DELETE`})}var pt={anthropic:{label:`Claude`,vendor:`Anthropic`,format:`anthropic`,baseUrl:`https://api.anthropic.com`,defaultModel:`claude-haiku-4-5`,chatPath:`/v1/messages`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`native`},"claude-code":{label:`Claude Code`,vendor:`Anthropic`,format:`anthropic`,baseUrl:`https://api.anthropic.com`,defaultModel:`claude-haiku-4-5-20251001`,chatPath:`/v1/messages`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`native`},openai:{label:`ChatGPT`,vendor:`OpenAI`,format:`openai`,baseUrl:`https://api.openai.com`,defaultModel:`gpt-4o`,chatPath:`/v1/chat/completions`,maxTokensParam:`max_completion_tokens`,forbidTools:`tool_choice`,openObjects:`native`,reasoningParam:`reasoning_effort`},gemini:{label:`Gemini`,vendor:`Google`,format:`openai`,baseUrl:`https://generativelanguage.googleapis.com/v1beta/openai`,defaultModel:`gemini-3.6-flash`,chatPath:`/chat/completions`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`json_string`,reasoningParam:`reasoning_effort`},openrouter:{label:`OpenRouter`,vendor:`OpenRouter`,format:`openai`,baseUrl:`https://openrouter.ai/api`,defaultModel:`anthropic/claude-haiku-4.5`,chatPath:`/v1/chat/completions`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`native`,reasoningParam:`reasoning`},ollama:{label:`Ollama`,vendor:`Ollama (on your own computer)`,format:`openai`,baseUrl:`http://localhost:11434`,defaultModel:`llama3.1`,chatPath:`/v1/chat/completions`,maxTokensParam:`max_tokens`,forbidTools:`omit_tools`,openObjects:`native`,reasoningParam:`reasoning_effort`}},j=e(n(),1),mt=`claude-code`,ht=[`openrouter`,mt,`ollama`];function gt(e){return Object.hasOwn(pt,e)}function M(e){return gt(e)?pt[e]:null}function N(e){return M(e)?.label??e}function _t(e){return M(e)?.vendor??e}function vt(e){return ht.includes(e)}function yt(e){return e.providers.filter(e=>e.ready).sort((e,t)=>Number(t.active)-Number(e.active))}function bt(e){return e.providers.filter(e=>!e.ready&&!vt(e.provider))}function xt(e){return e.providers.filter(e=>!e.ready&&vt(e.provider))}function St(e,t=!0){return!e.configured||!e.provider?t?`AI help is off. Add a key below to turn it on.`:`AI help is off. An admin can add a key to turn it on.`:`AI help is on, using ${N(e.provider)}.`}function Ct(e){return!e.configured||!e.provider?`The AI`:`${N(e.provider)} · ${e.model??`its default model`}`}function wt(e){return e===`saved`?`Key saved here, encrypted.`:e===`environment`||e===`configuration`?`Set up by your developer.`:`Runs on your own computer.`}var Tt=/401|403|unauthori[sz]ed|invalid|incorrect|api[ -]?key|permission/i;function Et(e,t){let n=N(e);return t.success?`${n} works: it answered.`:Tt.test(t.error??``)?`${n} did not accept the key. Check that you copied all of it.`:`${n} did not answer: ${t.error??`no reason given`}.`}function P(){let[e,t]=(0,j.useState)(!1),n=(0,j.useRef)(!1);async function r(e){if(!n.current){n.current=!0,t(!0);try{await e()}finally{n.current=!1,t(!1)}}}return{busy:e,once:r}}function F(){let{busy:e,once:t}=P(),[n,r]=(0,j.useState)(null);return{busy:e,error:n,setError:r,run:(e,n)=>t(async()=>{r(null);try{await e()}catch(e){r(_(e,n))}})}}function Dt(e){let t=g(),{busy:n,once:r}=P();function i(e,n){r(async()=>{try{await e()}catch(e){t({text:_(e,n),tone:`error`})}})}async function a(e){let n=await d(e);t({text:Et(e,n),tone:n.success?`success`:`error`})}return{busy:n,turnOn:t=>i(async()=>{e(await v(t)),await a(t.provider)},`The key could not be saved`),use:n=>i(async()=>{e(await v({provider:n,use:!0})),t({text:`The site now uses ${N(n)}.`})},`The AI could not be changed`),save:n=>i(async()=>{e(await v(n)),t({text:`Saved the settings for ${N(n.provider)}.`})},`The settings could not be saved`),test:e=>i(()=>a(e),`The test failed`)}}var I=t();function L({title:e,children:t,confirmLabel:n,danger:r=!1,onConfirm:i,onClose:a}){let o=(0,j.useRef)(null),{busy:s,error:c,run:l}=F(),u=s?()=>void 0:a;return(0,I.jsxs)(h,{title:e,onClose:u,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{ref:o,onClick:u,"aria-disabled":s,children:`Cancel`}),(0,I.jsx)(S,{variant:r?`danger`:`primary`,"aria-disabled":s,onClick:()=>void l(i,`It did not work`),children:s?`Working…`:n})]}),initialFocus:o,busy:s,children:[(0,I.jsx)(`div`,{className:`setup-confirm`,children:t}),c&&(0,I.jsx)(R,{text:c})]})}function R({text:e}){return(0,I.jsx)(`p`,{role:`alert`,className:`setup-note setup-note--error`,children:e})}function Ot({id:e,label:t,hint:n,children:r}){return(0,I.jsxs)(`div`,{className:`setup-field`,children:[(0,I.jsx)(`label`,{htmlFor:e,children:t}),r,n&&(0,I.jsx)(`span`,{id:`${e}-hint`,className:`setup-hint`,children:n})]})}function z({label:e,value:t,onChange:n,disabled:r=!1,hint:i,type:a=`text`,placeholder:o}){let s=(0,j.useId)();return(0,I.jsx)(Ot,{id:s,label:e,hint:i,children:(0,I.jsx)(`input`,{id:s,type:a,className:`setup-input`,value:t,disabled:r,placeholder:o,"aria-describedby":i?`${s}-hint`:void 0,onChange:e=>n(e.target.value)})})}function B({label:e,value:t,onChange:n,disabled:r=!1,hint:i,options:a}){let o=(0,j.useId)(),s=e=>{let t=a.find(t=>t.value===e);t&&n(t.value)};return(0,I.jsx)(Ot,{id:o,label:e,hint:i,children:(0,I.jsx)(`select`,{id:o,className:`setup-input`,value:t,disabled:r,"aria-describedby":i?`${o}-hint`:void 0,onChange:e=>s(e.target.value),children:a.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})})}function kt({label:e,checked:t,onChange:n}){return(0,I.jsxs)(`label`,{className:`setup-check`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),e]})}function At({provider:e}){return(0,I.jsxs)(`div`,{className:`ai-card-title`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:N(e)}),(0,I.jsx)(`span`,{className:`setup-muted`,children:_t(e)})]})}function jt({provider:e,onRemoved:t,onClose:n}){let r=g();async function i(){t(await ye(e)),r({text:`Removed the saved key for ${N(e)}.`}),n()}return(0,I.jsx)(L,{title:`Remove the key for ${N(e)}?`,confirmLabel:`Remove key`,danger:!0,onConfirm:i,onClose:n,children:(0,I.jsx)(`p`,{children:`The key saved here is deleted, and it cannot be shown again: you would have to paste it anew. A key set up by your developer is not touched.`})})}function Mt({status:e,actions:t}){let n=M(e.provider),[r,i]=(0,j.useState)(e.model??``),[a,o]=(0,j.useState)(e.baseUrl??``),s=e.provider===mt;return(0,I.jsxs)(`details`,{className:`ai-advanced`,children:[(0,I.jsx)(`summary`,{children:`Advanced`}),(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsx)(z,{label:`Model`,value:s?n?.defaultModel??``:r,onChange:i,disabled:s,placeholder:n?.defaultModel,hint:s?`Fixed: this one runs a single model.`:`Empty uses the default model.`}),(0,I.jsx)(z,{label:`Address`,type:`url`,value:a,onChange:o,placeholder:n?.baseUrl,hint:`Only for a proxy or your own server. Empty uses the usual address.`}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(S,{"aria-disabled":t.busy,onClick:()=>t.save({provider:e.provider,model:r,baseUrl:a}),children:`Save`})})]})]})}function Nt({status:e,actions:t,readOnly:n,onChange:r}){let[i,a]=(0,j.useState)(!1),o=t.busy?`Working…`:null;return(0,I.jsxs)(`li`,{className:`ai-card ai-card--on`,children:[(0,I.jsxs)(`div`,{className:`ai-card-head`,children:[(0,I.jsx)(At,{provider:e.provider}),e.active&&(0,I.jsx)(y,{tone:`success`,icon:xe,children:`In use`})]}),(0,I.jsx)(`p`,{className:`setup-note`,children:wt(e.keySource)}),!n&&(0,I.jsxs)(`div`,{className:`setup-actions`,children:[!e.active&&(0,I.jsx)(T,{variant:`primary`,icon:at,reason:o,onClick:()=>t.use(e.provider),children:`Use this one`}),(0,I.jsx)(T,{icon:rt,reason:o,onClick:()=>t.test(e.provider),children:`Test`}),e.keySource===`saved`&&(0,I.jsx)(S,{variant:`ghost`,icon:w,onClick:()=>a(!0),children:`Remove key`})]}),!n&&(0,I.jsx)(Mt,{status:e,actions:t}),i&&(0,I.jsx)(jt,{provider:e.provider,onRemoved:r,onClose:()=>a(!1)})]})}function Pt({status:e,actions:t}){let[n,r]=(0,j.useState)(``),i=N(e.provider),a=()=>{t.turnOn({provider:e.provider,apiKey:n}),r(``)},o=t.busy?`Working…`:n.trim()===``?`Paste the key first.`:null;return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`div`,{className:`ai-card-head`,children:(0,I.jsx)(At,{provider:e.provider})}),(0,I.jsx)(z,{label:`${i} key`,type:`password`,value:n,onChange:r,hint:`Paste the key from ${_t(e.provider)}. It is saved encrypted and never shown again.`}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(T,{variant:`primary`,icon:$e,reason:o,onClick:a,children:`Turn on`})})]})}function Ft({status:e}){return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:N(e.provider)}),(0,I.jsxs)(`p`,{className:`setup-note`,children:[`Runs on your Claude subscription, on your own machine only. Set the token`,` `,(0,I.jsx)(`code`,{children:`claude setup-token`}),` prints as `,(0,I.jsx)(`code`,{children:e.env}),`, and restart the site.`]})]})}function It({status:e,actions:t}){let n=M(e.provider),[r,i]=(0,j.useState)(``),[a,o]=(0,j.useState)(``);return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:N(e.provider)}),(0,I.jsx)(`p`,{className:`setup-note`,children:`Runs a model on your own computer. It needs no key.`}),(0,I.jsx)(z,{label:`Model`,value:r,onChange:i,placeholder:n?.defaultModel}),(0,I.jsx)(z,{label:`Address`,type:`url`,value:a,onChange:o,placeholder:n?.baseUrl}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(S,{variant:`primary`,"aria-disabled":t.busy,onClick:()=>t.save({provider:e.provider,model:r,baseUrl:a,use:!0}),children:`Turn on`})})]})}function Lt({status:e,actions:t}){return e.provider===`claude-code`?(0,I.jsx)(Ft,{status:e}):e.provider===`ollama`?(0,I.jsx)(It,{status:e,actions:t}):(0,I.jsx)(Pt,{status:e,actions:t})}function Rt({settings:e,providers:t,actions:n}){let r=e.providers.filter(e=>e.env!==``);return(0,I.jsxs)(`details`,{className:`ai-developer`,children:[(0,I.jsx)(`summary`,{children:`For developers`}),(0,I.jsxs)(`div`,{className:`setup-stack`,children:[t.length>0&&(0,I.jsx)(`ul`,{className:`ai-cards`,children:t.map(e=>(0,I.jsx)(Lt,{status:e,actions:n},e.provider))}),(0,I.jsxs)(`div`,{className:`setup-prose`,children:[(0,I.jsx)(`p`,{children:`A key can also be set in the environment of the machine that runs the site. A provider with a key there turns on at the next start, and no key is saved in the database.`}),(0,I.jsx)(`ul`,{className:`ai-variables`,children:r.map(e=>(0,I.jsxs)(`li`,{children:[N(e.provider),`: `,(0,I.jsx)(`code`,{children:e.env})]},e.provider))})]})]})]})}var zt={config:{icon:Ze,label:`Configuration`},database:{icon:Ye,label:`Database`},server:{icon:_e,label:`Server`}};function V({source:e,children:t}){let{icon:n,label:r}=zt[e];return(0,I.jsxs)(`p`,{className:`setup-source`,children:[(0,I.jsx)(y,{icon:n,children:r}),(0,I.jsx)(`span`,{children:t})]})}function H({title:e,sources:t,actions:n,children:r}){let i=(0,j.useId)();return(0,I.jsxs)(`section`,{className:`setup-section`,"aria-labelledby":i,children:[(0,I.jsxs)(`div`,{className:`setup-section-head`,children:[(0,I.jsx)(`h2`,{id:i,className:`setup-section-title`,children:e}),n&&(0,I.jsx)(`div`,{className:`setup-actions`,children:n})]}),(0,I.jsx)(`div`,{className:`setup-sources`,children:t}),r]})}function U({children:e,tone:t=`muted`}){return(0,I.jsx)(`p`,{className:t===`error`?`setup-note setup-note--error`:`setup-note`,children:e})}function W({what:e}){return(0,I.jsxs)(U,{children:[`Reading `,e,`…`]})}function G({message:e,onRetry:t}){return(0,I.jsxs)(`div`,{role:`alert`,className:`setup-row`,children:[(0,I.jsx)(U,{tone:`error`,children:e}),(0,I.jsx)(S,{size:`sm`,icon:we,onClick:t,children:`Try again`})]})}var Bt=new Map([[je,`Fill missing SEO`],[ke,`Meta only`],[Oe,`Force regenerate`]]);function Vt(e){return e.scope===`collection`?`${D(e.collection)}`:`the whole site`}function Ht(e){let t=e.state===`idle`?`Enrichment`:Bt.get(e.plan)??`Enrichment`;return e.state===`failed`?{text:`${t} failed: ${e.message}`,tone:`error`}:{text:`${t} finished. Setup › AI provider lists what each step did.`}}function Ut(){return(0,I.jsxs)(`div`,{className:`setup-prose`,children:[(0,I.jsxs)(`p`,{children:[(0,I.jsx)(`strong`,{children:`Fill missing SEO`}),` writes meta descriptions and the Schema.org properties no one has set. `,(0,I.jsx)(`strong`,{children:`Meta only`}),` writes only the missing meta descriptions. Neither overwrites a value someone set. `,(0,I.jsx)(`strong`,{children:`Force regenerate`}),` writes both over every value, the editors' own included.`]}),(0,I.jsx)(`p`,{children:`What a run writes is saved at once: each meta description as a new version of its document and in the document's SEO settings, the Schema.org properties in those settings. The SEO settings have no versions, so the live pages' meta descriptions and structured data change straight away. A document someone else is editing keeps its meta description.`})]})}function Wt({scope:e,model:t,onConfirm:n,onClose:r}){return(0,I.jsxs)(L,{title:`Force regenerate SEO for ${Vt(e)}?`,confirmLabel:`Overwrite and regenerate`,danger:!0,onConfirm:n,onClose:r,children:[(0,I.jsxs)(`p`,{children:[t,` writes a new meta description and new Schema.org properties for every document in`,` `,Vt(e),`. It`,` `,(0,I.jsx)(`strong`,{children:`overwrites the values there now, the editors' own included`}),`.`]}),(0,I.jsx)(`p`,{children:`Each meta description is saved as a new version of its document and in the document's SEO settings; the Schema.org properties are written to those settings, which have no versions. The live pages' meta descriptions and structured data change at once: this is not a draft, there is nothing to publish first, and the SEO settings keep no earlier values to go back to. A document someone else is editing keeps its meta description.`})]})}function Gt(e,t,n){return e.state===`running`?`Enrichment is running.`:t?n?null:`Add an AI key first.`:`Enrichment is run by an admin.`}function Kt({reason:e,onRun:t,onForce:n}){return(0,I.jsxs)(`div`,{className:`setup-actions`,children:[(0,I.jsx)(T,{variant:`primary`,icon:Me,reason:e,onClick:()=>t(je),children:`Fill missing SEO`}),(0,I.jsx)(T,{icon:Te,reason:e,onClick:()=>t(ke),children:`Meta only`}),(0,I.jsx)(T,{variant:`danger`,icon:st,reason:e,onClick:n,children:`Force regenerate…`})]})}function qt(){let{loaded:e}=x(te,`The collections could not be read`);return e.state===`ready`?e.data.filter(e=>e.pages):[]}var Jt=(0,I.jsx)(V,{source:`database`,children:`Writes to the documents and their SEO settings in the site's database, with the AI in use above.`});function Yt({configured:e,admin:t,model:n}){let r=g(),o=Ae(),s=qt(),[c,l]=(0,j.useState)({scope:`all`}),[u,d]=(0,j.useState)(!1);(0,j.useEffect)(()=>()=>De(),[]);let f=(0,j.useCallback)(e=>Ee(c,e=>r(Ht(e)),e),[c,r]),p=Gt(o,t,e),m=o.state===`running`;return(0,I.jsxs)(H,{title:`Run across the site`,sources:Jt,children:[(0,I.jsx)(Ut,{}),(0,I.jsx)(i,{collections:s,value:c,disabled:m,onChange:l}),(0,I.jsx)(Kt,{reason:p,onRun:f,onForce:()=>d(!0)}),p&&!m&&(0,I.jsx)(`p`,{className:`setup-note`,children:p}),(0,I.jsx)(a,{run:o}),u&&(0,I.jsx)(Wt,{scope:c,model:n,onClose:()=>d(!1),onConfirm:async()=>{d(!1),f(Oe)||r({text:`Another run is going across the site, so Force regenerate did not start. Try again when it ends.`,tone:`error`})}})]})}function Xt({settings:e,readOnly:t,onChange:n}){let r=Dt(n),i=yt(e),a=bt(e);return(0,I.jsxs)(I.Fragment,{children:[i.length>0&&(0,I.jsxs)(`section`,{className:`ai-group`,"aria-labelledby":`ai-configured`,children:[(0,I.jsx)(`h3`,{id:`ai-configured`,className:`ai-group-title`,children:`Ready to use`}),(0,I.jsx)(`ul`,{className:`ai-cards`,children:i.map(e=>(0,I.jsx)(Nt,{status:e,actions:r,readOnly:t,onChange:n},e.provider))})]}),!t&&a.length>0&&(0,I.jsxs)(`section`,{className:`ai-group`,"aria-labelledby":`ai-available`,children:[(0,I.jsx)(`h3`,{id:`ai-available`,className:`ai-group-title`,children:i.length>0?`Add another`:`Add a key to turn one on`}),(0,I.jsx)(`ul`,{className:`ai-cards`,children:a.map(e=>(0,I.jsx)(Pt,{status:e,actions:r},e.provider))})]}),!t&&(0,I.jsx)(Rt,{settings:e,providers:xt(e),actions:r})]})}function Zt(){let e=b().hasRole(`admin`),{loaded:t,reload:n}=x(m,`The AI provider could not be read`),[r,i]=(0,j.useState)(null);if(t.state===`loading`)return(0,I.jsx)(W,{what:`the AI provider`});if(t.state===`error`)return(0,I.jsx)(G,{message:t.message,onRetry:n});let a=r??t.data;return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsxs)(H,{title:`AI help`,sources:(0,I.jsx)(`p`,{className:`setup-source`,children:`An AI turns on when it has a key. Pick the one the site uses; the assistant lets editors pick another.`}),children:[(0,I.jsx)(`p`,{className:a.configured?`ai-status ai-status--on`:`ai-status`,role:`status`,children:St(a,e)}),(0,I.jsx)(Xt,{settings:a,readOnly:!e,onChange:i}),a.assistantProvider&&(0,I.jsxs)(`p`,{className:`setup-note`,children:[`The assistant is set to `,N(a.assistantProvider),` in the site's configuration.`]})]}),(0,I.jsx)(Yt,{configured:a.configured,admin:e,model:Ct(a)})]})}var Qt={manual:`By hand`,"pre-restore":`Before a restore`,"pre-migration":`Before a migration`,"pre-import":`Before an import`};function K(e){return e.name?`v${e.version} · ${e.name}`:`v${e.version}`}function $t({checkpoint:e,onDone:t,onClose:n}){let r=g(),i=K(e);async function a(){await se(e.version),r({text:`Restored ${i}. A safety checkpoint of the state before was taken first.`}),t()}return(0,I.jsxs)(L,{title:`Restore ${i}?`,confirmLabel:`Restore checkpoint`,danger:!0,onConfirm:a,onClose:n,children:[(0,I.jsxs)(`p`,{children:[`Every document — the version being edited and the version that is live — the runtime fields and the media library's records go back to how they stood at`,` `,E(e.createdAt),`. Versions saved since stay in each document's history but are no longer current.`]}),(0,I.jsxs)(`p`,{children:[`A safety checkpoint, `,(0,I.jsxs)(`code`,{children:[`pre-restore-v`,e.version]}),`, is taken first, so you can return to how things are now. Settings, SEO configuration and people are not rewound.`]}),(0,I.jsx)(`p`,{children:`Every cached page is marked stale: its next visit may still get the old page while it is rendered again.`})]})}function en({checkpoint:e,onDone:t,onClose:n}){let r=g(),i=K(e);async function a(){await ve(e.version),r({text:`Deleted ${i}.`}),t()}return(0,I.jsx)(L,{title:`Delete ${i}?`,confirmLabel:`Delete checkpoint`,danger:!0,onConfirm:a,onClose:n,children:(0,I.jsx)(`p`,{children:`It can no longer be restored. The content stays as it is.`})})}function tn(e,t){return[{id:`name`,header:`Checkpoint`,primary:!0,cell:e=>K(e)},{id:`trigger`,header:`Taken`,cell:e=>(0,I.jsx)(y,{children:Qt[e.trigger]})},{id:`created`,header:`Created`,cell:e=>E(e.createdAt)},{id:`actions`,header:`Actions`,cell:n=>e?(0,I.jsxs)(`span`,{className:`setup-row-actions`,children:[(0,I.jsx)(S,{size:`sm`,icon:oe,"aria-label":`Restore ${K(n)}`,onClick:()=>t({kind:`restore`,checkpoint:n}),children:`Restore`}),(0,I.jsx)(S,{size:`sm`,variant:`ghost`,icon:w,"aria-label":`Delete ${K(n)}`,onClick:()=>t({kind:`delete`,checkpoint:n}),children:`Delete`})]}):null}]}function nn({onCreated:e}){let t=g(),[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(!1);async function s(){if(!o.current){o.current=!0,a(!0);try{let i=await ae(n.trim()||void 0);t({text:`Created ${K(i)}.`}),r(``),e()}catch(e){t({text:_(e,`The checkpoint could not be created`),tone:`error`})}finally{o.current=!1,a(!1)}}}return(0,I.jsxs)(`form`,{className:`setup-inline-form`,onSubmit:e=>{e.preventDefault(),i||s()},children:[(0,I.jsx)(z,{label:`Name`,value:n,onChange:r,placeholder:`Before the spring relaunch`,hint:`Optional`}),(0,I.jsx)(S,{type:`submit`,variant:`primary`,icon:de,"aria-disabled":i,children:i?`Creating…`:`Create checkpoint`})]})}function rn(){return(0,I.jsx)(V,{source:`database`,children:`Stored in the site's database. A checkpoint marks a point in time and copies nothing; restoring one rewinds to it. The API lists each checkpoint's number, name, what took it and when — not its size or the schema version it was taken under.`})}function an(){let{hasRole:e}=b(),{loaded:t,reload:n}=x(be,`The checkpoints could not be read`),[r,i]=(0,j.useState)(null),a=()=>i(null),o=()=>{a(),n()};return(0,I.jsxs)(H,{title:`Checkpoints`,sources:(0,I.jsx)(rn,{}),children:[e(`editor`)?(0,I.jsx)(nn,{onCreated:n}):(0,I.jsx)(U,{children:`Editors and admins create checkpoints.`}),t.state===`loading`&&(0,I.jsx)(W,{what:`the checkpoints`}),t.state===`error`&&(0,I.jsx)(G,{message:t.message,onRetry:n}),t.state===`ready`&&t.data.length===0&&(0,I.jsx)(Le,{icon:de,title:`No checkpoints yet`,children:`Create one to mark the content store as it is now, so you can return to it.`}),t.state===`ready`&&t.data.length>0&&(0,I.jsx)(O,{caption:`Checkpoints, newest first`,columns:tn(e(`admin`),i),rows:t.data,rowKey:e=>String(e.version)}),r?.kind===`restore`&&(0,I.jsx)($t,{checkpoint:r.checkpoint,onDone:o,onClose:a}),r?.kind===`delete`&&(0,I.jsx)(en,{checkpoint:r.checkpoint,onDone:o,onClose:a})]})}async function on(e){let[t,n,r]=await Promise.all([te(),Ve(e,Se),Ve(e,async()=>(await Ce()).types)]);return{collections:t,configs:n,catalog:r}}function sn(e,t){return e.state===`ok`?e.value.find(e=>e.id===`collection:${t}`)?.config.entities.map(e=>e[`@type`])??[]:null}function cn(e,t){if(e.state!==`ok`||t===null)return null;let n=e.value.filter(e=>t.includes(e.type)&&e.richResult!==null).filter(e=>e.richResultStatus===`active`||e.richResultStatus===`restricted`).map(e=>e.richResult??``);return[...new Set(n)]}function ln(e){return e.collections.map(t=>{let n=t.pages?sn(e.configs,t.name):[];return{collection:t,rendersAt:pe(t,`:slug`),types:n,richResults:t.pages?cn(e.catalog,n):[]}})}function un(e){return e==null?null:typeof e==`string`?e:JSON.stringify(e)}function dn(e){return e.enum?`enum`:e.format===`uri`?`url`:e.format===`email`?`email`:String(e.type??`string`)}function fn(e,t){let n=new Set(e.schema.required??[]),r=Object.entries(e.schema.properties??{}).filter(([,e])=>!(Be(e)&&e._runtime)).map(([e,t])=>({name:e,type:dn(t),required:n.has(e),description:t.description??null,defaultValue:un(t.default),source:`code`,runtime:null})),i=t.map(e=>({name:e.name,type:e.type,required:e.required,description:e.description??null,defaultValue:un(e.default),source:`runtime`,runtime:e}));return[...r,...i]}var pn=[`string`,`textarea`,`number`,`boolean`,`date`,`enum`,`url`,`email`,`color`,`reference`],mn={string:`text (one line)`,textarea:`text (long)`,number:`number`,boolean:`yes/no`,date:`date`,enum:`choice`,url:`web address`,email:`email`,color:`color`,reference:`link to a page`,integer:`number`,array:`list`,object:`group`};function hn(e){return mn[e]??e}var q=e=>e==null?``:String(e);function gn(e){return{name:e?.name??``,type:e?.type??`string`,required:e?.required??!1,description:e?.description??``,defaultValue:q(e?.default),enumValues:e?.enumValues?.join(`, `)??``,refCollection:e?.refCollection??``,min:q(e?.min),max:q(e?.max),pattern:e?.pattern??``}}function J(e){return e===`string`||e===`textarea`||e===`number`}function _n(e){let t=e.defaultValue.trim();if(t)return e.type===`number`?Number(t):e.type===`boolean`?t===`true`:t}function Y(e){return e.enumValues.split(`,`).map(e=>e.trim()).filter(Boolean)}function vn(e){let t=e.defaultValue.trim();return t?e.type===`number`&&!Number.isFinite(Number(t))?`The default is a number.`:e.type===`boolean`&&t!==`true`&&t!==`false`?`The default is true or false.`:e.type===`enum`&&!Y(e).includes(t)?`The default is one of the values.`:null:null}function yn(e){if(!J(e.type))return null;let[t,n]=[e.min.trim(),e.max.trim()];return[t,n].some(e=>e&&!Number.isFinite(Number(e)))?`Minimum and maximum are numbers.`:t&&n&&Number(t)>Number(n)?`The minimum is not above the maximum.`:null}function bn(e){let t=e.pattern.trim();if(e.type!==`string`||!t)return null;try{return new RegExp(t),null}catch{return`The pattern is not a valid regular expression.`}}function xn(e){let t=e.name.trim();return t?/^[a-z][a-z0-9_-]*$/i.test(t)?e.type===`reference`&&!e.refCollection?`Choose the collection it refers to.`:e.type===`enum`&&new Set(Y(e)).size<2?`Give the enum two different values or more.`:yn(e)??bn(e)??vn(e):`A name starts with a letter and holds only letters, digits, hyphens and underscores.`:`A field needs a name.`}function Sn(e){let t=Y(e),n={name:e.name.trim(),type:e.type,required:e.required},r=_n(e);return r!==void 0&&(n.default=r),e.description.trim()&&(n.description=e.description.trim()),e.type===`enum`&&t.length>0&&(n.enumValues=t),e.type===`reference`&&(n.refCollection=e.refCollection),J(e.type)&&e.min.trim()&&(n.min=Number(e.min)),J(e.type)&&e.max.trim()&&(n.max=Number(e.max)),e.type===`string`&&e.pattern.trim()&&(n.pattern=e.pattern.trim()),n}var Cn=pn.map(e=>({value:e,label:hn(e)}));function wn({form:e,set:t}){let n=e.type===`number`;return(0,I.jsxs)(`div`,{className:`setup-field-row`,children:[(0,I.jsx)(z,{label:n?`Minimum`:`Minimum length`,type:`number`,value:e.min,onChange:t(`min`)}),(0,I.jsx)(z,{label:n?`Maximum`:`Maximum length`,type:`number`,value:e.max,onChange:t(`max`)})]})}function Tn(e){let{form:t,set:n,collections:r}=e,i=[{value:``,label:`Choose a collection`},...r.map(e=>({value:e.name,label:D(e.name)}))];return(0,I.jsxs)(I.Fragment,{children:[t.type===`enum`&&(0,I.jsx)(z,{label:`Values`,value:t.enumValues,onChange:n(`enumValues`),hint:`Separated by commas`}),t.type===`reference`&&(0,I.jsx)(B,{label:`Refers to`,value:t.refCollection,options:i,onChange:n(`refCollection`)}),J(t.type)&&(0,I.jsx)(wn,{form:t,set:n}),t.type===`string`&&(0,I.jsx)(z,{label:`Pattern`,value:t.pattern,onChange:n(`pattern`),hint:`A regular expression the value must match`})]})}function En({form:e,set:t,editing:n,collections:r}){let i=n?`A field keeps its name`:`The key documents store its value under`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{label:`Name`,value:e.name,onChange:t(`name`),disabled:n,hint:i}),(0,I.jsx)(B,{label:`Type`,value:e.type,options:Cn,onChange:t(`type`),disabled:n,hint:n?`A field keeps its type`:void 0}),(0,I.jsx)(kt,{label:`Required`,checked:e.required,onChange:t(`required`)}),(0,I.jsx)(z,{label:`Description`,value:e.description,onChange:t(`description`),hint:`Shown to editors under the field`}),(0,I.jsx)(z,{label:`Default`,value:e.defaultValue,onChange:t(`defaultValue`)}),(0,I.jsx)(Tn,{form:e,set:t,collections:r})]})}function Dn(e){let{collection:t,field:n,collections:r,onSave:i,onClose:a}=e,o=(0,j.useId)(),[s,c]=(0,j.useState)(()=>gn(n)),l=e=>t=>c(n=>({...n,[e]:t})),{busy:u,error:d,setError:f,run:p}=F();function m(e){e.preventDefault();let t=xn(s);t?f(t):p(()=>i(Sn(s)),`The field could not be saved`)}let ee=n?`Edit ${n.name}`:`Add a runtime field to ${D(t)}`;return(0,I.jsx)(h,{title:ee,onClose:a,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{onClick:a,children:`Cancel`}),(0,I.jsx)(S,{variant:`primary`,type:`submit`,form:o,"aria-disabled":u,children:u?`Saving…`:`Save field`})]}),busy:u,children:(0,I.jsxs)(`form`,{id:o,className:`setup-form`,onSubmit:m,children:[d&&(0,I.jsx)(R,{text:d}),(0,I.jsx)(En,{form:s,set:l,editing:n!==null,collections:r})]})})}function On(e){let t=g();return async()=>{if(e!==null)try{await navigator.clipboard.writeText(e),t({text:`Copied the Zod schema.`})}catch{t({text:`The browser did not allow copying; select the code instead.`,tone:`error`})}}}function kn({collection:e,onClose:t}){let n=(0,j.useCallback)(async()=>(await p(e)).code,[e]),{loaded:r,reload:i}=x(n,`The schema could not be exported`),a=r.state===`ready`?r.data:null,o=On(a),s=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{onClick:t,children:`Close`}),(0,I.jsx)(S,{variant:`primary`,icon:Ue,"aria-disabled":a===null,onClick:()=>void o(),children:`Copy`})]});return(0,I.jsxs)(h,{title:`${D(e)} as Zod`,onClose:t,actions:s,children:[(0,I.jsxs)(`p`,{className:`setup-note`,children:[`The code fields and the runtime fields as one Zod schema. Paste it into`,` `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),` to make the runtime fields part of the code; code always wins over a runtime field of the same name.`]}),r.state===`loading`&&(0,I.jsx)(W,{what:`the schema`}),r.state===`error`&&(0,I.jsx)(G,{message:r.message,onRetry:i}),a!==null&&(0,I.jsx)(`section`,{className:`setup-code`,"aria-label":`Zod schema`,tabIndex:0,children:(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{children:a})})})]})}function An({field:e,onDialog:t}){return(0,I.jsxs)(`span`,{className:`setup-row-actions`,children:[(0,I.jsx)(S,{size:`sm`,icon:He,"aria-label":`Edit ${e.name}`,onClick:()=>t({kind:`edit`,field:e}),children:`Edit`}),(0,I.jsx)(S,{size:`sm`,variant:`ghost`,icon:w,"aria-label":`Delete ${e.name}`,onClick:()=>t({kind:`delete`,field:e}),children:`Delete`})]})}function jn({field:e,admin:t,onDialog:n}){return e.runtime?t?(0,I.jsx)(An,{field:e.runtime,onDialog:n}):(0,I.jsx)(`span`,{className:`setup-muted`,children:`Admins edit runtime fields`}):(0,I.jsxs)(`span`,{className:`setup-locked`,children:[(0,I.jsx)(ce,{"aria-hidden":`true`}),`Defined in code, change it in `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`; code always wins`]})}function Mn(e,t){return[{id:`field`,header:`Field`,primary:!0,cell:e=>(0,I.jsxs)(`span`,{className:`setup-name`,children:[(0,I.jsx)(`code`,{children:e.name}),e.description&&(0,I.jsx)(`span`,{className:`setup-muted`,children:e.description})]})},{id:`type`,header:`Type`,cell:e=>hn(e.type)},{id:`required`,header:`Required`,cell:e=>e.required?`Required`:`Optional`},{id:`default`,header:`Default`,cell:e=>e.defaultValue?(0,I.jsx)(`code`,{children:e.defaultValue}):`—`},{id:`source`,header:`Source`,cell:e=>e.source===`code`?(0,I.jsx)(y,{icon:ce,children:`Code`}):(0,I.jsx)(y,{tone:`accent`,children:`Runtime`})},{id:`edit`,header:`Edit`,cell:n=>(0,I.jsx)(jn,{field:n,admin:e,onDialog:t})}]}function Nn(e){let t=(0,j.useCallback)(async()=>{let[t,n]=await Promise.all([c(e),ne(e)]);return fn(t,n.fields)},[e]);return x(t,`The fields could not be read`)}function Pn({admin:e,onDialog:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{icon:Ze,onClick:()=>t({kind:`export`}),children:`Export as Zod`}),e&&(0,I.jsx)(S,{variant:`primary`,icon:me,onClick:()=>t({kind:`edit`,field:null}),children:`Add runtime field`})]})}function Fn({collection:e,collections:t,admin:n}){let{loaded:r,reload:i}=Nn(e),[a,o]=(0,j.useState)(null),s=D(e),c=(0,I.jsx)(Pn,{admin:n,onDialog:o});return(0,I.jsxs)(H,{title:`Fields of ${s}`,actions:c,sources:(0,I.jsx)(In,{}),children:[r.state===`loading`&&(0,I.jsx)(W,{what:`the fields`}),r.state===`error`&&(0,I.jsx)(G,{message:r.message,onRetry:i}),r.state===`ready`&&(0,I.jsx)(O,{caption:`Fields of ${s}`,columns:Mn(n,o),rows:r.data,rowKey:e=>`${e.source}:${e.name}`}),a&&(0,I.jsx)(Rn,{collection:e,collections:t,dialog:a,onClose:()=>o(null),onChanged:i})]})}function In(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{source:`config`,children:[`Code fields come from the collection's Zod schema in `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`, read-only here.`]}),(0,I.jsx)(V,{source:`database`,children:`Runtime fields are stored in the site's database: added, edited and deleted here, and added to the collection's form at once.`})]})}function Ln({collection:e,name:t,onDone:n,onClose:r}){return(0,I.jsxs)(L,{title:`Delete the field ${t}?`,confirmLabel:`Delete field`,danger:!0,onConfirm:async()=>{await l(e,t),n(`Deleted the runtime field ${t}.`)},onClose:r,children:[(0,I.jsxs)(`p`,{children:[`The runtime field `,(0,I.jsx)(`code`,{children:t}),` is removed from `,D(e),`'s schema, so its form no longer shows it.`]}),(0,I.jsx)(`p`,{children:`Only the schema changes. Documents keep the values they already hold in the field; the form no longer shows them.`})]})}function Rn(e){let{collection:t,collections:n,dialog:r,onClose:i,onChanged:a}=e,o=g(),s=e=>{o({text:e}),i(),a()};return r.kind===`export`?(0,I.jsx)(kn,{collection:t,onClose:i}):r.kind===`delete`?(0,I.jsx)(Ln,{collection:t,name:r.field.name,onDone:s,onClose:i}):(0,I.jsx)(Dn,{collection:t,field:r.field,collections:n,onSave:async e=>{await ie(t,e),s(`Saved the runtime field ${e.name}.`)},onClose:i})}var X=`collection`;function zn({names:e,none:t}){return e===null?(0,I.jsx)(`span`,{className:`setup-muted`,children:`Not read`}):e.length===0?(0,I.jsx)(`span`,{className:`setup-muted`,children:t}):(0,I.jsx)(`span`,{className:`setup-chips`,children:e.map(e=>(0,I.jsx)(y,{children:e},e))})}function Bn({name:e}){return(0,I.jsxs)(`span`,{className:`setup-name`,children:[D(e),(0,I.jsx)(`code`,{className:`setup-muted`,children:e})]})}function Vn({name:e,open:t,onFields:n}){return(0,I.jsx)(S,{size:`sm`,icon:tt,variant:t?`primary`:`secondary`,"aria-label":`Fields of ${D(e)}`,"aria-pressed":t,onClick:()=>n(e),children:`Fields`})}function Hn(e,t){return[{id:`collection`,header:`Collection`,primary:!0,cell:e=>(0,I.jsx)(Bn,{name:e.collection.name})},{id:`renders`,header:`Renders at`,cell:e=>e.rendersAt?(0,I.jsx)(`code`,{children:e.rendersAt}):(0,I.jsx)(`span`,{className:`setup-muted`,children:`No pages`})},{id:`types`,header:`Schema.org types`,cell:e=>(0,I.jsx)(zn,{names:e.types,none:`None set`})},{id:`rich`,header:`Rich results`,cell:e=>(0,I.jsx)(zn,{names:e.richResults,none:`None`})},{id:`fields`,header:`Fields`,cell:n=>(0,I.jsx)(Vn,{name:n.collection.name,open:e===n.collection.name,onFields:t})}]}function Un({seo:e}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{source:`config`,children:[`The collections and where they render come from `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`, read-only here.`]}),e&&(0,I.jsxs)(V,{source:`database`,children:[`The Schema.org types are each collection's archetype, set in`,` `,(0,I.jsx)(ze,{to:f(`collection`),children:`Structure › Scopes & archetypes`}),`. The rich results are what the catalog says those types are eligible for.`]})]})}function Wn(){let[e,t]=Re(),n=e.get(X),r=(0,j.useRef)(null),i=(0,j.useRef)(!1);return(0,j.useEffect)(()=>{n&&i.current&&r.current?.focus(),i.current=!1},[n]),{open:n,onFields:(0,j.useCallback)(e=>{i.current=!0,t({[X]:e},{replace:!0})},[t]),ref:r}}function Gn(){let e=Ie(Ne(),`seo`),t=b().hasRole(`admin`),n=(0,j.useCallback)(()=>on(e),[e]),{loaded:r,reload:i}=x(n,`The collections could not be read`),{open:a,onFields:o,ref:s}=Wn(),c=r.state===`ready`?r.data.collections:[],l=c.some(e=>e.name===a);return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsxs)(H,{title:`Collections & schema`,sources:(0,I.jsx)(Un,{seo:e}),children:[r.state===`loading`&&(0,I.jsx)(W,{what:`the collections`}),r.state===`error`&&(0,I.jsx)(G,{message:r.message,onRetry:i}),r.state===`ready`&&(0,I.jsx)(O,{caption:`Collections`,columns:Hn(a,o),rows:ln(r.data),rowKey:e=>e.collection.name})]}),a&&r.state===`ready`&&!l&&(0,I.jsxs)(U,{children:[`No collection is named `,a,`.`]}),a&&l&&(0,I.jsx)(`div`,{ref:s,tabIndex:-1,className:`setup-focus-target`,children:(0,I.jsx)(Fn,{collection:a,collections:c,admin:t},a)})]})}function Kn(e){return e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}function qn(e){let t=[],n=Pe(e);n&&t.push({name:`Framework`,value:n}),t.push({name:`Persistence`,value:e.persistence},{name:`Auth`,value:e.authMode}),e.schemaVersion!==null&&t.push({name:`Schema version`,value:`v${String(e.schemaVersion).padStart(3,`0`)}`});for(let[n,r]of Object.entries(e.features))t.push({name:Kn(n),value:r});return t}function Jn({value:e}){return(0,I.jsx)(y,{tone:e===`disabled`||e===`none`?`neutral`:`success`,children:e})}var Yn=[{id:`name`,header:`Capability`,primary:!0,cell:e=>e.name},{id:`value`,header:`Value`,cell:e=>(0,I.jsx)(Jn,{value:e.value})}];function Xn(){let e=Ne();return(0,I.jsx)(H,{title:`Environment`,sources:(0,I.jsxs)(V,{source:`server`,children:[`What the running server reports (`,(0,I.jsx)(`code`,{children:`GET /api/capabilities`}),`), read-only. It follows the configuration and the persistence the server started with.`]}),children:(0,I.jsx)(O,{caption:`What the server reports`,columns:Yn,rows:qn(e),rowKey:e=>e.name})})}var Zn=[{id:`all`,label:`All`},{id:`pending`,label:`Pending`},{id:`delivered`,label:`Delivered`},{id:`failed`,label:`Failed`}];function Qn(e){return e.deliveredAt?`delivered`:e.attempts>=5?`failed`:`pending`}function $n(e){return e===null?`—`:e===0?`Network error`:String(e)}function er(e){switch(e){case`pending`:return`No delivery is waiting for another attempt.`;case`delivered`:return`No delivery has reached its webhook yet.`;case`failed`:return`No delivery has failed.`;default:return`Nothing has been sent yet.`}}function tr(e,t){let n=Math.ceil(t/25);return n>1?`Page ${e+1} of ${n}`:null}var nr={delivered:(0,I.jsx)(y,{tone:`success`,icon:he,children:`Delivered`}),pending:(0,I.jsx)(y,{tone:`warning`,icon:We,children:`Pending`}),failed:(0,I.jsx)(y,{tone:`danger`,icon:ue,children:`Failed`})};function rr(e,t){return[{id:`event`,header:`Event`,primary:!0,cell:e=>(0,I.jsx)(`code`,{children:e.event})},{id:`url`,header:`URL`,cell:e=>(0,I.jsx)(`span`,{className:`setup-url`,children:e.url})},{id:`state`,header:`State`,cell:e=>nr[Qn(e)]},{id:`http`,header:`HTTP`,numeric:!0,cell:e=>$n(e.status)},{id:`attempts`,header:`Attempts`,numeric:!0,cell:e=>`${e.attempts} / 5`},{id:`created`,header:`Created`,cell:e=>E(e.createdAt)},{id:`delivered`,header:`Delivered`,cell:e=>e.deliveredAt?E(e.deliveredAt):`—`},{id:`retry`,header:`Retry`,cell:n=>Qn(n)===`failed`?(0,I.jsx)(S,{size:`sm`,icon:Ge,"aria-disabled":e!==null,"aria-label":`Retry delivery ${n.id} of ${n.event}`,onClick:e===null?()=>t(n):void 0,children:e===n.id?`Retrying…`:`Retry`}):null}]}function ir({filter:e,onFilter:t}){return(0,I.jsxs)(`fieldset`,{className:`setup-segmented`,children:[(0,I.jsx)(`legend`,{className:`visually-hidden`,children:`Show deliveries`}),Zn.map(n=>(0,I.jsx)(S,{size:`sm`,variant:e===n.id?`primary`:`secondary`,"aria-pressed":e===n.id,onClick:()=>t(n.id),children:n.label},n.id))]})}function ar(e){let t=g(),[n,r]=(0,j.useState)(null),i=(0,j.useRef)(null);return{retrying:n,retry:(0,j.useCallback)(n=>{i.current===null&&(i.current=n.id,r(n.id),re(n.id).then(()=>t({text:`Sent delivery ${n.id} again. It shows as pending until the webhook answers.`})).catch(e=>t({text:_(e,`The delivery could not be retried`),tone:`error`})).finally(()=>{i.current=null,r(null),e()}))},[e,t])}}function or({page:e,total:t,onPage:n}){let r=tr(e,t);if(!r)return null;let i=Math.ceil(t/25)-1;return(0,I.jsxs)(`nav`,{"aria-label":`Pages of deliveries`,className:`setup-row`,children:[(0,I.jsx)(S,{size:`sm`,"aria-disabled":e===0,onClick:e===0?void 0:()=>n(e-1),children:`Previous`}),(0,I.jsx)(`span`,{className:`setup-muted`,children:r}),(0,I.jsx)(S,{size:`sm`,"aria-disabled":e>=i,onClick:e>=i?void 0:()=>n(e+1),children:`Next`})]})}async function sr(e,t){let n=e===`all`?void 0:e;try{return await ge({limit:25,offset:t*25,status:n})}catch(e){if(e instanceof Ke&&e.status===403)return null;throw e}}function cr({filter:e,page:t,revision:n,onPage:r}){let i=(0,j.useCallback)(()=>sr(e,t),[e,t]),{loaded:a,reload:o}=x(i,`The deliveries could not be read`),s=(0,j.useRef)(n);(0,j.useEffect)(()=>{s.current!==n&&(s.current=n,o())},[n,o]);let{retrying:c,retry:l}=ar(o);if(a.state===`loading`)return(0,I.jsx)(W,{what:`the deliveries`});if(a.state===`error`)return(0,I.jsx)(G,{message:a.message,onRetry:o});if(a.data===null)return(0,I.jsx)(U,{children:`Only admins see webhook deliveries.`});let{deliveries:u,total:d}=a.data;return u.length===0?(0,I.jsx)(lr,{filter:e}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`setup-muted`,children:d===1?`1 delivery`:`${d} deliveries`}),(0,I.jsx)(O,{caption:`Webhook deliveries`,columns:rr(c,l),rows:u,rowKey:e=>String(e.id)}),(0,I.jsx)(or,{page:t,total:d,onPage:r})]})}function lr({filter:e}){return(0,I.jsxs)(Le,{icon:fe,title:`No webhook deliveries`,children:[er(e),` `,e===`all`&&(0,I.jsxs)(I.Fragment,{children:[`Each webhook the API is created with (`,(0,I.jsxs)(`code`,{children:[`createApiHandlers(`,`{ webhooks }`,`)`]}),`) logs a delivery here when content is created, updated, published or deleted.`]})]})}function ur(){let[e,t]=(0,j.useState)(`all`),[n,r]=(0,j.useState)(0),[i,a]=(0,j.useState)(0);return(0,I.jsxs)(H,{title:`Webhook deliveries`,actions:(0,I.jsx)(S,{size:`sm`,icon:we,onClick:()=>a(e=>e+1),children:`Refresh`}),sources:(0,I.jsx)(V,{source:`database`,children:`The delivery log in the site's database: every webhook sent, its answer and its attempts. Delivery logging runs on SQLite only.`}),children:[(0,I.jsx)(ir,{filter:e,onFilter:e=>{t(e),r(0)}}),(0,I.jsx)(cr,{filter:e,page:n,revision:i,onPage:r})]})}var Z=e=>`${e.collection}/${e.slug}/${e.locale}`;function dr({version:e,item:t,defaultLocale:n,canCreate:r,created:i,busy:a,onCreate:o}){let{collection:s,slug:c,locale:l}=e;return t.locales.includes(l)?(0,I.jsx)(y,{tone:`success`,icon:xe,children:`Exists`}):i.has(Z(e))?(0,I.jsxs)(ze,{to:ee(s,c,l),children:[`Open the `,l,` draft`]}):!r||!t.locales.includes(n)?(0,I.jsx)(y,{tone:`warning`,children:`Missing`}):(0,I.jsx)(S,{size:`sm`,icon:le,"aria-disabled":a!==null,"aria-label":`Create the ${l} draft of ${c}`,onClick:a===null?()=>o(e):void 0,children:a===Z(e)?`Creating…`:`Create draft`})}function fr(e,t,n){return[{id:`slug`,header:`Document`,primary:!0,cell:e=>(0,I.jsx)(`code`,{children:e.slug})},...e.map(e=>({id:`locale-${e}`,header:e===t.defaultLocale?`${e} (default)`:e,cell:r=>(0,I.jsx)(dr,{...t,item:r,version:{collection:n,slug:r.slug,locale:e}})}))]}function pr(e){let t=g(),[n,r]=(0,j.useState)(new Set),[i,a]=(0,j.useState)(null);return{created:n,busy:i,onCreate:(0,j.useCallback)(n=>{a(Z(n)),qe(n.collection,n.slug,n.locale,e).then(()=>{r(e=>new Set([...e,Z(n)])),t({text:`Created the ${n.locale} draft of ${n.slug}, copied from ${e}.`})}).catch(e=>t({text:_(e,`The draft could not be created`),tone:`error`})).finally(()=>a(null))},[e,t])}}function mr({status:e,locales:t,cell:n}){let r=D(e.collection);return(0,I.jsxs)(`div`,{className:`setup-coverage`,children:[(0,I.jsx)(`h3`,{className:`setup-subtitle`,children:r}),e.items.length===0?(0,I.jsx)(`p`,{className:`setup-muted`,children:`No documents.`}):(0,I.jsx)(O,{caption:`${r}: versions per locale`,columns:fr(t,n,e.collection),rows:e.items,rowKey:e=>e.slug})]})}function hr({settings:e}){let t=b().hasRole(`editor`),n=`${e.defaultLocale}:${e.supportedLocales.join(`,`)}`,r=(0,j.useCallback)(()=>u(),[n]),{loaded:i,reload:a}=x(r,`Translation coverage could not be read`),o={...pr(e.defaultLocale),defaultLocale:e.defaultLocale,canCreate:t};return(0,I.jsxs)(H,{title:`Translation coverage`,sources:(0,I.jsxs)(V,{source:`database`,children:[`Each document's versions as the site's database holds them. Create draft copies the`,` `,e.defaultLocale,` version's fields and body into a new draft in that locale; it is not live until it is published.`]}),children:[i.state===`loading`&&(0,I.jsx)(W,{what:`translation coverage`}),i.state===`error`&&(0,I.jsx)(G,{message:i.message,onRetry:a}),i.state===`ready`&&i.data.collections.map(e=>(0,I.jsx)(mr,{status:e,locales:i.data.supportedLocales,cell:o},e.collection))]})}function gr(e){return e.configuredLocales.filter(t=>!e.supportedLocales.includes(t))}function _r(e,t){return[...e.supportedLocales,t]}function vr(e,t){return t===e.defaultLocale?e.supportedLocales:e.supportedLocales.filter(e=>e!==t)}function yr(){let{loaded:e,reload:t}=x(s,`The locales could not be read`),[n,r]=(0,j.useState)(null),i=(0,j.useCallback)(e=>r(e),[]);return n&&e.state===`ready`?{loaded:{state:`ready`,data:n},reload:t,set:i}:{loaded:e,reload:t,set:i}}function br({settings:e}){return e.source===`database`?(0,I.jsxs)(V,{source:`database`,children:[`The active locales are chosen here among the configured ones and stored in the site's database. The default locale is `,(0,I.jsx)(`code`,{children:`site.defaultLocale`}),` in the configuration.`]}):(0,I.jsxs)(V,{source:`config`,children:[`The locales are `,(0,I.jsx)(`code`,{children:`site.supportedLocales`}),` and the default locale is`,` `,(0,I.jsx)(`code`,{children:`site.defaultLocale`}),`, in `,(0,I.jsx)(`code`,{children:`krantho.config.ts`}),` or the environment. Setup chooses which of the configured locales are active; the default is set only in the configuration.`]})}function xr(e,t,n){return[{id:`locale`,header:`Locale`,primary:!0,cell:e=>(0,I.jsx)(`code`,{children:e.code})},{id:`default`,header:`Default`,cell:e=>e.isDefault?(0,I.jsx)(y,{tone:`accent`,children:`Default`}):null},{id:`actions`,header:`Actions`,cell:r=>e&&!r.isDefault?(0,I.jsx)(`span`,{className:`setup-row-actions`,children:(0,I.jsx)(S,{size:`sm`,variant:`ghost`,icon:w,"aria-disabled":t,"aria-label":`Remove ${r.code}`,onClick:()=>n(r.code),children:`Remove`})}):null}]}function Sr({settings:e,busy:t,change:n}){let r=gr(e),[i,a]=(0,j.useState)(``),o=r.includes(i)?i:r[0];return o===void 0?(0,I.jsx)(U,{children:`Every locale in the configuration is active.`}):(0,I.jsxs)(`form`,{className:`setup-inline-form`,onSubmit:r=>{r.preventDefault(),t||n(_r(e,o),`Added ${o}.`)},children:[(0,I.jsx)(B,{label:`Configured locale`,value:o,onChange:a,hint:`A locale in site.supportedLocales that is not active`,options:r.map(e=>({value:e,label:e}))}),(0,I.jsx)(S,{type:`submit`,variant:`primary`,icon:me,"aria-disabled":t,children:`Add locale`})]})}function Cr(e){let t=g(),{busy:n,once:r}=P();return{busy:n,change:(n,i)=>{r(async()=>{try{e(await o(n)),t({text:i})}catch(e){t({text:_(e,`The locales could not be saved`),tone:`error`})}})}}}function wr({code:e,settings:t,onSaved:n,onClose:r}){let i=g();async function a(){n(await o(vr(t,e))),i({text:`Removed ${e}.`}),r()}return(0,I.jsx)(L,{title:`Remove the locale ${e}?`,confirmLabel:`Remove locale`,danger:!0,onConfirm:a,onClose:r,children:(0,I.jsxs)(`p`,{children:[`The site stops serving `,(0,I.jsx)(`code`,{children:e}),`. Documents already in that locale are kept, not deleted. Only the list of locales changes.`]})})}function Tr({settings:e,set:t}){let n=b().hasRole(`admin`),{busy:r,change:i}=Cr(t),[a,o]=(0,j.useState)(null),s=e.supportedLocales.map(t=>({code:t,isDefault:t===e.defaultLocale}));return(0,I.jsxs)(H,{title:`Locales`,sources:(0,I.jsx)(br,{settings:e}),children:[(0,I.jsx)(O,{caption:`Locales`,columns:xr(n,r,o),rows:s,rowKey:e=>e.code}),n?(0,I.jsx)(Sr,{settings:e,busy:r,change:i}):(0,I.jsx)(U,{children:`Only admins change the locales.`}),a&&(0,I.jsx)(wr,{code:a,settings:e,onSaved:t,onClose:()=>o(null)})]})}function Er(){let{loaded:e,reload:t,set:n}=yr();if(e.state===`loading`)return(0,I.jsx)(W,{what:`the locales`});if(e.state===`error`)return(0,I.jsx)(G,{message:e.message,onRetry:t});let r=e.data;return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsx)(Tr,{settings:r,set:n}),r.supportedLocales.length>1&&(0,I.jsx)(hr,{settings:r})]})}var Dr=[{value:`admin`,label:`Admin`,can:`everything, including Setup and people`},{value:`editor`,label:`Editor`,can:`writes, publishes and takes checkpoints`},{value:`viewer`,label:`Viewer`,can:`reads`}];function Q(e){return e.roles[0]??`viewer`}function $(e){return e.name||e.email||e.id}var Or=Dr.map(e=>({value:e.value,label:`${e.label} — ${e.can}`}));function kr({form:e,setForm:t,editing:n}){let r=n?`An account keeps its email`:`They sign in with this address`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{label:`Email`,type:`email`,value:e.email,disabled:n,onChange:n=>t({...e,email:n}),hint:r}),(0,I.jsx)(z,{label:`Name`,value:e.name,onChange:n=>t({...e,name:n})}),(0,I.jsx)(B,{label:`Role`,value:e.role,options:Or,onChange:n=>t({...e,role:n}),hint:`Roles are site-wide: admin > editor > viewer`})]})}function Ar({user:e,onSave:t,onClose:n}){let r=(0,j.useId)(),[i,a]=(0,j.useState)(()=>({email:e?.email??``,name:e?.name??``,role:e?Q(e):`viewer`})),{busy:o,error:s,setError:c,run:l}=F();function u(n){if(n.preventDefault(),!e&&!i.email.trim()){c(`An account needs an email.`);return}let r={...i,email:i.email.trim(),name:i.name.trim()};l(()=>t(r),`The account could not be saved`)}let d=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{onClick:n,children:`Cancel`}),(0,I.jsx)(S,{variant:`primary`,type:`submit`,form:r,"aria-disabled":o,children:o?`Saving…`:e?`Save`:`Create user`})]}),f=e?`Edit ${$(e)}`:`Create user`;return(0,I.jsx)(h,{title:f,onClose:n,actions:d,busy:o,children:(0,I.jsxs)(`form`,{id:r,className:`setup-form`,onSubmit:u,children:[s&&(0,I.jsx)(R,{text:s}),(0,I.jsx)(kr,{form:i,setForm:a,editing:e!==null})]})})}var jr=e=>Dr.find(t=>t.value===Q(e))?.label??Q(e);function Mr(e,t){let n={kind:`edit`,label:`Edit`,icon:He,variant:`secondary`};return t?[n]:[n,{kind:`active`,label:e.isActive?`Deactivate`:`Activate`,icon:at,variant:`ghost`},{kind:`delete`,label:`Delete`,icon:w,variant:`ghost`}]}function Nr({user:e,self:t,onDialog:n}){let r=$(e),i=Mr(e,t);return(0,I.jsx)(`span`,{className:`setup-row-actions`,children:i.map(t=>(0,I.jsx)(S,{size:`sm`,variant:t.variant,icon:t.icon,"aria-label":`${t.label} ${r}`,onClick:()=>n({kind:t.kind,user:e}),children:t.label},t.kind))})}function Pr(e,t){return[{id:`name`,header:`Person`,primary:!0,cell:e=>e.name||(0,I.jsx)(`span`,{className:`setup-muted`,children:`No name`})},{id:`email`,header:`Email`,cell:e=>e.email??`—`},{id:`role`,header:`Role`,cell:e=>(0,I.jsx)(y,{tone:Q(e)===`admin`?`accent`:`neutral`,children:jr(e)})},{id:`status`,header:`Status`,cell:e=>e.isActive?(0,I.jsx)(y,{tone:`success`,children:`Active`}):(0,I.jsx)(y,{children:`Deactivated`})},{id:`sign-in`,header:`Signs in with`,cell:e=>e.oidcIssuer?`OIDC provider`:`Studio`},{id:`created`,header:`Created`,cell:e=>Fe(e.createdAt)},{id:`actions`,header:`Actions`,cell:n=>(0,I.jsx)(Nr,{user:n,self:n.id===e,onDialog:t})}]}async function Fr(e,t){return e?(await A(e.id,{name:t.name,role:t.role}),`Saved ${$(e)}: ${t.role}.`):`Created ${$(await dt({email:t.email,name:t.name||void 0,role:t.role}))} as ${t.role}.`}async function Ir(e,t){return e===`delete`?(await ft(t.id),`Deleted ${$(t)}.`):(await A(t.id,{isActive:!t.isActive}),`${t.isActive?`Deactivated`:`Activated`} ${$(t)}.`)}function Lr({user:e,onConfirm:t,onClose:n}){let r=e.isActive,i=r?`Deactivate`:`Activate`;return(0,I.jsx)(L,{title:`${i} ${$(e)}?`,confirmLabel:i,danger:r,onConfirm:t,onClose:n,children:(0,I.jsx)(`p`,{children:r?`They can no longer sign in, and their sessions can no longer be renewed; a session already open lasts until its access token expires.`:`They can sign in again, with their role.`})})}function Rr({dialog:e,onClose:t,onDone:n}){if(e.kind===`create`||e.kind===`edit`){let r=e.kind===`edit`?e.user:null;return(0,I.jsx)(Ar,{user:r,onSave:async e=>n(await Fr(r,e)),onClose:t})}let{kind:r,user:i}=e,a=async()=>n(await Ir(r,i));return r===`active`?(0,I.jsx)(Lr,{user:i,onConfirm:a,onClose:t}):(0,I.jsx)(L,{title:`Delete ${$(i)}?`,confirmLabel:`Delete account`,danger:!0,onConfirm:a,onClose:t,children:(0,I.jsx)(`p`,{children:`The account is removed from the site's database.`})})}function zr(){let e=g(),t=b().user?.id,{loaded:n,reload:r}=x(ut,`The accounts could not be read`),[i,a]=(0,j.useState)(null);return(0,I.jsxs)(H,{title:`People`,sources:(0,I.jsx)(V,{source:`database`,children:`The accounts in the site's database. Roles are site-wide: admin > editor > viewer. The API does not record when someone was last active.`}),actions:(0,I.jsx)(S,{variant:`primary`,icon:lt,onClick:()=>a({kind:`create`}),children:`Create user`}),children:[n.state===`loading`&&(0,I.jsx)(W,{what:`the accounts`}),n.state===`error`&&(0,I.jsx)(G,{message:n.message,onRetry:r}),n.state===`ready`&&(0,I.jsx)(O,{caption:`People`,columns:Pr(t,a),rows:n.data,rowKey:e=>e.id}),i&&(0,I.jsx)(Rr,{dialog:i,onClose:()=>a(null),onDone:t=>{a(null),e({text:t}),r()}})]})}function Br({tab:e}){switch(e){case`collections`:return(0,I.jsx)(Gn,{});case`locales`:return(0,I.jsx)(Er,{});case`ai`:return(0,I.jsx)(Zt,{});case`integrations`:return(0,I.jsx)(ur,{});case`checkpoints`:return(0,I.jsx)(an,{});case`people`:return(0,I.jsx)(zr,{});case`environment`:return(0,I.jsx)(Xn,{})}}function Vr({tab:e,tabs:t}){let n=(0,j.useId)(),i=(0,j.useCallback)(e=>`${n}-tab-${e}`,[n]);return(0,I.jsxs)(`div`,{className:`setup`,children:[(0,I.jsxs)(`header`,{className:`setup-header`,children:[(0,I.jsx)(`h1`,{className:`setup-title`,children:`Setup`}),(0,I.jsxs)(`p`,{className:`setup-lead`,children:[`How the site is configured. Each tab says where its values come from: the configuration —`,` `,(0,I.jsx)(`code`,{children:`krantho.config.ts`}),`, `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),` and the environment, read-only here — the site's database, changed here, or what the running server reports.`]})]}),(0,I.jsx)(r,{label:`Setup`,tabs:t,current:e,tabId:i,panelId:`${n}-panel`}),(0,I.jsx)(`div`,{id:`${n}-panel`,role:`tabpanel`,"aria-labelledby":i(e),className:`setup-panel`,children:(0,I.jsx)(Br,{tab:e})})]})}export{Vr as SetupPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{o as t,s as n}from"./vendor-diff-DGCTJYJ4.js";import{t as r}from"./vendor-router-B4czwg8X.js";import{r as i,u as a}from"./format-C3ZX9yGM.js";import{n as o}from"./use-loaded-BNCu0C-c.js";import{t as s}from"./circle-dashed-cuYrILNo.js";import{t as c}from"./circle-x-peGpq98w.js";import{t as l}from"./corner-down-right-BpwOGRFR.js";import{t as u}from"./external-link-Dh7p8Ii6.js";import{f as d}from"./api-seo-DeG5gsh6.js";import{C as f,D as p,K as m,S as h,St as g,Tt as _,V as v,ft as y,j as b,x,z as S}from"./index-d5j-az5g.js";import{a as C,u as w}from"./site-model-BXHOxNij.js";import{t as T}from"./source-CGZGd3Xy.js";var E=t();function D(e,t){return _(e.collection,e.slug,e.locale===t?void 0:e.locale)}function O({row:e,baseUrl:t}){return e.path===null?null:e.liveVersion===null?(0,E.jsx)(`span`,{className:`site-url`,title:`Not published yet`,children:e.path}):(0,E.jsxs)(`a`,{className:`site-url site-url--link`,href:C(t,e.path),target:`_blank`,rel:`noreferrer`,"aria-label":`${e.path} on the site (opens in a new tab)`,children:[e.path,(0,E.jsx)(u,{className:`site-url-icon`,"aria-hidden":`true`})]})}function k({row:e,context:t}){return(0,E.jsxs)(`div`,{className:`site-page`,children:[(0,E.jsx)(x,{status:e.status,decorative:!0}),(0,E.jsxs)(`div`,{className:`site-page-text`,children:[(0,E.jsx)(r,{to:D(e,t.defaultLocale),className:`site-title`,children:e.title}),e.path===null?(0,E.jsx)(`span`,{className:`site-url`,children:`no URL, shared`}):(0,E.jsx)(O,{row:e,baseUrl:t.baseUrl})]})]})}function A({row:e,context:t}){return(0,E.jsxs)(`div`,{className:`site-page-text`,children:[(0,E.jsx)(r,{to:D(e,t.defaultLocale),className:`site-slug`,children:e.slug}),(0,E.jsx)(`span`,{className:`site-links`,children:(0,E.jsx)(O,{row:e,baseUrl:t.baseUrl})})]})}function j({row:e}){return(0,E.jsxs)(`span`,{className:`site-status site-status--${e.status}`,children:[(0,E.jsx)(x,{status:e.status,decorative:!0}),b[e.status]]})}function M({row:e}){return e.liveVersion===null?(0,E.jsxs)(`span`,{className:`site-muted`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,E.jsx)(`span`,{className:`visually-hidden`,children:`Not published`})]}):(0,E.jsxs)(`span`,{children:[`v`,e.liveVersion]})}function N({row:e}){return(0,E.jsx)(`time`,{dateTime:e.updatedAt,title:new Date(e.updatedAt).toLocaleString(),children:i(e.updatedAt)})}var P={covered:{icon:o,tone:`good`,text:`Own meta description`},fallback:{icon:l,tone:`muted`,text:`Falls back to description`},missing:{icon:y,tone:`warn`,text:`No meta description`}};function F(e,t){switch(e){case`valid`:return{icon:o,tone:`good`,text:`Structured data valid`};case`errors`:return{icon:c,tone:`bad`,text:`Structured data has errors`};case`not-live`:return{icon:s,tone:`muted`,text:`Structured data checked once live`};case`default-locale-only`:return{icon:s,tone:`muted`,text:`Structured data checked in ${t}`};case`failed`:return{icon:s,tone:`muted`,text:`Structured data unavailable`};case`off`:return null}}function I({line:e}){let t=e.icon;return(0,E.jsxs)(`span`,{className:`site-finding site-finding--${e.tone}`,children:[(0,E.jsx)(t,{className:`site-finding-icon`,"aria-hidden":`true`}),e.text]})}function L({row:e,context:t}){if(e.meta===null){let t=e.collection===g;return(0,E.jsx)(`span`,{className:`site-muted`,children:t?`Read by every page`:`No page`})}let n=e.graph===null?null:F(e.graph,t.defaultLocale);return(0,E.jsxs)(`span`,{className:`site-findability`,children:[(0,E.jsx)(I,{line:P[e.meta]}),n&&(0,E.jsx)(I,{line:n})]})}function R({row:e}){let{locales:t}=e;return t.state===`failed`?(0,E.jsx)(`span`,{className:`site-muted`,children:`Unavailable`}):t.state===`off`?(0,E.jsxs)(`span`,{className:`site-muted`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,E.jsx)(`span`,{className:`visually-hidden`,children:`Locale versions not tracked`})]}):(0,E.jsxs)(`span`,{className:`site-locales`,children:[t.present.map(e=>(0,E.jsx)(`code`,{className:`site-locale`,children:e},e)),t.missing.map(e=>(0,E.jsxs)(`code`,{className:`site-locale site-locale--missing`,title:`No ${e} version`,children:[e,(0,E.jsx)(`span`,{className:`visually-hidden`,children:` missing`})]},e))]})}function z(e){return e?[{id:`locales`,header:`Locales`,cell:e=>(0,E.jsx)(R,{row:e})}]:[]}var B={id:`status`,header:`Status`,width:`11rem`,cell:e=>(0,E.jsx)(j,{row:e})},V={id:`updated`,header:`Updated`,numeric:!0,width:`9.5rem`,cell:e=>(0,E.jsx)(N,{row:e})};function H(e,t){return[{id:`page`,header:`Page`,primary:!0,cell:t=>(0,E.jsx)(k,{row:t,context:e})},B,{id:`findability`,header:`Findability`,cell:t=>(0,E.jsx)(L,{row:t,context:e})},...z(t),V]}function U(e,t){return[{id:`slug`,header:`Slug`,primary:!0,cell:t=>(0,E.jsx)(A,{row:t,context:e})},B,{id:`live`,header:`Live`,numeric:!0,width:`4.5rem`,cell:e=>(0,E.jsx)(M,{row:e})},{id:`seo`,header:`SEO`,cell:t=>(0,E.jsx)(L,{row:t,context:e})},...z(t),V]}async function W(e){let[t,n,r]=await Promise.all([p(),v(),f()]),[i,o]=await Promise.all([T(a(e,`seo`),async()=>(await d()).pages),T(h(r),m)]);return{site:t,locales:r,collections:n,findings:i,translations:o}}function G(e,t){return e.map(e=>w(e,t))}function K(e,t){return{collection:e,defaultLocale:t.locales.defaultLocale,findings:t.findings,translations:t.translations}}async function q(e){let t=await W(e),n=t.locales.defaultLocale,r=await S({locale:n}),i=[],a=null;for(let e of t.collections){let n=G(r.filter(t=>t.meta.collection===e.name),K(e,t));e.name===`globals`?a=n:i.push({collection:e,rows:n})}let o=t.translations.state!==`off`;return{site:t.site,locales:t.locales,sections:i,layout:a,localization:o}}async function J(e,t,n){let r=await W(e),{supportedLocales:i,defaultLocale:a}=r.locales,o=n&&i.includes(n)?n:a,s=r.translations.state!==`off`,c=r.collections.find(e=>e.name===t&&e.name!==`globals`)??null,l={site:r.site,locales:r.locales,collection:c,locale:o,localization:s};if(!c)return{...l,rows:[]};let u=await S({collections:[c.name],locale:o});return{...l,rows:G(u,K(c,r))}}var Y=e(n(),1);function X(e,t){let[n,r]=(0,Y.useState)(0),i=(0,Y.useRef)(0),{ready:a,error:o}=t;return(0,Y.useEffect)(()=>{n!==i.current&&e!==`loading`&&(i.current=n,(e===`error`?o:a).current?.focus())},[n,e,a,o]),(0,Y.useCallback)(()=>r(e=>e+1),[])}export{H as a,U as i,J as n,D as o,q as r,X as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{o as t,s as n}from"./vendor-diff-DGCTJYJ4.js";import{n as r}from"./createLucideIcon-BklFHeMd.js";import{i,n as a,r as o}from"./findability-BrhtZ2yD.js";import{y as s}from"./api-seo-DeG5gsh6.js";import{t as c}from"./triangle-exclamation-point-ttN5lZI0.js";import{M as l,o as u}from"./index-d5j-az5g.js";import{t as d}from"./empty-state-CeUZocHx.js";var f=e(n(),1),p=t();function m({title:e,message:t,onRetry:n,panelRef:i}){let a=(0,f.useId)();return(0,p.jsx)(`div`,{ref:i,className:`site-panel site-focus-target`,role:`alert`,"aria-labelledby":a,tabIndex:-1,children:(0,p.jsx)(d,{icon:c,title:e,titleId:a,action:(0,p.jsx)(r,{icon:s,onClick:n,children:`Try again`}),children:t})})}function h(e,t){if(!t.collection.pages)return null;let{findings:n,defaultLocale:r}=t;if(n.state!==`ok`)return n.state;if(e.meta.locale!==r)return`default-locale-only`;let i=n.value.find(t=>t.collection===e.meta.collection&&t.slug===e.meta.slug);return i?o(i)?`valid`:`errors`:`not-live`}function g(e,t){let{translations:n,collection:r}=t;if(n.state!==`ok`)return n;let i=n.value.collections.find(e=>e.collection===r.name)?.items.find(t=>t.slug===e.slug),a=new Set([...i?.locales??[],e.locale]),o=n.value.supportedLocales;return{state:`ok`,present:o.filter(e=>a.has(e)),missing:o.filter(e=>!a.has(e))}}function _(e,t){let{meta:n,fields:r}=e,o=r.title,s=t.collection.pages;return{collection:n.collection,slug:n.slug,locale:n.locale,title:a(o)?String(o):n.slug,status:l(n),version:n.version,liveVersion:n.liveVersion,updatedAt:n.createdAt,path:s?u(t.collection,n.slug):null,meta:s?i(r):null,graph:h(e,t),locales:g(n,t)}}var v=[`all`,`live`,`ahead`,`draft`],y=[`updated`,`slug`];function b(e){return v.some(t=>t===e)}function x(e){return y.some(t=>t===e)}function S(e){return e===`slug`?(e,t)=>e.slug.localeCompare(t.slug):(e,t)=>t.updatedAt.localeCompare(e.updatedAt)||e.slug.localeCompare(t.slug)}function C(e,t,n){return e.filter(e=>t===`all`||e.status===t).sort(S(n))}function w(e){let t=t=>e.filter(e=>e.status===t).length;return{total:e.length,live:t(`live`),ahead:t(`ahead`),draft:t(`draft`)}}function T(e,t){return`${e} of ${t}`}function E(e,t){return`${e.replace(/\/+$/,``)}${t}`}function D(e,t){return t.length>0&&t.every(t=>e.has(t))?new Set:new Set(t)}function O(e,t){return t.filter(t=>e.has(t))}export{E as a,C as c,D as d,m as f,b as i,w as l,v as n,O as o,x as r,T as s,y as t,_ as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{s as t}from"./vendor-diff-DGCTJYJ4.js";import{t as n}from"./createLucideIcon-BklFHeMd.js";import{f as r}from"./index-d5j-az5g.js";var i={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};i.node;var a=n(i),o=e(t(),1);function s(e,t){let[n,i]=(0,o.useState)({state:`loading`}),[a,s]=(0,o.useState)(0),[c,l]=(0,o.useState)(()=>e);return c!==e&&(l(()=>e),i({state:`loading`})),(0,o.useEffect)(()=>{let n=!0;return e().then(e=>{n&&i({state:`ready`,data:e})}).catch(e=>{n&&i({state:`error`,message:r(e,t)})}),()=>{n=!1}},[e,t,a]),{loaded:n,reload:(0,o.useCallback)(()=>{i(e=>e.state===`error`?{state:`loading`}:e),s(e=>e+1)},[])}}export{a as n,s as t};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
function e(e,t){this.v=e,this.k=t}function t(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e){if(Array.isArray(e))return e}function r(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function i(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function a(e,t){return n(e)||r(e,t)||o(e,t)||i()}function o(e,n){if(e){if(typeof e==`string`)return t(e,n);var r={}.toString.call(e).slice(8,-1);return r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`?Array.from(e):r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function s(t){var n,r;function i(n,r){try{var o=t[n](r),s=o.value,c=s instanceof e;Promise.resolve(c?s.v:s).then(function(e){if(c){var r=n===`return`&&s.k?n:`next`;if(!s.k||e.done)return i(r,e);e=t[r](e).value}a(!!o.done,e)},function(e){i(`throw`,e)})}catch(e){a(2,e)}}function a(e,t){e===2?n.reject(t):n.resolve({value:t,done:e}),(n=n.next)?i(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise(function(a,o){var s={key:e,arg:t,resolve:a,reject:o,next:null};r?r=r.next=s:(n=r=s,i(e,t))})},typeof t.return!=`function`&&(this.return=void 0)}s.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},s.prototype.next=function(e){return this._invoke(`next`,e)},s.prototype.throw=function(e){return this._invoke(`throw`,e)},s.prototype.return=function(e){return this._invoke(`return`,e)};var c=Object.entries,l=Object.keys,u=Object.setPrototypeOf,d=Object.isFrozen,f=Object.getPrototypeOf,p=Object.getOwnPropertyDescriptor,m=Object.freeze,h=Object.seal,g=Object.create,ee=typeof Reflect<`u`&&Reflect,te=ee.apply,ne=ee.construct;m||=function(e){return e},h||=function(e){return e},te||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ne||=function(e){return new e(...[...arguments].slice(1))};var _=S(Array.prototype.forEach),re=S(Array.prototype.lastIndexOf),ie=S(Array.prototype.pop),ae=S(Array.prototype.push),oe=S(Array.prototype.slice),se=S(Array.prototype.splice),ce=Array.isArray,le=C(Set),ue=S(Set.prototype.add),de=S(Set.prototype.has),fe=S(String.prototype.toLowerCase),pe=S(String.prototype.toString),me=S(String.prototype.match),he=S(String.prototype.replace),ge=S(String.prototype.indexOf),_e=S(String.prototype.trim),ve=S(Number.prototype.toString),ye=S(Boolean.prototype.toString),be=typeof BigInt>`u`?null:S(BigInt.prototype.toString),xe=typeof Symbol>`u`?null:S(Symbol.prototype.toString),v=S(Object.prototype.hasOwnProperty),y=S(Object.prototype.toString),Se=RegExp.prototype.test,b=function(e,t){return e instanceof RegExp&&(e.lastIndex=0),te(Se,e,[t])},x=C(TypeError);function S(e){return function(t){var n=[...arguments].slice(1);return te(e,t,n)}}function C(e){return function(){return ne(e,[...arguments])}}function w(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:fe;if(u&&u(e,null),!ce(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(d(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ce(e){for(let t=0;t<e.length;t++)v(e,t)||(e[t]=null);return e}function we(e){let t=g(null);for(let r of c(e)){var n=a(r,2);let i=n[0],o=n[1];v(e,i)&&(t[i]=ce(o)?Ce(o):o&&typeof o==`object`&&o.constructor===Object?we(o):o)}return t}function Te(e){let t=g(null),n=l(e),r=n.length;for(;r--;)t[n[r]]=e[n[r]];return t}function Ee(e){switch(typeof e){case`string`:return e;case`number`:return ve(e);case`boolean`:return ye(e);case`bigint`:return be?be(e):`0`;case`symbol`:return xe?xe(e):`Symbol()`;case`undefined`:return y(e);case`function`:case`object`:{if(e===null)return y(e);let t=e,n=T(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:y(e)}return y(e)}default:return y(e)}}function T(e,t){for(;e!==null;){let n=p(e,t);if(n){if(n.get)return S(n.get);if(typeof n.value==`function`)return S(n.value)}e=f(e)}function n(){return null}return n}function De(e,t){for(;e!==null;){let n=p(e,t);if(n)return n.get?S(n.get):null;e=f(e)}return null}function Oe(e){if(!e)return!1;try{return b(e,``),!0}catch{return!1}}var ke=m(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Ae=m(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.filter.font.g.glyph.glyphref.hkern.image.line.lineargradient.marker.mask.metadata.mpath.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),je=m([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Me=m([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Ne=m(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Pe=m([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Fe=m([`#text`]),Ie=m(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Le=m(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Re=m(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),ze=m([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Be=h(/{{[\w\W]*|^[\w\W]*}}/g),Ve=h(/<%[\w\W]*|^[\w\W]*%>/g),He=h(/\${[\w\W]*/g),Ue=h(/{{|}}|\${|<%|%>|<%|%>/),We=h(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ge=h(/^aria-[\-\w]+$/),Ke=h(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qe=h(/^(?:\w+script|data):/i),Je=h(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ye=h(/^html$/i),Xe=h(/^[a-z][.\w]*(-[.\w]+)+$/i),Ze=h(/<[/\w!]/g),Qe=h(/<[/\w]/g),$e=h(/<\/no(script|embed|frames)/i),et=h(/\/>/i),tt=h(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),nt=h(/^[\r\n\t ]+/),E={element:1,text:3,processingInstruction:7,comment:8,document:9,documentFragment:11},rt=m(w({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),it=function(){return typeof window>`u`?null:window},at=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},ot=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},st=function(e,t,n,r){return v(e,t)&&ce(e[t])?w(r.base?Te(r.base):{},e[t],r.transform):n},ct=function(e,t,n){let r=v(e,t)?e[t]:void 0;return r&&typeof r==`object`?we(r):n};function lt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:it(),t=e=>lt(e);if(t.version=`3.4.18`,t.removed=[],!e||!e.document||e.document.nodeType!==E.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript,a=e.HTMLTemplateElement,o=e.Node,s=e.Element,l=e.NodeFilter,u=e.DOMParser,d=e.trustedTypes,f=s.prototype,p=T(f,`cloneNode`),ee=T(f,`remove`),te=T(f,`removeAttributeNode`),ne=T(f,`nextSibling`),ve=T(f,`childNodes`),ye=T(f,`parentNode`),be=T(f,`shadowRoot`),xe=T(f,`attributes`),y=o&&o.prototype?T(o.prototype,`nodeType`):null,Se=o&&o.prototype?T(o.prototype,`nodeName`):null,S=o&&o.prototype?T(o.prototype,`ownerDocument`):null,C=function(e){return y?y(e):e.nodeType},Ce=function(e){return Se?Se(e):e.nodeName},ut=De(f,`namespaceURI`),dt=function(e){return ut?ut(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let D,O=``,k,A=!1,j=0,ft=function(){if(j>0)throw x(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},M=function(e){ft(),j++;try{return D.createHTML(e)}finally{j--}},pt=function(e){return D&&Wt?M(e):e},mt=function(e){ft(),j++;try{return D.createScriptURL(e)}finally{j--}},ht=function(){return A||=(k=at(d,i),!0),k},N=n,gt=N.implementation,_t=N.createNodeIterator,vt=N.createDocumentFragment,yt=N.getElementsByTagName,bt=r.importNode,P=ot();t.isSupported=typeof c==`function`&&typeof ye==`function`&>&>.createHTMLDocument!==void 0;let xt=Be,St=Ve,Ct=He,wt=We,Tt=Ge,Et=qe,Dt=Je,Ot=Xe,kt=Ke,F=null,At=w({},[...ke,...Ae,...je,...Ne,...Fe]),I=null,jt=w({},[...Ie,...Le,...Re,...ze]),L=null,Mt=null,Nt=null,R=Object.seal(g(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Pt=!0,z=!0,Ft=!1,It=!0,B=!1,Lt=!0,V=!1,Rt=!1,zt=null,Bt=null,Vt=!1,Ht=!1,Ut=!1,Wt=!1,Gt=!0,Kt=!1,qt=`user-content-`,Jt=!0,Yt=!1,H=null,Xt=!1,Zt=null,Qt=w({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),$t=null,en=w({},[`audio`,`video`,`img`,`source`,`image`,`track`]),tn=null,nn=w({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),rn=`http://www.w3.org/1998/Math/MathML`,an=`http://www.w3.org/2000/svg`,U=`http://www.w3.org/1999/xhtml`,on=U,sn=!1,cn=null,ln=w({},[rn,an,U],pe),un=m(w({},[`mi`,`mo`,`mn`,`ms`,`mtext`])),dn=null,fn=m(w({},[`annotation-xml`])),pn=null,mn=m(g(null)),hn=w({},[`title`,`style`,`font`,`a`,`script`]),gn=null,_n=[`application/xhtml+xml`,`text/html`],W=null,vn=null,yn=n.createElement(`form`),G=function(e){return e instanceof RegExp||e instanceof Function},bn=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e&&typeof e==`object`||(e={}),e=we(e),gn=_n.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,W=gn===`application/xhtml+xml`?pe:fe,F=st(e,`ALLOWED_TAGS`,At,{transform:W}),I=st(e,`ALLOWED_ATTR`,jt,{transform:W}),cn=st(e,`ALLOWED_NAMESPACES`,ln,{transform:pe}),tn=st(e,`ADD_URI_SAFE_ATTR`,nn,{transform:W,base:nn}),$t=st(e,`ADD_DATA_URI_TAGS`,en,{transform:W,base:en}),Zt=st(e,`FORBID_CONTENTS`,Qt,{transform:W}),Mt=st(e,`FORBID_TAGS`,g(null),{transform:W}),Nt=st(e,`FORBID_ATTR`,g(null),{transform:W}),Xt=v(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?we(e.USE_PROFILES):e.USE_PROFILES:!1,Pt=e.ALLOW_ARIA_ATTR!==!1,z=e.ALLOW_DATA_ATTR!==!1,Ft=e.ALLOW_UNKNOWN_PROTOCOLS||!1,It=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,B=e.SAFE_FOR_TEMPLATES||!1,Lt=e.SAFE_FOR_XML!==!1,V=e.WHOLE_DOCUMENT||!1,Ht=e.RETURN_DOM||!1,Ut=e.RETURN_DOM_FRAGMENT||!1,Wt=e.RETURN_TRUSTED_TYPE||!1,Vt=e.FORCE_BODY||!1,Gt=e.SANITIZE_DOM!==!1,Kt=e.SANITIZE_NAMED_PROPS||!1,Jt=e.KEEP_CONTENT!==!1,Yt=e.IN_PLACE||!1,kt=Oe(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Ke,on=typeof e.NAMESPACE==`string`?e.NAMESPACE:U,dn=ct(e,`MATHML_TEXT_INTEGRATION_POINTS`,un),pn=ct(e,`HTML_INTEGRATION_POINTS`,fn);let t=ct(e,`CUSTOM_ELEMENT_HANDLING`,mn);if(L=g(null),v(t,`tagNameCheck`)&&G(t.tagNameCheck)&&(L.tagNameCheck=t.tagNameCheck),v(t,`attributeNameCheck`)&&G(t.attributeNameCheck)&&(L.attributeNameCheck=t.attributeNameCheck),v(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(L.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),h(L),B&&(z=!1),Ut&&(Ht=!0),Xt&&((v(e,`ALLOWED_TAGS`)||v(e,`ALLOWED_ATTR`))&&typeof console<`u`&&typeof console.warn==`function`&&console.warn(`DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together.`),F=w({},Fe),I=g(null),Xt.html===!0&&(w(F,ke),w(I,Ie)),Xt.svg===!0&&(w(F,Ae),w(I,Le),w(I,ze)),Xt.svgFilters===!0&&(w(F,je),w(I,Le),w(I,ze)),Xt.mathMl===!0&&(w(F,Ne),w(I,Re),w(I,ze))),R.tagCheck=null,R.attributeCheck=null,v(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?R.tagCheck=e.ADD_TAGS:ce(e.ADD_TAGS)&&(F===At&&(F=Te(F)),w(F,e.ADD_TAGS,W))),v(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?R.attributeCheck=e.ADD_ATTR:ce(e.ADD_ATTR)&&(I===jt&&(I=Te(I)),w(I,e.ADD_ATTR,W))),v(e,`ADD_FORBID_CONTENTS`)&&ce(e.ADD_FORBID_CONTENTS)&&(Zt===Qt&&(Zt=Te(Zt)),w(Zt,e.ADD_FORBID_CONTENTS,W)),Jt&&(F[`#text`]=!0),V&&w(F,[`html`,`head`,`body`]),F.table&&(F.tbody=!0,delete Mt.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw x(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw x(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=D;D=e.TRUSTED_TYPES_POLICY;try{O=M(``)}catch(e){throw D=t,e}}else e.TRUSTED_TYPES_POLICY===null?(D=void 0,O=``):(D===void 0&&(D=ht()),D&&typeof O==`string`&&(O=M(``)));vn=m(e)},xn=w({},[...Ae,...je,...Me]),Sn=w({},[...Ne,...Pe]),K=function(e,t,n){return t===U?e===`svg`:t===rn?e===`svg`&&(n===`annotation-xml`||dn[n]):!!xn[e]},Cn=function(e,t,n){return t===U?e===`math`:t===an?e===`math`&&pn[n]:!!Sn[e]},wn=function(e,t,n){return t===an&&!pn[n]||t===rn&&!dn[n]?!1:!Sn[e]&&(hn[e]||!xn[e])},Tn=function(e){let t=dt(e),n=fe(Ce(e)),r=ye(e),i=on,a=`template`;return r&&C(r)===E.element&&(i=dt(r),a=fe(Ce(r))),cn[t]?t===an?K(n,i,a):t===rn?Cn(n,i,a):t===U?wn(n,i,a):gn===`application/xhtml+xml`:!1},q=function(e){ae(t.removed,{element:e});try{ye(e).removeChild(e)}catch{if(ee(e),!ye(e))throw x(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},En=function(e,t,n){try{te(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Dn=function(e){jn(e);let t=ve(e);t&&_(oe(t),e=>{try{ee(e)}catch{}}),C(e)===E.element&&kn(e,!1)},On=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}if(ae(t.removed,{attribute:r||null,from:n}),r)En(n,r,e);else try{n.removeAttribute(e)}catch{}if(e===`is`){if(Ht||Ut)try{q(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},kn=function(e,t){let n=xe(e);if(n)for(let r=n.length-1;r>=0;--r){let i=n[r],a=i&&i.name;typeof a==`string`&&!(t&&I[W(a)])&&En(e,i,a)}},An=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&C(e)===E.element){let t=be(e);Hn(t)&&r.push(t)}let i=ve(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},jn=function(e){An(e,e=>{C(e)===E.element&&kn(e,!0)})},Mn=function(e){let t=[];return An(e,e=>{t.push(e)},!0),t},Nn=function(e,t){let n=le();_(Mn(e),e=>{C(e)===E.element&&ue(n,e)}),_(t,e=>{C(e)===E.element&&!de(n,e)&&kn(e,!0)})},Pn=function(e,n){let r=!1;return _(t.removed,t=>{t.element&&(r||=t.element===e,jn(t.element))}),Nn(e,n),r},Fn=function(e,t){let n=H,r=null,i=()=>(r||(r=le(),_(t,e=>{ue(r,e)})),r);for(let t=0;;t++){let r=Mn(e),a=[e],o=!1;if(_(r,e=>{C(e)===E.documentFragment?ae(a,e):!o&&!de(n,e)&&(o=de(i(),e))}),!o)return;if(t>=8)throw x(`the tree kept changing during in-place sanitization; refusing to return it`);_(a,(t,n)=>{J(t,n>0,e,i())})}},J=function(e,t,n,r){let i=X(e),a;for(;a=i.nextNode();)de(r,a)&&!de(H,a)&&(t&&$(P.uponSanitizeShadowNode,a,null),rr(a,n))},In=function(e){H&&ue(H,e)},Ln=function(e,t){return Lt?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Y=function(e){Lt&&An(e,e=>{let t=C(e);if(t===E.processingInstruction||t===E.comment&&b(Qe,e.data)){try{ee(e)}catch{}return!1}if(t===E.element){let t=e,n=W(Ce(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Ln(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},Rn=function(e){let t=null,r=null;if(Vt)e=`<remove></remove>`+e;else{let t=me(e,nt);r=t&&t[0]}gn===`application/xhtml+xml`&&on===U&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=D?M(e):e;if(on===U)try{t=new u().parseFromString(i,gn)}catch{}if(!t||!t.documentElement){t=gt.createDocument(on,`template`,null);try{t.documentElement.innerHTML=sn?O:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),on===U?yt.call(t,V?`html`:`body`)[0]:V?t.documentElement:a},X=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=S?S(e):e.ownerDocument;return _t.call(n||e,e,(t?0:l.SHOW_ELEMENT)|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},zn=function(e){return e=he(e,xt,` `),e=he(e,St,` `),e=he(e,Ct,` `),e},Z=function(e){Q(e);let t=e.querySelectorAll?.call(e,`template`);t&&_(t,e=>{Hn(e.content)&&Z(e.content)})},Q=function(e){e.normalize();let t=X(e,!0),n=t.nextNode();for(;n;)n.data=zn(n.data),n=t.nextNode()},Bn=function(e){let t=Se?Se(e):null;return typeof t!=`string`||W(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==xe(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==ve(e)},Vn=function(e){if(!y||typeof e!=`object`||!e)return null;try{let t=y(e);return typeof t==`number`?t:null}catch{return null}},Hn=function(e){return Vn(e)===E.documentFragment},Un=function(e){return Vn(e)!==null};function $(e,n,r){e.length!==0&&_(e,e=>{e.call(t,n,r,vn)})}let Wn=function(e,t,n){return!!(Lt&&n===E.element&&e.hasChildNodes()&&!Un(e.firstElementChild)&&b(Ze,e.textContent)&&b(Ze,e.innerHTML)||Lt&&rt[t]&&n===E.element&&dt(e)===U&&(Un(e.firstElementChild)||typeof e.textContent==`string`&&b(Ze,e.textContent))||n===E.processingInstruction||Lt&&n===E.comment&&b(Qe,e.data))},Gn=function(e,t){return e instanceof RegExp?b(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Kn=function(e,t,n){if(!Mt[t]&&Qn(t)&&Gn(L.tagNameCheck,t))return!1;if(Jt&&!Zt[t]&&!Zt[fe(t)]){let t=ye(e),r=ve(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?p(r[a],!0):r[a];t.insertBefore(i,ne(e))}}}return q(e),!0},qn=function(e,t,n,r){return e.length===0?t:t===n||t===r?Te(t):t},Jn=function(e,t){return e===t||ye(e)!==null?!1:(Yt&&jn(e),!0)},Yn=function(e,n){if(In(e),$(P.beforeSanitizeElements,e,null),Jn(e,n))return!0;if(Bn(e))return q(e),!0;let r=W(Ce(e)),i=C(e);if(F=qn(P.uponSanitizeElement,F,At,zt),$(P.uponSanitizeElement,e,{tagName:r,allowedTags:F}),Jn(e,n))return!0;if(Wn(e,r,i))return q(e),!0;if(Mt[r]||!(R.tagCheck instanceof Function&&R.tagCheck(r))&&!F[r]){let t=Kn(e,r,n);return t===!1&&($(P.afterSanitizeElements,e,null),Jn(e,n))?!0:t}if(i===E.element&&!Tn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&b($e,e.innerHTML))return q(e),!0;if(B&&i===E.text){let n=e.textContent,r=zn(n);n!==r&&(ae(t.removed,{element:e.cloneNode()}),e.textContent=r)}return $(P.afterSanitizeElements,e,null),Jn(e,n)},Xn=function(e,t,r){if(Nt[t]||Ln(t,e)||Gt&&(t===`id`||t===`name`)&&(r in n||r in yn))return!1;let i=I[t]||R.attributeCheck instanceof Function&&R.attributeCheck(t,e);if(z&&b(wt,t)||Pt&&b(Tt,t))return!0;if(!i)return Qn(e)&&Gn(L.tagNameCheck,e)&&Gn(L.attributeNameCheck,t,e)||t===`is`&&L.allowCustomizedBuiltInElements&&Gn(L.tagNameCheck,r);if(tn[t])return!0;let a=he(r,Dt,``);return b(kt,a)||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ge(r,`data:`)===0&&$t[e]||Ft&&!b(Et,a)?!0:!r},Zn=w({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Qn=function(e){return!Zn[fe(e)]&&b(Ot,e)},$n=function(e,t,n,r){if(D&&typeof d==`object`&&typeof d.getAttributeType==`function`&&!n)switch(d.getAttributeType(e,t)){case`TrustedHTML`:return M(r);case`TrustedScriptURL`:return mt(r)}return r},er=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Bn(e)||(q(e),!1)}catch{return On(t,e),!1}},tr=function(e,t){return Lt&&b(tt,t)?!0:fe(e)===`attributename`&&ge(t,`href`)!==-1},nr=function(e,n){if($(P.beforeSanitizeAttributes,e,null),Jn(e,n))return;let r=e.attributes;if(!r||Bn(e))return;I=qn(P.uponSanitizeAttribute,I,jt,Bt);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:I,forceKeepAttr:void 0},a=r.length,o=W(Ce(e));for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=W(s),d=l,f=s===`value`?d:_e(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,$(P.uponSanitizeAttribute,e,i),f=i.attrValue,Kt&&(u===`id`||u===`name`)&&ge(f,qt)!==0&&(On(s,e,n),f=qt+f,p=!0),tr(s,f)?On(s,e,n):i.forceKeepAttr||(i.keepAttr?!It&&b(et,f)?On(s,e,n):(B&&(f=zn(f)),Xn(o,u,f)?(f=$n(o,u,c,f),f!==d&&er(e,s,c,f)&&p&&ie(t.removed)):On(s,e,n)):On(s,e,n))}$(P.afterSanitizeAttributes,e,null),Jn(e,n)},rr=function(e,t){Yn(e,t),nr(e,t),Hn(e.content)&&ir(e.content)},ir=function(e){let t=null,n=X(e);for($(P.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if($(P.uponSanitizeShadowNode,t,null),rr(t,e),C(t)===E.element){let e=be(t);Hn(e)&&(ar(e),ir(e))}B&&Q(e),$(P.afterSanitizeShadowDOM,e,null)},ar=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){ir(e.shadow);continue}let n=e.node,r=C(n)===E.element,i=ve(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=Se?Se(n):null;if(typeof e==`string`&&W(e)===`template`){let e=n.content;Hn(e)&&t.push({node:e,shadow:null})}}if(r){let e=be(n);Hn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(sn=!e,sn&&(e=`<!-->`),typeof e!=`string`&&!Un(e)&&(e=Ee(e),typeof e!=`string`))throw x(`dirty is not a string, aborting`);if(!t.isSupported)return e;Rt?(F=zt,I=Bt):bn(n),t.removed=[];let c=Yt&&typeof e!=`string`&&Un(e),l=[],u=H;if(c){Y(e);let t=Ce(e);if(typeof t==`string`){let n=W(t);if(!F[n]||Mt[n])throw Dn(e),x(`root node is forbidden and cannot be sanitized in-place`)}if(Bn(e))throw Dn(e),x(`root node is clobbered and cannot be sanitized in-place`);l=Mn(e),H=le()}else if(Un(e))i=Rn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===E.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),ar(i);else{if(!Ht&&!B&&!V&&e.indexOf(`<`)===-1)return pt(e);if(i=Rn(e),!i)return Ht?null:Wt?O:``}i&&Vt&&q(i.firstChild);let d=c?e:i;try{c&&ar(e);let t=X(d);for(;o=t.nextNode();)rr(o,d);c&&Fn(e,l)}catch(t){throw c&&(Dn(e),Pn(e,l)),t}finally{H=u}if(c){if(Pn(e,l))throw x(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return B&&Z(e),e}if(Ht){if(B&&Z(i),Ut)for(s=vt.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(I.shadowroot||I.shadowrootmode)&&(s=bt.call(r,s,!0)),s}let f=()=>V?i.outerHTML:i.innerHTML,p=f();return B&&b(Ue,p)&&(Q(i),p=f()),V&&F[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&b(Ye,i.ownerDocument.doctype.name)&&(p=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
|
-
`+p),pt(p)},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};bn(e),Rt=!0,zt=F,Bt=I},t.clearConfig=function(){vn=null,Rt=!1,zt=null,Bt=null,D=k,O=``},t.isValidAttribute=function(e,t,n){vn||bn({});let r=W(e),i=W(t);return typeof n==`string`&&(tr(t,n)||!It&&b(et,n))?!1:Xn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&v(P,e)&&ae(P[e],t)},t.removeHook=function(e,t){if(v(P,e)){if(t!==void 0){let n=re(P[e],t);return n===-1?void 0:se(P[e],n,1)[0]}return ie(P[e])}},t.removeHooks=function(e){v(P,e)&&(P[e]=[])},t.removeAllHooks=function(){P=ot()},t}var ut=lt();function dt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var D=dt();function O(e){D=e}var k={exec:()=>null};function A(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function j(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(M.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ft=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),M={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,listInterruptsParagraph:/^ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {0,3}>)([ \t]+)/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\][ \t]+\S/,listReplaceTask:/^\[[ xX]\][ \t]+/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:A(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:A(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:A(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:A(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:A(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:A(e=>RegExp(`^ {0,${e}}(?:</?(?:${Tt})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:A(e=>RegExp(`^ {0,${e}}>`)),nestedContainerMarkers:/^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/},pt=/^(?:[ \t]*(?:\n|$))+/,mt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ht=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/,N=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,gt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_t=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,vt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/,yt=j(vt).replace(/bull/g,_t).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),bt=j(vt).replace(/bull/g,_t).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),P=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,xt=/^[^\n]+/,St=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/,Ct=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,St).replace(`title`,/(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex(),wt=j(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,_t).getRegex(),Tt=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Et=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Dt=j(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Et).replace(`tag`,Tt).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ot=e=>j(P).replace(`hr`,N).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Tt).getRegex(),kt=Ot(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),F=Ot(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),At={blockquote:j(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace(`paragraph`,F).getRegex(),code:mt,def:Ct,fences:ht,heading:gt,hr:N,html:Dt,lheading:yt,list:wt,newline:pt,paragraph:kt,table:k,text:xt},I=j(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,N).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Tt).getRegex(),jt={...At,lheading:bt,table:I,paragraph:j(P).replace(`hr`,N).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,I).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Tt).getRegex()},L={...At,html:j(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace(`comment`,Et).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:k,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(P).replace(`hr`,N).replace(`heading`,` *#{1,6} *[^
|
|
4
|
-
]`).replace(`lheading`,yt).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Mt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Nt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,R=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Pt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,z=/[\p{P}\p{S}]/u,Ft=/[\s\p{P}\p{S}]/u,It=/[^\s\p{P}\p{S}]/u,B=j(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Ft).getRegex(),Lt=/[\p{Pi}\p{Ps}"']/u,V=/(?!~)[\p{P}\p{S}]/u,Rt=/(?!~)[\s\p{P}\p{S}]/u,zt=/(?:[^\s\p{P}\p{S}]|~)/u,Bt=j(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,ft?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Vt=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ht=j(Vt,`u`).replace(/punct/g,z).getRegex(),Ut=j(Vt,`u`).replace(/punct/g,V).getRegex(),Wt=j(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Lt).replace(/punct/g,z).getRegex(),Gt=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Kt=j(Gt,`gu`).replace(/notPunctSpace/g,It).replace(/punctSpace/g,Ft).replace(/punct/g,z).getRegex(),qt=j(Gt,`gu`).replace(/notPunctSpace/g,zt).replace(/punctSpace/g,Rt).replace(/punct/g,V).getRegex(),Jt=j(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,It).replace(/punctSpace/g,Ft).replace(/punct/g,z).getRegex(),Yt=j(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,It).replace(/punctSpace/g,Ft).replace(/punct/g,z).getRegex(),H=j(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,It).replace(/punctSpace/g,Ft).replace(/punct/g,z).getRegex(),Xt=j(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,z).getRegex(),Zt=j(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,It).replace(/punctSpace/g,Ft).replace(/punct/g,z).getRegex(),Qt=j(/\\(punct)/,`gu`).replace(/punct/g,z).getRegex(),$t=j(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,z).getRegex(),en=j(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),tn=j(Et).replace(`(?:-->|$)`,`-->`).getRegex(),nn=j(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,tn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),rn=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,an=j(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,rn).getRegex(),U=j(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,an).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex(),on=j(/^!?\[(label)\]\[(ref)\]/).replace(`label`,an).replace(`ref`,St).getRegex(),sn=j(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,St).getRegex(),cn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,ln=j(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,rn).getRegex(),un=j(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,j(/^!?\[(label)\]\[(ref)\]/).replace(`label`,ln).replace(`ref`,cn).getRegex()).replace(`nolink`,j(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,cn).getRegex()).getRegex(),dn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,fn=j(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),pn={_backpedal:k,anyPunctuation:Qt,anyPunctuationOutsideCode:$t,autolink:en,blockSkip:Bt,br:R,code:Nt,del:k,delLDelim:k,delRDelim:k,emStrongLDelim:Ht,emStrongRDelimAst:Kt,emStrongRDelimUnd:Yt,escape:Mt,link:U,nolink:sn,punctuation:B,reflink:on,reflinkSearch:un,tag:nn,text:Pt,url:k},mn={...pn,emStrongLDelim:Wt,emStrongRDelimAst:Jt,emStrongRDelimUnd:H,link:j(/^!?\[(label)\]\((.*?)\)/).replace(`label`,an).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,an).getRegex()},hn={...pn,emStrongRDelimAst:qt,emStrongLDelim:Ut,delLDelim:Xt,delRDelim:Zt,url:j(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,fn).replace(`protocol`,dn).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:j(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|wwwStart|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,dn).replace(/emailProtocol/g,/(?:mailto|xmpp):/).replace(`wwwStart`,ft?`(?<![^\\s*_~(])www\\.`:`www\\.`).getRegex()},gn={...hn,br:j(R).replace(`{2,}`,`*`).getRegex(),text:j(hn.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},_n={normal:At,gfm:jt,pedantic:L},W={normal:pn,gfm:hn,breaks:gn,pedantic:mn},vn={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},yn=e=>vn[e];function G(e,t){if(t){if(M.escapeTest.test(e))return e.replace(M.escapeReplace,yn)}else if(M.escapeTestNoEncode.test(e))return e.replace(M.escapeReplaceNoEncode,yn);return e}function bn(e){return M.numericCharacterReference.test(e)?e.replace(M.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&`:String.fromCodePoint(r)}):e}function xn(e){try{e=encodeURI(e).replace(M.percentDecode,`%`)}catch{return null}return e}function Sn(e,t){let n=e.replace(M.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(M.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(M.slashPipe,`|`);return n}function K(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Cn(e){let t=e.split(`
|
|
5
|
-
`),n=t.length-1;for(;n>=0&&M.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
6
|
-
`)}function wn(e){return e.trim().replace(M.multipleSpaceGlobal,` `).toLowerCase().toUpperCase().toLowerCase()}function Tn(e,t){if(e.indexOf(t[0])===-1&&e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}var q=new WeakMap;function En(e){let t={"*":-1,_:-1},n=-1,r=e.length;for(let i=0;i<r;i++){let a=e[i];if(a!==`*`&&a!==`_`&&a!==`~`)continue;let o=i===0?`
|
|
7
|
-
`:e[i-1],s=i+1;for(;s<r&&e[s]===a;)s++;o!==` `&&o!==` `&&o!==`
|
|
8
|
-
`&&o!==`\r`&&o!==`\f`&&(a===`~`?n=i:t[a]=i),i=s-1}return{maskedSrc:e,lastPossibleEmStrongCloserIndex:t,lastPossibleDelCloserIndex:n}}function Dn(e,t){let n=En(t),r=q.get(e);r?r.push(n):q.set(e,[n])}function On(e){let t=q.get(e);t&&(t.pop(),t.length===0&&q.delete(e))}function kn(e,t,n){let r=q.get(e)?.at(-1);return r&&r.maskedSrc===t?r.lastPossibleEmStrongCloserIndex[n]:En(t).lastPossibleEmStrongCloserIndex[n]}function An(e,t){let n=q.get(e)?.at(-1);return n&&n.maskedSrc===t?n.lastPossibleDelCloserIndex:En(t).lastPossibleDelCloserIndex}function jn(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Mn(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`,l=r.state.inLink,u=r.state.linkEmitted,d=r.state.inRawBlock;r.state.inLink=!0,r.state.linkEmitted=!1;let f=r.inlineTokens(s),p=r.state.linkEmitted;if(r.state.linkEmitted=u,r.state.inLink=l,!c){if(p){r.state.inRawBlock=d;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:f}}function Nn(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
9
|
-
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(`
|
|
10
|
-
`)}function Pn(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var Fn=class{options;rules;lexer;constructor(e){this.options=e||D}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Cn(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Nn(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=K(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:K(t[0],`
|
|
11
|
-
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:K(t[0],`
|
|
12
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=K(t[0],`
|
|
13
|
-
`).split(`
|
|
14
|
-
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
15
|
-
`),c=s.replace(this.rules.other.blockquoteMarkerWhitespace,(e,t,n)=>t+jn(n,t.length)).replace(this.rules.other.blockquoteSetextReplace,`
|
|
16
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
17
|
-
${s}`:s,r=r?`${r}
|
|
18
|
-
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`||u?.type===`heading`||u?.type===`hr`||u?.type===`html`||u?.type===`table`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
|
|
19
|
-
`),o=t.raw+`
|
|
20
|
-
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s;let c=o.substring(s.raw.length).replace(/^\n/,``),l=c?c.split(`
|
|
21
|
-
`).length:0,d=l?e.slice(0,-l):e;if(d.length>0&&(n=`${n}
|
|
22
|
-
${d.join(`
|
|
23
|
-
`)}`),r=r.substring(0,r.length-t.text.length)+s.text,e=e.slice(d.length),e.length>0&&this.rules.other.blockquoteStart.test(e[0]))continue;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
24
|
-
`+e.join(`
|
|
25
|
-
`),o=this.list(a);i[i.length-1]=o;let s=o.raw.length>t.raw.length?a.slice(t.raw.length+1,o.raw.length).split(`
|
|
26
|
-
`).length:0;if(s>0){let t=e.slice(0,s).join(`
|
|
27
|
-
`);n=`${n}
|
|
28
|
-
${t}`,r=`${r}
|
|
29
|
-
${t}`}e=e.slice(s)}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){if(!this.options.pedantic&&this.lexer.state.lastToken?.type===`text`&&!this.rules.other.listInterruptsParagraph.test(e))return;let n=e,r=()=>n.length-e.length,i=t[1].trim(),a=i.length>1,o={type:`list`,raw:``,ordered:a,start:a?+i.slice(0,-1):``,loose:!1,items:[]};i=a?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=a?i:`[*+-]`);let s=this.rules.other.listItemRegex(i),c=!1;for(;e;){let i=!1,a=``;if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;let l=r();e=e.substring(t[0].length);let u=t[2].split(`
|
|
30
|
-
`,1)[0],d=t[1].length,f=this.options.pedantic?jn(u,d):u.replace(this.rules.other.leadingSpaceTab,e=>jn(e,d)),p=e.split(`
|
|
31
|
-
`,1)[0],m=!f.trim(),h=0;if(this.options.pedantic?(h=2,a=f.trimStart()):m?h=d+1:(h=f.search(this.rules.other.nonSpaceChar),h=h>4?1:h,a=f.slice(h),h+=d),m&&this.rules.other.blankLine.test(p)&&(e=e.substring(p.length+1),i=!0),!i){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),r=this.rules.other.fencesBeginRegex(h),i=this.options.pedantic?this.rules.other.pedanticHeadingBeginRegex(h):this.rules.other.headingBeginRegex(h),o=this.rules.other.htmlBeginRegex(h),s=this.rules.other.blockquoteBeginRegex(h),c=!1;for(;e;){let l=e.split(`
|
|
32
|
-
`,1)[0],u;if(p=l,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting,` `),u=p):u=p.replace(this.rules.other.leadingSpaceTab,e=>jn(e)),r.test(p)||i.test(p)||o.test(p)||s.test(p)||t.test(p)||n.test(p))break;if(u.search(this.rules.other.nonSpaceChar)>=h||!p.trim())a+=`
|
|
33
|
-
`+u.slice(h),c=!1;else{if(m||f.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||r.test(f)||i.test(f)||o.test(f)||n.test(f))break;if(!this.options.pedantic&&!c){let e=f.replace(this.rules.other.nestedContainerMarkers,``);if(this.rules.block.fences.test(e)||this.rules.block.heading.test(e)||this.rules.block.hr.test(e))break}let e=!this.options.pedantic&&/^ {0,3}(?:=+|-+) *$/.test(p)&&this.rules.block.lheading.test(`${f}
|
|
34
|
-
${p}`)?` ${u.replace(/^ {0,3}/,``)}`:p;a+=`
|
|
35
|
-
`+e,c=!0}m=!p.trim(),e=e.substring(l.length+1),f=u.slice(h)}}let g=n.slice(l,r());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(c=!0)),o.items.push({type:`list_item`,raw:g,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]})}let l=o.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;o.raw=n.slice(0,r()).trimEnd();for(let e of o.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!o.loose){let t=e.tokens.filter(e=>e.type===`space`);o.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of o.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,o.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(o.loose)for(let e of o.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Cn(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&Tn(t[2],`()`)!==-1)return;let e=wn(t[1]),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:K(t[0],`
|
|
36
|
-
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Sn(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
37
|
-
`):[],a={type:`table`,raw:K(t[0],`
|
|
38
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Sn(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:K(t[0],`
|
|
39
|
-
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
40
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&Pn(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=K(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=Tn(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let i=K(t[0].slice(0,-1),`\\`);if((t[0].length-i.length)%2==0)return;let a=t[2],o=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(a);e&&(a=e[1],o=e[3])}else o=t[3]?t[3].slice(1,-1):``;return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(a=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?a.slice(1):a.slice(1,-1)),Mn(t,{href:a&&a.replace(this.rules.inline.anyPunctuation,`$1`),title:o&&o.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&Pn(e,n[1],r,this.rules))return;let i=t[wn(n[2]||n[1])];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Mn(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||!r[1]&&!r[2]&&!r[3]&&!r[4])return;let i=r[0][0],a=n===i,o=t.length-e.length,s=o;for(;!this.options.pedantic&&s>0&&t[s-1]===i;)s--;let c=[...t.slice(Math.max(0,s-2),s)].at(-1)??``,l=c===`*`||c===`_`||!!this.rules.inline.punctuation.exec(c);s<o&&(n=c);let u=s<o?l:n===`*`||n===`_`||!!this.rules.inline.punctuation.exec(n);if(r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))return;let d=r[1]||r[3]||``;if(!d||!n||u){let n=[...r[0]].length-1,u,f,p=n,m=0,h=o-s+n,g=!this.options.pedantic&&!!c.trim()&&(!!d||i===`*`&&!l);if(i!==`*`&&i!==`_`)return;let ee=i===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd,te=kn(this,t,i),ne=t.length-e.length+n;if(te<ne)return;t=t.slice(-1*e.length+n);let _=te-ne;for(ee.lastIndex=0;(r=ee.exec(t))!==null&&!(r.index>_);){if(u=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!u)continue;if(f=[...u].length,r[3]||r[4]){p+=f;continue}if(r[5]||r[6]||g){if(a&&(r[5]||r[6]))break;if(h%3&&!((h+f)%3)){m+=f;continue}}if(p-=f,p>0)continue;f=Math.min(f,f+p+m);let t=[...r[0]][0].length,i=e.slice(0,n+r.index+t+f);if(Math.min(n,f)%2){let e=i.slice(1,-1);return{type:`em`,raw:i,text:e,tokens:this.lexer.inlineTokens(e)}}let o=i.slice(2,-2);return{type:`strong`,raw:i,text:o,tokens:this.lexer.inlineTokens(o)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim,c=An(this,t),l=t.length-e.length+n;if(c<l)return;t=t.slice(-1*e.length+n);let u=c-l;for(s.lastIndex=0;(r=s.exec(t))!==null&&!(r.index>u);){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:e?t[0]:bn(t[0]),escaped:e}}}},J=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||D,this.options.tokenizer=this.options.tokenizer||new Fn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let t={other:M,block:_n.normal,inline:W.normal};this.options.pedantic?(t.block=_n.pedantic,t.inline=W.pedantic):this.options.gfm&&(t.block=_n.gfm,t.inline=this.options.breaks?W.breaks:W.gfm),this.tokenizer.rules=t}static get rules(){return{block:_n,inline:W}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(M.carriageReturn,`
|
|
41
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.state.inRawBlock=!1,this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this;let r=this.state.lastToken;this.options.pedantic&&(e=e.replace(M.tabCharGlobal,` `).replace(M.spaceLine,``));let i=1/0;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}this.state.lastToken=t.at(-1);let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
|
|
42
|
-
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
43
|
-
`)?``:`
|
|
44
|
-
`)+r.raw,n.text+=`
|
|
45
|
-
`+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if((r=this.tokenizer.fences(e))||(r=this.tokenizer.heading(e))||(r=this.tokenizer.hr(e))||(r=this.tokenizer.blockquote(e))||(r=this.tokenizer.list(e))||(r=this.tokenizer.html(e))){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
46
|
-
`)?``:`
|
|
47
|
-
`)+r.raw,n.text+=`
|
|
48
|
-
`+r.raw,this.inlineQueue.at(-1).src=n.text):(this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title}),t.push(r));continue}if((r=this.tokenizer.table(e))||(r=this.tokenizer.lheading(e))){e=e.substring(r.raw.length),t.push(r);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(a))){let i=t.at(-1);n&&i?.type===`paragraph`?(i.raw+=(i.raw.endsWith(`
|
|
49
|
-
`)?``:`
|
|
50
|
-
`)+r.raw,i.text+=`
|
|
51
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):t.push(r),n=a.length!==e.length,e=e.substring(r.raw.length)}else if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
52
|
-
`)?``:`
|
|
53
|
-
`)+r.raw,n.text+=`
|
|
54
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,this.state.lastToken=r,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,wn(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=this.state.linkParenPossible;this.state.linkParenPossible=n&&e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e.includes(`*`)||e.includes(`_`)||e.includes(`~`)||this.options.hooks?.emStrongMask||this.tokenizer.emStrong!==Fn.prototype.emStrong||this.tokenizer.del!==Fn.prototype.del?this.#r(e):e;Dn(this.tokenizer,n);try{return this.#t(e,n,t)}finally{On(this.tokenizer)}}#t(e,t,n){let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(t=>(o=t.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))continue;if((o=this.tokenizer.escape(e))||(o=this.tokenizer.tag(e))||(o=this.tokenizer.link(e))){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let t=n.at(-1);o.type===`text`&&t?.type===`text`?(t.raw+=o.raw,t.text+=o.text):n.push(o);continue}if((o=this.tokenizer.emStrong(e,t,i))||(o=this.tokenizer.codespan(e))||(o=this.tokenizer.br(e))||(o=this.tokenizer.del(e,t,i))||(o=this.tokenizer.autolink(e))||!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),n.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let t=n.at(-1);t?.type===`text`?(t.raw+=o.raw,t.text+=o.text):n.push(o)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}#n(e){let{blockSkip:t,tag:n,autolink:r}=this.tokenizer.rules.inline,i=``,a=0,o;for(t.lastIndex=0;o=t.exec(e);){let s=o.index+(o[2]?o[2].length:0),c=o.index+o[0].length;if(e.charAt(s)===`<`){let i=e.slice(s),a=n.exec(i)||r.exec(i);if(!a){t.lastIndex=s+1;continue}c=s+a[0].length,t.lastIndex=c}i+=e.slice(a,s)+`[`+`a`.repeat(c-s-2)+`]`,a=c}return i+e.slice(a)}#r(e){let t=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,n=t=>{let r=t.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,wn(t.slice(r+1,-1))))return t;if(r>1&&t.charAt(0)!==`!`){let i=t.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,n)+`][`+`a`.repeat(t.length-r-2)+`]`}return`[`+`a`.repeat(t.length-2)+`]`};t=t.replace(e,n)}return t=t.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(e,t,n)=>n?`+`.repeat(e.length):t?t+e.slice(t.length,-t.length).replace(/`/g,`+`)+t:e),t=this.#n(t),t=this.options.hooks?.emStrongMask?.call({lexer:this},t)??t,t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},In=class{options;parser;constructor(e){this.options=e||D}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(M.notSpaceStart)?.[0],i=e?e.replace(M.endingNewline,``)+`
|
|
55
|
-
`:``;return r?`<pre><code class="language-`+G(r)+`">`+(n?i:G(i,!0))+`</code></pre>
|
|
56
|
-
`:`<pre><code>`+(n?i:G(i,!0))+`</code></pre>
|
|
57
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
58
|
-
${this.parser.parse(e)}</blockquote>
|
|
59
|
-
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
60
|
-
`}hr(e){return`<hr>
|
|
61
|
-
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
62
|
-
`+r+`</`+i+`>
|
|
63
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
64
|
-
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
65
|
-
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
66
|
-
<thead>
|
|
67
|
-
`+t+`</thead>
|
|
68
|
-
`+r+`</table>
|
|
69
|
-
`}tablerow({text:e}){return`<tr>
|
|
70
|
-
${e}</tr>
|
|
71
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
72
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${G(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?G(n,!0):this.parser.parseInline(r),o=xn(e);if(o===null)return a;e=G(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+G(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=xn(e);if(i===null)return G(n);e=i;let a=`<img src="${G(e)}" alt="${G(n)}"`;return t&&(a+=` title="${G(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:G(e.text)}},Ln=class{parser;strong({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}em({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}codespan({text:e}){return e}del({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}html({text:e}){return e}text({text:e}){return e}link({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}image({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}br(){return`
|
|
73
|
-
`}checkbox({raw:e}){return e}},Y=class e{options;renderer;textRenderer;constructor(e){this.options=e||D,this.options.renderer=this.options.renderer||new In,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ln,this.textRenderer.parser=this}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n===!1?``:n??``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e===!1?``:e??``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Rn=class{options;block;constructor(e){this.options=e||D}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?J.lex:J.lexInline}provideParser(e=this.block){return e?Y.parse:Y.parseInline}};function X(e,t){if(Array.isArray(t))for(let n=0;n<t.length;n++)e.push(t[n]);else e.push(t)}var zn=class{defaults=dt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Y;Renderer=In;TextRenderer=Ln;Lexer=J;Tokenizer=Fn;Hooks=Rn;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(X(n,t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)X(n,this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)X(n,this.walkTokens(e.tokens,t));break}case`list`:{let e=r;X(n,this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);X(n,this.walkTokens(i,t))}):e.tokens&&X(n,this.walkTokens(e.tokens,t))}}return n}use(...e){let t=this.defaults.extensions||{renderers:Object.create(null),childTokens:Object.create(null)};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new In(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n===!1?``:n??``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Fn(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Rn;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Rn.passThroughHooks.has(n)?e=>{if(t.options.async&&Rn.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(t.options.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return X(n,r.call(this,e)),t&&X(n,t.call(this,e)),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return J.lex(e,t??this.defaults)}parser(e,t){return Y.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?J.lex:J.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Y.parse:Y.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?J.lex:J.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Y.parse:Y.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
74
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+G(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Z=new zn;function Q(e,t){return Z.parse(e,t)}Q.options=Q.setOptions=function(e){return Z.setOptions(e),Q.defaults=Z.defaults,O(Q.defaults),Q},Q.getDefaults=dt,Q.defaults=D;function Bn(...e){return Z.use(...e),Q.defaults=Z.defaults,O(Q.defaults),Q}Q.use=Bn,Q.walkTokens=function(e,t){return Z.walkTokens(e,t)},Q.parseInline=Z.parseInline,Q.Parser=Y,Q.parser=Y.parse,Q.Renderer=In,Q.TextRenderer=Ln,Q.Lexer=J,Q.lexer=J.lex,Q.Tokenizer=Fn,Q.Hooks=Rn,Q.parse=Q,Q.options,Q.setOptions,Q.walkTokens,Q.parseInline,Y.parse,J.lex;export{Q as n,ut as r,zn as t};
|