@a9n-shoji/rvw 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +41 -7
- package/dist/cli.mjs +989 -45
- package/dist/cli.mjs.map +4 -4
- package/dist/web/assets/{CommentThread-CMXtuZ98.js → CommentThread-dsad9VaW.js} +4 -4
- package/dist/web/assets/DocumentViewer-CPq2FCqU.js +1414 -0
- package/dist/web/assets/{MermaidSurface-Dt2_Hu6n.js → FileIcon-AhP8Ezk9.js} +94 -95
- package/dist/web/assets/{MarkdownTable-7Sm_sj1E.js → MarkdownTable-Clfr8wUw.js} +1 -1
- package/dist/web/assets/MermaidExpandedView-BjmXfluL.js +4 -0
- package/dist/web/assets/MermaidSurface-B2Z3pJme.js +2 -0
- package/dist/web/assets/StructureViewer-CyDDQwHl.js +1 -0
- package/dist/web/assets/{WalkthroughViewer-CuJMrKOW.js → WalkthroughViewer-c3XUP0RH.js} +4 -4
- package/dist/web/assets/index-CWOtOTHG.js +11 -0
- package/dist/web/assets/index-D_e3Zku8.css +1 -0
- package/dist/web/index.html +5 -4
- package/migrations/014_structures.sql +13 -0
- package/migrations/015_structure_concurrency.sql +6 -0
- package/migrations/016_structure_retired_ids.sql +13 -0
- package/package.json +1 -1
- package/skills/rvw-structure/SKILL.md +152 -0
- package/skills/rvw-structure/agents/openai.yaml +4 -0
- package/skills/rvw-structure/references/structure-authoring.md +144 -0
- package/skills/rvw-walkthrough/SKILL.md +5 -0
- package/dist/web/assets/DocumentViewer-D-UGIxCU.js +0 -1417
- package/dist/web/assets/MermaidExpandedView-CyWRss2q.js +0 -4
- package/dist/web/assets/index-BNcvGFlf.css +0 -1
- package/dist/web/assets/index-BwIKbLJ1.js +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./MermaidSurface-B2Z3pJme.js";import{c as n,s as r}from"./FileIcon-AhP8Ezk9.js";var i=e(n(),1),a=t(),o=r(),s=new Set([`blockquote`,`details`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`li`,`ol`,`p`,`pre`,`table`,`ul`]);function c(e,t){e.properties??={};let n=e.properties.className,r=Array.isArray(n)?n.map(String):typeof n==`string`?n.split(/\s+/u).filter(Boolean):[];r.includes(t)||r.push(t),e.properties.className=r}function l(e){return{dataRvwSourceStartLine:e.start.line,dataRvwSourceEndLine:e.end.line}}function u(e,t){let n=e.value??``,r=e.position??t;if(!r)return[e];let i=n.split(`
|
|
2
2
|
`);if(i.length===1)return[{type:`element`,tagName:`span`,properties:{...l(r),dataRvwSourceLeaf:`true`},children:[{type:`text`,value:n}],position:r}];let a=[];for(let[e,t]of i.entries()){if(e===i.length-1&&t===``&&n.endsWith(`
|
|
3
3
|
`))continue;let o=Math.min(r.start.line+e,r.end.line);t&&a.push({type:`element`,tagName:`span`,properties:{dataRvwSourceStartLine:o,dataRvwSourceEndLine:o,dataRvwSourceLeaf:`true`},children:[{type:`text`,value:t}],position:{start:{line:o},end:{line:o}}}),e<i.length-1&&a.push({type:`text`,value:`
|
|
4
4
|
`})}return a}function d(e,t,n){if(!e||t===void 0)return;let r=Math.max(1,n.split(`
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-DCGa16l5.js","assets/rolldown-runtime-hePW80VL.js","assets/preload-helper-Czpn1I53.js","assets/lib-p2IERBh0.js","assets/ccount-DFmD81E1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,r as n,t as r}from"./MermaidSurface-B2Z3pJme.js";import{a as i,c as a,i as o,s,t as c}from"./FileIcon-AhP8Ezk9.js";import{t as l}from"./preload-helper-Czpn1I53.js";var u=e(a(),1),d=t(),f=s(),p=[.5,.75,1,1.25,1.5,2,3],m=4,h=380,g=300,_=640,v=360,y=6;function b(e,t,n){return Math.min(n,Math.max(t,e))}function x(e){return Math.max(g,Math.min(_,e-v-y))}function ee(e){return Array.from(e.querySelectorAll(`button:not([disabled]), a[href], input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hidden&&e.getClientRects().length>0)}function te(e){let t=e.querySelector(`svg`);if(!t)return null;let n=t.viewBox.baseVal;if(n.width>0&&n.height>0)return{width:n.width,height:n.height};let r=t.width.baseVal.value,i=t.height.baseVal.value;return r>0&&i>0?{width:r,height:i}:null}function S(e,t){if(e?.availability!==`available`||e.text===null)return null;let n=e.text.split(`
|
|
3
|
+
`),r=t.startLine??1,i=t.startLine===null?Math.min(n.length,32):t.endLine??t.startLine,a=Math.max(1,r-m),o=Math.min(n.length,i+m);return{start:a,end:o,referencedStart:r,referencedEnd:i,lines:n.slice(a-1,o)}}function ne(){return(0,f.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,children:(0,f.jsx)(`path`,{d:`M3 8h10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`})})}function re(){return(0,f.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,children:(0,f.jsx)(`path`,{d:`M3 8h10M8 3v10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`})})}function ie(){return(0,f.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,children:(0,f.jsx)(`path`,{d:`M2.25 3.5A1.25 1.25 0 0 1 3.5 2.25h9A1.25 1.25 0 0 1 13.75 3.5v6A1.25 1.25 0 0 1 12.5 10.75H7l-3.25 2.5v-2.5H3.5A1.25 1.25 0 0 1 2.25 9.5v-6Z`,fill:`none`,stroke:`currentColor`,strokeLinejoin:`round`,strokeWidth:`1.25`})})}function ae(){return(0,f.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,children:(0,f.jsx)(`path`,{d:`m3.5 3.5 9 9m0-9-9 9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`})})}function oe({peek:e,document:t,loading:n,error:r,onBack:i,onOpenInReview:a}){let o=(0,u.useRef)(null),s=(0,u.useMemo)(()=>S(t,e.reference),[t,e.reference]),l=e.reference.startLine===null?null:e.reference.endLine??e.reference.startLine,d=e.reference.startLine===null?`File`:e.reference.startLine===l?`L${e.reference.startLine}`:`L${e.reference.startLine}–L${l}`;return(0,u.useEffect)(()=>{o.current?.focus()},[]),(0,f.jsxs)(`div`,{className:`mermaid-reference-peek`,children:[(0,f.jsxs)(`header`,{children:[(0,f.jsx)(`button`,{ref:o,className:`button--back`,onClick:i,children:`← Comments`}),(0,f.jsxs)(`div`,{className:`mermaid-reference-location`,children:[(0,f.jsx)(c,{path:e.reference.path,kind:`file`}),(0,f.jsxs)(`span`,{children:[(0,f.jsx)(`strong`,{title:e.reference.path,children:e.reference.path}),(0,f.jsx)(`small`,{children:d})]})]})]}),(0,f.jsx)(`div`,{className:`mermaid-reference-source`,children:n?(0,f.jsx)(`p`,{role:`status`,children:`参照先を読み込んでいます…`}):r?(0,f.jsx)(`p`,{className:`form-error`,role:`alert`,children:r.message}):t?.availability===`available`?s?(0,f.jsx)(w,{excerpt:s,path:e.reference.path,lineLabel:d}):null:(0,f.jsx)(`p`,{role:`status`,children:`この参照先はテキストとして表示できません。`})}),(0,f.jsx)(`footer`,{children:(0,f.jsx)(`button`,{title:`Cmd/Ctrl+clickで右ペインに開く`,onClick:e=>a(e.metaKey||e.ctrlKey),children:`Open in review`})})]})}function C({excerpt:e,label:t}){return(0,f.jsx)(`pre`,{"aria-label":t,"data-syntax-highlighted":`false`,children:e.lines.map((t,n)=>{let r=e.start+n,i=r>=e.referencedStart&&r<=e.referencedEnd;return(0,f.jsxs)(`span`,{className:i?`is-referenced`:void 0,"data-line":r,children:[(0,f.jsx)(`span`,{"aria-hidden":`true`,children:r}),(0,f.jsx)(`code`,{children:t||` `})]},r)})})}function w({excerpt:e,path:t,lineLabel:n}){let[r,i]=(0,u.useState)(null),a=`${t} ${n} のソース抜粋`;return(0,u.useEffect)(()=>{let n=!0;return i(null),(async()=>{let{getFiletypeFromFileName:r,getSharedHighlighter:a}=await l(async()=>{let{getFiletypeFromFileName:e,getSharedHighlighter:t}=await import(`./dist-DCGa16l5.js`).then(e=>e.t);return{getFiletypeFromFileName:e,getSharedHighlighter:t}},__vite__mapDeps([0,1,2,3,4])),o=r(t),s=(await a({langs:[o],themes:[`github-light`,`github-dark`]})).codeToHtml(e.lines.join(`
|
|
4
|
+
`),{lang:o,themes:{light:`github-light`,dark:`github-dark`},transformers:[{line(t,n){let r=e.start+n-1;this.addClassToHast(t,`mermaid-reference-code-line`),r>=e.referencedStart&&r<=e.referencedEnd&&this.addClassToHast(t,`is-referenced`),t.properties[`data-line`]=r}}]});n&&i(s)})().catch(e=>{console.error(`Reference peekのsyntax highlightingに失敗しました。`,e)}),()=>{n=!1}},[e,t]),r===null?(0,f.jsx)(C,{excerpt:e,label:a}):(0,f.jsx)(`div`,{className:`mermaid-reference-highlight`,"aria-label":a,"data-syntax-highlighted":`true`,dangerouslySetInnerHTML:{__html:r}})}function T({source:e,themePreference:t,renderIdPrefix:a,review:s,onClose:c}){let l=(0,u.useId)(),m=(0,u.useRef)(null),v=(0,u.useRef)(null),y=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)(null),E=(0,u.useRef)(c),D=(0,u.useRef)(null),O=(0,u.useRef)(s?.diagramReferenceBindings);E.current=c,O.current=s?.diagramReferenceBindings;let[k,A]=(0,u.useState)(!1),[j,M]=(0,u.useState)(h),[N,P]=(0,u.useState)(!1),[F,I]=(0,u.useState)(null),[L,R]=(0,u.useState)(`fit`),[z,se]=(0,u.useState)(null),[B,ce]=(0,u.useState)({width:0,height:0}),[V,le]=(0,u.useState)(0);D.current=F,(0,u.useEffect)(()=>{let e=m.current;T.current=document.activeElement instanceof HTMLElement?document.activeElement:null;let t=document.body.style.overflow,n=Array.from(document.body.children).filter(t=>t instanceof HTMLElement&&t!==e),r=n.map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));for(let e of n)e.inert=!0,e.setAttribute(`aria-hidden`,`true`);document.body.style.overflow=`hidden`;let i=window.requestAnimationFrame(()=>y.current?.focus());return()=>{window.cancelAnimationFrame(i),document.body.style.overflow=t;for(let e of r)e.element.inert=e.inert,e.ariaHidden===null?e.element.removeAttribute(`aria-hidden`):e.element.setAttribute(`aria-hidden`,e.ariaHidden);T.current?.isConnected&&T.current.focus()}},[]),(0,u.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>ce({width:e.clientWidth,height:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,u.useEffect)(()=>{let e=w.current;if(!e)return;let t=()=>le(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let H=V>0?x(V):_;(0,u.useEffect)(()=>{M(e=>b(e,g,H))},[H]);let U=z?Math.min(1,Math.max(.05,(B.width-48)/z.width),Math.max(.05,(B.height-48)/z.height)):1,W=L===`fit`?U:L,G=p.filter(e=>e<W-.001).at(-1),K=p.find(e=>e>W+.001),q=L!==`fit`&&G===void 0&&U<W-.001,J=z?z.width*W:void 0,Y=z?z.height*W:void 0,ue=(0,u.useCallback)(e=>{se(te(e)),O.current?.onRendered(e)},[]),X=(0,u.useCallback)(e=>{let t=w.current;if(!t)return;let n=t.getBoundingClientRect(),r=x(n.width);M(b(n.right-e,g,r))},[]),Z=n({queryKey:[`mermaid-reference-peek`,s?.pullRequestId,F?.sourceOid,F?.reference.id,F?.reference.path,F?.reference.startLine,F?.reference.endLine,!!F?.resolveForPeek],queryFn:async()=>{if(!F||!s)throw Error(`参照先がありません。`);if(F.resolveForPeek)return await F.resolveForPeek(F.reference);let e={kind:`repository-file`,pullRequestId:s.pullRequestId,sourceOid:F.sourceOid,path:F.reference.path},{document:t}=await o(i(e));return{sourceOid:F.sourceOid,reference:F.reference,document:t}},enabled:F!==null&&!!s,staleTime:F?.resolveForPeek?0:1/0}),Q=F&&Z.data?{...F,sourceOid:Z.data.sourceOid,reference:Z.data.reference}:F,de=(0,u.useCallback)((e,t)=>(A(!0),I({sourceOid:e,reference:t}),Promise.resolve(null)),[]),fe=(0,u.useCallback)(e=>{let t=O.current,n=t?.referenceFromTarget(e);return!t||!n?!1:(A(!0),I({sourceOid:t.sourceOid,reference:n,...t.resolveForPeek?{resolveForPeek:t.resolveForPeek}:{},onOpenInReview:t.onOpenInReview}),!0)},[]),$=(0,u.useCallback)(()=>{I(null),window.requestAnimationFrame(()=>S.current?.focus())},[]);return(0,u.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.isComposing||e.defaultPrevented||v.current?.contains(e.target)||(e.preventDefault(),e.stopPropagation(),D.current?$():E.current())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[$]),(0,d.createPortal)((0,f.jsx)(`div`,{className:`mermaid-expanded-backdrop`,ref:m,children:(0,f.jsxs)(`section`,{className:`mermaid-expanded-view${k&&s?` has-rail`:``}`,ref:v,role:`dialog`,"aria-modal":`true`,"aria-labelledby":l,tabIndex:-1,onKeyDown:e=>{if(e.key===`Tab`){let t=v.current;if(!t)return;let n=ee(t);if(n.length===0){e.preventDefault(),t.focus();return}let r=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus());return}if(!(e.key!==`Escape`||e.nativeEvent.isComposing||e.defaultPrevented)){if(e.preventDefault(),e.stopPropagation(),D.current){$();return}E.current()}},children:[(0,f.jsxs)(`header`,{className:`mermaid-expanded-toolbar`,children:[(0,f.jsx)(`strong`,{id:l,children:`Mermaid diagram`}),(0,f.jsxs)(`div`,{className:`mermaid-expanded-actions`,children:[(0,f.jsxs)(`div`,{className:`mermaid-zoom-controls`,"aria-label":`Diagram zoom`,children:[(0,f.jsx)(`button`,{"aria-label":`Zoom out`,title:`Zoom out`,disabled:G===void 0&&!q,onClick:()=>G===void 0?q?R(`fit`):void 0:R(G),children:(0,f.jsx)(ne,{})}),(0,f.jsx)(`button`,{className:L===`fit`?`active`:``,"aria-pressed":L===`fit`,title:`Fit diagram`,onClick:()=>R(`fit`),children:`Fit`}),(0,f.jsx)(`button`,{"aria-label":`Zoom in`,title:`Zoom in`,disabled:K===void 0,onClick:()=>K!==void 0&&R(K),children:(0,f.jsx)(re,{})})]}),s&&(0,f.jsxs)(`button`,{ref:S,className:`mermaid-comments-toggle`,"aria-pressed":k,title:k?`Commentsを閉じる`:`Commentsを開く`,onClick:()=>{A(e=>!e),I(null)},children:[(0,f.jsx)(ie,{}),`Comments`,s.commentCount>0&&(0,f.jsx)(`span`,{children:s.commentCount})]}),(0,f.jsx)(`button`,{ref:y,className:`mermaid-expanded-close`,"aria-label":`Expanded Mermaid viewを閉じる`,title:`Close (Escape)`,onClick:c,children:(0,f.jsx)(ae,{})})]})]}),(0,f.jsxs)(`div`,{className:`mermaid-expanded-workspace${N?` is-resizing`:``}`,ref:w,style:{"--mermaid-review-rail-width":`${j}px`},children:[(0,f.jsx)(`div`,{className:`mermaid-expanded-canvas`,ref:C,role:`region`,"aria-label":`Mermaid diagram canvas`,tabIndex:0,"data-zoom-mode":L===`fit`?`fit`:`manual`,"data-zoom":W.toFixed(3),children:(0,f.jsx)(`div`,{className:`mermaid-expanded-stage`,children:(0,f.jsx)(r,{className:`mermaid-expanded-diagram`,role:s?.diagramReferenceBindings?`group`:`img`,"aria-label":`Expanded Mermaid diagram`,source:e,themePreference:t,renderIdPrefix:`${a}Expanded`,errorClassName:`mermaid-expanded-error`,onRendered:ue,onPointerDown:e=>{e.button!==0||!fe(e.target)||(e.preventDefault(),e.stopPropagation())},onKeyDown:e=>{e.key!==`Enter`&&e.key!==` `||!fe(e.target)||(e.preventDefault(),e.stopPropagation())},style:{...J===void 0?{}:{width:J},...Y===void 0?{}:{height:Y}}})})}),k&&s&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`horizontal-resize-handle mermaid-rail-resize-handle${N?` active`:``}`,role:`separator`,"aria-label":`Comments railの幅を変更`,"aria-orientation":`vertical`,"aria-valuemin":g,"aria-valuemax":Math.round(H),"aria-valuenow":Math.round(j),tabIndex:0,onPointerDown:e=>{e.button===0&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),P(!0),X(e.clientX))},onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&X(e.clientX)},onPointerUp:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),P(!1)},onPointerCancel:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),P(!1)},onLostPointerCapture:()=>P(!1),onDoubleClick:()=>M(b(h,g,H)),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),M(t=>b(t+(e.key===`ArrowLeft`?16:-16),g,H)))}}),(0,f.jsx)(`aside`,{className:`mermaid-review-rail`,"aria-label":`Diagram review`,children:F&&Q?(0,f.jsx)(oe,{peek:Q,document:Z.data?.document,loading:Z.isLoading,error:Z.error,onBack:$,onOpenInReview:e=>{let t=F;c(),t.onOpenInReview?t.onOpenInReview(t.reference,e):s.onOpenCodeReference(t.sourceOid,t.reference,e)}}):(0,f.jsxs)(`div`,{className:`mermaid-comments-mode`,children:[(0,f.jsxs)(`header`,{children:[(0,f.jsx)(`strong`,{children:`Comments`}),(0,f.jsx)(`span`,{children:s.commentCount})]}),(0,f.jsx)(`div`,{className:`mermaid-comments-scroll`,children:s.renderComments(de)})]})})]})]})]})}),document.body)}export{T as MermaidExpandedView};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BVyLgPb6.js","assets/preload-helper-Czpn1I53.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-B6xuSHsQ.js","assets/rolldown-runtime-hePW80VL.js","assets/chunk-I66GZJ75-CEntV2nF.js","assets/chunk-NSK5VX7P-AmYQxFLu.js","assets/dist-v5Q1xZ2K.js","assets/chunk-3NCLNEKW-k0AW8Qyp.js","assets/chunk-4I5QYGJK-q_8xEFmv.js","assets/chunk-WRU74C26-CS8zeNym.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-UBXNYLIW-D4XAD8w6.js","assets/chunk-W5SLKNZC-B8QG_JAG.js","assets/chunk-QR6OTTB3-VIu9ZqqS.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-7Z6QIM7H-B8QX_5g4.js","assets/line-Dah7RomF.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/chunk-J7OUQ5F2-XLdTvjUm.js","assets/chunk-ZIRB5QZD-O39ZBUk3.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{c as n,s as r}from"./FileIcon-AhP8Ezk9.js";import{t as i}from"./preload-helper-Czpn1I53.js";var a=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},o=new class extends a{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},s={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},c=new class{#e=s;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function l(e){setTimeout(e,0)}var u=typeof window>`u`||`Deno`in globalThis;function d(){}function f(e,t){return typeof e==`function`?e(t):e}function p(e){return typeof e==`number`&&e>=0&&e!==1/0}function m(e,t){return Math.max(e+(t||0)-Date.now(),0)}function h(e,t){return typeof e==`function`?e(t):e}function g(e,t){return typeof e==`function`?e(t):e}function _(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==y(o,t.options))return!1}else if(!x(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function v(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(b(t.options.mutationKey)!==b(a))return!1}else if(!x(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function y(e,t){return(t?.queryKeyHashFn||b)(e)}function b(e){return JSON.stringify(e,(e,t)=>T(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function x(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!x(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!x(e[r],t[r]))return!1;return!0}return!1}var S=Object.prototype.hasOwnProperty;function C(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ee(e)&&ee(t);if(!r&&!(T(e)&&T(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:S.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=C(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function w(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ee(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function T(e){if(!E(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!E(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function E(e){return Object.prototype.toString.call(e)===`[object Object]`}function te(e){return new Promise(t=>{c.setTimeout(t,e)})}function D(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:C(e,t)}function ne(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function re(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var O=Symbol();function k(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===O?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function A(e,t){return typeof e==`function`?e(...t):!!e}function ie(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var j=(()=>{let e=()=>u;return{isServer(){return e()},setIsServer(t){e=t}}})();function M(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var ae=l;function oe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ae,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var N=oe(),P=new class extends a{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function se(e){return Math.min(1e3*2**e,3e4)}function F(e){return(e??`online`)!==`online`||P.isOnline()}var I=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function L(e){let t=!1,n=0,r,i=M(),a=()=>i.status!==`pending`,s=t=>{if(!a()){let n=new I(t);p(n),e.onCancel?.(n)}},c=()=>{t=!0},l=()=>{t=!1},u=()=>o.isFocused()&&(e.networkMode===`always`||P.isOnline())&&e.canRun(),d=()=>F(e.networkMode)&&e.canRun(),f=e=>{a()||(r?.(),i.resolve(e))},p=e=>{a()||(r?.(),i.reject(e))},m=()=>new Promise(t=>{r=e=>{(a()||u())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),h=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(a())return;let i=e.retry??(j.isServer()?0:3),o=e.retryDelay??se,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),te(s).then(()=>u()?void 0:m()).then(()=>{t?p(r):h()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:c,continueRetry:l,canStart:d,start:()=>(d()?h():m().then(h),i)}}var R=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),p(this.gcTime)&&(this.#e=c.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(j.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(c.clearTimeout(this.#e),this.#e=void 0)}};function ce(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ie(e,()=>t.signal,()=>n=!0)},u=k(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?re:ne;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?le:z,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:z(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function z(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function le(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var ue=class extends R{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=H(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=H(this.options);e.data!==void 0&&(this.setState(V(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=D(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(d).catch(d):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>g(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===O||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>h(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!m(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=k(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?ce(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=L({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof I&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof I){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...B(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...V(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),N.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function B(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:F(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function V(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function H(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var U=class extends a{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=M(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),W(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return G(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return G(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof g(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!w(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&K(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||g(this.options.enabled,this.#t)!==g(t.enabled,this.#t)||h(this.options.staleTime,this.#t)!==h(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||g(this.options.enabled,this.#t)!==g(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return fe(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(d)),t}#g(){this.#b();let e=h(this.options.staleTime,this.#t);if(j.isServer()||this.#r.isStale||!p(e))return;let t=m(this.#r.dataUpdatedAt,e)+1;this.#d=c.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(j.isServer()||g(this.options.enabled,this.#t)===!1||!p(this.#p)||this.#p===0)&&(this.#f=c.setInterval(()=>{(this.options.refetchIntervalInBackground||o.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(c.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(c.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&W(e,t),o=i&&K(e,n,t,r);(a||o)&&(l={...l,...B(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=D(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=D(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let _=l.fetchStatus===`fetching`,v=m===`pending`,y=m===`error`,b=v&&_,x=d!==void 0,S={status:m,fetchStatus:l.fetchStatus,isPending:v,isSuccess:m===`success`,isError:y,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:y&&x,isStale:q(e,t),refetch:this.refetch,promise:this.#o,isEnabled:g(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{let e=this.#o=S.promise=M();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a()}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!w(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){N.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function de(e,t){return g(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||g(t.retryOnMount,e)!==!1)}function W(e,t){return de(e,t)||e.state.data!==void 0&&G(e,t,t.refetchOnMount)}function G(e,t,n){if(g(t.enabled,e)!==!1&&h(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&q(e,t)}return!1}function K(e,t,n,r){return(e!==t||g(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&q(e,n)}function q(e,t){return g(t.enabled,e)!==!1&&e.isStaleByTime(h(t.staleTime,e))}function fe(e,t){return!w(e.getCurrentResult(),t)}var J=e(n(),1),Y=r(),X=J.createContext(void 0),Z=e=>{let t=J.useContext(X);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},pe=({client:e,children:t})=>(J.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Y.jsx)(X.Provider,{value:e,children:t})),me=J.createContext(!1),he=()=>J.useContext(me);me.Provider;function ge(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var _e=J.createContext(ge()),ve=()=>J.useContext(_e),ye=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?A(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},be=e=>{J.useEffect(()=>{e.clearReset()},[e])},xe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||A(n,[e.error,r])),Se=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Ce=(e,t)=>e.isLoading&&e.isFetching&&!t,we=(e,t)=>e?.suspense&&t.isPending,Q=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Te(e,t,n){let r=he(),i=ve(),a=Z(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Se(o),ye(o,i,s),be(i);let l=!a.getQueryCache().get(o.queryHash),[u]=J.useState(()=>new t(a,o)),f=u.getOptimisticResult(o),p=!r&&c;if(J.useSyncExternalStore(J.useCallback(e=>{let t=p?u.subscribe(N.batchCalls(e)):d;return u.updateResult(),t},[u,p]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),J.useEffect(()=>{u.setOptions(o)},[o,u]),we(o,f))throw Q(o,u,i);if(xe({result:f,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw f.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,f),o.experimental_prefetchInRender&&!j.isServer()&&Ce(f,r)&&(l?Q(o,u,i):s?.promise)?.catch(d).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?f:u.trackResult(f)}function Ee(e,t){return Te(e,U,t)}var De=t((e=>{var t=n();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.8`})),Oe=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=De()})),ke=Promise.resolve(),$=`(prefers-color-scheme: dark)`;function Ae(){let[e,t]=(0,J.useState)(()=>window.matchMedia($).matches);return(0,J.useEffect)(()=>{let e=window.matchMedia($),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function je({source:e,themePreference:t,renderIdPrefix:n,errorClassName:r,onRendered:a,...o}){let s=(0,J.useId)().replace(/[^A-Za-z0-9]/g,``),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),f=Ae(),p=t===`dark`||t===`system`&&f;return(0,J.useEffect)(()=>d(null),[p,e]),(0,J.useEffect)(()=>{if(!c)return;let t=!1;d(null);let r=`${n}${s}`;return ke=ke.then(async()=>{let{default:n}=await i(async()=>{let{default:e}=await import(`./mermaid.core-BVyLgPb6.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]));n.initialize({startOnLoad:!1,suppressErrorRendering:!0,securityLevel:`strict`,theme:p?`dark`:`base`,flowchart:{htmlLabels:!1,curve:`basis`},themeVariables:p?{primaryColor:`#1f2937`,primaryTextColor:`#f0f6fc`,lineColor:`#8c959f`}:{primaryColor:`#eef5ff`,primaryTextColor:`#24292f`,lineColor:`#57606a`}});let o=await n.render(r,e);t||(c.innerHTML=o.svg,a?.(c))}).catch(e=>{t||d(e instanceof Error?e.message:`diagramを表示できません。`)}).finally(()=>{document.getElementById(`d${r}`)?.remove(),document.getElementById(`i${r}`)?.remove()}),()=>{t=!0}},[c,p,s,a,n,e]),u?(0,Y.jsx)(`div`,{className:r,children:u}):(0,Y.jsx)(`div`,{...o,ref:l})}export{A,v as C,C as D,x as E,o as M,a as N,h as O,y as S,d as T,L as _,Q as a,f as b,xe as c,he as d,pe as f,R as g,ue as h,Se as i,O as j,w as k,be as l,U as m,Oe as n,we as o,Z as p,Ee as r,ye as s,je as t,ve as u,P as v,_ as w,b as x,N as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,s as r,t as i}from"./FileIcon-AhP8Ezk9.js";import{a,c as o,d as s,f as c,h as l,i as u,l as d,m as f,n as p,o as m,r as h,s as g,t as _,u as v}from"./index-CWOtOTHG.js";var y=e(t(),1),b=r(),x=2,S=.005,C=.002;function w(e){return e.startLine===null?e.path:`${e.path}:${e.startLine}${e.endLine===e.startLine?``:`-${e.endLine}`}`}function T(e){let t=[...new Set(e)],n=new Map(t.map(e=>[e,e.split(`/`)]));return new Map(t.map(e=>{let r=n.get(e);for(let i=1;i<=r.length;i+=1){let a=r.slice(-i).join(`/`);if(t.every(t=>t===e||n.get(t).slice(-i).join(`/`)!==a))return[e,a]}return[e,e]}))}function E({anchor:e,compact:t=!1,onOpen:n}){let r=`${w(e)}を開く`;return(0,b.jsxs)(`button`,{type:`button`,className:`structure-source${t?` compact`:``}`,title:r,"aria-label":r,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),n(e.metaKey||e.ctrlKey)},children:[(0,b.jsx)(`span`,{"aria-hidden":`true`,children:`</>`}),!t&&(0,b.jsx)(`span`,{children:w(e)})]})}function ee({edge:e,onOpen:t}){return e.anchors.length===0?null:e.anchors.length===1?(0,b.jsx)(E,{compact:!0,anchor:e.anchors[0],onOpen:n=>t({kind:`edge`,edgeId:e.id,anchorIndex:0},e.anchors[0],n)}):(0,b.jsxs)(`details`,{className:`structure-edge-sources`,children:[(0,b.jsxs)(`summary`,{className:`structure-source compact`,"aria-label":`${e.label}のsource evidence ${e.anchors.length}件を表示`,title:`source evidence ${e.anchors.length}件`,children:[(0,b.jsx)(`span`,{"aria-hidden":`true`,children:`</>`}),(0,b.jsx)(`span`,{className:`structure-edge-source-count`,"aria-hidden":`true`,children:e.anchors.length})]}),(0,b.jsx)(`div`,{className:`structure-edge-source-menu`,children:e.anchors.map((n,r)=>(0,b.jsx)(E,{anchor:n,onOpen:i=>t({kind:`edge`,edgeId:e.id,anchorIndex:r},n,i)},`${e.id}:${r}`))})]})}function te({anchor:e,changeKind:t,sourceLabel:n}){return(0,b.jsxs)(`span`,{className:`structure-source-identity`,"data-source-path":e.path,"data-source-change-kind":t??void 0,title:e.path,children:[(0,b.jsx)(i,{path:e.path,kind:`file`}),t&&(0,b.jsx)(f,{kind:t}),(0,b.jsx)(`span`,{className:`structure-source-name`,children:n})]})}function ne(e,t){let n=e.anchors.flatMap(e=>{let n=t.get(e.path);return n?[n]:[]}),r=[...new Set(n)].sort((e,t)=>e.localeCompare(t,`en`));return{anchorCount:e.anchors.length,changeKind:r.length>1?`mixed`:r.length===1?r[0]:null}}function re({label:e}){let t=e.split(/(::|[./_-])/u);return(0,b.jsx)(b.Fragment,{children:t.map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[e,(e===`::`||/^[./_-]$/u.test(e))&&(0,b.jsx)(`wbr`,{})]},`${t}-${e}`))})}function ie(e,t,n=0,r=!1){let i=t[e.from],a=t[e.to];if(!i||!a)return null;let o=i.x+114,s=i.y+56,c=a.x+114,l=a.y+56;if(e.from===e.to){let e=i.x+228,t=i.y,r=n*.3,a=88+Math.abs(n)*.35;return{path:`M ${e+8} ${t+34+r} C ${e+a} ${t-84+r}, ${e+a} ${t+112+84+r}, ${e+8} ${t+112-34+r}`,startX:e+8,startY:t+34+r,control1X:e+a,control1Y:t-84+r,control2X:e+a,control2Y:t+112+84+r,endX:e+8,endY:t+112-34+r,bounds:{left:e+8,top:t-84+r,right:e+a,bottom:t+112+84+r}}}let u=c-o,d=l-s,f=Math.max(1,Math.hypot(u,d)),p=u/f,m=d/f,h=-m,g=p,_=Math.min(114/Math.max(1e-4,Math.abs(p)),56/Math.max(1e-4,Math.abs(m)))+8,v=o+p*_+h*n,y=s+m*_+g*n,b=c-p*_+h*n,x=l-m*_+g*n,S=Math.min(r?168:96,Math.max(r?132:n===0?28:52,f*(r?.18:.1)))+n*.35,C=v+(b-v)*.36+h*S,w=y+(x-y)*.36+g*S,T=v+(b-v)*.64+h*S,E=y+(x-y)*.64+g*S;return{path:`M ${v} ${y} C ${C} ${w}, ${T} ${E}, ${b} ${x}`,startX:v,startY:y,control1X:C,control1Y:w,control2X:T,control2Y:E,endX:b,endY:x,bounds:{left:Math.min(v,C,T,b),top:Math.min(y,w,E,x),right:Math.max(v,C,T,b),bottom:Math.max(y,w,E,x)}}}function ae(e){let t=new Set(e.filter(e=>e.directed&&e.from!==e.to).map(e=>JSON.stringify([e.from,e.to])));return new Set(e.filter(e=>e.directed&&e.from!==e.to&&t.has(JSON.stringify([e.to,e.from]))).map(e=>e.id))}function oe(e,t,n){let r=1-t,i=r**3*e.startX+3*r**2*t*e.control1X+3*r*t**2*e.control2X+t**3*e.endX,a=r**3*e.startY+3*r**2*t*e.control1Y+3*r*t**2*e.control2Y+t**3*e.endY,o=3*r**2*(e.control1X-e.startX)+6*r*t*(e.control2X-e.control1X)+3*t**2*(e.endX-e.control2X),s=3*r**2*(e.control1Y-e.startY)+6*r*t*(e.control2Y-e.control1Y)+3*t**2*(e.endY-e.control2Y),c=Math.max(1,Math.hypot(o,s));return{x:i+-s/c*n,y:a+o/c*n}}var se=210,D=64,O=11,k=2,A=14;function j(e,t){return!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function M(e,t,n,r,i=0){return{left:e-n/2-i,top:t-r/2-i,right:e+n/2+i,bottom:t+r/2+i}}function ce(e){return e.length===0?null:{left:Math.min(...e.map(e=>e.left)),top:Math.min(...e.map(e=>e.top)),right:Math.max(...e.map(e=>e.right)),bottom:Math.max(...e.map(e=>e.bottom))}}function N(e,t){let n=[...e.label].reduce((e,t)=>e+(/\p{Script=Han}|\p{Script=Hiragana}|\p{Script=Katakana}/u.test(t)?1:.56),0),r=Math.ceil(n*11.5),i=Math.min(se,Math.max(D,r+O+k)),a=Math.max(1,i-O),o=Math.max(1,Math.ceil(r/a)),s=Math.max(24,o*A+10),c=ne(e,t),l=c.anchorCount>1?4:0,u=c.anchorCount>0?29+l:0,d=Math.max(s,c.anchorCount>1?34:c.anchorCount===1?26:0);return{selectWidth:i,boxWidth:i+u,height:d,source:c}}function le(e,t,n,r,i,a){let o=t.flatMap(e=>{let t=n[e.id];return t?[{left:t.x,top:t.y,right:t.x+228,bottom:t.y+112}]:[]}),s=new Map,c=e=>{let t=[],n=Math.floor(e.left/128),r=Math.floor(e.right/128),i=Math.floor(e.top/128),a=Math.floor(e.bottom/128);for(let e=n;e<=r;e+=1)for(let n=i;n<=a;n+=1)t.push(`${e}:${n}`);return t},l=e=>{let t=new Set;for(let n of c(e)){let r=s.get(n);if(r){if(r.saturated)return!0;for(let n of r.boxes)if(!t.has(n)&&(t.add(n),j(e,n)))return!0}}return!1},u=e=>{for(let t of c(e)){let n=s.get(t)??{boxes:[],saturated:!1};n.saturated||(n.boxes.push(e),n.boxes.length>=48&&(n.boxes=[],n.saturated=!0)),s.set(t,n)}},d=[],f=Array.from({length:22},(e,t)=>.08+t*.04).sort((e,t)=>Math.abs(e-.5)-Math.abs(t-.5)),p=[0,12,-12,24,-24,36,-36,48,-48].flatMap(e=>f.map(t=>[t,e])),m=[...e].sort((e,t)=>e.id.localeCompare(t.id,`en`));for(let[e,t]of m.entries()){let s=ie(t,n,i.get(t.id)??0,a.has(t.id));if(!s)continue;let c=N(t,r),f=p.map(([e,t])=>oe(s,e,t)),m=f.filter(e=>{let t=M(e.x,e.y,c.boxWidth,c.height,4);return!o.some(e=>j(t,e))}),h=m.find(e=>{let t=M(e.x,e.y,c.boxWidth,c.height,5);return!l(t)}),g=m.length>0?m[e%m.length]:void 0,_=h??g??f[e%f.length];u(M(_.x,_.y,c.boxWidth,c.height,4)),d.push({edge:t,source:c.source,x:_.x,y:_.y,selectWidth:c.selectWidth,boxWidth:c.boxWidth,height:c.height,crowded:!h})}return d}function ue({structure:e,positions:t,focusedNodeId:n,viewport:r,viewportElement:i}){let a=s(e.nodes.map(e=>e.id),t);if(!a)return null;let o=Math.max(1,a.maxX-a.minX),c=Math.max(1,a.maxY-a.minY),l=Math.min(164/o,98/c),u=i?{x:-r.x/r.scale,y:-r.y/r.scale,width:i.clientWidth/r.scale,height:i.clientHeight/r.scale}:null,d=e=>(e-a.minX)*l,f=e=>(e-a.minY)*l;return(0,b.jsxs)(`svg`,{className:`structure-minimap`,viewBox:`0 0 164 98`,"aria-label":`Structure minimap`,children:[e.nodes.map(e=>{let r=t[e.id];return r?(0,b.jsx)(`circle`,{cx:d(r.x+114),cy:f(r.y+56),r:e.id===n?3.2:1.7,className:e.id===n?`focused`:``},e.id):null}),u&&(0,b.jsx)(`rect`,{className:`structure-minimap-viewport`,x:d(u.x),y:f(u.y),width:Math.max(2,u.width*l),height:Math.max(2,u.height*l)})]})}function P({paneId:e,pullRequestId:t,structure:r,changedFiles:i,onOpenSource:f,onDeleted:w}){let oe=`structure-${e}-${r.id}`,se=u(e,r.id),D=se??p(r),[O,k]=(0,y.useState)(D.focusId),[A,j]=(0,y.useState)(D.selectedEdgeId),[N,P]=(0,y.useState)(D.depth),[F,de]=(0,y.useState)(D.positions),[I,L]=(0,y.useState)(D.viewport),[R,fe]=(0,y.useState)({width:0,height:0}),[pe,z]=(0,y.useState)(null),[me,he]=(0,y.useState)(!1),B=(0,y.useRef)(null),ge=(0,y.useRef)(D.surfaceSize),V=(0,y.useRef)(O),_e=(0,y.useRef)(F),ve=(0,y.useRef)({sourceOid:r.sourceOid,updatedAt:r.updatedAt}),ye=(0,y.useRef)(se?null:`initial`),H=(0,y.useRef)(null),U=(0,y.useRef)(null);V.current=O,_e.current=F,(0,y.useLayoutEffect)(()=>{let e=B.current;if(!e)return;let t=()=>{let t={width:e.clientWidth,height:e.clientHeight};if(t.width===0||t.height===0)return;let n=ge.current;ge.current=t,fe(t),n.width!==0&&n.height!==0&&L(e=>{let r={...e,x:e.x+(t.width-n.width)/2,y:e.y+(t.height-n.height)/2},i=V.current?_e.current[V.current]:void 0;if(!i)return r;let a=228*r.scale,o=112*r.scale,s=r.x+i.x*r.scale,c=r.y+i.y*r.scale;return a>t.width-24?r.x=t.width/2-(i.x+114)*r.scale:s<12?r.x+=12-s:s+a>t.width-12&&(r.x-=s+a-(t.width-12)),o>t.height-24?r.y=t.height/2-(i.y+56)*r.scale:c<12?r.y+=12-c:c+o>t.height-12&&(r.y-=c+o-(t.height-12)),r})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,y.useEffect)(()=>{let e=B.current;if(!e)return;let t=t=>{let n=t.ctrlKey||t.metaKey;if(t.target instanceof Element){let e=t.target.closest(`.structure-node-focus`),r=Math.abs(t.deltaY)>=Math.abs(t.deltaX),i=e?t.deltaY<0?e.scrollTop>0:t.deltaY>0&&e.scrollTop+e.clientHeight<e.scrollHeight-1:!1;if(!n&&r&&i)return}t.preventDefault(),t.stopPropagation();let r=t.deltaMode===WheelEvent.DOM_DELTA_LINE?16:t.deltaMode===WheelEvent.DOM_DELTA_PAGE?Math.max(1,e.clientHeight):1;if(!n){L(e=>({...e,x:e.x-t.deltaX*r*x,y:e.y-t.deltaY*r*x}));return}let i=e.getBoundingClientRect(),o=t.clientX-i.left,s=t.clientY-i.top;L(e=>{let n=t.ctrlKey&&!t.metaKey?S:C,i=a(e.scale,Math.exp(-t.deltaY*r*n)),c=(o-e.x)/e.scale,l=(s-e.y)/e.scale;return{scale:i,x:o-c*i,y:s-l*i}})};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,y.useEffect)(()=>{if(u(e,r.id)?.updatedAt===r.updatedAt)return;let t=ve.current;t.updatedAt!==r.updatedAt&&z(t.sourceOid===r.sourceOid?`Structureが更新されました。閲覧状態を保ったまま最新のclaimへ反映しています。`:`Structureが更新されました。exact source ${t.sourceOid.slice(0,8)} → ${r.sourceOid.slice(0,8)}`),ve.current={sourceOid:r.sourceOid,updatedAt:r.updatedAt},de(e=>d(r,e));let n=V.current&&r.nodes.some(e=>e.id===V.current)?V.current:null;k(n),n===null&&P(`all`),j(e=>e&&r.edges.some(t=>t.id===e)?e:null)},[e,r,r.updatedAt]),(0,y.useEffect)(()=>{m(e,r.id,{focusId:O,selectedEdgeId:A,depth:N,positions:F,viewport:I,surfaceSize:ge.current,updatedAt:r.updatedAt})},[N,O,F,e,A,r.updatedAt,I]);let W=(0,y.useMemo)(()=>c(r,O,N),[N,O,r]),G=(0,y.useMemo)(()=>new Map(r.nodes.map(e=>[e.id,e])),[r.nodes]),be=O?G.get(O)??null:null,xe=G.get(r.originNodeId),K=A?r.edges.find(e=>e.id===A)??null:null,Se=(0,y.useMemo)(()=>new Set(K?[K.from,K.to]:[]),[K]),Ce=(0,y.useMemo)(()=>O?g(r,O):[],[O,r]),q=(0,y.useMemo)(()=>v(r.edges),[r.edges]),J=(0,y.useMemo)(()=>ae(r.edges),[r.edges]),Y=(0,y.useMemo)(()=>{let e=new Map;for(let t of i){let n=l(t);n&&e.set(n,t.kind),t.oldPath&&e.set(t.oldPath,t.kind),t.newPath&&e.set(t.newPath,t.kind)}return e},[i]),we=(0,y.useMemo)(()=>T([...r.nodes.flatMap(e=>e.anchor?[e.anchor.path]:[]),...r.edges.flatMap(e=>e.anchors.map(e=>e.path))]),[r.edges,r.nodes]),X=(0,y.useMemo)(()=>s(W.nodeIds,F),[F,W.nodeIds]),Z=W.nodeIds,Q=(0,y.useMemo)(()=>r.edges.filter(e=>W.edgeIds.has(e.id)&&Z.has(e.from)&&Z.has(e.to)),[Z,r.edges,W.edgeIds]),Te=(0,y.useMemo)(()=>r.nodes.filter(e=>Z.has(e.id)),[Z,r.nodes]),Ee=(0,y.useMemo)(()=>O?Q.filter(e=>e.from===O||e.to===O||e.id===A):Q,[O,Q,A]),De=(0,y.useMemo)(()=>le(Ee,Te,F,Y,q,J),[Ee,F,J,Te,q,Y]),$=(0,y.useMemo)(()=>{let e=[];X&&e.push({left:X.minX,top:X.minY,right:X.maxX,bottom:X.maxY});for(let t of Q){let n=ie(t,F,q.get(t.id)??0,J.has(t.id));n&&e.push(n.bounds)}for(let t of De)e.push(M(t.x,t.y,t.boxWidth,t.height,4));return ce(e)},[De,X,F,J,Q,q]),Oe=Math.max(1200,($?.right??1e3)+180),ke=Math.max(800,($?.bottom??600)+180),Ae=()=>{if(!$||R.width===0||R.height===0)return null;let e=Math.min(1.25,Math.max(_,Math.min((R.width-72)/Math.max(1,$.right-$.left),(R.height-72)/Math.max(1,$.bottom-$.top)))),t=($.right-$.left)*e,n=($.bottom-$.top)*e;return{scale:e,x:(R.width-t)/2-$.left*e,y:(R.height-n)/2-$.top*e}},je=()=>{let e=Ae();e&&L(e)};(0,y.useLayoutEffect)(()=>{if(!ye.current||!$||R.width===0||R.height===0)return;let e=F[r.originNodeId],t=e?e.x+114:($.left+$.right)/2,n=e?e.y+56:($.top+$.bottom)/2;ye.current=null,L({scale:1,x:R.width*.25-t,y:R.height/2-n})},[$,F,r.originNodeId,R.height,R.width]);let Me=(e,t)=>{let n=F[e];n&&L(e=>({scale:t??e.scale,x:R.width/2-(n.x+114)*(t??e.scale),y:R.height/2-(n.y+56)*(t??e.scale)}))},Ne=()=>{O&&Me(O)},Pe=()=>{de(o(r))},Fe=(e,t=!1)=>{j(null),k(e),t&&Me(e)},Ie=()=>{j(null),k(null),P(`all`)},Le=e=>{e!==N&&P(e)},Re=async()=>{try{await navigator.clipboard.writeText(r.ref),z(`Structure参照をコピーしました。`)}catch{z(`Structure参照をコピーできませんでした。`)}},ze=e=>{L(t=>{let n=a(t.scale,e),r=R.width/2,i=R.height/2,o=(r-t.x)/t.scale,s=(i-t.y)/t.scale;return{scale:n,x:r-o*n,y:i-s*n}})},Be=async(e,t,n)=>{z(null);try{let t=await f(e,n);z(t)}catch(e){z(e instanceof Error?e.message:`参照先を開けません · ${t.path}`)}},Ve=async()=>{if(me)return;let e=r.nodes.filter(e=>e.anchor!==null).length+r.edges.reduce((e,t)=>e+t.anchors.length,0);if(window.confirm(`Structure「${r.title}」を削除します。\n\nNode ${r.nodes.length}\nEdge ${r.edges.length}\nSource anchor ${e}\n\nこの操作は元に戻せません。`)){he(!0),z(null);try{await n(`/api/pull-requests/${t}/structures/${r.id}`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify({expectedUpdatedAt:r.updatedAt})}),h(r.id),w()}catch(e){z(e instanceof Error?e.message:`Structureを削除できませんでした。`)}finally{he(!1)}}},He=e=>{let t=U.current;if(t?.pointerId===e.pointerId){let n=(e.clientX-t.x)/I.scale,r=(e.clientY-t.y)/I.scale;U.current={...t,x:e.clientX,y:e.clientY,distance:t.distance+Math.hypot(e.clientX-t.x,e.clientY-t.y)},de(e=>{let i=e[t.nodeId];return i?{...e,[t.nodeId]:{x:i.x+n,y:i.y+r}}:e});return}let n=H.current;if(n?.pointerId!==e.pointerId)return;let r=e.clientX-n.x,i=e.clientY-n.y;H.current={...n,x:e.clientX,y:e.clientY},L(e=>({...e,x:e.x+r,y:e.y+i}))},Ue=e=>{if(H.current?.pointerId===e.pointerId&&(H.current=null),U.current?.pointerId===e.pointerId){let e=U.current;U.current=null,e.distance<4&&Fe(e.nodeId)}e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)};return(0,b.jsxs)(`article`,{className:`structure-viewer`,"data-structure-id":r.id,"data-visible-node-count":W.nodeIds.size,"data-total-node-count":r.nodes.length,"data-visible-edge-count":W.edgeIds.size,"data-total-edge-count":r.edges.length,"data-rendered-node-count":Te.length,"data-rendered-edge-count":Q.length,"data-viewport-scale":I.scale.toFixed(3),"data-selected-edge-id":A??void 0,children:[(0,b.jsxs)(`header`,{className:`structure-header`,children:[(0,b.jsxs)(`div`,{className:`structure-header-main`,children:[(0,b.jsx)(`span`,{className:`structure-kicker`,children:`Structure`}),(0,b.jsx)(`h2`,{title:r.title,children:r.title}),(0,b.jsx)(`span`,{className:`structure-source-oid`,title:`exact source ${r.sourceOid}`,children:r.sourceOid.slice(0,8)}),(0,b.jsxs)(`details`,{className:`structure-scope-details`,children:[(0,b.jsx)(`summary`,{"aria-label":`scopeを表示`,children:`scope`}),(0,b.jsx)(`p`,{children:r.scope})]})]}),(0,b.jsxs)(`div`,{className:`structure-header-side`,children:[(0,b.jsx)(`button`,{type:`button`,className:`structure-header-action`,"aria-label":`参照をコピー`,title:`Structure参照をコピー`,onClick:()=>void Re(),children:`参照`}),(0,b.jsx)(`button`,{type:`button`,className:`danger structure-delete`,disabled:me,onClick:()=>void Ve(),children:me?`削除中…`:`削除`})]})]}),(0,b.jsxs)(`div`,{className:`structure-body`,children:[(0,b.jsxs)(`div`,{className:`structure-toolbar`,"aria-label":`Structure表示操作`,children:[(0,b.jsx)(`div`,{className:`structure-toolbar-group`,role:`group`,"aria-label":`近傍の深さ`,children:[1,2,`all`].map(e=>(0,b.jsx)(`button`,{type:`button`,className:N===e?`active`:``,"aria-pressed":N===e,disabled:!O&&e!==`all`,onClick:()=>Le(e),children:e===`all`?`全体`:`${e}-hop`},e))}),(0,b.jsxs)(`div`,{className:`structure-toolbar-group`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:()=>ze(1/1.2),"aria-label":`縮小`,children:`−`}),(0,b.jsxs)(`span`,{children:[Math.round(I.scale*100),`%`]}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>ze(1.2),"aria-label":`拡大`,children:`+`}),(0,b.jsx)(`button`,{type:`button`,"aria-label":`表示中を収める`,title:`表示中を収める`,onClick:je,children:`Fit`}),(0,b.jsx)(`button`,{type:`button`,"aria-label":`focusを中央へ`,title:`focusを中央へ`,disabled:!O,onClick:Ne,children:`中央`}),(0,b.jsx)(`button`,{type:`button`,"aria-label":`focusを解除`,title:`focusを解除`,disabled:!O,onClick:Ie,children:`解除`}),(0,b.jsx)(`button`,{type:`button`,"aria-label":`レイアウトを戻す`,title:`レイアウトを戻す`,onClick:Pe,children:`Reset`})]})]}),pe&&(0,b.jsx)(`div`,{className:`structure-status`,role:`status`,"aria-live":`polite`,children:pe}),(0,b.jsx)(`section`,{className:`structure-canvas-shell`,"aria-label":`${r.title} graph`,children:(0,b.jsxs)(`div`,{ref:B,className:`structure-canvas`,tabIndex:0,onKeyDown:e=>{e.key!==`Escape`||!A&&!O||(e.preventDefault(),A?j(null):Ie())},onPointerDown:e=>{e.button!==0||e.target instanceof Element&&e.target.closest(`.structure-node, .structure-edge-label, button`)||(H.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:He,onPointerUp:Ue,onPointerCancel:Ue,onDoubleClick:e=>{e.target===e.currentTarget&&je()},children:[(0,b.jsxs)(`div`,{className:`structure-world`,style:{width:Oe,height:ke,transform:`translate(${I.x}px, ${I.y}px) scale(${I.scale})`},children:[(0,b.jsxs)(`svg`,{className:`structure-edges`,width:Oe,height:ke,"aria-hidden":`true`,children:[(0,b.jsx)(`defs`,{children:(0,b.jsx)(`marker`,{id:`${oe}-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,b.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`})})}),Q.map(e=>{let t=ie(e,F,q.get(e.id)??0,J.has(e.id));if(!t)return null;let n=e.from===O||e.to===O,r=e.id===A,i=A!==null&&!r,a=ne(e,Y).changeKind;return(0,b.jsx)(`path`,{className:`structure-edge${n?` focused`:``}${r?` selected`:``}${i?` muted`:``}`,"data-edge-id":e.id,"data-source-change-kind":a??void 0,"data-start-x":t.startX,"data-start-y":t.startY,"data-end-x":t.endX,"data-end-y":t.endY,d:t.path,markerEnd:e.directed?`url(#${oe}-arrow)`:void 0},e.id)})]}),De.map(({edge:e,source:t,x:n,y:r,selectWidth:i,height:a,crowded:o})=>{let s=t.changeKind,c=G.get(e.from),l=G.get(e.to),u=e.directed?`${c?.label??e.from} から ${l?.label??e.to} へ: ${e.label}`:`${c?.label??e.from} と ${l?.label??e.to} の関係: ${e.label}`,d=e.id===A;return(0,b.jsxs)(`div`,{className:`structure-edge-label${o?` crowded`:``}${A!==null&&!d?` muted`:``}`,"data-edge-id":e.id,"data-source-anchor-count":t.anchorCount,"data-source-change-kind":s??void 0,style:{left:n,top:r,minHeight:a},children:[(0,b.jsx)(`button`,{type:`button`,className:`structure-edge-select${d?` selected`:``}`,title:e.label,"aria-label":u,"aria-pressed":d,style:{maxWidth:i},onClick:()=>j(t=>t===e.id?null:e.id),children:(0,b.jsx)(`span`,{className:`structure-edge-label-text`,children:e.label})}),(0,b.jsx)(ee,{edge:e,onOpen:(e,t,n)=>void Be(e,t,n)})]},`label:${e.id}`)}),Te.map(e=>{let t=F[e.id];if(!t)return null;let n=e.id===O,i=Ce.some(t=>t.from===e.id||t.to===e.id),a=e.anchor?Y.get(e.anchor.path)??null:null;return(0,b.jsxs)(`div`,{className:`structure-node notation-${e.notation}${e.id===r.originNodeId?` origin`:``}${n?` focused`:``}${i?` neighboring`:``}${Se.has(e.id)?` edge-endpoint`:``}`,"data-node-id":e.id,"data-node-notation":e.notation,"data-origin-node":e.id===r.originNodeId?`true`:void 0,"data-source-change-kind":a??void 0,style:{left:t.x,top:t.y},onPointerDown:t=>{t.button===0&&(t.stopPropagation(),U.current={pointerId:t.pointerId,nodeId:e.id,x:t.clientX,y:t.clientY,distance:0},B.current?.setPointerCapture(t.pointerId))},children:[(0,b.jsxs)(`button`,{type:`button`,className:`structure-node-focus`,"aria-pressed":n,onClick:t=>{t.detail===0&&Fe(e.id)},children:[e.anchor&&(0,b.jsx)(te,{anchor:e.anchor,changeKind:a,sourceLabel:we.get(e.anchor.path)??e.anchor.path}),(0,b.jsx)(`strong`,{className:`structure-node-title`,children:(0,b.jsx)(`span`,{className:`structure-node-title-text`,title:e.label,children:(0,b.jsx)(re,{label:e.label})})}),(0,b.jsx)(`span`,{className:`structure-node-description`,children:e.description??`Producerによる説明なし`})]}),e.anchor&&(0,b.jsx)(E,{compact:!0,anchor:e.anchor,onOpen:t=>void Be({kind:`node`,nodeId:e.id},e.anchor,t)})]},e.id)})]}),(0,b.jsxs)(`div`,{className:`structure-canvas-status`,children:[(0,b.jsx)(`strong`,{children:be?.label??`focusなし`}),(0,b.jsxs)(`span`,{children:[`origin · `,xe.label]}),(0,b.jsxs)(`span`,{children:[W.nodeIds.size,`/`,r.nodes.length,` Node · `,W.edgeIds.size,`/`,r.edges.length,` Relation`]})]}),(0,b.jsx)(ue,{structure:r,positions:F,focusedNodeId:O,viewport:I,viewportElement:B.current})]})})]})]})}export{P as StructureViewer};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,b as n,l as r,s as i,t as a,x as o,y as s}from"./MermaidSurface-Dt2_Hu6n.js";import{C as c,E as l,O as u,P as d,S as f,T as p,_ as m,a as h,b as g,g as _,i as v,j as y,k as b,m as x,n as S,nt as C,o as w,s as T,t as E,u as D,v as O,w as k,x as A,y as j}from"./CommentThread-CMXtuZ98.js";import{t as ee}from"./index-BwIKbLJ1.js";import{t as M}from"./lib-p2IERBh0.js";import{a as te,i as N,n as ne,o as P,r as F,t as I}from"./MarkdownTable-7Sm_sj1E.js";var L={abandonedHeadElementChild:{reason:`Unexpected metadata element after head`,description:"Unexpected element after head. Expected the element before `</head>`",url:!1},abruptClosingOfEmptyComment:{reason:`Unexpected abruptly closed empty comment`,description:"Unexpected `>` or `->`. Expected `-->` to close comments"},abruptDoctypePublicIdentifier:{reason:`Unexpected abruptly closed public identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the public identifier"},abruptDoctypeSystemIdentifier:{reason:`Unexpected abruptly closed system identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the identifier identifier"},absenceOfDigitsInNumericCharacterReference:{reason:`Unexpected non-digit at start of numeric character reference`,description:"Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references"},cdataInHtmlContent:{reason:`Unexpected CDATA section in HTML`,description:"Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead"},characterReferenceOutsideUnicodeRange:{reason:`Unexpected too big numeric character reference`,description:`Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)`},closingOfElementWithOpenChildElements:{reason:`Unexpected closing tag with open child elements`,description:`Unexpectedly closing tag. Expected other tags to be closed first`,url:!1},controlCharacterInInputStream:{reason:`Unexpected control character`,description:"Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace"},controlCharacterReference:{reason:`Unexpected control character reference`,description:`Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace`},disallowedContentInNoscriptInHead:{reason:"Disallowed content inside `<noscript>` in `<head>`",description:"Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`",url:!1},duplicateAttribute:{reason:`Unexpected duplicate attribute`,description:`Unexpectedly double attribute. Expected attributes to occur only once`},endTagWithAttributes:{reason:`Unexpected attribute on closing tag`,description:"Unexpected attribute. Expected `>` instead"},endTagWithTrailingSolidus:{reason:`Unexpected slash at end of closing tag`,description:"Unexpected `%c-1`. Expected `>` instead"},endTagWithoutMatchingOpenElement:{reason:`Unexpected unopened end tag`,description:`Unexpected end tag. Expected no end tag or another end tag`,url:!1},eofBeforeTagName:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected tag name instead`},eofInCdata:{reason:`Unexpected end of file in CDATA`,description:"Unexpected end of file. Expected `]]>` to close the CDATA"},eofInComment:{reason:`Unexpected end of file in comment`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInDoctype:{reason:`Unexpected end of file in doctype`,description:"Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)"},eofInElementThatCanContainOnlyText:{reason:`Unexpected end of file in element that can only contain text`,description:`Unexpected end of file. Expected text or a closing tag`,url:!1},eofInScriptHtmlCommentLikeText:{reason:`Unexpected end of file in comment inside script`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInTag:{reason:`Unexpected end of file in tag`,description:"Unexpected end of file. Expected `>` to close the tag"},incorrectlyClosedComment:{reason:`Incorrectly closed comment`,description:"Unexpected `%c-1`. Expected `-->` to close the comment"},incorrectlyOpenedComment:{reason:`Incorrectly opened comment`,description:"Unexpected `%c`. Expected `<!--` to open the comment"},invalidCharacterSequenceAfterDoctypeName:{reason:`Invalid sequence after doctype name`,description:"Unexpected sequence at `%c`. Expected `public` or `system`"},invalidFirstCharacterOfTagName:{reason:`Invalid first character in tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},misplacedDoctype:{reason:`Misplaced doctype`,description:`Unexpected doctype. Expected doctype before head`,url:!1},misplacedStartTagForHeadElement:{reason:"Misplaced `<head>` start tag",description:"Unexpected start tag `<head>`. Expected `<head>` directly after doctype",url:!1},missingAttributeValue:{reason:`Missing attribute value`,description:"Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead"},missingDoctype:{reason:`Missing doctype before other content`,description:"Expected a `<!doctype html>` before anything else",url:!1},missingDoctypeName:{reason:`Missing doctype name`,description:"Unexpected doctype end at `%c`. Expected `html` instead"},missingDoctypePublicIdentifier:{reason:`Missing public identifier in doctype`,description:"Unexpected `%c`. Expected identifier for `public` instead"},missingDoctypeSystemIdentifier:{reason:`Missing system identifier in doctype`,description:'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'},missingEndTagName:{reason:`Missing name in end tag`,description:"Unexpected `%c`. Expected an ASCII letter instead"},missingQuoteBeforeDoctypePublicIdentifier:{reason:`Missing quote before public identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingQuoteBeforeDoctypeSystemIdentifier:{reason:`Missing quote before system identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingSemicolonAfterCharacterReference:{reason:`Missing semicolon after character reference`,description:"Unexpected `%c`. Expected `;` instead"},missingWhitespaceAfterDoctypePublicKeyword:{reason:`Missing whitespace after public identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceAfterDoctypeSystemKeyword:{reason:`Missing whitespace after system identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBeforeDoctypeName:{reason:`Missing whitespace before doctype name`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenAttributes:{reason:`Missing whitespace between attributes`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:{reason:`Missing whitespace between public and system identifiers in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},nestedComment:{reason:`Unexpected nested comment`,description:"Unexpected `<!--`. Expected `-->`"},nestedNoscriptInHead:{reason:"Unexpected nested `<noscript>` in `<head>`",description:"Unexpected `<noscript>`. Expected a closing tag or a meta element",url:!1},nonConformingDoctype:{reason:`Unexpected non-conforming doctype declaration`,description:'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',url:!1},nonVoidHtmlElementStartTagWithTrailingSolidus:{reason:`Unexpected trailing slash on start tag of non-void element`,description:"Unexpected `/`. Expected `>` instead"},noncharacterCharacterReference:{reason:`Unexpected noncharacter code point referenced by character reference`,description:`Unexpected code point. Do not use noncharacters in HTML`},noncharacterInInputStream:{reason:`Unexpected noncharacter character`,description:"Unexpected code point `%x`. Do not use noncharacters in HTML"},nullCharacterReference:{reason:`Unexpected NULL character referenced by character reference`,description:`Unexpected code point. Do not use NULL characters in HTML`},openElementsLeftAfterEof:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected closing tag instead`,url:!1},surrogateCharacterReference:{reason:`Unexpected surrogate character referenced by character reference`,description:`Unexpected code point. Do not use lone surrogate characters in HTML`},surrogateInInputStream:{reason:`Unexpected surrogate character`,description:"Unexpected code point `%x`. Do not use lone surrogate characters in HTML"},unexpectedCharacterAfterDoctypeSystemIdentifier:{reason:`Invalid character after system identifier in doctype`,description:"Unexpected character at `%c`. Expected `>`"},unexpectedCharacterInAttributeName:{reason:`Unexpected character in attribute name`,description:"Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter"},unexpectedCharacterInUnquotedAttributeValue:{reason:`Unexpected character in unquoted attribute value`,description:"Unexpected `%c`. Quote the attribute value to include it"},unexpectedEqualsSignBeforeAttributeName:{reason:`Unexpected equals sign before attribute name`,description:"Unexpected `%c`. Add an attribute name before it"},unexpectedNullCharacter:{reason:`Unexpected NULL character`,description:"Unexpected code point `%x`. Do not use NULL characters in HTML"},unexpectedQuestionMarkInsteadOfTagName:{reason:`Unexpected question mark instead of tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},unexpectedSolidusInTag:{reason:`Unexpected slash in tag`,description:"Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value"},unknownNamedCharacterReference:{reason:`Unexpected unknown named character reference`,description:`Unexpected character reference. Expected known named character references`}},R=`https://html.spec.whatwg.org/multipage/parsing.html#parse-error-`,z=/-[a-z]/g,B=/%c(?:([-+])(\d+))?/g,V=/%x/g,re={2:!0,1:!1,0:null},ie={};function ae(e,t){let n=t||ie,r=n.onerror,i=e instanceof k?e:new k(e),a=n.fragment?g:j,o=String(i),s=a(o,{sourceCodeLocationInfo:!0,onParseError:n.onerror?c:null,scriptingEnabled:!1});return A(s,{file:i,space:n.space,verbose:n.verbose});function c(e){let t=e.code,a=H(t),s=n[a]??!0,c=typeof s==`number`?s:+!!s;if(c){let n=L[a],o=new l(u(n.reason),{place:{start:{line:e.startLine,column:e.startCol,offset:e.startOffset},end:{line:e.endLine,column:e.endCol,offset:e.endOffset}},ruleId:t,source:`hast-util-from-html`});i.path&&(o.file=i.path,o.name=i.path+`:`+o.name),o.fatal=re[c],o.note=u(n.description),o.url=n.url===!1?void 0:R+t,r(o)}function u(t){return t.replace(B,n).replace(V,r);function n(t,n,r){let i=(r?Number.parseInt(r,10):0)*(n===`-`?-1:1);return U(o.charAt(e.startOffset+i))}function r(){return W(o.charCodeAt(e.startOffset))}}}}function H(e){return e.replace(z,oe)}function oe(e){return e.charAt(1).toUpperCase()}function U(e){return e==="`"?"` ` `":e}function W(e){return`0x`+e.toString(16).toUpperCase()}var G=e(o(),1),se=class extends Error{code;suggestions;status;details;constructor(e,t,n={}){super(t,n.cause===void 0?void 0:{cause:n.cause}),this.name=`RvwError`,this.code=e,this.suggestions=n.suggestions??[],this.status=n.status??400,this.details=n.details}toJSON(){return{code:this.code,message:this.message,suggestions:this.suggestions,...this.details===void 0?{}:{details:this.details}}}},ce=`rvw-ref:`,K=`rvw-source:`,q=/^[A-Za-z][A-Za-z\d+.-]*:/u,le=/^data:image\/(?:png|jpeg|gif|webp|avif);base64,[A-Za-z\d+/=\s]+$/u,ue=/<\s*\/?\s*(?:html|head|body)(?:\s|>)/iu,de=new Set(`a.article.aside.b.blockquote.br.button.caption.code.col.colgroup.dd.details.div.dl.dt.em.figcaption.figure.footer.h1.h2.h3.h4.h5.h6.header.hr.i.img.input.kbd.label.li.main.mark.nav.ol.option.p.pre.section.select.small.span.strong.style.sub.summary.sup.table.tbody.td.textarea.tfoot.th.thead.tr.ul`.split(`.`)),J=new Set([`circle`,`clipPath`,`defs`,`desc`,`ellipse`,`g`,`line`,`linearGradient`,`marker`,`mask`,`path`,`polygon`,`polyline`,`radialGradient`,`rect`,`stop`,`svg`,`symbol`,`text`,`title`,`tspan`,`use`]),fe=new Set([`audio`,`base`,`canvas`,`embed`,`frame`,`iframe`,`link`,`meta`,`object`,`script`,`video`,`foreignobject`]),pe=new Set([`article`,`aside`,`details`,`figure`,`img`,`section`,`svg`,`table`]),me=new Set([`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`,`className`,`dir`,`hidden`,`id`,`lang`,`role`,`style`,`tabIndex`,`title`]),he=new Map([[`a`,new Set([`href`,`hrefLang`])],[`blockquote`,new Set([`cite`])],[`button`,new Set([`disabled`,`name`,`type`,`value`])],[`col`,new Set([`span`,`width`])],[`details`,new Set([`open`])],[`img`,new Set([`alt`,`decoding`,`height`,`loading`,`src`,`width`])],[`input`,new Set([`accept`,`autoComplete`,`checked`,`disabled`,`max`,`maxLength`,`min`,`minLength`,`multiple`,`name`,`placeholder`,`readOnly`,`required`,`size`,`step`,`type`,`value`])],[`label`,new Set([`htmlFor`])],[`li`,new Set([`value`])],[`ol`,new Set([`reversed`,`start`,`type`])],[`option`,new Set([`disabled`,`label`,`selected`,`value`])],[`select`,new Set([`disabled`,`multiple`,`name`,`required`,`size`])],[`td`,new Set([`colSpan`,`headers`,`rowSpan`])],[`textarea`,new Set([`cols`,`disabled`,`maxLength`,`minLength`,`name`,`placeholder`,`readOnly`,`required`,`rows`,`wrap`])],[`th`,new Set([`abbr`,`colSpan`,`headers`,`rowSpan`,`scope`])]]),ge=new Set(`alignmentBaseline.clipPath.clipPathUnits.cx.cy.d.dominantBaseline.dx.dy.fill.fillOpacity.fillRule.fontFamily.fontSize.fontStyle.fontWeight.gradientTransform.gradientUnits.height.href.lengthAdjust.markerEnd.markerHeight.markerMid.markerStart.markerUnits.markerWidth.mask.maskContentUnits.maskUnits.offset.opacity.orient.pathLength.points.preserveAspectRatio.r.refX.refY.rx.ry.spreadMethod.stopColor.stopOpacity.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.textAnchor.textLength.transform.vectorEffect.viewBox.width.x.x1.x2.xmlns.y.y1.y2`.split(`.`)),_e=new Set([`clipPath`,`fill`,`markerEnd`,`markerMid`,`markerStart`,`mask`,`stroke`]);function ve(e){let t=p(e),n=[],r=e=>{if(e.type===`code`&&e.lang===`html-preview`&&typeof e.value==`string`&&e.position){let t=e.position.start.line+1;n.push({startLine:t,endLine:t+Math.max(1,e.value.split(`
|
|
2
|
-
`).length)-1})}e.children?.forEach(r)};return r(t),n}function ye(e,t){return t+(e?.start.line??1)}function Y(e,t){throw new se(`INVALID_INPUT`,`html-preview L${e}: ${t}`)}function be(e){return e.replace(/\\([\da-f]{1,6}\s?|.)/giu,(e,t)=>{let n=t.trim();if(/^[\da-f]{1,6}$/iu.test(n)){let e=Number.parseInt(n,16);return e===0||e>1114111?`�`:String.fromCodePoint(e)}return t})}function xe(e,t){let n=be(e.replace(/\/\*[\s\S]*?\*\//gu,` `)).toLowerCase().replace(/url\s*\(\s*(["']?)#[a-z_][\w:.-]*\1\s*\)/giu,`internal-fragment`);(/@import\b|@font-face\b|(?:^|[^-])url\s*\(|image-set\s*\(|(?:^|[^-])image\s*\(|expression\s*\(|-moz-binding\s*:|behavior\s*:/u.test(n)||/(?:https?|file|blob|data):|\/\//u.test(n))&&Y(t,`network resourceを参照するCSSは使用できません。`)}function X(e){let t=e.trim();if(t.length===0||t.startsWith(`#`)||t.startsWith(`?`)||t.startsWith(`//`)||q.test(t))return null;let n=t.split(/[?#]/u,1)[0];if(!n)return null;let r;try{r=decodeURIComponent(n)}catch{return null}if(r.includes(`\\`)||r.includes(`\0`))return null;let i=[];for(let e of r.split(`/`))if(!(!e||e===`.`)){if(e===`..`){if(i.length===0)return null;i.pop();continue}i.push(e)}return i.length>0?i.join(`/`):null}function Se(e,t,n){return me.has(t)||/^aria[A-Z]/u.test(t)||t===`dataRvwCommentable`||n&&ge.has(t)?!0:he.get(e)?.has(t)??!1}function Z(e,t){let n=e.properties?.[t];return typeof n==`string`?n:typeof n==`number`||typeof n==`boolean`||typeof n==`bigint`?String(n):Array.isArray(n)?n.filter(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`).map(String).join(` `):null}function Ce(e,t,n,r){let i=e.trim();if(i.toLowerCase().startsWith(ce)){n&&Y(t,`inline SVGのhrefはfragmentだけを使用できます。`),r.push(i.slice(8));return}i.startsWith(`#`)||!n&&(/^https?:/iu.test(i)||X(i))||(/^javascript:/iu.test(i)&&Y(t,`javascript: URLは使用できません。`),Y(t,n?`inline SVGのexternal hrefは使用できません。`:`link ${i} は使用できません。`))}function we(e,t){let n=[],r=[],i=new Set,a=0,o=(e,s)=>{if(e.type===`comment`){e.value?.startsWith(K)&&Y(ye(e.position,t),`内部source markerは指定できません。`);return}if(e.type===`doctype`&&Y(ye(e.position,t),`doctypeはfragment内で使用できません。`),e.type!==`element`||!e.tagName){e.children?.forEach(e=>o(e,s));return}let c=e.tagName,l=c.toLowerCase(),u=ye(e.position,t),d=s||l===`svg`;fe.has(l)&&Y(u,`<${c}> は使用できません。`),!de.has(c)&&!J.has(c)&&Y(u,`<${c}> は使用できません。`);for(let t of Object.keys(e.properties??{}))/^on/iu.test(t)&&Y(u,`${t.toLowerCase()} attribute は使用できません。`),t===`srcDoc`&&Y(u,`srcdoc attribute は使用できません。`),(/^dataRvwSource/iu.test(t)||/^dataRvw(?:Node|Text|CommentSurface)/iu.test(t))&&Y(u,`内部data-rvw-source-* attributeは指定できません。`),Se(c,t,d)||Y(u,`<${c}>の${t} attribute は使用できません。`),i.add(t);let f=Z(e,`style`);f!==null&&xe(f,u),c===`style`&&xe(e.children?.map(e=>e.value??``).join(``)??``,u);let p=Z(e,`href`);if(p!==null&&Ce(p,u,d,n),d)for(let t of _e){let n=Z(e,t);n!==null&&xe(n,u)}if(c===`img`){a+=1;let t=Z(e,`src`);if(t||Y(u,`<img>にはsrcが必要です。`),t.startsWith(`data:`))le.test(t)||Y(u,`inline imageは対応するbase64 data:imageだけを使用できます。`);else{let e=X(t);e||Y(u,`外部画像 ${t} は使用できません。`),r.push(e)}}e.children?.forEach(e=>o(e,d))};return o(e,!1),a>32&&Y(t,`画像はWalkthrough全体で32件以下にしてください。`),{referenceIds:n,repositoryImages:r,propertyNames:i,imageCount:a}}function Te(e){return{allowComments:!0,allowDoctypes:!1,ancestors:{},attributes:{"*":[...e]},clobber:[],protocols:{href:[`http`,`https`,`rvw-ref`],src:[`data`]},required:{},strip:[...fe],tagNames:[...de,...J]}}function Ee(e,t){return e.position?{startLine:t+e.position.start.line,endLine:t+e.position.end.line}:null}function De(e,t){let n=Z(e,`alt`)?.trim(),r=Z(e,`title`)?.trim();e.tagName=`span`,e.properties={className:[`rvw-html-image-placeholder`],dataRvwImagePath:t,role:`img`,ariaLabel:n||r||`Missing image: ${t}`,...r?{title:r}:{}},e.children=[{type:`text`,value:n||r||`Image unavailable: ${t}`}]}function Oe(e,t,n){let r=(e,i=!1)=>{if(e.type!==`element`||!e.tagName){if(e.children){let n=[];for(let a of e.children){let e=!i&&a.type===`text`?Ee(a,t):null;e&&a.value?.trim()&&n.push({type:`comment`,value:`${K}${e.startLine}:${e.endLine}`}),r(a,i),n.push(a)}e.children=n}return}let a=Ee(e,t);if(e.properties??={},a&&(e.properties.dataRvwSourceStartLine=a.startLine,e.properties.dataRvwSourceEndLine=a.endLine),(pe.has(e.tagName)||Object.hasOwn(e.properties,`dataRvwCommentable`))&&(e.properties.dataRvwCommentSurface=`true`),e.tagName===`img`){let t=Z(e,`src`);if(t&&!t.startsWith(`data:`)){let r=X(t),i=r?n.get(r):null;r&&i?(e.properties.src=i,e.properties.dataRvwImagePath=r):r&&De(e,r)}}if(e.children){let n=[];for(let i of e.children){let a=e.tagName!==`style`&&i.type===`text`?Ee(i,t):null;a&&i.value?.trim()&&n.push({type:`comment`,value:`${K}${a.startLine}:${a.endLine}`}),r(i,e.tagName===`style`),n.push(i)}e.children=n}};r(e)}function ke(e,t,n=new Map){ue.test(e)&&Y(t+1,`<html>、<head>、<body>はfragment内で使用できません。`);let r=ae(e,{fragment:!0}),i=we(r,t),a=
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t,r as n,t as r}from"./MermaidSurface-B2Z3pJme.js";import{C as i,E as a,O as o,P as s,S as c,T as l,_ as u,a as d,b as f,g as p,i as m,j as h,k as g,m as _,n as v,nt as y,o as b,s as x,t as S,u as C,v as w,w as T,x as E,y as D}from"./CommentThread-dsad9VaW.js";import{c as O,i as k,o as A,s as j}from"./FileIcon-AhP8Ezk9.js";import{p as ee}from"./index-CWOtOTHG.js";import{t as M}from"./lib-p2IERBh0.js";import{a as te,i as N,n as ne,o as P,r as F,t as I}from"./MarkdownTable-Clfr8wUw.js";var L={abandonedHeadElementChild:{reason:`Unexpected metadata element after head`,description:"Unexpected element after head. Expected the element before `</head>`",url:!1},abruptClosingOfEmptyComment:{reason:`Unexpected abruptly closed empty comment`,description:"Unexpected `>` or `->`. Expected `-->` to close comments"},abruptDoctypePublicIdentifier:{reason:`Unexpected abruptly closed public identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the public identifier"},abruptDoctypeSystemIdentifier:{reason:`Unexpected abruptly closed system identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the identifier identifier"},absenceOfDigitsInNumericCharacterReference:{reason:`Unexpected non-digit at start of numeric character reference`,description:"Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references"},cdataInHtmlContent:{reason:`Unexpected CDATA section in HTML`,description:"Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead"},characterReferenceOutsideUnicodeRange:{reason:`Unexpected too big numeric character reference`,description:`Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)`},closingOfElementWithOpenChildElements:{reason:`Unexpected closing tag with open child elements`,description:`Unexpectedly closing tag. Expected other tags to be closed first`,url:!1},controlCharacterInInputStream:{reason:`Unexpected control character`,description:"Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace"},controlCharacterReference:{reason:`Unexpected control character reference`,description:`Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace`},disallowedContentInNoscriptInHead:{reason:"Disallowed content inside `<noscript>` in `<head>`",description:"Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`",url:!1},duplicateAttribute:{reason:`Unexpected duplicate attribute`,description:`Unexpectedly double attribute. Expected attributes to occur only once`},endTagWithAttributes:{reason:`Unexpected attribute on closing tag`,description:"Unexpected attribute. Expected `>` instead"},endTagWithTrailingSolidus:{reason:`Unexpected slash at end of closing tag`,description:"Unexpected `%c-1`. Expected `>` instead"},endTagWithoutMatchingOpenElement:{reason:`Unexpected unopened end tag`,description:`Unexpected end tag. Expected no end tag or another end tag`,url:!1},eofBeforeTagName:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected tag name instead`},eofInCdata:{reason:`Unexpected end of file in CDATA`,description:"Unexpected end of file. Expected `]]>` to close the CDATA"},eofInComment:{reason:`Unexpected end of file in comment`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInDoctype:{reason:`Unexpected end of file in doctype`,description:"Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)"},eofInElementThatCanContainOnlyText:{reason:`Unexpected end of file in element that can only contain text`,description:`Unexpected end of file. Expected text or a closing tag`,url:!1},eofInScriptHtmlCommentLikeText:{reason:`Unexpected end of file in comment inside script`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInTag:{reason:`Unexpected end of file in tag`,description:"Unexpected end of file. Expected `>` to close the tag"},incorrectlyClosedComment:{reason:`Incorrectly closed comment`,description:"Unexpected `%c-1`. Expected `-->` to close the comment"},incorrectlyOpenedComment:{reason:`Incorrectly opened comment`,description:"Unexpected `%c`. Expected `<!--` to open the comment"},invalidCharacterSequenceAfterDoctypeName:{reason:`Invalid sequence after doctype name`,description:"Unexpected sequence at `%c`. Expected `public` or `system`"},invalidFirstCharacterOfTagName:{reason:`Invalid first character in tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},misplacedDoctype:{reason:`Misplaced doctype`,description:`Unexpected doctype. Expected doctype before head`,url:!1},misplacedStartTagForHeadElement:{reason:"Misplaced `<head>` start tag",description:"Unexpected start tag `<head>`. Expected `<head>` directly after doctype",url:!1},missingAttributeValue:{reason:`Missing attribute value`,description:"Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead"},missingDoctype:{reason:`Missing doctype before other content`,description:"Expected a `<!doctype html>` before anything else",url:!1},missingDoctypeName:{reason:`Missing doctype name`,description:"Unexpected doctype end at `%c`. Expected `html` instead"},missingDoctypePublicIdentifier:{reason:`Missing public identifier in doctype`,description:"Unexpected `%c`. Expected identifier for `public` instead"},missingDoctypeSystemIdentifier:{reason:`Missing system identifier in doctype`,description:'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'},missingEndTagName:{reason:`Missing name in end tag`,description:"Unexpected `%c`. Expected an ASCII letter instead"},missingQuoteBeforeDoctypePublicIdentifier:{reason:`Missing quote before public identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingQuoteBeforeDoctypeSystemIdentifier:{reason:`Missing quote before system identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingSemicolonAfterCharacterReference:{reason:`Missing semicolon after character reference`,description:"Unexpected `%c`. Expected `;` instead"},missingWhitespaceAfterDoctypePublicKeyword:{reason:`Missing whitespace after public identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceAfterDoctypeSystemKeyword:{reason:`Missing whitespace after system identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBeforeDoctypeName:{reason:`Missing whitespace before doctype name`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenAttributes:{reason:`Missing whitespace between attributes`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:{reason:`Missing whitespace between public and system identifiers in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},nestedComment:{reason:`Unexpected nested comment`,description:"Unexpected `<!--`. Expected `-->`"},nestedNoscriptInHead:{reason:"Unexpected nested `<noscript>` in `<head>`",description:"Unexpected `<noscript>`. Expected a closing tag or a meta element",url:!1},nonConformingDoctype:{reason:`Unexpected non-conforming doctype declaration`,description:'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',url:!1},nonVoidHtmlElementStartTagWithTrailingSolidus:{reason:`Unexpected trailing slash on start tag of non-void element`,description:"Unexpected `/`. Expected `>` instead"},noncharacterCharacterReference:{reason:`Unexpected noncharacter code point referenced by character reference`,description:`Unexpected code point. Do not use noncharacters in HTML`},noncharacterInInputStream:{reason:`Unexpected noncharacter character`,description:"Unexpected code point `%x`. Do not use noncharacters in HTML"},nullCharacterReference:{reason:`Unexpected NULL character referenced by character reference`,description:`Unexpected code point. Do not use NULL characters in HTML`},openElementsLeftAfterEof:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected closing tag instead`,url:!1},surrogateCharacterReference:{reason:`Unexpected surrogate character referenced by character reference`,description:`Unexpected code point. Do not use lone surrogate characters in HTML`},surrogateInInputStream:{reason:`Unexpected surrogate character`,description:"Unexpected code point `%x`. Do not use lone surrogate characters in HTML"},unexpectedCharacterAfterDoctypeSystemIdentifier:{reason:`Invalid character after system identifier in doctype`,description:"Unexpected character at `%c`. Expected `>`"},unexpectedCharacterInAttributeName:{reason:`Unexpected character in attribute name`,description:"Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter"},unexpectedCharacterInUnquotedAttributeValue:{reason:`Unexpected character in unquoted attribute value`,description:"Unexpected `%c`. Quote the attribute value to include it"},unexpectedEqualsSignBeforeAttributeName:{reason:`Unexpected equals sign before attribute name`,description:"Unexpected `%c`. Add an attribute name before it"},unexpectedNullCharacter:{reason:`Unexpected NULL character`,description:"Unexpected code point `%x`. Do not use NULL characters in HTML"},unexpectedQuestionMarkInsteadOfTagName:{reason:`Unexpected question mark instead of tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},unexpectedSolidusInTag:{reason:`Unexpected slash in tag`,description:"Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value"},unknownNamedCharacterReference:{reason:`Unexpected unknown named character reference`,description:`Unexpected character reference. Expected known named character references`}},R=`https://html.spec.whatwg.org/multipage/parsing.html#parse-error-`,z=/-[a-z]/g,B=/%c(?:([-+])(\d+))?/g,V=/%x/g,re={2:!0,1:!1,0:null},ie={};function ae(e,t){let n=t||ie,r=n.onerror,i=e instanceof T?e:new T(e),o=n.fragment?f:D,s=String(i),c=o(s,{sourceCodeLocationInfo:!0,onParseError:n.onerror?l:null,scriptingEnabled:!1});return E(c,{file:i,space:n.space,verbose:n.verbose});function l(e){let t=e.code,o=H(t),c=n[o]??!0,l=typeof c==`number`?c:+!!c;if(l){let n=L[o],s=new a(u(n.reason),{place:{start:{line:e.startLine,column:e.startCol,offset:e.startOffset},end:{line:e.endLine,column:e.endCol,offset:e.endOffset}},ruleId:t,source:`hast-util-from-html`});i.path&&(s.file=i.path,s.name=i.path+`:`+s.name),s.fatal=re[l],s.note=u(n.description),s.url=n.url===!1?void 0:R+t,r(s)}function u(t){return t.replace(B,n).replace(V,r);function n(t,n,r){let i=(r?Number.parseInt(r,10):0)*(n===`-`?-1:1);return U(s.charAt(e.startOffset+i))}function r(){return W(s.charCodeAt(e.startOffset))}}}}function H(e){return e.replace(z,oe)}function oe(e){return e.charAt(1).toUpperCase()}function U(e){return e==="`"?"` ` `":e}function W(e){return`0x`+e.toString(16).toUpperCase()}var G=e(O(),1),se=class extends Error{code;suggestions;status;details;constructor(e,t,n={}){super(t,n.cause===void 0?void 0:{cause:n.cause}),this.name=`RvwError`,this.code=e,this.suggestions=n.suggestions??[],this.status=n.status??400,this.details=n.details}toJSON(){return{code:this.code,message:this.message,suggestions:this.suggestions,...this.details===void 0?{}:{details:this.details}}}},ce=`rvw-ref:`,K=`rvw-source:`,q=/^[A-Za-z][A-Za-z\d+.-]*:/u,le=/^data:image\/(?:png|jpeg|gif|webp|avif);base64,[A-Za-z\d+/=\s]+$/u,ue=/<\s*\/?\s*(?:html|head|body)(?:\s|>)/iu,de=new Set(`a.article.aside.b.blockquote.br.button.caption.code.col.colgroup.dd.details.div.dl.dt.em.figcaption.figure.footer.h1.h2.h3.h4.h5.h6.header.hr.i.img.input.kbd.label.li.main.mark.nav.ol.option.p.pre.section.select.small.span.strong.style.sub.summary.sup.table.tbody.td.textarea.tfoot.th.thead.tr.ul`.split(`.`)),J=new Set([`circle`,`clipPath`,`defs`,`desc`,`ellipse`,`g`,`line`,`linearGradient`,`marker`,`mask`,`path`,`polygon`,`polyline`,`radialGradient`,`rect`,`stop`,`svg`,`symbol`,`text`,`title`,`tspan`,`use`]),fe=new Set([`audio`,`base`,`canvas`,`embed`,`frame`,`iframe`,`link`,`meta`,`object`,`script`,`video`,`foreignobject`]),pe=new Set([`article`,`aside`,`details`,`figure`,`img`,`section`,`svg`,`table`]),me=new Set([`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`,`className`,`dir`,`hidden`,`id`,`lang`,`role`,`style`,`tabIndex`,`title`]),he=new Map([[`a`,new Set([`href`,`hrefLang`])],[`blockquote`,new Set([`cite`])],[`button`,new Set([`disabled`,`name`,`type`,`value`])],[`col`,new Set([`span`,`width`])],[`details`,new Set([`open`])],[`img`,new Set([`alt`,`decoding`,`height`,`loading`,`src`,`width`])],[`input`,new Set([`accept`,`autoComplete`,`checked`,`disabled`,`max`,`maxLength`,`min`,`minLength`,`multiple`,`name`,`placeholder`,`readOnly`,`required`,`size`,`step`,`type`,`value`])],[`label`,new Set([`htmlFor`])],[`li`,new Set([`value`])],[`ol`,new Set([`reversed`,`start`,`type`])],[`option`,new Set([`disabled`,`label`,`selected`,`value`])],[`select`,new Set([`disabled`,`multiple`,`name`,`required`,`size`])],[`td`,new Set([`colSpan`,`headers`,`rowSpan`])],[`textarea`,new Set([`cols`,`disabled`,`maxLength`,`minLength`,`name`,`placeholder`,`readOnly`,`required`,`rows`,`wrap`])],[`th`,new Set([`abbr`,`colSpan`,`headers`,`rowSpan`,`scope`])]]),ge=new Set(`alignmentBaseline.clipPath.clipPathUnits.cx.cy.d.dominantBaseline.dx.dy.fill.fillOpacity.fillRule.fontFamily.fontSize.fontStyle.fontWeight.gradientTransform.gradientUnits.height.href.lengthAdjust.markerEnd.markerHeight.markerMid.markerStart.markerUnits.markerWidth.mask.maskContentUnits.maskUnits.offset.opacity.orient.pathLength.points.preserveAspectRatio.r.refX.refY.rx.ry.spreadMethod.stopColor.stopOpacity.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.textAnchor.textLength.transform.vectorEffect.viewBox.width.x.x1.x2.xmlns.y.y1.y2`.split(`.`)),_e=new Set([`clipPath`,`fill`,`markerEnd`,`markerMid`,`markerStart`,`mask`,`stroke`]);function ve(e){let t=l(e),n=[],r=e=>{if(e.type===`code`&&e.lang===`html-preview`&&typeof e.value==`string`&&e.position){let t=e.position.start.line+1;n.push({startLine:t,endLine:t+Math.max(1,e.value.split(`
|
|
2
|
+
`).length)-1})}e.children?.forEach(r)};return r(t),n}function ye(e,t){return t+(e?.start.line??1)}function Y(e,t){throw new se(`INVALID_INPUT`,`html-preview L${e}: ${t}`)}function be(e){return e.replace(/\\([\da-f]{1,6}\s?|.)/giu,(e,t)=>{let n=t.trim();if(/^[\da-f]{1,6}$/iu.test(n)){let e=Number.parseInt(n,16);return e===0||e>1114111?`�`:String.fromCodePoint(e)}return t})}function xe(e,t){let n=be(e.replace(/\/\*[\s\S]*?\*\//gu,` `)).toLowerCase().replace(/url\s*\(\s*(["']?)#[a-z_][\w:.-]*\1\s*\)/giu,`internal-fragment`);(/@import\b|@font-face\b|(?:^|[^-])url\s*\(|image-set\s*\(|(?:^|[^-])image\s*\(|expression\s*\(|-moz-binding\s*:|behavior\s*:/u.test(n)||/(?:https?|file|blob|data):|\/\//u.test(n))&&Y(t,`network resourceを参照するCSSは使用できません。`)}function X(e){let t=e.trim();if(t.length===0||t.startsWith(`#`)||t.startsWith(`?`)||t.startsWith(`//`)||q.test(t))return null;let n=t.split(/[?#]/u,1)[0];if(!n)return null;let r;try{r=decodeURIComponent(n)}catch{return null}if(r.includes(`\\`)||r.includes(`\0`))return null;let i=[];for(let e of r.split(`/`))if(!(!e||e===`.`)){if(e===`..`){if(i.length===0)return null;i.pop();continue}i.push(e)}return i.length>0?i.join(`/`):null}function Se(e,t,n){return me.has(t)||/^aria[A-Z]/u.test(t)||t===`dataRvwCommentable`||n&&ge.has(t)?!0:he.get(e)?.has(t)??!1}function Z(e,t){let n=e.properties?.[t];return typeof n==`string`?n:typeof n==`number`||typeof n==`boolean`||typeof n==`bigint`?String(n):Array.isArray(n)?n.filter(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`).map(String).join(` `):null}function Ce(e,t,n,r){let i=e.trim();if(i.toLowerCase().startsWith(ce)){n&&Y(t,`inline SVGのhrefはfragmentだけを使用できます。`),r.push(i.slice(8));return}i.startsWith(`#`)||!n&&(/^https?:/iu.test(i)||X(i))||(/^javascript:/iu.test(i)&&Y(t,`javascript: URLは使用できません。`),Y(t,n?`inline SVGのexternal hrefは使用できません。`:`link ${i} は使用できません。`))}function we(e,t){let n=[],r=[],i=new Set,a=0,o=(e,s)=>{if(e.type===`comment`){e.value?.startsWith(K)&&Y(ye(e.position,t),`内部source markerは指定できません。`);return}if(e.type===`doctype`&&Y(ye(e.position,t),`doctypeはfragment内で使用できません。`),e.type!==`element`||!e.tagName){e.children?.forEach(e=>o(e,s));return}let c=e.tagName,l=c.toLowerCase(),u=ye(e.position,t),d=s||l===`svg`;fe.has(l)&&Y(u,`<${c}> は使用できません。`),!de.has(c)&&!J.has(c)&&Y(u,`<${c}> は使用できません。`);for(let t of Object.keys(e.properties??{}))/^on/iu.test(t)&&Y(u,`${t.toLowerCase()} attribute は使用できません。`),t===`srcDoc`&&Y(u,`srcdoc attribute は使用できません。`),(/^dataRvwSource/iu.test(t)||/^dataRvw(?:Node|Text|CommentSurface)/iu.test(t))&&Y(u,`内部data-rvw-source-* attributeは指定できません。`),Se(c,t,d)||Y(u,`<${c}>の${t} attribute は使用できません。`),i.add(t);let f=Z(e,`style`);f!==null&&xe(f,u),c===`style`&&xe(e.children?.map(e=>e.value??``).join(``)??``,u);let p=Z(e,`href`);if(p!==null&&Ce(p,u,d,n),d)for(let t of _e){let n=Z(e,t);n!==null&&xe(n,u)}if(c===`img`){a+=1;let t=Z(e,`src`);if(t||Y(u,`<img>にはsrcが必要です。`),t.startsWith(`data:`))le.test(t)||Y(u,`inline imageは対応するbase64 data:imageだけを使用できます。`);else{let e=X(t);e||Y(u,`外部画像 ${t} は使用できません。`),r.push(e)}}e.children?.forEach(e=>o(e,d))};return o(e,!1),a>32&&Y(t,`画像はWalkthrough全体で32件以下にしてください。`),{referenceIds:n,repositoryImages:r,propertyNames:i,imageCount:a}}function Te(e){return{allowComments:!0,allowDoctypes:!1,ancestors:{},attributes:{"*":[...e]},clobber:[],protocols:{href:[`http`,`https`,`rvw-ref`],src:[`data`]},required:{},strip:[...fe],tagNames:[...de,...J]}}function Ee(e,t){return e.position?{startLine:t+e.position.start.line,endLine:t+e.position.end.line}:null}function De(e,t){let n=Z(e,`alt`)?.trim(),r=Z(e,`title`)?.trim();e.tagName=`span`,e.properties={className:[`rvw-html-image-placeholder`],dataRvwImagePath:t,role:`img`,ariaLabel:n||r||`Missing image: ${t}`,...r?{title:r}:{}},e.children=[{type:`text`,value:n||r||`Image unavailable: ${t}`}]}function Oe(e,t,n){let r=(e,i=!1)=>{if(e.type!==`element`||!e.tagName){if(e.children){let n=[];for(let a of e.children){let e=!i&&a.type===`text`?Ee(a,t):null;e&&a.value?.trim()&&n.push({type:`comment`,value:`${K}${e.startLine}:${e.endLine}`}),r(a,i),n.push(a)}e.children=n}return}let a=Ee(e,t);if(e.properties??={},a&&(e.properties.dataRvwSourceStartLine=a.startLine,e.properties.dataRvwSourceEndLine=a.endLine),(pe.has(e.tagName)||Object.hasOwn(e.properties,`dataRvwCommentable`))&&(e.properties.dataRvwCommentSurface=`true`),e.tagName===`img`){let t=Z(e,`src`);if(t&&!t.startsWith(`data:`)){let r=X(t),i=r?n.get(r):null;r&&i?(e.properties.src=i,e.properties.dataRvwImagePath=r):r&&De(e,r)}}if(e.children){let n=[];for(let i of e.children){let a=e.tagName!==`style`&&i.type===`text`?Ee(i,t):null;a&&i.value?.trim()&&n.push({type:`comment`,value:`${K}${a.startLine}:${a.endLine}`}),r(i,e.tagName===`style`),n.push(i)}e.children=n}};r(e)}function ke(e,t,n=new Map){ue.test(e)&&Y(t+1,`<html>、<head>、<body>はfragment内で使用できません。`);let r=ae(e,{fragment:!0}),i=we(r,t),a=u(r,Te(i.propertyNames));Oe(a,t,n);let o=Math.max(1,e.split(`
|
|
3
3
|
`).length);return{startLine:t+1,endLine:t+o,imageCount:i.imageCount,referenceIds:i.referenceIds,repositoryImages:i.repositoryImages,html:M(a)}}function Ae(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function je(e,t,n,r){return[...r].sort((e,t)=>t.length-e.length).find(r=>{let i=`${t}${r}`;return n?RegExp(`${Ae(i)}-\\d+$`).test(e):e.endsWith(i)})??null}function Q(e,t,n,r,i=!0){return Array.from(e.querySelectorAll(t)).flatMap(e=>{let t=je(e.id,n,i,r);return t?[{bindingKey:t,element:e}]:[]})}var Me={flowchart:{targets:(e,t)=>Q(e,`g.node[id]`,`-flowchart-`,t)},classDiagram:{targets:(e,t)=>Q(e,`g.node[id]`,`-classId-`,t)},sequenceDiagram:{targets:(e,t)=>{let n=new Set(t);return Array.from(e.querySelectorAll(`g[data-et="participant"][data-id]`)).flatMap(e=>{let t=e.dataset.id;return t&&n.has(t)?[{bindingKey:t,element:e}]:[]})}},"stateDiagram-v2":{targets:(e,t)=>Q(e,`g.statediagram-state[id]`,`-state-`,t)},erDiagram:{targets:(e,t)=>Q(e,`g.node[id]`,`-entity-`,t)},"architecture-beta":{targets:(e,t)=>Q(e,`g.architecture-service[id]`,`-service-`,t,!1)}};function Ne(e){for(let t of e.split(`
|
|
4
|
-
`)){let e=t.trim();if(!e||e.startsWith(`%%`))continue;let n=e.match(/^(flowchart|graph|classDiagram|sequenceDiagram|stateDiagram-v2|erDiagram|architecture-beta)\b/)?.[1];return n===`graph`?`flowchart`:n??null}return null}function Pe(e,t,n){let r=Ne(e);return r?Me[r].targets(t,n):[]}var $=
|
|
4
|
+
`)){let e=t.trim();if(!e||e.startsWith(`%%`))continue;let n=e.match(/^(flowchart|graph|classDiagram|sequenceDiagram|stateDiagram-v2|erDiagram|architecture-beta)\b/)?.[1];return n===`graph`?`flowchart`:n??null}return null}function Pe(e,t,n){let r=Ne(e);return r?Me[r].targets(t,n):[]}var $=j();function Fe({action:e,markers:t,composer:n,composerAnchor:r,onComment:i,onActivateComment:a}){let s=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{if(!n)return;let e=window.requestAnimationFrame(()=>{s.current?.scrollIntoView({block:`nearest`,inline:`nearest`})});return()=>window.cancelAnimationFrame(e)},[n]),(0,$.jsxs)(`div`,{className:`walkthrough-html-overlay`,"aria-hidden":e===null&&t.length===0&&!n,children:[t.map(e=>(0,$.jsx)(`button`,{className:`walkthrough-html-marker${e.active?` is-active`:``}`,style:{left:e.left,top:e.top},"aria-label":e.label,title:e.label,onClick:()=>a(e.id),children:(0,$.jsx)(o,{})},e.id)),e&&(0,$.jsxs)(`button`,{className:`walkthrough-html-comment-action`,style:{left:e.left,top:e.top},"aria-label":e.label,title:e.label,onPointerDown:e=>e.preventDefault(),onClick:()=>i(e),children:[(0,$.jsx)(o,{}),`コメント`]}),n&&r&&(0,$.jsx)(`div`,{ref:s,className:`walkthrough-html-comment-composer`,style:{left:r.left,top:r.top},children:n})]})}var Ie=240,Le=2e4,Re=/^rvw-source:(\d+):(\d+)$/u,ze=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/avif`,`image/svg+xml`]),Be=[`default-src 'none'`,`script-src 'none'`,`style-src 'unsafe-inline'`,`img-src data:`,`font-src 'none'`,`connect-src 'none'`,`media-src 'none'`,`object-src 'none'`,`frame-src 'none'`,`worker-src 'none'`,`base-uri 'none'`,`form-action 'none'`].join(`; `);function Ve(e){let t=`
|
|
5
5
|
--rvw-bg: #161b22;
|
|
6
6
|
--rvw-fg: #e6edf3;
|
|
7
7
|
--rvw-muted: #8b949e;
|
|
@@ -40,4 +40,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,b as n,l as r,s
|
|
|
40
40
|
<meta name="color-scheme" content="light dark">
|
|
41
41
|
<style>${He(t)}</style>
|
|
42
42
|
<div class="rvw-preview-root" data-pane-find-text>${e}</div>
|
|
43
|
-
<style>${Ue}</style>`}function Ge(e){if(!e)return null;let t=e,n=Number(t.dataset.rvwSourceStartLine),r=Number(t.dataset.rvwSourceEndLine);return!Number.isInteger(n)||!Number.isInteger(r)||n<1||r<1?null:{startLine:Math.min(n,r),endLine:Math.max(n,r)}}function Ke(e){return e&&typeof e==`object`&&`closest`in e?e:null}function qe(e,t){return e.startLine<=t.endLine&&e.endLine>=t.startLine}function Je(e){let t=0,n=e;for(;n;)t+=1,n=n.parentElement;return t}function Ye(e,t){let n=[...e.querySelectorAll(`[data-rvw-source-start-line]`)].map(e=>({element:e,range:Ge(e)})).filter(e=>e.range!==null&&qe(e.range,t));return n.sort((e,n)=>(e.range.startLine<=t.startLine&&e.range.endLine>=t.endLine?0:1)-(n.range.startLine<=t.startLine&&n.range.endLine>=t.endLine?0:1)||e.range.endLine-e.range.startLine-(n.range.endLine-n.range.startLine)||Je(n.element)-Je(e.element)),n[0]?.element??null}function Xe(e,t){let n=``,r=32768;for(let t=0;t<e.length;t+=r)n+=String.fromCharCode(...e.subarray(t,t+r));return`data:${t};base64,${window.btoa(n)}`}async function Ze(e,t,n,r){let i=[...new Set(n)],a=new Map,o=0;for(let n of i){if(o>=20971520){a.set(n,null);continue}try{let i=await fetch(D(e,t,n),{signal:r}),s=i.headers.get(`content-type`)?.split(`;`,1)[0]?.toLowerCase(),c=Number(i.headers.get(`content-length`));if(!i.ok||!s||!ze.has(s)||Number.isFinite(c)&&(c>5242880||o+c>20971520)){await i.body?.cancel(),a.set(n,null);continue}let l=new Uint8Array(await i.arrayBuffer());if(l.byteLength>5242880||o+l.byteLength>20971520){a.set(n,null);continue}o+=l.byteLength,a.set(n,Xe(l,s))}catch(e){if(r.aborted)throw e;a.set(n,null)}}return a}function Qe({source:e,fenceRange:t,pullRequestId:n,sourceOid:r,references:i,placedComments:a,activeCommentId:o,navigationLine:s,themePreference:c,commentComposer:l,onOpenReference:u,onOpenRepositoryLink:d,onCommentRange:f,onActivateComment:p}){let m=(0,G.useRef)(null),h=(0,G.useRef)(null),g=(0,G.useRef)(null),_=(0,G.useRef)(new WeakMap),[v,y]=(0,G.useState)(new Map),[b,x]=(0,G.useState)(Ie),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)(null),[E,D]=(0,G.useState)([]),O=(0,G.useMemo)(()=>{try{return{value:ke(e,t.startLine,v)}}catch(e){return{error:e instanceof Error?e.message:`HTML previewを表示できません。`}}},[t.startLine,v,e]),k=(0,G.useMemo)(()=>{try{return ke(e,t.startLine).repositoryImages}catch{return[]}},[t.startLine,e]);(0,G.useEffect)(()=>{let e=new AbortController;return y(new Map),k.length>0&&Ze(n,r,k,e.signal).then(t=>{e.signal.aborted||y(t)},()=>void 0),()=>e.abort()},[k,n,r]);let A=(0,G.useCallback)(()=>{let e=g.current,t=m.current,n=h.current,r=e?.contentDocument;if(!e||!t||!n||!r)return;let i=Math.max(r.documentElement.scrollHeight,r.body?.scrollHeight??0),s=Math.min(Le,Math.max(Ie,i));x(e=>Math.abs(e-s)<1?e:s),r.body&&(r.body.style.overflowY=i>Le?`auto`:`hidden`);let c=e.getBoundingClientRect(),l=n.getBoundingClientRect();D(a.flatMap(({comment:e,placement:t})=>{if(t.outdated||!t.range)return[];let n=Ye(r,t.range);if(!n)return[];let i=n.getBoundingClientRect();return[{id:e.id,left:c.left-l.left+i.right,top:c.top-l.top+i.top,active:e.id===o,label:`${e.id}のコメントを開く`}]}))},[o,a]);return(0,G.useLayoutEffect)(()=>{A()},[b,A]),(0,G.useEffect)(()=>{let e=g.current,t=m.current,n=h.current;if(!e||!t||!n||!O.value)return;let a=()=>void 0,o=()=>{a();let o=e.contentDocument;if(!o)return;let s=new WeakMap,c=o.createTreeWalker(o,NodeFilter.SHOW_COMMENT),l=c.nextNode();for(;l;){let e=Re.exec(l.nodeValue??``),t=l.nextSibling;e&&t?.nodeType===Node.TEXT_NODE&&s.set(t,{startLine:Number(e[1]),endLine:Number(e[2])}),l=c.nextNode()}_.current=s;let f=e=>Math.max(48,Math.min(n.clientWidth-48,e)),p=()=>{let e=o.getSelection();if(!e||e.rangeCount===0||e.isCollapsed||!e.toString().trim())return null;let t=e.getRangeAt(0),n=o.createTreeWalker(o,NodeFilter.SHOW_TEXT),r=[],i=n.nextNode();for(;i;){if(t.intersectsNode(i)){let e=s.get(i);e&&r.push(e)}i=n.nextNode()}if(r.length===0){let e=Ge((t.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?t.commonAncestorContainer:t.commonAncestorContainer.parentElement)?.closest(`[data-rvw-source-start-line]`)??null);e&&r.push(e)}return r.length===0?null:{range:{startLine:Math.min(...r.map(e=>e.startLine)),endLine:Math.max(...r.map(e=>e.endLine))},rect:t.getBoundingClientRect()}},m=()=>{let t=p();if(!t){C(null);return}let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();C({range:t.range,left:f(r.left-i.left+t.rect.left+t.rect.width/2),top:r.top-i.top+t.rect.bottom+8,label:`選択したテキストへコメント`})},h=t=>{if(o.getSelection()?.toString().trim())return;let r=Ke(t.target)?.closest(`[data-rvw-comment-surface='true']`)??null,i=Ge(r);if(!r||!i){C(null);return}let a=r.getBoundingClientRect(),s=e.getBoundingClientRect(),c=n.getBoundingClientRect();C({range:i,left:f(s.left-c.left+a.right),top:s.top-c.top+a.top,label:`このvisualへコメント`})},g=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let t=e.key.toLowerCase(),n=t===`f`&&!e.shiftKey,r=t===`p`&&!e.shiftKey,i=t===`f`&&e.shiftKey;if(!n&&!r&&!i)return;let a=new KeyboardEvent(`keydown`,{key:e.key,code:e.code,location:e.location,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,repeat:e.repeat,bubbles:!0,cancelable:!0});window.document.dispatchEvent(a)||e.preventDefault()},v=e=>{let t=Ke(e.target)?.closest(`a[href]`);if(!t)return;e.preventDefault(),e.stopPropagation();let n=t.getAttribute(`href`)?.trim()??``,a=e.metaKey||e.ctrlKey;if(n.startsWith(`rvw-ref:`)){let e=i.get(n.slice(8));e&&u(e,a);return}if(n.startsWith(`#`)){o.getElementById(n.slice(1))?.scrollIntoView({block:`center`});return}if(/^https?:/iu.test(n)){window.open(n,`_blank`,`noopener,noreferrer`);return}let s=X(n);s&&d(s,r,a)};o.addEventListener(`selectionchange`,m),o.addEventListener(`pointerup`,m),o.addEventListener(`pointermove`,h),o.addEventListener(`keydown`,g),o.addEventListener(`click`,v,!0),o.addEventListener(`toggle`,A,!0);let y=null,b=()=>{y===null&&(y=window.requestAnimationFrame(()=>{y=null,A()}))};o.addEventListener(`scroll`,b,!0);let x=[...o.images];for(let e of x)e.addEventListener(`load`,A),e.addEventListener(`error`,A);let S=new ResizeObserver(A);S.observe(o.documentElement),o.body&&S.observe(o.body);let w=new ResizeObserver(A);w.observe(t),A(),a=()=>{o.removeEventListener(`selectionchange`,m),o.removeEventListener(`pointerup`,m),o.removeEventListener(`pointermove`,h),o.removeEventListener(`keydown`,g),o.removeEventListener(`click`,v,!0),o.removeEventListener(`toggle`,A,!0),o.removeEventListener(`scroll`,b,!0),y!==null&&window.cancelAnimationFrame(y);for(let e of x)e.removeEventListener(`load`,A),e.removeEventListener(`error`,A);S.disconnect(),w.disconnect()}};return e.addEventListener(`load`,o),e.contentDocument?.readyState===`complete`&&o(),()=>{e.removeEventListener(`load`,o),a()}},[u,d,i,O.value,r,A]),(0,G.useEffect)(()=>{let e=g.current?.contentDocument;if(!e)return;for(let t of e.querySelectorAll(`.rvw-html-active-comment`))t.classList.remove(`rvw-html-active-comment`);let t=a.find(({comment:e,placement:t})=>e.id===o&&!t.outdated&&t.range)?.placement;if(!t?.range)return;let n=Ye(e,t.range);n&&(n.classList.add(`rvw-html-active-comment`),m.current?.scrollIntoView({block:`nearest`,inline:`nearest`}),n.scrollIntoView({block:`center`,inline:`nearest`}),A())},[o,a,A]),(0,G.useEffect)(()=>{if(s===null)return;let e=g.current?.contentDocument;if(!e)return;let t=Ye(e,{startLine:s,endLine:s});t&&(m.current?.scrollIntoView({block:`center`,inline:`nearest`}),t.scrollIntoView({block:`center`,inline:`nearest`}))},[s,O.value]),O.error?(0,$.jsx)(`div`,{className:`walkthrough-html-preview-error`,role:`alert`,children:O.error}):(0,$.jsxs)(`div`,{className:`walkthrough-html-preview-shell`,ref:m,"data-rvw-navigation-start-line":t.startLine,"data-rvw-navigation-end-line":t.endLine,children:[(0,$.jsxs)(`div`,{className:`walkthrough-html-preview-toolbar`,"data-pane-find-ignore":!0,children:[(0,$.jsx)(`span`,{children:`HTML preview`}),(0,$.jsx)(`span`,{children:`textまたはvisualを選択してコメント`})]}),(0,$.jsxs)(`div`,{className:`walkthrough-html-preview-frame-shell`,ref:h,onPointerLeave:()=>C(null),children:[(0,$.jsx)(`iframe`,{ref:g,title:`Walkthrough HTML preview L${t.startLine}`,"data-pane-find-child-document":!0,sandbox:`allow-same-origin`,srcDoc:We(O.value?.html??``,c),style:{height:b}}),(0,$.jsx)(Fe,{action:S,markers:E,composer:w?l(w.label):null,composerAnchor:w,onComment:e=>{g.current?.contentDocument?.getSelection()?.removeAllRanges(),C(null);let t=m.current?.clientWidth??0,n=Math.min(420,Math.max(0,t-24))/2,r=t>0?Math.max(12+n,Math.min(t-12-n,e.left)):e.left;T({...e,left:r}),f(e.range)},onActivateComment:p})]})]})}var $e=2400;function et(e){return G.Children.toArray(e).map(e=>typeof e==`string`||typeof e==`number`?String(e):(0,G.isValidElement)(e)?et(e.props.children):``).join(``)}function tt(e,t){return!!(e&&t&&e.startLine===t.startLine&&e.endLine===t.endLine)}function nt(){return(0,$.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,width:`16`,height:`16`,children:(0,$.jsx)(`path`,{fill:`currentColor`,d:`M5.5 1.75A1.75 1.75 0 0 1 7.25 0h1.5a1.75 1.75 0 0 1 1.75 1.75V2h3a.75.75 0 0 1 0 1.5h-.64l-.68 10.03A2.5 2.5 0 0 1 9.69 16H6.31a2.5 2.5 0 0 1-2.49-2.47L3.14 3.5H2.5a.75.75 0 0 1 0-1.5h3v-.25Zm1.5 0V2h2v-.25a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25ZM4.65 3.5l.67 9.96c.02.58.46 1.04.99 1.04h3.38c.53 0 .97-.46.99-1.04l.67-9.96h-6.7Z`})})}function rt({source:e,sourceRange:t,commented:n,bindings:r,references:i,themePreference:o,onOpenReference:s,onCommentRange:c,commentComposer:l,reviewContext:d}){let f=(0,G.useRef)(null),p=!!l,[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(``);(0,G.useLayoutEffect)(()=>{if(!p)return;let e=window.requestAnimationFrame(()=>{f.current?.scrollIntoView({block:`nearest`,inline:`nearest`})});return()=>window.cancelAnimationFrame(e)},[p]);let v=(0,G.useCallback)(e=>{if(!(e instanceof Element))return;let t=e.closest(`[data-walkthrough-reference-id]`)?.dataset.walkthroughReferenceId;return t?i.get(t):void 0},[i]),y=(0,G.useCallback)(t=>{for(let{bindingKey:n,element:a}of Pe(e,t,Object.keys(r))){let e=r[n],t=e?i.get(e):void 0;t&&(a.classList.add(`walkthrough-diagram-node--linked`),a.setAttribute(`role`,`button`),a.setAttribute(`tabindex`,`0`),a.setAttribute(`aria-label`,`${t.label}をコードで開く`),a.dataset.walkthroughReferenceId=t.id)}},[r,i,e]),x=t?d.placedComments.filter(({placement:e})=>tt(e.range,t)):[],C=t?{pullRequestId:d.pullRequestId,commentCount:x.length,onOpenCodeReference:d.onOpenCommentCodeReference,diagramReferenceBindings:{sourceOid:d.sourceOid,onRendered:y,referenceFromTarget:v,resolveForPeek:d.onResolveReferenceForPeek,onOpenInReview:s},renderComments:e=>(0,$.jsxs)(`div`,{className:`mermaid-diagram-comments`,children:[x.length===0&&!m&&(0,$.jsx)(`p`,{className:`mermaid-comments-empty`,children:`この diagram へのコメントはありません。`}),x.map(({comment:n,placement:r})=>(0,$.jsx)(E,{comment:n,variant:`sidebar`,draftScope:`${d.draftScope}:mermaid:${t.startLine}-${t.endLine}`,placement:r,markdownSourceOid:d.sourceOid,themePreference:o,cancelDraftOnEscape:!0,onActiveChange:d.onCommentActiveChange,onOpenCodeReference:e,onOpenRepositoryLink:d.onOpenRepositoryLink},n.id)),m?(0,$.jsx)(b,{body:g,label:`Comment on diagram`,pending:d.diagramCommentPending,error:d.diagramCommentError,validationError:void 0,placement:`line`,onBodyChange:_,onCancel:()=>{h(!1),_(``),d.onCancelDiagramComment()},onSubmit:()=>{d.onCreateExpandedDiagramComment(t,g).then(()=>{h(!1),_(``)}).catch(()=>void 0)}}):(0,$.jsxs)(`button`,{className:`mermaid-comment-action`,onClick:()=>{d.onCancelDiagramComment(),h(!0)},children:[(0,$.jsx)(u,{}),`Comment on diagram`]})]})}:void 0;return(0,$.jsx)(S,{source:e,themePreference:o,renderIdPrefix:`rvwWalkthrough`,review:C,renderInline:r=>(0,$.jsxs)(`div`,{className:`walkthrough-diagram-shell${n?` has-comment`:``}`,...t?{"data-rvw-navigation-start-line":t.startLine,"data-rvw-navigation-end-line":t.endLine}:{},children:[(0,$.jsxs)(`div`,{className:`walkthrough-diagram-toolbar`,children:[(0,$.jsx)(`span`,{children:`Mermaid diagram`}),(0,$.jsx)(`span`,{children:`強調された要素を選択してコードを開く · Cmd/Ctrlで反対のペイン`}),t&&(0,$.jsxs)(`button`,{className:`button--quiet walkthrough-diagram-comment`,onPointerDown:e=>{e.button===0&&(e.preventDefault(),c(t))},onClick:e=>{e.detail===0&&c(t)},children:[(0,$.jsx)(u,{}),`図全体へコメント`]}),r]}),(0,$.jsx)(a,{className:`walkthrough-diagram`,source:e,themePreference:o,renderIdPrefix:`rvwWalkthrough`,errorClassName:`walkthrough-diagram-error`,onRendered:y,onPointerDown:e=>{let t=v(e.target);t&&(e.preventDefault(),e.stopPropagation(),s(t,e.metaKey||e.ctrlKey))},onKeyDown:e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=v(e.target);t&&(e.preventDefault(),s(t,!1))}}),l&&(0,$.jsx)(`div`,{className:`walkthrough-diagram-comment-composer`,ref:f,children:l})]})})}var it=(0,G.createContext)(null);function at({range:e,label:t,pending:n,error:r,onCancel:i,onSubmit:a}){let[o,s]=(0,G.useState)(``),c=t??(e.startLine===e.endLine?`L${e.startLine}へコメント`:`L${e.startLine}–${e.endLine}へコメント`);return(0,$.jsx)(b,{body:o,label:c,pending:n,error:r,validationError:void 0,placement:`line`,onBodyChange:s,onCancel:i,onSubmit:()=>a(o)})}var ot=({children:e,node:t,...n})=>{let r=(0,G.useContext)(it),i=G.Children.count(e)===1?G.Children.only(e):null;if(!r||!(0,G.isValidElement)(i))return(0,$.jsx)(`pre`,{...n,children:e});let a=N(t);if(i.props.className===`language-html-preview`&&a){let e=r.diagramCommentRange&&r.diagramCommentRange.startLine>=a.startLine&&r.diagramCommentRange.endLine<=a.endLine?r.diagramCommentRange:null;return(0,$.jsx)(Qe,{source:et(i.props.children).replace(/\n$/u,``),fenceRange:a,pullRequestId:r.pullRequestId,sourceOid:r.sourceOid,references:r.references,placedComments:r.placedComments,activeCommentId:r.activeCommentId,navigationLine:r.navigationLine,themePreference:r.themePreference,onOpenReference:r.onOpenReference,onOpenRepositoryLink:r.onOpenRepositoryLink,onCommentRange:r.onCommentRange,onActivateComment:r.onActivateComment,commentComposer:t=>e?(0,$.jsx)(at,{range:e,label:t,pending:r.diagramCommentPending,error:r.diagramCommentError,onCancel:r.onCancelDiagramComment,onSubmit:t=>r.onSubmitDiagramComment(e,t)},`${e.startLine}:${e.endLine}`):null})}return i.props.className===`language-mermaid`?(0,$.jsx)(rt,{source:et(i.props.children).trim(),sourceRange:a,commented:!!(a&&r.activeCommentId&&r.placedComments.some(({comment:e,placement:t})=>e.id===r.activeCommentId&&t.range&&t.range.startLine<=a.endLine&&t.range.endLine>=a.startLine)),bindings:r.diagramBindings,references:r.references,themePreference:r.themePreference,onOpenReference:r.onOpenReference,onCommentRange:r.onCommentRange,commentComposer:a&&tt(a,r.diagramCommentRange)?(0,$.jsx)(at,{range:a,pending:r.diagramCommentPending,error:r.diagramCommentError,onCancel:r.onCancelDiagramComment,onSubmit:e=>r.onSubmitDiagramComment(a,e)},`${a.startLine}:${a.endLine}`):null,reviewContext:r}):(0,$.jsx)(`pre`,{...n,children:e})},st=(0,G.memo)(function({pullRequestId:e,body:t,diagramBindings:n,references:r,placedComments:i,activeCommentId:a,navigationLine:o,selectedRange:s,selectionComposerOpen:l,diagramCommentRange:u,markdownSourceOid:d,draftScope:p,themePreference:m,onOpenReference:g,onResolveReferenceForPeek:y,onOpenCommentCodeReference:b,onOpenRepositoryLink:S,onCommentActiveChange:C,onActivateComment:D,onCommentRange:k,diagramCommentPending:A,diagramCommentError:j,onCancelDiagramComment:ee,onSubmitDiagramComment:M,onCreateExpandedDiagramComment:N}){let ne=(0,G.useMemo)(()=>ve(t),[t]),L=(0,G.useMemo)(()=>i.filter(({placement:e})=>{let t=e.range;return!(t&&ne.some(e=>t.startLine>=e.startLine&&t.endLine<=e.endLine))}),[ne,i]),R=(0,G.useMemo)(()=>L.map(({comment:e,placement:t})=>({id:e.id,range:t.range})),[L]),z=(0,G.useMemo)(()=>new Map(L.map(({comment:e,placement:t})=>[e.id,{comment:e,placement:t}])),[L]),B=(0,G.useCallback)(({node:e,children:t,...n})=>{let r=F(e);return r.length===0?(0,$.jsx)(`div`,{...n,children:t}):(0,$.jsx)(`div`,{className:`markdown-inline-comments`,children:r.map(e=>{let t=z.get(e);return t?(0,$.jsx)(E,{comment:t.comment,variant:`inline`,draftScope:p,placement:t.placement,markdownSourceOid:d,themePreference:m,onActiveChange:C,onOpenCodeReference:b,onOpenRepositoryLink:S},e):null})})},[z,p,d,C,b,S,m]);return(0,$.jsx)(it.Provider,{value:{pullRequestId:e,sourceOid:d,diagramBindings:n,references:r,placedComments:i,activeCommentId:a,navigationLine:o,diagramCommentRange:u,themePreference:m,onOpenReference:g,onResolveReferenceForPeek:y,onOpenCommentCodeReference:b,onOpenRepositoryLink:S,onCommentActiveChange:C,onActivateComment:D,onCommentRange:k,diagramCommentPending:A,diagramCommentError:j,onCancelDiagramComment:ee,onSubmitDiagramComment:M,onCreateExpandedDiagramComment:N,draftScope:p},children:(0,$.jsx)(`article`,{className:`walkthrough-markdown`,children:(0,$.jsx)(f,{rehypePlugins:[O,[_,T],[P,{annotations:R,activeCommentId:a,selectedRange:s,composerOpen:l}]],remarkPlugins:[x],urlTransform:e=>e.startsWith(`rvw-ref:`)?e:c(e),components:{div:B,table:I,a:({href:e,children:t,node:n,...i})=>{let a=w(e),o=a?r.get(a):void 0;return o?(0,$.jsx)(h,{reference:o,className:`walkthrough-inline-reference`,onOpen:g,children:t}):(0,$.jsx)(`a`,{...te(n),...i,href:e,children:t})},img:({alt:e,title:t,node:n})=>(0,$.jsx)(v,{alt:e,title:t,sourceAttributes:te(n)}),pre:ot},children:t})})})});function ct({walkthrough:e,paneId:n,comments:a,activeCommentId:o,navigationTarget:c,onNavigationApplied:l,themePreference:f,onCommentActiveChange:p,onActivateComment:m,onOpenReference:h,onResolveReferenceForPeek:g,onOpenCommentCodeReference:_,onOpenRepositoryLink:v,onDeleted:x}){let S=s(),w=d(n,{kind:`walkthrough`,id:e.id,title:e.title,sourceOid:e.sourceOid}),T=(0,G.useRef)(null),D=(0,G.useRef)(null),O=(0,G.useRef)(l);O.current=l;let[k,A]=(0,G.useState)(!1),[j,M]=(0,G.useState)(null),[te,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(null),[I,L]=(0,G.useState)(``),[R,z]=(0,G.useState)(null),B=(0,G.useRef)(0),V=(0,G.useRef)(null),re=(0,G.useMemo)(()=>new Map(e.references.map(e=>[e.id,e])),[e.references]);(0,G.useLayoutEffect)(()=>{if(!c||D.current===c.requestId)return;let e=c.requestId,t=window.requestAnimationFrame(()=>{let t=T.current;if(!t)return;if(c.line===null){t.scrollIntoView({behavior:`auto`,block:`start`,inline:`nearest`}),D.current=e,O.current(e);return}let n=String(c.line),r=t.querySelector(`[data-rvw-navigation-start-line="${n}"]`)??t.querySelector(`[data-rvw-source-start-line="${n}"]`)??[...t.querySelectorAll(`[data-rvw-navigation-start-line]`)].find(e=>{let t=Number(e.dataset.rvwNavigationStartLine),n=Number(e.dataset.rvwNavigationEndLine);return t<=c.line&&n>=c.line}),i=r?.closest(`details:not([open])`);i&&(i.open=!0),r&&(r.scrollIntoView({behavior:`auto`,block:`center`,inline:`nearest`}),D.current=e,O.current(e))});return()=>window.cancelAnimationFrame(t)},[c]);let ie=(0,G.useCallback)((t,n)=>{B.current+=1;let r=B.current;V.current!==null&&(window.clearTimeout(V.current),V.current=null),z(null),h(e,t,n).then(e=>{r!==B.current||!e||(z(e),V.current=window.setTimeout(()=>{z(null),V.current=null},$e))})},[h,e]),ae=(0,G.useCallback)(t=>g(e,t),[g,e]);(0,G.useEffect)(()=>()=>{B.current+=1,V.current!==null&&window.clearTimeout(V.current)},[]);let H=a.filter(t=>t.target.kind===`walkthrough`&&t.target.walkthroughId===e.id),oe=H.reduce((e,t)=>e+t.posts.length,0),U=r({queryKey:[`walkthrough-comment-placements`,e.id,e.body,H.map(e=>`${e.id}:${e.updatedAt}`)],queryFn:async()=>{let n=new URLSearchParams({kind:`walkthrough`,pullRequestId:e.pullRequestId,walkthroughId:e.id});return await Promise.all(H.map(async e=>({comment:e,placement:(await t(`/api/comments/${e.id}/placement?${n.toString()}`)).placement})))},enabled:H.length>0}),W=(0,G.useMemo)(()=>U.data??[],[U.data]),se=(0,G.useMemo)(()=>W.filter(({placement:e})=>!e.outdated&&e.range!==null),[W]),ce=(0,G.useMemo)(()=>W.filter(({comment:e,placement:t})=>e.target.kind===`walkthrough`&&e.target.startLine===null||t.outdated),[W]),K=C({mutationFn:async({range:n,body:r})=>await t(`/api/comments`,i({pullRequestId:e.pullRequestId,target:{kind:`walkthrough`,walkthroughId:e.id,startLine:n?.startLine??null,endLine:n?.endLine??null},body:r,authorLabel:`You`})),onSuccess:async()=>{window.getSelection()?.removeAllRanges(),L(``),A(!1),M(null),N(null),F(null),await S.invalidateQueries({queryKey:[`comments`]}),await S.invalidateQueries({queryKey:[`change-sequence`]})}}),q=C({mutationFn:async()=>await t(`/api/pull-requests/${e.pullRequestId}/walkthroughs/${e.id}`,{...i({}),method:`DELETE`}),onSuccess:async()=>{x(e),await Promise.all([S.invalidateQueries({queryKey:[`walkthroughs`]}),S.invalidateQueries({queryKey:[`walkthrough`]}),S.invalidateQueries({queryKey:[`comments`]}),S.invalidateQueries({queryKey:[`change-sequence`]})])}}),le=H.filter(e=>e.resolvedAt===null).length,ue=()=>{let e=H.length===0?`紐づくコメントはありません。`:`紐づくコメント ${H.length}件と投稿 ${oe}件も削除されます。`;window.confirm(`このウォークスルーを削除します。\n${e}\nコピー済みの参照は無効になります。\n\nこの操作は元に戻せません。`)&&q.mutate()},de=j?j.startLine===j.endLine?`L${j.startLine}`:`L${j.startLine}–${j.endLine}`:null,J=()=>{window.getSelection()?.removeAllRanges(),K.reset(),L(``),M(null),N(null),F(null)},fe=e=>{K.reset(),L(``),A(!1),M(null),N(e),F(`diagram`)},pe=j?(0,$.jsx)(b,{body:I,label:`${de??`選択範囲`}へコメント`,pending:K.isPending,error:K.error,validationError:void 0,placement:`line`,onBodyChange:L,onCancel:J,onSubmit:()=>K.mutate({range:j,body:I})}):null,me=(0,$.jsx)(st,{pullRequestId:e.pullRequestId,body:e.body,diagramBindings:e.diagramBindings,references:re,placedComments:se,activeCommentId:o,navigationLine:c?.line??null,selectedRange:P===`selection`?j:null,selectionComposerOpen:P===`selection`,diagramCommentRange:te,markdownSourceOid:e.sourceOid,draftScope:w,themePreference:f,onOpenReference:ie,onResolveReferenceForPeek:ae,onOpenCommentCodeReference:_,onOpenRepositoryLink:v,onCommentActiveChange:p,onActivateComment:m,onCommentRange:fe,diagramCommentPending:K.isPending,diagramCommentError:K.error,onCancelDiagramComment:J,onSubmitDiagramComment:(e,t)=>K.mutate({range:e,body:t}),onCreateExpandedDiagramComment:async(e,t)=>{await K.mutateAsync({range:e,body:t})}});return(0,$.jsxs)(`div`,{className:`walkthrough-viewer`,ref:T,children:[(0,$.jsxs)(`header`,{className:`walkthrough-viewer-header`,children:[(0,$.jsxs)(`div`,{className:`walkthrough-viewer-title`,children:[(0,$.jsx)(`span`,{className:`walkthrough-viewer-icon`,children:(0,$.jsx)(ee,{})}),(0,$.jsxs)(`div`,{className:`walkthrough-viewer-heading-copy`,children:[(0,$.jsx)(`span`,{className:`walkthrough-kicker`,children:`Agent-provided walkthrough`}),(0,$.jsx)(`h2`,{title:e.title,children:e.title})]})]}),(0,$.jsxs)(`div`,{className:`walkthrough-viewer-actions`,children:[(0,$.jsxs)(`button`,{className:`comment-icon-button walkthrough-comment-button`,"aria-label":`ウォークスルー全体へコメント`,title:`ウォークスルー全体へコメント`,"aria-pressed":k,onClick:()=>{K.reset(),L(``),M(null),N(null),F(null),A(e=>!e)},children:[(0,$.jsx)(u,{}),le>0&&(0,$.jsx)(`span`,{children:le})]}),(0,$.jsx)(`button`,{className:`comment-icon-button walkthrough-delete-button`,"aria-label":`ウォークスルーを削除`,title:`ウォークスルーを削除`,disabled:q.isPending,onClick:ue,children:(0,$.jsx)(nt,{})})]}),R&&(0,$.jsx)(`div`,{className:`code-reference-notice walkthrough-reference-notice`,role:`status`,"aria-live":`polite`,children:R})]}),(0,$.jsx)(y,{error:q.error}),(0,$.jsx)(y,{error:U.error}),(k||ce.length>0)&&(0,$.jsxs)(`div`,{className:`walkthrough-comment-area`,children:[k&&(0,$.jsx)(b,{body:I,label:`ウォークスルー全体へコメント`,pending:K.isPending,error:K.error,validationError:void 0,placement:`file`,onBodyChange:L,onCancel:()=>{K.reset(),L(``),A(!1)},onSubmit:()=>K.mutate({range:null,body:I})}),ce.map(({comment:t,placement:n})=>(0,$.jsx)(E,{comment:t,variant:`inline`,draftScope:w,placement:n,markdownSourceOid:e.sourceOid,themePreference:f,onActiveChange:p,onOpenCodeReference:_,onOpenRepositoryLink:v},t.id))]}),(0,$.jsx)(ne,{className:`walkthrough-markdown-surface`,selectedRange:j,composerOpen:P===`selection`,onSelection:e=>{if(!e){M(null),F(e=>e===`selection`?null:e);return}K.reset(),L(``),A(!1),M(e),N(null),F(null)},onOpenComposer:()=>F(`selection`),composer:pe,children:(0,$.jsx)(`div`,{"data-pane-find-surface":!0,"data-pane-find-text":!0,children:me})})]})}export{ct as WalkthroughViewer};
|
|
43
|
+
<style>${Ue}</style>`}function Ge(e){if(!e)return null;let t=e,n=Number(t.dataset.rvwSourceStartLine),r=Number(t.dataset.rvwSourceEndLine);return!Number.isInteger(n)||!Number.isInteger(r)||n<1||r<1?null:{startLine:Math.min(n,r),endLine:Math.max(n,r)}}function Ke(e){return e&&typeof e==`object`&&`closest`in e?e:null}function qe(e,t){return e.startLine<=t.endLine&&e.endLine>=t.startLine}function Je(e){let t=0,n=e;for(;n;)t+=1,n=n.parentElement;return t}function Ye(e,t){let n=[...e.querySelectorAll(`[data-rvw-source-start-line]`)].map(e=>({element:e,range:Ge(e)})).filter(e=>e.range!==null&&qe(e.range,t));return n.sort((e,n)=>(e.range.startLine<=t.startLine&&e.range.endLine>=t.endLine?0:1)-(n.range.startLine<=t.startLine&&n.range.endLine>=t.endLine?0:1)||e.range.endLine-e.range.startLine-(n.range.endLine-n.range.startLine)||Je(n.element)-Je(e.element)),n[0]?.element??null}function Xe(e,t){let n=``,r=32768;for(let t=0;t<e.length;t+=r)n+=String.fromCharCode(...e.subarray(t,t+r));return`data:${t};base64,${window.btoa(n)}`}async function Ze(e,t,n,r){let i=[...new Set(n)],a=new Map,o=0;for(let n of i){if(o>=20971520){a.set(n,null);continue}try{let i=await fetch(C(e,t,n),{signal:r}),s=i.headers.get(`content-type`)?.split(`;`,1)[0]?.toLowerCase(),c=Number(i.headers.get(`content-length`));if(!i.ok||!s||!ze.has(s)||Number.isFinite(c)&&(c>5242880||o+c>20971520)){await i.body?.cancel(),a.set(n,null);continue}let l=new Uint8Array(await i.arrayBuffer());if(l.byteLength>5242880||o+l.byteLength>20971520){a.set(n,null);continue}o+=l.byteLength,a.set(n,Xe(l,s))}catch(e){if(r.aborted)throw e;a.set(n,null)}}return a}function Qe({source:e,fenceRange:t,pullRequestId:n,sourceOid:r,references:i,placedComments:a,activeCommentId:o,navigationLine:s,themePreference:c,commentComposer:l,onOpenReference:u,onOpenRepositoryLink:d,onCommentRange:f,onActivateComment:p}){let m=(0,G.useRef)(null),h=(0,G.useRef)(null),g=(0,G.useRef)(null),_=(0,G.useRef)(new WeakMap),[v,y]=(0,G.useState)(new Map),[b,x]=(0,G.useState)(Ie),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)(null),[E,D]=(0,G.useState)([]),O=(0,G.useMemo)(()=>{try{return{value:ke(e,t.startLine,v)}}catch(e){return{error:e instanceof Error?e.message:`HTML previewを表示できません。`}}},[t.startLine,v,e]),k=(0,G.useMemo)(()=>{try{return ke(e,t.startLine).repositoryImages}catch{return[]}},[t.startLine,e]);(0,G.useEffect)(()=>{let e=new AbortController;return y(new Map),k.length>0&&Ze(n,r,k,e.signal).then(t=>{e.signal.aborted||y(t)},()=>void 0),()=>e.abort()},[k,n,r]);let A=(0,G.useCallback)(()=>{let e=g.current,t=m.current,n=h.current,r=e?.contentDocument;if(!e||!t||!n||!r)return;let i=Math.max(r.documentElement.scrollHeight,r.body?.scrollHeight??0),s=Math.min(Le,Math.max(Ie,i));x(e=>Math.abs(e-s)<1?e:s),r.body&&(r.body.style.overflowY=i>Le?`auto`:`hidden`);let c=e.getBoundingClientRect(),l=n.getBoundingClientRect();D(a.flatMap(({comment:e,placement:t})=>{if(t.outdated||!t.range)return[];let n=Ye(r,t.range);if(!n)return[];let i=n.getBoundingClientRect();return[{id:e.id,left:c.left-l.left+i.right,top:c.top-l.top+i.top,active:e.id===o,label:`${e.id}のコメントを開く`}]}))},[o,a]);return(0,G.useLayoutEffect)(()=>{A()},[b,A]),(0,G.useEffect)(()=>{let e=g.current,t=m.current,n=h.current;if(!e||!t||!n||!O.value)return;let a=()=>void 0,o=()=>{a();let o=e.contentDocument;if(!o)return;let s=new WeakMap,c=o.createTreeWalker(o,NodeFilter.SHOW_COMMENT),l=c.nextNode();for(;l;){let e=Re.exec(l.nodeValue??``),t=l.nextSibling;e&&t?.nodeType===Node.TEXT_NODE&&s.set(t,{startLine:Number(e[1]),endLine:Number(e[2])}),l=c.nextNode()}_.current=s;let f=e=>Math.max(48,Math.min(n.clientWidth-48,e)),p=()=>{let e=o.getSelection();if(!e||e.rangeCount===0||e.isCollapsed||!e.toString().trim())return null;let t=e.getRangeAt(0),n=o.createTreeWalker(o,NodeFilter.SHOW_TEXT),r=[],i=n.nextNode();for(;i;){if(t.intersectsNode(i)){let e=s.get(i);e&&r.push(e)}i=n.nextNode()}if(r.length===0){let e=Ge((t.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?t.commonAncestorContainer:t.commonAncestorContainer.parentElement)?.closest(`[data-rvw-source-start-line]`)??null);e&&r.push(e)}return r.length===0?null:{range:{startLine:Math.min(...r.map(e=>e.startLine)),endLine:Math.max(...r.map(e=>e.endLine))},rect:t.getBoundingClientRect()}},m=()=>{let t=p();if(!t){C(null);return}let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();C({range:t.range,left:f(r.left-i.left+t.rect.left+t.rect.width/2),top:r.top-i.top+t.rect.bottom+8,label:`選択したテキストへコメント`})},h=t=>{if(o.getSelection()?.toString().trim())return;let r=Ke(t.target)?.closest(`[data-rvw-comment-surface='true']`)??null,i=Ge(r);if(!r||!i){C(null);return}let a=r.getBoundingClientRect(),s=e.getBoundingClientRect(),c=n.getBoundingClientRect();C({range:i,left:f(s.left-c.left+a.right),top:s.top-c.top+a.top,label:`このvisualへコメント`})},g=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let t=e.key.toLowerCase(),n=t===`f`&&!e.shiftKey,r=t===`p`&&!e.shiftKey,i=t===`f`&&e.shiftKey;if(!n&&!r&&!i)return;let a=new KeyboardEvent(`keydown`,{key:e.key,code:e.code,location:e.location,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,repeat:e.repeat,bubbles:!0,cancelable:!0});window.document.dispatchEvent(a)||e.preventDefault()},v=e=>{let t=Ke(e.target)?.closest(`a[href]`);if(!t)return;e.preventDefault(),e.stopPropagation();let n=t.getAttribute(`href`)?.trim()??``,a=e.metaKey||e.ctrlKey;if(n.startsWith(`rvw-ref:`)){let e=i.get(n.slice(8));e&&u(e,a);return}if(n.startsWith(`#`)){o.getElementById(n.slice(1))?.scrollIntoView({block:`center`});return}if(/^https?:/iu.test(n)){window.open(n,`_blank`,`noopener,noreferrer`);return}let s=X(n);s&&d(s,r,a)};o.addEventListener(`selectionchange`,m),o.addEventListener(`pointerup`,m),o.addEventListener(`pointermove`,h),o.addEventListener(`keydown`,g),o.addEventListener(`click`,v,!0),o.addEventListener(`toggle`,A,!0);let y=null,b=()=>{y===null&&(y=window.requestAnimationFrame(()=>{y=null,A()}))};o.addEventListener(`scroll`,b,!0);let x=[...o.images];for(let e of x)e.addEventListener(`load`,A),e.addEventListener(`error`,A);let S=new ResizeObserver(A);S.observe(o.documentElement),o.body&&S.observe(o.body);let w=new ResizeObserver(A);w.observe(t),A(),a=()=>{o.removeEventListener(`selectionchange`,m),o.removeEventListener(`pointerup`,m),o.removeEventListener(`pointermove`,h),o.removeEventListener(`keydown`,g),o.removeEventListener(`click`,v,!0),o.removeEventListener(`toggle`,A,!0),o.removeEventListener(`scroll`,b,!0),y!==null&&window.cancelAnimationFrame(y);for(let e of x)e.removeEventListener(`load`,A),e.removeEventListener(`error`,A);S.disconnect(),w.disconnect()}};return e.addEventListener(`load`,o),e.contentDocument?.readyState===`complete`&&o(),()=>{e.removeEventListener(`load`,o),a()}},[u,d,i,O.value,r,A]),(0,G.useEffect)(()=>{let e=g.current?.contentDocument;if(!e)return;for(let t of e.querySelectorAll(`.rvw-html-active-comment`))t.classList.remove(`rvw-html-active-comment`);let t=a.find(({comment:e,placement:t})=>e.id===o&&!t.outdated&&t.range)?.placement;if(!t?.range)return;let n=Ye(e,t.range);n&&(n.classList.add(`rvw-html-active-comment`),m.current?.scrollIntoView({block:`nearest`,inline:`nearest`}),n.scrollIntoView({block:`center`,inline:`nearest`}),A())},[o,a,A]),(0,G.useEffect)(()=>{if(s===null)return;let e=g.current?.contentDocument;if(!e)return;let t=Ye(e,{startLine:s,endLine:s});t&&(m.current?.scrollIntoView({block:`center`,inline:`nearest`}),t.scrollIntoView({block:`center`,inline:`nearest`}))},[s,O.value]),O.error?(0,$.jsx)(`div`,{className:`walkthrough-html-preview-error`,role:`alert`,children:O.error}):(0,$.jsxs)(`div`,{className:`walkthrough-html-preview-shell`,ref:m,"data-rvw-navigation-start-line":t.startLine,"data-rvw-navigation-end-line":t.endLine,children:[(0,$.jsxs)(`div`,{className:`walkthrough-html-preview-toolbar`,"data-pane-find-ignore":!0,children:[(0,$.jsx)(`span`,{children:`HTML preview`}),(0,$.jsx)(`span`,{children:`textまたはvisualを選択してコメント`})]}),(0,$.jsxs)(`div`,{className:`walkthrough-html-preview-frame-shell`,ref:h,onPointerLeave:()=>C(null),children:[(0,$.jsx)(`iframe`,{ref:g,title:`Walkthrough HTML preview L${t.startLine}`,"data-pane-find-child-document":!0,sandbox:`allow-same-origin`,srcDoc:We(O.value?.html??``,c),style:{height:b}}),(0,$.jsx)(Fe,{action:S,markers:E,composer:w?l(w.label):null,composerAnchor:w,onComment:e=>{g.current?.contentDocument?.getSelection()?.removeAllRanges(),C(null);let t=m.current?.clientWidth??0,n=Math.min(420,Math.max(0,t-24))/2,r=t>0?Math.max(12+n,Math.min(t-12-n,e.left)):e.left;T({...e,left:r}),f(e.range)},onActivateComment:p})]})]})}var $e=2400;function et(e){return G.Children.toArray(e).map(e=>typeof e==`string`||typeof e==`number`?String(e):(0,G.isValidElement)(e)?et(e.props.children):``).join(``)}function tt(e,t){return!!(e&&t&&e.startLine===t.startLine&&e.endLine===t.endLine)}function nt(){return(0,$.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,width:`16`,height:`16`,children:(0,$.jsx)(`path`,{fill:`currentColor`,d:`M5.5 1.75A1.75 1.75 0 0 1 7.25 0h1.5a1.75 1.75 0 0 1 1.75 1.75V2h3a.75.75 0 0 1 0 1.5h-.64l-.68 10.03A2.5 2.5 0 0 1 9.69 16H6.31a2.5 2.5 0 0 1-2.49-2.47L3.14 3.5H2.5a.75.75 0 0 1 0-1.5h3v-.25Zm1.5 0V2h2v-.25a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25ZM4.65 3.5l.67 9.96c.02.58.46 1.04.99 1.04h3.38c.53 0 .97-.46.99-1.04l.67-9.96h-6.7Z`})})}function rt({source:e,sourceRange:t,commented:n,bindings:i,references:a,themePreference:s,onOpenReference:c,onCommentRange:l,commentComposer:u,reviewContext:d}){let f=(0,G.useRef)(null),p=!!u,[m,h]=(0,G.useState)(!1),[_,y]=(0,G.useState)(``);(0,G.useLayoutEffect)(()=>{if(!p)return;let e=window.requestAnimationFrame(()=>{f.current?.scrollIntoView({block:`nearest`,inline:`nearest`})});return()=>window.cancelAnimationFrame(e)},[p]);let b=(0,G.useCallback)(e=>{if(!(e instanceof Element))return;let t=e.closest(`[data-walkthrough-reference-id]`)?.dataset.walkthroughReferenceId;return t?a.get(t):void 0},[a]),x=(0,G.useCallback)(t=>{for(let{bindingKey:n,element:r}of Pe(e,t,Object.keys(i))){let e=i[n],t=e?a.get(e):void 0;t&&(r.classList.add(`walkthrough-diagram-node--linked`),r.setAttribute(`role`,`button`),r.setAttribute(`tabindex`,`0`),r.setAttribute(`aria-label`,`${t.label}をコードで開く`),r.dataset.walkthroughReferenceId=t.id)}},[i,a,e]),C=t?d.placedComments.filter(({placement:e})=>tt(e.range,t)):[],w=t?{pullRequestId:d.pullRequestId,commentCount:C.length,onOpenCodeReference:d.onOpenCommentCodeReference,diagramReferenceBindings:{sourceOid:d.sourceOid,onRendered:x,referenceFromTarget:b,resolveForPeek:d.onResolveReferenceForPeek,onOpenInReview:c},renderComments:e=>(0,$.jsxs)(`div`,{className:`mermaid-diagram-comments`,children:[C.length===0&&!m&&(0,$.jsx)(`p`,{className:`mermaid-comments-empty`,children:`この diagram へのコメントはありません。`}),C.map(({comment:n,placement:r})=>(0,$.jsx)(S,{comment:n,variant:`sidebar`,draftScope:`${d.draftScope}:mermaid:${t.startLine}-${t.endLine}`,placement:r,markdownSourceOid:d.sourceOid,themePreference:s,cancelDraftOnEscape:!0,onActiveChange:d.onCommentActiveChange,onOpenCodeReference:e,onOpenRepositoryLink:d.onOpenRepositoryLink},n.id)),m?(0,$.jsx)(g,{body:_,label:`Comment on diagram`,pending:d.diagramCommentPending,error:d.diagramCommentError,validationError:void 0,placement:`line`,onBodyChange:y,onCancel:()=>{h(!1),y(``),d.onCancelDiagramComment()},onSubmit:()=>{d.onCreateExpandedDiagramComment(t,_).then(()=>{h(!1),y(``)}).catch(()=>void 0)}}):(0,$.jsxs)(`button`,{className:`mermaid-comment-action`,onClick:()=>{d.onCancelDiagramComment(),h(!0)},children:[(0,$.jsx)(o,{}),`Comment on diagram`]})]})}:void 0;return(0,$.jsx)(v,{source:e,themePreference:s,renderIdPrefix:`rvwWalkthrough`,review:w,renderInline:i=>(0,$.jsxs)(`div`,{className:`walkthrough-diagram-shell${n?` has-comment`:``}`,...t?{"data-rvw-navigation-start-line":t.startLine,"data-rvw-navigation-end-line":t.endLine}:{},children:[(0,$.jsxs)(`div`,{className:`walkthrough-diagram-toolbar`,children:[(0,$.jsx)(`span`,{children:`Mermaid diagram`}),(0,$.jsx)(`span`,{children:`強調された要素を選択してコードを開く · Cmd/Ctrlで反対のペイン`}),t&&(0,$.jsxs)(`button`,{className:`button--quiet walkthrough-diagram-comment`,onPointerDown:e=>{e.button===0&&(e.preventDefault(),l(t))},onClick:e=>{e.detail===0&&l(t)},children:[(0,$.jsx)(o,{}),`図全体へコメント`]}),i]}),(0,$.jsx)(r,{className:`walkthrough-diagram`,source:e,themePreference:s,renderIdPrefix:`rvwWalkthrough`,errorClassName:`walkthrough-diagram-error`,onRendered:x,onPointerDown:e=>{let t=b(e.target);t&&(e.preventDefault(),e.stopPropagation(),c(t,e.metaKey||e.ctrlKey))},onKeyDown:e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=b(e.target);t&&(e.preventDefault(),c(t,!1))}}),u&&(0,$.jsx)(`div`,{className:`walkthrough-diagram-comment-composer`,ref:f,children:u})]})})}var it=(0,G.createContext)(null);function at({range:e,label:t,pending:n,error:r,onCancel:i,onSubmit:a}){let[o,s]=(0,G.useState)(``),c=t??(e.startLine===e.endLine?`L${e.startLine}へコメント`:`L${e.startLine}–${e.endLine}へコメント`);return(0,$.jsx)(g,{body:o,label:c,pending:n,error:r,validationError:void 0,placement:`line`,onBodyChange:s,onCancel:i,onSubmit:()=>a(o)})}var ot=({children:e,node:t,...n})=>{let r=(0,G.useContext)(it),i=G.Children.count(e)===1?G.Children.only(e):null;if(!r||!(0,G.isValidElement)(i))return(0,$.jsx)(`pre`,{...n,children:e});let a=N(t);if(i.props.className===`language-html-preview`&&a){let e=r.diagramCommentRange&&r.diagramCommentRange.startLine>=a.startLine&&r.diagramCommentRange.endLine<=a.endLine?r.diagramCommentRange:null;return(0,$.jsx)(Qe,{source:et(i.props.children).replace(/\n$/u,``),fenceRange:a,pullRequestId:r.pullRequestId,sourceOid:r.sourceOid,references:r.references,placedComments:r.placedComments,activeCommentId:r.activeCommentId,navigationLine:r.navigationLine,themePreference:r.themePreference,onOpenReference:r.onOpenReference,onOpenRepositoryLink:r.onOpenRepositoryLink,onCommentRange:r.onCommentRange,onActivateComment:r.onActivateComment,commentComposer:t=>e?(0,$.jsx)(at,{range:e,label:t,pending:r.diagramCommentPending,error:r.diagramCommentError,onCancel:r.onCancelDiagramComment,onSubmit:t=>r.onSubmitDiagramComment(e,t)},`${e.startLine}:${e.endLine}`):null})}return i.props.className===`language-mermaid`?(0,$.jsx)(rt,{source:et(i.props.children).trim(),sourceRange:a,commented:!!(a&&r.activeCommentId&&r.placedComments.some(({comment:e,placement:t})=>e.id===r.activeCommentId&&t.range&&t.range.startLine<=a.endLine&&t.range.endLine>=a.startLine)),bindings:r.diagramBindings,references:r.references,themePreference:r.themePreference,onOpenReference:r.onOpenReference,onCommentRange:r.onCommentRange,commentComposer:a&&tt(a,r.diagramCommentRange)?(0,$.jsx)(at,{range:a,pending:r.diagramCommentPending,error:r.diagramCommentError,onCancel:r.onCancelDiagramComment,onSubmit:e=>r.onSubmitDiagramComment(a,e)},`${a.startLine}:${a.endLine}`):null,reviewContext:r}):(0,$.jsx)(`pre`,{...n,children:e})},st=(0,G.memo)(function({pullRequestId:e,body:t,diagramBindings:n,references:r,placedComments:a,activeCommentId:o,navigationLine:s,selectedRange:l,selectionComposerOpen:u,diagramCommentRange:f,markdownSourceOid:h,draftScope:g,themePreference:v,onOpenReference:y,onResolveReferenceForPeek:C,onOpenCommentCodeReference:T,onOpenRepositoryLink:E,onCommentActiveChange:D,onActivateComment:O,onCommentRange:k,diagramCommentPending:A,diagramCommentError:j,onCancelDiagramComment:ee,onSubmitDiagramComment:M,onCreateExpandedDiagramComment:N}){let ne=(0,G.useMemo)(()=>ve(t),[t]),L=(0,G.useMemo)(()=>a.filter(({placement:e})=>{let t=e.range;return!(t&&ne.some(e=>t.startLine>=e.startLine&&t.endLine<=e.endLine))}),[ne,a]),R=(0,G.useMemo)(()=>L.map(({comment:e,placement:t})=>({id:e.id,range:t.range})),[L]),z=(0,G.useMemo)(()=>new Map(L.map(({comment:e,placement:t})=>[e.id,{comment:e,placement:t}])),[L]),B=(0,G.useCallback)(({node:e,children:t,...n})=>{let r=F(e);return r.length===0?(0,$.jsx)(`div`,{...n,children:t}):(0,$.jsx)(`div`,{className:`markdown-inline-comments`,children:r.map(e=>{let t=z.get(e);return t?(0,$.jsx)(S,{comment:t.comment,variant:`inline`,draftScope:g,placement:t.placement,markdownSourceOid:h,themePreference:v,onActiveChange:D,onOpenCodeReference:T,onOpenRepositoryLink:E},e):null})})},[z,g,h,D,T,E,v]);return(0,$.jsx)(it.Provider,{value:{pullRequestId:e,sourceOid:h,diagramBindings:n,references:r,placedComments:a,activeCommentId:o,navigationLine:s,diagramCommentRange:f,themePreference:v,onOpenReference:y,onResolveReferenceForPeek:C,onOpenCommentCodeReference:T,onOpenRepositoryLink:E,onCommentActiveChange:D,onActivateComment:O,onCommentRange:k,diagramCommentPending:A,diagramCommentError:j,onCancelDiagramComment:ee,onSubmitDiagramComment:M,onCreateExpandedDiagramComment:N,draftScope:g},children:(0,$.jsx)(`article`,{className:`walkthrough-markdown`,children:(0,$.jsx)(c,{rehypePlugins:[w,[p,x],[P,{annotations:R,activeCommentId:o,selectedRange:l,composerOpen:u}]],remarkPlugins:[_],urlTransform:e=>e.startsWith(`rvw-ref:`)?e:i(e),components:{div:B,table:I,a:({href:e,children:t,node:n,...i})=>{let a=b(e),o=a?r.get(a):void 0;return o?(0,$.jsx)(d,{reference:o,className:`walkthrough-inline-reference`,onOpen:y,children:t}):(0,$.jsx)(`a`,{...te(n),...i,href:e,children:t})},img:({alt:e,title:t,node:n})=>(0,$.jsx)(m,{alt:e,title:t,sourceAttributes:te(n)}),pre:ot},children:t})})})});function ct({walkthrough:e,paneId:r,comments:i,activeCommentId:a,navigationTarget:c,onNavigationApplied:l,themePreference:u,onCommentActiveChange:d,onActivateComment:f,onOpenReference:p,onResolveReferenceForPeek:m,onOpenCommentCodeReference:_,onOpenRepositoryLink:v,onDeleted:b}){let x=t(),C=s(r,{kind:`walkthrough`,id:e.id,title:e.title,sourceOid:e.sourceOid}),w=(0,G.useRef)(null),T=(0,G.useRef)(null),E=(0,G.useRef)(l);E.current=l;let[D,O]=(0,G.useState)(!1),[j,M]=(0,G.useState)(null),[te,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(null),[I,L]=(0,G.useState)(``),[R,z]=(0,G.useState)(null),B=(0,G.useRef)(0),V=(0,G.useRef)(null),re=(0,G.useMemo)(()=>new Map(e.references.map(e=>[e.id,e])),[e.references]);(0,G.useLayoutEffect)(()=>{if(!c||T.current===c.requestId)return;let e=c.requestId,t=window.requestAnimationFrame(()=>{let t=w.current;if(!t)return;if(c.line===null){t.scrollIntoView({behavior:`auto`,block:`start`,inline:`nearest`}),T.current=e,E.current(e);return}let n=String(c.line),r=t.querySelector(`[data-rvw-navigation-start-line="${n}"]`)??t.querySelector(`[data-rvw-source-start-line="${n}"]`)??[...t.querySelectorAll(`[data-rvw-navigation-start-line]`)].find(e=>{let t=Number(e.dataset.rvwNavigationStartLine),n=Number(e.dataset.rvwNavigationEndLine);return t<=c.line&&n>=c.line}),i=r?.closest(`details:not([open])`);i&&(i.open=!0),r&&(r.scrollIntoView({behavior:`auto`,block:`center`,inline:`nearest`}),T.current=e,E.current(e))});return()=>window.cancelAnimationFrame(t)},[c]);let ie=(0,G.useCallback)((t,n)=>{B.current+=1;let r=B.current;V.current!==null&&(window.clearTimeout(V.current),V.current=null),z(null),p(e,t,n).then(e=>{r!==B.current||!e||(z(e),V.current=window.setTimeout(()=>{z(null),V.current=null},$e))})},[p,e]),ae=(0,G.useCallback)(t=>m(e,t),[m,e]);(0,G.useEffect)(()=>()=>{B.current+=1,V.current!==null&&window.clearTimeout(V.current)},[]);let H=i.filter(t=>t.target.kind===`walkthrough`&&t.target.walkthroughId===e.id),oe=H.reduce((e,t)=>e+t.posts.length,0),U=n({queryKey:[`walkthrough-comment-placements`,e.id,e.body,H.map(e=>`${e.id}:${e.updatedAt}`)],queryFn:async()=>{let t=new URLSearchParams({kind:`walkthrough`,pullRequestId:e.pullRequestId,walkthroughId:e.id});return await Promise.all(H.map(async e=>({comment:e,placement:(await k(`/api/comments/${e.id}/placement?${t.toString()}`)).placement})))},enabled:H.length>0}),W=(0,G.useMemo)(()=>U.data??[],[U.data]),se=(0,G.useMemo)(()=>W.filter(({placement:e})=>!e.outdated&&e.range!==null),[W]),ce=(0,G.useMemo)(()=>W.filter(({comment:e,placement:t})=>e.target.kind===`walkthrough`&&e.target.startLine===null||t.outdated),[W]),K=y({mutationFn:async({range:t,body:n})=>await k(`/api/comments`,A({pullRequestId:e.pullRequestId,target:{kind:`walkthrough`,walkthroughId:e.id,startLine:t?.startLine??null,endLine:t?.endLine??null},body:n,authorLabel:`You`})),onSuccess:async()=>{window.getSelection()?.removeAllRanges(),L(``),O(!1),M(null),N(null),F(null),await x.invalidateQueries({queryKey:[`comments`]}),await x.invalidateQueries({queryKey:[`change-sequence`]})}}),q=y({mutationFn:async()=>await k(`/api/pull-requests/${e.pullRequestId}/walkthroughs/${e.id}`,{...A({}),method:`DELETE`}),onSuccess:async()=>{b(e),await Promise.all([x.invalidateQueries({queryKey:[`walkthroughs`]}),x.invalidateQueries({queryKey:[`walkthrough`]}),x.invalidateQueries({queryKey:[`comments`]}),x.invalidateQueries({queryKey:[`change-sequence`]})])}}),le=H.filter(e=>e.resolvedAt===null).length,ue=()=>{let e=H.length===0?`紐づくコメントはありません。`:`紐づくコメント ${H.length}件と投稿 ${oe}件も削除されます。`;window.confirm(`このウォークスルーを削除します。\n${e}\nコピー済みの参照は無効になります。\n\nこの操作は元に戻せません。`)&&q.mutate()},de=j?j.startLine===j.endLine?`L${j.startLine}`:`L${j.startLine}–${j.endLine}`:null,J=()=>{window.getSelection()?.removeAllRanges(),K.reset(),L(``),M(null),N(null),F(null)},fe=e=>{K.reset(),L(``),O(!1),M(null),N(e),F(`diagram`)},pe=j?(0,$.jsx)(g,{body:I,label:`${de??`選択範囲`}へコメント`,pending:K.isPending,error:K.error,validationError:void 0,placement:`line`,onBodyChange:L,onCancel:J,onSubmit:()=>K.mutate({range:j,body:I})}):null,me=(0,$.jsx)(st,{pullRequestId:e.pullRequestId,body:e.body,diagramBindings:e.diagramBindings,references:re,placedComments:se,activeCommentId:a,navigationLine:c?.line??null,selectedRange:P===`selection`?j:null,selectionComposerOpen:P===`selection`,diagramCommentRange:te,markdownSourceOid:e.sourceOid,draftScope:C,themePreference:u,onOpenReference:ie,onResolveReferenceForPeek:ae,onOpenCommentCodeReference:_,onOpenRepositoryLink:v,onCommentActiveChange:d,onActivateComment:f,onCommentRange:fe,diagramCommentPending:K.isPending,diagramCommentError:K.error,onCancelDiagramComment:J,onSubmitDiagramComment:(e,t)=>K.mutate({range:e,body:t}),onCreateExpandedDiagramComment:async(e,t)=>{await K.mutateAsync({range:e,body:t})}});return(0,$.jsxs)(`div`,{className:`walkthrough-viewer`,ref:w,children:[(0,$.jsxs)(`header`,{className:`walkthrough-viewer-header`,children:[(0,$.jsxs)(`div`,{className:`walkthrough-viewer-title`,children:[(0,$.jsx)(`span`,{className:`walkthrough-viewer-icon`,children:(0,$.jsx)(ee,{})}),(0,$.jsxs)(`div`,{className:`walkthrough-viewer-heading-copy`,children:[(0,$.jsx)(`span`,{className:`walkthrough-kicker`,children:`Agent-provided walkthrough`}),(0,$.jsx)(`h2`,{title:e.title,children:e.title})]})]}),(0,$.jsxs)(`div`,{className:`walkthrough-viewer-actions`,children:[(0,$.jsxs)(`button`,{className:`comment-icon-button walkthrough-comment-button`,"aria-label":`ウォークスルー全体へコメント`,title:`ウォークスルー全体へコメント`,"aria-pressed":D,onClick:()=>{K.reset(),L(``),M(null),N(null),F(null),O(e=>!e)},children:[(0,$.jsx)(o,{}),le>0&&(0,$.jsx)(`span`,{children:le})]}),(0,$.jsx)(`button`,{className:`comment-icon-button walkthrough-delete-button`,"aria-label":`ウォークスルーを削除`,title:`ウォークスルーを削除`,disabled:q.isPending,onClick:ue,children:(0,$.jsx)(nt,{})})]}),R&&(0,$.jsx)(`div`,{className:`code-reference-notice walkthrough-reference-notice`,role:`status`,"aria-live":`polite`,children:R})]}),(0,$.jsx)(h,{error:q.error}),(0,$.jsx)(h,{error:U.error}),(D||ce.length>0)&&(0,$.jsxs)(`div`,{className:`walkthrough-comment-area`,children:[D&&(0,$.jsx)(g,{body:I,label:`ウォークスルー全体へコメント`,pending:K.isPending,error:K.error,validationError:void 0,placement:`file`,onBodyChange:L,onCancel:()=>{K.reset(),L(``),O(!1)},onSubmit:()=>K.mutate({range:null,body:I})}),ce.map(({comment:t,placement:n})=>(0,$.jsx)(S,{comment:t,variant:`inline`,draftScope:C,placement:n,markdownSourceOid:e.sourceOid,themePreference:u,onActiveChange:d,onOpenCodeReference:_,onOpenRepositoryLink:v},t.id))]}),(0,$.jsx)(ne,{className:`walkthrough-markdown-surface`,selectedRange:j,composerOpen:P===`selection`,onSelection:e=>{if(!e){M(null),F(e=>e===`selection`?null:e);return}K.reset(),L(``),O(!1),M(e),N(null),F(null)},onOpenComposer:()=>F(`selection`),composer:pe,children:(0,$.jsx)(`div`,{"data-pane-find-surface":!0,"data-pane-find-text":!0,children:me})})]})}export{ct as WalkthroughViewer};
|