@thxgg/steward 0.1.16 → 0.1.17
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/.env.example +6 -0
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/{wbjFvimm.js → 4r0X30JV.js} +1 -1
- package/.output/public/_nuxt/{ynmyrfyT.js → BMdjSp24.js} +1 -1
- package/.output/public/_nuxt/{BWVTacYj.js → BSZqAKg4.js} +1 -1
- package/.output/public/_nuxt/{Dum5qplW.js → BdjPva1I.js} +1 -1
- package/.output/public/_nuxt/Beeir9iR.js +1 -0
- package/.output/public/_nuxt/Bh3vsUvl.js +1 -0
- package/.output/public/_nuxt/{Bibm_IDv.js → BlTKcjLJ.js} +2 -2
- package/.output/public/_nuxt/{CxHOXVf6.js → By7gAVcL.js} +1 -1
- package/.output/public/_nuxt/CbJfCtEa.js +1 -0
- package/.output/public/_nuxt/CbkpNvIu.js +141 -0
- package/.output/public/_nuxt/CmhLcqDu.js +1 -0
- package/.output/public/_nuxt/DC6iPLz1.js +30 -0
- package/.output/public/_nuxt/{BSA0RJ-H.js → DD--ojY9.js} +1 -1
- package/.output/public/_nuxt/Detail.DSyVQNdr.css +1 -0
- package/.output/public/_nuxt/DhKWRjCh.js +60 -0
- package/.output/public/_nuxt/_prd_.BkpxMFSV.css +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/f3f42dbd-d501-442b-871c-3d06157e7aa1.json +1 -0
- package/.output/public/_nuxt/c1sXju8w.js +1 -0
- package/.output/public/_nuxt/eGCjCghR.js +1 -0
- package/.output/public/_nuxt/nX8Sf7cz.js +13 -0
- package/.output/server/chunks/_/git-api.mjs +100 -7
- package/.output/server/chunks/_/git-api.mjs.map +1 -1
- package/.output/server/chunks/_/git.mjs +3 -10
- package/.output/server/chunks/_/git.mjs.map +1 -1
- package/.output/server/chunks/_/prd-service.mjs +234 -0
- package/.output/server/chunks/_/prd-service.mjs.map +1 -0
- package/.output/server/chunks/_/task-graph.mjs +3 -3
- package/.output/server/chunks/_/task-graph.mjs.map +1 -1
- package/.output/server/chunks/_/watcher.mjs +26 -46
- package/.output/server/chunks/_/watcher.mjs.map +1 -1
- package/.output/server/chunks/build/{Detail-CUfU85GY.mjs → Detail-MGwP_u2d.mjs} +63 -34
- package/.output/server/chunks/build/Detail-MGwP_u2d.mjs.map +1 -0
- package/.output/server/chunks/build/DiffViewer-styles-1.mjs-BFsE2PCW.mjs +4 -0
- package/.output/server/chunks/build/DiffViewer-styles-1.mjs-BFsE2PCW.mjs.map +1 -0
- package/.output/server/chunks/build/DiffViewer-styles.D2bqX3nK.mjs +8 -0
- package/.output/server/chunks/build/DiffViewer-styles.D2bqX3nK.mjs.map +1 -0
- package/.output/server/chunks/build/DiffViewer-styles.FoV36wuV.mjs +10 -0
- package/.output/server/chunks/build/DiffViewer-styles.FoV36wuV.mjs.map +1 -0
- package/.output/server/chunks/build/Viewer-styles.D6wYWFb1.mjs +8 -0
- package/.output/server/chunks/build/Viewer-styles.D6wYWFb1.mjs.map +1 -0
- package/.output/server/chunks/build/{_prd_-CeVnQzOV.mjs → _prd_-C-Aj4fVa.mjs} +75 -33
- package/.output/server/chunks/build/_prd_-C-Aj4fVa.mjs.map +1 -0
- package/.output/server/chunks/build/client.precomputed.mjs +1 -1
- package/.output/server/chunks/build/{default-DWCOHHTE.mjs → default-Cao5eO80.mjs} +4 -3
- package/.output/server/chunks/build/default-Cao5eO80.mjs.map +1 -0
- package/.output/server/chunks/build/error-404-Bf6kdO80.mjs +2 -1
- package/.output/server/chunks/build/error-500-D_bcARXN.mjs +2 -1
- package/.output/server/chunks/build/{index-CckL_NBD.mjs → index-ByZO4Bvq.mjs} +2 -2
- package/.output/server/chunks/build/index-ByZO4Bvq.mjs.map +1 -0
- package/.output/server/chunks/build/{index-QVeSHT3L.mjs → index-ljj9uTXI.mjs} +8 -5
- package/.output/server/chunks/build/index-ljj9uTXI.mjs.map +1 -0
- package/.output/server/chunks/build/nuxt-link-SvT1nf8Z.mjs +1 -1
- package/.output/server/chunks/build/{repo-graph-CHNl58mY.mjs → repo-graph-EuhMeFt7.mjs} +25 -10
- package/.output/server/chunks/build/repo-graph-EuhMeFt7.mjs.map +1 -0
- package/.output/server/chunks/build/server.mjs +7 -6
- package/.output/server/chunks/build/styles.mjs +4 -4
- package/.output/server/chunks/build/{usePrd-SqcxGyFU.mjs → usePrd-f7ylhIqs.mjs} +10 -34
- package/.output/server/chunks/build/usePrd-f7ylhIqs.mjs.map +1 -0
- package/.output/server/chunks/nitro/nitro.mjs +1106 -677
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/browse.get.mjs +12 -6
- package/.output/server/chunks/routes/api/browse.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/index.get.mjs +2 -1
- package/.output/server/chunks/routes/api/index.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/index.post.mjs +3 -2
- package/.output/server/chunks/routes/api/index.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/git/commits.get.mjs +11 -13
- package/.output/server/chunks/routes/api/repos/_repoId/git/commits.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/git/diff.get.mjs +11 -6
- package/.output/server/chunks/routes/api/repos/_repoId/git/diff.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/git/file-content.get.mjs +31 -12
- package/.output/server/chunks/routes/api/repos/_repoId/git/file-content.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/git/file-diff.get.mjs +13 -13
- package/.output/server/chunks/routes/api/repos/_repoId/git/file-diff.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/graph.get.mjs +5 -1
- package/.output/server/chunks/routes/api/repos/_repoId/graph.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/graph.get.mjs +14 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/graph.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/progress.get.mjs +20 -9
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/progress.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/tasks/_taskId/commits.get.mjs +20 -85
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/tasks/_taskId/commits.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/tasks.get.mjs +20 -9
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/tasks.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug_.get.mjs +30 -50
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug_.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prds.get.mjs +19 -49
- package/.output/server/chunks/routes/api/repos/_repoId/prds.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/refresh-git-repos.post.mjs +6 -13
- package/.output/server/chunks/routes/api/repos/_repoId/refresh-git-repos.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId_.delete.mjs +2 -1
- package/.output/server/chunks/routes/api/repos/_repoId_.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/runtime.get.mjs +3 -2
- package/.output/server/chunks/routes/api/runtime.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/watch.get.mjs +5 -4
- package/.output/server/chunks/routes/api/watch.get.mjs.map +1 -1
- package/.output/server/chunks/routes/renderer.mjs +1 -1
- package/.output/server/index.mjs +3 -2
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/zod/index.js +4 -0
- package/.output/server/node_modules/zod/package.json +118 -0
- package/.output/server/node_modules/zod/v3/ZodError.js +133 -0
- package/.output/server/node_modules/zod/v3/errors.js +9 -0
- package/.output/server/node_modules/zod/v3/external.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/.output/server/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/.output/server/node_modules/zod/v3/helpers/util.js +133 -0
- package/.output/server/node_modules/zod/v3/locales/en.js +109 -0
- package/.output/server/node_modules/zod/v3/types.js +3693 -0
- package/.output/server/package.json +2 -1
- package/README.md +7 -2
- package/dist/host/src/api/prds.js +6 -172
- package/dist/host/src/api/repos.js +3 -16
- package/dist/host/src/api/state.js +7 -2
- package/dist/host/src/executor-runner.js +368 -0
- package/dist/host/src/executor.js +138 -260
- package/dist/host/src/index.js +7 -2
- package/dist/host/src/mcp.js +27 -1
- package/dist/host/src/ui.js +18 -3
- package/dist/server/utils/change-events.js +33 -0
- package/dist/server/utils/git.js +11 -16
- package/dist/server/utils/prd-service.js +235 -0
- package/dist/server/utils/prd-state.js +57 -45
- package/dist/server/utils/repos.js +58 -13
- package/dist/server/utils/state-schema.js +61 -0
- package/dist/server/utils/task-graph.js +2 -2
- package/package.json +2 -1
- package/.output/public/_nuxt/CVJh28bx.js +0 -1
- package/.output/public/_nuxt/CyZuidLG.js +0 -60
- package/.output/public/_nuxt/D0op9E2g.js +0 -1
- package/.output/public/_nuxt/DX8awZaa.js +0 -1
- package/.output/public/_nuxt/Detail.z33AHKev.css +0 -1
- package/.output/public/_nuxt/DiTJUZOC.js +0 -1
- package/.output/public/_nuxt/T_3JE9C-.js +0 -1
- package/.output/public/_nuxt/WOI2tLsR.js +0 -42
- package/.output/public/_nuxt/_prd_.KTotLoF_.css +0 -1
- package/.output/public/_nuxt/builds/meta/029070b0-b8e2-4988-84f4-d0c9ff55c998.json +0 -1
- package/.output/public/_nuxt/odRGDGwj.js +0 -1
- package/.output/server/chunks/build/Detail-CUfU85GY.mjs.map +0 -1
- package/.output/server/chunks/build/DiffViewer-styles-1.mjs-CS8FTppg.mjs +0 -4
- package/.output/server/chunks/build/DiffViewer-styles-1.mjs-CS8FTppg.mjs.map +0 -1
- package/.output/server/chunks/build/DiffViewer-styles.AUfwwelI.mjs +0 -10
- package/.output/server/chunks/build/DiffViewer-styles.AUfwwelI.mjs.map +0 -1
- package/.output/server/chunks/build/DiffViewer-styles.D_it8zfk.mjs +0 -8
- package/.output/server/chunks/build/DiffViewer-styles.D_it8zfk.mjs.map +0 -1
- package/.output/server/chunks/build/Viewer-styles.CshnetGw.mjs +0 -8
- package/.output/server/chunks/build/Viewer-styles.CshnetGw.mjs.map +0 -1
- package/.output/server/chunks/build/_prd_-CeVnQzOV.mjs.map +0 -1
- package/.output/server/chunks/build/default-DWCOHHTE.mjs.map +0 -1
- package/.output/server/chunks/build/index-CckL_NBD.mjs.map +0 -1
- package/.output/server/chunks/build/index-QVeSHT3L.mjs.map +0 -1
- package/.output/server/chunks/build/repo-graph-CHNl58mY.mjs.map +0 -1
- package/.output/server/chunks/build/usePrd-SqcxGyFU.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as a,e as s,h as u,i as r,f as h}from"./
|
|
1
|
+
import{u as a,e as s,h as u,i as r,f as h}from"./BlTKcjLJ.js";function i(t){const e=t||s();return e.ssrContext?.head||e.runWithContext(()=>{if(u()){const n=r(h);if(!n)throw new Error("[nuxt] [unhead] Missing Unhead instance.");return n}})}function d(t,e={}){const n=e.head||i(e.nuxt);return a(t,{head:n,...e})}export{d as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as M,l as e,a0 as bt,g as D,k as ne,o as u,x as g,L as j,c as S,n as H,F as te,r as se,v as xt,B as fe,w as p,y as V,q as w,b as m,G as be,p as ke,ac as wt,z as re,A as ve,ad as Ct,j as Qe,M as Me,a as c,t as q,ae as kt,af as St,m as ye,H as le,d as J,a1 as $t,J as Ie,K as Pe,aa as Oe,ag as Xe,ab as Rt,_ as Et,ah as Dt}from"./BlTKcjLJ.js";import{c as xe,m as Te,h as At,f as Ye,d as Ze,P as ie,g as Ae,u as Se,o as Bt,B as me,b as et,a as Ve,F as Fe,r as Z,e as Q,n as It}from"./CmhLcqDu.js";import{q as Pt,V as Ot,u as Tt,c as we,a as $e,b as Ft,r as Lt,f as Mt,p as tt,g as Vt,o as zt,n as qt,i as jt,j as Kt,k as Ut,l as Ht,S as Nt,G as at,L as Gt,C as Wt,R as st,B as Jt,d as he,s as Qt,t as ze,v as ot,w as nt,x as lt,X as rt,e as Re,y as Xt,z as Yt,A as Zt,h as ea,K as ta}from"./DD--ojY9.js";import{F as aa,I as sa,a as Le}from"./4r0X30JV.js";import{b as qe,u as je,g as oa,A as na}from"./c1sXju8w.js";import{_ as la}from"./Beeir9iR.js";const it=xe("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const ut=xe("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);const ra=xe("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const dt=xe("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);const ia=xe("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);function ua(s,t,a){const o=s.findIndex(l=>Te(l,t)),i=s.findIndex(l=>Te(l,a));if(o===-1||i===-1)return[];const[r,n]=[o,i].sort((l,f)=>l-f);return s.slice(r,n+1)}function da(s){const t=M(()=>e(s)),a=M(()=>new Intl.Collator("en",{usage:"search",...t.value}));return{startsWith:(n,l)=>l.length===0?!0:(n=n.normalize("NFC"),l=l.normalize("NFC"),a.value.compare(n.slice(0,l.length),l)===0),endsWith:(n,l)=>l.length===0?!0:(n=n.normalize("NFC"),l=l.normalize("NFC"),a.value.compare(n.slice(-l.length),l)===0),contains:(n,l)=>{if(l.length===0)return!0;n=n.normalize("NFC"),l=l.normalize("NFC");let f=0;const v=l.length;for(;f+v<=n.length;f++){const y=n.slice(f,f+v);if(a.value.compare(l,y)===0)return!0}return!1}}}function ca(s){return M(()=>bt(s)?!!At(s)?.closest("form"):!0)}function pa(){return{ALT:"Alt",ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",BACKSPACE:"Backspace",CAPS_LOCK:"CapsLock",CONTROL:"Control",DELETE:"Delete",END:"End",ENTER:"Enter",ESCAPE:"Escape",F1:"F1",F10:"F10",F11:"F11",F12:"F12",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",HOME:"Home",META:"Meta",PAGE_DOWN:"PageDown",PAGE_UP:"PageUp",SHIFT:"Shift",SPACE:" ",TAB:"Tab",CTRL:"Control",ASTERISK:"*",SPACE_CODE:"Space"}}function fa(s){const t=Ye("",1e3);return{search:t,handleTypeaheadSearch:(i,r)=>{t.value=t.value+i;{const n=Pt(),l=r.map(_=>({..._,textValue:_.value?.textValue??_.ref.textContent?.trim()??""})),f=l.find(_=>_.ref===n),v=l.map(_=>_.textValue),y=va(v,t.value,f?.textValue),d=l.find(_=>_.textValue===y);return d&&d.ref.focus(),d?.ref}},resetTypeahead:()=>{t.value=""}}}function ma(s,t){return s.map((a,o)=>s[(t+o)%s.length])}function va(s,t,a){const i=t.length>1&&Array.from(t).every(v=>v===t[0])?t[0]:t,r=a?s.indexOf(a):-1;let n=ma(s,Math.max(r,0));i.length===1&&(n=n.filter(v=>v!==a));const f=n.find(v=>v.toLowerCase().startsWith(i.toLowerCase()));return f!==a?f:void 0}var ha=D({inheritAttrs:!1,__name:"VisuallyHiddenInputBubble",props:{name:{type:String,required:!0},value:{type:null,required:!0},checked:{type:Boolean,required:!1,default:void 0},required:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},feature:{type:String,required:!1,default:"fully-hidden"}},setup(s){const t=s,{primitiveElement:a,currentElement:o}=qe(),i=M(()=>t.checked??t.value);return ne(i,(r,n)=>{if(!o.value)return;const l=o.value,f=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(f,"value").set;if(y&&r!==n){const d=new Event("input",{bubbles:!0}),_=new Event("change",{bubbles:!0});y.call(l,r),l.dispatchEvent(d),l.dispatchEvent(_)}}),(r,n)=>(u(),g(Ot,j({ref_key:"primitiveElement",ref:a},{...t,...r.$attrs},{as:"input"}),null,16))}}),Ne=ha,ga=D({inheritAttrs:!1,__name:"VisuallyHiddenInput",props:{name:{type:String,required:!0},value:{type:null,required:!0},checked:{type:Boolean,required:!1,default:void 0},required:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},feature:{type:String,required:!1,default:"fully-hidden"}},setup(s){const t=s,a=M(()=>typeof t.value=="object"&&Array.isArray(t.value)&&t.value.length===0&&t.required),o=M(()=>typeof t.value=="string"||typeof t.value=="number"||typeof t.value=="boolean"||t.value===null||t.value===void 0?[{name:t.name,value:t.value}]:typeof t.value=="object"&&Array.isArray(t.value)?t.value.flatMap((i,r)=>typeof i=="object"?Object.entries(i).map(([n,l])=>({name:`${t.name}[${r}][${n}]`,value:l})):{name:`${t.name}[${r}]`,value:i}):t.value!==null&&typeof t.value=="object"&&!Array.isArray(t.value)?Object.entries(t.value).map(([i,r])=>({name:`${t.name}[${i}]`,value:r})):[]);return(i,r)=>(u(),S(te,null,[H(" We render single input if it's required "),a.value?(u(),g(Ne,j({key:i.name},{...t,...i.$attrs},{name:i.name,value:i.value}),null,16,["name","value"])):(u(!0),S(te,{key:1},se(o.value,n=>(u(),g(Ne,j({key:n.name},{ref_for:!0},{...t,...i.$attrs},{name:n.name,value:n.value}),null,16,["name","value"]))),128))],2112))}}),ya=ga;function _a(s,t,a){return s===void 0?!1:Array.isArray(s)?s.some(o=>_e(o,t,a)):_e(s,t,a)}function _e(s,t,a){return s===void 0||t===void 0?!1:typeof s=="string"?s===t:typeof a=="function"?a(s,t):typeof a=="string"?s?.[a]===t?.[a]:Te(s,t)}const[Ke,ba]=we("ListboxRoot");var xa=D({__name:"ListboxRoot",props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},multiple:{type:Boolean,required:!1},orientation:{type:String,required:!1,default:"vertical"},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},selectionBehavior:{type:String,required:!1,default:"toggle"},highlightOnHover:{type:Boolean,required:!1},by:{type:[String,Function],required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","highlight","entryFocus","leave"],setup(s,{expose:t,emit:a}){const o=s,i=a,{multiple:r,highlightOnHover:n,orientation:l,disabled:f,selectionBehavior:v,dir:y}=xt(o),{getItems:d}=je({isProvider:!0}),{handleTypeaheadSearch:_}=fa(),{primitiveElement:A,currentElement:x}=qe(),T=pa(),F=Tt(y),C=ca(x),L=w(),z=w(!1),R=w(!0),B=Ze(o,"modelValue",i,{defaultValue:o.defaultValue??(r.value?[]:void 0),passive:o.modelValue===void 0,deep:!0});function ae(h){if(z.value=!0,o.multiple){const k=Array.isArray(B.value)?[...B.value]:[],E=k.findIndex(U=>_e(U,h,o.by));o.selectionBehavior==="toggle"?(E===-1?k.push(h):k.splice(E,1),B.value=k):(B.value=[h],L.value=h)}else o.selectionBehavior==="toggle"&&_e(B.value,h,o.by)?B.value=void 0:B.value=h;setTimeout(()=>{z.value=!1},1)}const K=w(null),oe=w(null),ee=w(!1),G=w(!1),X=Ae(),W=Ae(),Y=Ae();function $(){return d().map(h=>h.ref).filter(h=>h.dataset.disabled!=="")}function I(h,k=!0){if(!h)return;K.value=h,R.value&&K.value.focus(),k&&K.value.scrollIntoView({block:"nearest"});const E=d().find(U=>U.ref===h);i("highlight",E)}function N(h){if(ee.value)Y.trigger(h);else{const k=d().find(E=>_e(E.value,h,o.by));k&&(K.value=k.ref,I(k.ref))}}function ue(h){K.value&&K.value.isConnected&&(h.preventDefault(),h.stopPropagation(),G.value||K.value.click())}function P(h){if(R.value){if(z.value=!0,ee.value)W.trigger(h);else{const k=h.altKey||h.ctrlKey||h.metaKey;if(k&&h.key==="a"&&r.value){const E=d(),U=E.map(ce=>ce.value);B.value=[...U],h.preventDefault(),I(E[E.length-1].ref)}else if(!k){const E=_(h.key,d());E&&I(E)}}setTimeout(()=>{z.value=!1},1)}}function b(){G.value=!0}function O(){fe(()=>{G.value=!1})}function de(){fe(()=>{const h=new KeyboardEvent("keydown",{key:"PageUp"});Ue(h)})}function De(h){const k=K.value;k?.isConnected&&(oe.value=k),K.value=null,i("leave",h)}function gt(h){const k=new CustomEvent("listbox.entryFocus",{bubbles:!1,cancelable:!0});if(h.currentTarget?.dispatchEvent(k),i("entryFocus",k),!k.defaultPrevented)if(oe.value)I(oe.value);else{const E=$()?.[0];I(E)}}function Ue(h){const k=oa(h,l.value,F.value);if(!k)return;let E=$();if(K.value){if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const U=E.indexOf(K.value);E=E.slice(U+1)}yt(h,E[0])}if(E.length){const U=!K.value&&k==="prev"?E.length-1:0;I(E[U])}if(ee.value)return W.trigger(h)}function yt(h,k){if(!(ee.value||o.selectionBehavior!=="replace"||!r.value||!Array.isArray(B.value)||(h.altKey||h.ctrlKey||h.metaKey)&&!h.shiftKey)&&h.shiftKey){const U=d().filter(ge=>ge.ref.dataset.disabled!=="");let ce=U.find(ge=>ge.ref===k)?.value;if(h.key===T.END?ce=U[U.length-1].value:h.key===T.HOME&&(ce=U[0].value),!ce||!L.value)return;const _t=ua(U.map(ge=>ge.value),L.value,ce);B.value=_t}}async function He(h){if(await fe(),ee.value)X.trigger(h);else{const k=$(),E=k.find(U=>U.dataset.state==="checked");E?I(E):k.length&&I(k[0])}}return ne(B,()=>{z.value||fe(()=>{He()})},{immediate:!0,deep:!0}),t({highlightedElement:K,highlightItem:N,highlightFirstItem:de,highlightSelected:He,getItems:d}),ba({modelValue:B,onValueChange:ae,multiple:r,orientation:l,dir:F,disabled:f,highlightOnHover:n,highlightedElement:K,isVirtual:ee,virtualFocusHook:X,virtualKeydownHook:W,virtualHighlightHook:Y,by:o.by,firstValue:L,selectionBehavior:v,focusable:R,onLeave:De,onEnter:gt,changeHighlight:I,onKeydownEnter:ue,onKeydownNavigation:Ue,onKeydownTypeAhead:P,onCompositionStart:b,onCompositionEnd:O,highlightFirstItem:de}),(h,k)=>(u(),g(e(ie),{ref_key:"primitiveElement",ref:A,as:h.as,"as-child":h.asChild,dir:e(F),"data-disabled":e(f)?"":void 0,onPointerleave:De,onFocusout:k[0]||(k[0]=async E=>{const U=E.relatedTarget||E.target;await fe(),K.value&&e(x)&&!e(x).contains(U)&&De(E)})},{default:p(()=>[V(h.$slots,"default",{modelValue:e(B)}),e(C)&&h.name?(u(),g(e(ya),{key:0,name:h.name,value:e(B),disabled:e(f),required:h.required},null,8,["name","value","disabled","required"])):H("v-if",!0)]),_:3},8,["as","as-child","dir","data-disabled"]))}}),wa=xa,Ca=D({__name:"ListboxContent",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(s){const{CollectionSlot:t}=je(),a=Ke(),o=Ye(!1,10);return(i,r)=>(u(),g(e(t),null,{default:p(()=>[m(e(ie),{role:"listbox",as:i.as,"as-child":i.asChild,tabindex:e(a).focusable.value?e(a).highlightedElement.value?"-1":"0":"-1","aria-orientation":e(a).orientation.value,"aria-multiselectable":!!e(a).multiple.value,"data-orientation":e(a).orientation.value,onMousedown:r[0]||(r[0]=ke(n=>o.value=!0,["left"])),onFocus:r[1]||(r[1]=n=>{e(o)||e(a).onEnter(n)}),onKeydown:[r[2]||(r[2]=be(n=>{e(a).orientation.value==="vertical"&&(n.key==="ArrowLeft"||n.key==="ArrowRight")||e(a).orientation.value==="horizontal"&&(n.key==="ArrowUp"||n.key==="ArrowDown")||(n.preventDefault(),e(a).focusable.value&&e(a).onKeydownNavigation(n))},["down","up","left","right","home","end"])),be(e(a).onKeydownEnter,["enter"]),e(a).onKeydownTypeAhead]},{default:p(()=>[V(i.$slots,"default")]),_:3},8,["as","as-child","tabindex","aria-orientation","aria-multiselectable","data-orientation","onKeydown"])]),_:3}))}}),ka=Ca,Sa=D({__name:"ListboxFilter",props:{modelValue:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},emits:["update:modelValue"],setup(s,{emit:t}){const a=s,i=Ze(a,"modelValue",t,{defaultValue:"",passive:a.modelValue===void 0}),r=Ke(),{primitiveElement:n,currentElement:l}=qe(),f=M(()=>a.disabled||r.disabled.value||!1),v=w();return wt(()=>v.value=r.highlightedElement.value?.id),re(()=>{r.focusable.value=!1,setTimeout(()=>{a.autoFocus&&l.value?.focus()},1)}),ve(()=>{r.focusable.value=!0}),(y,d)=>(u(),g(e(ie),{ref_key:"primitiveElement",ref:n,as:y.as,"as-child":y.asChild,value:e(i),disabled:f.value?"":void 0,"data-disabled":f.value?"":void 0,"aria-disabled":f.value??void 0,"aria-activedescendant":v.value,type:"text",onKeydown:[be(ke(e(r).onKeydownNavigation,["prevent"]),["down","up","home","end"]),be(e(r).onKeydownEnter,["enter"])],onInput:d[0]||(d[0]=_=>{i.value=_.target.value,e(r).highlightFirstItem()}),onCompositionstart:e(r).onCompositionStart,onCompositionend:e(r).onCompositionEnd},{default:p(()=>[V(y.$slots,"default",{modelValue:e(i)})]),_:3},8,["as","as-child","value","disabled","data-disabled","aria-disabled","aria-activedescendant","onKeydown","onCompositionstart","onCompositionend"]))}}),$a=Sa;const[Ra,Ea]=we("ListboxGroup");var Da=D({__name:"ListboxGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(s){const t=s,a=$e(void 0,"reka-listbox-group");return Ea({id:a}),(o,i)=>(u(),g(e(ie),j({role:"group"},t,{"aria-labelledby":e(a)}),{default:p(()=>[V(o.$slots,"default")]),_:3},16,["aria-labelledby"]))}}),Aa=Da,Ba=D({__name:"ListboxGroupLabel",props:{for:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},setup(s){const t=s,a=Ra({id:""});return(o,i)=>(u(),g(e(ie),j(t,{id:e(a).id}),{default:p(()=>[V(o.$slots,"default")]),_:3},16,["id"]))}}),Ia=Ba;const Pa="listbox.select",[Fo,Oa]=we("ListboxItem");var Ta=D({__name:"ListboxItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},emits:["select"],setup(s,{emit:t}){const a=s,o=t,i=$e(void 0,"reka-listbox-item"),{CollectionItem:r}=je(),{forwardRef:n,currentElement:l}=Ft(),f=Ke(),v=M(()=>l.value===f.highlightedElement.value),y=M(()=>_a(f.modelValue.value,a.value,f.by)),d=M(()=>f.disabled.value||a.disabled);async function _(x){o("select",x),!x?.defaultPrevented&&!d.value&&x&&(f.onValueChange(a.value),f.changeHighlight(l.value))}function A(x){const T={originalEvent:x,value:a.value};Lt(Pa,_,T)}return Oa({isSelected:y}),(x,T)=>(u(),g(e(r),{value:x.value},{default:p(()=>[Ct([v.value,y.value],()=>m(e(ie),j({id:e(i)},x.$attrs,{ref:e(n),role:"option",tabindex:e(f).focusable.value?v.value?"0":"-1":-1,"aria-selected":y.value,as:x.as,"as-child":x.asChild,disabled:d.value?"":void 0,"data-disabled":d.value?"":void 0,"data-highlighted":v.value?"":void 0,"data-state":y.value?"checked":"unchecked",onClick:A,onKeydown:be(ke(A,["prevent"]),["space"]),onPointermove:T[0]||(T[0]=()=>{e(f).highlightedElement.value!==e(l)&&e(f).highlightOnHover.value&&!e(f).focusable.value&&e(f).changeHighlight(e(l),!1)})}),{default:p(()=>[V(x.$slots,"default")]),_:3},16,["id","tabindex","aria-selected","as","as-child","disabled","data-disabled","data-highlighted","data-state","onKeydown"]),T,1)]),_:3},8,["value"]))}}),Fa=Ta;const La={class:"flex items-center gap-2 truncate"},Ma={class:"truncate"},Va={key:0,class:"absolute top-full right-0 z-[9999] mt-1 w-[280px] rounded-md border bg-popover p-1 text-popover-foreground shadow-md"},za={class:"max-h-[200px] overflow-y-auto"},qa=["aria-selected","onClick"],ja={class:"flex flex-1 flex-col gap-0.5 overflow-hidden text-left"},Ka={class:"truncate font-medium"},Ua={class:"truncate text-xs text-muted-foreground"},Ha=["onClick"],Na={key:1,class:"px-2 py-1.5 text-sm text-muted-foreground"},Ga={key:2,class:"my-1 h-px bg-border"},Wa={class:"space-y-2"},Ja={class:"flex gap-2"},Qa={key:0,class:"text-sm text-destructive"},Xa={key:0,class:"space-y-2 rounded-md border p-3"},Ya={class:"flex items-center gap-2 text-sm"},Za=["disabled"],es={class:"flex-1 truncate font-mono text-xs text-muted-foreground"},ts={class:"max-h-[200px] overflow-y-auto"},as={key:0,class:"py-2 text-center text-sm text-muted-foreground"},ss={key:1,class:"py-2 text-center text-sm text-muted-foreground"},os=["onClick"],ns={class:"truncate"},ls={key:0},rs={key:1},is=D({__name:"RepoSelector",setup(s,{expose:t}){const a=Qe(),o=Me(),{repos:i,currentRepo:r,currentRepoId:n,selectRepo:l,addRepo:f,removeRepo:v}=Se(),{showSuccess:y}=et(),d=w(!1),_=w(""),A=w(null);Bt(A,()=>{d.value&&(d.value=!1,_.value="")}),ne(()=>o.fullPath,()=>{d.value=!1,_.value=""});async function x(P){l(P),d.value=!1,_.value="";try{const O=(await $fetch(`/api/repos/${P}/prds`))?.[0];O?a.push(`/${P}/${O.slug}`):a.push("/")}catch{a.push("/")}}function T(){d.value=!1,G.value=!0}const F=w(!1),C=w(""),L=w(null),z=w([]),R=w(!1),B=M(()=>!!L.value&&L.value!==C.value);async function ae(P){R.value=!0;try{const b=await $fetch("/api/browse",{query:{path:P||C.value||void 0}});C.value=b.current,L.value=b.parent,z.value=b.directories}catch{}finally{R.value=!1}}function K(){F.value=!0,ae(X.value||void 0)}function oe(P){X.value=P,F.value=!1,W.value=null}function ee(){const P=L.value;!B.value||!P||ae(P)}const G=w(!1),X=w(""),W=w(null),Y=w(!1),$=M(()=>{if(!_.value)return i.value;const P=_.value.toLowerCase();return i.value?.filter(b=>b.name.toLowerCase().includes(P)||b.path.toLowerCase().includes(P))??[]});async function I(){if(!X.value.trim()){W.value="Please enter a repository path";return}Y.value=!0,W.value=null;try{const P=await f(X.value.trim());if(G.value=!1,X.value="",y("Repository added",P?.name||"Successfully added repository"),P?.id)try{const O=(await $fetch(`/api/repos/${P.id}/prds`))?.[0];O&&a.push(`/${P.id}/${O.slug}`)}catch{}}catch(P){if(P instanceof Error){const b=P;W.value=b.data?.message||P.message}else W.value="Failed to add repository"}finally{Y.value=!1}}async function N(P,b){P.stopPropagation(),await v(b)}function ue(){G.value=!1,X.value="",W.value=null}return t({openAddDialog:()=>{G.value=!0}}),(P,b)=>(u(),S("div",{ref_key:"dropdownRef",ref:A,class:"relative"},[c("button",{type:"button",class:"inline-flex h-8 w-[200px] items-center justify-between gap-2 rounded-md border border-input bg-background px-3 text-sm font-normal ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:b[0]||(b[0]=O=>d.value=!e(d))},[c("span",La,[m(e(aa),{class:"size-4 shrink-0 text-muted-foreground"}),c("span",Ma,q(e(r)?.name??"Select repository"),1)]),m(e(Mt),{class:"size-4 shrink-0 opacity-50"})]),e(d)?(u(),S("div",Va,[kt(c("input",{"onUpdate:modelValue":b[1]||(b[1]=O=>ye(_)?_.value=O:null),type:"text",placeholder:"Search repositories...",class:"mb-1 h-9 w-full rounded-md border border-input bg-background px-3 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"},null,512),[[St,e(_)]]),c("div",za,[e($)?.length?(u(!0),S(te,{key:0},se(e($),O=>(u(),S("div",{key:O.id,class:"group flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground cursor-pointer",role:"option","aria-selected":e(n)===O.id,onClick:de=>x(O.id)},[m(e(tt),{class:le(["size-4 shrink-0",e(n)===O.id?"opacity-100":"opacity-0"])},null,8,["class"]),c("div",ja,[c("span",Ka,q(O.name),1),c("span",Ua,q(O.path),1)]),c("button",{type:"button",class:"ml-auto opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",title:"Remove repository",onClick:de=>N(de,O.id)},[m(e(ia),{class:"size-3.5 text-destructive"})],8,Ha)],8,qa))),128)):(u(),S("div",Na," No repositories found. ")),e($)?.length?(u(),S("div",Ga)):H("",!0),c("button",{type:"button",class:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground",onClick:T},[m(e(Vt),{class:"size-4"}),b[5]||(b[5]=c("span",null,"Add repository...",-1))])])])):H("",!0),m(e(zt),{open:e(G),"onUpdate:open":b[4]||(b[4]=O=>G.value=O)},{default:p(()=>[m(e(qt),{side:"right",class:"flex h-full flex-col",onEscapeKeyDown:ue},{default:p(()=>[m(e(jt),{class:"px-6"},{default:p(()=>[m(e(Kt),null,{default:p(()=>[...b[6]||(b[6]=[J("Add Repository",-1)])]),_:1}),m(e(Ut),null,{default:p(()=>[...b[7]||(b[7]=[J(" Enter the absolute path to a repository containing PRD documents. ",-1)])]),_:1})]),_:1}),c("form",{id:"add-repo-form",class:"min-h-0 flex-1 space-y-4 overflow-y-auto px-6",onSubmit:ke(I,["prevent"])},[c("div",Wa,[b[8]||(b[8]=c("label",{for:"repo-path",class:"text-sm font-medium"}," Repository Path ",-1)),c("div",Ja,[m(e(sa),{id:"repo-path",modelValue:e(X),"onUpdate:modelValue":b[2]||(b[2]=O=>ye(X)?X.value=O:null),placeholder:"/path/to/your/project","aria-invalid":!!e(W),disabled:e(Y),class:"flex-1"},null,8,["modelValue","aria-invalid","disabled"]),m(e(me),{type:"button",variant:"outline",size:"icon",disabled:e(Y),onClick:K},{default:p(()=>[m(e(Le),{class:"size-4"})]),_:1},8,["disabled"])]),e(W)?(u(),S("p",Qa,q(e(W)),1)):H("",!0),b[9]||(b[9]=c("p",{class:"text-xs text-muted-foreground"},[J(" The repository should contain a "),c("code",{class:"rounded bg-muted px-1"},"docs/prd/"),J(" directory with markdown files. ")],-1))]),e(F)?(u(),S("div",Xa,[c("div",Ya,[c("button",{type:"button",class:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",disabled:!e(B),onClick:ee},[m(e(na),{class:"size-3"}),b[10]||(b[10]=J(" Up ",-1))],8,Za),c("span",es,q(e(C)),1),m(e(me),{type:"button",variant:"ghost",size:"sm",class:"h-7 text-xs",onClick:b[3]||(b[3]=O=>oe(e(C)))},{default:p(()=>[...b[11]||(b[11]=[J(" Select ",-1)])]),_:1})]),c("div",ts,[e(R)?(u(),S("div",as," Loading... ")):e(z).length?(u(!0),S(te,{key:2},se(e(z),O=>(u(),S("button",{key:O.path,type:"button",class:"flex w-full items-center gap-2 rounded px-2 py-1 text-sm hover:bg-accent",onClick:de=>ae(O.path)},[m(e(Le),{class:"size-4 text-muted-foreground"}),c("span",ns,q(O.name),1)],8,os))),128)):(u(),S("div",ss," No subdirectories "))])])):H("",!0)],32),m(e(Ht),{class:"px-6 pb-6"},{default:p(()=>[m(e(me),{type:"button",variant:"outline",disabled:e(Y),onClick:ue},{default:p(()=>[...b[12]||(b[12]=[J(" Cancel ",-1)])]),_:1},8,["disabled"]),m(e(me),{type:"submit",form:"add-repo-form",disabled:e(Y)},{default:p(()=>[e(Y)?(u(),S("span",ls,"Adding...")):(u(),S("span",rs,"Add Repository"))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["open"])],512))}}),us=Object.assign(is,{__name:"LayoutRepoSelector"}),ds={class:"flex h-full w-64 flex-col border-r border-border bg-background"},cs={class:"p-2"},ps={key:1,class:"flex items-center justify-center py-8"},fs={key:2,class:"px-2 py-8 text-center"},ms={key:3,class:"px-2 py-8 text-center"},vs={key:4,class:"px-2 py-8 text-center"},hs={key:5,class:"space-y-1"},gs={class:"flex-1 truncate"},ys=D({__name:"Sidebar",setup(s){const t=Me(),{prds:a,prdsStatus:o,refreshPrds:i}=Ve(),{currentRepoId:r}=Se(),n=M(()=>t.params.prd);function l(y){return n.value===y}const f=M(()=>r.value?`/${r.value}/repo-graph`:"/"),v=M(()=>r.value?t.path===`/${r.value}/repo-graph`:!1);return(y,d)=>{const _=la;return u(),S("aside",ds,[m(e(Nt),{class:"flex-1"},{default:p(()=>[c("div",cs,[e(r)?(u(),g(_,{key:0,to:e(f),class:le(["group mb-2 flex items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors",[e(v)?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"]])},{default:p(()=>[m(e(at),{class:"size-4 shrink-0"}),d[0]||(d[0]=c("span",{class:"flex-1 truncate"},"Repo Graph",-1))]),_:1},8,["to","class"])):H("",!0),d[6]||(d[6]=c("h2",{class:"flex h-10 items-center px-2 text-sm font-medium text-muted-foreground"},"Documents",-1)),e(o)==="pending"?(u(),S("div",ps,[m(e(Gt),{class:"size-5 animate-spin text-muted-foreground"})])):e(r)?e(o)==="error"?(u(),S("div",ms,[m(e(Wt),{class:"mx-auto size-8 text-destructive/50"}),d[3]||(d[3]=c("p",{class:"mt-2 text-sm text-muted-foreground"}," Failed to load PRDs ",-1)),m(e(me),{variant:"ghost",size:"sm",class:"mt-2",onClick:e(i)},{default:p(()=>[m(e(st),{class:"mr-1 size-3"}),d[2]||(d[2]=J(" Retry ",-1))]),_:1},8,["onClick"])])):e(a)?.length?(u(),S("nav",hs,[(u(!0),S(te,null,se(e(a),A=>(u(),g(_,{key:A.slug,to:`/${e(r)}/${A.slug}`,class:le(["group flex items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors",[l(A.slug)?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"]])},{default:p(()=>[m(e(Fe),{class:"size-4 shrink-0"}),c("span",gs,q(A.name),1),A.hasState&&A.taskCount?(u(),g(e(Jt),{key:0,variant:"secondary",class:"shrink-0 text-xs"},{default:p(()=>[J(q(A.completedCount??0)+"/"+q(A.taskCount),1)]),_:2},1024)):H("",!0)]),_:2},1032,["to","class"]))),128))])):(u(),S("div",vs,[m(e(Fe),{class:"mx-auto size-8 text-muted-foreground/50"}),d[4]||(d[4]=c("p",{class:"mt-2 text-sm text-muted-foreground"}," No PRDs found ",-1)),d[5]||(d[5]=c("p",{class:"mt-1 text-xs text-muted-foreground/70"}," Add .md files to docs/prd/ ",-1))])):(u(),S("div",fs,[...d[1]||(d[1]=[c("p",{class:"text-sm text-muted-foreground"}," Select a repository to view PRDs ",-1)])]))])]),_:1})])}}}),_s=Object.assign(ys,{__name:"LayoutSidebar"}),bs=D({__name:"Command",props:{modelValue:{default:""},defaultValue:{},multiple:{type:Boolean},orientation:{},dir:{},disabled:{type:Boolean},selectionBehavior:{},highlightOnHover:{type:Boolean},by:{},asChild:{type:Boolean},as:{},name:{},required:{type:Boolean},class:{},defaultSearch:{default:""}},emits:["update:modelValue","highlight","entryFocus","leave"],setup(s,{emit:t}){const a=s,o=t,i=Z(a,"class"),r=he(i,o),n=w(new Map),l=w(new Map),{contains:f}=da({sensitivity:"base"}),v=$t({search:a.defaultSearch||"",filtered:{count:0,items:new Map,groups:new Set}});ne(()=>a.defaultSearch,d=>{d!==void 0&&(v.search=d)});function y(){if(!v.search){v.filtered.count=n.value.size;return}v.filtered.groups=new Set;let d=0;for(const[_,A]of n.value){const x=f(A,v.search);v.filtered.items.set(_,x?1:0),x&&d++}for(const[_,A]of l.value)for(const x of A)if(v.filtered.items.get(x)>0){v.filtered.groups.add(_);break}v.filtered.count=d}return ne(()=>v.search,()=>{y()}),ne(()=>n.value.size,()=>{v.search&&y()}),Gs({allItems:n,allGroups:l,filterState:v}),(d,_)=>(u(),g(e(wa),j({"data-slot":"command"},e(r),{class:e(Q)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",a.class)}),{default:p(()=>[V(d.$slots,"default")]),_:3},16,["class"]))}}),xs=Object.assign(bs,{__name:"UiCommand"}),ws=D({__name:"Dialog",props:{open:{type:Boolean},defaultOpen:{type:Boolean},modal:{type:Boolean}},emits:["update:open"],setup(s,{emit:t}){const i=he(s,t);return(r,n)=>(u(),g(e(Qt),j({"data-slot":"dialog"},e(i)),{default:p(l=>[V(r.$slots,"default",Ie(Pe(l)))]),_:3},16))}}),ct=Object.assign(ws,{__name:"UiDialog"}),Cs=D({__name:"DialogClose",props:{asChild:{type:Boolean},as:{}},setup(s){const t=s;return(a,o)=>(u(),g(e(ze),j({"data-slot":"dialog-close"},t),{default:p(()=>[V(a.$slots,"default")]),_:3},16))}});Object.assign(Cs,{__name:"UiDialogClose"});const ks=D({__name:"DialogOverlay",props:{forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{}},setup(s){const t=s,a=Z(t,"class");return(o,i)=>(u(),g(e(ot),j({"data-slot":"dialog-overlay"},e(a),{class:e(Q)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",t.class)}),{default:p(()=>[V(o.$slots,"default")]),_:3},16,["class"]))}}),Ss=Object.assign(ks,{__name:"UiDialogOverlay"}),$s=D({inheritAttrs:!1,__name:"DialogContent",props:{forceMount:{type:Boolean},disableOutsidePointerEvents:{type:Boolean},asChild:{type:Boolean},as:{},class:{},showCloseButton:{type:Boolean,default:!0}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(s,{emit:t}){const a=s,o=t,i=Z(a,"class"),r=he(i,o);return(n,l)=>(u(),g(e(nt),null,{default:p(()=>[m(Ss),m(e(lt),j({"data-slot":"dialog-content"},{...n.$attrs,...e(r)},{class:e(Q)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a.class)}),{default:p(()=>[V(n.$slots,"default"),s.showCloseButton?(u(),g(e(ze),{key:0,"data-slot":"dialog-close",class:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"},{default:p(()=>[m(e(rt)),l[0]||(l[0]=c("span",{class:"sr-only"},"Close",-1))]),_:1})):H("",!0)]),_:3},16,["class"])]),_:3}))}}),pt=Object.assign($s,{__name:"UiDialogContent"}),Rs=D({__name:"DialogDescription",props:{asChild:{type:Boolean},as:{},class:{}},setup(s){const t=s,a=Z(t,"class"),o=Re(a);return(i,r)=>(u(),g(e(Xt),j({"data-slot":"dialog-description"},e(o),{class:e(Q)("text-muted-foreground text-sm",t.class)}),{default:p(()=>[V(i.$slots,"default")]),_:3},16,["class"]))}}),ft=Object.assign(Rs,{__name:"UiDialogDescription"}),Es=D({__name:"DialogFooter",props:{class:{}},setup(s){const t=s;return(a,o)=>(u(),S("div",{"data-slot":"dialog-footer",class:le(e(Q)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t.class))},[V(a.$slots,"default")],2))}});Object.assign(Es,{__name:"UiDialogFooter"});const Ds=D({__name:"DialogHeader",props:{class:{}},setup(s){const t=s;return(a,o)=>(u(),S("div",{"data-slot":"dialog-header",class:le(e(Q)("flex flex-col gap-2 text-center sm:text-left",t.class))},[V(a.$slots,"default")],2))}}),mt=Object.assign(Ds,{__name:"UiDialogHeader"}),As=D({inheritAttrs:!1,__name:"DialogScrollContent",props:{forceMount:{type:Boolean},disableOutsidePointerEvents:{type:Boolean},asChild:{type:Boolean},as:{},class:{}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(s,{emit:t}){const a=s,o=t,i=Z(a,"class"),r=he(i,o);return(n,l)=>(u(),g(e(nt),null,{default:p(()=>[m(e(ot),{class:"fixed inset-0 z-50 grid place-items-center overflow-y-auto bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"},{default:p(()=>[m(e(lt),j({class:e(Q)("relative z-50 grid w-full max-w-lg my-8 gap-4 border border-border bg-background p-6 shadow-lg duration-200 sm:rounded-lg md:w-full",a.class)},{...n.$attrs,...e(r)},{onPointerDownOutside:l[0]||(l[0]=f=>{const v=f.detail.originalEvent,y=v.target;(v.offsetX>y.clientWidth||v.offsetY>y.clientHeight)&&f.preventDefault()})}),{default:p(()=>[V(n.$slots,"default"),m(e(ze),{class:"absolute top-4 right-4 p-0.5 transition-colors rounded-md hover:bg-secondary"},{default:p(()=>[m(e(rt),{class:"w-4 h-4"}),l[1]||(l[1]=c("span",{class:"sr-only"},"Close",-1))]),_:1})]),_:3},16,["class"])]),_:3})]),_:3}))}});Object.assign(As,{__name:"UiDialogScrollContent"});const Bs=D({__name:"DialogTitle",props:{asChild:{type:Boolean},as:{},class:{}},setup(s){const t=s,a=Z(t,"class"),o=Re(a);return(i,r)=>(u(),g(e(Yt),j({"data-slot":"dialog-title"},e(o),{class:e(Q)("text-lg leading-none font-semibold",t.class)}),{default:p(()=>[V(i.$slots,"default")]),_:3},16,["class"]))}}),vt=Object.assign(Bs,{__name:"UiDialogTitle"}),Is=D({__name:"DialogTrigger",props:{asChild:{type:Boolean},as:{}},setup(s){const t=s;return(a,o)=>(u(),g(e(Zt),j({"data-slot":"dialog-trigger"},t),{default:p(()=>[V(a.$slots,"default")]),_:3},16))}});Object.assign(Is,{__name:"UiDialogTrigger"});const Ps=D({__name:"CommandDialog",props:{open:{type:Boolean},defaultOpen:{type:Boolean},modal:{type:Boolean},title:{default:"Command Palette"},description:{default:"Search for a command to run..."},defaultSearch:{default:""}},emits:["update:open"],setup(s,{emit:t}){const i=he(s,t);return(r,n)=>(u(),g(e(ct),Ie(Pe(e(i))),{default:p(l=>[m(e(pt),{class:"overflow-hidden p-0","show-close-button":!1},{default:p(()=>[m(e(mt),{class:"sr-only"},{default:p(()=>[m(e(vt),null,{default:p(()=>[J(q(s.title),1)]),_:1}),m(e(ft),null,{default:p(()=>[J(q(s.description),1)]),_:1})]),_:1}),m(xs,{"default-search":s.defaultSearch},{default:p(()=>[V(r.$slots,"default",Ie(Pe(l)))]),_:2},1032,["default-search"])]),_:2},1024)]),_:3},16))}}),Os=Object.assign(Ps,{__name:"UiCommandDialog"}),Ts=D({__name:"CommandEmpty",props:{asChild:{type:Boolean},as:{},class:{}},setup(s){const t=s,a=Z(t,"class"),{filterState:o}=Ee(),i=M(()=>!!o.search&&o.filtered.count===0);return(r,n)=>i.value?(u(),g(e(ie),j({key:0,"data-slot":"command-empty"},e(a),{class:e(Q)("py-6 text-center text-sm",t.class)}),{default:p(()=>[V(r.$slots,"default")]),_:3},16,["class"])):H("",!0)}}),Fs=Object.assign(Ts,{__name:"UiCommandEmpty"}),Ls=D({__name:"CommandGroup",props:{asChild:{type:Boolean},as:{},class:{},heading:{}},setup(s){const t=s,a=Z(t,"class"),{allGroups:o,filterState:i}=Ee(),r=$e(),n=M(()=>i.search?i.filtered.groups.has(r):!0);return Js({id:r}),re(()=>{o.value.has(r)||o.value.set(r,new Set)}),ve(()=>{o.value.delete(r)}),(l,f)=>(u(),g(e(Aa),j(e(a),{id:e(r),"data-slot":"command-group",class:e(Q)("text-foreground overflow-hidden p-1",t.class),hidden:n.value?void 0:!0}),{default:p(()=>[s.heading?(u(),g(e(Ia),{key:0,"data-slot":"command-group-heading",class:"px-2 py-1.5 text-xs font-medium text-muted-foreground"},{default:p(()=>[J(q(s.heading),1)]),_:1})):H("",!0),V(l.$slots,"default")]),_:3},16,["id","class","hidden"]))}}),Be=Object.assign(Ls,{__name:"UiCommandGroup"}),Ms={"data-slot":"command-input-wrapper",class:"flex h-9 items-center gap-2 border-b px-3"},Vs=D({inheritAttrs:!1,__name:"CommandInput",props:{modelValue:{},autoFocus:{type:Boolean},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{}},setup(s){const t=s,a=Z(t,"class"),o=Re(a),{filterState:i}=Ee(),r=w(null);return re(()=>{fe(()=>{const n=r.value?.$el;if(n&&i.search){const l=i.search.length;n.setSelectionRange(l,l)}})}),(n,l)=>(u(),S("div",Ms,[m(e(ra),{class:"size-4 shrink-0 opacity-50"}),m(e($a),j({ref_key:"inputRef",ref:r},{...e(o),...n.$attrs},{modelValue:e(i).search,"onUpdate:modelValue":l[0]||(l[0]=f=>e(i).search=f),"data-slot":"command-input","auto-focus":"",class:e(Q)("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t.class)}),null,16,["modelValue","class"])]))}}),zs=Object.assign(Vs,{__name:"UiCommandInput"}),qs=D({__name:"CommandItem",props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{}},emits:["select"],setup(s,{emit:t}){const a=s,o=t,i=Z(a,"class"),r=he(i,o),n=$e(),{filterState:l,allItems:f,allGroups:v}=Ee(),y=Ws(),d=M(()=>{if(l.search){const x=l.filtered.items.get(n);return x===void 0?!0:x>0}else return!0}),_=w(),A=It(_);return re(()=>{if(!(A.value instanceof HTMLElement))return;f.value.set(n,A.value.textContent??a.value?.toString()??"");const x=y?.id;x&&(v.value.has(x)?v.value.get(x)?.add(n):v.value.set(x,new Set([n])))}),ve(()=>{f.value.delete(n)}),(x,T)=>d.value?(u(),g(e(Fa),j({key:0},e(r),{id:e(n),ref_key:"itemRef",ref:_,"data-slot":"command-item",class:e(Q)("data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",a.class),onSelect:T[0]||(T[0]=()=>{e(l).search=""})}),{default:p(()=>[V(x.$slots,"default")]),_:3},16,["id","class"])):H("",!0)}}),pe=Object.assign(qs,{__name:"UiCommandItem"}),js={role:"presentation"},Ks=D({__name:"CommandList",props:{asChild:{type:Boolean},as:{},class:{}},setup(s){const t=s,a=Z(t,"class"),o=Re(a);return(i,r)=>(u(),g(e(ka),j({"data-slot":"command-list"},e(o),{class:e(Q)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto scrollbar-none",t.class)}),{default:p(()=>[c("div",js,[V(i.$slots,"default")])]),_:3},16,["class"]))}}),Us=Object.assign(Ks,{__name:"UiCommandList"}),Hs=D({__name:"CommandSeparator",props:{orientation:{},decorative:{type:Boolean},asChild:{type:Boolean},as:{},class:{}},setup(s){const t=s,a=Z(t,"class");return(o,i)=>(u(),g(e(ea),j({"data-slot":"command-separator"},e(a),{class:e(Q)("bg-border -mx-1 h-px",t.class)}),{default:p(()=>[V(o.$slots,"default")]),_:3},16,["class"]))}}),Ge=Object.assign(Hs,{__name:"UiCommandSeparator"}),Ns=D({__name:"CommandShortcut",props:{class:{}},setup(s){const t=s;return(a,o)=>(u(),S("span",{"data-slot":"command-shortcut",class:le(e(Q)("text-muted-foreground ml-auto text-xs tracking-widest",t.class))},[V(a.$slots,"default")],2))}});Object.assign(Ns,{__name:"UiCommandShortcut"});const[Ee,Gs]=we("Command"),[Ws,Js]=we("CommandGroup"),Qs={class:"flex-1"},Xs={class:"flex-1"},Ys={class:"ml-auto flex items-center gap-1"},Zs={class:"inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-[10px] text-muted-foreground"},eo={class:"flex-1"},to={class:"ml-auto flex items-center gap-1"},ao={class:"inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-[10px] text-muted-foreground"},so={class:"ml-auto flex items-center gap-1"},oo={class:"inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-[10px] text-muted-foreground"},no=D({__name:"CommandPalette",props:{open:{type:Boolean,default:!1},openModifiers:{},filter:{default:""},filterModifiers:{}},emits:Rt(["openShortcutsHelp"],["update:open","update:filter"]),setup(s,{emit:t}){const a=Oe(s,"open"),o=Oe(s,"filter"),i=t,r=Qe(),{themeMode:n,cycleThemeMode:l}=Xe(),{prds:f}=Ve(),{repos:v,currentRepoId:y,selectRepo:d,refreshGitRepos:_}=Se(),{showSuccess:A,showError:x}=et(),T=["document","board","graph"],F={document:"Document",board:"Task Board",graph:"Graph"},C=w("document");{const $=localStorage.getItem("prd-viewer-tab");($==="document"||$==="board"||$==="graph")&&(C.value=$)}function L($){$.key!=="prd-viewer-tab"||!$.newValue||($.newValue==="document"||$.newValue==="board"||$.newValue==="graph")&&(C.value=$.newValue)}re(()=>{window.addEventListener("storage",L)}),ve(()=>{window.removeEventListener("storage",L)});const z=M(()=>{const $=T.indexOf(C.value),I=$>=0?$:0;return T[(I+1)%T.length]}),R=M(()=>F[z.value]);function B($){y.value&&(r.push(`/${y.value}/${$}`),a.value=!1)}function ae($){d($),r.push("/"),a.value=!1}function K(){l(),a.value=!1}function oe(){const $=z.value;C.value=$,localStorage.setItem("prd-viewer-tab",$),window.dispatchEvent(new StorageEvent("storage",{key:"prd-viewer-tab",newValue:$})),a.value=!1}function ee(){a.value=!1,i("openShortcutsHelp")}const G=w(!1);async function X(){if(!(!y.value||G.value)){G.value=!0,a.value=!1;try{const $=await _(y.value);A(`Discovered ${$.discovered} git repositories`)}catch{x("Failed to refresh git repos")}finally{G.value=!1}}}ne(a,$=>{$||(o.value="")});const W=M(()=>navigator.platform.toUpperCase().indexOf("MAC")>=0),Y=M(()=>W.value?"⌘":"Ctrl");return($,I)=>(u(),g(e(Os),{open:a.value,"onUpdate:open":I[0]||(I[0]=N=>a.value=N),"default-search":o.value},{default:p(()=>[m(e(zs),{placeholder:"Type a command or search..."}),m(e(Us),null,{default:p(()=>[m(e(Fs),null,{default:p(()=>[...I[1]||(I[1]=[J("No results found.",-1)])]),_:1}),e(f)?.length?(u(),g(e(Be),{key:0,heading:"Documents"},{default:p(()=>[(u(!0),S(te,null,se(e(f),N=>(u(),g(e(pe),{key:N.slug,value:`PRD: ${N.name}`,onSelect:ue=>B(N.slug)},{default:p(()=>[m(e(Fe),{class:"size-4"}),c("span",null,q(N.name),1)]),_:2},1032,["value","onSelect"]))),128))]),_:1})):H("",!0),e(f)?.length&&e(v)?.length?(u(),g(e(Ge),{key:1})):H("",!0),e(v)?.length?(u(),g(e(Be),{key:2,heading:"Repositories"},{default:p(()=>[(u(!0),S(te,null,se(e(v),N=>(u(),g(e(pe),{key:N.id,value:`repo-${N.id} ${N.name}`,onSelect:ue=>ae(N.id)},{default:p(()=>[m(e(Le),{class:"size-4"}),c("span",Qs,q(N.name),1),N.id===e(y)?(u(),g(e(tt),{key:0,class:"size-4 text-primary"})):H("",!0)]),_:2},1032,["value","onSelect"]))),128))]),_:1})):H("",!0),e(v)?.length?(u(),g(e(Ge),{key:3})):H("",!0),m(e(Be),{heading:"Actions"},{default:p(()=>[m(e(pe),{value:"cycle-theme light dark system",onSelect:K},{default:p(()=>[e(n)==="system"?(u(),g(e(it),{key:0,class:"size-4"})):e(n)==="light"?(u(),g(e(dt),{key:1,class:"size-4"})):(u(),g(e(ut),{key:2,class:"size-4"})),c("span",Xs,"Cycle theme mode ("+q(e(n))+")",1),c("div",Ys,[c("kbd",Zs,q(e(Y)),1),I[2]||(I[2]=c("kbd",{class:"inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-[10px] text-muted-foreground"},".",-1))])]),_:1}),m(e(pe),{value:`switch-tab ${e(R).toLowerCase()}`,onSelect:oe},{default:p(()=>[m(e(at),{class:"size-4"}),c("span",eo,"Switch to "+q(e(R)),1),c("div",to,[c("kbd",ao,q(e(Y)),1),I[3]||(I[3]=c("kbd",{class:"inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-[10px] text-muted-foreground"},"\\",-1))])]),_:1},8,["value"]),m(e(pe),{value:"keyboard shortcuts help",onSelect:ee},{default:p(()=>[m(e(ta),{class:"size-4"}),I[5]||(I[5]=c("span",{class:"flex-1"},"Keyboard shortcuts",-1)),c("div",so,[c("kbd",oo,q(e(Y)),1),I[4]||(I[4]=c("kbd",{class:"inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-[10px] text-muted-foreground"},"/",-1))])]),_:1}),e(y)?(u(),g(e(pe),{key:0,value:"refresh git repos rescan discover",disabled:e(G),onSelect:X},{default:p(()=>[m(e(st),{class:le(["size-4",{"animate-spin":e(G)}])},null,8,["class"]),I[6]||(I[6]=c("span",{class:"flex-1"},"Refresh git repos",-1))]),_:1},8,["disabled"])):H("",!0)]),_:1})]),_:1})]),_:1},8,["open","default-search"]))}}),lo=Object.assign(no,{__name:"CommandPalette"}),ro={class:"space-y-6"},io={class:"mb-3 text-sm font-medium text-muted-foreground"},uo={class:"space-y-2"},co={class:"text-sm"},po={class:"flex items-center gap-1"},fo=D({__name:"ShortcutsHelp",props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:["update:open"],setup(s){const t=Oe(s,"open"),a=M(()=>navigator.platform.toUpperCase().indexOf("MAC")>=0),o=M(()=>a.value?"⌘":"Ctrl"),i=M(()=>[{name:"Navigation",shortcuts:[{keys:[o.value,"K"],description:"Open command palette"},{keys:[o.value,"J"],description:"Quick jump to document"}]},{name:"Actions",shortcuts:[{keys:[o.value,"."],description:"Cycle theme mode (light/dark/system)"},{keys:[o.value,"\\"],description:"Cycle Document, Task Board, and Graph tabs"},{keys:[o.value,","],description:"Add repository"}]},{name:"Help",shortcuts:[{keys:[o.value,"/"],description:"Show this help"},{keys:["Esc"],description:"Close dialog or palette"}]}]);return(r,n)=>(u(),g(e(ct),{open:t.value,"onUpdate:open":n[0]||(n[0]=l=>t.value=l)},{default:p(()=>[m(e(pt),{class:"max-w-md"},{default:p(()=>[m(e(mt),null,{default:p(()=>[m(e(vt),null,{default:p(()=>[...n[1]||(n[1]=[J("Keyboard Shortcuts",-1)])]),_:1}),m(e(ft),null,{default:p(()=>[...n[2]||(n[2]=[J(" Quick reference for available keyboard shortcuts. ",-1)])]),_:1})]),_:1}),c("div",ro,[(u(!0),S(te,null,se(e(i),l=>(u(),S("div",{key:l.name},[c("h3",io,q(l.name),1),c("div",uo,[(u(!0),S(te,null,se(l.shortcuts,f=>(u(),S("div",{key:f.description,class:"flex items-center justify-between"},[c("span",co,q(f.description),1),c("div",po,[(u(!0),S(te,null,se(f.keys,(v,y)=>(u(),S("kbd",{key:y,class:"inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-xs font-medium text-muted-foreground"},q(v),1))),128))])]))),128))])]))),128))])]),_:1})]),_:1},8,["open"]))}}),mo=Object.assign(fo,{__name:"ShortcutsHelp"});function ht(){const s=document.activeElement;if(!s)return!1;const t=s.tagName.toLowerCase();return t==="input"||t==="textarea"||s.getAttribute("contenteditable")==="true"||s.getAttribute("role")==="textbox"}function vo(s){const t=s.toLowerCase().split("+"),a=t.pop()||"";return{meta:t.includes("meta"),ctrl:t.includes("ctrl"),shift:t.includes("shift"),alt:t.includes("alt"),key:a}}function ho(s,t){const a=s.key.toLowerCase();let o=a===t.key;return t.key==="\\"&&(o=a==="\\"||s.code==="Backslash"),t.key==="/"&&(o=a==="/"||s.code==="Slash"),t.key==="."&&(o=a==="."||s.code==="Period"),t.key===","&&(o=a===","||s.code==="Comma"),o&&s.metaKey===t.meta&&s.ctrlKey===t.ctrl&&s.shiftKey===t.shift&&s.altKey===t.alt}const Ce=[];let We=!1;function go(s){for(const t of Ce)if(ho(s,t.combo)){if(!t.allowInInput&&ht())continue;s.preventDefault(),s.stopPropagation(),t.handler();return}}function Je(){We||(document.addEventListener("keydown",go,{capture:!0}),We=!0)}function yo(){re(()=>{Je()});function s(a,o,i){const n={combo:vo(a),handler:o,allowInInput:i?.allowInInput??!1};Ce.push(n),Je(),ve(()=>{const l=Ce.indexOf(n);l>-1&&Ce.splice(l,1)})}function t(){return ht()}return{onShortcut:s,isInputFocused:t}}const _o=globalThis.setInterval,bo=2e3,xo=2e3;function wo(s){return!s.instanceId||!s.buildId?null:`${s.buildId}:${s.instanceId}`}function Co(s){const t=w(null),a=w(!1),o=w(null),i=w(null),r=w(null),n=w(null),l=w(!1),f=w(!1),v=w(!1);function y(){i.value&&(clearTimeout(i.value),i.value=null)}function d(){r.value&&(clearInterval(r.value),r.value=null)}async function _(){try{const R=await $fetch(`/api/runtime?_=${Date.now()}`);return wo(R)}catch{return null}}async function A(){n.value===null&&(n.value=await _())}async function x(){if(!(l.value||v.value)){l.value=!0;try{const R=await _();if(!R)return;if(!n.value){n.value=R;return}R!==n.value&&(v.value=!0,window.location.reload())}finally{l.value=!1}}}function T(){r.value||(r.value=_o(()=>{x()},xo))}function F(){i.value||(i.value=setTimeout(()=>{i.value=null,L()},bo))}function C(){const R=new URLSearchParams(window.location.search).get("token");return R?`/api/watch?token=${encodeURIComponent(R)}`:"/api/watch"}function L(){if(!t.value)try{const R=new EventSource(C());R.onopen=async()=>{a.value=!0,o.value=null,y(),d(),f.value&&(f.value=!1,await x())},R.onmessage=B=>{try{const ae=JSON.parse(B.data);s(ae)}catch{}},R.onerror=()=>{a.value=!1,o.value="Connection lost",f.value=!0,t.value===R&&(R.close(),t.value=null),T(),F()},t.value=R}catch{o.value="Failed to connect",T(),F()}}function z(){y(),d(),f.value=!1,t.value&&(t.value.close(),t.value=null,a.value=!1)}return re(async()=>{await A(),L()}),ve(()=>{z()}),{isConnected:a,error:o,connect:L,disconnect:z}}const ko={class:"min-h-screen bg-background text-foreground"},So={class:"fixed top-0 left-0 right-0 z-50 h-14 border-b border-border bg-background/95 backdrop-blur-sm supports-[backdrop-filter]:bg-background/80"},$o={class:"flex h-full items-center justify-between px-4 md:px-6"},Ro={class:"flex items-center gap-3"},Eo={class:"flex h-screen pt-14"},Do={class:"flex-1 overflow-auto"},Lo=D({__name:"default",setup(s){const{themeMode:t,cycleThemeMode:a}=Xe(),{refreshPrds:o}=Ve(),{currentRepoId:i}=Se(),r=Me(),n=w(null);Et("fileChangeEvent",n);const l=w(!1),f=w(""),v=w(!1),y=w(null),{onShortcut:d}=yo();d("Meta+k",()=>{l.value=!0}),d("Ctrl+k",()=>{l.value=!0}),d("Meta+j",()=>{f.value="PRD: ",l.value=!0}),d("Ctrl+j",()=>{f.value="PRD: ",l.value=!0});function _(){const F=["document","board","graph"],C=localStorage.getItem("prd-viewer-tab")||"document",L=F.indexOf(C),z=L>=0?L:0,R=F[(z+1)%F.length]??"document";localStorage.setItem("prd-viewer-tab",R),window.dispatchEvent(new StorageEvent("storage",{key:"prd-viewer-tab",newValue:R}))}d("Meta+\\",_),d("Ctrl+\\",_);function A(){a()}d("Meta+.",A),d("Ctrl+.",A);function x(){y.value?.openAddDialog()}d("Meta+,",x),d("Ctrl+,",x);function T(){v.value=!0}return d("Meta+/",T),d("Ctrl+/",T),d("Meta+Shift+/",T),d("Ctrl+Shift+/",T),Co(F=>{if(F.type==="connected"||!F.category)return;const C=F.category;if(F.repoId!==i.value)return;(C==="prd"||C==="tasks")&&o();const L=r.params.prd,z=C==="tasks"||C==="progress",R=C==="prd"&&(!L||F.path?.includes(`/${L}.`)),B=!!L&&z&&F.path?.includes(`/${L}/`);(z||R||B)&&(n.value={category:C,path:F.path,timestamp:Date.now()})}),(F,C)=>{const L=us,z=Dt,R=_s;return u(),S("div",ko,[m(lo,{open:e(l),"onUpdate:open":C[0]||(C[0]=B=>ye(l)?l.value=B:null),filter:e(f),"onUpdate:filter":C[1]||(C[1]=B=>ye(f)?f.value=B:null),onOpenShortcutsHelp:T},null,8,["open","filter"]),m(mo,{open:e(v),"onUpdate:open":C[2]||(C[2]=B=>ye(v)?v.value=B:null)},null,8,["open"]),c("header",So,[c("div",$o,[C[5]||(C[5]=c("div",{class:"flex items-center gap-4"},[c("h1",{class:"text-lg font-semibold tracking-tight"}," PRD Viewer ")],-1)),m(z,null,{fallback:p(()=>[...C[4]||(C[4]=[c("div",{class:"flex items-center gap-3"},[c("div",{class:"h-8 w-[200px] animate-pulse rounded-md bg-muted"}),c("div",{class:"size-9 animate-pulse rounded-md bg-muted"})],-1)])]),default:p(()=>[c("div",Ro,[m(L,{ref_key:"repoSelectorRef",ref:y},null,512),m(e(me),{variant:"ghost",size:"icon",class:"size-9",onClick:A},{default:p(()=>[e(t)==="system"?(u(),g(e(it),{key:0,class:"size-4"})):e(t)==="light"?(u(),g(e(dt),{key:1,class:"size-4"})):(u(),g(e(ut),{key:2,class:"size-4"})),C[3]||(C[3]=c("span",{class:"sr-only"},"Cycle theme mode",-1))]),_:1})])]),_:1})])]),c("div",Eo,[m(z,null,{fallback:p(()=>[...C[6]||(C[6]=[c("aside",{class:"flex h-full w-64 flex-col border-r border-border bg-background"},[c("div",{class:"flex h-12 items-center border-b border-border px-4"},[c("div",{class:"h-4 w-20 animate-pulse rounded bg-muted"})]),c("div",{class:"flex-1 p-2 space-y-2"},[c("div",{class:"h-9 animate-pulse rounded-md bg-muted"}),c("div",{class:"h-9 animate-pulse rounded-md bg-muted"}),c("div",{class:"h-9 animate-pulse rounded-md bg-muted"})])],-1)])]),default:p(()=>[m(R)]),_:1}),c("main",Do,[V(F.$slots,"default")])])])}}});export{Lo as default};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import{S as on,a as un,b as cn,d as ln,e as pn,f as fn,g as dn,h as gn,i as hn,j as mn,c as wn,k as yn,l as bn,m as Cn,n as kn,o as xn,p as En,q as $n,r as An,s as In,t as Sn,u as vn,v as _n,w as Mn,x as Nn,y as Ln,z as Fn,A as Gn,B as Pn,C as Rn,D as Un,E as Tn,F as On,G as Dn,H as Bn,I as Vn,J as zn,K as Hn,L as Wn,M as jn,N as Xn,O as Zn,P as Qn,Q as qn,R as Jn,T as Kn,U as Yn,V as es,W as rs,X as ts,Y as ns,Z as ss,_ as as}from"./nX8Sf7cz.js";import"./BlTKcjLJ.js";function W(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function wr(e,t,r){return e.has(t)||e.set(t,r),e.get(t)}const be=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),k=String.raw;function j(e,t){if(e==null)throw new Error(t??"Value expected");return e}const We=k`\[\^?`,je=`c.? | C(?:-.?)?|${k`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${k`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${k`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${k`o\{[^\}]*\}?`}|${k`\d{1,3}`}`,Ce=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,K=new RegExp(k`
|
|
2
|
+
\\ (?:
|
|
3
|
+
${je}
|
|
4
|
+
| [gk]<[^>]*>?
|
|
5
|
+
| [gk]'[^']*'?
|
|
6
|
+
| .
|
|
7
|
+
)
|
|
8
|
+
| \( (?:
|
|
9
|
+
\? (?:
|
|
10
|
+
[:=!>({]
|
|
11
|
+
| <[=!]
|
|
12
|
+
| <[^>]*>
|
|
13
|
+
| '[^']*'
|
|
14
|
+
| ~\|?
|
|
15
|
+
| #(?:[^)\\]|\\.?)*
|
|
16
|
+
| [^:)]*[:)]
|
|
17
|
+
)?
|
|
18
|
+
| \*[^\)]*\)?
|
|
19
|
+
)?
|
|
20
|
+
| (?:${Ce.source})+
|
|
21
|
+
| ${We}
|
|
22
|
+
| .
|
|
23
|
+
`.replace(/\s+/g,""),"gsu"),oe=new RegExp(k`
|
|
24
|
+
\\ (?:
|
|
25
|
+
${je}
|
|
26
|
+
| .
|
|
27
|
+
)
|
|
28
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
29
|
+
| ${We}
|
|
30
|
+
| &&
|
|
31
|
+
| .
|
|
32
|
+
`.replace(/\s+/g,""),"gsu");function yr(e,t={}){const r={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const n=Ur(r.flags),a=[n.extended],s={captureGroup:r.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(p){a.push(p)},replaceCurrentModX(p){a[a.length-1]=p},singleline:r.rules.singleline};let o=[],i;for(K.lastIndex=0;i=K.exec(e);){const p=br(s,e,i[0],K.lastIndex);p.tokens?o.push(...p.tokens):p.token&&o.push(p.token),p.lastIndex!==void 0&&(K.lastIndex=p.lastIndex)}const u=[];let c=0;o.filter(p=>p.type==="GroupOpen").forEach(p=>{p.kind==="capturing"?p.number=++c:p.raw==="("&&u.push(p)}),c||u.forEach((p,f)=>{p.kind="capturing",p.number=f+1});const l=c||u.length;return{tokens:o.map(p=>p.type==="EscapedNumber"?Or(p,l):p).flat(),flags:n}}function br(e,t,r,n){const[a,s]=r;if(r==="["||r==="[^"){const o=Cr(t,r,n);return{tokens:o.tokens,lastIndex:o.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(s))return{token:Ae(r,r)};if(/^\\g[<']/.test(r)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:Mr(r)}}if(/^\\k[<']/.test(r)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:Ze(r)}}if(s==="K")return{token:Qe("keep",r)};if(s==="N"||s==="R")return{token:U("newline",r,{negate:s==="N"})};if(s==="O")return{token:U("any",r)};if(s==="X")return{token:U("text_segment",r)};const o=Xe(r,{inCharClass:!1});return Array.isArray(o)?{tokens:o}:{token:o}}if(a==="("){if(s==="*")return{token:Gr(r)};if(r==="(?{")throw new Error(`Unsupported callout "${r}"`);if(r.startsWith("(?#")){if(t[n]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:n+1}}if(/^\(\?[-imx]+[:)]$/.test(r))return{token:Fr(r,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,r==="("&&!e.captureGroup||r==="(?:")return{token:z("group",r)};if(r==="(?>")return{token:z("atomic",r)};if(r==="(?="||r==="(?!"||r==="(?<="||r==="(?<!")return{token:z(r[2]==="<"?"lookbehind":"lookahead",r,{negate:r.endsWith("!")})};if(r==="("&&e.captureGroup||r.startsWith("(?<")&&r.endsWith(">")||r.startsWith("(?'")&&r.endsWith("'"))return{token:z("capturing",r,{...r!=="("&&{name:r.slice(3,-1)}})};if(r.startsWith("(?~")){if(r==="(?~|")throw new Error(`Unsupported absence function kind "${r}"`);return{token:z("absence_repeater",r)}}throw r==="(?("?new Error(`Unsupported conditional "${r}"`):new Error(`Invalid or unsupported group option "${r}"`)}if(r===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:Sr(r)}}if(e.getCurrentModX()){if(r==="#"){const o=t.indexOf(`
|
|
33
|
+
`,n);return{lastIndex:o===-1?t.length:o}}if(/^\s$/.test(r)){const o=/\s+/y;return o.lastIndex=n,{lastIndex:o.exec(t)?o.lastIndex:n}}}if(r===".")return{token:U("dot",r)};if(r==="^"||r==="$"){const o=e.singleline?{"^":k`\A`,$:k`\Z`}[r]:r;return{token:Ae(o,r)}}return r==="|"?{token:xr(r)}:Ce.test(r)?{tokens:Dr(r)}:{token:N(W(r),r)}}function Cr(e,t,r){const n=[Ie(t[1]==="^",t)];let a=1,s;for(oe.lastIndex=r;s=oe.exec(e);){const o=s[0];if(o[0]==="["&&o[1]!==":")a++,n.push(Ie(o[1]==="^",o));else if(o==="]"){if(n.at(-1).type==="CharacterClassOpen")n.push(N(93,o));else if(a--,n.push(Er(o)),!a)break}else{const i=kr(o);Array.isArray(i)?n.push(...i):n.push(i)}}return{tokens:n,lastIndex:oe.lastIndex||e.length}}function kr(e){if(e[0]==="\\")return Xe(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!be.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return U("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?$r(e):e==="&&"?Ar(e):N(W(e),e)}function Xe(e,{inCharClass:t}){const r=e[1];if(r==="c"||r==="C")return Lr(e);if("dDhHsSwW".includes(r))return Pr(e);if(e.startsWith(k`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Rr(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const n=e.split(/\\x/).slice(1).map(o=>parseInt(o,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(n)),s=new TextEncoder;return[...a].map(o=>{const i=[...s.encode(o)].map(u=>`\\x${u.toString(16)}`).join("");return N(W(o),i)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(r==="u"||r==="x")return N(Tr(e),e);if(Se.has(r))return N(Se.get(r),e);if(/\d/.test(r))return Ir(t,e);if(e==="\\")throw new Error(k`Incomplete escape "\"`);if(r==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return N(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function xr(e){return{type:"Alternator",raw:e}}function Ae(e,t){return{type:"Assertion",kind:e,raw:t}}function Ze(e){return{type:"Backreference",raw:e}}function N(e,t){return{type:"Character",value:e,raw:t}}function Er(e){return{type:"CharacterClassClose",raw:e}}function $r(e){return{type:"CharacterClassHyphen",raw:e}}function Ar(e){return{type:"CharacterClassIntersector",raw:e}}function Ie(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function U(e,t,r={}){return{type:"CharacterSet",kind:e,...r,raw:t}}function Qe(e,t,r={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:j(r.flags),raw:t}}function Ir(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function Sr(e){return{type:"GroupClose",raw:e}}function z(e,t,r={}){return{type:"GroupOpen",kind:e,...r,raw:t}}function vr(e,t,r,n){return{type:"NamedCallout",kind:e,tag:t,arguments:r,raw:n}}function _r(e,t,r,n){return{type:"Quantifier",kind:e,min:t,max:r,raw:n}}function Mr(e){return{type:"Subroutine",raw:e}}const Nr=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Se=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Lr(e){const t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return N(W(t.toUpperCase())-64,e)}function Fr(e,t){let{on:r,off:n}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;n??="";const a=(t.getCurrentModX()||r.includes("x"))&&!n.includes("x"),s=_e(r),o=_e(n),i={};if(s&&(i.enable=s),o&&(i.disable=o),e.endsWith(")"))return t.replaceCurrentModX(a),Qe("flags",e,{flags:i});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,z("group",e,{...(s||o)&&{flags:i}});throw new Error(`Unexpected flag modifier "${e}"`)}function Gr(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:r,tag:n,args:a}=t.groups;if(!r)throw new Error(`Invalid named callout "${e}"`);if(n==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const s=a?a.split(",").filter(l=>l!=="").map(l=>/^[+-]?\d+$/.test(l)?+l:l):[],[o,i,u]=s,c=Nr.has(r)?r.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(s.length>0)throw new Error(`Named callout arguments not allowed "${s}"`);break;case"error":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(typeof o=="string")throw new Error(`Named callout argument must be a number "${o}"`);break;case"max":if(!s.length||s.length>2)throw new Error(`Named callout must have one or two arguments "${s}"`);if(typeof o=="string"&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(s.length===2&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);break;case"count":case"total_count":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(s.length===1&&(typeof o=="number"||!/^[<>X]$/.test(o)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case"cmp":if(s.length!==3)throw new Error(`Named callout must have three arguments "${s}"`);if(typeof o=="string"&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof i=="number"||!/^(?:[<>!=]=|[<>])$/.test(i))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument three must be a tag or number "${u}"`);break;case"custom":throw new Error(`Undefined callout name "${r}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return vr(c,n??null,a?.split(",")??null,e)}function ve(e){let t=null,r,n;if(e[0]==="{"){const{minStr:a,maxStr:s}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+a>o||s&&+s>o)throw new Error("Quantifier value unsupported in Oniguruma");if(r=+a,n=s===void 0?+a:s===""?1/0:+s,r>n&&(t="possessive",[r,n]=[n,r]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else r=e[0]==="+"?1:0,n=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return _r(t,r,n,e)}function Pr(e){const t=e[1].toLowerCase();return U({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Rr(e){const{p:t,neg:r,value:n}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return U("property",e,{value:n,negate:t==="P"&&!r||t==="p"&&!!r})}function _e(e){const t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Ur(e){const t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let r=0;r<e.length;r++){const n=e[r];if(!"imxDPSWy".includes(n))throw new Error(`Invalid flag "${n}"`);if(n==="y"){if(!/^y{[gw]}/.test(e.slice(r)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[r+2]==="g"?"grapheme":"word",r+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[n]]=!0}return t}function Tr(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Or(e,t){const{raw:r,inCharClass:n}=e,a=r.slice(1);if(!n&&(a!=="0"&&a.length===1||a[0]!=="0"&&+a<=t))return[Ze(r)];const s=[],o=a.match(/^[0-7]+|\d/g);for(let i=0;i<o.length;i++){const u=o[i];let c;if(i===0&&u!=="8"&&u!=="9"){if(c=parseInt(u,8),c>127)throw new Error(k`Octal encoded byte above 177 unsupported "${r}"`)}else c=W(u);s.push(N(c,(i===0?"\\":"")+u))}return s}function Dr(e){const t=[],r=new RegExp(Ce,"gy");let n;for(;n=r.exec(e);){const a=n[0];if(a[0]==="{"){const s=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(a);if(s){const{min:o,max:i}=s.groups;if(+o>+i&&a.endsWith("?")){r.lastIndex--,t.push(ve(a.slice(0,-1)));continue}}}t.push(ve(a))}return t}function qe(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;const r=e.body[0];return!t||Object.keys(t).every(n=>t[n]===r[n])}function Br(e){return Vr.has(e.type)}const Vr=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Je(e,t={}){const r={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},n=yr(e,{flags:r.flags,rules:{captureGroup:r.rules.captureGroup,singleline:r.rules.singleline}}),a=(f,g)=>{const d=n.tokens[s.nextIndex];switch(s.parent=f,s.nextIndex++,d.type){case"Alternator":return T();case"Assertion":return zr(d);case"Backreference":return Hr(d,s);case"Character":return ne(d.value,{useLastValid:!!g.isCheckingRangeEnd});case"CharacterClassHyphen":return Wr(d,s,g);case"CharacterClassOpen":return jr(d,s,g);case"CharacterSet":return Xr(d,s);case"Directive":return Yr(d.kind,{flags:d.flags});case"GroupOpen":return Zr(d,s,g);case"NamedCallout":return rt(d.kind,d.tag,d.arguments);case"Quantifier":return Qr(d,s);case"Subroutine":return qr(d,s);default:throw new Error(`Unexpected token type "${d.type}"`)}},s={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:r.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:r.skipBackrefValidation,skipLookbehindValidation:r.skipLookbehindValidation,skipPropertyNameValidation:r.skipPropertyNameValidation,subroutines:[],tokens:n.tokens,unicodePropertyMap:r.unicodePropertyMap,walk:a},o=nt(et(n.flags));let i=o.body[0];for(;s.nextIndex<n.tokens.length;){const f=a(i,{});f.type==="Alternative"?(o.body.push(f),i=f):i.body.push(f)}const{capturingGroups:u,hasNumberedRef:c,namedGroupsByName:l,subroutines:p}=s;if(c&&l.size&&!r.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:f}of p)if(typeof f=="number"){if(f>u.length)throw new Error("Subroutine uses a group number that's not defined");f&&(u[f-1].isSubroutined=!0)}else if(l.has(f)){if(l.get(f).length>1)throw new Error(k`Subroutine uses a duplicate group name "\g<${f}>"`);l.get(f)[0].isSubroutined=!0}else throw new Error(k`Subroutine uses a group name that's not defined "\g<${f}>"`);return o}function zr({kind:e}){return de(j({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===k`\B`||e===k`\Y`})}function Hr({raw:e},t){const r=/^\\k[<']/.test(e),n=r?e.slice(3,-1):e.slice(1),a=(s,o=!1)=>{const i=t.capturingGroups.length;let u=!1;if(s>i)if(t.skipBackrefValidation)u=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,ge(o?i+1-s:s,{orphan:u})};if(r){const s=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(n);if(s)return a(+s.groups.num,!!s.groups.sign);if(/[-+]/.test(n))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(n))throw new Error(`Group name not defined to the left "${e}"`);return ge(n)}return a(+n)}function Wr(e,t,r){const{tokens:n,walk:a}=t,s=t.parent,o=s.body.at(-1),i=n[t.nextIndex];if(!r.isCheckingRangeEnd&&o&&o.type!=="CharacterClass"&&o.type!=="CharacterClassRange"&&i&&i.type!=="CharacterClassOpen"&&i.type!=="CharacterClassClose"&&i.type!=="CharacterClassIntersector"){const u=a(s,{...r,isCheckingRangeEnd:!0});if(o.type==="Character"&&u.type==="Character")return s.body.pop(),Kr(o,u);throw new Error("Invalid character class range")}return ne(W("-"))}function jr({negate:e},t,r){const{tokens:n,walk:a}=t,s=n[t.nextIndex],o=[re()];let i=Le(s);for(;i.type!=="CharacterClassClose";){if(i.type==="CharacterClassIntersector")o.push(re()),t.nextIndex++;else{const c=o.at(-1);c.body.push(a(c,r))}i=Le(n[t.nextIndex],s)}const u=re({negate:e});return o.length===1?u.body=o[0].body:(u.kind="intersection",u.body=o.map(c=>c.body.length===1?c.body[0]:c)),t.nextIndex++,u}function Xr({kind:e,negate:t,value:r},n){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:s,unicodePropertyMap:o}=n;if(e==="property"){const i=se(r);if(be.has(i)&&!o?.has(i))e="posix",r=i;else return H(r,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:s,unicodePropertyMap:o})}return e==="posix"?tt(r,{negate:t}):he(e,{negate:t})}function Zr(e,t,r){const{tokens:n,capturingGroups:a,namedGroupsByName:s,skipLookbehindValidation:o,walk:i}=t,u=st(e),c=u.type==="AbsenceFunction",l=Ne(u),p=l&&u.negate;if(u.type==="CapturingGroup"&&(a.push(u),u.name&&wr(s,u.name,[]).push(u)),c&&r.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let f=Fe(n[t.nextIndex]);for(;f.type!=="GroupClose";){if(f.type==="Alternator")u.body.push(T()),t.nextIndex++;else{const g=u.body.at(-1),d=i(g,{...r,isInAbsenceFunction:r.isInAbsenceFunction||c,isInLookbehind:r.isInLookbehind||l,isInNegLookbehind:r.isInNegLookbehind||p});if(g.body.push(d),(l||r.isInLookbehind)&&!o){const m="Lookbehind includes a pattern not allowed by Oniguruma";if(p||r.isInNegLookbehind){if(Me(d)||d.type==="CapturingGroup")throw new Error(m)}else if(Me(d)||Ne(d)&&d.negate)throw new Error(m)}}f=Fe(n[t.nextIndex])}return t.nextIndex++,u}function Qr({kind:e,min:t,max:r},n){const a=n.parent,s=a.body.at(-1);if(!s||!Br(s))throw new Error("Quantifier requires a repeatable token");const o=Ye(e,t,r,s);return a.body.pop(),o}function qr({raw:e},t){const{capturingGroups:r,subroutines:n}=t;let a=e.slice(3,-1);const s=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(a);if(s){const i=+s.groups.num,u=r.length;if(t.hasNumberedRef=!0,a={"":i,"+":u+i,"-":u+1-i}[s.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const o=er(a);return n.push(o),o}function Jr(e,t){return{type:"AbsenceFunction",kind:e,body:q(t?.body)}}function T(e){return{type:"Alternative",body:rr(e?.body)}}function de(e,t){const r={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(r.negate=!!t?.negate),r}function ge(e,t){const r=!!t?.orphan;return{type:"Backreference",ref:e,...r&&{orphan:r}}}function Ke(e,t){const r={name:void 0,isSubroutined:!1,...t};if(r.name!==void 0&&!at(r.name))throw new Error(`Group name "${r.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...r.name&&{name:r.name},...r.isSubroutined&&{isSubroutined:r.isSubroutined},body:q(t?.body)}}function ne(e,t){const r={useLastValid:!1,...t};if(e>1114111){const n=e.toString(16);if(r.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${n}}"`):new Error(`Invalid code point out of range in JS "\\x{${n}}"`)}return{type:"Character",value:e}}function re(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:rr(e?.body)}}function Kr(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function he(e,t){const r=!!t?.negate,n={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(n.negate=r),(e==="text_segment"||e==="newline"&&!r)&&(n.variableLength=!0),n}function Yr(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:j(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function et(e){return{type:"Flags",...e}}function v(e){const t=e?.atomic,r=e?.flags;if(t&&r)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...r&&{flags:r},body:q(e?.body)}}function R(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:q(e?.body)}}function rt(e,t,r){return{type:"NamedCallout",kind:e,tag:t,arguments:r}}function tt(e,t){const r=!!t?.negate;if(!be.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:r}}function Ye(e,t,r,n){if(t>r)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:r,body:n}}function nt(e,t){return{type:"Regex",body:q(t?.body),flags:e}}function er(e){return{type:"Subroutine",ref:e}}function H(e,t){const r={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let n=r.unicodePropertyMap?.get(se(e));if(!n){if(r.normalizeUnknownPropertyNames)n=ot(e);else if(r.unicodePropertyMap&&!r.skipPropertyNameValidation)throw new Error(k`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:n??e,negate:r.negate}}function st({flags:e,kind:t,name:r,negate:n,number:a}){switch(t){case"absence_repeater":return Jr("repeater");case"atomic":return v({atomic:!0});case"capturing":return Ke(a,{name:r});case"group":return v({flags:e});case"lookahead":case"lookbehind":return R({behind:t==="lookbehind",negate:n});default:throw new Error(`Unexpected group kind "${t}"`)}}function q(e){if(e===void 0)e=[T()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function rr(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function Me(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function Ne(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function at(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function ot(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function se(e){return e.replace(/[- _]+/g,"").toLowerCase()}function Le(e,t){return j(e,`${t?.type==="Character"&&t.value===93?"Empty":"Unclosed"} character class`)}function Fe(e){return j(e,"Unclosed group")}function Z(e,t,r=null){function n(s,o){for(let i=0;i<s.length;i++){const u=a(s[i],o,i,s);i=Math.max(-1,i+u)}}function a(s,o=null,i=null,u=null){let c=0,l=!1;const p={node:s,parent:o,key:i,container:u,root:e,remove(){Y(u).splice(Math.max(0,B(i)+c),1),c--,l=!0},removeAllNextSiblings(){return Y(u).splice(B(i)+1)},removeAllPrevSiblings(){const y=B(i)+c;return c-=y,Y(u).splice(0,Math.max(0,y))},replaceWith(y,E={}){const $=!!E.traverse;u?u[Math.max(0,B(i)+c)]=y:j(o,"Can't replace root node")[i]=y,$&&a(y,o,i,u),l=!0},replaceWithMultiple(y,E={}){const $=!!E.traverse;if(Y(u).splice(Math.max(0,B(i)+c),1,...y),c+=y.length-1,$){let x=0;for(let A=0;A<y.length;A++)x+=a(y[A],o,B(i)+A+x,u)}l=!0},skip(){l=!0}},{type:f}=s,g=t["*"],d=t[f],m=typeof g=="function"?g:g?.enter,w=typeof d=="function"?d:d?.enter;if(m?.(p,r),w?.(p,r),!l)switch(f){case"AbsenceFunction":case"CapturingGroup":case"Group":n(s.body,s);break;case"Alternative":case"CharacterClass":n(s.body,s);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":a(s.min,s,"min"),a(s.max,s,"max");break;case"LookaroundAssertion":n(s.body,s);break;case"Quantifier":a(s.body,s,"body");break;case"Regex":n(s.body,s),a(s.flags,s,"flags");break;default:throw new Error(`Unexpected node type "${f}"`)}return d?.exit?.(p,r),g?.exit?.(p,r),c}return a(e),e}function Y(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function B(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const it=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function ut(e,t){for(let r=0;r<e.length;r++)e[r]>=t&&e[r]++}function ct(e,t,r,n){return e.slice(0,t)+n+e.slice(t+r.length)}const S=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function ke(e,t,r,n){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),s=[!1];let o=0,i="";for(const u of e.matchAll(a)){const{0:c,groups:{$skip:l}}=u;if(!l&&(!n||n===S.DEFAULT==!o)){r instanceof Function?i+=r(u,{context:o?S.CHAR_CLASS:S.DEFAULT,negated:s[s.length-1]}):i+=r;continue}c[0]==="["?(o++,s.push(c[1]==="^")):c==="]"&&o&&(o--,s.pop()),i+=c}return i}function tr(e,t,r,n){ke(e,t,r,n)}function lt(e,t,r=0,n){if(!new RegExp(t,"su").test(e))return null;const a=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=r;let s=0,o;for(;o=a.exec(e);){const{0:i,groups:{$skip:u}}=o;if(!u&&(!n||n===S.DEFAULT==!s))return o;i==="["?s++:i==="]"&&s&&s--,a.lastIndex==o.index&&a.lastIndex++}return null}function ee(e,t,r){return!!lt(e,t,0,r)}function pt(e,t){const r=/\\?./gsu;r.lastIndex=t;let n=e.length,a=0,s=1,o;for(;o=r.exec(e);){const[i]=o;if(i==="[")a++;else if(a)i==="]"&&a--;else if(i==="(")s++;else if(i===")"&&(s--,!s)){n=o.index;break}}return e.slice(t,n)}const Ge=new RegExp(String.raw`(?<noncapturingStart>${it})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function ft(e,t){const r=t?.hiddenCaptures??[];let n=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:n,hiddenCaptures:r};const a="(?>",s="(?:(?=(",o=[0],i=[];let u=0,c=0,l=NaN,p;do{p=!1;let f=0,g=0,d=!1,m;for(Ge.lastIndex=Number.isNaN(l)?0:l+s.length;m=Ge.exec(e);){const{0:w,index:y,groups:{capturingStart:E,noncapturingStart:$}}=m;if(w==="[")f++;else if(f)w==="]"&&f--;else if(w===a&&!d)l=y,d=!0;else if(d&&$)g++;else if(E)d?g++:(u++,o.push(u+c));else if(w===")"&&d){if(!g){c++;const x=u+c;if(e=`${e.slice(0,l)}${s}${e.slice(l+a.length,y)}))<$$${x}>)${e.slice(y+1)}`,p=!0,i.push(x),ut(r,x),n.size){const A=new Map;n.forEach((J,O)=>{A.set(O>=x?O+1:O,J.map(D=>D>=x?D+1:D))}),n=A}break}g--}}}while(p);return r.push(...i),e=ke(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:g,wrappedBackrefNum:d}})=>{if(g){const m=+g;if(m>o.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${o[m]}`}return`\\${d}`},S.DEFAULT),{pattern:e,captureTransfers:n,hiddenCaptures:r}}const nr=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,ie=new RegExp(String.raw`
|
|
34
|
+
\\(?: \d+
|
|
35
|
+
| c[A-Za-z]
|
|
36
|
+
| [gk]<[^>]+>
|
|
37
|
+
| [pPu]\{[^\}]+\}
|
|
38
|
+
| u[A-Fa-f\d]{4}
|
|
39
|
+
| x[A-Fa-f\d]{2}
|
|
40
|
+
)
|
|
41
|
+
| \((?: \? (?: [:=!>]
|
|
42
|
+
| <(?:[=!]|[^>]+>)
|
|
43
|
+
| [A-Za-z\-]+:
|
|
44
|
+
| \(DEFINE\)
|
|
45
|
+
))?
|
|
46
|
+
| (?<qBase>${nr})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
47
|
+
| \\?.
|
|
48
|
+
`.replace(/\s+/g,""),"gsu");function dt(e){if(!new RegExp(`${nr}\\+`).test(e))return{pattern:e};const t=[];let r=null,n=null,a="",s=0,o;for(ie.lastIndex=0;o=ie.exec(e);){const{0:i,index:u,groups:{qBase:c,qMod:l,invalidQ:p}}=o;if(i==="[")s||(n=u),s++;else if(i==="]")s?s--:n=null;else if(!s)if(l==="+"&&a&&!a.startsWith("(")){if(p)throw new Error(`Invalid quantifier "${i}"`);let f=-1;if(/^\{\d+\}$/.test(c))e=ct(e,u+c.length,l,"");else{if(a===")"||a==="]"){const g=a===")"?r:n;if(g===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,g)}(?>${e.slice(g,u)}${c})${e.slice(u+i.length)}`}else e=`${e.slice(0,u-a.length)}(?>${a}${c})${e.slice(u+i.length)}`;f+=4}ie.lastIndex+=f}else i[0]==="("?t.push(u):i===")"&&(r=t.length?t.pop():null);a=i}return{pattern:e}}const I=String.raw,gt=I`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,me=I`\(\?R=(?<rDepth>[^\)]+)\)|${gt}`,ae=I`\(\?<(?![=!])(?<captureName>[^>]+)>`,sr=I`${ae}|(?<unnamed>\()(?!\?)`,P=new RegExp(I`${ae}|${me}|\(\?|\\?.`,"gsu"),ue="Cannot use multiple overlapping recursions";function ht(e,t){const{hiddenCaptures:r,mode:n}={hiddenCaptures:[],mode:"plugin",...t};let a=t?.captureTransfers??new Map;if(!new RegExp(me,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:r};if(n==="plugin"&&ee(e,I`\(\?\(DEFINE\)`,S.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const s=[],o=ee(e,I`\\[1-9]`,S.DEFAULT),i=new Map,u=[];let c=!1,l=0,p=0,f;for(P.lastIndex=0;f=P.exec(e);){const{0:g,groups:{captureName:d,rDepth:m,gRNameOrNum:w,gRDepth:y}}=f;if(g==="[")l++;else if(l)g==="]"&&l--;else if(m){if(Pe(m),c)throw new Error(ue);if(o)throw new Error(`${n==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const E=e.slice(0,f.index),$=e.slice(P.lastIndex);if(ee($,me,S.DEFAULT))throw new Error(ue);const x=+m-1;e=Re(E,$,x,!1,r,s,p),a=Te(a,E,x,s.length,0,p);break}else if(w){Pe(y);let E=!1;for(const X of u)if(X.name===w||X.num===+w){if(E=!0,X.hasRecursedWithin)throw new Error(ue);break}if(!E)throw new Error(I`Recursive \g cannot be used outside the referenced group "${n==="external"?w:I`\g<${w}&R=${y}>`}"`);const $=i.get(w),x=pt(e,$);if(o&&ee(x,I`${ae}|\((?!\?)`,S.DEFAULT))throw new Error(`${n==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const A=e.slice($,f.index),J=x.slice(A.length+g.length),O=s.length,D=+y-1,$e=Re(A,J,D,!0,r,s,p);a=Te(a,A,D,s.length-O,O,p);const hr=e.slice(0,$),mr=e.slice($+x.length);e=`${hr}${$e}${mr}`,P.lastIndex+=$e.length-g.length-A.length-J.length,u.forEach(X=>X.hasRecursedWithin=!0),c=!0}else if(d)p++,i.set(String(p),P.lastIndex),i.set(d,P.lastIndex),u.push({num:p,name:d});else if(g[0]==="("){const E=g==="(";E&&(p++,i.set(String(p),P.lastIndex)),u.push(E?{num:p}:{})}else g===")"&&u.pop()}return r.push(...s),{pattern:e,captureTransfers:a,hiddenCaptures:r}}function Pe(e){const t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function Re(e,t,r,n,a,s,o){const i=new Set;n&&tr(e+t,ae,({groups:{captureName:c}})=>{i.add(c)},S.DEFAULT);const u=[r,n?i:null,a,s,o];return`${e}${Ue(`(?:${e}`,"forward",...u)}(?:)${Ue(`${t})`,"backward",...u)}${t}`}function Ue(e,t,r,n,a,s,o){const u=l=>t==="forward"?l+2:r-l+2-1;let c="";for(let l=0;l<r;l++){const p=u(l);c+=ke(e,I`${sr}|\\k<(?<backref>[^>]+)>`,({0:f,groups:{captureName:g,unnamed:d,backref:m}})=>{if(m&&n&&!n.has(m))return f;const w=`_$${p}`;if(d||g){const y=o+s.length+1;return s.push(y),mt(a,y),d?f:`(?<${g}${w}>`}return I`\k<${m}${w}>`},S.DEFAULT)}return c}function mt(e,t){for(let r=0;r<e.length;r++)e[r]>=t&&e[r]++}function Te(e,t,r,n,a,s){if(e.size&&n){let o=0;tr(t,sr,()=>o++,S.DEFAULT);const i=s-o+a,u=new Map;return e.forEach((c,l)=>{const p=(n-o*r)/r,f=o*r,g=l>i+o?l+n:l,d=[];for(const m of c)if(m<=i)d.push(m);else if(m>i+o+p)d.push(m+n);else if(m<=i+o)for(let w=0;w<=r;w++)d.push(m+o*w);else for(let w=0;w<=r;w++)d.push(m+f+p*w);u.set(g,d)}),u}return e}var C=String.fromCodePoint,h=String.raw,L={flagGroups:(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),unicodeSets:(()=>{try{new RegExp("[[]]","v")}catch{return!1}return!0})()};L.bugFlagVLiteralHyphenIsRange=L.unicodeSets?(()=>{try{new RegExp(h`[\d\-a]`,"v")}catch{return!0}return!1})():!1;L.bugNestedClassIgnoresNegation=L.unicodeSets&&new RegExp("[[^a]]","v").test("a");function te(e,{enable:t,disable:r}){return{dotAll:!r?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!r?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function Q(e,t,r){return e.has(t)||e.set(t,r),e.get(t)}function we(e,t){return Oe[e]>=Oe[t]}function wt(e,t){if(e==null)throw new Error(t??"Value expected");return e}var Oe={ES2025:2025,ES2024:2024,ES2018:2018},yt={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function ar(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!yt[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=L.flagGroups?"ES2025":L.unicodeSets?"ES2024":"ES2018"),t}var bt="[ -\r ]",Ct=new Set([C(304),C(305)]),_=h`[\p{L}\p{M}\p{N}\p{Pc}]`;function or(e){if(Ct.has(e))return[e];const t=new Set,r=e.toLowerCase(),n=r.toUpperCase(),a=Et.get(r),s=kt.get(r),o=xt.get(r);return[...n].length===1&&t.add(n),o&&t.add(o),a&&t.add(a),t.add(r),s&&t.add(s),[...t]}var xe=new Map(`C Other
|
|
49
|
+
Cc Control cntrl
|
|
50
|
+
Cf Format
|
|
51
|
+
Cn Unassigned
|
|
52
|
+
Co Private_Use
|
|
53
|
+
Cs Surrogate
|
|
54
|
+
L Letter
|
|
55
|
+
LC Cased_Letter
|
|
56
|
+
Ll Lowercase_Letter
|
|
57
|
+
Lm Modifier_Letter
|
|
58
|
+
Lo Other_Letter
|
|
59
|
+
Lt Titlecase_Letter
|
|
60
|
+
Lu Uppercase_Letter
|
|
61
|
+
M Mark Combining_Mark
|
|
62
|
+
Mc Spacing_Mark
|
|
63
|
+
Me Enclosing_Mark
|
|
64
|
+
Mn Nonspacing_Mark
|
|
65
|
+
N Number
|
|
66
|
+
Nd Decimal_Number digit
|
|
67
|
+
Nl Letter_Number
|
|
68
|
+
No Other_Number
|
|
69
|
+
P Punctuation punct
|
|
70
|
+
Pc Connector_Punctuation
|
|
71
|
+
Pd Dash_Punctuation
|
|
72
|
+
Pe Close_Punctuation
|
|
73
|
+
Pf Final_Punctuation
|
|
74
|
+
Pi Initial_Punctuation
|
|
75
|
+
Po Other_Punctuation
|
|
76
|
+
Ps Open_Punctuation
|
|
77
|
+
S Symbol
|
|
78
|
+
Sc Currency_Symbol
|
|
79
|
+
Sk Modifier_Symbol
|
|
80
|
+
Sm Math_Symbol
|
|
81
|
+
So Other_Symbol
|
|
82
|
+
Z Separator
|
|
83
|
+
Zl Line_Separator
|
|
84
|
+
Zp Paragraph_Separator
|
|
85
|
+
Zs Space_Separator
|
|
86
|
+
ASCII
|
|
87
|
+
ASCII_Hex_Digit AHex
|
|
88
|
+
Alphabetic Alpha
|
|
89
|
+
Any
|
|
90
|
+
Assigned
|
|
91
|
+
Bidi_Control Bidi_C
|
|
92
|
+
Bidi_Mirrored Bidi_M
|
|
93
|
+
Case_Ignorable CI
|
|
94
|
+
Cased
|
|
95
|
+
Changes_When_Casefolded CWCF
|
|
96
|
+
Changes_When_Casemapped CWCM
|
|
97
|
+
Changes_When_Lowercased CWL
|
|
98
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
99
|
+
Changes_When_Titlecased CWT
|
|
100
|
+
Changes_When_Uppercased CWU
|
|
101
|
+
Dash
|
|
102
|
+
Default_Ignorable_Code_Point DI
|
|
103
|
+
Deprecated Dep
|
|
104
|
+
Diacritic Dia
|
|
105
|
+
Emoji
|
|
106
|
+
Emoji_Component EComp
|
|
107
|
+
Emoji_Modifier EMod
|
|
108
|
+
Emoji_Modifier_Base EBase
|
|
109
|
+
Emoji_Presentation EPres
|
|
110
|
+
Extended_Pictographic ExtPict
|
|
111
|
+
Extender Ext
|
|
112
|
+
Grapheme_Base Gr_Base
|
|
113
|
+
Grapheme_Extend Gr_Ext
|
|
114
|
+
Hex_Digit Hex
|
|
115
|
+
IDS_Binary_Operator IDSB
|
|
116
|
+
IDS_Trinary_Operator IDST
|
|
117
|
+
ID_Continue IDC
|
|
118
|
+
ID_Start IDS
|
|
119
|
+
Ideographic Ideo
|
|
120
|
+
Join_Control Join_C
|
|
121
|
+
Logical_Order_Exception LOE
|
|
122
|
+
Lowercase Lower
|
|
123
|
+
Math
|
|
124
|
+
Noncharacter_Code_Point NChar
|
|
125
|
+
Pattern_Syntax Pat_Syn
|
|
126
|
+
Pattern_White_Space Pat_WS
|
|
127
|
+
Quotation_Mark QMark
|
|
128
|
+
Radical
|
|
129
|
+
Regional_Indicator RI
|
|
130
|
+
Sentence_Terminal STerm
|
|
131
|
+
Soft_Dotted SD
|
|
132
|
+
Terminal_Punctuation Term
|
|
133
|
+
Unified_Ideograph UIdeo
|
|
134
|
+
Uppercase Upper
|
|
135
|
+
Variation_Selector VS
|
|
136
|
+
White_Space space
|
|
137
|
+
XID_Continue XIDC
|
|
138
|
+
XID_Start XIDS`.split(/\s/).map(e=>[se(e),e])),kt=new Map([["s",C(383)],[C(383),"s"]]),xt=new Map([[C(223),C(7838)],[C(107),C(8490)],[C(229),C(8491)],[C(969),C(8486)]]),Et=new Map([F(453),F(456),F(459),F(498),...ce(8072,8079),...ce(8088,8095),...ce(8104,8111),F(8124),F(8140),F(8188)]),$t=new Map([["alnum",h`[\p{Alpha}\p{Nd}]`],["alpha",h`\p{Alpha}`],["ascii",h`\p{ASCII}`],["blank",h`[\p{Zs}\t]`],["cntrl",h`\p{Cc}`],["digit",h`\p{Nd}`],["graph",h`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",h`\p{Lower}`],["print",h`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",h`[\p{P}\p{S}]`],["space",h`\p{space}`],["upper",h`\p{Upper}`],["word",h`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",h`\p{AHex}`]]);function At(e,t){const r=[];for(let n=e;n<=t;n++)r.push(n);return r}function F(e){const t=C(e);return[t.toLowerCase(),t]}function ce(e,t){return At(e,t).map(r=>F(r))}var ir=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function It(e,t){const r={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};ur(e);const n={accuracy:r.accuracy,asciiWordBoundaries:r.asciiWordBoundaries,avoidSubclass:r.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:we(r.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Z(e,St,n);const a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},s={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:n.subroutineRefMap};Z(e,vt,s);const o={groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer};return Z(e,_t,o),e._originMap=s.groupOriginByCopy,e._strategy=n.strategy,e}var St={AbsenceFunction({node:e,parent:t,replaceWith:r}){const{body:n,kind:a}=e;if(a==="repeater"){const s=v();s.body[0].body.push(R({negate:!0,body:n}),H("Any"));const o=v();o.body[0].body.push(Ye("greedy",0,1/0,s)),r(b(o,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:r},{flagDirectivesByAlt:n}){const a=e.body.filter(s=>s.kind==="flags");for(let s=r+1;s<t.body.length;s++){const o=t.body[s];Q(n,o,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){const r=lr(t.get(e));if(r){const n=v({flags:r});n.body[0].body=e.body,e.body=[b(n,e)]}}}},Assertion({node:e,parent:t,key:r,container:n,root:a,remove:s,replaceWith:o},i){const{kind:u,negate:c}=e,{asciiWordBoundaries:l,avoidSubclass:p,supportedGNodes:f,wordIsAscii:g}=i;if(u==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(u==="line_end")o(b(R({body:[T({body:[de("string_end")]}),T({body:[ne(10)]})]}),t));else if(u==="line_start")o(b(M(h`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(u==="search_start")if(f.has(e))a.flags.sticky=!0,s();else{const d=n[r-1];if(d&&Pt(d))o(b(R({negate:!0}),t));else{if(p)throw new Error(h`Uses "\G" in a way that requires a subclass`);o(G(de("string_start"),t)),i.strategy="clip_search"}}else if(!(u==="string_end"||u==="string_start"))if(u==="string_end_newline")o(b(M(h`(?=\n?\z)`),t));else if(u==="word_boundary"){if(!g&&!l){const d=`(?:(?<=${_})(?!${_})|(?<!${_})(?=${_}))`,m=`(?:(?<=${_})(?=${_})|(?<!${_})(?!${_}))`;o(b(M(c?m:d),t))}}else throw new Error(`Unexpected assertion kind "${u}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:r}=e;typeof r=="string"&&!pe(r)&&(r=le(r,t),e.ref=r)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:r}){let{name:n}=e;n&&!pe(n)&&(n=le(n,t),e.name=n),r.set(e.number,e),n&&r.set(n,e)},CharacterClassRange({node:e,parent:t,replaceWith:r}){if(t.kind==="intersection"){const n=re({body:[e]});r(b(n,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:r},{accuracy:n,minTargetEs2024:a,digitIsAscii:s,spaceIsAscii:o,wordIsAscii:i}){const{kind:u,negate:c,value:l}=e;if(s&&(u==="digit"||l==="digit")){r(G(he("digit",{negate:c}),t));return}if(o&&(u==="space"||l==="space")){r(b(fe(M(bt),c),t));return}if(i&&(u==="word"||l==="word")){r(G(he("word",{negate:c}),t));return}if(u==="any")r(G(H("Any"),t));else if(u==="digit")r(G(H("Nd",{negate:c}),t));else if(u!=="dot")if(u==="text_segment"){if(n==="strict")throw new Error(h`Use of "\X" requires non-strict accuracy`);const p="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",f=h`\p{RI}{2}|${p}(?:\u200D${p})*`;r(b(M(h`(?>\r\n|${a?h`\p{RGI_Emoji}`:f}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(u==="hex")r(G(H("AHex",{negate:c}),t));else if(u==="newline")r(b(M(c?`[^
|
|
139
|
+
]`:`(?>\r
|
|
140
|
+
?|[
|
|
141
|
+
\v\f
\u2028\u2029])`),t));else if(u==="posix")if(!a&&(l==="graph"||l==="print")){if(n==="strict")throw new Error(`POSIX class "${l}" requires min target ES2024 or non-strict accuracy`);let p={graph:"!-~",print:" -~"}[l];c&&(p=`\0-${C(p.codePointAt(0)-1)}${C(p.codePointAt(2)+1)}-`),r(b(M(`[${p}]`),t))}else r(b(fe(M($t.get(l)),c),t));else if(u==="property")xe.has(se(l))||(e.key="sc");else if(u==="space")r(G(H("space",{negate:c}),t));else if(u==="word")r(b(fe(M(_),c),t));else throw new Error(`Unexpected character set kind "${u}"`)},Directive({node:e,parent:t,root:r,remove:n,replaceWith:a,removeAllPrevSiblings:s,removeAllNextSiblings:o}){const{kind:i,flags:u}=e;if(i==="flags")if(!u.enable&&!u.disable)n();else{const c=v({flags:u});c.body[0].body=o(),a(b(c,t),{traverse:!0})}else if(i==="keep"){const c=r.body[0],p=r.body.length===1&&qe(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:r;if(t.parent!==p||p.body.length>1)throw new Error(h`Uses "\K" in a way that's unsupported`);const f=R({behind:!0});f.body[0].body=s(),a(b(f,t))}else throw new Error(`Unexpected directive kind "${i}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(r=>delete e[r]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:r}=e.flags;t?.extended&&delete t.extended,r?.extended&&delete r.extended,t?.dotAll&&r?.dotAll&&delete t.dotAll,t?.ignoreCase&&r?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,r&&!Object.keys(r).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:r}=e;r==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:r}){const{kind:n}=e;if(n==="fail")r(b(R({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${n.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=v();t.body[0].body.push(e.body),e.body=b(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const r=[];let n=!1,a=!1;for(const s of e.body)if(s.body.length===1&&s.body[0].kind==="search_start")s.body.pop();else{const o=fr(s.body);o?(n=!0,Array.isArray(o)?r.push(...o):r.push(o)):a=!0}n&&!a&&r.forEach(s=>t.add(s))},exit(e,{accuracy:t,passedLookbehind:r,strategy:n}){if(t==="strict"&&r&&n)throw new Error(h`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:r}=e;typeof r=="string"&&!pe(r)&&(r=le(r,t),e.ref=r)}},vt={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:r}){const{orphan:n,ref:a}=e;n||r.set(e,[...t.get(a).map(({node:s})=>s)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:r,skip:n},{groupOriginByCopy:a,groupsByName:s,multiplexCapturesToLeftByRef:o,openRefs:i,reffedNodesByReferencer:u}){const c=a.get(e);if(c&&i.has(e.number)){const p=G(De(e.number),t);u.set(p,i.get(e.number)),r(p);return}i.set(e.number,e),o.set(e.number,[]),e.name&&Q(o,e.name,[]);const l=o.get(e.name??e.number);for(let p=0;p<l.length;p++){const f=l[p];if(c===f.node||c&&c===f.origin||e===f.origin){l.splice(p,1);break}}if(o.get(e.number).push({node:e,origin:c}),e.name&&o.get(e.name).push({node:e,origin:c}),e.name){const p=Q(s,e.name,new Map);let f=!1;if(c)f=!0;else for(const g of p.values())if(!g.hasDuplicateNameToRemove){f=!0;break}s.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:f})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=te(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:r},n){const{isRecursive:a,ref:s}=e;if(a){let l=t;for(;(l=l.parent)&&!(l.type==="CapturingGroup"&&(l.name===s||l.number===s)););n.reffedNodesByReferencer.set(e,l);return}const o=n.subroutineRefMap.get(s),i=s===0,u=i?De(0):cr(o,n.groupOriginByCopy,null);let c=u;if(!i){const l=lr(Lt(o,f=>f.type==="Group"&&!!f.flags)),p=l?te(n.globalFlags,l):n.globalFlags;Mt(p,n.currentFlags)||(c=v({flags:Ft(p)}),c.body[0].body.push(u))}r(b(c,t),{traverse:!i})}},_t={Backreference({node:e,parent:t,replaceWith:r},n){if(e.orphan){n.highestOrphanBackref=Math.max(n.highestOrphanBackref,e.ref);return}const s=n.reffedNodesByReferencer.get(e).filter(o=>Nt(o,e));if(!s.length)r(b(R({negate:!0}),t));else if(s.length>1){const o=v({atomic:!0,body:s.reverse().map(i=>T({body:[ge(i.number)]}))});r(b(o,t))}else e.ref=s[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const r=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let n=0;n<r;n++){const a=Ke();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function ur(e){Z(e,{"*"({node:t,parent:r}){t.parent=r}})}function Mt(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Nt(e,t){let r=t;do{if(r.type==="Regex")return!1;if(r.type==="Alternative")continue;if(r===e)return!1;const n=pr(r.parent);for(const a of n){if(a===r)break;if(a===e||dr(a,e))return!0}}while(r=r.parent);throw new Error("Unexpected path")}function cr(e,t,r,n){const a=Array.isArray(e)?[]:{};for(const[s,o]of Object.entries(e))s==="parent"?a.parent=Array.isArray(r)?n:r:o&&typeof o=="object"?a[s]=cr(o,t,a,r):(s==="type"&&o==="CapturingGroup"&&t.set(a,t.get(e)??e),a[s]=o);return a}function De(e){const t=er(e);return t.isRecursive=!0,t}function Lt(e,t){const r=[];for(;e=e.parent;)(!t||t(e))&&r.push(e);return r}function le(e,t){if(t.has(e))return t.get(e);const r=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,r),r}function lr(e){const t=["dotAll","ignoreCase"],r={enable:{},disable:{}};return e.forEach(({flags:n})=>{t.forEach(a=>{n.enable?.[a]&&(delete r.disable[a],r.enable[a]=!0),n.disable?.[a]&&(r.disable[a]=!0)})}),Object.keys(r.enable).length||delete r.enable,Object.keys(r.disable).length||delete r.disable,r.enable||r.disable?r:null}function Ft({dotAll:e,ignoreCase:t}){const r={};return(e||t)&&(r.enable={},e&&(r.enable.dotAll=!0),t&&(r.enable.ignoreCase=!0)),(!e||!t)&&(r.disable={},!e&&(r.disable.dotAll=!0),!t&&(r.disable.ignoreCase=!0)),r}function pr(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function fr(e){const t=e.find(r=>r.kind==="search_start"||Rt(r,{negate:!1})||!Gt(r));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const r=[];for(const n of t.body){const a=fr(n.body);if(!a)return null;Array.isArray(a)?r.push(...a):r.push(a)}return r}return null}function dr(e,t){const r=pr(e)??[];for(const n of r)if(n===t||dr(n,t))return!0;return!1}function Gt({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function Pt(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function Rt(e,t){const r={negate:null,...t};return e.type==="LookaroundAssertion"&&(r.negate===null||e.negate===r.negate)&&e.body.length===1&&qe(e.body[0],{type:"Assertion",kind:"search_start"})}function pe(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function M(e,t){const n=Je(e,{...t,unicodePropertyMap:xe}).body;return n.length>1||n[0].body.length>1?v({body:n}):n[0].body[0]}function fe(e,t){return e.negate=t,e}function G(e,t){return e.parent=t,e}function b(e,t){return ur(e),e.parent=t,e}function Ut(e,t){const r=ar(t),n=we(r.target,"ES2024"),a=we(r.target,"ES2025"),s=r.rules.recursionLimit;if(!Number.isInteger(s)||s<2||s>20)throw new Error("Invalid recursionLimit; use 2-20");let o=null,i=null;if(!a){const g=[e.flags.ignoreCase];Z(e,Tt,{getCurrentModI:()=>g.at(-1),popModI(){g.pop()},pushModI(d){g.push(d)},setHasCasedChar(){g.at(-1)?o=!0:i=!0}})}const u={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!i)};let c=e;const l={accuracy:r.accuracy,appliedGlobalFlags:u,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:s,useAppliedIgnoreCase:!!(!a&&o&&i),useFlagMods:a,useFlagV:n,verbose:r.verbose};function p(g){return l.lastNode=c,c=g,wt(Ot[g.type],`Unexpected node type "${g.type}"`)(g,l,p)}const f={pattern:e.body.map(p).join("|"),flags:p(e.flags),options:{...e.options}};return n||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],l.captureMap.forEach((g,d)=>{g.hidden&&f._hiddenCaptures.push(d),g.transferTo&&Q(f._captureTransfers,g.transferTo,[]).push(d)}),f}var Tt={"*":{enter({node:e},t){if(Ve(e)){const r=t.getCurrentModI();t.pushModI(e.flags?te({ignoreCase:r},e.flags).ignoreCase:r)}},exit({node:e},t){Ve(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Ee(C(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},r){t(),gr(e,{firstOnly:!0}).length&&r.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&ir.has(e.value)&&t.setHasCasedChar()}},Ot={Alternative({body:e},t,r){return e.map(r).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?h`\B`:h`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,r){const{body:n,name:a,number:s}=e,o={ignoreCase:t.currentFlags.ignoreCase},i=t.originMap.get(e);return i&&(o.hidden=!0,s>i.number&&(o.transferTo=i.number)),t.captureMap.set(s,o),`(${a?`?<${a}>`:""}${n.map(r).join("|")})`},Character({value:e},t){const r=C(e),n=V(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(n!==r)return n;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Ee(r)){const a=or(r);return t.inCharClass?a.join(""):a.length>1?`[${a.join("")}]`:a[0]}return r},CharacterClass(e,t,r){const{kind:n,negate:a,parent:s}=e;let{body:o}=e;if(n==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");L.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(ze)&&(o=[ne(45),...o.filter(c=>!ze(c))]);const i=()=>`[${a?"^":""}${o.map(r).join(n==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||L.bugNestedClassIgnoresNegation)&&!a){const l=o.filter(p=>p.type==="CharacterClass"&&p.kind==="union"&&p.negate);if(l.length){const p=v(),f=p.body[0];return p.parent=s,f.parent=p,o=o.filter(g=>!l.includes(g)),e.body=o,o.length?(e.parent=f,f.body.push(e)):p.body.pop(),l.forEach(g=>{const d=T({body:[g]});g.parent=d,d.parent=p,p.body.push(d)}),r(p)}}t.inCharClass=!0;const c=i();return t.inCharClass=!1,c}const u=o[0];if(n==="union"&&!a&&u&&((!t.useFlagV||!t.verbose)&&s.kind==="union"&&!(L.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&s.kind==="intersection"&&o.length===1&&u.type!=="CharacterClassRange"))return o.map(r).join("");if(!t.useFlagV&&s.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return i()},CharacterClassRange(e,t){const r=e.min.value,n=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},s=V(r,a),o=V(n,a),i=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const u=gr(e);Ht(u).forEach(l=>{i.add(Array.isArray(l)?`${V(l[0],a)}-${V(l[1],a)}`:V(l,a))})}return`${s}-${o}${[...i].join("")}`},CharacterSet({kind:e,negate:t,value:r,key:n},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":h`[^\n]`;if(e==="digit")return t?h`\D`:h`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&ir.has(r))throw new Error(`Unicode property "${r}" can't be case-insensitive when other chars have specific case`);return`${t?h`\P`:h`\p`}{${n?`${n}=`:""}${r}}`}if(e==="word")return t?h`\W`:h`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:r,parent:n},a,s){const o=a.currentFlags;r&&(a.currentFlags=te(o,r));const i=t.map(s).join("|"),u=!a.verbose&&t.length===1&&n.type!=="Quantifier"&&!e&&(!a.useFlagMods||!r)?i:`(?${Wt(e,r,a.useFlagMods)}${i})`;return a.currentFlags=o,u},LookaroundAssertion({body:e,kind:t,negate:r},n,a){return`(?${`${t==="lookahead"?"":"<"}${r?"!":"="}`}${e.map(a).join("|")})`},Quantifier(e,t,r){return r(e.body)+jt(e)},Subroutine({isRecursive:e,ref:t},r){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const n=r.recursionLimit;return t===0?`(?R=${n})`:h`\g<${t}&R=${n}>`}},Dt=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Bt=new Set(["-","\\","]","^","["]),Vt=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Be=new Map([[9,h`\t`],[10,h`\n`],[11,h`\v`],[12,h`\f`],[13,h`\r`],[8232,h`\u2028`],[8233,h`\u2029`],[65279,h`\uFEFF`]]),zt=new RegExp("^\\p{Cased}$","u");function Ee(e){return zt.test(e)}function gr(e,t){const r=!!t?.firstOnly,n=e.min.value,a=e.max.value,s=[];if(n<65&&(a===65535||a>=131071)||n===65536&&a>=131071)return s;for(let o=n;o<=a;o++){const i=C(o);if(!Ee(i))continue;const u=or(i).filter(c=>{const l=c.codePointAt(0);return l<n||l>a});if(u.length&&(s.push(...u),r))break}return s}function V(e,{escDigit:t,inCharClass:r,useFlagV:n}){if(Be.has(e))return Be.get(e);if(e<32||e>126&&e<160||e>262143||t&&Xt(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=r?n?Vt:Bt:Dt,s=C(e);return(a.has(s)?"\\":"")+s}function Ht(e){const t=e.map(a=>a.codePointAt(0)).sort((a,s)=>a-s),r=[];let n=null;for(let a=0;a<t.length;a++)t[a+1]===t[a]+1?n??=t[a]:n===null?r.push(t[a]):(r.push([n,t[a]]),n=null);return r}function Wt(e,t,r){if(e)return">";let n="";if(t&&r){const{enable:a,disable:s}=t;n=(a?.ignoreCase?"i":"")+(a?.dotAll?"s":"")+(s?"-":"")+(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")}return`${n}:`}function jt({kind:e,max:t,min:r}){let n;return!r&&t===1?n="?":!r&&t===1/0?n="*":r===1&&t===1/0?n="+":r===t?n=`{${r}}`:n=`{${r},${t===1/0?"":t}}`,n+{greedy:"",lazy:"?",possessive:"+"}[e]}function Ve({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function Xt(e){return e>47&&e<58}function ze({type:e,value:t}){return e==="Character"&&t===45}var Zt=class ye extends RegExp{#r=new Map;#e=null;#n;#t=null;#s=null;rawOptions={};get source(){return this.#n||"(?:)"}constructor(t,r,n){const a=!!n?.lazyCompile;if(t instanceof RegExp){if(n)throw new Error("Cannot provide options when copying a regexp");const s=t;super(s,r),this.#n=s.source,s instanceof ye&&(this.#r=s.#r,this.#t=s.#t,this.#s=s.#s,this.rawOptions=s.rawOptions)}else{const s={hiddenCaptures:[],strategy:null,transfers:[],...n};super(a?"":t,r),this.#n=t,this.#r=qt(s.hiddenCaptures,s.transfers),this.#s=s.strategy,this.rawOptions=n??{}}a||(this.#e=this)}exec(t){if(!this.#e){const{lazyCompile:a,...s}=this.rawOptions;this.#e=new ye(this.#n,this.flags,s)}const r=this.global||this.sticky,n=this.lastIndex;if(this.#s==="clip_search"&&r&&n){this.lastIndex=0;const a=this.#a(t.slice(n));return a&&(Qt(a,n,t,this.hasIndices),this.lastIndex+=n),a}return this.#a(t)}#a(t){this.#e.lastIndex=this.lastIndex;const r=super.exec.call(this.#e,t);if(this.lastIndex=this.#e.lastIndex,!r||!this.#r.size)return r;const n=[...r];r.length=1;let a;this.hasIndices&&(a=[...r.indices],r.indices.length=1);const s=[0];for(let o=1;o<n.length;o++){const{hidden:i,transferTo:u}=this.#r.get(o)??{};if(i?s.push(null):(s.push(r.length),r.push(n[o]),this.hasIndices&&r.indices.push(a[o])),u&&n[o]!==void 0){const c=s[u];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(r[c]=n[o],this.hasIndices&&(r.indices[c]=a[o]),r.groups){this.#t||(this.#t=Jt(this.source));const l=this.#t.get(u);l&&(r.groups[l]=n[o],this.hasIndices&&(r.indices.groups[l]=a[o]))}}}return r}};function Qt(e,t,r,n){if(e.index+=t,e.input=r,n){const a=e.indices;for(let o=0;o<a.length;o++){const i=a[o];i&&(a[o]=[i[0]+t,i[1]+t])}const s=a.groups;s&&Object.keys(s).forEach(o=>{const i=s[o];i&&(s[o]=[i[0]+t,i[1]+t])})}}function qt(e,t){const r=new Map;for(const n of e)r.set(n,{hidden:!0});for(const[n,a]of t)for(const s of a)Q(r,s,{}).transferTo=n;return r}function Jt(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,r=new Map;let n=0,a=0,s;for(;s=t.exec(e);){const{0:o,groups:{capture:i,name:u}}=s;o==="["?n++:n?o==="]"&&n--:i&&(a++,u&&r.set(a,u))}return r}function Kt(e,t){const r=Yt(e,t);return r.options?new Zt(r.pattern,r.flags,r.options):new RegExp(r.pattern,r.flags)}function Yt(e,t){const r=ar(t),n=Je(e,{flags:r.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:r.rules.captureGroup,singleline:r.rules.singleline},skipBackrefValidation:r.rules.allowOrphanBackrefs,unicodePropertyMap:xe}),a=It(n,{accuracy:r.accuracy,asciiWordBoundaries:r.rules.asciiWordBoundaries,avoidSubclass:r.avoidSubclass,bestEffortTarget:r.target}),s=Ut(a,r),o=ht(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),i=dt(o.pattern),u=ft(i.pattern,{captureTransfers:o.captureTransfers,hiddenCaptures:o.hiddenCaptures}),c={pattern:u.pattern,flags:`${r.hasIndices?"d":""}${r.global?"g":""}${s.flags}${s.options.disable.v?"u":"v"}`};if(r.avoidSubclass){if(r.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const l=u.hiddenCaptures.sort((d,m)=>d-m),p=Array.from(u.captureTransfers),f=a._strategy,g=c.pattern.length>=r.lazyCompileLength;(l.length||p.length||f||g)&&(c.options={...l.length&&{hiddenCaptures:l},...p.length&&{transfers:p},...f&&{strategy:f},...g&&{lazyCompile:g}})}return c}const He=4294967295;class en{constructor(t,r={}){this.patterns=t,this.options=r;const{forgiving:n=!1,cache:a,regexConstructor:s}=r;if(!s)throw new Error("Option `regexConstructor` is not provided");this.regexps=t.map(o=>{if(typeof o!="string")return o;const i=a?.get(o);if(i){if(i instanceof RegExp)return i;if(n)return null;throw i}try{const u=s(o);return a?.set(o,u),u}catch(u){if(a?.set(o,u),n)return null;throw u}})}regexps;findNextMatchSync(t,r,n){const a=typeof t=="string"?t:t.content,s=[];function o(i,u,c=0){return{index:i,captureIndices:u.indices.map(l=>l==null?{start:He,end:He,length:0}:{start:l[0]+c,end:l[1]+c,length:l[1]-l[0]})}}for(let i=0;i<this.regexps.length;i++){const u=this.regexps[i];if(u)try{u.lastIndex=r;const c=u.exec(a);if(!c)continue;if(c.index===r)return o(i,c,0);s.push([i,c,0])}catch(c){if(this.options.forgiving)continue;throw c}}if(s.length){const i=Math.min(...s.map(u=>u[1].index));for(const[u,c,l]of s)if(c.index===i)return o(u,c,l)}return null}}function rn(e,t){return Kt(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function nn(e={}){const t=Object.assign({target:"auto",cache:new Map},e);return t.regexConstructor||=r=>rn(r,{target:t.target}),{createScanner(r){return new en(r,t)},createString(r){return{content:r}}}}export{on as ShikiError,un as addClassToHast,cn as applyColorReplacements,ln as bundledLanguages,pn as bundledLanguagesAlias,fn as bundledLanguagesBase,dn as bundledLanguagesInfo,gn as bundledThemes,hn as bundledThemesInfo,mn as codeToHast,wn as codeToHtml,yn as codeToTokens,bn as codeToTokensBase,Cn as codeToTokensWithThemes,kn as createBundledHighlighter,xn as createCssVariablesTheme,En as createHighlighter,$n as createHighlighterCore,An as createHighlighterCoreSync,nn as createJavaScriptRegexEngine,In as createOnigurumaEngine,Sn as createPositionConverter,vn as createShikiInternal,_n as createShikiInternalSync,Mn as createSingletonShorthands,Nn as createdBundledHighlighter,rn as defaultJavaScriptRegexConstructor,Ln as enableDeprecationWarnings,Fn as flatTokenVariants,Gn as getLastGrammarState,Pn as getSingletonHighlighter,Rn as getSingletonHighlighterCore,Un as getTokenStyleObject,Tn as guessEmbeddedLanguages,On as hastToHtml,Dn as isNoneTheme,Bn as isPlainLang,Vn as isSpecialLang,zn as isSpecialTheme,Hn as loadWasm,Wn as makeSingletonHighlighter,jn as makeSingletonHighlighterCore,Xn as normalizeGetter,Zn as normalizeTheme,Qn as resolveColorReplacements,qn as splitLines,Jn as splitToken,Kn as splitTokens,Yn as stringifyTokenStyle,es as toArray,rs as tokenizeAnsiWithTheme,ts as tokenizeWithTheme,ns as tokensToHast,ss as transformerDecorations,as as warnDeprecated};
|