@puddle-code/cli 0.0.14 → 0.0.16
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/CHANGELOG.md +19 -41
- package/README.md +7 -0
- package/dist/index.js +18 -3
- package/dist/public/assets/Dashboard-CtZlkE5U.js +1 -0
- package/dist/public/assets/EditorTabClose-BFw75E8R.js +1 -0
- package/dist/public/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/public/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/public/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/public/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/public/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/public/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/public/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/public/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/public/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/public/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/public/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/public/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/public/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/public/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/public/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/public/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/public/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/public/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/public/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/public/assets/LazyTerminal-cG7dCkyV.js +2 -0
- package/dist/public/assets/ModelRefcount-IW7hUUf9.js +1 -0
- package/dist/public/assets/PaneEditorBody-DA3-1W6W.js +322 -0
- package/dist/public/assets/PaneEditorBody-Dz-67XSV.css +1 -0
- package/dist/public/assets/SettingsDialog-D-oGeh0Z.js +1 -0
- package/dist/public/assets/{Terminal-DA8zjtmU.js → Terminal-NijDOcpZ.js} +18 -18
- package/dist/public/assets/Workspace-hBoBilwE.js +7 -0
- package/dist/public/assets/_virtual_katex-inline-css-DN-_JSKR.js +2 -0
- package/dist/public/assets/{api-Bh5IJ30S.js → api-DT1aed3K.js} +1 -1
- package/dist/public/assets/{buffer-store-BHJ82Nh3.js → buffer-store-CaznA05X.js} +3 -3
- package/dist/public/assets/context-menu-DpbvYsmG.js +1 -0
- package/dist/public/assets/{cssMode-Ctq00nXG.js → cssMode-DrMmLKy7.js} +1 -1
- package/dist/public/assets/dist-i-QevsUb.js +1 -0
- package/dist/public/assets/editor-sync-f1V6Wuxn.js +1 -0
- package/dist/public/assets/editor-tabs-QRn6z-xC.js +1 -0
- package/dist/public/assets/{htmlMode-pYCLPiZ_.js → htmlMode-D7fMiQgq.js} +1 -1
- package/dist/public/assets/index-BJ6qpNjc.js +10 -0
- package/dist/public/assets/index-qL_4L359.css +2 -0
- package/dist/public/assets/{jsonMode-Ch5UticT.js → jsonMode-Ck9UDuO6.js} +1 -1
- package/dist/public/assets/profile-store--YCT1sQn.js +1 -0
- package/dist/public/assets/{session-seed-DBxHPYBK.js → session-seed-BH2gKlwV.js} +1 -1
- package/dist/public/assets/ssh-mode-02k1gbAH.js +1 -0
- package/dist/public/assets/{tsMode-CeXrzlPn.js → tsMode-DtQBZIna.js} +1 -1
- package/dist/public/index.html +5 -5
- package/package.json +1 -1
- package/dist/public/assets/Dashboard-Ct5exI8s.js +0 -1
- package/dist/public/assets/EditorTabClose-BhFjRoCZ.js +0 -1
- package/dist/public/assets/LazyTerminal-B0xYs2ul.js +0 -2
- package/dist/public/assets/ModelRefcount-BY5Ul0p3.js +0 -1
- package/dist/public/assets/PaneEditorBody-DLMtDiov.js +0 -66
- package/dist/public/assets/SettingsDialog-WhQXNCmS.js +0 -1
- package/dist/public/assets/Workspace-B0FDl771.js +0 -6
- package/dist/public/assets/context-menu--H5GoapF.js +0 -1
- package/dist/public/assets/dist-VDiYuPKw.js +0 -1
- package/dist/public/assets/editor-sync-F3Wyveaa.js +0 -1
- package/dist/public/assets/editor-tabs-D0_DZriG.js +0 -1
- package/dist/public/assets/index-CjgsCY-C.css +0 -2
- package/dist/public/assets/index-RvCLpi9M.js +0 -10
- package/dist/public/assets/poll-focus-B7dQPFj6.js +0 -1
- package/dist/public/assets/ssh-mode-eNTVum_C.js +0 -1
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{_ as r,b as i,c as a,g as o,i as s,n as c,o as l,p as u,r as d,t as ee,v as te,y as f}from"./editor-tabs-D0_DZriG.js";import{r as p,t as m,x as ne}from"./api-Bh5IJ30S.js";import{t as re}from"./createLucideIcon-DyMAgLa3.js";import{g as h,h as g,k as _,m as v}from"./index-RvCLpi9M.js";import{i as y,r as ie}from"./editor.api2-4X9Vh9Zw.js";import{a as b,c as ae,d as x,f as oe,i as se,l as ce,n as le,o as ue,r as de,s as fe,t as pe,u as S}from"./buffer-store-BHJ82Nh3.js";import{a as me,c as he,i as ge,l as _e,n as ve,o as ye,r as be,s as xe}from"./editor-sync-F3Wyveaa.js";import{r as Se}from"./buffer-logic-BrpRsL1b.js";var C=re(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),w=e(t(),1);function T(e){return!e}function Ce(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=y.CtrlCmd:e===`ctrl`?r|=y.WinCtrl:e===`alt`?r|=y.Alt:e===`shift`&&(r|=y.Shift);let i=ie[/^Key[A-Z]$/.test(n)?`Key${n.slice(3)}`:/^Digit[0-9]$/.test(n)?`Digit${n.slice(5)}`:n];return typeof i==`number`?r|i:null}function E(e,t){let n=Ce(_(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Ce(_(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>g({editorWordWrap:T(v().editorWordWrap)})})}function we(e,t,n){let r=pe(e,t),a=i(e,t),o=te(e),[s,c]=(0,w.useState)(null),[l,u]=(0,w.useState)(!1),d=(0,w.useRef)(!1),ee=(0,w.useRef)(null),f=(0,w.useRef)(null),p=(0,w.useRef)(n);p.current=n;let re=(0,w.useRef)(!1),h=(0,w.useCallback)((e,t)=>{f.current?.cancel(),re.current=!0;try{ue(r,e,t)}finally{re.current=!1}},[r]),g=(0,w.useSyncExternalStore)((0,w.useCallback)(e=>ce(r,e),[r]),()=>de(r)),_=(0,w.useSyncExternalStore)((0,w.useCallback)(e=>ye(r,e),[r]),()=>me(r));(0,w.useEffect)(()=>{let n=a.data;if(!n||n.binary||n.content===null||d.current)return;d.current=!0;let i=ae(r)!==void 0,o=le(e,t,n.content,n.mtime_ms);c(o),!i&&_e(e,t).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?Se(o,e.content)&&u(!0):ne(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{Se(o,e.content)&&u(!0)}}}))})},[a.data,r,e,t]),(0,w.useEffect)(()=>{if(!s)return;let n=he(e,t);f.current=n;let i=s.onDidChangeContent(()=>{re.current||(n(s.getValue(),ae(r)??0),ve(e,t))});return()=>{n.flush(),i.dispose(),f.current=null}},[s,r,e,t]),(0,w.useEffect)(()=>{!s||!_.savedElsewhere||de(r)||a.refetch().then(e=>{de(r)||(e.data&&e.data.content!==null&&h(e.data.content,e.data.mtime_ms),ge(r))})},[_.savedElsewhere,s,r]),(0,w.useEffect)(()=>{let e=a.data;!s||!e||e.content===null||!de(r)&&e.mtime_ms!==ae(r)&&h(e.content,e.mtime_ms)},[a.data,s,r]);let v=(0,w.useCallback)((n,i)=>{se(r,n,i),f.current?.cancel(),xe(e,t),be(e,t,i),u(!1)},[r,e,t]),y=(0,w.useCallback)(()=>{a.refetch().then(n=>{n.data&&n.data.content!==null&&h(n.data.content,n.data.mtime_ms),xe(e,t),u(!1)})},[r,e,t,h]),ie=(0,w.useCallback)((e,n)=>{o.mutate({path:t,content:e},{onSuccess:e=>v(n,e.mtime_ms),onError:e=>ne.error(e instanceof Error?e.message:`Overwrite failed`)})},[o,t,v]),b=(0,w.useCallback)(()=>{if(!s||!de(r))return;let e=s.getValue(),n=s.getAlternativeVersionId();o.mutate({path:t,content:e,expected_mtime_ms:ae(r)},{onSuccess:e=>v(n,e.mtime_ms),onError:t=>{t instanceof m&&t.status===409&&t.code===`stale_file`?ne.error(`File changed on disk (probably the agent)`,{duration:1/0,action:{label:`Reload`,onClick:()=>y()},cancel:{label:`Overwrite`,onClick:()=>ie(e,n)}}):ne.error(t instanceof Error?t.message:`Save failed`)}})},[s,r,o,t,v,y,ie]),x=(0,w.useRef)(b);x.current=b;let oe=(0,w.useCallback)(()=>{let n=ee.current,r=p.current;!n||!r||r.session!==e||r.path!==t||(n.revealLineInCenter(r.line),n.setPosition({lineNumber:r.line,column:r.column??1}),n.focus())},[e,t]),fe=(0,w.useCallback)(e=>{ee.current=e,E(e,{onSave:()=>x.current()}),oe()},[oe]);(0,w.useEffect)(()=>{oe()},[n,s,oe]);let S=(0,w.useCallback)(()=>{y()},[y]),C,T=null;a.data?.binary?C=`binary`:a.error?a.error instanceof m&&a.error.status===413?C=`too-large`:(C=`error`,T=a.error instanceof Error?a.error.message:`Failed to load file`):C=s?`ready`:`loading`;let Ce=g&&_.savedElsewhere?`saved-elsewhere`:g&&_.dirtyElsewhere?`dirty-elsewhere`:null;return{status:C,errorMessage:T,model:s,dirty:g,restoredNotice:l,discardRestore:S,peerBadge:Ce,save:b,onMount:fe}}var D=n();function O({message:e,session:t,path:n,download:r}){return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e}),r&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void u(t,n).catch(e=>ne.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,D.jsx)(C,{className:`size-4`}),`Download`]})]})}function Te({session:e,path:t,reveal:n}){let r=h(),i=we(e,t,n),a=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(i.status===`binary`)return(0,D.jsx)(O,{message:`Binary file — use Download`,session:e,path:t,download:!0});if(i.status===`too-large`)return(0,D.jsx)(O,{message:`File too large to edit — use Download`,session:e,path:t,download:!0});if(i.status===`error`)return(0,D.jsx)(O,{message:i.errorMessage??`Failed to load file`,session:e,path:t});let o=i.peerBadge===`saved-elsewhere`?`Saved in another window`:i.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[i.restoredNotice&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`Restored unsaved changes`}),(0,D.jsx)(`button`,{type:`button`,onClick:i.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),o&&(0,D.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:o}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:i.model&&(0,D.jsx)(x,{path:i.model.uri.toString(),defaultValue:i.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>i.onMount(e),loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:a,tabSize:r.editorTabSize,wordWrap:r.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function k({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Ee(e,t){let n=(0,w.useRef)(t);n.current=t,(0,w.useEffect)(()=>(fe(e),()=>{n.current?.(),b(e)}),[e])}function De(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function A({session:e,refName:t,path:n,content:r}){let i=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.jsx)(x,{path:De(`puddle-view`,e,t,n),defaultValue:r,theme:S,loading:(0,D.jsx)(k,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:i,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function j({session:e,against:t,path:n}){let i=r(e,t,n);return i.isPending?(0,D.jsx)(k,{children:`…`}):i.error?(0,D.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load`}):i.data.binary?(0,D.jsx)(k,{children:`Binary file — deleted`}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(A,{session:e,refName:t,path:n,content:i.data.content??``})})]})}function Oe({session:e,against:t,path:n,basePath:i}){let a=h(),o=we(e,n,null),s=r(e,t,i),c=(0,w.useRef)(null);Ee(pe(e,n),()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),c.current=null});let l=(0,w.useRef)(o.save);l.current=o.save;let u=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=s.error instanceof m&&s.error.status===404;return o.status===`binary`||s.data?.binary?(0,D.jsx)(k,{children:`Binary file`}):o.status===`too-large`?(0,D.jsx)(k,{children:`File too large to show`}):o.status===`error`?(0,D.jsx)(k,{children:o.errorMessage??`Failed to load file`}):d?(0,D.jsx)(Te,{session:e,path:n,reveal:null}):s.isPending||!o.model?(0,D.jsx)(k,{children:`…`}):s.error?(0,D.jsx)(k,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,D.jsx)(oe,{modifiedModelPath:o.model.uri.toString(),originalModelPath:De(`puddle-base`,e,t,i),original:s.data.content??``,language:o.model.getLanguageId(),theme:S,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null}),e.getModifiedEditor().addCommand(y.CtrlCmd|ie.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,wordWrap:a.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function ke({session:e,path:t}){return Ee(pe(e,t)),(0,D.jsx)(Te,{session:e,path:t,reveal:null})}function Ae({session:e,against:t,entry:n}){switch(n.status){case`added`:return(0,D.jsx)(ke,{session:e,path:n.path});case`deleted`:return(0,D.jsx)(j,{session:e,against:t,path:n.path});case`modified`:case`renamed`:return(0,D.jsx)(Oe,{session:e,against:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function je({session:e,sha:t,path:n}){let i=r(e,t,n);return i.isPending?(0,D.jsx)(k,{children:`…`}):i.error?(0,D.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load file`}):i.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(A,{session:e,refName:t,path:n,content:i.data.content??``})}function Me({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=(0,w.useRef)(null),c=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,w.useEffect)(()=>()=>{let e=s.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),s.current=null},[]),(0,D.jsx)(oe,{originalModelPath:De(`puddle-hist-orig`,e,t,n),modifiedModelPath:De(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:S,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{s.current=e,e.onDidDispose(()=>{s.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Ne({session:e,sha:t,path:n,basePath:i}){let a=r(e,`${t}^`,i),o=r(e,t,n);return a.error instanceof m&&a.error.status===404?(0,D.jsx)(je,{session:e,sha:t,path:n}):a.isPending||o.isPending?(0,D.jsx)(k,{children:`…`}):a.error?(0,D.jsx)(k,{children:a.error instanceof Error?a.error.message:`Failed to load original`}):o.error?(0,D.jsx)(k,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):a.data.binary||o.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(Me,{session:e,originalRef:`${t}^`,originalPath:i,originalContent:a.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``})}function Pe({session:e,sha:t,entry:n,isRootCommit:r}){switch(a(n.status,r)){case`added`:return(0,D.jsx)(je,{session:e,sha:t,path:n.path});case`deleted`:return(0,D.jsx)(j,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,D.jsx)(Ne,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function Fe({session:e,sha:t,path:n}){let r=o(e,t);if(r.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(r.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load commit`});let i=r.data.files.find(e=>e.path===n);return i?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Pe,{session:e,sha:t,entry:i,isRootCommit:r.data.parents.length===0})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`font-mono`,children:n}),` is not part of `,t.slice(0,7),`.`]})}function Ie({session:e,path:t}){let n=f(e);if(n.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(n.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load diff`});let r=n.data.entries.find(e=>e.path===t);return r?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Ae,{session:e,against:n.data.against,entry:r})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,D.jsx)(`span`,{className:`mx-1 font-mono`,children:t}),` against the base.`]})}function Le(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 Re(e){if(Array.isArray(e))return e}function ze(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)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 Be(){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 Ve(e,t){return Re(e)||ze(e,t)||M(e,t)||Be()}function M(e,t){if(e){if(typeof e==`string`)return Le(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Le(e,t):void 0}}var He=Object.entries,Ue=Object.setPrototypeOf,We=Object.isFrozen,Ge=Object.getPrototypeOf,Ke=Object.getOwnPropertyDescriptor,N=Object.freeze,P=Object.seal,qe=Object.create,Je=typeof Reflect<`u`&&Reflect,Ye=Je.apply,Xe=Je.construct;N||=function(e){return e},P||=function(e){return e},Ye||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Xe||=function(e){return new e(...[...arguments].slice(1))};var Ze=R(Array.prototype.forEach),Qe=R(Array.prototype.lastIndexOf),$e=R(Array.prototype.pop),et=R(Array.prototype.push),tt=R(Array.prototype.splice),nt=Array.isArray,rt=R(String.prototype.toLowerCase),it=R(String.prototype.toString),at=R(String.prototype.match),ot=R(String.prototype.replace),st=R(String.prototype.indexOf),ct=R(String.prototype.trim),F=R(Number.prototype.toString),lt=R(Boolean.prototype.toString),ut=typeof BigInt>`u`?null:R(BigInt.prototype.toString),dt=typeof Symbol>`u`?null:R(Symbol.prototype.toString),I=R(Object.prototype.hasOwnProperty),ft=R(Object.prototype.toString),L=R(RegExp.prototype.test),pt=mt(TypeError);function R(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return Ye(e,t,n)}}function mt(e){return function(){return Xe(e,[...arguments])}}function z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:rt;if(Ue&&Ue(e,null),!nt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(We(t)||(t[r]=e),i=e)}e[i]=!0}return e}function ht(e){for(let t=0;t<e.length;t++)I(e,t)||(e[t]=null);return e}function B(e){let t=qe(null);for(let r of He(e)){var n=Ve(r,2);let i=n[0],a=n[1];I(e,i)&&(nt(a)?t[i]=ht(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=B(a):t[i]=a)}return t}function gt(e){switch(typeof e){case`string`:return e;case`number`:return F(e);case`boolean`:return lt(e);case`bigint`:return ut?ut(e):`0`;case`symbol`:return dt?dt(e):`Symbol()`;case`undefined`:return ft(e);case`function`:case`object`:{if(e===null)return ft(e);let t=e,n=V(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:ft(e)}return ft(e)}default:return ft(e)}}function V(e,t){for(;e!==null;){let n=Ke(e,t);if(n){if(n.get)return R(n.get);if(typeof n.value==`function`)return R(n.value)}e=Ge(e)}function n(){return null}return n}function _t(e){try{return L(e,``),!0}catch{return!1}}var vt=N(`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(`.`)),yt=N(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),bt=N([`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`]),xt=N([`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`]),St=N(`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(`.`)),Ct=N([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),wt=N([`#text`]),Tt=N(`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(`.`)),Et=N(`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.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.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(`.`)),Dt=N(`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(`.`)),Ot=N([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),kt=P(/{{[\w\W]*|^[\w\W]*}}/g),At=P(/<%[\w\W]*|^[\w\W]*%>/g),jt=P(/\${[\w\W]*/g),Mt=P(/^data-[\-\w.\u00B7-\uFFFF]+$/),Nt=P(/^aria-[\-\w]+$/),Pt=P(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ft=P(/^(?:\w+script|data):/i),It=P(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Lt=P(/^html$/i),Rt=P(/^[a-z][.\w]*(-[.\w]+)+$/i),zt=P(/<[/\w!]/g),Bt=P(/<[/\w]/g),Vt=P(/<\/no(script|embed|frames)/i),Ht=P(/\/>/i),H={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ut=function(){return typeof window>`u`?null:window},Wt=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}},Gt=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Kt=function(e,t,n,r){return I(e,t)&&nt(e[t])?z(r.base?B(r.base):{},e[t],r.transform):n};function qt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ut(),t=e=>qt(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==H.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,ee=V(d,`cloneNode`),te=V(d,`remove`),f=V(d,`nextSibling`),p=V(d,`childNodes`),m=V(d,`parentNode`),ne=V(d,`shadowRoot`),re=V(d,`attributes`),h=o&&o.prototype?V(o.prototype,`nodeType`):null,g=o&&o.prototype?V(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let _,v=``,y,ie=!1,b=0,ae=function(){if(b>0)throw pt(`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.`)},x=function(e){ae(),b++;try{return _.createHTML(e)}finally{b--}},oe=function(e){ae(),b++;try{return _.createScriptURL(e)}finally{b--}},se=function(){return ie||=(y=Wt(u,i),!0),y},ce=n,le=ce.implementation,ue=ce.createNodeIterator,de=ce.createDocumentFragment,fe=ce.getElementsByTagName,pe=r.importNode,S=Gt();t.isSupported=typeof He==`function`&&typeof m==`function`&&le&&le.createHTMLDocument!==void 0;let me=kt,he=At,ge=jt,_e=Mt,ve=Nt,ye=Ft,be=It,xe=Rt,Se=Pt,C=null,w=z({},[...vt,...yt,...bt,...St,...wt]),T=null,Ce=z({},[...Tt,...Et,...Dt,...Ot]),E=Object.seal(qe(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),we=null,D=null,O=Object.seal(qe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Te=!0,k=!0,Ee=!1,De=!0,A=!1,j=!0,Oe=!1,ke=!1,Ae=null,je=null,Me=!1,Ne=!1,Pe=!1,Fe=!1,Ie=!0,Le=!1,Re=`user-content-`,ze=!0,Be=!1,Ve={},M=null,Ue=z({},`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(`.`)),We=null,Ge=z({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ke=null,Je=z({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ye=`http://www.w3.org/1998/Math/MathML`,Xe=`http://www.w3.org/2000/svg`,F=`http://www.w3.org/1999/xhtml`,lt=F,ut=!1,dt=null,ft=z({},[Ye,Xe,F],it),R=N([`mi`,`mo`,`mn`,`ms`,`mtext`]),mt=z({},R),ht=N([`annotation-xml`]),Jt=z({},ht),Yt=z({},[`title`,`style`,`font`,`a`,`script`]),U=null,Xt=[`application/xhtml+xml`,`text/html`],W=null,G=null,K=n.createElement(`form`),Zt=function(e){return e instanceof RegExp||e instanceof Function},q=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(G&&G===e)return;(!e||typeof e!=`object`)&&(e={}),e=B(e),U=Xt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,W=U===`application/xhtml+xml`?it:rt,C=Kt(e,`ALLOWED_TAGS`,w,{transform:W}),T=Kt(e,`ALLOWED_ATTR`,Ce,{transform:W}),dt=Kt(e,`ALLOWED_NAMESPACES`,ft,{transform:it}),Ke=Kt(e,`ADD_URI_SAFE_ATTR`,Je,{transform:W,base:Je}),We=Kt(e,`ADD_DATA_URI_TAGS`,Ge,{transform:W,base:Ge}),M=Kt(e,`FORBID_CONTENTS`,Ue,{transform:W}),we=Kt(e,`FORBID_TAGS`,B({}),{transform:W}),D=Kt(e,`FORBID_ATTR`,B({}),{transform:W}),Ve=I(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?B(e.USE_PROFILES):e.USE_PROFILES:!1,Te=e.ALLOW_ARIA_ATTR!==!1,k=e.ALLOW_DATA_ATTR!==!1,Ee=e.ALLOW_UNKNOWN_PROTOCOLS||!1,De=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,A=e.SAFE_FOR_TEMPLATES||!1,j=e.SAFE_FOR_XML!==!1,Oe=e.WHOLE_DOCUMENT||!1,Ne=e.RETURN_DOM||!1,Pe=e.RETURN_DOM_FRAGMENT||!1,Fe=e.RETURN_TRUSTED_TYPE||!1,Me=e.FORCE_BODY||!1,Ie=e.SANITIZE_DOM!==!1,Le=e.SANITIZE_NAMED_PROPS||!1,ze=e.KEEP_CONTENT!==!1,Be=e.IN_PLACE||!1,Se=_t(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Pt,lt=typeof e.NAMESPACE==`string`?e.NAMESPACE:F,mt=I(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?B(e.MATHML_TEXT_INTEGRATION_POINTS):z({},R),Jt=I(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?B(e.HTML_INTEGRATION_POINTS):z({},ht);let t=I(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?B(e.CUSTOM_ELEMENT_HANDLING):qe(null);if(E=qe(null),I(t,`tagNameCheck`)&&Zt(t.tagNameCheck)&&(E.tagNameCheck=t.tagNameCheck),I(t,`attributeNameCheck`)&&Zt(t.attributeNameCheck)&&(E.attributeNameCheck=t.attributeNameCheck),I(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(E.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),P(E),A&&(k=!1),Pe&&(Ne=!0),Ve&&(C=z({},wt),T=qe(null),Ve.html===!0&&(z(C,vt),z(T,Tt)),Ve.svg===!0&&(z(C,yt),z(T,Et),z(T,Ot)),Ve.svgFilters===!0&&(z(C,bt),z(T,Et),z(T,Ot)),Ve.mathMl===!0&&(z(C,St),z(T,Dt),z(T,Ot))),O.tagCheck=null,O.attributeCheck=null,I(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?O.tagCheck=e.ADD_TAGS:nt(e.ADD_TAGS)&&(C===w&&(C=B(C)),z(C,e.ADD_TAGS,W))),I(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?O.attributeCheck=e.ADD_ATTR:nt(e.ADD_ATTR)&&(T===Ce&&(T=B(T)),z(T,e.ADD_ATTR,W))),I(e,`ADD_URI_SAFE_ATTR`)&&nt(e.ADD_URI_SAFE_ATTR)&&z(Ke,e.ADD_URI_SAFE_ATTR,W),I(e,`FORBID_CONTENTS`)&&nt(e.FORBID_CONTENTS)&&(M===Ue&&(M=B(M)),z(M,e.FORBID_CONTENTS,W)),I(e,`ADD_FORBID_CONTENTS`)&&nt(e.ADD_FORBID_CONTENTS)&&(M===Ue&&(M=B(M)),z(M,e.ADD_FORBID_CONTENTS,W)),ze&&(C[`#text`]=!0),Oe&&z(C,[`html`,`head`,`body`]),C.table&&(z(C,[`tbody`]),delete we.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw pt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw pt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=_;_=e.TRUSTED_TYPES_POLICY;try{v=x(``)}catch(e){throw _=t,e}}else e.TRUSTED_TYPES_POLICY===null?(_=void 0,v=``):(_===void 0&&(_=se()),_&&typeof v==`string`&&(v=x(``)));N&&N(e),G=e},Qt=z({},[...yt,...bt,...xt]),$t=z({},[...St,...Ct]),en=function(e,t,n){return t.namespaceURI===F?e===`svg`:t.namespaceURI===Ye?e===`svg`&&(n===`annotation-xml`||mt[n]):!!Qt[e]},tn=function(e,t,n){return t.namespaceURI===F?e===`math`:t.namespaceURI===Xe?e===`math`&&Jt[n]:!!$t[e]},nn=function(e,t,n){return t.namespaceURI===Xe&&!Jt[n]||t.namespaceURI===Ye&&!mt[n]?!1:!$t[e]&&(Yt[e]||!Qt[e])},rn=function(e){let t=m(e);(!t||!t.tagName)&&(t={namespaceURI:lt,tagName:`template`});let n=rt(e.tagName),r=rt(t.tagName);return dt[e.namespaceURI]?e.namespaceURI===Xe?en(n,t,r):e.namespaceURI===Ye?tn(n,t,r):e.namespaceURI===F?nn(n,t,r):!!(U===`application/xhtml+xml`&&dt[e.namespaceURI]):!1},J=function(e){et(t.removed,{element:e});try{m(e).removeChild(e)}catch{if(te(e),!m(e))throw pt(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},an=function(e){cn(e);let t=p(e);if(t){let e=[];Ze(t,t=>{et(e,t)}),Ze(e,e=>{try{te(e)}catch{}})}let n=re(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},on=function(e,n){try{et(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{et(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Ne||Pe)try{J(n)}catch{}else try{n.setAttribute(e,``)}catch{}},sn=function(e){let t=re(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||T[W(i)]))try{e.removeAttribute(i)}catch{}}},cn=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(h?h(e):e.nodeType)===H.element&&sn(e);let n=p(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},ln=function(e){if(!j)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=h?h(e):e.nodeType;if(n===H.processingInstruction||n===H.comment&&L(Bt,e.data)){try{te(e)}catch{}continue}if(n===H.element){let t=e,n=W(g?g(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=p(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},un=function(e){let t=null,r=null;if(Me)e=`<remove></remove>`+e;else{let t=at(e,/^[\r\n\t ]+/);r=t&&t[0]}U===`application/xhtml+xml`&<===F&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=_?x(e):e;if(lt===F)try{t=new l().parseFromString(i,U)}catch{}if(!t||!t.documentElement){t=le.createDocument(lt,`template`,null);try{t.documentElement.innerHTML=ut?v:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),lt===F?fe.call(t,Oe?`html`:`body`)[0]:Oe?t.documentElement:a},dn=function(e){return ue.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},fn=function(e){return e=ot(e,me,` `),e=ot(e,he,` `),e=ot(e,ge,` `),e},pn=function(e){e.normalize();let t=ue.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=fn(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&Ze(r,e=>{hn(e.content)&&pn(e.content)})},mn=function(e){let t=g?g(e):null;return typeof t!=`string`||W(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==re(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==h(e)||e.childNodes!==p(e)},hn=function(e){if(!h||typeof e!=`object`||!e)return!1;try{return h(e)===H.documentFragment}catch{return!1}},gn=function(e){if(!h||typeof e!=`object`||!e)return!1;try{return typeof h(e)==`number`}catch{return!1}};function Y(e,n,r){e.length!==0&&Ze(e,e=>{e.call(t,n,r,G)})}let _n=function(e,t){return!!(j&&e.hasChildNodes()&&!gn(e.firstElementChild)&&L(zt,e.textContent)&&L(zt,e.innerHTML)||j&&e.namespaceURI===F&&t===`style`&&gn(e.firstElementChild)||e.nodeType===H.processingInstruction||j&&e.nodeType===H.comment&&L(Bt,e.data))},vn=function(e,t){if(!we[t]&&Sn(t)&&(E.tagNameCheck instanceof RegExp&&L(E.tagNameCheck,t)||E.tagNameCheck instanceof Function&&E.tagNameCheck(t)))return!1;if(ze&&!M[t]){let t=m(e),n=p(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Be?n[i]:ee(n[i],!0);t.insertBefore(r,f(e))}}}return J(e),!0},yn=function(e,n){if(Y(S.beforeSanitizeElements,e,null),e!==n&&m(e)===null)return!0;if(mn(e))return J(e),!0;let r=W(g?g(e):e.nodeName);if(Y(S.uponSanitizeElement,e,{tagName:r,allowedTags:C}),e!==n&&m(e)===null)return!0;if(_n(e,r))return J(e),!0;if(we[r]||!(O.tagCheck instanceof Function&&O.tagCheck(r))&&!C[r]){let t=vn(e,r);return t===!1&&Y(S.afterSanitizeElements,e,null),t}if((h?h(e):e.nodeType)===H.element&&!rn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&L(Vt,e.innerHTML))return J(e),!0;if(A&&e.nodeType===H.text){let n=fn(e.textContent);e.textContent!==n&&(et(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Y(S.afterSanitizeElements,e,null),!1},bn=function(e,t,r){if(D[t]||j&&t===`patchsrc`||j&&t===`for`&&e!==`label`&&e!==`output`||Ie&&(t===`id`||t===`name`)&&(r in n||r in K))return!1;let i=T[t]||O.attributeCheck instanceof Function&&O.attributeCheck(t,e);if(!(k&&L(_e,t))&&!(Te&&L(ve,t))){if(!i){if(!(Sn(e)&&(E.tagNameCheck instanceof RegExp&&L(E.tagNameCheck,e)||E.tagNameCheck instanceof Function&&E.tagNameCheck(e))&&(E.attributeNameCheck instanceof RegExp&&L(E.attributeNameCheck,t)||E.attributeNameCheck instanceof Function&&E.attributeNameCheck(t,e))||t===`is`&&E.allowCustomizedBuiltInElements&&(E.tagNameCheck instanceof RegExp&&L(E.tagNameCheck,r)||E.tagNameCheck instanceof Function&&E.tagNameCheck(r))))return!1}else if(!Ke[t]&&!L(Se,ot(r,be,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&st(r,`data:`)===0&&We[e])&&!(Ee&&!L(ye,ot(r,be,``)))&&r)return!1}return!0},xn=z({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Sn=function(e){return!xn[rt(e)]&&L(xe,e)},Cn=function(e,t,n,r){if(_&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return x(r);case`TrustedScriptURL`:return oe(r)}return r},wn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),mn(e)?J(e):$e(t.removed)}catch{on(n,e)}},Tn=function(e){Y(S.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||mn(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0},r=t.length,i=W(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=W(o),u=c,d=o===`value`?u:ct(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Y(S.uponSanitizeAttribute,e,n),d=n.attrValue,Le&&(l===`id`||l===`name`)&&st(d,Re)!==0&&(on(o,e),d=Re+d),j&&L(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){on(o,e);continue}if(l===`attributename`&&at(d,`href`)){on(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){on(o,e);continue}if(!De&&L(Ht,d)){on(o,e);continue}if(A&&(d=fn(d)),!bn(i,l,d)){on(o,e);continue}d=Cn(i,l,s,d),d!==u&&wn(e,o,s,d)}}Y(S.afterSanitizeAttributes,e,null)},En=function(e){let t=null,n=dn(e);for(Y(S.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Y(S.uponSanitizeShadowNode,t,null),yn(t,e),Tn(t),hn(t.content)&&En(t.content),(h?h(t):t.nodeType)===H.element){let e=ne(t);hn(e)&&(Dn(e),En(e))}Y(S.afterSanitizeShadowDOM,e,null)},Dn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){En(e.shadow);continue}let n=e.node,r=(h?h(n):n.nodeType)===H.element,i=p(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=g?g(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=ne(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(ut=!e,ut&&(e=`<!-->`),typeof e!=`string`&&!gn(e)&&(e=gt(e),typeof e!=`string`))throw pt(`dirty is not a string, aborting`);if(!t.isSupported)return e;ke?(C=Ae,T=je):q(n),(S.uponSanitizeElement.length>0||S.uponSanitizeAttribute.length>0)&&(C=B(C)),S.uponSanitizeAttribute.length>0&&(T=B(T)),t.removed=[];let c=Be&&typeof e!=`string`&&gn(e);if(c){ln(e);let t=g?g(e):e.nodeName;if(typeof t==`string`){let n=W(t);if(!C[n]||we[n])throw an(e),pt(`root node is forbidden and cannot be sanitized in-place`)}if(mn(e))throw an(e),pt(`root node is clobbered and cannot be sanitized in-place`);try{Dn(e)}catch(t){throw an(e),t}}else if(gn(e))i=un(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===H.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Dn(a);else{if(!Ne&&!A&&!Oe&&e.indexOf(`<`)===-1)return _&&Fe?x(e):e;if(i=un(e),!i)return Ne?null:Fe?v:``}i&&Me&&J(i.firstChild);let l=c?e:i,u=dn(l);try{for(;o=u.nextNode();)yn(o,l),Tn(o),hn(o.content)&&En(o.content)}catch(n){throw c&&(an(e),Ze(t.removed,e=>{e.element&&cn(e.element)})),n}if(c)return Ze(t.removed,e=>{e.element&&cn(e.element)}),A&&pn(e),e;if(Ne){if(A&&pn(i),Pe)for(s=de.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(T.shadowroot||T.shadowrootmode)&&(s=pe.call(r,s,!0)),s}let d=Oe?i.outerHTML:i.innerHTML;return Oe&&C[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&L(Lt,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
|
-
`+d),A&&(d=fn(d)),_&&Fe?x(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};q(e),ke=!0,Ae=C,je=T},t.clearConfig=function(){G=null,ke=!1,Ae=null,je=null,_=y,v=``},t.isValidAttribute=function(e,t,n){G||q({});let r=W(e),i=W(t);return bn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&I(S,e)&&et(S[e],t)},t.removeHook=function(e,t){if(I(S,e)){if(t!==void 0){let n=Qe(S[e],t);return n===-1?void 0:tt(S[e],n,1)[0]}return $e(S[e])}},t.removeHooks=function(e){I(S,e)&&(S[e]=[])},t.removeAllHooks=function(){S=Gt()},t}var Jt=qt();function Yt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var U=Yt();function Xt(e){U=e}var W={exec:()=>null};function G(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 K(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(q.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Zt=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),q={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,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,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:G(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:G(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:G(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:G(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:G(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:G(e=>RegExp(`^ {0,${e}}>`))},Qt=/^(?:[ \t]*(?:\n|$))+/,$t=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,en=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,tn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,rn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,J=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,an=K(J).replace(/bull/g,rn).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(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),on=K(J).replace(/bull/g,rn).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(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),sn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,cn=/^[^\n]+/,ln=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,un=K(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,ln).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),dn=K(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,rn).getRegex(),fn=`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`,pn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,mn=K(`^ {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)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,pn).replace(`tag`,fn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),hn=e=>K(sn).replace(`hr`,tn).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`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,fn).getRegex(),gn=hn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Y=hn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),_n={blockquote:K(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Y).getRegex(),code:$t,def:un,fences:en,heading:nn,hr:tn,html:mn,lheading:an,list:dn,newline:Qt,paragraph:gn,table:W,text:cn},vn=K(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,tn).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`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,fn).getRegex(),yn={..._n,lheading:on,table:vn,paragraph:K(sn).replace(`hr`,tn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,vn).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,fn).getRegex()},bn={..._n,html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,pn).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:W,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K(sn).replace(`hr`,tn).replace(`heading`,` *#{1,6} *[^
|
|
4
|
-
]`).replace(`lheading`,an).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},xn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Sn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Cn=/^( {2,}|\\)\n(?!\s*$)/,wn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Tn=/[\p{P}\p{S}]/u,En=/[\s\p{P}\p{S}]/u,Dn=/[^\s\p{P}\p{S}]/u,On=K(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,En).getRegex(),kn=/(?!~)[\p{P}\p{S}]/u,An=/(?!~)[\s\p{P}\p{S}]/u,jn=/(?:[^\s\p{P}\p{S}]|~)/u,Mn=K(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Zt?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Nn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Pn=K(Nn,`u`).replace(/punct/g,Tn).getRegex(),Fn=K(Nn,`u`).replace(/punct/g,kn).getRegex(),In=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Ln=K(In,`gu`).replace(/notPunctSpace/g,Dn).replace(/punctSpace/g,En).replace(/punct/g,Tn).getRegex(),Rn=K(In,`gu`).replace(/notPunctSpace/g,jn).replace(/punctSpace/g,An).replace(/punct/g,kn).getRegex(),zn=K(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Dn).replace(/punctSpace/g,En).replace(/punct/g,Tn).getRegex(),Bn=K(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Tn).getRegex(),Vn=K(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Dn).replace(/punctSpace/g,En).replace(/punct/g,Tn).getRegex(),Hn=K(/\\(punct)/,`gu`).replace(/punct/g,Tn).getRegex(),Un=K(/^<(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(),Wn=K(pn).replace(`(?:-->|$)`,`-->`).getRegex(),Gn=K(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Wn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Kn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,qn=K(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Kn).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Jn=K(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Kn).replace(`ref`,ln).getRegex(),Yn=K(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,ln).getRegex(),Xn=K(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Jn).replace(`nolink`,Yn).getRegex(),Zn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Qn={_backpedal:W,anyPunctuation:Hn,autolink:Un,blockSkip:Mn,br:Cn,code:Sn,del:W,delLDelim:W,delRDelim:W,emStrongLDelim:Pn,emStrongRDelimAst:Ln,emStrongRDelimUnd:zn,escape:xn,link:qn,nolink:Yn,punctuation:On,reflink:Jn,reflinkSearch:Xn,tag:Gn,text:wn,url:W},$n={...Qn,link:K(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Kn).getRegex(),reflink:K(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Kn).getRegex()},er={...Qn,emStrongRDelimAst:Rn,emStrongLDelim:Fn,delLDelim:Bn,delRDelim:Vn,url:K(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Zn).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:K(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Zn).getRegex()},tr={...er,br:K(Cn).replace(`{2,}`,`*`).getRegex(),text:K(er.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},nr={normal:_n,gfm:yn,pedantic:bn},rr={normal:Qn,gfm:er,breaks:tr,pedantic:$n},ir={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},ar=e=>ir[e];function X(e,t){if(t){if(q.escapeTest.test(e))return e.replace(q.escapeReplace,ar)}else if(q.escapeTestNoEncode.test(e))return e.replace(q.escapeReplaceNoEncode,ar);return e}function or(e){try{e=encodeURI(e).replace(q.percentDecode,`%`)}catch{return null}return e}function sr(e,t){let n=e.replace(q.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(q.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(q.slashPipe,`|`);return n}function cr(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 lr(e){let t=e.split(`
|
|
5
|
-
`),n=t.length-1;for(;n>=0&&q.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
6
|
-
`)}function ur(e,t){if(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}function dr(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 fr(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function pr(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
7
|
-
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
8
|
-
`)}var mr=class{options;rules;lexer;constructor(e){this.options=e||U}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]:lr(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=pr(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=cr(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:cr(t[0],`
|
|
9
|
-
`),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:cr(t[0],`
|
|
10
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=cr(t[0],`
|
|
11
|
-
`).split(`
|
|
12
|
-
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;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(`
|
|
13
|
-
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
15
|
-
${s}`:s,r=r?`${r}
|
|
16
|
-
${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`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
|
|
17
|
-
`+e.join(`
|
|
18
|
-
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
|
|
19
|
-
`+e.join(`
|
|
20
|
-
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
21
|
-
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=dr(t[2].split(`
|
|
22
|
-
`,1)[0],t[1].length),l=e.split(`
|
|
23
|
-
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
24
|
-
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),ee=this.rules.other.blockquoteBeginRegex(d);for(;e;){let te=e.split(`
|
|
25
|
-
`,1)[0],f;if(l=te,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),f=l):f=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||ee.test(l)||t.test(l)||n.test(l))break;if(f.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
26
|
-
`+f.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
27
|
-
`+l}u=!l.trim(),r+=te+`
|
|
28
|
-
`,e=e.substring(te.length+1),c=f.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);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,i.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(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=lr(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){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),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:cr(t[0],`
|
|
29
|
-
`),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=sr(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
30
|
-
`):[],a={type:`table`,raw:cr(t[0],`
|
|
31
|
-
`),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(sr(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:cr(t[0],`
|
|
32
|
-
`),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)===`
|
|
33
|
-
`?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){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=cr(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=ur(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 n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),fr(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.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 e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return fr(n,e,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]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}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;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){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,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,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:t[0],escaped:e}}}},Z=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||U,this.options.tokenizer=this.options.tokenizer||new mr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:q,block:nr.normal,inline:rr.normal};this.options.pedantic?(t.block=nr.pedantic,t.inline=rr.pedantic):this.options.gfm&&(t.block=nr.gfm,this.options.breaks?t.inline=rr.breaks:t.inline=rr.gfm),this.tokenizer.rules=t}static get rules(){return{block:nr,inline:rr}}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(q.carriageReturn,`
|
|
34
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(q.tabCharGlobal,` `).replace(q.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
35
|
-
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
36
|
-
`)?``:`
|
|
37
|
-
`)+i.raw,n.text+=`
|
|
38
|
-
`+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
39
|
-
`)?``:`
|
|
40
|
-
`)+i.raw,n.text+=`
|
|
41
|
-
`+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);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&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
42
|
-
`)?``:`
|
|
43
|
-
`)+i.raw,r.text+=`
|
|
44
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
45
|
-
`)?``:`
|
|
46
|
-
`)+i.raw,n.text+=`
|
|
47
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links){let e=Object.keys(this.tokens.links);e.length>0&&(n=n.replace(this.tokenizer.rules.inline.reflinkSearch,t=>e.includes(t.slice(t.lastIndexOf(`[`)+1,-1))?`[`+`a`.repeat(t.length-2)+`]`:t))}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,`++`),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??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(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.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 n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},hr=class{options;parser;constructor(e){this.options=e||U}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(q.notSpaceStart)?.[0],i=e.replace(q.endingNewline,``)+`
|
|
48
|
-
`;return r?`<pre><code class="language-`+X(r)+`">`+(n?i:X(i,!0))+`</code></pre>
|
|
49
|
-
`:`<pre><code>`+(n?i:X(i,!0))+`</code></pre>
|
|
50
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
51
|
-
${this.parser.parse(e)}</blockquote>
|
|
52
|
-
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
53
|
-
`}hr(e){return`<hr>
|
|
54
|
-
`}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+`>
|
|
55
|
-
`+r+`</`+i+`>
|
|
56
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
57
|
-
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
58
|
-
`}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>
|
|
59
|
-
<thead>
|
|
60
|
-
`+t+`</thead>
|
|
61
|
-
`+r+`</table>
|
|
62
|
-
`}tablerow({text:e}){return`<tr>
|
|
63
|
-
${e}</tr>
|
|
64
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
65
|
-
`}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>${X(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=or(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+X(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=or(e);if(i===null)return X(n);e=i;let a=`<img src="${e}" alt="${X(n)}"`;return t&&(a+=` title="${X(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:X(e.text)}},gr=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Q=class e{options;renderer;textRenderer;constructor(e){this.options=e||U,this.options.renderer=this.options.renderer||new hr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new gr}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`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=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`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=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}},_r=class{options;block;constructor(e){this.options=e||U}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?Z.lex:Z.lexInline}provideParser(e=this.block){return e?Q.parse:Q.parseInline}},vr=new class{defaults=Yt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Q;Renderer=hr;TextRenderer=gr;Lexer=Z;Tokenizer=mr;Hooks=_r;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(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);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};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 hr(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||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new mr(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 _r;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];_r.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&_r.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)}:t[r]=(...e)=>{if(this.defaults.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 n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Z.lex(e,t??this.defaults)}parser(e,t){return Q.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?Z.lex:Z.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?Q.parse:Q.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?Z.lex:Z.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?Q.parse:Q.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+=`
|
|
66
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+X(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function $(e,t){return vr.parse(e,t)}$.options=$.setOptions=function(e){return vr.setOptions(e),$.defaults=vr.defaults,Xt($.defaults),$},$.getDefaults=Yt,$.defaults=U,$.use=function(...e){return vr.use(...e),$.defaults=vr.defaults,Xt($.defaults),$},$.walkTokens=function(e,t){return vr.walkTokens(e,t)},$.parseInline=vr.parseInline,$.Parser=Q,$.parser=Q.parse,$.Renderer=hr,$.TextRenderer=gr,$.Lexer=Z,$.lexer=Z.lex,$.Tokenizer=mr,$.Hooks=_r,$.parse=$,$.options,$.setOptions,$.use,$.walkTokens,$.parseInline,Q.parse,Z.lex;var yr=$.setOptions({gfm:!0,breaks:!1,async:!1});function br(e){return yr.parse(e)}function xr({session:e,path:t,kind:n}){let r=Sr(e,t);return r===null?null:n===`markdown`?(0,D.jsx)(Cr,{session:e,path:t,text:r}):(0,D.jsx)(Er,{session:e,path:t,text:r})}function Sr(e,t){let n=i(e,t),r=n.data&&!n.data.binary?n.data.content:null,a=r!==null&&n.data?le(e,t,r,n.data.mtime_ms):null;return(0,w.useSyncExternalStore)(n=>ce(pe(e,t),n),()=>a?.getValue()??null)}Jt.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&/^https?:/i.test(e.getAttribute(`href`)??``)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function Cr({session:e,path:t,text:n}){let r=(0,w.useMemo)(()=>Jt.sanitize(br(n)),[n]),i=(0,w.useRef)(null);(0,w.useEffect)(()=>{let n=i.current;if(!n)return;let r=!1,a=[];for(let i of n.querySelectorAll(`img`)){let n=s(t,i.getAttribute(`src`)??``);n&&(i.removeAttribute(`src`),p(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(n)}`).then(e=>e.blob()).then(e=>{if(r)return;let t=URL.createObjectURL(e);a.push(t),i.src=t}).catch(()=>void 0))}return()=>{r=!0;for(let e of a)URL.revokeObjectURL(e)}},[r,e,t]);let{openFile:a}=l();return(0,D.jsx)(`div`,{className:`h-full overflow-y-auto bg-ground`,children:(0,D.jsx)(`div`,{ref:i,onClick:n=>{let r=n.target.closest(`a`);if(!r)return;let i=r.getAttribute(`href`)??``;if(/^https?:/i.test(i)||(n.preventDefault(),!n.metaKey&&!n.ctrlKey))return;let o=s(t,i);o&&a(e,o,void 0,d(o)?{view:`preview`}:void 0)},className:`md-preview mx-auto max-w-3xl px-6 py-5 text-sm text-fg-secondary`,dangerouslySetInnerHTML:{__html:r}})})}var wr=[[`img`,`src`],[`script`,`src`],[`link[rel~="stylesheet" i]`,`href`],[`link[rel~="icon" i]`,`href`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`]],Tr=20*1024*1024;function Er({session:e,path:t,text:n}){let[r,i]=(0,w.useState)(null),a=(0,w.useRef)(new Map);return(0,w.useEffect)(()=>{let r=!1;return Dr(e,t,n,a.current).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r===null?null:(0,D.jsx)(`iframe`,{sandbox:`allow-scripts`,srcDoc:r,title:t,className:`size-full bg-paper`})}async function Dr(e,t,n,r){let i=new DOMParser().parseFromString(n,`text/html`),a=[];for(let[n,o]of wr)for(let c of i.querySelectorAll(n)){let n=s(t,c.getAttribute(o)??``);n&&(c.removeAttribute(o),a.push(Or(e,n,r).then(e=>{e&&c.setAttribute(o,e)})))}return await Promise.all(a),`<!doctype html>${i.documentElement.outerHTML}`}function Or(e,t,n){let r=n.get(t);if(r)return r;let i=p(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}`).then(e=>e.blob()).then(async e=>e.size>Tr?null:`data:${kr(t,e.type)};base64,${Ar(await e.arrayBuffer())}`).catch(()=>null);return n.set(t,i),i}function kr(e,t){let n=(e.split(`/`).pop()??``).split(`.`).pop()?.toLowerCase()??``;return n===`css`?`text/css`:n===`js`||n===`mjs`?`text/javascript`:t!==``&&t!==`application/octet-stream`?t:`application/octet-stream`}function Ar(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}var jr={png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,mov:`video`,mkv:`video`,avi:`video`,mp3:`audio`,wav:`audio`,ogg:`audio`,m4a:`audio`,flac:`audio`,aac:`audio`,pdf:`pdf`};function Mr(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:jr[t.slice(n+1).toLowerCase()]??null}function Nr({session:e,path:t,kind:n}){let{url:r,error:i}=Ir(e,t);return i?(0,D.jsxs)(Pr,{children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,D.jsx)(Fr,{session:e,path:t})]}):r?n===`image`?(0,D.jsx)(Pr,{children:(0,D.jsx)(`img`,{src:r,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,D.jsx)(Pr,{children:(0,D.jsx)(`video`,{src:r,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,D.jsx)(Pr,{children:(0,D.jsx)(`audio`,{src:r,controls:!0,className:`w-full max-w-xl`})}):(0,D.jsx)(`iframe`,{src:r,title:t,className:`h-full w-full border-0 bg-ground`}):(0,D.jsx)(Pr,{children:(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function Pr({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 overflow-auto bg-ground p-4`,children:e})}function Fr({session:e,path:t}){return(0,D.jsx)(`button`,{type:`button`,onClick:()=>void u(e,t).catch(e=>ne.error(e instanceof Error?e.message:`Download failed`)),className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})}function Ir(e,t){let[n,r]=(0,w.useState)(null),[i,a]=(0,w.useState)(!1);return(0,w.useEffect)(()=>{let n=null,i=!1;return r(null),a(!1),p(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}`).then(e=>e.blob()).then(e=>{i||(n=URL.createObjectURL(e),r(n))}).catch(()=>{i||a(!0)}),()=>{i=!0,n&&URL.revokeObjectURL(n)}},[e,t]),{url:n,error:i}}function Lr({tab:e,reveal:t}){let n=c(e);if(n===`diff`)return(0,D.jsx)(Ie,{session:e.session,path:e.path},ee(e));if(n===`commit`&&e.sha)return(0,D.jsx)(Fe,{session:e.session,sha:e.sha,path:e.path},ee(e));let r=Mr(e.path);if(r)return(0,D.jsx)(Nr,{session:e.session,path:e.path,kind:r},ee(e));let i=e.view===`preview`?d(e.path):null;return i?(0,D.jsx)(xr,{session:e.session,path:e.path,kind:i},ee(e)):(0,D.jsx)(Te,{session:e.session,path:e.path,reveal:t},ee(e))}export{Lr as PaneEditorBody};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{d as r,f as i,g as a,h as o,m as s,p as c,u as l,x as u}from"./api-Bh5IJ30S.js";import{a as d,g as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-B43iKmfK.js";import{A as v,D as y,F as b,H as x,I as S,L as C,M as w,P as T,S as E,T as D,V as O,W as k,X as ee,Y as te,_ as A,f as j,i as ne,it as M,k as re,nt as ie,o as N,p as ae,r as oe,rt as P,v as se,z as ce}from"./LazyTerminal-B0xYs2ul.js";import{t as F}from"./utils-B6KiDbIe.js";import{t as I}from"./createLucideIcon-DyMAgLa3.js";import{a as L,i as R,n as z,o as B,r as V,s as le,t as ue}from"./session-seed-DBxHPYBK.js";import{i as de,r as fe}from"./dist-VDiYuPKw.js";import{A as pe,B as me,C as he,D as ge,E as _e,F as ve,H as ye,I as be,J as xe,K as Se,L as Ce,N as we,O as Te,T as Ee,U as De,V as Oe,Y as ke,a as H,b as Ae,c as je,d as Me,f as Ne,g as U,h as W,l as Pe,m as Fe,nt as Ie,ot as Le,p as Re,q as ze,u as Be,v as Ve,x as He,y as Ue,z as We}from"./index-RvCLpi9M.js";var Ge=I(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Ke=I(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),qe=I(`folder-input`,[[`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`}]]),Je=I(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Ye=I(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Xe=I(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Ze=I(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Qe=I(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),$e=I(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),G=e(t(),1),K=n();function q({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:F(`flex items-center gap-4 py-2.5`,a),children:[(0,K.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:F(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function J({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function et(){let e=U(),[t,n]=(0,G.useState)(Le());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Appearance`}),(0,K.jsx)(q,{label:`Theme`,description:`Chrome, terminal, and editor restyle together.`,children:(0,K.jsxs)(z,{value:t,onValueChange:e=>{n(e),Ie(e)},children:[(0,K.jsx)(L,{className:`w-32`,children:(0,K.jsx)(B,{})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(R,{value:`dark`,children:`Dark`}),(0,K.jsx)(R,{value:`light`,children:`Light`}),(0,K.jsx)(R,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(q,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(P,{id:`ui-font-size`,type:`number`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onChange:e=>W({uiFontSize:Number(e.target.value)||Re.uiFontSize})})}),(0,K.jsx)(q,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(P,{id:`terminal-font-size`,type:`number`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onChange:e=>W({terminalFontSize:Number(e.target.value)||13})})}),(0,K.jsx)(q,{label:`Density`,children:(0,K.jsxs)(z,{value:e.density,onValueChange:e=>W({density:e}),children:[(0,K.jsx)(L,{className:`w-36`,children:(0,K.jsx)(B,{})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(R,{value:`compact`,children:`Compact`}),(0,K.jsx)(R,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(q,{label:`Reduced motion`,description:`Status ripples become static dots.`,htmlFor:`reduced-motion`,children:(0,K.jsx)(H,{id:`reduced-motion`,checked:e.reducedMotion,onCheckedChange:e=>W({reducedMotion:e})})}),(0,K.jsx)(q,{label:`All projects in the sidebar`,description:`Show every project's sessions in the right sidebar, grouped by project.`,htmlFor:`all-project-sessions`,children:(0,K.jsx)(H,{id:`all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>W({showAllProjectSessions:e})})})]})}function tt({profile:e}){let t=S(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>u.error(e.message)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>u.error(e.message)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{label:`Icon`,description:`The glyph shown wherever this profile appears.`,children:(0,K.jsxs)(Ue,{open:n,onOpenChange:r,children:[(0,K.jsx)(He,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(We,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(Ae,{align:`end`,className:`w-72`,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:F(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,K.jsx)(We,{icon:null,colour:null,className:`size-4`})}),Oe.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:F(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,K.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,K.jsx)(q,{label:`Icon colour`,description:`Any theme colour; recolours with light/dark.`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:F(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),o.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:F(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:F(`size-3.5 rounded-full bg-current`,me(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var Y=`__none__`;function nt(){let e=N(),t=x().data?.find(t=>t.id===e),n=j(e??void 0),r=O(e??void 0),i=S(),a=C(e??``),o=y(),[s,c]=(0,G.useState)(``),[v,b]=(0,G.useState)(``),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(c(t.name),b(t.branch_prefix))},[t]),!t)return null;let k=r.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Profile`}),(0,K.jsxs)(q,{label:`Name`,description:`A display label. Letters, digits, dot, underscore and hyphen; must be unique.`,htmlFor:`profile-name`,children:[(0,K.jsx)(P,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44 font-mono`}),(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>u.error(e.message)}),children:`Save`})]}),(0,K.jsxs)(q,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(P,{id:`branch-prefix`,value:v,onChange:e=>b(e.target.value),placeholder:l,className:`w-44 font-mono`}),(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:v===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:v},{onError:e=>u.error(e.message)}),children:`Save`})]}),(0,K.jsx)(tt,{profile:t}),(0,K.jsx)(q,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(z,{value:typeof k==`number`?String(k):Y,onValueChange:e=>a.mutate({default_account_id:e===Y?null:Number(e)},{onError:e=>u.error(e.message)}),children:[(0,K.jsx)(L,{className:`w-56`,children:(0,K.jsx)(B,{})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(R,{value:Y,children:`First available`}),n.data?.map(e=>(0,K.jsx)(R,{value:String(e.id),children:(0,K.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(q,{label:`Delete profile`,description:`Removes its projects, accounts (logging them out), and archived history. Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(f,{variant:`danger`,size:`sm`,onClick:()=>T(!0),children:`Delete…`})}),(0,K.jsx)(_,{open:w,onOpenChange:e=>{e||(T(!1),D(``))},children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsxs)(h,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`font-mono`,children:t.name}),`?`]}),(0,K.jsx)(g,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(ie,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(P,{id:`delete-confirm-name`,value:E,onChange:e=>D(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:()=>{T(!1),D(``)},children:`Cancel`}),(0,K.jsx)(f,{variant:`danger`,disabled:E!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{ve(),ne.set(null)},onError:e=>{T(!1),D(``),u.error(e.message)}}),children:`Delete profile`})]})]})})]})}function rt({agentId:e,profileId:t,onClose:n}){let r=se(),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),c=re(we(o,150)),l=i.trim()!==``&&(o.startsWith(`/`)||o.startsWith(`~`));return(0,K.jsx)(_,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsx)(h,{children:`Import an existing account`}),(0,K.jsx)(g,{children:`The directory is copied into a puddle-owned account; the original is never touched. If credentials do not travel (macOS keychain), log in once afterwards.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(P,{placeholder:`label, e.g. personal`,value:i,onChange:e=>a(e.target.value),className:`font-mono`}),(0,K.jsx)(oe,{value:o,onValueChange:s,placeholder:`config dir on the host, e.g. ~/.claude`,hints:(c.data?.entries??[]).map(e=>({value:e.path,label:e.name})),className:`font-mono`})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(f,{disabled:!l||r.isPending,onClick:()=>r.mutate({profile_id:t,agent_type:e,label:i.trim(),import_dir:o.trim()},{onSuccess:e=>{n(),e.logged_in||u.info(`Imported without credentials — press Login to authenticate.`)},onError:e=>u.error(e.message)}),children:[(0,K.jsx)(qe,{}),`Import`]})]})]})})}function it({account:e,gateOpen:t}){let n=w(),r=T(),i=D(),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[l,v]=(0,G.useState)(e.label);return(0,G.useEffect)(()=>v(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`input`,{value:l,onChange:e=>v(e.target.value),onBlur:()=>{let t=l.trim();if(t!==e.label){if(t===``){v(e.label);return}r.mutate({id:e.id,label:t},{onError:t=>{u.error(t.message),v(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(v(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full truncate rounded-sm bg-transparent px-1 py-0.5 font-mono text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-running`:`text-waiting`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,K.jsx)(H,{checked:e.skip_permissions_default,onCheckedChange:t=>r.mutate({id:e.id,skip_permissions_default:t},{onError:e=>u.error(e.message)})})]}),(0,K.jsxs)(f,{size:`sm`,variant:`secondary`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>o(e.stream),onError:e=>u.error(e.message)}),children:[(0,K.jsx)(ke,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(f,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>c(!0),children:[(0,K.jsx)(De,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),a&&(0,K.jsx)(Ve,{stream:a,label:`${e.agent_type}/${e.label}`,onClose:()=>o(null)}),(0,K.jsx)(_,{open:s,onOpenChange:c,children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsxs)(h,{children:[`Delete `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.label}),`?`]}),(0,K.jsx)(g,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:()=>c(!1),children:`Cancel`}),(0,K.jsx)(f,{variant:`danger`,disabled:i.isPending,onClick:()=>i.mutate(e.id,{onSuccess:()=>c(!1),onError:e=>{c(!1),u.error(e.message)}}),children:`Delete account`})]})]})})]})}function at(){let e=N(),t=ae(),n=j(e??void 0),r=O(e??void 0),i=se(),a=w(),[o,s]=(0,G.useState)({}),[c,l]=(0,G.useState)(null),[d,p]=(0,G.useState)(null),m=r.data?.allowSkipPermissions===!0,h=t=>{let n=(o[t]??``).trim();!n||e===null||i.mutate({profile_id:e,agent_type:t,label:n},{onSuccess:e=>{s(e=>({...e,[t]:``})),a.mutate(e.id,{onSuccess:n=>l({stream:n.stream,label:`${t}/${e.label}`})})},onError:e=>u.error(e.message)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[];return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(q,{label:e.display_name,description:`Accounts are isolated config dirs under this profile.`,className:`py-1`,children:(0,K.jsx)(`span`,{className:`font-mono text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(it,{account:t,gateOpen:m&&e.capabilities.skip_permissions},t.id)),(0,K.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),h(e.id)},children:[(0,K.jsx)(P,{placeholder:`label, e.g. personal`,value:o[e.id]??``,onChange:t=>s(n=>({...n,[e.id]:t.target.value})),className:`w-48 font-mono`}),(0,K.jsxs)(f,{type:`submit`,size:`sm`,variant:`secondary`,disabled:!(o[e.id]??``).trim()||i.isPending,children:[(0,K.jsx)(ze,{}),`Add account`]}),(0,K.jsxs)(f,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>p(e.id),children:[(0,K.jsx)(qe,{}),`Import existing…`]})]})]})]},e.id)}),c&&(0,K.jsx)(Ve,{stream:c.stream,label:c.label,onClose:()=>l(null)}),d!==null&&e!==null&&(0,K.jsx)(rt,{agentId:d,profileId:e,onClose:()=>p(null)})]})}function ot(){let e=A(),t=b(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(q,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH to find agent CLIs like claude (e.g. ~/.local/bin). Applies after the daemon restarts.`,htmlFor:`agent-path`,children:(0,K.jsx)(P,{id:`agent-path`,type:`text`,className:`w-64 font-mono text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function st({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=ue(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(q,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(P,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48 font-mono`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,K.jsx)(q,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(H,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(q,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`An own working copy of the base branch, instead of sharing one.`,htmlFor:`${e}-default-dir`,children:(0,K.jsx)(H,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ct(){return(0,K.jsx)(q,{label:`Terminal scrollback`,description:`Lines kept per terminal. This browser only.`,htmlFor:`scrollback`,children:(0,K.jsx)(P,{id:`scrollback`,type:`number`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:U().terminalScrollback,onChange:e=>W({terminalScrollback:Number(e.target.value)||5e3})})})}function X({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,G.useState)(r);return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,K.jsx)(M,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(f,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var lt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function ut({initial:e,onSave:t,pending:n}){let[r,i]=(0,G.useState)(e),o=r.length>0?r:s;return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,K.jsx)(P,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:s}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:he(lt,o)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:a.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,K.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(f,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function dt(){let e=N(),t=x().data?.find(t=>t.id===e),n=O(e??void 0),a=C(e??``),[o,s]=(0,G.useState)(!1),[l,v]=(0,G.useState)(``),y=n.data?.allowSkipPermissions===!0,b=e=>a.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),v(``)},onError:e=>u.error(e.message)}),S=e=>t=>a.mutate({[e]:t},{onError:e=>u.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Sessions`}),(0,K.jsx)(`p`,{className:`mb-3 text-xs text-fg-secondary`,children:`Permission prompts are on by default, everywhere. Skipping them requires this profile gate, a per-account opt-in, and a per-session toggle — and the daemon re-checks all three on every launch, resume, and hand-off.`}),(0,K.jsx)(q,{label:`Allow skipping permission prompts`,description:y?`The gate is open: opted-in accounts can start prompt-free sessions.`:`The gate is closed: every session keeps its permission prompts.`,htmlFor:`gate`,children:(0,K.jsx)(H,{id:`gate`,checked:y,onCheckedChange:e=>{e?s(!0):b(!1)}})}),(0,K.jsx)(q,{label:`Capture exported env vars`,description:n.data?.captureSessionEnv===!1?`Paused: session shells spawn plain — nothing new is captured or injected. Already-captured vars are kept for when this is re-enabled.`:`Vars exported in a session terminal persist: re-injected into its new shells and agent restarts. Values stay on the daemon host.`,htmlFor:`capture-env`,children:(0,K.jsx)(H,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:a.isPending,onCheckedChange:e=>a.mutate({captureSessionEnv:e},{onError:e=>u.error(e.message)})})}),(0,K.jsx)(ot,{}),(0,K.jsx)(ct,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`What the new-agent and new-terminal modals open with — everything stays editable per session.`,children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(st,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>u.error(e.message)}),pending:a.isPending},`${e}:agent-seed`),(0,K.jsx)(st,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>u.error(e.message)}),pending:a.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`Sent to the agent as its opening message when a session starts. Leave a box empty to send no preamble.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{id:`onboarding-template`,label:`New worktree`,description:`For a freshly created worktree. Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??i,defaultText:i,onSave:S(`onboardingTemplate`),pending:a.isPending},`${e}:onboarding`),(0,K.jsx)(X,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??r,defaultText:r,onSave:S(`concurrentTemplate`),pending:a.isPending},`${e}:concurrent`),(0,K.jsx)(X,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot — its processes are gone.`,initial:n.data.restartTemplate??c,defaultText:c,onSave:S(`restartTemplate`),pending:a.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`How each session's tab and sidebar label is composed from its parts.`,children:`Tab title`}),n.data&&(0,K.jsx)(ut,{initial:n.data.tabTitleTemplate??"${name}",onSave:S(`tabTitleTemplate`),pending:a.isPending},`${e}:tab-title`)]}),(0,K.jsx)(_,{open:o,onOpenChange:e=>{e||(s(!1),v(``))},children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsxs)(h,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ze,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(g,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,K.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,K.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,K.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,K.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,K.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,K.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,K.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(ie,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(P,{id:`confirm-name`,value:l,onChange:e=>v(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:()=>{s(!1),v(``)},children:`Cancel`}),(0,K.jsx)(f,{variant:`danger`,disabled:l!==t?.name||a.isPending,onClick:()=>b(!0),children:`Open the gate`})]})]})})]})}var ft={desktop:!0,sound:!1,muted_projects:[]};function pt(){let e=N(),t=O(e??void 0),n=C(e??``),r=k(e??void 0),i={...ft,...t.data?.notifications??{}},a=e=>n.mutate({notifications:e},{onError:e=>u.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`When an agent flips to waiting for input`,children:`Notifications`}),(0,K.jsx)(q,{label:`Desktop notification on waiting`,description:`Shown while this window is unfocused; clicking it opens the session.`,htmlFor:`notify-desktop`,children:(0,K.jsx)(H,{id:`notify-desktop`,checked:i.desktop,onCheckedChange:e=>{e&&typeof Notification<`u`&&Notification.requestPermission(),a({...i,desktop:e})}})}),(0,K.jsx)(q,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(H,{id:`notify-sound`,checked:i.sound,onCheckedChange:e=>a({...i,sound:e})})}),(0,K.jsx)(q,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[i.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,K.jsx)(H,{checked:i.muted_projects.includes(e.id),onCheckedChange:t=>a({...i,muted_projects:t?[...i.muted_projects,e.id]:i.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function mt(){let e=U();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Editor`}),(0,K.jsx)(q,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(P,{id:`tab-size`,type:`number`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onChange:e=>W({editorTabSize:Number(e.target.value)||2})})}),(0,K.jsx)(q,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(H,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>W({editorWordWrap:e})})}),(0,K.jsx)(q,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,K.jsx)(P,{id:`editor-link-host`,type:`text`,placeholder:`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>W({editorLinkSshHost:e.target.value})})})]})}function ht({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=ge(e.nativeEvent);t&&(n(t),a(!1))},className:F(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:Te(e)}),!t&&(0,K.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(Ye,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function gt(){let e=N(),t=O(e??void 0),n=C(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of Ee){let t=i(e.id,e.defaultBinding);a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>u.error(e.message)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>u.error(e.message)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Hotkeys`}),(0,K.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed. Browser-reserved combos (⌘W, ⌘T, ⌘⇧B, …) can’t be captured by a web tab.`}),_e.map(e=>{let t=Ee.filter(t=>t.group===e);return t.length===0?null:(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,e.defaultBinding),n=(a.get(t)??0)>1,c=pe(t)?`Browser-reserved — won’t fire in a tab.`:n?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(q,{label:e.label,description:c,descriptionClassName:c?`text-interrupted`:void 0,children:(0,K.jsx)(ht,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var _t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([..._t].map((e,t)=>[e,t])),vt=`H`,yt=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function bt(e){let t=4294967295;for(let n of e)t=yt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function xt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function St(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function Ct(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function wt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function Tt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:_t[(e+n)%Z]}return r}async function Et(e){let t=await Ct(JSON.stringify(e));return Tt(xt(t)+bt(t),1+Math.floor(Math.random()*(Z-1)))}async function Dt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=Tt(t,-((Q[n]-Q[vt]+Z)%Z));if(r.length<9||r[0]!==vt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=St(i);if(bt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await wt(o))}var Ot=`puddle.sync-selection`;function kt(){try{let e=JSON.parse(localStorage.getItem(Ot)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return je.map(e=>e.id)}function At({selected:e,onToggle:t}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:je.map(n=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(H,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function jt(){let e=N(),t=O(e??void 0),n=x().data?.find(t=>t.id===e),r=ee(e??void 0,void 0),i=C(e??``),a=S(),o=E(),s=Me(),c=Ne(),[l,d]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(kt),w=n?s.data?.file.profiles[n.name]:void 0,T=w?.enabled===!0,D=T&&w?w.groups:y,k=()=>({client:Fe(),theme:Le(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),te={setClient:e=>W(e),setTheme:e=>{typeof e==`string`&&Ie(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>u.error(e.message)}),patchProfileColumns:t=>{e&&a.mutate({id:e,...t},{onError:e=>u.error(e.message)})},createScratchpad:t=>{if(e)for(let n of t)o.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},A=(e,t)=>{n&&c.mutate({profile:n.name,entry:{enabled:e.enabled??T,groups:t,doc:Be(t,k()),updatedAt:new Date().toISOString()}},{onError:e=>u.error(e.message)})},j=(e,t)=>{let n=t?[...D,e]:D.filter(t=>t!==e);b(n),localStorage.setItem(Ot,JSON.stringify(n)),T&&A({},n)},ne=async()=>{v(!0);try{let e=Pe(await Dt(l.trim()),te,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?u.error(`Nothing recognised to import.`):(u.success(`Imported ${e.join(`, `)}.`),d(``))}catch(e){u.error(e.message)}finally{v(!1)}},re=async()=>{v(!0);try{let e=await Et(Be(D,k()));m(e),await navigator.clipboard?.writeText(e),u.success(`Copied to clipboard`)}finally{v(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Sync`}),(0,K.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),s.data?.available===!1?(0,K.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the puddle CLI to sync across windows.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Mirror the selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`~/.puddle`}),`, so every puddle window — any port, any host — stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:n?.name??`…`}),`. The checklist below then applies to imports and exports alike; scratchpad entries merge and never overwrite.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(H,{checked:T,disabled:!n||s.isLoading||c.isPending,onCheckedChange:e=>A({enabled:e},D)}),`Sync locally`]})]})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[h?(0,K.jsx)(le,{className:`size-3.5`}):(0,K.jsx)(de,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(At,{selected:D,onToggle:j})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,K.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste an exported string — only the settings it carries are updated. Scratchpad entries are added alongside yours, never replacing them.`}),(0,K.jsx)(M,{value:l,onChange:e=>d(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(f,{size:`sm`,disabled:!l.trim()||_,onClick:()=>void ne(),children:`Import`})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,K.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`One click builds the string from the checklist above and copies it to your clipboard.`}),(0,K.jsx)(f,{size:`sm`,disabled:_,onClick:()=>void re(),children:`Export & copy`}),p&&(0,K.jsx)(M,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]})]})}function Mt({repo:e}){let t=ce(),n=v(),[r,i]=(0,G.useState)(e.default_base_branch),[a,o]=(0,G.useState)(e.onboarding_notes??``),s=e=>u.error(e.message);return(0,K.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm text-fg`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,K.jsxs)(f,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>u.success(`Fetched.`),onError:s}),children:[(0,K.jsx)(Se,{}),`Fetch now`]})]}),(0,K.jsxs)(q,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(P,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40 font-mono`}),(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:s}),children:`Save`})]}),(0,K.jsx)(q,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,K.jsx)(H,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,K.jsx)(M,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4,className:`font-mono`}),(0,K.jsx)(`div`,{children:(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:s}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,K.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,K.jsx)(`li`,{className:`truncate font-mono text-2xs text-fg-muted`,children:e},e))})]})]})}function Nt(){let e=te();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Repositories`}),e.data?.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No repositories yet — register one from the new-project flow on the dashboard.`}),e.data?.map(e=>(0,K.jsx)(Mt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=b();return(0,K.jsx)(q,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(P,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>u.error(e.message)})}})})}function Pt(){let e=A(),t=b();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(q,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,K.jsx)(P,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>u.error(e.message)})}})}),(0,K.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,K.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,K.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,K.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,K.jsx)(q,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(H,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>u.error(e.message)})})})]}):null}var Ft=[{id:`appearance`,label:`Appearance`,icon:xe,render:()=>(0,K.jsx)(et,{})},{id:`profile`,label:`Profile`,icon:ye,render:()=>(0,K.jsx)(nt,{})},{id:`accounts`,label:`Accounts`,icon:$e,render:()=>(0,K.jsx)(at,{})},{id:`sessions`,label:`Sessions`,icon:Qe,render:()=>(0,K.jsx)(dt,{})},{id:`editor`,label:`Editor`,icon:Ke,render:()=>(0,K.jsx)(mt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Je,render:()=>(0,K.jsx)(gt,{})},{id:`notifications`,label:`Notifications`,icon:Ge,render:()=>(0,K.jsx)(pt,{})},{id:`repositories`,label:`Repositories`,icon:fe,render:()=>(0,K.jsx)(Nt,{})},{id:`host`,label:`Host`,icon:Xe,render:()=>(0,K.jsx)(Pt,{})},{id:`sync`,label:`Sync`,icon:Se,render:()=>(0,K.jsx)(jt,{})}],It={terminal:`sessions`};function Lt(){let e=Ce(),t=e===null?null:It[e]??e,n=Ft.find(e=>e.id===t)??Ft[0];return(0,K.jsx)(_,{open:e!==null,onOpenChange:e=>!e&&ve(),children:(0,K.jsxs)(m,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(h,{className:`sr-only`,children:`Settings`}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Ft.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>be(e),className:F(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,K.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Lt as SettingsDialog};
|