@json-to-office/jto 6.8.0 → 7.0.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/dist/cli.js +17 -9
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/{HomePage-DdKO7Rz8.js → HomePage-CAQsE0sn.js} +4 -4
- package/dist/client/assets/HomePage-CAQsE0sn.js.map +1 -0
- package/dist/client/assets/{JsonEditorPage-CIB7kfUW.js → JsonEditorPage-Cqz2zDan.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-CIB7kfUW.js.map → JsonEditorPage-Cqz2zDan.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-Cql9aylS.js → MonacoPluginProvider-FJHgHgFQ.js} +5 -5
- package/dist/client/assets/{MonacoPluginProvider-Cql9aylS.js.map → MonacoPluginProvider-FJHgHgFQ.js.map} +1 -1
- package/dist/client/assets/{_virtual_jto-plugin-type-libs-BJgH7I8Z.js → _virtual_jto-plugin-type-libs-DroopP3q.js} +39 -14
- package/dist/client/assets/{_virtual_jto-plugin-type-libs-BJgH7I8Z.js.map → _virtual_jto-plugin-type-libs-DroopP3q.js.map} +1 -1
- package/dist/client/assets/_virtual_jto-sandbox-runtime-v4kQF3ee.js +2 -0
- package/dist/client/assets/_virtual_jto-sandbox-runtime-v4kQF3ee.js.map +1 -0
- package/dist/client/assets/{editor-Dl0mPZWB.js → editor-1mTGQjga.js} +2 -2
- package/dist/client/assets/{editor-Dl0mPZWB.js.map → editor-1mTGQjga.js.map} +1 -1
- package/dist/client/assets/{editor-monaco-json-BWLlWM6o.js → editor-monaco-json-B19wOO_b.js} +2 -2
- package/dist/client/assets/{editor-monaco-json-BWLlWM6o.js.map → editor-monaco-json-B19wOO_b.js.map} +1 -1
- package/dist/client/assets/{index-Db2WFiF0.js → index-Da5mi8tP.js} +2 -2
- package/dist/client/assets/{index-Db2WFiF0.js.map → index-Da5mi8tP.js.map} +1 -1
- package/dist/client/assets/{index-1Vg-Jg2R.js → index-DsuZTLjf.js} +5 -5
- package/dist/client/assets/index-DsuZTLjf.js.map +1 -0
- package/dist/client/assets/{preview-BXysnPth.js → preview-T1T-uQbx.js} +2 -2
- package/dist/client/assets/preview-T1T-uQbx.js.map +1 -0
- package/dist/client/assets/{useQualityAnalysis-Dr3UHxyN.js → useQualityAnalysis-CnLgG345.js} +2 -2
- package/dist/client/assets/{useQualityAnalysis-Dr3UHxyN.js.map → useQualityAnalysis-CnLgG345.js.map} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/templates/client-report-blocks.docx.json +1 -1
- package/dist/client/templates/consulting-deck-blocks.pptx.json +39 -18
- package/dist/client/templates/data-report-presentation.pptx.json +1 -1
- package/dist/client/templates/management-plan.pptx.json +4 -4
- package/dist/client/templates/minimalist-pitch-deck.pptx.json +1 -1
- package/dist/client/templates/modern-annual-report-3.docx.json +1 -0
- package/dist/client/templates/technical-report-blocks.docx.json +1 -1
- package/package.json +8 -8
- package/dist/client/assets/HomePage-DdKO7Rz8.js.map +0 -1
- package/dist/client/assets/_virtual_jto-sandbox-runtime-BFXK15tx.js +0 -2
- package/dist/client/assets/_virtual_jto-sandbox-runtime-BFXK15tx.js.map +0 -1
- package/dist/client/assets/index-1Vg-Jg2R.js.map +0 -1
- package/dist/client/assets/preview-BXysnPth.js.map +0 -1
package/dist/client/assets/{useQualityAnalysis-Dr3UHxyN.js → useQualityAnalysis-CnLgG345.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{y as te,z as ne,a as re,c as T,w as he,F as L}from"./index-1Vg-Jg2R.js";import{z as ye,I as oe,n as be,A as me}from"./HomePage-DdKO7Rz8.js";import{r as c,j as p}from"./react-vendor-BmQ2Ko_D.js";import{e as xe,X as ke,b as ve,C as Se}from"./ui-vendor-BsAtAN16.js";import{d as Te,x as Ce,T as Ae,f as F,v as Ee}from"./MonacoPluginProvider-Cql9aylS.js";function gt(e){try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?{ok:!1,error:"A theme is a JSON object."}:{ok:!0,theme:t}}catch(t){return{ok:!1,error:t instanceof Error?t.message:"Invalid JSON"}}}function ht(e){return JSON.stringify(e,null,2)}function _(e,t,n){return ye(e,t,n)}function yt(e,t){if(t.length===0)return e;const n=t.slice(0,-1),r=t[t.length-1],o=we(e,n);if(!o||typeof o!="object")return e;if(Array.isArray(o)){if(typeof r!="number"||!Number.isInteger(r)||r<0||r>=o.length)return e;const i=o.slice();return i.splice(r,1),n.length===0?i:_(e,n,i)}if(!Object.prototype.hasOwnProperty.call(o,r))return e;const s={...o};return delete s[r],n.length===0?s:_(e,n,s)}function we(e,t){let n=e;for(const r of t){if(n===null||typeof n!="object")return;n=n[r]}return n}const H={primary:"Headings, the strongest brand colour",secondary:"Supporting brand colour",accent:"Highlights and emphasis",text:"Default body text",textPrimary:"Primary text",textSecondary:"Secondary text",textMuted:"Captions and de-emphasised text",background:"Page or slide background",backgroundPrimary:"Primary surface",backgroundSecondary:"Alternate surface, table stripes",background2:"Alternate surface, table rules",text2:"Secondary text, captions",border:"Default rules and borders",borderPrimary:"Primary rules",borderSecondary:"Subtle rules",accent4:"Chart series 4",accent5:"Chart series 5",accent6:"Chart series 6"},Oe=[["Core",["primary","secondary","accent"]],["Text",["text","textPrimary","textSecondary","textMuted","text2"]],["Background",["background","backgroundPrimary","backgroundSecondary","background2"]],["Border",["border","borderPrimary","borderSecondary"]],["Chart",["accent4","accent5","accent6"]]];function Y(e){return e.replace(/([a-z])([A-Z0-9])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function Ne(e){var n;const t=(n=e==null?void 0:e.properties)==null?void 0:n.colors;return{keys:Object.keys((t==null?void 0:t.properties)??{}),required:new Set((t==null?void 0:t.required)??[])}}function bt(e){const{keys:t,required:n}=Ne(e==="docx"?te:ne),r=[],o=new Set;for(const[s,i]of Oe)for(const l of i)t.includes(l)&&(o.add(l),r.push({key:l,label:Y(l),group:s,required:n.has(l),hint:H[l]??""}));for(const s of t)o.has(s)||r.push({key:s,label:Y(s),group:"Other",required:n.has(s),hint:H[s]??""});return r}const se=/^#[0-9A-Fa-f]{6}$/;function mt(e){return typeof e=="string"&&se.test(e)}function xt(e){const t=e.trim(),n=t.match(/^#?([0-9A-Fa-f]{3})$/);if(n)return`#${n[1].split("").map(o=>o+o).join("").toUpperCase()}`;const r=t.match(/^#?([0-9A-Fa-f]{6})$/);return r?`#${r[1].toUpperCase()}`:t}function kt(e){const t=e.colors;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,n])=>typeof n=="string").map(([n])=>n)}function je(e,t,n=0){if(typeof t!="string"||n>8)return null;if(se.test(t))return t;const r=t.match(/^#?([0-9A-Fa-f]{6})$/);if(r)return`#${r[1]}`;const o=e.colors;return o?je(e,o[t],n+1):null}function vt(e,t){const n=K(e),r=K(t);if(n===null||r===null)return null;const[o,s]=n>r?[n,r]:[r,n];return(o+.05)/(s+.05)}function K(e){const t=e.match(/^#?([0-9A-Fa-f]{6})$/);if(!t)return null;const n=[0,2,4].map(r=>{const o=parseInt(t[1].slice(r,r+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*n[0]+.7152*n[1]+.0722*n[2]}const St=["heading","body","mono","light"],Tt=["heading","body"],Ct={heading:"Headings and titles",body:"Body text",mono:"Code and tabular figures",light:"Large, light display text"},At=["A4","A3","LETTER","LEGAL"],Et=["top","bottom","left","right","header","footer","gutter"],ie={in:1440,cm:1440/2.54,pt:20,twips:1};function wt(e,t){const n=e/ie[t];return t==="twips"?Math.round(n):Math.round(n*100)/100}function Ot(e,t){return Math.round(e*ie[t])}const ae=["left","center","right","justify"],Ie=[{path:["font"],label:"Font role",kind:"fontRole"},{path:["size"],label:"Size",kind:"number",unit:"pt",min:8,max:120,step:.5},{path:["color"],label:"Colour",kind:"color"},{path:["bold"],label:"Bold",kind:"boolean"},{path:["italic"],label:"Italic",kind:"boolean"},{path:["underline"],label:"Underline",kind:"boolean"},{path:["alignment"],label:"Alignment",kind:"select",options:ae},{path:["spacing","before"],label:"Space before",kind:"number",unit:"pt",min:0,step:1},{path:["spacing","after"],label:"Space after",kind:"number",unit:"pt",min:0,step:1},{path:["lineSpacing","type"],label:"Line spacing",kind:"select",options:["single","multiple","double","atLeast","exactly"]},{path:["lineSpacing","value"],label:"Line spacing value",kind:"number",min:0,step:.05,hint:"A factor for multiple; points for atLeast and exactly"},{path:["fontWeight"],label:"Weight",kind:"number",min:100,max:900,step:100,advanced:!0},{path:["characterSpacing","type"],label:"Tracking",kind:"select",options:["condensed","expanded"],advanced:!0},{path:["characterSpacing","value"],label:"Tracking amount",kind:"number",min:0,step:1,advanced:!0,hint:"Twentieths of a point"},{path:["scale"],label:"Width scale",kind:"number",unit:"%",min:1,max:600,step:1,advanced:!0},{path:["keepNext"],label:"Keep with next",kind:"boolean",advanced:!0},{path:["keepLinesTogether"],label:"Keep lines together",kind:"boolean",advanced:!0},{path:["widowControl"],label:"Widow control",kind:"boolean",advanced:!0},{path:["outlineLevel"],label:"Outline level",kind:"number",min:0,max:9,step:1,advanced:!0},{path:["baseStyle"],label:"Based on",kind:"text",advanced:!0},{path:["followingStyle"],label:"Next style",kind:"text",advanced:!0}],Pe=[{path:["fontSize"],label:"Size",kind:"number",unit:"pt",min:1,max:200,step:1},{path:["fontFace"],label:"Font",kind:"fontFamily"},{path:["fontColor"],label:"Colour",kind:"color"},{path:["bold"],label:"Bold",kind:"boolean"},{path:["italic"],label:"Italic",kind:"boolean"},{path:["align"],label:"Alignment",kind:"select",options:ae},{path:["lineSpacing"],label:"Line spacing",kind:"number",unit:"pt",min:0,step:1,advanced:!0},{path:["charSpacing"],label:"Tracking",kind:"number",unit:"pt",step:.5,advanced:!0},{path:["paraSpaceAfter"],label:"Space after",kind:"number",unit:"pt",min:0,step:1,advanced:!0},{path:["fontWeight"],label:"Weight",kind:"number",min:100,max:900,step:100,advanced:!0}],Re=["normal","title","subtitle","heading1","heading2","heading3","heading4","heading5","heading6","TOC1","TOC2","TOC3","TOC4","TOC5","TOC6"];function J(e){var r;const t=(r=e==null?void 0:e.properties)==null?void 0:r.styles;if(!t)return[];if(t.properties)return Object.keys(t.properties);const n=(t.anyOf??[]).find(o=>o.properties);return n?Object.keys(n.properties):[]}function Le(e){if(e==="docx"){const t=J(te),n=Re.filter(r=>t.includes(r));return[...n,...t.filter(r=>!n.includes(r))]}return J(ne)}function Nt(e){return e==="docx"?Ie:Pe}function jt(e,t){const n=new Set(Le(t)),r=e.styles;return!r||typeof r!="object"?[]:Object.keys(r).filter(o=>!n.has(o))}const De={normal:"Normal (body)",title:"Title",subtitle:"Subtitle",body:"Body",caption:"Caption",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",TOC1:"TOC level 1",TOC2:"TOC level 2",TOC3:"TOC level 3",TOC4:"TOC level 4",TOC5:"TOC level 5",TOC6:"TOC level 6"};function It(e){return De[e]??e}const ce={docx:["name","displayName","description","version","colors","fonts","page","styles"],pptx:["name","displayName","description","version","colors","fonts","defaults","styles"]};function Pt(e){return ce[e]}function Rt(e,t,n=[]){const r=new Set([...ce[t],...n]);return Object.keys(e).filter(o=>!r.has(o)).map(o=>({key:o,summary:Fe(e[o])}))}function Fe(e){if(Array.isArray(e))return`${e.length} item${e.length===1?"":"s"}`;if(e&&typeof e=="object"){const t=Object.keys(e);return t.length===0?"empty":t.slice(0,4).join(", ")+(t.length>4?", …":"")}return typeof e=="string"?e.length>40?`${e.slice(0,40)}…`:e:String(e)}function Lt(e,t){let n=e;const r=t==="docx"?["colors","fonts","page","styles"]:["colors","fonts","defaults","styles"];for(const o of r)(!n[o]||typeof n[o]!="object")&&(n=_(n,[o],{}));return n}const le=c.createContext(null),Dt=le.Provider;function Ft(){const e=c.useContext(le);if(!e)throw new Error("useThemeEditor must be used inside ThemeVisualEditor");return e}const $={safe:[],google:[]};let w=null,R=null;function _e(){return w?Promise.resolve(w):(R||(R=fetch(re.fonts.catalog).then(e=>e.ok?e.json():$).then(e=>{const t=e;return w={safe:Array.isArray(t==null?void 0:t.safe)?t.safe:[],google:Array.isArray(t==null?void 0:t.google)?t.google:[]},w}).catch(()=>(R=null,$))),R)}function _t(){const[e,t]=c.useState(w??$);return c.useEffect(()=>{let n=!0;return w||_e().then(r=>{n&&t(r)}),()=>{n=!1}},[]),e}const ue="h-7 px-2 text-xs shadow-none",$t="h-7 min-h-0 w-full gap-1.5 px-2 py-0 text-xs shadow-none [&>span]:truncate [&>span]:whitespace-nowrap",$e="text-[11px] leading-snug text-muted-foreground",Bt="text-[11px] font-medium leading-none text-muted-foreground";function zt({title:e,hint:t,actions:n,defaultOpen:r=!0,forceOpen:o,children:s}){const[i,l]=c.useState(r),a=o??i;return p.jsxs("section",{className:"border-t border-border/60 pt-2 first:border-t-0","data-crumb":e,children:[p.jsxs("div",{className:"flex h-7 items-center gap-1.5",children:[p.jsxs("button",{type:"button",onClick:()=>l(d=>!d),"aria-expanded":a,className:T("flex h-7 min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-sm px-1","text-foreground/75 transition-colors hover:bg-accent hover:text-foreground","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"),children:[p.jsx(xe,{"aria-hidden":!0,className:T("size-3 shrink-0 transition-transform duration-150 ease-out",a&&"rotate-90")}),p.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] uppercase",children:e})]}),n&&p.jsx("div",{className:"flex shrink-0 items-center gap-1 pr-1",children:n})]}),t&&p.jsx("p",{className:T($e,"px-1 pb-2"),children:t}),a&&p.jsx("div",{className:"flex flex-col gap-3 px-1 pb-4",children:s})]})}function Mt({children:e}){return p.jsx("div",{className:"pt-1 text-[10px] tracking-[0.08em] text-muted-foreground uppercase",children:e})}function qt({label:e,onClick:t,className:n}){return p.jsx("button",{type:"button",onClick:t,"aria-label":e,title:e,className:T("flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm","text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",n),children:p.jsx(ke,{className:"size-3.5","aria-hidden":!0})})}function Ut({children:e,onClick:t,className:n,...r}){return p.jsx("button",{type:"button",onClick:t,className:T("flex h-6 cursor-pointer items-center gap-1 rounded-sm px-1.5","text-[11px] font-medium text-muted-foreground transition-colors","hover:bg-accent hover:text-foreground","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-50",n),...r,children:e})}function Gt({label:e,value:t,options:n,onChange:r,className:o}){return p.jsx("div",{role:"radiogroup","aria-label":e,className:T("flex h-6 shrink-0 items-center rounded-sm border border-border/70 bg-muted/60 p-0.5",o),children:n.map(s=>{const i=s.value===t;return p.jsx("button",{type:"button",role:"radio","aria-checked":i,onClick:()=>r(s.value),className:T("flex h-full flex-1 cursor-pointer items-center justify-center rounded-[3px] px-1.5 text-[11px] transition-colors","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",i?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:s.label},s.value)})})}function de(e,t){const[n,r]=c.useState(null),o=c.useRef(null),s=c.useCallback(f=>{o.current=f,r(f)},[]),i=c.useCallback(()=>s(e),[e,s]),l=c.useCallback(f=>s(f.target.value),[s]),a=c.useCallback(()=>{const f=o.current;s(null),f!==null&&f!==e&&t(f)},[t,e,s]),d=c.useCallback(f=>{f.key==="Enter"?(f.preventDefault(),f.currentTarget.blur()):f.key==="Escape"&&(s(null),f.currentTarget.blur())},[s]);return{syncDraft:c.useCallback(f=>{o.current!==null&&s(f)},[s]),props:{value:n??e,onFocus:i,onChange:l,onBlur:a,onKeyDown:d}}}function Ht({value:e,onCommit:t,className:n,...r}){const o=c.useCallback(i=>t(i.trim()===""?null:i),[t]),{props:s}=de(e??"",o);return p.jsx(oe,{type:"text",autoComplete:"off",spellCheck:!1,className:T(ue,n),...s,...r})}function Be(e){const t=c.useRef(null),n=c.useCallback(()=>{t.current&&clearTimeout(t.current),t.current=null},[]),r=c.useCallback(o=>{e(o);const s=i=>{t.current=setTimeout(()=>{e(o),s(60)},i)};s(400)},[e]);return c.useEffect(()=>n,[n]),{start:r,stop:n}}function Yt({value:e,onCommit:t,unit:n,className:r,min:o,max:s,step:i=1,...l}){const a=c.useCallback(v=>{const m=v.trim();if(m===""){t(null);return}const S=Number(m);Number.isFinite(S)&&t(S)},[t]),{props:d,syncDraft:h}=de(e===void 0?"":String(e),a),f=typeof i=="number"?i:Number(i)||1,k=typeof o=="number"?o:Number(o),u=typeof s=="number"?s:Number(s),y=c.useCallback(v=>{let S=(e??(Number.isFinite(k)?k:0))+v*f;Number.isFinite(k)&&(S=Math.max(k,S)),Number.isFinite(u)&&(S=Math.min(u,S));const E=Number(S.toFixed(4));t(E),h(String(E))},[k,f,t,h,u,e]),b=Be(y);return p.jsxs("div",{className:"relative flex min-w-0 items-center",children:[p.jsx(oe,{type:"number",inputMode:"decimal",min:o,max:s,step:i,className:T(ue,"tabular-nums",n?"pr-11":"pr-5","[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",r),...d,...l}),n&&p.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute right-5 text-[10px] text-muted-foreground",children:n}),p.jsxs("div",{className:"absolute right-0 flex h-7 w-4 flex-col border-l border-input/70",children:[p.jsx(W,{label:"Increase",icon:ve,onStart:()=>b.start(1),onStop:b.stop,disabled:Number.isFinite(u)&&e!==void 0&&e>=u}),p.jsx(W,{label:"Decrease",icon:Se,onStart:()=>b.start(-1),onStop:b.stop,disabled:Number.isFinite(k)&&e!==void 0&&e<=k})]})]})}function W({label:e,icon:t,onStart:n,onStop:r,disabled:o}){return p.jsx("button",{type:"button","aria-label":e,tabIndex:-1,disabled:o,onPointerDown:s=>{s.preventDefault(),n()},onPointerUp:r,onPointerLeave:r,onPointerCancel:r,className:T("flex h-1/2 cursor-pointer items-center justify-center","text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","disabled:pointer-events-none disabled:opacity-30"),children:p.jsx(t,{className:"size-2.5"})})}function ze(e){return e>=4.5?"text-success":e>=3?"text-warning":"text-destructive"}function Kt({label:e,ratio:t}){return p.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[e,p.jsx("span",{className:T("font-medium tabular-nums",t===null?"text-muted-foreground":ze(t)),title:t===null?"Both colours must resolve to a hex":t>=4.5?"Meets WCAG AA for body text":t>=3?"Large text only":"Below WCAG minimums",children:t===null?"—":`${t.toFixed(1)}:1`})]})}const Me=["error","warning","info"],Q={error:0,warning:1,info:2},B=3;function j(e){return typeof e=="string"&&e in Q?Q[e]:B}const qe=["deterministic","measured","estimated","rendered","evaluative"],Ue=["add","replace","remove","move","copy","test"],Ge="other";function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function He(e){return O(e)}function A(e){return typeof e=="string"?e:void 0}function I(e){return typeof e=="string"&&Me.includes(e)?e:void 0}function fe(e){return typeof e=="string"&&qe.includes(e)?e:void 0}function Ye(e){if(!Array.isArray(e))return;const t=e.filter(n=>typeof n=="string");return t.length>0?t:void 0}function Ke(e){return O(e)?e:void 0}function Je(e){if(!Array.isArray(e))return;const t=[];for(const n of e){if(!O(n))continue;const r=n.op,o=n.path;if(typeof r!="string"||typeof o!="string"||!Ue.includes(r))continue;const s={op:r,path:o};"value"in n&&(s.value=n.value);const i=A(n.from);i!==void 0&&(s.from=i),t.push(s)}return t.length>0?t:void 0}function We(e,t){if(!t)return e;const n=`[${t}] `;return e.startsWith(n)?e.slice(n.length):e}function Qe(e,t,n){return`${e||"quality"}:${t}:${n}`}function pe(e,t){const n=A(e.code)??"",r=A(e.message)??"";if(!n&&!r)return;const o=A(e.path)??"",s={id:Qe(n,o,t),code:n,message:We(r,n)||n,path:o,severity:e.severity},i=A(e.ruleId);i!==void 0&&(s.ruleId=i);const l=A(e.category);l!==void 0&&(s.category=l);const a=fe(e.certainty);a!==void 0&&(s.certainty=a),typeof e.blocking=="boolean"&&(s.blocking=e.blocking);const d=A(e.suggestion);d!==void 0&&(s.suggestion=d);const h=Ye(e.relatedPaths);h!==void 0&&(s.relatedPaths=h);const f=Ke(e.evidence);f!==void 0&&(s.evidence=f);const k=Je(e.fixes);return k!==void 0&&(s.fixes=k),s}function Jt(e){const t=[],n=[];if(!Array.isArray(e))return{findings:t,others:n};for(const r of e){if(!He(r))continue;if(r.component!=="quality"){n.push(r);continue}const o=O(r.context)?r.context:{},s=I(o.originalSeverity)??I(r.severity)??"warning",i=pe({code:o.code,message:r.message,path:o.path,severity:s,ruleId:o.ruleId,category:o.category,certainty:o.certainty,blocking:o.blocking,suggestion:o.suggestion,relatedPaths:o.relatedPaths,evidence:o.evidence,fixes:o.fixes},t.length);i&&t.push(i)}return{findings:t,others:n}}function X(e){if(!O(e))return[];const t=e.diagnostics;if(!Array.isArray(t))return[];const n=[];for(const r of t){if(!O(r))continue;const o=pe({code:r.code,message:r.message,path:r.path,severity:I(r.severity)??"warning",ruleId:r.ruleId,category:r.category,certainty:r.certainty,blocking:r.blocking,suggestion:r.suggestion,relatedPaths:r.relatedPaths,evidence:r.evidence,fixes:r.fixes},n.length);o&&n.push(o)}return n}function V(e){const t={error:0,warning:0,info:0};if(!Array.isArray(e))return t;for(const n of e){const r=I(n==null?void 0:n.severity);r&&(t[r]+=1)}return t}function Xe(e,t){const n=j(e==null?void 0:e.severity),r=j(t==null?void 0:t.severity);if(n!==r)return n-r;const o=(e==null?void 0:e.path)??"",s=(t==null?void 0:t.path)??"";if(o!==s)return o<s?-1:1;const i=(e==null?void 0:e.code)??"",l=(t==null?void 0:t.code)??"";return i===l?0:i<l?-1:1}function Wt(e){const t=new Map;if(!Array.isArray(e))return[];for(const r of e){if(!r)continue;const o=r.category||Ge,s=t.get(o);s?s.push(r):t.set(o,[r])}const n=r=>r.reduce((o,s)=>{const i=j(s.severity);return i<o?i:o},B);return Array.from(t.entries()).map(([r,o])=>({category:r,findings:[...o].sort(Xe)})).sort((r,o)=>{const s=n(r.findings)-n(o.findings);return s!==0?s:r.category===o.category?0:r.category<o.category?-1:1})}function Qt(e,t){if(!Array.isArray(e))return[];const n=I(t)?j(t):B;return e.filter(r=>j(r==null?void 0:r.severity)<=n)}function Xt(e){const t=fe(e);if(t)return t.charAt(0).toUpperCase()+t.slice(1)}const Vt=`{
|
|
1
|
+
import{y as te,z as ne,a as re,c as T,w as he,F as L}from"./index-DsuZTLjf.js";import{z as ye,I as oe,n as be,A as me}from"./HomePage-CAQsE0sn.js";import{r as c,j as p}from"./react-vendor-BmQ2Ko_D.js";import{e as xe,X as ke,b as ve,C as Se}from"./ui-vendor-BsAtAN16.js";import{d as Te,x as Ce,T as Ae,f as F,v as Ee}from"./MonacoPluginProvider-FJHgHgFQ.js";function gt(e){try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?{ok:!1,error:"A theme is a JSON object."}:{ok:!0,theme:t}}catch(t){return{ok:!1,error:t instanceof Error?t.message:"Invalid JSON"}}}function ht(e){return JSON.stringify(e,null,2)}function _(e,t,n){return ye(e,t,n)}function yt(e,t){if(t.length===0)return e;const n=t.slice(0,-1),r=t[t.length-1],o=we(e,n);if(!o||typeof o!="object")return e;if(Array.isArray(o)){if(typeof r!="number"||!Number.isInteger(r)||r<0||r>=o.length)return e;const i=o.slice();return i.splice(r,1),n.length===0?i:_(e,n,i)}if(!Object.prototype.hasOwnProperty.call(o,r))return e;const s={...o};return delete s[r],n.length===0?s:_(e,n,s)}function we(e,t){let n=e;for(const r of t){if(n===null||typeof n!="object")return;n=n[r]}return n}const H={primary:"Headings, the strongest brand colour",secondary:"Supporting brand colour",accent:"Highlights and emphasis",text:"Default body text",textPrimary:"Primary text",textSecondary:"Secondary text",textMuted:"Captions and de-emphasised text",background:"Page or slide background",backgroundPrimary:"Primary surface",backgroundSecondary:"Alternate surface, table stripes",background2:"Alternate surface, table rules",text2:"Secondary text, captions",border:"Default rules and borders",borderPrimary:"Primary rules",borderSecondary:"Subtle rules",accent4:"Chart series 4",accent5:"Chart series 5",accent6:"Chart series 6"},Oe=[["Core",["primary","secondary","accent"]],["Text",["text","textPrimary","textSecondary","textMuted","text2"]],["Background",["background","backgroundPrimary","backgroundSecondary","background2"]],["Border",["border","borderPrimary","borderSecondary"]],["Chart",["accent4","accent5","accent6"]]];function Y(e){return e.replace(/([a-z])([A-Z0-9])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function Ne(e){var n;const t=(n=e==null?void 0:e.properties)==null?void 0:n.colors;return{keys:Object.keys((t==null?void 0:t.properties)??{}),required:new Set((t==null?void 0:t.required)??[])}}function bt(e){const{keys:t,required:n}=Ne(e==="docx"?te:ne),r=[],o=new Set;for(const[s,i]of Oe)for(const l of i)t.includes(l)&&(o.add(l),r.push({key:l,label:Y(l),group:s,required:n.has(l),hint:H[l]??""}));for(const s of t)o.has(s)||r.push({key:s,label:Y(s),group:"Other",required:n.has(s),hint:H[s]??""});return r}const se=/^#[0-9A-Fa-f]{6}$/;function mt(e){return typeof e=="string"&&se.test(e)}function xt(e){const t=e.trim(),n=t.match(/^#?([0-9A-Fa-f]{3})$/);if(n)return`#${n[1].split("").map(o=>o+o).join("").toUpperCase()}`;const r=t.match(/^#?([0-9A-Fa-f]{6})$/);return r?`#${r[1].toUpperCase()}`:t}function kt(e){const t=e.colors;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,n])=>typeof n=="string").map(([n])=>n)}function je(e,t,n=0){if(typeof t!="string"||n>8)return null;if(se.test(t))return t;const r=t.match(/^#?([0-9A-Fa-f]{6})$/);if(r)return`#${r[1]}`;const o=e.colors;return o?je(e,o[t],n+1):null}function vt(e,t){const n=K(e),r=K(t);if(n===null||r===null)return null;const[o,s]=n>r?[n,r]:[r,n];return(o+.05)/(s+.05)}function K(e){const t=e.match(/^#?([0-9A-Fa-f]{6})$/);if(!t)return null;const n=[0,2,4].map(r=>{const o=parseInt(t[1].slice(r,r+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*n[0]+.7152*n[1]+.0722*n[2]}const St=["heading","body","mono","light"],Tt=["heading","body"],Ct={heading:"Headings and titles",body:"Body text",mono:"Code and tabular figures",light:"Large, light display text"},At=["A4","A3","LETTER","LEGAL"],Et=["top","bottom","left","right","header","footer","gutter"],ie={in:1440,cm:1440/2.54,pt:20,twips:1};function wt(e,t){const n=e/ie[t];return t==="twips"?Math.round(n):Math.round(n*100)/100}function Ot(e,t){return Math.round(e*ie[t])}const ae=["left","center","right","justify"],Ie=[{path:["font"],label:"Font role",kind:"fontRole"},{path:["size"],label:"Size",kind:"number",unit:"pt",min:8,max:120,step:.5},{path:["color"],label:"Colour",kind:"color"},{path:["bold"],label:"Bold",kind:"boolean"},{path:["italic"],label:"Italic",kind:"boolean"},{path:["underline"],label:"Underline",kind:"boolean"},{path:["alignment"],label:"Alignment",kind:"select",options:ae},{path:["spacing","before"],label:"Space before",kind:"number",unit:"pt",min:0,step:1},{path:["spacing","after"],label:"Space after",kind:"number",unit:"pt",min:0,step:1},{path:["lineSpacing","type"],label:"Line spacing",kind:"select",options:["single","multiple","double","atLeast","exactly"]},{path:["lineSpacing","value"],label:"Line spacing value",kind:"number",min:0,step:.05,hint:"A factor for multiple; points for atLeast and exactly"},{path:["fontWeight"],label:"Weight",kind:"number",min:100,max:900,step:100,advanced:!0},{path:["characterSpacing","type"],label:"Tracking",kind:"select",options:["condensed","expanded"],advanced:!0},{path:["characterSpacing","value"],label:"Tracking amount",kind:"number",min:0,step:1,advanced:!0,hint:"Twentieths of a point"},{path:["scale"],label:"Width scale",kind:"number",unit:"%",min:1,max:600,step:1,advanced:!0},{path:["keepNext"],label:"Keep with next",kind:"boolean",advanced:!0},{path:["keepLinesTogether"],label:"Keep lines together",kind:"boolean",advanced:!0},{path:["widowControl"],label:"Widow control",kind:"boolean",advanced:!0},{path:["outlineLevel"],label:"Outline level",kind:"number",min:0,max:9,step:1,advanced:!0},{path:["baseStyle"],label:"Based on",kind:"text",advanced:!0},{path:["followingStyle"],label:"Next style",kind:"text",advanced:!0}],Pe=[{path:["fontSize"],label:"Size",kind:"number",unit:"pt",min:1,max:200,step:1},{path:["fontFace"],label:"Font",kind:"fontFamily"},{path:["fontColor"],label:"Colour",kind:"color"},{path:["bold"],label:"Bold",kind:"boolean"},{path:["italic"],label:"Italic",kind:"boolean"},{path:["align"],label:"Alignment",kind:"select",options:ae},{path:["lineSpacing"],label:"Line spacing",kind:"number",unit:"pt",min:0,step:1,advanced:!0},{path:["charSpacing"],label:"Tracking",kind:"number",unit:"pt",step:.5,advanced:!0},{path:["paraSpaceAfter"],label:"Space after",kind:"number",unit:"pt",min:0,step:1,advanced:!0},{path:["fontWeight"],label:"Weight",kind:"number",min:100,max:900,step:100,advanced:!0}],Re=["normal","title","subtitle","heading1","heading2","heading3","heading4","heading5","heading6","TOC1","TOC2","TOC3","TOC4","TOC5","TOC6"];function J(e){var r;const t=(r=e==null?void 0:e.properties)==null?void 0:r.styles;if(!t)return[];if(t.properties)return Object.keys(t.properties);const n=(t.anyOf??[]).find(o=>o.properties);return n?Object.keys(n.properties):[]}function Le(e){if(e==="docx"){const t=J(te),n=Re.filter(r=>t.includes(r));return[...n,...t.filter(r=>!n.includes(r))]}return J(ne)}function Nt(e){return e==="docx"?Ie:Pe}function jt(e,t){const n=new Set(Le(t)),r=e.styles;return!r||typeof r!="object"?[]:Object.keys(r).filter(o=>!n.has(o))}const De={normal:"Normal (body)",title:"Title",subtitle:"Subtitle",body:"Body",caption:"Caption",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",TOC1:"TOC level 1",TOC2:"TOC level 2",TOC3:"TOC level 3",TOC4:"TOC level 4",TOC5:"TOC level 5",TOC6:"TOC level 6"};function It(e){return De[e]??e}const ce={docx:["name","displayName","description","version","colors","fonts","page","styles"],pptx:["name","displayName","description","version","colors","fonts","defaults","styles"]};function Pt(e){return ce[e]}function Rt(e,t,n=[]){const r=new Set([...ce[t],...n]);return Object.keys(e).filter(o=>!r.has(o)).map(o=>({key:o,summary:Fe(e[o])}))}function Fe(e){if(Array.isArray(e))return`${e.length} item${e.length===1?"":"s"}`;if(e&&typeof e=="object"){const t=Object.keys(e);return t.length===0?"empty":t.slice(0,4).join(", ")+(t.length>4?", …":"")}return typeof e=="string"?e.length>40?`${e.slice(0,40)}…`:e:String(e)}function Lt(e,t){let n=e;const r=t==="docx"?["colors","fonts","page","styles"]:["colors","fonts","defaults","styles"];for(const o of r)(!n[o]||typeof n[o]!="object")&&(n=_(n,[o],{}));return n}const le=c.createContext(null),Dt=le.Provider;function Ft(){const e=c.useContext(le);if(!e)throw new Error("useThemeEditor must be used inside ThemeVisualEditor");return e}const $={safe:[],google:[]};let w=null,R=null;function _e(){return w?Promise.resolve(w):(R||(R=fetch(re.fonts.catalog).then(e=>e.ok?e.json():$).then(e=>{const t=e;return w={safe:Array.isArray(t==null?void 0:t.safe)?t.safe:[],google:Array.isArray(t==null?void 0:t.google)?t.google:[]},w}).catch(()=>(R=null,$))),R)}function _t(){const[e,t]=c.useState(w??$);return c.useEffect(()=>{let n=!0;return w||_e().then(r=>{n&&t(r)}),()=>{n=!1}},[]),e}const ue="h-7 px-2 text-xs shadow-none",$t="h-7 min-h-0 w-full gap-1.5 px-2 py-0 text-xs shadow-none [&>span]:truncate [&>span]:whitespace-nowrap",$e="text-[11px] leading-snug text-muted-foreground",Bt="text-[11px] font-medium leading-none text-muted-foreground";function zt({title:e,hint:t,actions:n,defaultOpen:r=!0,forceOpen:o,children:s}){const[i,l]=c.useState(r),a=o??i;return p.jsxs("section",{className:"border-t border-border/60 pt-2 first:border-t-0","data-crumb":e,children:[p.jsxs("div",{className:"flex h-7 items-center gap-1.5",children:[p.jsxs("button",{type:"button",onClick:()=>l(d=>!d),"aria-expanded":a,className:T("flex h-7 min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-sm px-1","text-foreground/75 transition-colors hover:bg-accent hover:text-foreground","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"),children:[p.jsx(xe,{"aria-hidden":!0,className:T("size-3 shrink-0 transition-transform duration-150 ease-out",a&&"rotate-90")}),p.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] uppercase",children:e})]}),n&&p.jsx("div",{className:"flex shrink-0 items-center gap-1 pr-1",children:n})]}),t&&p.jsx("p",{className:T($e,"px-1 pb-2"),children:t}),a&&p.jsx("div",{className:"flex flex-col gap-3 px-1 pb-4",children:s})]})}function Mt({children:e}){return p.jsx("div",{className:"pt-1 text-[10px] tracking-[0.08em] text-muted-foreground uppercase",children:e})}function qt({label:e,onClick:t,className:n}){return p.jsx("button",{type:"button",onClick:t,"aria-label":e,title:e,className:T("flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm","text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",n),children:p.jsx(ke,{className:"size-3.5","aria-hidden":!0})})}function Ut({children:e,onClick:t,className:n,...r}){return p.jsx("button",{type:"button",onClick:t,className:T("flex h-6 cursor-pointer items-center gap-1 rounded-sm px-1.5","text-[11px] font-medium text-muted-foreground transition-colors","hover:bg-accent hover:text-foreground","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-50",n),...r,children:e})}function Gt({label:e,value:t,options:n,onChange:r,className:o}){return p.jsx("div",{role:"radiogroup","aria-label":e,className:T("flex h-6 shrink-0 items-center rounded-sm border border-border/70 bg-muted/60 p-0.5",o),children:n.map(s=>{const i=s.value===t;return p.jsx("button",{type:"button",role:"radio","aria-checked":i,onClick:()=>r(s.value),className:T("flex h-full flex-1 cursor-pointer items-center justify-center rounded-[3px] px-1.5 text-[11px] transition-colors","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",i?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:s.label},s.value)})})}function de(e,t){const[n,r]=c.useState(null),o=c.useRef(null),s=c.useCallback(f=>{o.current=f,r(f)},[]),i=c.useCallback(()=>s(e),[e,s]),l=c.useCallback(f=>s(f.target.value),[s]),a=c.useCallback(()=>{const f=o.current;s(null),f!==null&&f!==e&&t(f)},[t,e,s]),d=c.useCallback(f=>{f.key==="Enter"?(f.preventDefault(),f.currentTarget.blur()):f.key==="Escape"&&(s(null),f.currentTarget.blur())},[s]);return{syncDraft:c.useCallback(f=>{o.current!==null&&s(f)},[s]),props:{value:n??e,onFocus:i,onChange:l,onBlur:a,onKeyDown:d}}}function Ht({value:e,onCommit:t,className:n,...r}){const o=c.useCallback(i=>t(i.trim()===""?null:i),[t]),{props:s}=de(e??"",o);return p.jsx(oe,{type:"text",autoComplete:"off",spellCheck:!1,className:T(ue,n),...s,...r})}function Be(e){const t=c.useRef(null),n=c.useCallback(()=>{t.current&&clearTimeout(t.current),t.current=null},[]),r=c.useCallback(o=>{e(o);const s=i=>{t.current=setTimeout(()=>{e(o),s(60)},i)};s(400)},[e]);return c.useEffect(()=>n,[n]),{start:r,stop:n}}function Yt({value:e,onCommit:t,unit:n,className:r,min:o,max:s,step:i=1,...l}){const a=c.useCallback(v=>{const m=v.trim();if(m===""){t(null);return}const S=Number(m);Number.isFinite(S)&&t(S)},[t]),{props:d,syncDraft:h}=de(e===void 0?"":String(e),a),f=typeof i=="number"?i:Number(i)||1,k=typeof o=="number"?o:Number(o),u=typeof s=="number"?s:Number(s),y=c.useCallback(v=>{let S=(e??(Number.isFinite(k)?k:0))+v*f;Number.isFinite(k)&&(S=Math.max(k,S)),Number.isFinite(u)&&(S=Math.min(u,S));const E=Number(S.toFixed(4));t(E),h(String(E))},[k,f,t,h,u,e]),b=Be(y);return p.jsxs("div",{className:"relative flex min-w-0 items-center",children:[p.jsx(oe,{type:"number",inputMode:"decimal",min:o,max:s,step:i,className:T(ue,"tabular-nums",n?"pr-11":"pr-5","[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",r),...d,...l}),n&&p.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute right-5 text-[10px] text-muted-foreground",children:n}),p.jsxs("div",{className:"absolute right-0 flex h-7 w-4 flex-col border-l border-input/70",children:[p.jsx(W,{label:"Increase",icon:ve,onStart:()=>b.start(1),onStop:b.stop,disabled:Number.isFinite(u)&&e!==void 0&&e>=u}),p.jsx(W,{label:"Decrease",icon:Se,onStart:()=>b.start(-1),onStop:b.stop,disabled:Number.isFinite(k)&&e!==void 0&&e<=k})]})]})}function W({label:e,icon:t,onStart:n,onStop:r,disabled:o}){return p.jsx("button",{type:"button","aria-label":e,tabIndex:-1,disabled:o,onPointerDown:s=>{s.preventDefault(),n()},onPointerUp:r,onPointerLeave:r,onPointerCancel:r,className:T("flex h-1/2 cursor-pointer items-center justify-center","text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","disabled:pointer-events-none disabled:opacity-30"),children:p.jsx(t,{className:"size-2.5"})})}function ze(e){return e>=4.5?"text-success":e>=3?"text-warning":"text-destructive"}function Kt({label:e,ratio:t}){return p.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[e,p.jsx("span",{className:T("font-medium tabular-nums",t===null?"text-muted-foreground":ze(t)),title:t===null?"Both colours must resolve to a hex":t>=4.5?"Meets WCAG AA for body text":t>=3?"Large text only":"Below WCAG minimums",children:t===null?"—":`${t.toFixed(1)}:1`})]})}const Me=["error","warning","info"],Q={error:0,warning:1,info:2},B=3;function j(e){return typeof e=="string"&&e in Q?Q[e]:B}const qe=["deterministic","measured","estimated","rendered","evaluative"],Ue=["add","replace","remove","move","copy","test"],Ge="other";function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function He(e){return O(e)}function A(e){return typeof e=="string"?e:void 0}function I(e){return typeof e=="string"&&Me.includes(e)?e:void 0}function fe(e){return typeof e=="string"&&qe.includes(e)?e:void 0}function Ye(e){if(!Array.isArray(e))return;const t=e.filter(n=>typeof n=="string");return t.length>0?t:void 0}function Ke(e){return O(e)?e:void 0}function Je(e){if(!Array.isArray(e))return;const t=[];for(const n of e){if(!O(n))continue;const r=n.op,o=n.path;if(typeof r!="string"||typeof o!="string"||!Ue.includes(r))continue;const s={op:r,path:o};"value"in n&&(s.value=n.value);const i=A(n.from);i!==void 0&&(s.from=i),t.push(s)}return t.length>0?t:void 0}function We(e,t){if(!t)return e;const n=`[${t}] `;return e.startsWith(n)?e.slice(n.length):e}function Qe(e,t,n){return`${e||"quality"}:${t}:${n}`}function pe(e,t){const n=A(e.code)??"",r=A(e.message)??"";if(!n&&!r)return;const o=A(e.path)??"",s={id:Qe(n,o,t),code:n,message:We(r,n)||n,path:o,severity:e.severity},i=A(e.ruleId);i!==void 0&&(s.ruleId=i);const l=A(e.category);l!==void 0&&(s.category=l);const a=fe(e.certainty);a!==void 0&&(s.certainty=a),typeof e.blocking=="boolean"&&(s.blocking=e.blocking);const d=A(e.suggestion);d!==void 0&&(s.suggestion=d);const h=Ye(e.relatedPaths);h!==void 0&&(s.relatedPaths=h);const f=Ke(e.evidence);f!==void 0&&(s.evidence=f);const k=Je(e.fixes);return k!==void 0&&(s.fixes=k),s}function Jt(e){const t=[],n=[];if(!Array.isArray(e))return{findings:t,others:n};for(const r of e){if(!He(r))continue;if(r.component!=="quality"){n.push(r);continue}const o=O(r.context)?r.context:{},s=I(o.originalSeverity)??I(r.severity)??"warning",i=pe({code:o.code,message:r.message,path:o.path,severity:s,ruleId:o.ruleId,category:o.category,certainty:o.certainty,blocking:o.blocking,suggestion:o.suggestion,relatedPaths:o.relatedPaths,evidence:o.evidence,fixes:o.fixes},t.length);i&&t.push(i)}return{findings:t,others:n}}function X(e){if(!O(e))return[];const t=e.diagnostics;if(!Array.isArray(t))return[];const n=[];for(const r of t){if(!O(r))continue;const o=pe({code:r.code,message:r.message,path:r.path,severity:I(r.severity)??"warning",ruleId:r.ruleId,category:r.category,certainty:r.certainty,blocking:r.blocking,suggestion:r.suggestion,relatedPaths:r.relatedPaths,evidence:r.evidence,fixes:r.fixes},n.length);o&&n.push(o)}return n}function V(e){const t={error:0,warning:0,info:0};if(!Array.isArray(e))return t;for(const n of e){const r=I(n==null?void 0:n.severity);r&&(t[r]+=1)}return t}function Xe(e,t){const n=j(e==null?void 0:e.severity),r=j(t==null?void 0:t.severity);if(n!==r)return n-r;const o=(e==null?void 0:e.path)??"",s=(t==null?void 0:t.path)??"";if(o!==s)return o<s?-1:1;const i=(e==null?void 0:e.code)??"",l=(t==null?void 0:t.code)??"";return i===l?0:i<l?-1:1}function Wt(e){const t=new Map;if(!Array.isArray(e))return[];for(const r of e){if(!r)continue;const o=r.category||Ge,s=t.get(o);s?s.push(r):t.set(o,[r])}const n=r=>r.reduce((o,s)=>{const i=j(s.severity);return i<o?i:o},B);return Array.from(t.entries()).map(([r,o])=>({category:r,findings:[...o].sort(Xe)})).sort((r,o)=>{const s=n(r.findings)-n(o.findings);return s!==0?s:r.category===o.category?0:r.category<o.category?-1:1})}function Qt(e,t){if(!Array.isArray(e))return[];const n=I(t)?j(t):B;return e.filter(r=>j(r==null?void 0:r.severity)<=n)}function Xt(e){const t=fe(e);if(t)return t.charAt(0).toUpperCase()+t.slice(1)}const Vt=`{
|
|
2
2
|
"rules": {},
|
|
3
3
|
"suppressions": []
|
|
4
4
|
}
|
|
5
5
|
`,Ve=new Set(["error","warning","info"]);function N(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ze(e){const t=(e??"").trim();if(!t)return{ok:!0,policy:void 0};let n;try{n=JSON.parse(t)}catch(a){return{ok:!1,error:`Not valid JSON: ${a.message}`}}if(!N(n))return{ok:!1,error:"A policy must be a JSON object."};if("gate"in n)return{ok:!1,error:'Remove "gate" — it is set by the Gate control above.'};if("profile"in n)return{ok:!1,error:'Remove "profile" — it is set by the Profile control above.'};const r=new Set(["rules","suppressions","maxDiagnostics","onRuleError"]),o=Object.keys(n).find(a=>!r.has(a));if(o!==void 0)return{ok:!1,error:`Unknown key "${o}". A policy takes: ${[...r].join(", ")}.`};const s=new Set(he().map(a=>a.id)),i={};if(n.rules!==void 0){if(!N(n.rules))return{ok:!1,error:'"rules" must be an object keyed by rule id.'};for(const[a,d]of Object.entries(n.rules)){if(!s.has(a))return{ok:!1,error:`Unknown rule "${a}". This format ships: ${[...s].join(", ")}.`};if(!N(d))return{ok:!1,error:`Rule "${a}" must be an object, e.g. { "severity": "warning" }.`};if(d.severity!==void 0&&!Ve.has(d.severity))return{ok:!1,error:`Rule "${a}" has an invalid severity. Use "error", "warning" or "info".`};if(d.enabled!==void 0&&typeof d.enabled!="boolean")return{ok:!1,error:`Rule "${a}": "enabled" must be true or false.`};if(d.parameters!==void 0&&!N(d.parameters))return{ok:!1,error:`Rule "${a}": "parameters" must be an object.`}}i.rules=n.rules}if(n.suppressions!==void 0){if(!Array.isArray(n.suppressions))return{ok:!1,error:'"suppressions" must be an array.'};for(const[a,d]of n.suppressions.entries()){if(!N(d))return{ok:!1,error:`Suppression ${a} must be an object.`};if(typeof d.reason!="string"||!d.reason.trim())return{ok:!1,error:`Suppression ${a} needs a "reason" saying why the finding is acceptable.`};if(d.pathMatch!==void 0&&d.pathMatch!=="exact"&&d.pathMatch!=="subtree")return{ok:!1,error:`Suppression ${a}: "pathMatch" must be "exact" or "subtree".`}}i.suppressions=n.suppressions}if(n.maxDiagnostics!==void 0){if(!Number.isInteger(n.maxDiagnostics)||n.maxDiagnostics<0)return{ok:!1,error:'"maxDiagnostics" must be a whole number, zero or more.'};i.maxDiagnostics=n.maxDiagnostics}if(n.onRuleError!==void 0){if(n.onRuleError!=="continue"&&n.onRuleError!=="throw")return{ok:!1,error:'"onRuleError" must be "continue" or "throw".'};i.onRuleError=n.onRuleError}return{ok:!0,policy:(i.rules===void 0||Object.keys(i.rules).length===0)&&(i.suppressions===void 0||i.suppressions.length===0)&&i.maxDiagnostics===void 0&&i.onRuleError===void 0?void 0:i}}const et={docx:[{id:"client-report",label:"Client report",description:"Running head with page numbers after the cover; takeaway and source wherever a block declares them; every size on the theme scale, at most eight in play; no page rendered empty or half blank under the running head; at least one chart or table"},{id:"executive-report",label:"Executive report",description:"Short decision document with strict outline continuity"},{id:"technical-report",label:"Technical report",description:"Running head with page numbers after the cover; a source wherever a block declares one; no heading skipped; every size on the theme scale, at most nine in play; no page rendered empty or half blank; at least one chart or table"},{id:"legal-appendix",label:"Legal appendix",description:"Dense appendix: preserve integrity without editorial taste"},{id:"general",label:"General",description:"The format default: integrity and information-design rules, nothing required by structure"}],pptx:[{id:"executive-presentation",label:"Executive presentation",description:"Decision deck optimized for scan speed and projection"},{id:"technical-presentation",label:"Technical presentation",description:"Portable professional presentation defaults"}]};function tt(e){const t=e==null?void 0:e[L];return ge(t)?t:void 0}function ge(e){return e!==void 0&&et[L].some(t=>t.id===e)}function nt(e,t,n){const r={};ge(e)&&(r.profile={id:e,formats:[L]});const o=Ze(n),s=o.ok?o.policy:void 0,i=t==="error"||t==="warning"||t==="info";return(s||i)&&(r.policy={...s??{},...i&&{gate:t}}),r.profile||r.policy?r:void 0}let Z=0;function rt(){return Z+=1,Z}function ot(e,t){return e!=null&&e.seq>t}function ee(e,t){return e.map(n=>{var s;const r=t(n.path),o=(s=n.relatedPaths)==null?void 0:s.map(i=>t(i).path);return r.insidePlugin?{...n,path:r.path,message:`${n.message} (inside the output of a browser plugin — fix it in the plugin)`,...o?{relatedPaths:o}:{},fixes:void 0}:r.path===n.path&&!o?n:{...n,path:r.path,...o?{relatedPaths:o}:{}}})}const st=1500;async function it(e){if(me(e.headers.get("content-type")))try{return await e.json()}catch{return}}function at(e){if(!e||typeof e!="object")return{};const t=e;return{...typeof t.profileId=="string"?{profileId:t.profileId}:{},...typeof t.blocked=="boolean"?{blocked:t.blocked}:{},...typeof t.truncated=="boolean"?{truncated:t.truncated}:{}}}function ct(e,t){return t!=null&&t.error?t.error:`Quality analysis failed (${e.status}${e.statusText?` ${e.statusText}`:""}).`}function Zt(){const e=Te(u=>u.setOutput),t=c.useContext(Ce),n=c.useContext(Ae),r=F(u=>u.qualityProfileIds),o=tt(r),s=F(u=>u.qualityGate),i=F(u=>{var y;return(y=u.qualityPolicies)==null?void 0:y[L]}),l=c.useRef(null),a=c.useRef(null),d=c.useCallback(()=>{var u;l.current!==null&&(clearTimeout(l.current),l.current=null),(u=a.current)==null||u.abort(),a.current=null},[]);c.useEffect(()=>d,[d]);const h=c.useCallback((u,y)=>{ot(t.getState().quality,u)||e({quality:y})},[t,e]),f=c.useCallback(async(u,y)=>{var z,M;let b;try{b=JSON.parse(y)}catch{return}(z=a.current)==null||z.abort();const v=new AbortController;a.current=v;const m=rt(),S=nt(o,s,i);let E=g=>({path:g,insidePlugin:!1});try{const g=await be(y,{customThemes:n?Ee(n.getState().customThemes):{},signal:v.signal});if(v.signal.aborted)return;g.expanded&&(b=JSON.parse(g.text),E=g.remap)}catch(g){if(v.signal.aborted)return;const x=t.getState().quality,C=x&&x.documentName===u?x:void 0;h(m,{...C??{findings:[],counts:{error:0,warning:0,info:0},source:"validate"},documentName:u,seq:m,analyzedAt:Date.now(),blocked:(C==null?void 0:C.blocked)??!1,gateError:void 0,analysisError:g instanceof Error?g.message:String(g)});return}try{const g=await fetch(re.validate,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:b,options:S?{quality:S}:{}}),signal:v.signal}),x=await it(g);if(v.signal.aborted)return;if(!g.ok){const U=ct(g,x);if((x==null?void 0:x.code)==="QUALITY_GATE_FAILED"){const G=ee(X(x.quality),E);h(m,{findings:G,counts:V(G),documentName:u,seq:m,blocked:!0,source:"validate",analyzedAt:Date.now(),gateError:U});return}const D=t.getState().quality,P=D&&D.documentName===u?D:void 0;h(m,{...P??{findings:[],counts:{error:0,warning:0,info:0},source:"validate"},documentName:u,seq:m,analyzedAt:Date.now(),blocked:(P==null?void 0:P.blocked)??!1,gateError:void 0,analysisError:U});return}const C=(M=x==null?void 0:x.data)==null?void 0:M.qualityAnalysis,q=ee(X(C),E);h(m,{findings:q,counts:V(q),...at(C),documentName:u,seq:m,source:"validate",analyzedAt:Date.now()})}catch{}finally{a.current===v&&(a.current=null)}},[h,s,t,i,o,n]);return{analyze:c.useCallback((u,y,b)=>{if(l.current!==null&&(clearTimeout(l.current),l.current=null),b!=null&&b.immediate){f(u,y);return}l.current=setTimeout(()=>{l.current=null,f(u,y)},st)},[f]),cancel:d}}export{Xt as $,Rt as A,Pt as B,Kt as C,St as D,zt as E,Ct as F,Mt as G,$e as H,ue as I,kt as J,tt as K,nt as L,Et as M,Zt as N,Jt as O,Tt as P,Ut as Q,V as R,$t as S,Dt as T,X as U,rt as V,ot as W,Vt as X,Ze as Y,Qt as Z,Wt as _,bt as a,Ft as b,vt as c,qt as d,_t as e,Bt as f,we as g,Yt as h,mt as i,At as j,Ot as k,jt as l,Nt as m,xt as n,Le as o,Gt as p,Ht as q,je as r,It as s,wt as t,de as u,gt as v,ht as w,Lt as x,_ as y,yt as z};
|
|
6
|
-
//# sourceMappingURL=useQualityAnalysis-
|
|
6
|
+
//# sourceMappingURL=useQualityAnalysis-CnLgG345.js.map
|