pdit 0.6.0a1__py3-none-any.whl → 0.7.0__py3-none-any.whl

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.
pdit/_static/export.html CHANGED
@@ -65,7 +65,7 @@ Error generating stack: `+n.message+`
65
65
  `});++l<t.length;)l&&n.push({type:"text",value:`
66
66
  `}),n.push(t[l]);return e&&t.length>0&&n.push({type:"text",value:`
67
67
  `}),n}function dh(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function ph(t,e){const n=yx(t,e),l=n.one(t,void 0),u=ax(n),i=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return u&&i.children.push({type:"text",value:`
68
- `},u),i}function Ex(t,e){return t&&"run"in t?async function(n,l){const u=ph(n,{file:l,...e});await t.run(u,l)}:function(n,l){return ph(n,{file:l,...t||e})}}function mh(t){if(t)throw t}var Vi=Object.prototype.hasOwnProperty,lg=Object.prototype.toString,gh=Object.defineProperty,yh=Object.getOwnPropertyDescriptor,vh=function(e){return typeof Array.isArray=="function"?Array.isArray(e):lg.call(e)==="[object Array]"},bh=function(e){if(!e||lg.call(e)!=="[object Object]")return!1;var n=Vi.call(e,"constructor"),l=e.constructor&&e.constructor.prototype&&Vi.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!l)return!1;var u;for(u in e);return typeof u>"u"||Vi.call(e,u)},Sh=function(e,n){gh&&n.name==="__proto__"?gh(e,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):e[n.name]=n.newValue},xh=function(e,n){if(n==="__proto__")if(Vi.call(e,n)){if(yh)return yh(e,n).value}else return;return e[n]},Tx=function t(){var e,n,l,u,i,a,r=arguments[0],c=1,o=arguments.length,f=!1;for(typeof r=="boolean"&&(f=r,r=arguments[1]||{},c=2),(r==null||typeof r!="object"&&typeof r!="function")&&(r={});c<o;++c)if(e=arguments[c],e!=null)for(n in e)l=xh(r,n),u=xh(e,n),r!==u&&(f&&u&&(bh(u)||(i=vh(u)))?(i?(i=!1,a=l&&vh(l)?l:[]):a=l&&bh(l)?l:{},Sh(r,{name:n,newValue:t(f,a,u)})):typeof u<"u"&&Sh(r,{name:n,newValue:u}));return r};const Cr=Vc(Tx);function Yc(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function Ax(){const t=[],e={run:n,use:l};return e;function n(...u){let i=-1;const a=u.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);r(null,...u);function r(c,...o){const f=t[++i];let h=-1;if(c){a(c);return}for(;++h<u.length;)(o[h]===null||o[h]===void 0)&&(o[h]=u[h]);u=o,f?zx(f,r)(...o):a(null,...o)}}function l(u){if(typeof u!="function")throw new TypeError("Expected `middelware` to be a function, not "+u);return t.push(u),e}}function zx(t,e){let n;return l;function l(...a){const r=t.length>a.length;let c;r&&a.push(u);try{c=t.apply(this,a)}catch(o){const f=o;if(r&&n)throw f;return u(f)}r||(c&&c.then&&typeof c.then=="function"?c.then(i,u):c instanceof Error?u(c):i(c))}function u(a,...r){n||(n=!0,e(a,...r))}function i(a){u(null,a)}}const ze={basename:Ox,dirname:_x,extname:Dx,join:Mx,sep:"/"};function Ox(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');oi(t);let n=0,l=-1,u=t.length,i;if(e===void 0||e.length===0||e.length>t.length){for(;u--;)if(t.codePointAt(u)===47){if(i){n=u+1;break}}else l<0&&(i=!0,l=u+1);return l<0?"":t.slice(n,l)}if(e===t)return"";let a=-1,r=e.length-1;for(;u--;)if(t.codePointAt(u)===47){if(i){n=u+1;break}}else a<0&&(i=!0,a=u+1),r>-1&&(t.codePointAt(u)===e.codePointAt(r--)?r<0&&(l=u):(r=-1,l=a));return n===l?l=a:l<0&&(l=t.length),t.slice(n,l)}function _x(t){if(oi(t),t.length===0)return".";let e=-1,n=t.length,l;for(;--n;)if(t.codePointAt(n)===47){if(l){e=n;break}}else l||(l=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function Dx(t){oi(t);let e=t.length,n=-1,l=0,u=-1,i=0,a;for(;e--;){const r=t.codePointAt(e);if(r===47){if(a){l=e+1;break}continue}n<0&&(a=!0,n=e+1),r===46?u<0?u=e:i!==1&&(i=1):u>-1&&(i=-1)}return u<0||n<0||i===0||i===1&&u===n-1&&u===l+1?"":t.slice(u,n)}function Mx(...t){let e=-1,n;for(;++e<t.length;)oi(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":Cx(n)}function Cx(t){oi(t);const e=t.codePointAt(0)===47;let n=Nx(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function Nx(t,e){let n="",l=0,u=-1,i=0,a=-1,r,c;for(;++a<=t.length;){if(a<t.length)r=t.codePointAt(a);else{if(r===47)break;r=47}if(r===47){if(!(u===a-1||i===1))if(u!==a-1&&i===2){if(n.length<2||l!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",l=0):(n=n.slice(0,c),l=n.length-1-n.lastIndexOf("/")),u=a,i=0;continue}}else if(n.length>0){n="",l=0,u=a,i=0;continue}}e&&(n=n.length>0?n+"/..":"..",l=2)}else n.length>0?n+="/"+t.slice(u+1,a):n=t.slice(u+1,a),l=a-u-1;u=a,i=0}else r===46&&i>-1?i++:i=-1}return n}function oi(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const Rx={cwd:kx};function kx(){return"/"}function Xc(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function wx(t){if(typeof t=="string")t=new URL(t);else if(!Xc(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Ux(t)}function Ux(t){if(t.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const l=e.codePointAt(n+2);if(l===70||l===102){const u=new TypeError("File URL path must not include encoded / characters");throw u.code="ERR_INVALID_FILE_URL_PATH",u}}return decodeURIComponent(e)}const Nr=["history","path","basename","stem","extname","dirname"];class ug{constructor(e){let n;e?Xc(e)?n={path:e}:typeof e=="string"||Bx(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":Rx.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<Nr.length;){const i=Nr[l];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let u;for(u in n)Nr.includes(u)||(this[u]=n[u])}get basename(){return typeof this.path=="string"?ze.basename(this.path):void 0}set basename(e){kr(e,"basename"),Rr(e,"basename"),this.path=ze.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?ze.dirname(this.path):void 0}set dirname(e){Eh(this.basename,"dirname"),this.path=ze.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?ze.extname(this.path):void 0}set extname(e){if(Rr(e,"extname"),Eh(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ze.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Xc(e)&&(e=wx(e)),kr(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?ze.basename(this.path,this.extname):void 0}set stem(e){kr(e,"stem"),Rr(e,"stem"),this.path=ze.join(this.dirname||"",e+(this.extname||""))}fail(e,n,l){const u=this.message(e,n,l);throw u.fatal=!0,u}info(e,n,l){const u=this.message(e,n,l);return u.fatal=void 0,u}message(e,n,l){const u=new Lt(e,n,l);return this.path&&(u.name=this.path+":"+u.name,u.file=this.path),u.fatal=!1,this.messages.push(u),u}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function Rr(t,e){if(t&&t.includes(ze.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+ze.sep+"`")}function kr(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function Eh(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function Bx(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const Hx=function(t){const l=this.constructor.prototype,u=l[t],i=function(){return u.apply(i,arguments)};return Object.setPrototypeOf(i,l),i},Lx={}.hasOwnProperty;class uf extends Hx{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ax()}copy(){const e=new uf;let n=-1;for(;++n<this.attachers.length;){const l=this.attachers[n];e.use(...l)}return e.data(Cr(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(Br("data",this.frozen),this.namespace[e]=n,this):Lx.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Br("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...l]=this.attachers[this.freezeIndex];if(l[0]===!1)continue;l[0]===!0&&(l[0]=void 0);const u=n.call(e,...l);typeof u=="function"&&this.transformers.use(u)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=Di(e),l=this.parser||this.Parser;return wr("parse",l),l(String(n),n)}process(e,n){const l=this;return this.freeze(),wr("process",this.parser||this.Parser),Ur("process",this.compiler||this.Compiler),n?u(void 0,n):new Promise(u);function u(i,a){const r=Di(e),c=l.parse(r);l.run(c,r,function(f,h,d){if(f||!h||!d)return o(f);const s=h,b=l.stringify(s,d);Yx(b)?d.value=b:d.result=b,o(f,d)});function o(f,h){f||!h?a(f):i?i(h):n(void 0,h)}}}processSync(e){let n=!1,l;return this.freeze(),wr("processSync",this.parser||this.Parser),Ur("processSync",this.compiler||this.Compiler),this.process(e,u),Ah("processSync","process",n),l;function u(i,a){n=!0,mh(i),l=a}}run(e,n,l){Th(e),this.freeze();const u=this.transformers;return!l&&typeof n=="function"&&(l=n,n=void 0),l?i(void 0,l):new Promise(i);function i(a,r){const c=Di(n);u.run(e,c,o);function o(f,h,d){const s=h||e;f?r(f):a?a(s):l(void 0,s,d)}}}runSync(e,n){let l=!1,u;return this.run(e,n,i),Ah("runSync","run",l),u;function i(a,r){mh(a),u=r,l=!0}}stringify(e,n){this.freeze();const l=Di(n),u=this.compiler||this.Compiler;return Ur("stringify",u),Th(e),u(e,l)}use(e,...n){const l=this.attachers,u=this.namespace;if(Br("use",this.frozen),e!=null)if(typeof e=="function")c(e,n);else if(typeof e=="object")Array.isArray(e)?r(e):a(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function i(o){if(typeof o=="function")c(o,[]);else if(typeof o=="object")if(Array.isArray(o)){const[f,...h]=o;c(f,h)}else a(o);else throw new TypeError("Expected usable value, not `"+o+"`")}function a(o){if(!("plugins"in o)&&!("settings"in o))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");r(o.plugins),o.settings&&(u.settings=Cr(!0,u.settings,o.settings))}function r(o){let f=-1;if(o!=null)if(Array.isArray(o))for(;++f<o.length;){const h=o[f];i(h)}else throw new TypeError("Expected a list of plugins, not `"+o+"`")}function c(o,f){let h=-1,d=-1;for(;++h<l.length;)if(l[h][0]===o){d=h;break}if(d===-1)l.push([o,...f]);else if(f.length>0){let[s,...b]=f;const S=l[d][1];Yc(S)&&Yc(s)&&(s=Cr(!0,S,s)),l[d]=[o,s,...b]}}}}const qx=new uf().freeze();function wr(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function Ur(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Br(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Th(t){if(!Yc(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Ah(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Di(t){return jx(t)?t:new ug(t)}function jx(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function Yx(t){return typeof t=="string"||Xx(t)}function Xx(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const Vx="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",zh=[],Oh={allowDangerousHtml:!0},Qx=/^(https?|ircs?|mailto|xmpp)$/i,Gx=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Zx(t){const e=Kx(t),n=Jx(t);return Fx(e.runSync(e.parse(n),n),t)}function Kx(t){const e=t.rehypePlugins||zh,n=t.remarkPlugins||zh,l=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...Oh}:Oh;return qx().use(_S).use(n).use(Ex,l).use(e)}function Jx(t){const e=t.children||"",n=new ug;return typeof e=="string"&&(n.value=e),n}function Fx(t,e){const n=e.allowedElements,l=e.allowElement,u=e.components,i=e.disallowedElements,a=e.skipHtml,r=e.unwrapDisallowed,c=e.urlTransform||Ix;for(const f of Gx)Object.hasOwn(e,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+Vx+f.id,void 0);return ng(t,o),av(t,{Fragment:st.Fragment,components:u,ignoreInvalidStyle:!0,jsx:st.jsx,jsxs:st.jsxs,passKeys:!0,passNode:!0});function o(f,h,d){if(f.type==="raw"&&d&&typeof h=="number")return a?d.children.splice(h,1):d.children[h]={type:"text",value:f.value},h;if(f.type==="element"){let s;for(s in _r)if(Object.hasOwn(_r,s)&&Object.hasOwn(f.properties,s)){const b=f.properties[s],S=_r[s];(S===null||S.includes(f.tagName))&&(f.properties[s]=c(String(b||""),s,f))}}if(f.type==="element"){let s=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!s&&l&&typeof h=="number"&&(s=!l(f,h,d)),s&&d&&typeof h=="number")return r&&f.children?d.children.splice(h,1,...f.children):d.children.splice(h,1),h}}}function Ix(t){const e=t.indexOf(":"),n=t.indexOf("?"),l=t.indexOf("#"),u=t.indexOf("/");return e===-1||u!==-1&&e>u||n!==-1&&e>n||l!==-1&&e>l||Qx.test(t.slice(0,e))?t:""}const $x=({content:t,mimeType:e,width:n,height:l})=>{const u=`data:${e};base64,${t}`;return st.jsx("img",{src:u,className:"output-image",alt:"Plot output",width:n,height:l})},Wx=({html:t})=>{const e=gf.useRef(null);return gf.useEffect(()=>{if(!e.current)return;e.current.innerHTML=t,e.current.querySelectorAll("script").forEach(l=>{var i;const u=document.createElement("script");Array.from(l.attributes).forEach(a=>{u.setAttribute(a.name,a.value)}),u.textContent=l.textContent,(i=l.parentNode)==null||i.replaceChild(u,l)})},[t]),st.jsx("div",{ref:e,className:"output-html"})},Px=t=>t.replace(/\//g,"-"),t2=({expression:t,ref:e,allInvisible:n})=>{var i;const l=Oe.useRef(null);Oe.useImperativeHandle(e,()=>l.current,[]);const u=n?"output-container output-container-invisible":"output-container";return st.jsx("div",{ref:l,className:u,children:st.jsx("div",{className:"output-line",children:(i=t.result)==null?void 0:i.output.map((a,r)=>st.jsx("div",{className:`output-item output-${Px(a.type)}`,children:st.jsx("div",{className:"output-content-wrapper",children:a.type==="text/markdown"?st.jsx(Zx,{children:a.content}):a.type.startsWith("image/")?st.jsx($x,{content:a.content,mimeType:a.type,width:a.width,height:a.height}):a.type==="text/html"?st.jsx(Wx,{html:a.content}):st.jsx("pre",{children:a.content})})},r))})})},e2=({onLineGroupHeightChange:t,expressions:e,lineGroups:n,lineGroupLayouts:l,lineGroupHeights:u,readerMode:i})=>{const a=Oe.useRef(null),r=Oe.useRef(new Map),c=Oe.useMemo(()=>{if(i||!l||!u||n.length===0)return;const f=n[n.length-1],h=l.get(f.id),d=u.get(f.id);return h&&d!==void 0?h.top+d:void 0},[i,n,l,u]),o=Oe.useCallback(()=>{const f=new Map;for(const[h,d]of r.current.entries())d&&f.set(h,Math.max(0,d.getBoundingClientRect().height));return f},[]);return Oe.useEffect(()=>{if(!a.current||!t)return;const f=setTimeout(()=>{t(o())},0),h=new MutationObserver(()=>{t(o())}),d=new ResizeObserver(()=>{t(o())});return a.current&&(h.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","open","hidden"]}),d.observe(a.current)),()=>{clearTimeout(f),h.disconnect(),d.disconnect()}},[t,o,n]),st.jsx("div",{id:"output",ref:a,children:st.jsx("div",{className:`output-content ${i?"reader-mode":""}`,style:c?{minHeight:`${c}px`}:void 0,children:n.map(f=>{if(!f.resultIds.some(S=>{const z=e.find(p=>p.id===S);return(z==null?void 0:z.result)&&z.result.output.length>0}))return null;const d=l==null?void 0:l.get(f.id),s=["output-group",f.allInvisible?"output-group-invisible":"",f.hasError?"output-group-error":""].filter(Boolean).join(" "),b={};return d&&!i&&(b.position="absolute",b.top=d.top,b.left=8,b.right=8,b.minHeight=`${d.naturalHeight}px`),st.jsx("div",{className:s,ref:S=>{S?r.current.set(f.id,S):r.current.delete(f.id)},style:Object.keys(b).length>0?b:void 0,children:f.resultIds.map(S=>{const z=e.findIndex(m=>m.id===S);if(z===-1)return null;const p=e[z];return st.jsx(t2,{expression:p,index:z,allInvisible:f.allInvisible},p.id)})},f.id)})})})};let n2=0;function l2(t){if(t.length===0)return[];const e=c=>{var o,f;return((f=(o=c.result)==null?void 0:o.output)==null?void 0:f.some(h=>h.type==="error"||h.type==="stderr"))??!1},n=new Map;for(const c of t)for(let o=c.lineStart;o<=c.lineEnd;o++)n.has(o)||n.set(o,new Set),n.get(o).add(c.id);const l=new Map,u=c=>{l.has(c)||l.set(c,c);const o=l.get(c);if(o!==c){const f=u(o);return l.set(c,f),f}return o},i=(c,o)=>{const f=u(c),h=u(o);f!==h&&l.set(h,f)};for(const c of n.values()){const o=Array.from(c);for(let f=1;f<o.length;f++)i(o[0],o[f])}const a=new Map;for(const c of t){const o=u(c.id);a.has(o)||a.set(o,[]),a.get(o).push(c.id)}const r=[];for(const c of a.values()){let o=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY;const h=[];for(const d of c){const s=t.find(b=>b.id===d);s&&(h.push(s),o=Math.min(o,s.lineStart),f=Math.max(f,s.lineEnd))}if(o!==Number.POSITIVE_INFINITY&&f!==Number.NEGATIVE_INFINITY){const d=h.every(S=>{var z;return((z=S.result)==null?void 0:z.isInvisible)===!0}),s=h.some(e);let b="done";for(const S of h){if(S.state==="executing"){b="executing";break}S.state==="cancelled"&&(b="cancelled"),S.state==="pending"&&b!=="cancelled"&&(b="pending")}r.push({id:`lg-${n2++}`,resultIds:[...c].sort((S,z)=>S-z),lineStart:o,lineEnd:f,allInvisible:d,hasError:s,state:b})}}return r.sort((c,o)=>c.lineStart-o.lineStart)}function u2(){const t=window.__pdit_response__;if(!t)return st.jsx("div",{style:{padding:"20px",fontFamily:"monospace"},children:"Error: No execution data found. This page should be generated by `pdit export`."});const{expressions:e}=t,n=l2(e);return st.jsx("div",{id:"app",children:st.jsxs("div",{className:"split-container reader-mode",children:[st.jsx("div",{className:"editor-half editor-hidden"}),st.jsx("div",{className:"output-half output-full",children:st.jsx(e2,{expressions:e,lineGroups:n,readerMode:!0})})]})})}const i2=document.getElementById("app"),a2=o0.createRoot(i2);a2.render(st.jsx(u2,{}));</script>
68
+ `},u),i}function Ex(t,e){return t&&"run"in t?async function(n,l){const u=ph(n,{file:l,...e});await t.run(u,l)}:function(n,l){return ph(n,{file:l,...t||e})}}function mh(t){if(t)throw t}var Vi=Object.prototype.hasOwnProperty,lg=Object.prototype.toString,gh=Object.defineProperty,yh=Object.getOwnPropertyDescriptor,vh=function(e){return typeof Array.isArray=="function"?Array.isArray(e):lg.call(e)==="[object Array]"},bh=function(e){if(!e||lg.call(e)!=="[object Object]")return!1;var n=Vi.call(e,"constructor"),l=e.constructor&&e.constructor.prototype&&Vi.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!l)return!1;var u;for(u in e);return typeof u>"u"||Vi.call(e,u)},Sh=function(e,n){gh&&n.name==="__proto__"?gh(e,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):e[n.name]=n.newValue},xh=function(e,n){if(n==="__proto__")if(Vi.call(e,n)){if(yh)return yh(e,n).value}else return;return e[n]},Tx=function t(){var e,n,l,u,i,a,r=arguments[0],c=1,o=arguments.length,f=!1;for(typeof r=="boolean"&&(f=r,r=arguments[1]||{},c=2),(r==null||typeof r!="object"&&typeof r!="function")&&(r={});c<o;++c)if(e=arguments[c],e!=null)for(n in e)l=xh(r,n),u=xh(e,n),r!==u&&(f&&u&&(bh(u)||(i=vh(u)))?(i?(i=!1,a=l&&vh(l)?l:[]):a=l&&bh(l)?l:{},Sh(r,{name:n,newValue:t(f,a,u)})):typeof u<"u"&&Sh(r,{name:n,newValue:u}));return r};const Cr=Vc(Tx);function Yc(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function Ax(){const t=[],e={run:n,use:l};return e;function n(...u){let i=-1;const a=u.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);r(null,...u);function r(c,...o){const f=t[++i];let h=-1;if(c){a(c);return}for(;++h<u.length;)(o[h]===null||o[h]===void 0)&&(o[h]=u[h]);u=o,f?zx(f,r)(...o):a(null,...o)}}function l(u){if(typeof u!="function")throw new TypeError("Expected `middelware` to be a function, not "+u);return t.push(u),e}}function zx(t,e){let n;return l;function l(...a){const r=t.length>a.length;let c;r&&a.push(u);try{c=t.apply(this,a)}catch(o){const f=o;if(r&&n)throw f;return u(f)}r||(c&&c.then&&typeof c.then=="function"?c.then(i,u):c instanceof Error?u(c):i(c))}function u(a,...r){n||(n=!0,e(a,...r))}function i(a){u(null,a)}}const ze={basename:Ox,dirname:_x,extname:Dx,join:Mx,sep:"/"};function Ox(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');oi(t);let n=0,l=-1,u=t.length,i;if(e===void 0||e.length===0||e.length>t.length){for(;u--;)if(t.codePointAt(u)===47){if(i){n=u+1;break}}else l<0&&(i=!0,l=u+1);return l<0?"":t.slice(n,l)}if(e===t)return"";let a=-1,r=e.length-1;for(;u--;)if(t.codePointAt(u)===47){if(i){n=u+1;break}}else a<0&&(i=!0,a=u+1),r>-1&&(t.codePointAt(u)===e.codePointAt(r--)?r<0&&(l=u):(r=-1,l=a));return n===l?l=a:l<0&&(l=t.length),t.slice(n,l)}function _x(t){if(oi(t),t.length===0)return".";let e=-1,n=t.length,l;for(;--n;)if(t.codePointAt(n)===47){if(l){e=n;break}}else l||(l=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function Dx(t){oi(t);let e=t.length,n=-1,l=0,u=-1,i=0,a;for(;e--;){const r=t.codePointAt(e);if(r===47){if(a){l=e+1;break}continue}n<0&&(a=!0,n=e+1),r===46?u<0?u=e:i!==1&&(i=1):u>-1&&(i=-1)}return u<0||n<0||i===0||i===1&&u===n-1&&u===l+1?"":t.slice(u,n)}function Mx(...t){let e=-1,n;for(;++e<t.length;)oi(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":Cx(n)}function Cx(t){oi(t);const e=t.codePointAt(0)===47;let n=Nx(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function Nx(t,e){let n="",l=0,u=-1,i=0,a=-1,r,c;for(;++a<=t.length;){if(a<t.length)r=t.codePointAt(a);else{if(r===47)break;r=47}if(r===47){if(!(u===a-1||i===1))if(u!==a-1&&i===2){if(n.length<2||l!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",l=0):(n=n.slice(0,c),l=n.length-1-n.lastIndexOf("/")),u=a,i=0;continue}}else if(n.length>0){n="",l=0,u=a,i=0;continue}}e&&(n=n.length>0?n+"/..":"..",l=2)}else n.length>0?n+="/"+t.slice(u+1,a):n=t.slice(u+1,a),l=a-u-1;u=a,i=0}else r===46&&i>-1?i++:i=-1}return n}function oi(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const Rx={cwd:kx};function kx(){return"/"}function Xc(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function wx(t){if(typeof t=="string")t=new URL(t);else if(!Xc(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Ux(t)}function Ux(t){if(t.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const l=e.codePointAt(n+2);if(l===70||l===102){const u=new TypeError("File URL path must not include encoded / characters");throw u.code="ERR_INVALID_FILE_URL_PATH",u}}return decodeURIComponent(e)}const Nr=["history","path","basename","stem","extname","dirname"];class ug{constructor(e){let n;e?Xc(e)?n={path:e}:typeof e=="string"||Bx(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":Rx.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<Nr.length;){const i=Nr[l];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let u;for(u in n)Nr.includes(u)||(this[u]=n[u])}get basename(){return typeof this.path=="string"?ze.basename(this.path):void 0}set basename(e){kr(e,"basename"),Rr(e,"basename"),this.path=ze.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?ze.dirname(this.path):void 0}set dirname(e){Eh(this.basename,"dirname"),this.path=ze.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?ze.extname(this.path):void 0}set extname(e){if(Rr(e,"extname"),Eh(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ze.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Xc(e)&&(e=wx(e)),kr(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?ze.basename(this.path,this.extname):void 0}set stem(e){kr(e,"stem"),Rr(e,"stem"),this.path=ze.join(this.dirname||"",e+(this.extname||""))}fail(e,n,l){const u=this.message(e,n,l);throw u.fatal=!0,u}info(e,n,l){const u=this.message(e,n,l);return u.fatal=void 0,u}message(e,n,l){const u=new Lt(e,n,l);return this.path&&(u.name=this.path+":"+u.name,u.file=this.path),u.fatal=!1,this.messages.push(u),u}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function Rr(t,e){if(t&&t.includes(ze.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+ze.sep+"`")}function kr(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function Eh(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function Bx(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const Hx=function(t){const l=this.constructor.prototype,u=l[t],i=function(){return u.apply(i,arguments)};return Object.setPrototypeOf(i,l),i},Lx={}.hasOwnProperty;class uf extends Hx{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ax()}copy(){const e=new uf;let n=-1;for(;++n<this.attachers.length;){const l=this.attachers[n];e.use(...l)}return e.data(Cr(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(Br("data",this.frozen),this.namespace[e]=n,this):Lx.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Br("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...l]=this.attachers[this.freezeIndex];if(l[0]===!1)continue;l[0]===!0&&(l[0]=void 0);const u=n.call(e,...l);typeof u=="function"&&this.transformers.use(u)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=Di(e),l=this.parser||this.Parser;return wr("parse",l),l(String(n),n)}process(e,n){const l=this;return this.freeze(),wr("process",this.parser||this.Parser),Ur("process",this.compiler||this.Compiler),n?u(void 0,n):new Promise(u);function u(i,a){const r=Di(e),c=l.parse(r);l.run(c,r,function(f,h,d){if(f||!h||!d)return o(f);const s=h,b=l.stringify(s,d);Yx(b)?d.value=b:d.result=b,o(f,d)});function o(f,h){f||!h?a(f):i?i(h):n(void 0,h)}}}processSync(e){let n=!1,l;return this.freeze(),wr("processSync",this.parser||this.Parser),Ur("processSync",this.compiler||this.Compiler),this.process(e,u),Ah("processSync","process",n),l;function u(i,a){n=!0,mh(i),l=a}}run(e,n,l){Th(e),this.freeze();const u=this.transformers;return!l&&typeof n=="function"&&(l=n,n=void 0),l?i(void 0,l):new Promise(i);function i(a,r){const c=Di(n);u.run(e,c,o);function o(f,h,d){const s=h||e;f?r(f):a?a(s):l(void 0,s,d)}}}runSync(e,n){let l=!1,u;return this.run(e,n,i),Ah("runSync","run",l),u;function i(a,r){mh(a),u=r,l=!0}}stringify(e,n){this.freeze();const l=Di(n),u=this.compiler||this.Compiler;return Ur("stringify",u),Th(e),u(e,l)}use(e,...n){const l=this.attachers,u=this.namespace;if(Br("use",this.frozen),e!=null)if(typeof e=="function")c(e,n);else if(typeof e=="object")Array.isArray(e)?r(e):a(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function i(o){if(typeof o=="function")c(o,[]);else if(typeof o=="object")if(Array.isArray(o)){const[f,...h]=o;c(f,h)}else a(o);else throw new TypeError("Expected usable value, not `"+o+"`")}function a(o){if(!("plugins"in o)&&!("settings"in o))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");r(o.plugins),o.settings&&(u.settings=Cr(!0,u.settings,o.settings))}function r(o){let f=-1;if(o!=null)if(Array.isArray(o))for(;++f<o.length;){const h=o[f];i(h)}else throw new TypeError("Expected a list of plugins, not `"+o+"`")}function c(o,f){let h=-1,d=-1;for(;++h<l.length;)if(l[h][0]===o){d=h;break}if(d===-1)l.push([o,...f]);else if(f.length>0){let[s,...b]=f;const S=l[d][1];Yc(S)&&Yc(s)&&(s=Cr(!0,S,s)),l[d]=[o,s,...b]}}}}const qx=new uf().freeze();function wr(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function Ur(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Br(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Th(t){if(!Yc(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Ah(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Di(t){return jx(t)?t:new ug(t)}function jx(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function Yx(t){return typeof t=="string"||Xx(t)}function Xx(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const Vx="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",zh=[],Oh={allowDangerousHtml:!0},Qx=/^(https?|ircs?|mailto|xmpp)$/i,Gx=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Zx(t){const e=Kx(t),n=Jx(t);return Fx(e.runSync(e.parse(n),n),t)}function Kx(t){const e=t.rehypePlugins||zh,n=t.remarkPlugins||zh,l=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...Oh}:Oh;return qx().use(_S).use(n).use(Ex,l).use(e)}function Jx(t){const e=t.children||"",n=new ug;return typeof e=="string"&&(n.value=e),n}function Fx(t,e){const n=e.allowedElements,l=e.allowElement,u=e.components,i=e.disallowedElements,a=e.skipHtml,r=e.unwrapDisallowed,c=e.urlTransform||Ix;for(const f of Gx)Object.hasOwn(e,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+Vx+f.id,void 0);return ng(t,o),av(t,{Fragment:st.Fragment,components:u,ignoreInvalidStyle:!0,jsx:st.jsx,jsxs:st.jsxs,passKeys:!0,passNode:!0});function o(f,h,d){if(f.type==="raw"&&d&&typeof h=="number")return a?d.children.splice(h,1):d.children[h]={type:"text",value:f.value},h;if(f.type==="element"){let s;for(s in _r)if(Object.hasOwn(_r,s)&&Object.hasOwn(f.properties,s)){const b=f.properties[s],S=_r[s];(S===null||S.includes(f.tagName))&&(f.properties[s]=c(String(b||""),s,f))}}if(f.type==="element"){let s=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!s&&l&&typeof h=="number"&&(s=!l(f,h,d)),s&&d&&typeof h=="number")return r&&f.children?d.children.splice(h,1,...f.children):d.children.splice(h,1),h}}}function Ix(t){const e=t.indexOf(":"),n=t.indexOf("?"),l=t.indexOf("#"),u=t.indexOf("/");return e===-1||u!==-1&&e>u||n!==-1&&e>n||l!==-1&&e>l||Qx.test(t.slice(0,e))?t:""}const $x=({content:t,mimeType:e,width:n,height:l})=>{const u=`data:${e};base64,${t}`,i={};return n!==void 0&&(i.width=n),l!==void 0&&(i.height=l),st.jsx("img",{src:u,className:"output-image",alt:"Plot output",style:i})},Wx=({html:t})=>{const e=gf.useRef(null);return gf.useEffect(()=>{if(!e.current)return;e.current.innerHTML=t,e.current.querySelectorAll("script").forEach(l=>{var i;const u=document.createElement("script");Array.from(l.attributes).forEach(a=>{u.setAttribute(a.name,a.value)}),u.textContent=l.textContent,(i=l.parentNode)==null||i.replaceChild(u,l)})},[t]),st.jsx("div",{ref:e,className:"output-html"})},Px=t=>t.replace(/\//g,"-"),t2=({expression:t,ref:e,allInvisible:n})=>{var i;const l=Oe.useRef(null);Oe.useImperativeHandle(e,()=>l.current,[]);const u=n?"output-container output-container-invisible":"output-container";return st.jsx("div",{ref:l,className:u,children:st.jsx("div",{className:"output-line",children:(i=t.result)==null?void 0:i.output.map((a,r)=>st.jsx("div",{className:`output-item output-${Px(a.type)}`,children:st.jsx("div",{className:"output-content-wrapper",children:a.type==="text/markdown"?st.jsx(Zx,{children:a.content}):a.type.startsWith("image/")?st.jsx($x,{content:a.content,mimeType:a.type,width:a.width,height:a.height}):a.type==="text/html"?st.jsx(Wx,{html:a.content}):st.jsx("pre",{children:a.content})})},r))})})},e2=({onLineGroupHeightChange:t,expressions:e,lineGroups:n,lineGroupLayouts:l,lineGroupHeights:u,readerMode:i})=>{const a=Oe.useRef(null),r=Oe.useRef(new Map),c=Oe.useMemo(()=>{if(i||!l||!u||n.length===0)return;const f=n[n.length-1],h=l.get(f.id),d=u.get(f.id);return h&&d!==void 0?h.top+d:void 0},[i,n,l,u]),o=Oe.useCallback(()=>{const f=new Map;for(const[h,d]of r.current.entries())d&&f.set(h,Math.max(0,d.getBoundingClientRect().height));return f},[]);return Oe.useEffect(()=>{if(!a.current||!t)return;const f=setTimeout(()=>{t(o())},0),h=new MutationObserver(()=>{t(o())}),d=new ResizeObserver(()=>{t(o())});return a.current&&(h.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","open","hidden"]}),d.observe(a.current)),()=>{clearTimeout(f),h.disconnect(),d.disconnect()}},[t,o,n]),st.jsx("div",{id:"output",ref:a,children:st.jsx("div",{className:`output-content ${i?"reader-mode":""}`,style:c?{minHeight:`${c}px`}:void 0,children:n.map(f=>{if(!f.resultIds.some(S=>{const z=e.find(p=>p.id===S);return(z==null?void 0:z.result)&&z.result.output.length>0}))return null;const d=l==null?void 0:l.get(f.id),s=["output-group",f.allInvisible?"output-group-invisible":"",f.hasError?"output-group-error":""].filter(Boolean).join(" "),b={};return d&&!i&&(b.position="absolute",b.top=d.top,b.left=8,b.right=8,b.minHeight=`${d.naturalHeight}px`),st.jsx("div",{className:s,ref:S=>{S?r.current.set(f.id,S):r.current.delete(f.id)},style:Object.keys(b).length>0?b:void 0,children:f.resultIds.map(S=>{const z=e.findIndex(m=>m.id===S);if(z===-1)return null;const p=e[z];return st.jsx(t2,{expression:p,index:z,allInvisible:f.allInvisible},p.id)})},f.id)})})})};let n2=0;function l2(t){if(t.length===0)return[];const e=c=>{var o,f;return((f=(o=c.result)==null?void 0:o.output)==null?void 0:f.some(h=>h.type==="error"||h.type==="stderr"))??!1},n=new Map;for(const c of t)for(let o=c.lineStart;o<=c.lineEnd;o++)n.has(o)||n.set(o,new Set),n.get(o).add(c.id);const l=new Map,u=c=>{l.has(c)||l.set(c,c);const o=l.get(c);if(o!==c){const f=u(o);return l.set(c,f),f}return o},i=(c,o)=>{const f=u(c),h=u(o);f!==h&&l.set(h,f)};for(const c of n.values()){const o=Array.from(c);for(let f=1;f<o.length;f++)i(o[0],o[f])}const a=new Map;for(const c of t){const o=u(c.id);a.has(o)||a.set(o,[]),a.get(o).push(c.id)}const r=[];for(const c of a.values()){let o=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY;const h=[];for(const d of c){const s=t.find(b=>b.id===d);s&&(h.push(s),o=Math.min(o,s.lineStart),f=Math.max(f,s.lineEnd))}if(o!==Number.POSITIVE_INFINITY&&f!==Number.NEGATIVE_INFINITY){const d=h.every(S=>{var z;return((z=S.result)==null?void 0:z.isInvisible)===!0}),s=h.some(e);let b="done";for(const S of h){if(S.state==="executing"){b="executing";break}S.state==="cancelled"&&(b="cancelled"),S.state==="pending"&&b!=="cancelled"&&(b="pending")}r.push({id:`lg-${n2++}`,resultIds:[...c].sort((S,z)=>S-z),lineStart:o,lineEnd:f,allInvisible:d,hasError:s,state:b})}}return r.sort((c,o)=>c.lineStart-o.lineStart)}function u2(){const t=window.__pdit_response__;if(!t)return st.jsx("div",{style:{padding:"20px",fontFamily:"monospace"},children:"Error: No execution data found. This page should be generated by `pdit export`."});const{expressions:e}=t,n=l2(e);return st.jsx("div",{id:"app",children:st.jsxs("div",{className:"split-container reader-mode",children:[st.jsx("div",{className:"editor-half editor-hidden"}),st.jsx("div",{className:"output-half output-full",children:st.jsx(e2,{expressions:e,lineGroups:n,readerMode:!0})})]})})}const i2=document.getElementById("app"),a2=o0.createRoot(i2);a2.render(st.jsx(u2,{}));</script>
69
69
  <style rel="stylesheet" crossorigin>@import"https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap";:root{--color-yellow: #FFD700;--color-red: #E63946;--color-blue: #457B9D;--color-teal: #2A9D8F;--color-orange: #F4A261;--color-black: #1a1a1a;--color-cream: #FFFEF5;--color-warm-hover: #FFF8DC;--color-gray: #555;--color-gray-light: #888;--color-link: var(--color-red);--color-link-hover: var(--color-blue);--color-code-bg: var(--color-black);--color-code-text: var(--color-yellow);--border-thick: 3px solid var(--color-black);--border-thin: 1px solid #ddd;--top-bar-height: calc(32px + 1rem) ;--gradient-rainbow: linear-gradient(90deg, var(--color-red) 25%, var(--color-yellow) 25%, var(--color-yellow) 50%, var(--color-blue) 50%, var(--color-blue) 75%, var(--color-teal) 75% );--bg-primary: #fff;--bg-secondary: #f8f8f8;--bg-tertiary: #f5f5f5;--border: #ddd;--accent: var(--color-red);--accent-alt: var(--color-blue);--text-primary: var(--color-black);--text-secondary: var(--color-gray);--text-dim: var(--color-gray-light);--error: #cc0000;--error-soft: #d97a7a;--warning: var(--color-orange);font-family:system-ui,-apple-system,sans-serif;line-height:1.5;font-weight:400;color-scheme:light;color:var(--color-black);background-color:#fff;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}body{margin:0;width:100%;min-height:100vh;overflow-x:hidden;overflow-y:auto;background:#fff}#app{width:100%;height:auto;min-height:100vh;display:flex;flex-direction:column}#app.loading{cursor:wait}#app.loading .top-bar,#app.loading .split-container{opacity:.5;pointer-events:none}.top-bar{background:#fafafa;padding:.5rem 1rem;display:flex;align-items:center;flex-shrink:0;position:fixed;top:0;left:0;right:0;z-index:20;height:var(--top-bar-height);box-sizing:border-box;font-family:Fira Code,ui-monospace,monospace;border-bottom:1px solid #e0e0e0}.top-bar-content{display:flex;gap:.75rem;align-items:center;width:100%}.top-bar-button-wrapper{position:relative}.top-bar-button{background:transparent;color:var(--color-gray);border:1px solid var(--color-gray-light);border-radius:0;padding:0 .8rem;font-size:.75rem;cursor:pointer;font-family:inherit;transition:all .1s;font-weight:500;display:flex;align-items:center;gap:.5rem;height:32px}.top-bar-button:hover:not(:disabled){background:var(--color-warm-hover);color:var(--color-black);border-color:var(--color-gray)}.top-bar-button:disabled{cursor:not-allowed;color:#bbb;border-color:#ddd}.top-bar-tooltip{position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);background:var(--color-black);color:var(--color-cream);padding:.4rem .6rem;border-radius:0;font-size:.7rem;font-weight:500;font-family:ui-monospace,monospace;white-space:nowrap;border:none;z-index:1000;pointer-events:none;box-shadow:0 2px 4px #0003}.top-bar-status{display:flex;align-items:center;gap:.5rem;margin-left:.75rem}.top-bar-status-dot{width:8px;height:8px;border-radius:50%}.top-bar-status-dot.ready{background:var(--color-teal)}.top-bar-status-dot.initializing{background:var(--color-orange)}.top-bar-status-dot.connected{background:var(--color-teal)}.top-bar-status-dot.connecting{background:var(--color-orange)}.top-bar-status-dot.disconnected{background:var(--color-red)}.top-bar-conflict-compact{display:flex;align-items:center;gap:.375rem;background:transparent;border:1px solid var(--color-orange);border-radius:0;padding:.25rem .375rem;font-size:.7rem;margin-left:.75rem}.top-bar-conflict-compact-message{color:var(--color-orange);font-family:ui-monospace,monospace;white-space:nowrap;font-size:.75rem;font-weight:500}.top-bar-conflict-button-primary{position:relative;background:var(--color-orange);color:#fff;border:none;border-radius:0;padding:.25rem .5rem;font-size:.7rem;cursor:pointer;font-family:ui-monospace,monospace;transition:all .1s;font-weight:600}.top-bar-conflict-button-primary:hover{background:var(--color-red)}.top-bar-conflict-button-primary:disabled{cursor:not-allowed;background:#ccc}.top-bar-conflict-button-secondary{position:relative;background:transparent;color:var(--color-gray);border:1px solid var(--color-gray-light);border-radius:0;padding:.25rem .5rem;font-size:.7rem;cursor:pointer;font-family:ui-monospace,monospace;transition:all .1s;font-weight:500}.top-bar-conflict-button-secondary:hover{background:var(--color-warm-hover);color:var(--color-black)}.top-bar-conflict-button-secondary:disabled{cursor:not-allowed;color:#ccc;border-color:#ddd}.top-bar-status-text{font-size:.7rem;font-weight:500;color:var(--color-gray-light)}.top-bar-status-text.ready{color:var(--color-teal)}.top-bar-status-text.initializing{color:var(--color-orange)}.top-bar-status-text.connected{color:var(--color-teal)}.top-bar-status-text.connecting{color:var(--color-orange)}.top-bar-status-text.disconnected{color:var(--color-red)}.top-bar-toggle-wrapper{position:relative}.top-bar-toggle-icon{display:inline-flex;align-items:center;justify-content:center;line-height:0}.top-bar-toggle{display:inline-grid;grid-auto-flow:column;align-items:center;column-gap:.5rem;background:transparent;border:1px solid var(--color-gray-light);border-radius:0;padding:0 .8rem;cursor:pointer;font-size:.75rem;font-family:inherit;transition:all .1s;font-weight:500;color:var(--color-gray);height:32px;line-height:1}.top-bar-toggle:hover{background:var(--color-warm-hover);color:var(--color-black);border-color:var(--color-gray)}.top-bar-toggle:disabled{cursor:not-allowed;color:var(--color-gray-light);border-color:#ddd}.top-bar-toggle:disabled .top-bar-toggle-rail{background:#ddd;border-color:#ddd}.top-bar-toggle:disabled .top-bar-toggle-rail:after{background:var(--color-gray-light)}.top-bar-toggle.enabled{border-color:var(--color-teal);background:transparent;color:var(--color-teal)}.top-bar-toggle-label{font-size:.75rem;color:currentColor;line-height:1}.top-bar-toggle.enabled .top-bar-toggle-label{color:var(--color-teal)}.top-bar-toggle-rail{width:24px;height:14px;background:#ddd;border:1px solid var(--color-gray-light);border-radius:0;position:relative;transition:all .1s;box-sizing:border-box}.top-bar-toggle-rail:after{content:"";position:absolute;top:50%;left:2px;width:8px;height:8px;background:#fff;border-radius:0;transform:translateY(-50%);transition:transform .1s}.top-bar-toggle.enabled .top-bar-toggle-rail{background:var(--color-teal);border-color:var(--color-teal)}.top-bar-toggle.enabled .top-bar-toggle-rail:after{transform:translate(10px,-50%);background:#fff}.split-container{display:grid;grid-template-columns:1fr 1fr;flex:0 0 auto;min-height:100vh;box-sizing:border-box;overflow:visible;border-top:none;transition:opacity .15s ease-out;background:#fff}#app.has-topbar .split-container{padding-top:var(--top-bar-height);min-height:calc(100vh - var(--top-bar-height))}.editor-half{display:flex;flex-direction:column;flex:0 0 50%;min-width:0;border-right:1px solid #e5e5e5}.output-half{display:flex;flex:0 0 50%;min-width:0}.split-container.reader-mode{grid-template-columns:0fr 1fr}.editor-hidden{visibility:hidden;width:0;overflow:hidden}.output-full{flex:1}h1{font-size:2.5em;line-height:1.1;margin-bottom:1em;text-align:center;font-weight:800;letter-spacing:-.02em}.editor-container{display:flex;flex-direction:row;width:100%;border:none;border-radius:0;overflow:hidden;box-shadow:none;background:#fff}#editor{flex:1;width:100%;min-width:0}#editor-preview{flex:1;border-left:1px solid #e5e5e5;padding-left:.5rem}.cm-editor{font-size:14px;min-width:0;background:#fff;color:var(--color-black);font-family:ui-monospace,monospace}.cm-focused{outline:none}#output{font-size:13px;font-family:ui-monospace,monospace;width:100%;min-width:0;overflow-x:auto;overflow-y:hidden;background:#fff;border-left:none;padding-right:12px;scrollbar-gutter:stable}.output-content{display:flex;flex-direction:column;position:relative;padding:6px;gap:4px}.output-group{background:transparent;border:none;border-left:3px solid #e5e5e5;margin:0;padding:0 6px 0 8px;border-radius:0}.output-group-error{border-left-color:var(--color-red)}.output-content.reader-mode .output-group{margin:0;border:none;padding-left:8px;padding-right:8px;border-left:2px solid #ddd}.output-group-invisible{background:transparent;border:none;height:0;overflow:hidden;margin:0;padding:0;border-radius:0;box-shadow:none}.output-container,.output-container-invisible{padding:0}.output-line{position:relative}.output-line:not(.empty-line){padding:0}.output-line pre{margin:0;padding:0;font-size:13px;line-height:1.4;color:var(--color-black);font-family:ui-monospace,monospace}.output-item{color:var(--color-black);display:flex;flex-direction:column;align-items:flex-start;gap:0;margin:0}.output-content-wrapper{flex:1;min-width:0;overflow-x:auto;width:100%}.output-debug{margin-top:6px;padding-top:6px;border-top:2px solid var(--color-black)}.output-debug-button{font-size:10px;padding:2px 6px;background:transparent;border:2px solid var(--color-black);border-radius:0;cursor:pointer;font-family:ui-monospace,monospace;color:var(--color-black);transition:all .1s;font-weight:600}.output-debug-button:hover{background:var(--color-black);color:var(--color-yellow)}.output-debug-info{margin-top:6px;padding:6px;background:var(--color-black);border:2px solid var(--color-black);border-radius:0;max-height:400px;overflow:auto;position:relative}.output-debug-info:before{content:"";position:absolute;top:0;left:0;right:0;height:4px;background:var(--gradient-rainbow)}.output-debug-info pre{margin:4px 0 0;font-size:11px;line-height:1.4;color:var(--color-cream);font-family:ui-monospace,monospace}.output-item.output-stdout .output-content-wrapper{color:var(--color-black);font-family:ui-monospace,monospace}.output-item.output-stderr .output-content-wrapper,.output-item.output-error .output-content-wrapper{color:var(--color-red);font-weight:600}.output-item.output-warning .output-content-wrapper{color:var(--color-orange);font-weight:600}.output-item pre{color:var(--color-black);font-family:ui-monospace,monospace;background:transparent;margin:0;padding:0;border:none;white-space:pre-wrap;overflow-wrap:anywhere}.output-item code{color:var(--color-yellow);background:var(--color-black);padding:.2em .4em;border-radius:3px;font-family:ui-monospace,monospace}.output-text-markdown code{color:var(--color-yellow);background:var(--color-black);padding:.2em .4em;border-radius:3px;font-weight:600}.output-text-markdown pre{background:var(--color-black);border:none;padding:1.25rem;overflow-x:auto;margin:.5em 0;position:relative;border-radius:0}.output-text-markdown pre:before{content:"";position:absolute;top:0;left:0;right:0;height:4px;background:var(--gradient-rainbow)}.output-text-markdown pre code{background:none;padding:0;color:var(--color-cream);border-radius:0}.output-text-markdown blockquote{border-left:4px solid var(--color-yellow);margin:.5em 0;padding-left:1em;color:var(--color-gray)}.output-text-markdown h1,.output-text-markdown h2,.output-text-markdown h3,.output-text-markdown h4,.output-text-markdown h5,.output-text-markdown h6{font-weight:700;letter-spacing:-.02em;color:var(--color-black);margin:1em 0 .5em;text-align:left}.output-text-markdown table{margin-left:0;margin-right:auto}.output-text-markdown ul{list-style:none;padding-left:0;margin:.5em 0}.output-text-markdown ul li{padding-left:1.5rem;position:relative;margin:.25em 0}.output-text-markdown ul li:before{content:"";position:absolute;left:0;top:.55em;width:6px;height:6px;background:var(--color-yellow);border:none}.output-text-markdown ul li:nth-child(5n+1):before{background:var(--color-yellow)}.output-text-markdown ul li:nth-child(5n+2):before{background:var(--color-red)}.output-text-markdown ul li:nth-child(5n+3):before{background:var(--color-blue)}.output-text-markdown ul li:nth-child(5n+4):before{background:var(--color-teal)}.output-text-markdown ul li:nth-child(5n+5):before{background:var(--color-orange)}.output-text-markdown ol{padding-left:1.5rem;margin:.5em 0}.output-text-markdown ol li{margin:.25em 0}.output-text-markdown a{color:var(--color-red);text-decoration:none;font-weight:600}.output-text-markdown a:hover{color:var(--color-blue)}.output-text-markdown strong{font-weight:700;color:var(--color-black)}.output-text-markdown em{font-style:italic}.output-text-markdown .output-content-wrapper>*:first-child{margin-top:0;padding-top:0}.output-text-markdown .output-content-wrapper>*:last-child{margin-bottom:0;padding-bottom:0}.output-item.output-plot{margin-top:.25rem}.output-plot canvas{display:block;background:var(--color-cream);width:400px;height:300px;border:2px solid var(--color-black)}.output-image{max-width:100%;max-width:min(100%,1200px);height:auto;display:block;background:var(--color-cream);border:2px solid var(--color-black)}.output-html{width:100%;background:transparent;display:block;overflow-x:auto}.output-html table,.output-html .dt-container{margin-left:0!important;margin-right:auto!important}.output-html .dt-layout-cell{justify-content:flex-start!important;text-align:left!important}.output-table{width:100%;border-collapse:collapse;color:var(--color-gray);border:2px solid var(--color-black)}.output-table td{padding:.25rem .5rem;border:1px solid var(--color-gray);color:var(--color-gray)}.output-table .header-row td{font-weight:700;color:var(--color-black);background:var(--color-warm-hover);border-bottom:3px solid var(--color-black)}.output-table td:last-child{text-align:right;font-family:ui-monospace,monospace}.output-table tr:hover td{background:var(--color-warm-hover)}.empty-line{height:16px}.plot-chart{display:flex;align-items:end;gap:1px;height:30px}.plot-bar{min-width:6px;background-color:var(--color-red);opacity:.8}.array-items{display:flex;flex-wrap:wrap;gap:3px}.array-item{background:var(--color-black);color:var(--color-yellow);padding:2px 4px;border:2px solid var(--color-black);border-radius:0;font-family:ui-monospace,monospace}.output-spacer-container{display:block;background:transparent}.output-spacer{width:100%}.debug-panel{position:fixed;bottom:0;left:0;right:0;background:var(--color-cream);border-top:var(--border-thick);padding:1rem;max-height:300px;overflow-y:auto;font-size:.8rem}.debug-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}.debug-header h3{margin:0;color:var(--color-black);text-transform:uppercase;letter-spacing:.5px;font-weight:700}.debug-status{color:var(--color-gray-light);font-size:.75rem}.debug-table{width:100%;border-collapse:collapse;background:var(--color-cream);border-radius:0;overflow:hidden;border:2px solid var(--color-black)}.debug-table th{background:var(--color-yellow);color:var(--color-black);padding:.5rem 1rem;text-align:right;font-weight:700;font-size:.75rem;border-bottom:3px solid var(--color-black)}.debug-table td{padding:.5rem 1rem;border-bottom:1px solid #ddd;font-size:.75rem;color:var(--color-gray)}.debug-table tbody tr:hover{background:var(--color-warm-hover)}.line-number{font-weight:600;color:var(--color-gray-light);text-align:center;width:60px}.height-value{font-family:ui-monospace,monospace;text-align:right;color:var(--color-black)}.debug-tabs{display:flex;gap:0;margin-bottom:1rem;border-bottom:3px solid var(--color-black)}.debug-tab{background:none;border:none;border-bottom:3px solid transparent;padding:.5rem 1rem;cursor:pointer;font-size:.75rem;font-weight:600;color:var(--color-gray);transition:all .1s;text-transform:uppercase;letter-spacing:.5px;margin-bottom:-3px}.debug-tab:hover{color:var(--color-black);background:var(--color-warm-hover)}.debug-tab.active{color:var(--color-black);border-bottom-color:var(--color-red);background:var(--color-yellow)}.debug-empty{text-align:center;color:var(--color-gray-light);padding:2rem;font-style:italic}.range-id{font-weight:600;color:var(--color-gray-light);text-align:center;width:60px}.range-value{font-family:ui-monospace,monospace;text-align:right;color:var(--color-black)}.top-bar-split-button-wrapper{position:relative;display:flex;align-items:stretch}.top-bar-split-button-main{background:transparent;color:var(--color-gray);border:1px solid var(--color-gray-light);border-right:none;border-radius:0;padding:0 .8rem;font-size:.75rem;cursor:pointer;font-family:inherit;transition:all .1s;font-weight:500;display:flex;align-items:center;gap:.5rem;height:32px}.top-bar-run-label{display:inline-grid}.top-bar-run-label>span{grid-area:1 / 1}.top-bar-run-label-measure{visibility:hidden}.top-bar-split-button-arrow{background:transparent;color:var(--color-gray);border:1px solid var(--color-gray-light);border-left:1px solid #ddd;border-radius:0;padding:0 .4rem;font-size:.75rem;cursor:pointer;font-family:inherit;transition:all .1s;display:flex;align-items:center;justify-content:center;min-width:24px;height:32px}.top-bar-split-button-main:hover:not(:disabled),.top-bar-split-button-arrow:hover:not(:disabled),.top-bar-split-button-arrow.active{background:var(--color-warm-hover);color:var(--color-black);border-color:var(--color-gray)}.top-bar-split-button-main:hover:not(:disabled){border-right:none}.top-bar-split-button-arrow:hover:not(:disabled),.top-bar-split-button-arrow.active{border-left-color:#ddd}.top-bar-split-button-main:disabled{cursor:not-allowed;background:transparent;color:#ccc;border-color:#ddd}.top-bar-split-button-arrow:disabled{cursor:not-allowed;background:transparent;color:#ccc;border-color:#ddd;border-left-color:#ddd}.top-bar-dropdown-menu{position:absolute;top:100%;left:0;margin-top:4px;background:#fff;border:1px solid #ddd;border-radius:0;box-shadow:0 2px 8px #0000001a;min-width:100%;width:max-content;display:flex;flex-direction:column;z-index:1000}.top-bar-dropdown-menu:before{content:"";display:block;position:absolute;top:-4px;left:0;width:100%;height:4px;background:transparent}.top-bar-dropdown-item{padding:8px 12px;cursor:pointer;color:var(--color-gray);font-size:.75rem;font-family:inherit;border:none;background:transparent;text-align:left;font-weight:500;transition:all .1s;display:flex;align-items:center;justify-content:space-between;gap:1rem}.top-bar-dropdown-item:hover,.top-bar-dropdown-item.selected{background:var(--color-warm-hover);color:var(--color-black)}.top-bar-dropdown-item.disabled{cursor:not-allowed;color:var(--color-gray)}.top-bar-dropdown-item.disabled:hover,.top-bar-dropdown-item.disabled.selected{background:transparent;color:var(--color-gray)}.top-bar-dropdown-item-shortcut{font-size:.65rem;opacity:.7}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.fuzzy-finder-dropdown{position:absolute;top:100%;left:0;margin-top:4px;background:#fff;border:1px solid #ddd;border-radius:0;box-shadow:0 2px 8px #0000001a;width:320px;max-height:300px;display:flex;flex-direction:column;overflow:hidden;z-index:1000}.fuzzy-finder-input{background:#fff;color:var(--color-black);border:none;border-bottom:1px solid #ddd;padding:8px 10px;font-size:12px;font-family:inherit;outline:none;width:100%;box-sizing:border-box}.fuzzy-finder-input:focus{background:var(--color-warm-hover)}.fuzzy-finder-input::placeholder{color:var(--color-gray-light)}.fuzzy-finder-list{overflow-y:auto;flex:1}.fuzzy-finder-item{padding:6px 10px;cursor:pointer;display:flex;align-items:baseline;gap:8px;border-bottom:1px solid #ddd;min-width:0}.fuzzy-finder-item:hover{background:var(--color-warm-hover)}.fuzzy-finder-item.selected{background:var(--color-warm-hover);color:var(--color-black)}.fuzzy-finder-filename{color:var(--color-black);font-size:12px;font-family:ui-monospace,monospace;flex-shrink:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:200px;font-weight:600}.fuzzy-finder-path{color:var(--color-gray-light);font-size:10px;font-family:ui-monospace,monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}.fuzzy-match-highlight{color:var(--color-red);font-weight:700}.fuzzy-finder-item.selected .fuzzy-match-highlight{color:var(--color-red)}.fuzzy-finder-empty{padding:12px 10px;text-align:center;color:var(--color-gray-light);font-size:11px;font-family:ui-monospace,monospace;white-space:nowrap}table.dataTable{border-collapse:collapse;font-size:13px;font-family:ui-monospace,monospace;border:1px solid #ddd;background:#fff;width:100%}table.dataTable thead th{background:#f5f5f5;font-weight:600;color:var(--color-black);border-right:1px solid #ddd;border-bottom:1px solid #ddd;padding:8px;font-size:12px;text-align:left}table.dataTable thead th:last-child{border-right:none}table.dataTable tbody td{padding:6px 8px;border-right:1px solid #eee;border-bottom:1px solid #eee;color:var(--color-gray);background:#fff}table.dataTable tbody td:last-child{border-right:none}table.dataTable tbody tr:last-child td{border-bottom:none}table.dataTable tbody tr:hover td{background:#f9f9f9}table.dataTable.stripe tbody tr.odd,table.dataTable.display tbody tr.odd{background:#fff}table.dataTable.stripe tbody tr.odd:hover,table.dataTable.display tbody tr.odd:hover{background:#f9f9f9}div.dt-container{font-family:ui-monospace,monospace;font-size:11px}div.dt-layout-row{display:flex!important;justify-content:space-between!important;align-items:center!important;padding:4px 0!important}div.dt-layout-cell{padding:2px!important}div.dt-search input{background:#fff;border:1px solid #ddd;border-radius:0;padding:2px 6px;font-size:11px;font-family:ui-monospace,monospace;color:var(--color-black);height:22px}div.dt-search input:hover{border-color:#bbb}div.dt-search input:focus{outline:none;border-color:#999;background:#fff}div.dt-length select{background:#fff;border:1px solid #ddd;border-radius:0;padding:2px 6px;font-size:11px;font-family:ui-monospace,monospace;color:var(--color-black);height:22px}div.dt-length select:hover{border-color:#bbb}div.dt-length select:focus{outline:none;border-color:#999;background:#fff}div.dt-paging button{background:transparent;border:1px solid #ddd;border-radius:0;padding:2px 8px;font-size:11px;cursor:pointer;color:var(--color-gray);font-family:ui-monospace,monospace;transition:all .1s;height:22px;margin:0 1px;font-weight:500}div.dt-paging button:hover:not(.disabled){background:#f5f5f5;border-color:#bbb;color:var(--color-black)}div.dt-paging button.disabled{cursor:not-allowed;color:#ccc;border-color:#eee;opacity:.5}div.dt-paging button.current{background:#333;border-color:#333;color:#fff;font-weight:600}div.dt-info{color:var(--color-gray);font-size:11px;font-family:ui-monospace,monospace}table.dataTable.no-footer{border-bottom:1px solid #ddd}table.dataTable thead th.dt-orderable-asc,table.dataTable thead th.dt-orderable-desc,table.dataTable thead th.dt-ordering-asc,table.dataTable thead th.dt-ordering-desc{background:#f0f0f0}small.itables-dtype{color:var(--color-gray-light);font-size:10px}table tbody td{vertical-align:middle}table tbody td a{color:#06c;text-decoration:none}table tbody td a:hover{color:#049;text-decoration:underline}@media (max-width: 900px){.top-bar-label,.top-bar-toggle-label{display:none}}</style>
70
70
  </head>
71
71
  <body>
pdit/_static/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>pdit</title>
8
- <script type="module" crossorigin src="/assets/index-CTENpHH2.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-WLaVrqLo.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-rS96z8hq.css">
10
10
  </head>
11
11
  <body>
pdit/exporter.py CHANGED
@@ -1,13 +1,15 @@
1
1
  """Export functionality for pdit scripts."""
2
2
 
3
+ import asyncio
3
4
  import json
4
5
  from pathlib import Path
5
- from typing import Any
6
+ from threading import Thread
7
+ from typing import Any, Callable, Coroutine
6
8
 
7
9
  from .ipython_executor import IPythonExecutor
8
10
 
9
11
 
10
- def execute_script(script_content: str, script_name: str) -> list[dict[str, Any]]:
12
+ async def _execute_script_async(script_content: str, script_name: str) -> list[dict[str, Any]]:
11
13
  """Execute a script and return expressions in frontend format.
12
14
 
13
15
  Args:
@@ -22,7 +24,7 @@ def execute_script(script_content: str, script_name: str) -> list[dict[str, Any]
22
24
  expression_id = 0
23
25
 
24
26
  try:
25
- for event in executor.execute_script(script_content, script_name=script_name):
27
+ async for event in executor.execute_script(script_content, script_name=script_name):
26
28
  # Skip the expressions list event
27
29
  if event.get("type") == "expressions":
28
30
  continue
@@ -40,11 +42,44 @@ def execute_script(script_content: str, script_name: str) -> list[dict[str, Any]
40
42
  })
41
43
  expression_id += 1
42
44
  finally:
43
- executor.shutdown()
45
+ await executor.shutdown()
44
46
 
45
47
  return expressions
46
48
 
47
49
 
50
+ def _run_async(
51
+ async_fn: Callable[..., Coroutine[Any, Any, Any]],
52
+ *args: Any,
53
+ **kwargs: Any,
54
+ ) -> Any:
55
+ try:
56
+ asyncio.get_running_loop()
57
+ except RuntimeError:
58
+ return asyncio.run(async_fn(*args, **kwargs))
59
+
60
+ result: dict[str, Any] = {}
61
+ error: dict[str, BaseException] = {}
62
+
63
+ def runner() -> None:
64
+ try:
65
+ result["value"] = asyncio.run(async_fn(*args, **kwargs))
66
+ except BaseException as exc:
67
+ error["value"] = exc
68
+
69
+ thread = Thread(target=runner, daemon=True)
70
+ thread.start()
71
+ thread.join()
72
+
73
+ if "value" in error:
74
+ raise error["value"]
75
+ return result["value"]
76
+
77
+
78
+ def execute_script(script_content: str, script_name: str) -> list[dict[str, Any]]:
79
+ """Execute a script and return expressions in frontend format."""
80
+ return _run_async(_execute_script_async, script_content, script_name)
81
+
82
+
48
83
  def generate_html(script_content: str, expressions: list[dict[str, Any]]) -> str:
49
84
  """Generate self-contained HTML from script and execution results.
50
85
 
pdit/ipython_executor.py CHANGED
@@ -12,7 +12,7 @@ import json
12
12
  import logging
13
13
  import re
14
14
  import traceback
15
- from typing import Any, AsyncGenerator, Optional
15
+ from typing import Any, AsyncGenerator, Awaitable, Callable, Optional
16
16
 
17
17
  from jupyter_client import AsyncKernelManager
18
18
 
@@ -177,13 +177,15 @@ del _register_pdit_runtime_hooks
177
177
  source = '\n'.join(source_lines)
178
178
 
179
179
  is_expr = isinstance(node, ast.Expr)
180
- is_markdown_cell = is_expr and isinstance(node.value, ast.Constant) and isinstance(node.value.value, str)
180
+ is_string_literal = is_expr and isinstance(node.value, ast.Constant) and isinstance(node.value.value, str)
181
+ is_fstring = is_expr and isinstance(node.value, ast.JoinedStr)
181
182
 
182
183
  statements.append({
183
184
  "lineStart": line_start,
184
185
  "lineEnd": line_end,
185
186
  "source": source,
186
- "isMarkdownCell": is_markdown_cell
187
+ "isMarkdownCell": is_string_literal,
188
+ "isFStringMarkdown": is_fstring
187
189
  })
188
190
 
189
191
  return statements
@@ -232,8 +234,17 @@ del _register_pdit_runtime_hooks
232
234
 
233
235
  return output
234
236
 
235
- async def _execute_code(self, code: str) -> list[dict]:
236
- """Execute code in kernel and collect output."""
237
+ async def _execute_code(
238
+ self,
239
+ code: str,
240
+ on_stream: Callable[[list[dict]], Awaitable[None]] | None = None,
241
+ ) -> list[dict]:
242
+ """Execute code in kernel and collect output.
243
+
244
+ Args:
245
+ code: Python source to execute in the kernel.
246
+ on_stream: Optional callback invoked when stdout/stderr updates arrive.
247
+ """
237
248
  if self.kc is None:
238
249
  return [{"type": "error", "content": "Kernel not started"}]
239
250
 
@@ -263,6 +274,8 @@ del _register_pdit_runtime_hooks
263
274
  output[-1] = {"type": stream_name, "content": output[-1]["content"] + text}
264
275
  else:
265
276
  output.append({"type": stream_name, "content": text})
277
+ if on_stream:
278
+ await on_stream(output)
266
279
  elif msg_type == 'execute_result':
267
280
  # Expression result
268
281
  data = content['data']
@@ -289,7 +302,8 @@ del _register_pdit_runtime_hooks
289
302
  self,
290
303
  script: str,
291
304
  line_range: tuple[int, int] | None = None,
292
- script_name: str | None = None
305
+ script_name: str | None = None,
306
+ on_stream: Callable[[int, int, list[dict]], Awaitable[None]] | None = None,
293
307
  ) -> AsyncGenerator[dict, None]:
294
308
  """Execute Python script, yielding event dicts as each statement completes.
295
309
 
@@ -297,6 +311,7 @@ del _register_pdit_runtime_hooks
297
311
  First: {"type": "expressions", "expressions": [{"lineStart": N, "lineEnd": N}, ...]}
298
312
  Then for each statement: {"lineStart": N, "lineEnd": N, "output": [...], "isInvisible": bool}
299
313
  On error during execution, the final result dict will have output with type="error"
314
+ If on_stream is provided, it is invoked on stdout/stderr updates with the current output list.
300
315
  """
301
316
  # Wait for kernel to be ready
302
317
  await self.wait_ready()
@@ -342,15 +357,27 @@ del _register_pdit_runtime_hooks
342
357
 
343
358
  # Execute each statement
344
359
  for stmt in statements:
360
+ stream_cb = None
361
+ if on_stream is not None:
362
+ line_start = stmt["lineStart"]
363
+ line_end = stmt["lineEnd"]
364
+
365
+ async def stream_cb(updated_output: list[dict]) -> None:
366
+ await on_stream(line_start, line_end, updated_output)
367
+
345
368
  if stmt["isMarkdownCell"]:
346
369
  # For markdown cells, just return the string content
347
370
  try:
348
371
  value = ast.literal_eval(stmt["source"])
349
372
  output = [{"type": "text/markdown", "content": str(value).strip()}]
350
373
  except (ValueError, SyntaxError):
351
- output = await self._execute_code(stmt["source"])
374
+ output = await self._execute_code(stmt["source"], on_stream=stream_cb)
375
+ elif stmt["isFStringMarkdown"]:
376
+ # Wrap f-string in Markdown() so it returns text/markdown directly
377
+ wrapper_code = f"__import__('IPython').display.Markdown({stmt['source']})"
378
+ output = await self._execute_code(wrapper_code, on_stream=stream_cb)
352
379
  else:
353
- output = await self._execute_code(stmt["source"])
380
+ output = await self._execute_code(stmt["source"], on_stream=stream_cb)
354
381
 
355
382
  yield {
356
383
  "lineStart": stmt["lineStart"],
pdit/server.py CHANGED
@@ -174,7 +174,7 @@ async def websocket_session(websocket: WebSocket, sessionId: str, token: Optiona
174
174
 
175
175
  Message Protocol (Server -> Client):
176
176
  File events: {"type": "initial/fileChanged/fileDeleted", "path": "...", "content": "...", "timestamp": N}
177
- Execution: {"type": "expressions/result/cancelled/complete/busy", ...}
177
+ Execution: {"type": "expressions/result/stream/cancelled/complete/busy", ...}
178
178
  Errors: {"type": "error", "message": "..."}
179
179
  """
180
180
  # Validate token if configured
@@ -290,7 +290,26 @@ async def _handle_ws_execute(websocket: WebSocket, session: Session, data: dict)
290
290
  expressions: list[dict] = []
291
291
  executed_count = 0
292
292
 
293
- async for event in session.executor.execute_script(script, line_range, script_name):
293
+ async def _send_stream_update(line_start: int, line_end: int, output: list[dict]) -> None:
294
+ if shutdown_event.is_set():
295
+ return
296
+ try:
297
+ await websocket.send_json({
298
+ "type": "stream",
299
+ "lineStart": line_start,
300
+ "lineEnd": line_end,
301
+ "output": output,
302
+ })
303
+ except Exception:
304
+ # Connection may have closed; ignore streaming failures
305
+ pass
306
+
307
+ async for event in session.executor.execute_script(
308
+ script,
309
+ line_range,
310
+ script_name,
311
+ on_stream=_send_stream_update,
312
+ ):
294
313
  # Add type field to result messages (executor yields without type)
295
314
  if "output" in event and "type" not in event:
296
315
  event = {"type": "result", **event}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdit
3
- Version: 0.6.0a1
3
+ Version: 0.7.0
4
4
  Summary: Interactive Python code editor with inline execution results
5
5
  Author: Harry Vangberg
6
6
  License: MIT
@@ -0,0 +1,17 @@
1
+ pdit/__init__.py,sha256=QpiMnN_x5G3QaeWMXQlCRUtCo35IEYZLPj-cz87WG_g,185
2
+ pdit/_demo.py,sha256=SMOGoiHBdMDq8pXRVK-uuTRFCFbRd47diUyRR8Y3wZY,2026
3
+ pdit/cli.py,sha256=3YkWz2Sg3-OszRssWkXbPEu3dDQAXMS8Z0c07bZ7gx8,9634
4
+ pdit/exporter.py,sha256=xDFkAzigh7dDDCSqPP6nI4WKlZ_xI1XIKC2QkcdpRVg,3792
5
+ pdit/file_watcher.py,sha256=1WlqKWjLCdgMZLdN836MEeWTisGCtZmvgRdOFN-jns8,5200
6
+ pdit/ipython_executor.py,sha256=KMBFg4Xl5M2iiV8kkpSFJUURv9XjKYl5Nf1y5HzivxQ,17244
7
+ pdit/server.py,sha256=V5uFMqPle7JGeMHWRjniiN0m1z7rK-pOBZ1tiPNPU5E,14566
8
+ pdit/_static/export.html,sha256=ITKX3MKoWQYoR8EqkMTfsEYjpNWfhVVi-Mdmw_jpxoY,332339
9
+ pdit/_static/index.html,sha256=iDl5_lp8ailmLfeKWcGvEDY_wI6_hS5uMnDGRGEu1-o,450
10
+ pdit/_static/assets/index-WLaVrqLo.js,sha256=6g0aNVXaBOwAISafLYvgP-0bpEVL-YuQs026ebsFE4w,815277
11
+ pdit/_static/assets/index-rS96z8hq.css,sha256=0EMq2r0to1VxGznyp18tWCd97_sSZhGVC3YF7QdBXEU,22855
12
+ pdit-0.7.0.dist-info/licenses/LICENSE,sha256=Y9tvBURRu-1aHUHY-tnbsDpPBTRYKWpIInVmaoOUkME,1071
13
+ pdit-0.7.0.dist-info/METADATA,sha256=3tr06V3Xyy1c9elzPK1x0ULeowwrUrhJChqef0lsST0,1859
14
+ pdit-0.7.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
15
+ pdit-0.7.0.dist-info/entry_points.txt,sha256=n9I4wGD7M0NQrPWJcTWOsJAzeS6bQJbTnUP8C3Sl-iY,39
16
+ pdit-0.7.0.dist-info/top_level.txt,sha256=wk6vel1ecJS4EZZ3U6Xue9OwDq-Tw8Pbvq_TRQz9eIQ,5
17
+ pdit-0.7.0.dist-info/RECORD,,
@@ -1,17 +0,0 @@
1
- pdit/__init__.py,sha256=QpiMnN_x5G3QaeWMXQlCRUtCo35IEYZLPj-cz87WG_g,185
2
- pdit/_demo.py,sha256=SMOGoiHBdMDq8pXRVK-uuTRFCFbRd47diUyRR8Y3wZY,2026
3
- pdit/cli.py,sha256=3YkWz2Sg3-OszRssWkXbPEu3dDQAXMS8Z0c07bZ7gx8,9634
4
- pdit/exporter.py,sha256=i2emLqRQNPW92vFBTamLZyOhUTDU45_0QnOWG7PcIu8,2811
5
- pdit/file_watcher.py,sha256=1WlqKWjLCdgMZLdN836MEeWTisGCtZmvgRdOFN-jns8,5200
6
- pdit/ipython_executor.py,sha256=EZZ1s3R0VB4w8mD64Mw4bIgjQAJJQFrOJsUJK7ZWC7o,15917
7
- pdit/server.py,sha256=URabdsLxiLUipkl8PTc5jgDjMlQV0v8QJTMnNNy0XKs,13941
8
- pdit/_static/export.html,sha256=bBeRCDetAhp__f_IeDcwR1RtM3jZXnmhTZ2H_yjKViE,332294
9
- pdit/_static/index.html,sha256=asTkL8UvMT9q-3tMAxUVql0RrtlS8i1BypDt4uYDkFo,450
10
- pdit/_static/assets/index-CTENpHH2.js,sha256=2jt-rCNgRGTUnmzlTyQ_7ZNKp2xom7AxwmzTRaBZsQA,814857
11
- pdit/_static/assets/index-rS96z8hq.css,sha256=0EMq2r0to1VxGznyp18tWCd97_sSZhGVC3YF7QdBXEU,22855
12
- pdit-0.6.0a1.dist-info/licenses/LICENSE,sha256=Y9tvBURRu-1aHUHY-tnbsDpPBTRYKWpIInVmaoOUkME,1071
13
- pdit-0.6.0a1.dist-info/METADATA,sha256=YyByJOaWYlFw4bNKz-ikkVIT-WGQP8b9GNDwYcoIZS4,1861
14
- pdit-0.6.0a1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
15
- pdit-0.6.0a1.dist-info/entry_points.txt,sha256=n9I4wGD7M0NQrPWJcTWOsJAzeS6bQJbTnUP8C3Sl-iY,39
16
- pdit-0.6.0a1.dist-info/top_level.txt,sha256=wk6vel1ecJS4EZZ3U6Xue9OwDq-Tw8Pbvq_TRQz9eIQ,5
17
- pdit-0.6.0a1.dist-info/RECORD,,
File without changes