review-markdown 0.1.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/bin/review-markdown.js +155 -0
- package/package.json +31 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createServer } from "http";
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
4
|
+
import { resolve } from "path";
|
|
5
|
+
import { spawn } from "child_process";
|
|
6
|
+
const TIMEOUT_MS = 30 * 60 * 1e3;
|
|
7
|
+
const CORE_BUNDLE = '!function(e){"use strict";var n,t,o,i,r,l,a,s,c,u,d,p,f={},h=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function g(e,n){for(var t in n)e[t]=n[t];return e}function x(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function m(e,n,i,r,l){var a={type:e,props:n,key:i,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==l?++o:l,__i:-1,__u:0};return null==l&&null!=t.vnode&&t.vnode(a),a}function b(e){return e.children}function y(e,n){this.props=e,this.context=n}function k(e,n){if(null==n)return e.__?k(e.__,e.__i+1):null;for(var t;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e)return t.__e;return"function"==typeof e.type?k(e):null}function w(e){if(e.__P&&e.__d){var n=e.__v,o=n.__e,i=[],r=[],l=g({},n);l.__v=n.__v+1,t.vnode&&t.vnode(l),P(e.__P,l,n,e.__n,e.__P.namespaceURI,32&n.__u?[o]:null,i,null==o?k(n):o,!!(32&n.__u),r),l.__v=n.__v,l.__.__k[l.__i]=l,O(i,l,r),n.__e=n.__=null,l.__e!=o&&q(l)}}function q(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(n){if(null!=n&&null!=n.__e)return e.__e=e.__c.base=n.__e}),q(e)}function S(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!z.__r++||l!=t.debounceRendering)&&((l=t.debounceRendering)||a)(z)}function z(){for(var e,n=1;r.length;)r.length>n&&r.sort(s),e=r.shift(),n=r.length,w(e);z.__r=0}function T(e,n,t,o,i,r,l,a,s,c,u){var d,p,_,g,x,y,w,q=o&&o.__k||h,S=n.length;for(s=function(e,n,t,o,i){var r,l,a,s,c,u=t.length,d=u,p=0;for(e.__k=new Array(i),r=0;r<i;r++)null!=(l=n[r])&&"boolean"!=typeof l&&"function"!=typeof l?("string"==typeof l||"number"==typeof l||"bigint"==typeof l||l.constructor==String?l=e.__k[r]=m(null,l,null,null,null):v(l)?l=e.__k[r]=m(b,{children:l},null,null,null):void 0===l.constructor&&l.__b>0?l=e.__k[r]=m(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[r]=l,s=r+p,l.__=e,l.__b=e.__b+1,a=null,-1!=(c=l.__i=C(l,t,s,d))&&(d--,(a=t[c])&&(a.__u|=2)),null==a||null==a.__v?(-1==c&&(i>u?p--:i<u&&p++),"function"!=typeof l.type&&(l.__u|=4)):c!=s&&(c==s-1?p--:c==s+1?p++:(c>s?p--:p++,l.__u|=4))):e.__k[r]=null;if(d)for(r=0;r<u;r++)null!=(a=t[r])&&!(2&a.__u)&&(a.__e==o&&(o=k(a)),H(a,a));return o}(t,n,q,s,S),d=0;d<S;d++)null!=(_=t.__k[d])&&(p=-1!=_.__i&&q[_.__i]||f,_.__i=d,y=P(e,_,p,i,r,l,a,s,c,u),g=_.__e,_.ref&&p.ref!=_.ref&&(p.ref&&M(p.ref,null,_),u.push(_.ref,_.__c||g,_)),null==x&&null!=g&&(x=g),(w=!!(4&_.__u))||p.__k===_.__k?s=$(_,s,e,w):"function"==typeof _.type&&void 0!==y?s=y:g&&(s=g.nextSibling),_.__u&=-7);return t.__e=x,s}function $(e,n,t,o){var i,r;if("function"==typeof e.type){for(i=e.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=e,n=$(i[r],n,t,o));return n}e.__e!=n&&(o&&(n&&e.type&&!n.parentNode&&(n=k(e)),t.insertBefore(e.__e,n||null)),n=e.__e);do{n=n&&n.nextSibling}while(null!=n&&8==n.nodeType);return n}function C(e,n,t,o){var i,r,l,a=e.key,s=e.type,c=n[t],u=null!=c&&!(2&c.__u);if(null===c&&null==a||u&&a==c.key&&s==c.type)return t;if(o>(u?1:0))for(i=t-1,r=t+1;i>=0||r<n.length;)if(null!=(c=n[l=i>=0?i--:r++])&&!(2&c.__u)&&a==c.key&&s==c.type)return l;return-1}function E(e,n,t){"-"==n[0]?e.setProperty(n,null==t?"":t):e[n]=null==t?"":"number"!=typeof t||_.test(n)?t:t+"px"}function L(e,n,t,o,i){var r,l;e:if("style"==n)if("string"==typeof t)e.style.cssText=t;else{if("string"==typeof o&&(e.style.cssText=o=""),o)for(n in o)t&&n in t||E(e.style,n,"");if(t)for(n in t)o&&t[n]==o[n]||E(e.style,n,t[n])}else if("o"==n[0]&&"n"==n[1])r=n!=(n=n.replace(c,"$1")),l=n.toLowerCase(),n=l in e||"onFocusOut"==n||"onFocusIn"==n?l.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+r]=t,t?o?t.u=o.u:(t.u=u,e.addEventListener(n,r?p:d,r)):e.removeEventListener(n,r?p:d,r);else{if("http://www.w3.org/2000/svg"==i)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&"popover"!=n&&n in e)try{e[n]=null==t?"":t;break e}catch(a){}"function"==typeof t||(null==t||!1===t&&"-"!=n[4]?e.removeAttribute(n):e.setAttribute(n,"popover"==n&&1==t?"":t))}}function N(e){return function(n){if(this.l){var o=this.l[n.type+e];if(null==n.t)n.t=u++;else if(n.t<o.u)return;return o(t.event?t.event(n):n)}}}function P(e,o,i,r,l,a,s,c,u,d){var p,_,m,w,q,S,z,$,C,E,N,P,O,M,H,I=o.type;if(void 0!==o.constructor)return null;128&i.__u&&(u=!!(32&i.__u),a=[c=o.__e=i.__e]),(p=t.__b)&&p(o);e:if("function"==typeof I)try{if($=o.props,C="prototype"in I&&I.prototype.render,E=(p=I.contextType)&&r[p.__c],N=p?E?E.props.value:p.__:r,i.__c?z=(_=o.__c=i.__c).__=_.__E:(C?o.__c=_=new I($,N):(o.__c=_=new y($,N),_.constructor=I,_.render=j),E&&E.sub(_),_.state||(_.state={}),_.__n=r,m=_.__d=!0,_.__h=[],_._sb=[]),C&&null==_.__s&&(_.__s=_.state),C&&null!=I.getDerivedStateFromProps&&(_.__s==_.state&&(_.__s=g({},_.__s)),g(_.__s,I.getDerivedStateFromProps($,_.__s))),w=_.props,q=_.state,_.__v=o,m)C&&null==I.getDerivedStateFromProps&&null!=_.componentWillMount&&_.componentWillMount(),C&&null!=_.componentDidMount&&_.__h.push(_.componentDidMount);else{if(C&&null==I.getDerivedStateFromProps&&$!==w&&null!=_.componentWillReceiveProps&&_.componentWillReceiveProps($,N),o.__v==i.__v||!_.__e&&null!=_.shouldComponentUpdate&&!1===_.shouldComponentUpdate($,_.__s,N)){o.__v!=i.__v&&(_.props=$,_.state=_.__s,_.__d=!1),o.__e=i.__e,o.__k=i.__k,o.__k.some(function(e){e&&(e.__=o)}),h.push.apply(_.__h,_._sb),_._sb=[],_.__h.length&&s.push(_);break e}null!=_.componentWillUpdate&&_.componentWillUpdate($,_.__s,N),C&&null!=_.componentDidUpdate&&_.__h.push(function(){_.componentDidUpdate(w,q,S)})}if(_.context=N,_.props=$,_.__P=e,_.__e=!1,P=t.__r,O=0,C)_.state=_.__s,_.__d=!1,P&&P(o),p=_.render(_.props,_.state,_.context),h.push.apply(_.__h,_._sb),_._sb=[];else do{_.__d=!1,P&&P(o),p=_.render(_.props,_.state,_.context),_.state=_.__s}while(_.__d&&++O<25);_.state=_.__s,null!=_.getChildContext&&(r=g(g({},r),_.getChildContext())),C&&!m&&null!=_.getSnapshotBeforeUpdate&&(S=_.getSnapshotBeforeUpdate(w,q)),M=null!=p&&p.type===b&&null==p.key?U(p.props.children):p,c=T(e,v(M)?M:[M],o,i,r,l,a,s,c,u,d),_.base=o.__e,o.__u&=-161,_.__h.length&&s.push(_),z&&(_.__E=_.__=null)}catch(F){if(o.__v=null,u||null!=a)if(F.then){for(o.__u|=u?160:128;c&&8==c.nodeType&&c.nextSibling;)c=c.nextSibling;a[a.indexOf(c)]=null,o.__e=c}else{for(H=a.length;H--;)x(a[H]);A(o)}else o.__e=i.__e,o.__k=i.__k,F.then||A(o);t.__e(F,o,i)}else null==a&&o.__v==i.__v?(o.__k=i.__k,o.__e=i.__e):c=o.__e=function(e,o,i,r,l,a,s,c,u){var d,p,h,_,g,m,b,y=i.props||f,w=o.props,q=o.type;if("svg"==q?l="http://www.w3.org/2000/svg":"math"==q?l="http://www.w3.org/1998/Math/MathML":l||(l="http://www.w3.org/1999/xhtml"),null!=a)for(d=0;d<a.length;d++)if((g=a[d])&&"setAttribute"in g==!!q&&(q?g.localName==q:3==g.nodeType)){e=g,a[d]=null;break}if(null==e){if(null==q)return document.createTextNode(w);e=document.createElementNS(l,q,w.is&&w),c&&(t.__m&&t.__m(o,a),c=!1),a=null}if(null==q)y===w||c&&e.data==w||(e.data=w);else{if(a=a&&n.call(e.childNodes),!c&&null!=a)for(y={},d=0;d<e.attributes.length;d++)y[(g=e.attributes[d]).name]=g.value;for(d in y)g=y[d],"dangerouslySetInnerHTML"==d?h=g:"children"==d||d in w||"value"==d&&"defaultValue"in w||"checked"==d&&"defaultChecked"in w||L(e,d,null,g,l);for(d in w)g=w[d],"children"==d?_=g:"dangerouslySetInnerHTML"==d?p=g:"value"==d?m=g:"checked"==d?b=g:c&&"function"!=typeof g||y[d]===g||L(e,d,g,y[d],l);if(p)c||h&&(p.__html==h.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),o.__k=[];else if(h&&(e.innerHTML=""),T("template"==o.type?e.content:e,v(_)?_:[_],o,i,r,"foreignObject"==q?"http://www.w3.org/1999/xhtml":l,a,s,a?a[0]:i.__k&&k(i,0),c,u),null!=a)for(d=a.length;d--;)x(a[d]);c||(d="value","progress"==q&&null==m?e.removeAttribute("value"):null!=m&&(m!==e[d]||"progress"==q&&!m||"option"==q&&m!=y[d])&&L(e,d,m,y[d],l),d="checked",null!=b&&b!=e[d]&&L(e,d,b,y[d],l))}return e}(i.__e,o,i,r,l,a,s,u,d);return(p=t.diffed)&&p(o),128&o.__u?void 0:c}function A(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(A))}function O(e,n,o){for(var i=0;i<o.length;i++)M(o[i],o[++i],o[++i]);t.__c&&t.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(o){t.__e(o,n.__v)}})}function U(e){return"object"!=typeof e||null==e||e.__b>0?e:v(e)?e.map(U):g({},e)}function M(e,n,o){try{if("function"==typeof e){var i="function"==typeof e.__u;i&&e.__u(),i&&null==n||(e.__u=e(n))}else e.current=n}catch(r){t.__e(r,o)}}function H(e,n,o){var i,r;if(t.unmount&&t.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||M(i,null,n)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(l){t.__e(l,n)}i.base=i.__P=null}if(i=e.__k)for(r=0;r<i.length;r++)i[r]&&H(i[r],n,o||"function"!=typeof e.type);o||x(e.__e),e.__c=e.__=e.__e=void 0}function j(e,n,t){return this.constructor(e,t)}function I(e,o,i){var r,l,a;o==document&&(o=document.documentElement),t.__&&t.__(e,o),r=!1?null:o.__k,l=[],a=[],P(o,e=o.__k=function(e,t,o){var i,r,l,a={};for(l in t)"key"==l?i=t[l]:"ref"==l?r=t[l]:a[l]=t[l];if(arguments.length>2&&(a.children=arguments.length>3?n.call(arguments,2):o),"function"==typeof e&&null!=e.defaultProps)for(l in e.defaultProps)void 0===a[l]&&(a[l]=e.defaultProps[l]);return m(e,a,i,r,null)}(b,null,[e]),r||f,f,o.namespaceURI,r?null:o.firstChild?n.call(o.childNodes):null,l,r?r.__e:o.firstChild,false,a),O(l,e,a)}n=h.slice,t={__e:function(e,n,t,o){for(var i,r,l;n=n.__;)if((i=n.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(e)),l=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,o||{}),l=i.__d),l)return i.__E=i}catch(a){e=a}throw e}},o=0,i=function(e){return null!=e&&void 0===e.constructor},y.prototype.setState=function(e,n){var t;t=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=g({},this.state),"function"==typeof e&&(e=e(g({},t),this.props)),e&&g(t,e),null!=e&&this.__v&&(n&&this._sb.push(n),S(this))},y.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),S(this))},y.prototype.render=b,r=[],a="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,n){return e.__v.__b-n.__v.__b},z.__r=0,c=/(PointerCapture)$|Capture$/i,u=0,d=N(!1),p=N(!0);var F=0;function R(e,n,o,i,r,l){n||(n={});var a,s,c=n;if("ref"in c)for(s in c={},n)"ref"==s?a=n[s]:c[s]=n[s];var u={type:e,props:c,key:o,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--F,__i:-1,__u:0,__source:r,__self:l};if("function"==typeof e&&(a=e.defaultProps))for(s in a)void 0===c[s]&&(c[s]=a[s]);return t.vnode&&t.vnode(u),u}const D=new Set(["question:open","question:choice","question:checkbox"]);function W(e,n,t,o){const i=e.split(":")[1],r={};for(const a of n.split("\\n")){const e=a.match(/^(\\w+):\\s*(.*)/);e&&(r[e[1]]=e[2].trim())}const l={type:"question",qtype:i,id:r.id??"",question:r.question??"",content:n,lineStart:t,lineEnd:o};return r.options&&(l.options=r.options.split("|").map(e=>e.trim())),l}function B(e){const n=e.split("\\n"),t=[];let o=0;for(;o<n.length;){const e=n[o];if(""===e.trim()){o++;continue}const i=e.match(/^```(\\S*)/);if(i){const e=i[1],r=o;o++;const l=[];for(;o<n.length&&!n[o].startsWith("```");)l.push(n[o]),o++;const a=o;o<n.length&&o++;const s=l.join("\\n");D.has(e)?t.push(W(e,s,r,a)):t.push({type:"code",lang:e||"",content:s,lineStart:r,lineEnd:a});continue}const r=e.match(/^###\\s+(.*)/);if(r){t.push({type:"h3",content:r[1],lineStart:o,lineEnd:o}),o++;continue}const l=e.match(/^##\\s+(.*)/);if(l){t.push({type:"h2",content:l[1],lineStart:o,lineEnd:o}),o++;continue}const a=e.match(/^#\\s+(.*)/);if(a){t.push({type:"h1",content:a[1],lineStart:o,lineEnd:o}),o++;continue}const s=e.match(/^-\\s+(.*)/);if(s){t.push({type:"li",content:s[1],lineStart:o,lineEnd:o}),o++;continue}const c=e.match(/^\\d+[.)]\\s+(.*)/);if(c){t.push({type:"ol",content:c[1],lineStart:o,lineEnd:o}),o++;continue}const u=e.match(/^>\\s?(.*)/);u?(t.push({type:"quote",content:u[1],lineStart:o,lineEnd:o}),o++):(t.push({type:"p",content:e,lineStart:o,lineEnd:o}),o++)}return t}var K,G,X,V,Q=0,Y=[],J=t,Z=J.__b,ee=J.__r,ne=J.diffed,te=J.__c,oe=J.unmount,ie=J.__;function re(e,n){J.__h&&J.__h(G,e,Q||n),Q=0;var t=G.__H||(G.__H={__:[],__h:[]});return e>=t.__.length&&t.__.push({}),t.__[e]}function le(e){return Q=1,function(e,n){var t=re(K++,2);if(t.t=e,!t.__c&&(t.__=[ve(void 0,n),function(e){var n=t.__N?t.__N[0]:t.__[0],o=t.t(n,e);n!==o&&(t.__N=[o,t.__[1]],t.__c.setState({}))}],t.__c=G,!G.__f)){var o=function(e,n,o){if(!t.__c.__H)return!0;var r=t.__c.__H.__.filter(function(e){return e.__c});if(r.every(function(e){return!e.__N}))return!i||i.call(this,e,n,o);var l=t.__c.props!==e;return r.some(function(e){if(e.__N){var n=e.__[0];e.__=e.__N,e.__N=void 0,n!==e.__[0]&&(l=!0)}}),i&&i.call(this,e,n,o)||l};G.__f=!0;var i=G.shouldComponentUpdate,r=G.componentWillUpdate;G.componentWillUpdate=function(e,n,t){if(this.__e){var l=i;i=void 0,o(e,n,t),i=l}r&&r.call(this,e,n,t)},G.shouldComponentUpdate=o}return t.__N||t.__}(ve,e)}function ae(e,n){var t=re(K++,3);!J.__s&&_e(t.__H,n)&&(t.__=e,t.u=n,G.__H.__h.push(t))}function se(e){return Q=5,ce(function(){return{current:e}},[])}function ce(e,n){var t=re(K++,7);return _e(t.__H,n)&&(t.__=e(),t.__H=n,t.__h=e),t.__}function ue(){for(var e;e=Y.shift();){var n=e.__H;if(e.__P&&n)try{n.__h.some(fe),n.__h.some(he),n.__h=[]}catch(t){n.__h=[],J.__e(t,e.__v)}}}J.__b=function(e){G=null,Z&&Z(e)},J.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),ie&&ie(e,n)},J.__r=function(e){ee&&ee(e),K=0;var n=(G=e.__c).__H;n&&(X===G?(n.__h=[],G.__h=[],n.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(n.__h.some(fe),n.__h.some(he),n.__h=[],K=0)),X=G},J.diffed=function(e){ne&&ne(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(1!==Y.push(n)&&V===J.requestAnimationFrame||((V=J.requestAnimationFrame)||pe)(ue)),n.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),X=G=null},J.__c=function(e,n){n.some(function(e){try{e.__h.some(fe),e.__h=e.__h.filter(function(e){return!e.__||he(e)})}catch(t){n.some(function(e){e.__h&&(e.__h=[])}),n=[],J.__e(t,e.__v)}}),te&&te(e,n)},J.unmount=function(e){oe&&oe(e);var n,t=e.__c;t&&t.__H&&(t.__H.__.some(function(e){try{fe(e)}catch(t){n=t}}),t.__H=void 0,n&&J.__e(n,t.__v))};var de="function"==typeof requestAnimationFrame;function pe(e){var n,t=function(){clearTimeout(o),de&&cancelAnimationFrame(n),setTimeout(e)},o=setTimeout(t,35);de&&(n=requestAnimationFrame(t))}function fe(e){var n=G,t=e.__c;"function"==typeof t&&(e.__c=void 0,t()),G=n}function he(e){var n=G;e.__c=e.__(),G=n}function _e(e,n){return!e||e.length!==n.length||n.some(function(n,t){return n!==e[t]})}function ve(e,n){return"function"==typeof n?n(e):n}var ge=Symbol.for("preact-signals");function xe(){if(ke>1)ke--;else{for(var e,n=!1;void 0!==ye;){var t=ye;for(ye=void 0,we++;void 0!==t;){var o=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&$e(t))try{t.c()}catch(i){n||(e=i,n=!0)}t=o}}if(we=0,ke--,n)throw e}}var me=void 0;function be(e){var n=me;me=void 0;try{return e()}finally{me=n}}var ye=void 0,ke=0,we=0,qe=0;function Se(e){if(void 0!==me){var n=e.n;if(void 0===n||n.t!==me)return n={i:0,S:e,p:me.s,n:void 0,t:me,e:void 0,x:void 0,r:n},void 0!==me.s&&(me.s.n=n),me.s=n,e.n=n,32&me.f&&e.S(n),n;if(-1===n.i)return n.i=0,void 0!==n.n&&(n.n.p=n.p,void 0!==n.p&&(n.p.n=n.n),n.p=me.s,n.n=void 0,me.s.n=n,me.s=n),n}}function ze(e,n){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function Te(e,n){return new ze(e,n)}function $e(e){for(var n=e.s;void 0!==n;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function Ce(e){for(var n=e.s;void 0!==n;n=n.n){var t=n.S.n;if(void 0!==t&&(n.r=t),n.S.n=n,n.i=-1,void 0===n.n){e.s=n;break}}}function Ee(e){for(var n=e.s,t=void 0;void 0!==n;){var o=n.p;-1===n.i?(n.S.U(n),void 0!==o&&(o.n=n.n),void 0!==n.n&&(n.n.p=o)):t=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=o}e.s=t}function Le(e,n){ze.call(this,void 0),this.x=e,this.s=void 0,this.g=qe-1,this.f=4,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function Ne(e,n){return new Le(e,n)}function Pe(e){var n=e.u;if(e.u=void 0,"function"==typeof n){ke++;var t=me;me=void 0;try{n()}catch(o){throw e.f&=-2,e.f|=8,Ae(e),o}finally{me=t,xe()}}}function Ae(e){for(var n=e.s;void 0!==n;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,Pe(e)}function Oe(e){if(me!==this)throw new Error("Out-of-order effect");Ee(this),me=e,this.f&=-2,8&this.f&&Ae(this),xe()}function Ue(e,n){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==n?void 0:n.name}function Me(e,n){var t=new Ue(e,n);try{t.c()}catch(i){throw t.d(),i}var o=t.d.bind(t);return o[Symbol.dispose]=o,o}ze.prototype.brand=ge,ze.prototype.h=function(){return!0},ze.prototype.S=function(e){var n=this,t=this.t;t!==e&&void 0===e.e&&(e.x=t,this.t=e,void 0!==t?t.e=e:be(function(){var e;null==(e=n.W)||e.call(n)}))},ze.prototype.U=function(e){var n=this;if(void 0!==this.t){var t=e.e,o=e.x;void 0!==t&&(t.x=o,e.e=void 0),void 0!==o&&(o.e=t,e.x=void 0),e===this.t&&(this.t=o,void 0===o&&be(function(){var e;null==(e=n.Z)||e.call(n)}))}},ze.prototype.subscribe=function(e){var n=this;return Me(function(){var t=n.value,o=me;me=void 0;try{e(t)}finally{me=o}},{name:"sub"})},ze.prototype.valueOf=function(){return this.value},ze.prototype.toString=function(){return this.value+""},ze.prototype.toJSON=function(){return this.value},ze.prototype.peek=function(){var e=me;me=void 0;try{return this.value}finally{me=e}},Object.defineProperty(ze.prototype,"value",{get:function(){var e=Se(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(we>100)throw new Error("Cycle detected");this.v=e,this.i++,qe++,ke++;try{for(var n=this.t;void 0!==n;n=n.x)n.t.N()}finally{xe()}}}}),Le.prototype=new ze,Le.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===qe)return!0;if(this.g=qe,this.f|=1,this.i>0&&!$e(this))return this.f&=-2,!0;var e=me;try{Ce(this),me=this;var n=this.x();(16&this.f||this.v!==n||0===this.i)&&(this.v=n,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return me=e,Ee(this),this.f&=-2,!0},Le.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var n=this.s;void 0!==n;n=n.n)n.S.S(n)}ze.prototype.S.call(this,e)},Le.prototype.U=function(e){if(void 0!==this.t&&(ze.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var n=this.s;void 0!==n;n=n.n)n.S.U(n)}},Le.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(Le.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Se(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Ue.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var n=this.x();"function"==typeof n&&(this.u=n)}finally{e()}},Ue.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Pe(this),Ce(this),ke++;var e=me;return me=this,Oe.bind(this,e)},Ue.prototype.N=function(){2&this.f||(this.f|=2,this.o=ye,ye=this)},Ue.prototype.d=function(){this.f|=8,1&this.f||Ae(this)},Ue.prototype.dispose=function(){this.d()};var He,je,Ie="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__,Fe=[];function Re(e,n){t[e]=n.bind(null,t[e]||function(){})}function De(e){if(je){var n=je;je=void 0,n()}je=e&&e.S()}function We(e){var n=this,t=e.data,o=function(e,n){return ce(function(){return Te(e,n)},[])}(t);o.value=t;var r=ce(function(){for(var e=n,t=n.__v;t=t.__;)if(t.__c){t.__c.__$f|=4;break}var r=Ne(function(){var e=o.value.value;return 0===e?0:!0===e?"":e||""}),l=Ne(function(){return!Array.isArray(r.value)&&!i(r.value)}),a=Me(function(){if(this.N=Xe,l.value){var n=r.value;e.__v&&e.__v.__e&&3===e.__v.__e.nodeType&&(e.__v.__e.data=n)}}),s=n.__$u.d;return n.__$u.d=function(){a(),s.call(this)},[l,r]},[]),l=r[0],a=r[1];return l.value?a.peek():a.value}function Be(e,n,t,o){var i=n in e&&void 0===e.ownerSVGElement,r=Te(t),l=t.peek();return{o:function(e,n){r.value=e,l=e.peek()},d:Me(function(){this.N=Xe;var t=r.value.value;l!==t?(l=void 0,i?e[n]=t:null==t||!1===t&&"-"!==n[4]?e.removeAttribute(n):e.setAttribute(n,t)):l=void 0})}}Me(function(){He=this.N})(),We.displayName="ReactiveTextNode",Object.defineProperties(ze.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:We},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Re("__b",function(e,n){if("string"==typeof n.type){var t,o=n.props;for(var i in o)if("children"!==i){var r=o[i];r instanceof ze&&(t||(n.__np=t={}),t[i]=r,o[i]=r.peek())}}e(n)}),Re("__r",function(e,n){if(e(n),n.type!==b){De();var t,o=n.__c;o&&(o.__$f&=-2,void 0===(t=o.__$u)&&(o.__$u=(Me(function(){i=this},{name:"function"==typeof n.type?n.type.displayName||n.type.name:""}),i.c=function(){var e;Ie&&(null==(e=t.y)||e.call(t)),o.__$f|=1,o.setState({})},t=i))),De(t)}var i}),Re("__e",function(e,n,t,o){De(),e(n,t,o)}),Re("diffed",function(e,n){var t;if(De(),"string"==typeof n.type&&(t=n.__e)){var o=n.__np,i=n.props;if(o){var r=t.U;if(r)for(var l in r){var a=r[l];void 0===a||l in o||(a.d(),r[l]=void 0)}else r={},t.U=r;for(var s in o){var c=r[s],u=o[s];void 0===c?(c=Be(t,s,u),r[s]=c):c.o(u,i)}for(var d in o)i[d]=o[d]}}e(n)}),Re("unmount",function(e,n){if("string"==typeof n.type){var t=n.__e;if(t){var o=t.U;if(o)for(var i in t.U=void 0,o){var r=o[i];r&&r.d()}}n.__np=void 0}else{var l=n.__c;if(l){var a=l.__$u;a&&(l.__$u=void 0,a.d())}}e(n)}),Re("__h",function(e,n,t,o){(o<3||9===o)&&(n.__$f|=2),e(n,t,o)}),y.prototype.shouldComponentUpdate=function(e,n){if(this.__R)return!0;var t=this.__$u,o=t&&void 0!==t.s;for(var i in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){var r=2&this.__$f;if(!(o||r||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(o||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var l in e)if("__source"!==l&&e[l]!==this.props[l])return!0;for(var a in this.props)if(!(a in e))return!0;return!1};var Ke=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Ge(){!function(e){if(ke>0)return e();ke++;try{return e()}finally{xe()}}(function(){for(var e;e=Fe.shift();)He.call(e)})}function Xe(){1===Fe.push(this)&&(t.requestAnimationFrame||Ke)(Ge)}const Ve=Te([]),Qe=Te({}),Ye=Te([]),Je=Te({}),Ze=Te({}),en=Te({}),nn=Te("download"),tn=Te(""),on=Te(null),rn=Te(!1),ln=Te(null),an=Te(void 0),sn=Te(!1),cn=Te(!1),un=Te(""),dn=Te(!1),pn=Ne(()=>Ve.value.filter(e=>"question"===e.type&&!Ze.value[e.id])),fn=Ne(()=>pn.value.filter(e=>{const n=Je.value[e.id];return n&&!n._draft}).length),hn=Ne(()=>Object.keys(Qe.value).length+Ye.value.length),_n=Ne(()=>hn.value+fn.value);function vn(e){un.value=e,dn.value=!0,setTimeout(()=>{dn.value=!1},2e3)}function gn(){return"undefined"!=typeof window&&window.innerWidth>=800}function xn(){Qe.value={},Ye.value=[],Je.value={},Ze.value={},en.value={},rn.value=!1,ln.value=null,an.value=void 0,sn.value=!1,cn.value=!1}const mn={typescript:[{re:/(\\/\\/.*)/g,cls:"cmt"},{re:/\\b(export|const|return|function|type|interface|async|await|import|from)\\b/g,cls:"kw"},{re:/\\b(string|number|boolean|JWT|UserRole|void)\\b/g,cls:"typ"},{re:/("[^"]*"|\'[^\']*\'|`[^`]*`)/g,cls:"str"},{re:/\\b(\\d+m?)\\b/g,cls:"num"}],python:[{re:/(#.*)/g,cls:"cmt"},{re:/\\b(def|return|try|except|raise|if|else|import|from)\\b/g,cls:"kw"},{re:/\\b(Optional|Payload|str|int|bool)\\b/g,cls:"typ"},{re:/("[^"]*"|\'[^\']*\')/g,cls:"str"},{re:/\\b(\\d+)\\b/g,cls:"num"}]};function bn(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function yn(e,n){const t=mn[n]||mn.typescript,o=[];for(const s of t){const n=new RegExp(s.re.source,s.re.flags);let t;for(;null!==(t=n.exec(e));)o.push({start:t.index,end:t.index+t[0].length,text:t[0],cls:s.cls})}o.sort((e,n)=>e.start-n.start||n.end-n.start-(e.end-e.start));const i=[];let r=0;for(const s of o)s.start>=r&&(i.push(s),r=s.end);let l="",a=0;for(const s of i)s.start>a&&(l+=bn(e.slice(a,s.start))),l+=`<span class="syn-${s.cls}">${bn(s.text)}</span>`,a=s.end;return a<e.length&&(l+=bn(e.slice(a))),l}function kn(e){let n=bn(e);return n=n.replace(/\\*\\*(.+?)\\*\\*/g,"<strong>$1</strong>"),n=n.replace(/`(.+?)`/g,\'<code class="inline">$1</code>\'),n}function wn(e){ln.value=e,an.value=void 0,rn.value=!0}function qn({el:e,index:n}){const t=!!Qe.value[n];if("code"===e.type){const o=e;return R("div",{class:"block",id:`el-${n}`,onClick:()=>wn(n),style:{padding:0,margin:"2px -6px"},children:R("div",{class:"code-wrap",children:[t&&R("div",{class:"ann-dot",style:{position:"absolute",right:"8px",top:"8px",zIndex:2}}),R("div",{class:"code-header",children:[R("span",{class:"code-lang",children:bn(o.lang||"")}),R("button",{class:"code-copy",onClick:e=>{var n;e.stopPropagation(),n=o.content,navigator.clipboard.writeText(n).catch(()=>{})},children:"copy"})]}),R("div",{class:"code-body",dangerouslySetInnerHTML:{__html:yn(o.content,o.lang)}})]})})}return R("div",{class:`block el-${e.type}`,id:`el-${n}`,onClick:()=>wn(n),children:[t&&R("div",{class:"ann-dot"}),R("span",{dangerouslySetInnerHTML:{__html:kn(e.content)}})]})}function Sn(e){Ve.value.find(n=>"question"===n.type&&!Ze.value[n.id]&&!Je.value[n.id]&&n.id!==e)&&setTimeout(()=>{const e=document.querySelectorAll(".q-block.unanswered");e.length&&e[0].scrollIntoView({behavior:"smooth",block:"center"})},100)}function zn({el:e}){const n=Je.value[e.id]||{},t=se(null),o=se(null),[i,r]=le(!1);if("open"===e.qtype){const o=n.text||"";return R("div",{children:[R("textarea",{class:"q-textarea",rows:3,ref:t,placeholder:"Type your answer…",defaultValue:o,onInput:()=>{t.current&&r(t.current.value.trim().length>0)}}),R("button",{class:"q-submit "+(i||o.trim().length>0?"active":"inactive"),onClick:()=>{var n;return function(e,n){if(!n.trim())return;Je.value={...Je.value,[e]:{text:n.trim()}};const{[e]:t,...o}=en.value;en.value=o,vn("Answer saved ✓"),Sn(e)}(e.id,(null==(n=t.current)?void 0:n.value)||"")},children:"Submit"}),R("div",{style:{clear:"both"}})]})}const l=[...e.options||[],"Other"],a="choice"===e.qtype,s=a?n.choice||n.showOther&&(n.otherText||"").trim():(n.checked||[]).length>0||n.showOther&&(n.otherText||"").trim();return R("div",{children:[l.map((t,i)=>{const r="Other"===t;let l=!1;return l=a?n.choice===t||r&&!!n.showOther:(n.checked||[]).includes(t)||r&&!!n.showOther,R("div",{children:[R("div",{class:"q-option "+(l?"selected":""),onClick:()=>function(e,n,t,o,i){const r=[...i,"Other"][t],l={...Je.value[e]||{},_draft:!0};if("choice"===n)o?(l.choice=void 0,l.showOther=!0):(l.choice=r,l.showOther=!1,l.otherText="");else if(l.checked?l.checked=[...l.checked]:l.checked=[],o)l.showOther=!l.showOther,l.showOther||(l.otherText="");else{const e=l.checked.indexOf(r);e>=0?l.checked.splice(e,1):l.checked.push(r)}Je.value={...Je.value,[e]:l}}(e.id,e.qtype,i,r,e.options||[]),children:[R("div",a?{class:"q-radio",children:R("div",{class:"q-radio-inner"})}:{class:"q-check",children:l?"✓":""}),R("span",{children:bn(t)})]}),r&&l&&R("input",{class:"q-other-input",ref:o,placeholder:"Specify…",value:n.otherText||"",onClick:e=>e.stopPropagation(),onInput:()=>{if(o.current){const n=o.current.value;Je.value={...Je.value,[e.id]:{...Je.value[e.id],otherText:n}}}}})]},i)}),R("button",{class:"q-submit "+(s?"active":"inactive"),onClick:()=>{var n;return function(e,n,t){const o=Je.value[e];if(!o)return;const i={...o};if(void 0!==t&&(i.otherText=t),delete i._draft,!("choice"!==n||i.choice||i.showOther&&(i.otherText||"").trim()))return;if(!("checkbox"!==n||0!==(i.checked||[]).length||i.showOther&&(i.otherText||"").trim()))return;i.showOther&&!i.choice&&(i.choice="Other"),Je.value={...Je.value,[e]:i};const{[e]:r,...l}=en.value;en.value=l,vn("Answer saved ✓"),Sn(e)}(e.id,e.qtype,null==(n=o.current)?void 0:n.value)},children:"Submit"}),R("div",{style:{clear:"both"}})]})}function Tn({el:e}){const n=Je.value[e.id],t=!!n&&!n._draft&&!en.value[e.id],o=t?"answered":"unanswered",i="open"===e.qtype?"Q":"choice"===e.qtype?"◉":"☑";let r="";if(t)if("open"===e.qtype)r=n.text||"";else if("choice"===e.qtype)r=(n.choice||"")+(n.otherText?" — "+n.otherText:"");else{const e=[...n.checked||[]];n.otherText&&e.push("Other: "+n.otherText),r=e.join(", ")}return R("div",{class:`q-block ${o}`,style:t?{cursor:"pointer"}:void 0,onClick:t?()=>{return n=e.id,void(en.value={...en.value,[n]:!0});var n}:void 0,children:[R("div",{class:"q-header",children:[R("span",{class:"q-icon",children:i}),R("span",{class:"q-text",children:bn(e.question)}),!t&&R("button",{class:"q-dismiss",onClick:n=>{var t;n.stopPropagation(),t=e.id,Ze.value={...Ze.value,[t]:!0}},children:"×"})]}),R("div",t?{class:"q-answer-row",children:[R("span",{class:"q-answer-text",children:bn(r)}),R("span",{class:"q-edit-btn",children:"Edit"})]}:{class:"q-body",children:R(zn,{el:e})})]})}function $n(){rn.value=!1}function Cn(e){if(!e.trim())return;const n=e.trim(),t=Date.now(),o=ln.value,i=an.value,r=null!==o&&!!Qe.value[o],l=void 0!==i;if(null!==o)Qe.value={...Qe.value,[o]:{note:n,time:t}};else if(l){const e=[...Ye.value];e[i]={note:n,time:t},Ye.value=e,an.value=void 0}else Ye.value=[...Ye.value,{note:n,time:t}];$n(),vn(r||l?"Comment updated ✓":"Comment added ✓"),null!==o&&setTimeout(()=>{const e=document.getElementById(`el-${o}`);e&&(e.classList.add("block-flash"),setTimeout(()=>e.classList.remove("block-flash"),900))},50)}function En(){var e,n;const t=se(null),o=rn.value,i=ln.value;let r="",l=!1;if(null!==i){const e=Ve.value[i];if(e)if(l=!0,"code"===e.type){r=e.lang+" code block (L"+e.lineStart+"–L"+e.lineEnd+")"}else r=e.content.slice(0,120)}let a="";null!==i?a=(null==(e=Qe.value[i])?void 0:e.note)||"":void 0!==an.value&&(a=(null==(n=Ye.value[an.value])?void 0:n.note)||"");const s=null!==i?"Comment on this section…":"General feedback on this plan…",c=gn()?"Enter to send · Shift+Enter for newline":"⌘+Enter to send";ae(()=>{o&&t.current&&(t.current.value=a,setTimeout(()=>{var e;return null==(e=t.current)?void 0:e.focus()},280))},[o,i,an.value]);return R("div",{children:[R("div",{class:"overlay "+(o?"open":""),onClick:$n}),R("div",{class:"sheet "+(o?"open":""),children:[R("div",{class:"sheet-handle"}),l&&R("div",{class:"sheet-ctx",children:r}),R("textarea",{ref:t,rows:4,placeholder:s,onKeyDown:e=>{var n,o;"Enter"===e.key&&(!gn()||e.shiftKey||e.metaKey||e.ctrlKey?!e.metaKey&&!e.ctrlKey||gn()||Cn((null==(o=t.current)?void 0:o.value)||""):(e.preventDefault(),Cn((null==(n=t.current)?void 0:n.value)||"")))}}),R("button",{class:"sheet-send active",onClick:()=>{var e;return Cn((null==(e=t.current)?void 0:e.value)||"")},children:R("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[R("path",{d:"M22 2L11 13"}),R("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})}),R("div",{style:{clear:"both"}}),R("div",{class:"sheet-hint",children:c})]})]})}function Ln(){gn()||(sn.value=!sn.value)}function Nn(){const e=function(){const e=pn.value,n=e.filter(e=>Je.value[e.id]).length,t=Object.keys(Qe.value).length;let o="# Feedback: PLAN.md\\n\\n";return o+="- **File:** `PLAN.md`\\n",o+=`- **Generated:** ${(new Date).toISOString()}\\n`,o+=`- **Questions answered:** ${n} / ${e.length}\\n`,o+=`- **Inline comments:** ${t}\\n`,o+=`- **General notes:** ${Ye.value.length}\\n\\n---\\n\\n`,e.length&&(o+="## Question Responses\\n\\n",e.forEach(e=>{o+=`### ${e.question}\\n\\`\\`\\`\\nfile: PLAN.md\\nlines: L${e.lineStart}-L${e.lineEnd}\\ntype: question:${e.qtype}\\nid: ${e.id}\\n\\`\\`\\`\\n`;const n=Je.value[e.id];n?"open"===e.qtype?o+=`**Answer:**\\n\\n${n.text}\\n\\n`:"choice"===e.qtype?(o+=`**Selection:**\\n\\n- ${n.choice}`,n.otherText&&(o+=`: ${n.otherText}`),o+="\\n\\n"):(o+="**Selection:**\\n\\n",(n.checked||[]).forEach(e=>{o+=`- ${e}\\n`}),n.otherText&&(o+=`- Other: ${n.otherText}\\n`),o+="\\n"):o+="*No answer provided*\\n\\n"}),o+="---\\n\\n"),Ye.value.length&&(o+="## General Feedback\\n\\n",Ye.value.forEach((e,n)=>{o+=`### [General ${n+1}]\\n\\n${e.note}\\n\\n`}),o+="---\\n\\n"),t&&(o+="## Inline Annotations\\n\\n",Object.keys(Qe.value).map(Number).sort((e,n)=>e-n).forEach(e=>{const n=Ve.value[e],t=Qe.value[e];if(o+=`### PLAN.md:L${n.lineStart}-L${n.lineEnd}\\n\\`\\`\\`\\nfile: PLAN.md\\nlines: L${n.lineStart}-L${n.lineEnd}\\ntype: ${n.type}${n.lang?" ("+n.lang+")":""}\\n\\`\\`\\`\\n`,"code"===n.type){const e=n;o+=`**Snippet**\\n\\`\\`\\`${e.lang||""}\\n${e.content.split("\\n").slice(0,3).join("\\n")}\\n\\`\\`\\`\\n\\n`}o+=`**Comment**\\n\\n${t.note}\\n\\n`})),o}(),n=nn.value;if("post"===n){const n=tn.value;return void(n&&fetch(n,{method:"POST",headers:{"Content-Type":"text/markdown"},body:e}).then(()=>vn("Feedback posted ✓")).catch(()=>vn("Post failed")))}if("vscode"===n){const n=on.value;return void(n&&n(e))}const t=new Blob([e],{type:"text/markdown"}),o=document.createElement("a");o.href=URL.createObjectURL(t),o.download="PLAN-feedback.md",o.click(),URL.revokeObjectURL(o.href)}function Pn(e){const n=Je.value[e.id];if(!n)return"";if("open"===e.qtype)return n.text||"";if("choice"===e.qtype)return(n.choice||"")+(n.otherText?" — "+n.otherText:"");const t=[...n.checked||[]];return n.otherText&&t.push("Other: "+n.otherText),t.join(", ")}function An(){const e=sn.value,n=Ve.value.filter(e=>{if("question"!==e.type)return!1;const n=e,t=Je.value[n.id];return t&&!t._draft&&!Ze.value[n.id]}),t=Object.keys(Qe.value).map(Number).sort((e,n)=>Qe.value[n].time-Qe.value[e].time),o=[...Ye.value].reverse(),i=n.length>0||t.length>0||o.length>0,r=[];return t.forEach(e=>{r.push({kind:"ann",idx:e,...Qe.value[e]})}),o.forEach((e,n)=>{r.push({kind:"gen",idx:Ye.value.length-1-n,...e})}),r.sort((e,n)=>n.time-e.time),R("div",{children:[R("div",{class:"panel-overlay "+(e?"open":""),onClick:Ln}),R("div",{class:"panel "+(e?"open":""),children:[R("div",{class:"panel-head",children:[R("span",{class:"panel-title",children:"Notes & Answers"}),R("div",{class:"panel-actions",children:[R("button",{class:"panel-export",onClick:Nn,children:"↓ Export"}),R("button",{class:"panel-close",onClick:Ln,children:"×"})]})]}),R("div",i?{children:[n.length>0&&R("div",{class:"panel-section",children:[R("div",{class:"panel-label",children:"Questions"}),n.map(e=>R("div",{class:"panel-q-item",style:{cursor:"pointer"},onClick:()=>{return n=e.id,en.value={...en.value,[n]:!0},void setTimeout(()=>{const e=document.querySelectorAll(".q-block");for(const t of e)if(t.innerHTML.includes(n)){t.scrollIntoView({behavior:"smooth",block:"center"}),t.classList.add("block-flash"),setTimeout(()=>t.classList.remove("block-flash"),900);break}},50);var n},children:[R("button",{class:"panel-delete",onClick:n=>{n.stopPropagation(),function(e){const{[e]:n,...t}=Je.value;Je.value=t,vn("Answer removed")}(e.id)},children:"×"}),R("div",{class:"panel-q-question",children:bn(e.question)}),R("div",{class:"panel-q-answer",children:bn(Pn(e))})]},e.id))]}),r.length>0&&R("div",{class:"panel-section",children:[R("div",{class:"panel-label",children:"Comments"}),r.map((e,n)=>{if("ann"===e.kind){const t=Ve.value[e.idx],o="code"===t.type?t.lang+" (L"+t.lineStart+"-L"+t.lineEnd+")":t.content.slice(0,80);return R("div",{class:"panel-c-item",style:{cursor:"pointer"},onClick:()=>{return n=e.idx,ln.value=n,an.value=void 0,void(rn.value=!0);var n},children:[R("button",{class:"panel-delete",onClick:n=>{n.stopPropagation(),function(e){const{[e]:n,...t}=Qe.value;Qe.value=t,vn("Comment removed")}(e.idx)},children:"×"}),R("div",{class:"panel-c-ctx",children:bn(o)}),R("div",{class:"panel-c-note",children:bn(e.note)})]},`ann-${e.idx}-${n}`)}return R("div",{class:"panel-c-item",style:{cursor:"pointer"},onClick:()=>{return n=e.idx,ln.value=null,an.value=n,void(rn.value=!0);var n},children:[R("button",{class:"panel-delete",onClick:n=>{n.stopPropagation(),function(e){const n=[...Ye.value];n.splice(e,1),Ye.value=n,vn("Note removed")}(e.idx)},children:"×"}),R("div",{class:"panel-c-label",children:"GENERAL"}),R("div",{class:"panel-c-note",children:bn(e.note)})]},`gen-${e.idx}-${n}`)})]})]}:{class:"panel-empty",children:["No notes or answers yet.",R("br",{}),"Tap any section to comment, or answer the embedded questions."]}),i&&R("div",{class:"panel-footer",children:[R("button",{class:"panel-dl",onClick:Nn,children:"↓ Download PLAN-feedback.md"}),R("div",{class:"panel-dl-cap",children:"Markdown · questions, snippets & comments"})]})]})]})}function On(){cn.value=!cn.value}function Un({activeHeadingIdx:e}){const n=cn.value,t=Ve.value.map((e,n)=>({el:e,i:n})).filter(({el:e})=>"h1"===e.type||"h2"===e.type||"h3"===e.type);return R("div",{children:[R("button",{class:"outline-toggle",onClick:On,children:R("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round",children:R("path",{d:"M4 6h16M4 12h10M4 18h14"})})}),R("div",{class:"outline-overlay "+(n?"open":""),onClick:On}),R("div",{class:"outline "+(n?"open":""),children:t.map(({el:n,i:t},o)=>R("a",{class:`outline-item level-${n.type} ${o===e?"active":""}`,onClick:()=>function(e){const n=document.getElementById("el-"+e);n&&n.scrollIntoView({behavior:"smooth",block:"start"}),"undefined"!=typeof window&&window.innerWidth<1100&&(cn.value=!1)}(t),children:bn(n.content)},t))})]})}function Mn(){gn()||(sn.value=!sn.value)}function Hn(){ln.value=null,an.value=void 0,rn.value=!0}function jn(){const e=_n.value;return R("div",{class:"fab-stack",children:[R("button",{class:"fab-notes",onClick:Mn,children:["☰",e>0&&R("span",{class:"fab-badge",children:e})]}),R("button",{class:"fab-write",onClick:Hn,children:"✎"})]})}function In(){return R("div",{class:"toast "+(dn.value?"show":""),children:un.value})}function Fn({progress:e}){return R("div",{class:"scroll-progress",style:{width:e+"%"}})}const Rn=Te(0),Dn=Te(0);function Wn(){const e=se(null),n=Ve.value,t=pn.value,o=fn.value;ae(()=>{let e=null;const t=()=>{e||(e=requestAnimationFrame(()=>{e=null;const t=document.documentElement.scrollTop||document.body.scrollTop,o=document.documentElement.scrollHeight-document.documentElement.clientHeight,i=o>0?Math.min(100,t/o*100):0;Rn.value=i;const r=n.map((e,n)=>({el:e,i:n})).filter(({el:e})=>"h1"===e.type||"h2"===e.type||"h3"===e.type);let l=0;for(let e=0;e<r.length;e++){const n=document.getElementById("el-"+r[e].i);n&&n.getBoundingClientRect().top<=100&&(l=e)}Dn.value=l}))};return window.addEventListener("scroll",t,{passive:!0}),()=>window.removeEventListener("scroll",t)},[n]),ae(()=>{const e=e=>{const n=e.target;if("Escape"===e.key)return rn.value?void(rn.value=!1):cn.value?void(cn.value=!1):sn.value?void(sn.value=!1):void 0;"TEXTAREA"!==n.tagName&&"INPUT"!==n.tagName&&(rn.value||e.metaKey||e.ctrlKey||e.altKey||"Tab"===e.key||e.key.startsWith("Arrow")||"Shift"===e.key||1===e.key.length&&(ln.value=null,an.value=void 0,rn.value=!0,setTimeout(()=>{const n=document.querySelector(".sheet textarea");n&&(n.value=e.key)},300)))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),ae(()=>{const e=()=>{gn()&&(sn.value=!1)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const i=t.length>0,r=t.length>0?Math.round(o/t.length*100):0,l=t.length>0&&o===t.length;return R("div",{children:[R("style",{dangerouslySetInnerHTML:{__html:"\\n*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}\\nhtml{-webkit-text-size-adjust:100%}\\nbody{background:#111;color:#999;font-family:-apple-system,BlinkMacSystemFont,\'Segoe UI\',sans-serif;\\n -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;overflow-x:hidden;\\n text-rendering:optimizeLegibility}\\n.doc{max-width:580px;margin:0 auto;padding:60px 28px 160px}\\n\\n/* Block hover */\\n.block{cursor:pointer;border-radius:6px;padding:3px 6px;margin:2px -6px;position:relative;transition:background .15s}\\n.block:hover{background:rgba(255,255,255,.04)}\\n\\n/* Typography */\\n.el-h1{font-size:26px;font-weight:700;color:#fff;letter-spacing:-.4px;line-height:1.3;margin-top:28px}\\n.el-h2{font-size:12px;font-weight:600;color:#777;text-transform:uppercase;letter-spacing:1.3px;margin-top:36px}\\n.el-h3{font-size:14px;font-weight:600;color:#aaa;margin-top:18px}\\n.el-p{font-size:15px;color:#999;line-height:1.8;margin-top:8px;letter-spacing:.01em}\\n.el-li{font-size:15px;color:#ccc;line-height:1.8;padding-left:18px;position:relative;margin-top:5px}\\n.el-li::before{content:\\"●\\";position:absolute;left:0;color:#555;font-size:7px;top:7px}\\n.el-ol{font-size:15px;color:#ccc;line-height:1.8;padding-left:18px;position:relative;margin-top:5px}\\n.el-ol::before{content:\\"–\\";position:absolute;left:2px;color:#555;font-size:15px}\\n.el-quote{border-left:2px solid #333;padding-left:16px;color:#aaa;font-style:italic;font-size:15px;line-height:1.8;margin-top:8px}\\n\\n/* Code blocks */\\n.code-wrap{background:#0d1117;border:1px solid rgba(255,255,255,.06);border-radius:10px;overflow:hidden;margin-top:10px}\\n.code-header{background:#0a0e16;padding:7px 14px;border-bottom:1px solid rgba(255,255,255,.05);display:flex;justify-content:space-between;align-items:center}\\n.code-lang{color:#3d5070;font-family:\'Fira Code\',\'JetBrains Mono\',monospace;text-transform:uppercase;font-size:11px}\\n.code-copy{background:none;border:none;color:#3d5070;font-size:11px;cursor:pointer;font-family:inherit}\\n.code-copy:hover{color:#5a7da0}\\n.code-body{padding:16px;font-size:13.5px;line-height:1.75;font-family:\'Fira Code\',\'JetBrains Mono\',monospace;\\n color:#bbc;overflow-x:auto;white-space:pre}\\n\\n/* Syntax colors */\\n.syn-kw{color:#c792ea}.syn-typ{color:#82aaff}.syn-str{color:#c3e88d}.syn-cmt{color:#4a6070}.syn-num{color:#f78c6c}\\n\\n/* Annotation dot */\\n.ann-dot{position:absolute;left:-14px;top:50%;transform:translateY(-50%);width:7px;height:7px;border-radius:50%;background:#c792ea}\\n.code-wrap .ann-dot{left:-14px;top:14px;transform:none}\\n\\n/* Inline markdown */\\n.doc strong{color:#fff;font-weight:600}\\n.doc code.inline{font-family:monospace;font-size:.87em;background:rgba(255,255,255,.1);color:#ddd;padding:2px 6px;border-radius:3px}\\n\\n/* ---- Question Blocks ---- */\\n.q-block{margin:16px -6px;border-radius:12px;overflow:hidden;transition:all .2s}\\n.q-block.unanswered{border:1px solid rgba(255,255,255,.13);background:rgba(255,255,255,.04)}\\n.q-block.answered{border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.02);transition:background .15s}\\n.q-block.answered:hover{background:rgba(255,255,255,.05)}\\n.q-header{padding:14px 16px 10px;display:flex;gap:10px;align-items:flex-start}\\n.q-block.unanswered .q-header{border-bottom:1px solid rgba(255,255,255,.07)}\\n.q-icon{font-size:9px;color:#555;text-transform:uppercase;letter-spacing:1px;font-family:monospace;flex-shrink:0;margin-top:3px}\\n.q-text{flex:1;font-size:15px;line-height:1.55}\\n.q-block.unanswered .q-text{color:#ddd;font-weight:500}\\n.q-block.answered .q-text{color:#666;font-weight:400}\\n.q-dismiss{font-size:18px;color:#444;cursor:pointer;background:none;border:none;line-height:1;padding:0 2px;flex-shrink:0}\\n.q-dismiss:hover{color:#888}\\n.q-body{padding:10px 16px 14px}\\n\\n/* Answer summary */\\n.q-answer-row{padding:10px 16px 14px;display:flex;align-items:center;justify-content:space-between}\\n.q-answer-text{font-size:13.5px;color:#aaa}\\n.q-edit-btn{font-size:11px;color:#444;background:none;border:none;cursor:pointer;font-family:inherit}\\n.q-edit-btn:hover{color:#888}\\n\\n/* Open textarea */\\n.q-textarea{width:100%;background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.1);\\n color:#e0e0e0;font-size:14px;font-family:inherit;resize:none;outline:none;padding:4px 0;line-height:1.6}\\n\\n/* Choice / Checkbox options */\\n.q-option{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:8px;cursor:pointer;\\n border:1px solid rgba(255,255,255,.07);background:transparent;color:#aaa;margin-bottom:6px;transition:all .15s;font-size:14.5px}\\n.q-option.selected{border-color:rgba(255,255,255,.18);background:rgba(255,255,255,.07);color:#fff}\\n.q-radio{width:16px;height:16px;border-radius:50%;border:1.5px solid #444;flex-shrink:0;display:flex;align-items:center;justify-content:center}\\n.q-option.selected .q-radio{border-color:#fff}\\n.q-radio-inner{width:7px;height:7px;border-radius:50%;background:#fff;display:none}\\n.q-option.selected .q-radio-inner{display:block}\\n.q-check{width:16px;height:16px;border-radius:4px;border:1.5px solid #444;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:10px;color:#111}\\n.q-option.selected .q-check{background:#fff;border-color:#fff}\\n.q-other-input{width:100%;background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.1);\\n color:#e0e0e0;font-size:13px;outline:none;padding:6px 0;margin-top:4px;font-family:inherit}\\n\\n/* Submit btn inside question */\\n.q-submit{margin-top:10px;padding:8px 18px;border-radius:8px;border:none;font-size:13px;font-family:inherit;cursor:pointer;float:right}\\n.q-submit.active{background:#fff;color:#111}\\n.q-submit.inactive{background:rgba(255,255,255,.06);color:#333;cursor:default}\\n\\n/* Nudge */\\n.nudge{font-size:12.5px;color:#444;text-align:center;border:1px solid rgba(255,255,255,.06);border-radius:10px;padding:14px 16px;margin-top:32px}\\n\\n/* ---- FAB ---- */\\n.fab-stack{position:fixed;bottom:36px;right:24px;z-index:30;display:flex;flex-direction:column;gap:12px;align-items:center}\\n.fab-notes{width:44px;height:44px;border-radius:50%;background:#1a1a1a;border:1px solid rgba(255,255,255,.1);\\n color:#555;font-size:16px;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center}\\n.fab-notes:hover{background:#222}\\n.fab-badge{position:absolute;top:-3px;right:-3px;width:16px;height:16px;border-radius:50%;background:#fff;\\n color:#111;font-size:9px;font-weight:700;display:flex;align-items:center;justify-content:center}\\n.fab-write{width:52px;height:52px;border-radius:50%;background:#1e1e1e;border:1px solid rgba(255,255,255,.12);\\n color:#777;font-size:22px;cursor:pointer;display:flex;align-items:center;justify-content:center}\\n.fab-write:hover{background:#262626}\\n\\n/* ---- Overlay ---- */\\n.overlay{position:fixed;inset:0;z-index:40;opacity:0;pointer-events:none;transition:opacity .3s}\\n.overlay.open{opacity:1;pointer-events:auto}\\n\\n/* ---- Sheet ---- */\\n.sheet{position:fixed;bottom:0;left:0;right:0;z-index:50;background:#171717;\\n border-top:1px solid rgba(255,255,255,.07);border-radius:16px 16px 0 0;\\n padding:20px 24px calc(env(safe-area-inset-bottom, 0px) + 28px);transform:translateY(110%);transition:transform .3s cubic-bezier(.32,.72,0,1);\\n box-shadow:0 -8px 40px rgba(0,0,0,.6)}\\n.sheet.open{transform:translateY(0)}\\n.sheet-handle{width:32px;height:3px;background:rgba(255,255,255,.1);border-radius:2px;margin:0 auto 16px}\\n.sheet-ctx{font-size:12px;color:#aaa;font-style:italic;border-left:2px solid rgba(255,255,255,.25);\\n padding-left:10px;margin-bottom:12px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}\\n.sheet textarea{width:100%;background:transparent;border:none;color:#e0e0e0;font-size:16px;line-height:1.6;\\n resize:none;outline:none;font-family:inherit}\\n.sheet-send{margin-top:12px;margin-bottom:8px;float:right;width:40px;height:40px;border-radius:50%;border:none;cursor:pointer;\\n display:flex;align-items:center;justify-content:center}\\n.sheet-send.active{background:#fff;color:#111}\\n.sheet-send.inactive{background:rgba(255,255,255,.06);color:#333;cursor:default}\\n\\n/* ---- Notes Panel ---- */\\n.panel-overlay{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:60;opacity:0;pointer-events:none;transition:opacity .3s}\\n.panel-overlay.open{opacity:1;pointer-events:auto}\\n.panel{position:fixed;top:0;right:0;bottom:0;width:min(340px,92vw);z-index:70;background:#161616;\\n border-left:1px solid rgba(255,255,255,.07);transform:translateX(100%);transition:transform .3s cubic-bezier(.32,.72,0,1);\\n overflow-y:auto;display:flex;flex-direction:column}\\n.panel.open{transform:translateX(0)}\\n.panel-head{padding:52px 20px 16px;display:flex;justify-content:space-between;align-items:center;flex-shrink:0}\\n.panel-title{font-size:13px;font-weight:600;color:#e0e0e0}\\n.panel-actions{display:flex;gap:12px;align-items:center}\\n.panel-export{font-size:11px;color:#555;background:none;border:1px solid rgba(255,255,255,.1);border-radius:6px;\\n padding:4px 10px;cursor:pointer;font-family:inherit}\\n.panel-export:hover{color:#aaa;border-color:rgba(255,255,255,.2)}\\n.panel-close{font-size:18px;color:#444;background:none;border:none;cursor:pointer}\\n.panel-close:hover{color:#888}\\n.panel-section{padding:0 20px 16px}\\n.panel-label{font-size:10px;color:#444;text-transform:uppercase;font-family:monospace;letter-spacing:1px;margin-bottom:10px;margin-top:16px}\\n.panel-q-item{margin-bottom:14px;padding:6px 8px;border-radius:6px;transition:background .15s}\\n.panel-q-item:hover{background:rgba(255,255,255,.04)}\\n.panel-q-question{font-size:11px;color:#555;margin-bottom:3px}\\n.panel-q-answer{font-size:13.5px;color:#ccc}\\n.panel-c-item{margin-bottom:14px;padding:6px 8px;border-radius:6px;transition:background .15s}\\n.panel-c-item:hover{background:rgba(255,255,255,.04)}\\n.panel-c-ctx{font-size:11px;color:#3a3a3a;font-style:italic;border-left:2px solid rgba(255,255,255,.08);padding-left:8px;margin-bottom:3px}\\n.panel-c-note{font-size:13px;color:#ccc}\\n.panel-c-label{font-size:10px;color:#444;font-family:monospace;margin-bottom:3px}\\n.panel-footer{padding:16px 20px 28px;flex-shrink:0;margin-top:auto}\\n.panel-dl{width:100%;padding:12px;border-radius:10px;background:#fff;color:#111;border:none;\\n font-size:13px;font-weight:600;cursor:pointer;font-family:inherit}\\n.panel-dl:hover{background:#e8e8e8}\\n.panel-dl-cap{font-size:11px;color:#333;text-align:center;margin-top:6px}\\n.panel-empty{color:#333;font-size:13px;padding:40px 20px;text-align:center}\\n\\n/* Toast */\\n.toast{position:fixed;bottom:100px;left:50%;transform:translateX(-50%) translateY(20px);\\n background:#222;color:#ccc;font-size:13px;padding:8px 18px;border-radius:8px;opacity:0;\\n transition:all .3s ease;pointer-events:none;z-index:80;border:1px solid rgba(255,255,255,.08)}\\n.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}\\n\\n/* Block highlight flash */\\n@keyframes flash{0%{background:rgba(199,146,234,.15)}100%{background:transparent}}\\n.block-flash{animation:flash .8s ease-out}\\n\\n/* Sheet hint */\\n.sheet-hint{font-size:11px;color:#444;margin-top:6px;clear:both}\\n\\n/* Progress bar */\\n.nudge-bar{height:3px;border-radius:2px;background:rgba(255,255,255,.06);margin-top:10px;overflow:hidden}\\n.nudge-bar-fill{height:100%;background:#c792ea;border-radius:2px;transition:width .4s ease}\\n\\n/* Delete button in panel */\\n.panel-delete{font-size:11px;color:#444;background:none;border:none;cursor:pointer;float:right;margin-top:-2px}\\n.panel-delete:hover{color:#e55}\\n\\n/* Scroll progress bar */\\n.scroll-progress{position:fixed;top:0;left:0;width:0%;height:3px;background:#c792ea;z-index:90;transition:width .1s linear;border-radius:0 0 2px 0}\\n\\n.outline{position:fixed;top:0;left:0;bottom:0;width:200px;z-index:20;padding:60px 16px 40px;\\n overflow-y:auto;display:none}\\n.outline-item{display:block;font-size:12px;color:#444;padding:4px 0;cursor:pointer;\\n text-decoration:none;transition:color .15s;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\\n.outline-item:hover{color:#aaa}\\n.outline-item.active{color:#c792ea}\\n.outline-item.level-h1{font-weight:600;color:#666;font-size:13px;margin-top:8px}\\n.outline-item.level-h2{padding-left:8px;margin-top:6px}\\n.outline-item.level-h3{padding-left:16px}\\n\\n/* Mobile outline: overlay drawer */\\n.outline-toggle{position:fixed;top:16px;left:16px;z-index:25;width:36px;height:36px;border-radius:50%;\\n background:#1a1a1a;border:1px solid rgba(255,255,255,.1);color:#666;font-size:14px;cursor:pointer;\\n display:flex;align-items:center;justify-content:center}\\n.outline-toggle:hover{background:#222;color:#aaa}\\n@media(max-width:1099px){\\n .outline{background:#161616;border-right:1px solid rgba(255,255,255,.07);z-index:75;\\n transform:translateX(-100%);transition:transform .3s cubic-bezier(.32,.72,0,1);display:block}\\n .outline.open{transform:translateX(0)}\\n}\\n@media(min-width:1100px){\\n .outline{display:block}\\n .outline-toggle{display:none}\\n .doc{margin-left:200px}\\n}\\n\\n.outline-overlay{position:fixed;inset:0;z-index:74;background:rgba(0,0,0,.4);opacity:0;pointer-events:none;transition:opacity .3s}\\n.outline-overlay.open{opacity:1;pointer-events:auto}\\n\\n/* ---- Desktop: panel always open ---- */\\n@media(min-width:800px){\\n body{margin-right:340px}\\n .panel{transform:translateX(0)}\\n .panel-overlay{display:none!important}\\n .panel-close{display:none}\\n .fab-notes{display:none}\\n .sheet{right:340px;border-radius:16px 0 0 0}\\n .fab-stack{right:calc(340px + 24px)}\\n}\\n"}}),R(Fn,{progress:Rn.value}),R(Un,{activeHeadingIdx:Dn.value}),R("div",{class:"doc",ref:e,children:[n.map((e,n)=>{if("question"===e.type){const t=e;return Ze.value[t.id]?null:R(Tn,{el:t,index:n},t.id)}return R(qn,{el:e,index:n},n)}),i&&R("div",{class:"nudge",children:[l?"✓ All questions answered":`${o} of ${t.length} questions answered`,R("div",{class:"nudge-bar",children:R("div",{class:"nudge-bar-fill",style:{width:r+"%"}})})]})]}),R(jn,{}),R(En,{}),R(An,{}),R(In,{})]})}const Bn={init(e){xn(),Ve.value=B(e.markdown),nn.value=e.feedbackMode??"download",e.postUrl&&(tn.value=e.postUrl),e.onFeedback&&(on.value=e.onFeedback),I(R(Wn,{}),e.container)}};"undefined"!=typeof window&&(window.PlanReview=Bn),e.PlanReview=Bn,e.esc=bn,e.highlight=yn,e.parse=B,e.resetState=xn,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}(this.PlanReview=this.PlanReview||{});\n//# sourceMappingURL=plan-review-core.iife.js.map\n';
|
|
8
|
+
function parseArgs(argv) {
|
|
9
|
+
const args2 = { file: "", json: false, port: 0, noOpen: false };
|
|
10
|
+
for (let i = 0; i < argv.length; i++) {
|
|
11
|
+
const a = argv[i];
|
|
12
|
+
if (a === "-o" || a === "--output") {
|
|
13
|
+
args2.outputFile = argv[++i];
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (a === "--json") {
|
|
17
|
+
args2.json = true;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (a === "--port") {
|
|
21
|
+
args2.port = parseInt(argv[++i], 10);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (a === "--no-open") {
|
|
25
|
+
args2.noOpen = true;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (!a.startsWith("-")) {
|
|
29
|
+
args2.file = a;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return args2;
|
|
33
|
+
}
|
|
34
|
+
function openBrowser(url) {
|
|
35
|
+
let cmd;
|
|
36
|
+
let args2;
|
|
37
|
+
if (process.platform === "darwin") {
|
|
38
|
+
cmd = "open";
|
|
39
|
+
args2 = [url];
|
|
40
|
+
} else if (process.platform === "win32") {
|
|
41
|
+
cmd = "cmd";
|
|
42
|
+
args2 = ["/c", "start", "", url];
|
|
43
|
+
} else {
|
|
44
|
+
cmd = "xdg-open";
|
|
45
|
+
args2 = [url];
|
|
46
|
+
}
|
|
47
|
+
const child = spawn(cmd, args2, { stdio: "ignore", detached: true });
|
|
48
|
+
child.unref();
|
|
49
|
+
}
|
|
50
|
+
function buildHtml(markdown2) {
|
|
51
|
+
const escapedMarkdown = JSON.stringify(markdown2);
|
|
52
|
+
return `<!DOCTYPE html>
|
|
53
|
+
<html lang="en">
|
|
54
|
+
<head>
|
|
55
|
+
<meta charset="UTF-8">
|
|
56
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
57
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline';">
|
|
58
|
+
<title>Plan Review</title>
|
|
59
|
+
</head>
|
|
60
|
+
<body>
|
|
61
|
+
<div id="app"></div>
|
|
62
|
+
<script>${CORE_BUNDLE}<\/script>
|
|
63
|
+
<script>
|
|
64
|
+
PlanReview.init({
|
|
65
|
+
container: document.getElementById('app'),
|
|
66
|
+
markdown: ${escapedMarkdown},
|
|
67
|
+
feedbackMode: 'post',
|
|
68
|
+
postUrl: '/feedback',
|
|
69
|
+
});
|
|
70
|
+
<\/script>
|
|
71
|
+
</body>
|
|
72
|
+
</html>`;
|
|
73
|
+
}
|
|
74
|
+
const CONFIRM_HTML = `<!DOCTYPE html>
|
|
75
|
+
<html lang="en">
|
|
76
|
+
<head>
|
|
77
|
+
<meta charset="UTF-8">
|
|
78
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
79
|
+
<title>Feedback Sent</title>
|
|
80
|
+
<style>
|
|
81
|
+
body { background: #111; color: #ccc; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
82
|
+
display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0;
|
|
83
|
+
text-align: center; }
|
|
84
|
+
.msg { font-size: 28px; font-weight: 600; color: #fff; }
|
|
85
|
+
.sub { font-size: 15px; color: #666; margin-top: 12px; }
|
|
86
|
+
</style>
|
|
87
|
+
</head>
|
|
88
|
+
<body>
|
|
89
|
+
<div>
|
|
90
|
+
<div class="msg">Feedback sent! ✓</div>
|
|
91
|
+
<div class="sub">You can close this tab</div>
|
|
92
|
+
</div>
|
|
93
|
+
</body>
|
|
94
|
+
</html>`;
|
|
95
|
+
const args = parseArgs(process.argv.slice(2));
|
|
96
|
+
if (!args.file) {
|
|
97
|
+
process.stderr.write("Usage: review-markdown <file.md> [-o output.md] [--json] [--port N] [--no-open]\n");
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
const filePath = resolve(args.file);
|
|
101
|
+
if (!existsSync(filePath)) {
|
|
102
|
+
process.stderr.write(`Error: File not found: ${filePath}
|
|
103
|
+
`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
const markdown = readFileSync(filePath, "utf-8");
|
|
107
|
+
const server = createServer((req, res) => {
|
|
108
|
+
if (req.method === "GET" && req.url === "/") {
|
|
109
|
+
res.writeHead(200, { "Content-Type": "text/html", "Cache-Control": "no-store" });
|
|
110
|
+
res.end(buildHtml(markdown));
|
|
111
|
+
} else if (req.method === "POST" && req.url === "/feedback") {
|
|
112
|
+
let body = "";
|
|
113
|
+
req.on("data", (chunk) => {
|
|
114
|
+
body += chunk.toString();
|
|
115
|
+
});
|
|
116
|
+
req.on("end", () => {
|
|
117
|
+
try {
|
|
118
|
+
const feedback = JSON.parse(body);
|
|
119
|
+
const output = args.json ? JSON.stringify(feedback, null, 2) : feedback.feedbackMarkdown || JSON.stringify(feedback, null, 2);
|
|
120
|
+
if (args.outputFile) {
|
|
121
|
+
writeFileSync(args.outputFile, output);
|
|
122
|
+
process.stderr.write(`Feedback written to ${args.outputFile}
|
|
123
|
+
`);
|
|
124
|
+
} else {
|
|
125
|
+
process.stdout.write(output);
|
|
126
|
+
}
|
|
127
|
+
} catch {
|
|
128
|
+
process.stderr.write("Error parsing feedback\n");
|
|
129
|
+
}
|
|
130
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
131
|
+
res.end(CONFIRM_HTML);
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
server.close();
|
|
134
|
+
process.exit(0);
|
|
135
|
+
}, 500);
|
|
136
|
+
});
|
|
137
|
+
} else {
|
|
138
|
+
res.writeHead(404);
|
|
139
|
+
res.end("Not Found");
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
server.listen(args.port || 0, () => {
|
|
143
|
+
const addr = server.address();
|
|
144
|
+
const port = typeof addr === "object" && addr ? addr.port : args.port;
|
|
145
|
+
process.stderr.write(`review-markdown serving on http://localhost:${port}
|
|
146
|
+
`);
|
|
147
|
+
if (!args.noOpen) {
|
|
148
|
+
openBrowser(`http://localhost:${port}`);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
process.stderr.write("review-markdown: timed out after 30 minutes\n");
|
|
153
|
+
server.close();
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}, TIMEOUT_MS).unref();
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "review-markdown",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Interactive markdown plan review UI — annotate, answer questions, export feedback",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"review-markdown": "bin/review-markdown.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "vite build"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"vite": "^6.0.0",
|
|
18
|
+
"@plan-review/core": "*"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"markdown",
|
|
22
|
+
"review",
|
|
23
|
+
"feedback",
|
|
24
|
+
"plan",
|
|
25
|
+
"annotation"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18"
|
|
30
|
+
}
|
|
31
|
+
}
|