@quirekit/pptx-editor 0.2.1 → 0.3.1
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/README.md +21 -0
- package/README.zh-CN.md +21 -0
- package/dist/ai.d.mts +24 -1
- package/dist/ai.mjs +54 -54
- package/dist/index.d.mts +8 -2
- package/dist/index.mjs +39 -35
- package/dist/open-aKqKXJ6B.mjs +2 -0
- package/dist/styles.css +98 -41
- package/dist/svg-raster-BWlVOKxM.mjs +11 -0
- package/dist/templates.d.mts +575 -0
- package/dist/templates.mjs +1 -0
- package/dist/{types-Bed8XDUh.d.mts → types-Brh5JARz.d.mts} +437 -665
- package/dist/types-DeGx0c3N.d.mts +687 -0
- package/package.json +33 -29
- package/dist/svg-raster-DL19F7ez.mjs +0 -11
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{formatQuireHexColor as Me,parseQuireHexColor as et,quireContrastRatio as ke,quireOklchToSrgb as Se,quireSrgbToOklch as Tt}from"@quirekit/ui";import{addSlide as ve,findShapeById as Pt,findSlideByPartName as Ue,getCustomProperties as bt,getGroupChildren as dt,getGroupTransform as $e,getParagraphPropertiesEffective as Te,getPresentationFonts as Pe,getPresentationTheme as be,getShapeBoundsResolved as Ee,getShapeFillColorResolved as je,getShapeFlip as Le,getShapeId as z,getShapeImageBytes as Oe,getShapeImageFillBytes as Ie,getShapeKind as nt,getShapeMedia as Ae,getShapeName as ze,getShapeParagraphCount as Fe,getShapePlaceholderIdx as Et,getShapePlaceholderType as qe,getShapePreset as Ce,getShapeRotation as jt,getShapeRunCount as Re,getShapeRunFormatEffective as Lt,getShapeText as K,getShapeTextWrap as Ve,getSlideBackground as De,getSlideLayout as Be,getSlideLayoutName as Ne,getSlideLayoutType as Ot,getSlideLayouts as He,getSlidePartName as J,getSlideShapes as B,getSlideSize as Ge,getSlides as ft,isChartShape as _e,isShapeAspectRatioLocked as Qe,isShapeHidden as Ke,isTableShape as Je,loadPresentation as Ze,readPackagePart as It,removeSlide as We,setShapeText as Xe}from"@quirekit/office-kit-pptx";function pt(t,e){return Ue(t,e)}function Ye(t,e,n){const r=pt(t,e);return r===null?null:Pt(r,n)}function At(t){if(Je(t))return"table";if(_e(t))return"chart";const e=nt(t);return e==="picture"?Ae(t)===null?"picture":"media":e==="group"?"group":e==="connector"?"connector":e==="shape"?"text":"other"}function Z(t){const e=B(t),n=new Set(e.filter(r=>nt(r)==="group").flatMap(r=>dt(r).map(z)));return e.filter(r=>!n.has(z(r)))}function tn(t,e,n){const r=pt(t,e);if(r===null)return null;const i=(o,s)=>{for(const l of o){if(z(l)===n)return s;if(nt(l)!=="group")continue;const u=i(dt(l),[...s,l]);if(u!==null)return u}return null};return i(Z(r),[])}const rt=["background","surface","text","muted","dark","primary","accent","data3","data4","data5","data6"],zt=7,it=4.5,N=t=>Tt(et(t)),H=t=>Me(Se(t)).toUpperCase(),A=(t,e)=>ke(et(t),et(e));function mt(t,e,n){if(A(t,e)>=n)return t;const r=N(t),i=N(e).l>.6?-.02:.02;let o=t;for(let s=r.l;s>=0&&s<=1;s+=i)if(o=H({...r,l:s}),A(o,e)>=n)return o;return o}function en(t){const e=N(t.primary),n=N(t.background),r=n.l>.6,i=Math.max(e.c,.08),o=(p,c,h=e.h)=>H({l:p,c,h}),s={background:t.background.toUpperCase(),surface:H({...n,l:r?Math.max(0,n.l-.04):Math.min(1,n.l+.07)}),text:r?o(.22,Math.min(.03,e.c*.25)):H({...n,l:.97,c:Math.min(.02,n.c)}),muted:r?o(.5,Math.min(.03,e.c*.25)):H({...n,l:.78,c:Math.min(.03,n.c)}),dark:r?o(.22,Math.min(.07,e.c*.5)):o(.45,i),primary:t.primary.toUpperCase(),accent:o(r?.68:.78,i,(e.h+150)%360),data3:o(.62,i*.85,(e.h+60)%360),data4:o(.62,i*.85,(e.h+240)%360),data5:o(.62,i*.85,(e.h+300)%360),data6:o(.62,i*.85,(e.h+100)%360)},l=p=>t[p]?.toUpperCase(),u=Object.fromEntries(rt.map(p=>[p,l(p)??s[p]]));return l("text")||(u.text=mt(mt(u.text,u.background,zt),u.surface,zt)),l("muted")||(u.muted=mt(u.muted,u.background,it)),{palette:u,contrast:[["text","background",it],["text","surface",it],["muted","background",3],[Ft(u,u.dark),"dark",it],["primary","background",3]].flatMap(([p,c,h])=>{const f=A(u[p],u[c]);return f<h?[{foreground:p,background:c,ratio:Math.round(f*10)/10}]:[]})}}function Ft(t,e){return A(t.text,e)>=A(t.background,e)?"text":"background"}function W(t,e,n){const r=N(t),i=N(e),o=Math.min(1,Math.max(0,n));return H({l:r.l+(i.l-r.l)*o,c:r.c+(i.c-r.c)*o,h:r.c>=i.c?r.h:i.h})}function nn(t,e){if(!t||!e)return{emphasis:"primary",onEmphasis:"background"};const{palette:n}=t,r=A(n.primary,e)>=2.2?"primary":A(n.accent,e)>=2.2?"accent":"text",i=n[r];return{emphasis:r,onEmphasis:A(n.background,i)>=A(n.text,i)?"background":"text"}}function ot(t,e,n,r,i){if(i%360===0)return{x:t,y:e};const o=i*Math.PI/180,s=Math.cos(o),l=Math.sin(o),u=t-n,p=e-r;return{x:n+u*s-p*l,y:r+u*l+p*s}}function gt(t){const e=t%360;return e<0?e+360:e}function qt(t){const e=$e(t);if(e===null||e.inner.w===0||e.inner.h===0)return null;const n=Le(t);return{outer:e.outer,inner:e.inner,rotation:jt(t),flipH:n?.horizontal??!1,flipV:n?.vertical??!1}}function Ct(t,e){const{outer:n,inner:r}=e,i=n.w/r.w,o=n.h/r.h,s=n.x+n.w/2,l=n.y+n.h/2;let u=n.x+(t.x+t.width/2-r.x)*i,p=n.y+(t.y+t.height/2-r.y)*o;e.flipH&&(u=2*s-u),e.flipV&&(p=2*l-p);const c=ot(u,p,s,l,e.rotation),h=t.width*i,f=t.height*o,a=e.flipH!==e.flipV?-t.rotation:t.rotation;return{x:c.x-h/2,y:c.y-f/2,width:h,height:f,rotation:gt(a+e.rotation)}}function Rt(t,e){const{outer:n,inner:r}=e,i=n.w/r.w,o=n.h/r.h,s=n.x+n.w/2,l=n.y+n.h/2;let{x:u,y:p}=ot(t.x+t.width/2,t.y+t.height/2,s,l,-e.rotation);e.flipH&&(u=2*s-u),e.flipV&&(p=2*l-p);const c=t.width/i,h=t.height/o,f=t.rotation-e.rotation,a=e.flipH!==e.flipV?-f:f;return{x:r.x+(u-n.x)/i-c/2,y:r.y+(p-n.y)/o-h/2,width:c,height:h,rotation:gt(a)}}function Vt(t,e){return e.reduceRight((n,r)=>Ct(n,r),t)}function rn(t,e){return e.reduce((n,r)=>Rt(n,r),t)}function on(t){const e=t.rotation*Math.PI/180,n=Math.abs(Math.cos(e)),r=Math.abs(Math.sin(e)),i=t.width*n+t.height*r,o=t.width*r+t.height*n;return{x:t.x+(t.width-i)/2,y:t.y+(t.height-o)/2,width:i,height:o}}function sn(t,e,n){const r=ot(e,n,t.x+t.width/2,t.y+t.height/2,-t.rotation);return r.x>=t.x&&r.x<=t.x+t.width&&r.y>=t.y&&r.y<=t.y+t.height}const an={width:12192e3,height:6858e3};function X(t){const e=Ge(t);return e?{width:e.width,height:e.height}:an}function G(t,e,n={}){const r=[],i=(o,s,l)=>{const u=Ee(t,o);if(u===null)return null;const p=At(o);if((u.w<=0||u.h<=0)&&!(n.lines&&p==="connector"&&(u.w>0||u.h>0)))return null;const c=Vt({x:u.x,y:u.y,width:u.w,height:u.h,rotation:jt(o)},s),h=z(o),f=[],a={...c,id:h,name:ze(o),kind:p,parent:l,children:f,placeholder:cn(o),empty:p==="text"&&K(o).length===0,aspectLocked:ln(o)};r.push(a);const y=p==="group"?qt(o):null;if(y!==null)for(const $ of dt(o)){const P=i($,[...s,y],h);P!==null&&f.push(P)}return a};for(const o of Z(e))i(o,[],null);return r}function cn(t){const e=qe(t);return e!==null?e:Et(t)===null?null:"body"}function hn(t,e,n){const r=i=>{for(let o=i.length-1;o>=0;o-=1){const s=i[o];if(s.kind==="group"&&s.children.length>0){const l=r(s.children);if(l.length>0)return[s,...l]}else if(sn(s,e,n))return[s]}return[]};return r(t.filter(i=>i.parent===null))}function ln(t){try{return Qe(t)}catch{return!1}}const st=36e4;function yt(t,e,n=.05*st){return e.x>=t.x-n&&e.y>=t.y-n&&e.x+e.w<=t.x+t.w+n&&e.y+e.h<=t.y+t.h+n}function wt(t,e,n){return t.x-n<=e.x+e.w&&e.x-n<=t.x+t.w&&t.y-n<=e.y+e.h&&e.y-n<=t.y+t.h}function at(t){const e=Math.min(...t.map(r=>r.x)),n=Math.min(...t.map(r=>r.y));return{x:e,y:n,w:Math.max(...t.map(r=>r.x+r.w))-e,h:Math.max(...t.map(r=>r.y+r.h))-n}}function un(t,e){const n=Math.min(t.x+t.w,e.x+e.w)-Math.max(t.x,e.x),r=Math.min(t.y+t.h,e.y+e.h)-Math.max(t.y,e.y);return n<=0||r<=0?0:n*r/Math.max(1,Math.min(t.w*t.h,e.w*e.h))}function Dt(t,e,n){return Math.abs(t-e)<=n*Math.max(Math.abs(t),Math.abs(e),1)}function Bt(t,e){return[...t].sort((n,r)=>Math.abs(n.frame.y-r.frame.y)<e?n.frame.x-r.frame.x:n.frame.y-r.frame.y)}const dn=(t,e)=>Math.min(.2*st,.2*Math.min(t.frame.w,t.frame.h,e.frame.w,e.frame.h));function ct(t,e){return t!==e&&t.order<e.order&&(t.kind==="graphic"||t.kind==="content")&&yt(t.frame,e.frame)}function fn(t){const e=[...t].sort((n,r)=>n.order-r.order);return{pieces:e,frame:at(e.map(n=>n.frame)),signature:e.map(n=>`${n.kind}:${n.form}`).sort().join("+")}}function pn(t,e){const n=t.filter(h=>h.kind==="line"),r=t.filter(h=>h.kind!=="line"),i=r.filter(h=>r.some(f=>ct(h,f)&&r.some(a=>ct(f,a)))),o=r.filter(h=>!i.includes(h)),s=o.map((h,f)=>f),l=h=>s[h]===h?h:s[h]=l(s[h]);for(let h=0;h<o.length;h+=1)for(let f=h+1;f<o.length;f+=1){const a=o[h],y=o[f];(ct(a,y)||ct(y,a)||wt(a.frame,y.frame,dn(a,y))&&(a.kind!=="text"||y.kind!=="text"||un(a.frame,y.frame)>.8))&&(s[l(h)]=l(f))}const u=new Map;o.forEach((h,f)=>u.set(l(f),[...u.get(l(f))??[],h]));const p=[...u.values()],c=[];for(const h of n){const f=p.map(y=>at(y.map($=>$.frame))).flatMap((y,$)=>wt(y,h.frame,36e3)?[$]:[]),a=h.frame.w>=e.width*.25||h.frame.h>=e.height*.25;!a&&f.length===1?p[f[0]].push(h):!a&&f.length===0?p.push([h]):c.push({piece:h,atoms:f})}return{atoms:p.map(fn),links:c,regions:i}}const Y=.35*st,Nt=t=>t.pieces.every(e=>e.kind==="text")?"text":t.pieces.some(e=>e.kind==="text")?"mixed":"graphic",xt=(t,e)=>e==="x"?t.frame.x+t.frame.w/2:t.frame.y+t.frame.h/2,C=(t,e)=>e==="x"?t.frame.y:t.frame.x;function Ht(t,e){const n=e[t[0]];return t.every(r=>{const i=e[r];return i.signature===n.signature&&Dt(i.frame.w,n.frame.w,.15)&&Dt(i.frame.h,n.frame.h,.15)})}function Gt(t,e,n,r){const i=new Set;let o=0;for(const s of t){const l=e.find(u=>!i.has(u)&&Nt(n[s])===Nt(n[u])&&Math.abs(C(n[s],r)-C(n[u],r))<=Y);l!==void 0&&(i.add(l),o+=1)}return o/Math.max(t.length,e.length)}function _t(t,e,n,r){const i=[],o=c=>n==="x"?t[c].frame.w<r.width*.4:t[c].frame.h<r.height*.4;for(const c of[...e].filter(o).sort((h,f)=>xt(t[h],n)-xt(t[f],n))){const h=xt(t[c],n),f=i.find(a=>Math.abs(a.centre-h)<=Y);f?f.members.push(c):i.push({centre:h,members:[c]})}const s=i.flatMap(c=>mn(c.members.sort((h,f)=>C(t[h],n)-C(t[f],n)),t,n)).filter(c=>c.length>=2&&!Ht(c,t)),l=c=>{const h=c.map(a=>n==="x"?t[a].frame.x:t[a].frame.y),f=c.map(a=>n==="x"?t[a].frame.x+t[a].frame.w:t[a].frame.y+t[a].frame.h);return[Math.min(...h),Math.max(...f)]},u=[],p=new Set(s);for(;p.size>=2;){let c=[];for(const h of p){const f=[h,...[...p].filter(a=>a!==h&&Gt(h,a,t,n)>=.6)].sort((a,y)=>l(a)[0]-l(y)[0]);f.every((a,y)=>y===0||l(f[y-1])[1]<=l(a)[0]+Y)&&f.length>c.length&&(c=f)}if(!(c.length>=3||c.length===2&&Gt(c[0],c[1],t,n)*Math.max(c[0].length,c[1].length)>=2))break;u.push(c.map(h=>[...h].sort((f,a)=>C(t[f],n)-C(t[a],n))));for(const h of c)p.delete(h)}return u}function mn(t,e,n){const r=s=>n==="x"?e[s].frame.y+e[s].frame.h:e[s].frame.x+e[s].frame.w,i=[];let o=-1/0;for(const s of t)(i.length===0||C(e[s],n)-o>2*36e4)&&i.push([]),i.at(-1).push(s),o=Math.max(o,r(s));return i}function gn(t,e){const n=[],r=[...e];for(;r.length>0;){const i=r.shift(),o=[i,...r.filter(c=>Ht([i,c],t))];for(const c of o.slice(1))r.splice(r.indexOf(c),1);if(o.length<(t[i].pieces.length>1?2:3))continue;const s=Qt(o.map(c=>t[c].frame.y)),l=Qt(o.map(c=>t[c].frame.x)),u=s===1?"row":l===1?"column":s*l>=o.length&&o.length>Math.max(s,l)?"grid":null;if(u===null)continue;const p=o.sort((c,h)=>Math.abs(t[c].frame.y-t[h].frame.y)<=Y?t[c].frame.x-t[h].frame.x:t[c].frame.y-t[h].frame.y);n.push({layout:u,items:p.map(c=>[c])})}return n}function Qt(t){const e=[...t].sort((n,r)=>n-r);return e.reduce((n,r,i)=>i>0&&r-e[i-1]>Y?n+1:n,1)}function yn(t,e){const n=new Set(t.map((o,s)=>s)),r=[],i=[..._t(t,n,"x",e).map(o=>({layout:"row",items:o})),..._t(t,n,"y",e).map(o=>({layout:"column",items:o}))].sort((o,s)=>s.items.flat().length-o.items.flat().length);for(const o of i)if(!o.items.flat().some(s=>!n.has(s))){r.push(o);for(const s of o.items.flat())n.delete(s)}return r.push(...gn(t,n)),r}const wn=new Set(["dt","ftr","sldNum"]),xn=/:(page-number|decoration|title-mark):/u,Mn=/^qk:[a-z]+:e\d+-(eyebrow|title|subtitle):/u;function Kt(t,e){const n=r=>Math.round(r/5e4);return`${t.kind}:${n(t.x)},${n(t.y)},${n(t.width)},${n(t.height)}:${e}`}function Mt(t){if(t===void 0)return"";try{return K(t)}catch{return""}}function kn(t,e){const n=new Map;for(const r of ft(t)){const i=J(r);for(const o of G(t,r,{lines:!0})){if(o.parent!==null)continue;const s=Kt(o,Mt(e(i,o.id))),l=n.get(s)??new Set;l.add(i),n.set(s,l)}}return{elsewhere:(r,i,o)=>[...n.get(Kt(i,o))??[]].some(s=>s!==r)}}function Jt(t,e,n){return wn.has(t.placeholder??"")||xn.test(t.name)||t.width>=e.width*.95&&t.height>=e.height*.95||t.y>=e.height*.9?!0:n&&(t.y+t.height<=e.height*.22||t.x+t.width<=e.width*.06||t.x>=e.width*.94)}function Zt(t,e){if(e===void 0)return 0;try{return Lt(t,e,0,0).size??18}catch{return 0}}function Sn(t,e,n,r){const i=e.filter(a=>a.kind==="text"&&Mt(n(a.id)).trim()!==""),o=i.filter(a=>Mn.test(a.name)||a.placeholder==="subTitle"),s=i.find(a=>a.placeholder==="title"||a.placeholder==="ctrTitle"),l=i.filter(a=>a.y<r.height*.25),u=s??i.find(a=>/-title:/u.test(a.name))??l.reduce((a,y)=>a===void 0||Zt(t,n(y.id))>Zt(t,n(a.id))?y:a,void 0);if(u===void 0)return o.map(a=>a.id);const p=[u],c=a=>a.x+a.width/2,h=a=>Math.abs(a.x-u.x)<=.3*36e4||Math.abs(c(a)-c(u))<=.3*36e4;let f=!0;for(;f;){f=!1;for(const a of l)p.includes(a)||!h(a)||Math.min(...p.map(y=>Math.max(a.y-(y.y+y.height),y.y-(a.y+a.height))))<=.8*36e4&&(p.push(a),f=!0)}for(const a of o)p.includes(a)||p.push(a);return p.sort((a,y)=>a.y-y.y).map(a=>a.id)}function vn(t,e,n,r){const i={x:t.x,y:t.y,w:t.width,h:t.height};return t.kind==="connector"?{id:t.id,order:r,frame:i,kind:"line",form:n??"line"}:t.kind==="text"||t.kind==="other"?e.trim()!==""?{id:t.id,order:r,frame:i,kind:"text",form:"text"}:Math.min(t.width,t.height)<.08*36e4?{id:t.id,order:r,frame:i,kind:"line",form:n??"line"}:{id:t.id,order:r,frame:i,kind:"graphic",form:n??"shape"}:{id:t.id,order:r,frame:i,kind:"content",form:t.kind}}function Un(t,e,n){const r=X(t),i=J(e),o=new Map(Z(e).map(d=>[z(d),d])),s=G(t,e,{lines:!0}).filter(d=>d.parent===null&&!Ke(o.get(d.id))),l=d=>Mt(o.get(d)),u=s.filter(d=>Jt(d,r,!1)),p=Sn(t,s.filter(d=>!u.includes(d)),d=>o.get(d),r),c=s.filter(d=>u.includes(d)||!p.includes(d.id)&&Jt(d,r,n.elsewhere(i,d,l(d.id)))),{atoms:h,links:f,regions:a}=pn(s.filter(d=>!c.includes(d)&&!p.includes(d.id)).map(d=>vn(d,l(d.id),Ce(o.get(d.id)),s.indexOf(d))),r),y=yn(h,r),$=new Map;y.forEach((d,x)=>d.items.forEach((g,M)=>g.forEach(k=>$.set(k,{group:x,item:M}))));const P=y.map(d=>d.items.map(x=>x.flatMap(g=>h[g].pieces))),v=y.map(()=>[]),T=[];for(const d of f){const x=d.atoms.map(k=>$.get(k)),g=x[0];if(g!==void 0&&x.length>0&&x.every(k=>k?.group===g.group&&k.item===g.item)){P[g.group][g.item].push(d.piece);continue}const M=y.findIndex((k,U)=>P[U].filter(L=>wt(at(L.map(F=>F.frame)),d.piece.frame,.1*st)).length>=2);M>=0?v[M].push(d.piece):T.push(d.piece)}const m=[];y.forEach((d,x)=>{const g=P[x].map(M=>[...M].sort((k,U)=>k.order-U.order));m.push({element:{kind:"items",layout:d.layout,items:g.map(M=>M.map(k=>k.id)),links:v[x].map(M=>M.id)},frame:at(g.flat().map(M=>M.frame))})}),h.forEach((d,x)=>{if($.has(x))return;const g=d.pieces.find(M=>d.pieces.every(k=>k===M||M.order<k.order&&yt(M.frame,k.frame)));if(g!==void 0&&d.pieces.length>1){const M=d.pieces.filter(k=>k!==g).map(k=>({kind:"shape",shape:k.id}));m.push({element:{kind:"box",shape:g.id,holds:M},frame:g.frame});return}for(const M of d.pieces)m.push({element:{kind:"shape",shape:M.id},frame:d.frame})});for(const d of T)m.push({element:{kind:"shape",shape:d.id},frame:d.frame});return{header:p,content:$n(m,a,r.height/20),furniture:c.map(d=>d.id)}}function $n(t,e,n){let r=[...t];for(const i of[...e].sort((o,s)=>o.frame.w*o.frame.h-s.frame.w*s.frame.h)){const o=r.filter(l=>yt(i.frame,l.frame));r=r.filter(l=>!o.includes(l));const s=o.length===0?{kind:"shape",shape:i.id}:{kind:"box",shape:i.id,holds:Bt(o,n).map(l=>l.element)};r.push({element:s,frame:i.frame})}return Bt(r,n).map(i=>i.element)}function Wt(){let t=null;const e=new Map;return{read(n,r){const i=ft(n),o=i.map(c=>It(n,J(c)));if(t===null||t.parts.length!==o.length||t.parts.some((c,h)=>c!==o[h])){const c=new Map(i.map(h=>[J(h),new Map(Z(h).map(f=>[z(f),f]))]));t={parts:o,index:kn(n,(h,f)=>c.get(h)?.get(f))}}const s=J(r),l=It(n,s),u=e.get(s);if(u&&u.part===l&&u.index===t.index)return u.structure;const p=Un(n,r,t.index);return e.set(s,{part:l,index:t.index,structure:p}),p}}}const kt="quirekit.presentation-template";function _(t){const e=/^#?([0-9a-f]{6})$/iu.exec(t??"");return e?`#${e[1].toUpperCase()}`:void 0}function Xt(t,e){let n={};for(let r=0;r<Fe(e);r+=1)for(let i=0;i<Re(e,r);i+=1){const o=Lt(t,e,r,i);(Object.keys(n).length===0||(o.size??0)>(n.size??0))&&(n=o)}return n}function Yt(t,e){const n=Te(t,e,0).align;return n==="center"||n==="right"?n:"left"}function Tn(t,e,n,r){const i=t.y+t.height/2,o=r.filter(a=>a.children.length===0&&!n.includes(a)&&a.x<=t.x&&a.y<=i&&a.x+a.width>=t.x+t.width&&a.y+a.height>=i&&a.height>=t.height*.6).sort((a,y)=>a.width*a.height-y.width*y.height)[0];if(!o)return t.width;const s=o.height>t.height*2?[]:r.filter(a=>a!==o&&a.children.length===0&&!n.includes(a)&&a.width<o.width*.2&&a.x>=o.x&&a.x+a.width<=o.x+o.width),l=[...n,...s].filter(a=>a!==t&&Math.min(a.y+a.height,t.y+t.height)-Math.max(a.y,t.y)>t.height*.3),u=Math.max(o.x,...l.filter(a=>a.x<t.x).map(a=>a.x+a.width)),p=Math.min(o.x+o.width,...l.filter(a=>a.x>t.x).map(a=>a.x)),c=Math.max(0,t.x-u),h=Math.max(0,p-t.x-t.width),f=e==="center"?Math.min(c,h)*2:e==="right"?c:h;return Math.max(t.width,t.width+f-o.width*(s.length>0?.02:.1))}function te(t,e,n){const r=new Map(B(e).map(s=>[z(s),s])),i=new Map,o=new Map;for(const s of n){const l=r.get(s.id);if(!l||s.kind!=="text"||!K(l).trim())continue;const u=Xt(t,l);o.set(s.id,Yt(t,l)),i.set(s.id,{id:s.id,text:K(l),size:u.size??18,color:_(u.color),chinese:u.fontEastAsian??void 0,latin:u.font??void 0,box:s,unwrapped:Ve(l)==="none"})}return new Map([...i].map(([s,l])=>[s,{...l,room:Tn(l.box,o.get(s),[...i.values()].map(u=>u.box),n)}]))}function O(t){return Math.ceil([...t].reduce((e,n)=>e+(n.codePointAt(0)>11903?1:.5),0))}function ee(t){const e=t.size*12700,n=t.unwrapped?t.text.trim().split(/[\n\v]/u).length:Math.max(1,Math.floor(t.box.height/(e*1.3)));return Math.max(O(t.text),Math.floor((n===1?t.room:t.box.width)/e)*n,1)}const R=t=>Tt(et(t));var tt=class{#t=new Map;add(t,e){t&&this.#t.set(t,(this.#t.get(t)??0)+e)}ranked(){return[...this.#t].sort((t,e)=>e[1]-t[1]).map(([t])=>t)}};const ne=t=>[...t].sort((e,n)=>e-n)[Math.floor(t.length/2)];function re(t,e){const n=new tt,r=new tt;for(const i of t)n.add(i.chinese,O(i.text)),r.add(i.latin,O(i.text));return{chinese:n.ranked()[0]??e.chinese,latin:r.ranked()[0]??e.latin}}function Pn(t,e,n){const r=be(t),i=X(t),o=e.flatMap(S=>[...S.texts.values()]),s=e.flatMap(S=>S.title?[S.title]:[]),l=o.filter(S=>!s.includes(S)),u=new tt,p=new tt,c=new tt;for(const S of n){const b=new Map(G(t,S).map(j=>[j.id,j])),I=De(S);I.kind==="solid"&&c.add(_(I.color),1);for(const j of B(S)){const Q=b.get(z(j));Q&&u.add(_(je(t,j)),Math.min(.5,Q.width*Q.height/(i.width*i.height)))}}for(const S of s)u.add(S.color,.1);for(const S of l)p.add(S.color,O(S.text));const h=l.reduce((S,b)=>S+(b.color?(R(b.color).l<.75?1:-1)*O(b.text):0),0)>=0,f=c.ranked()[0]??(h?_(r?.light1)??"#FFFFFF":"#1F2937"),a=R(f).l>.6,y=p.ranked().find(S=>A(S,f)>=4.5)??(a?"#262626":"#FFFFFF"),$=(S,b)=>{const I=R(S),j=R(b);return Math.abs(I.l-j.l)+Math.abs(I.c-j.c)*2+Math.hypot(I.c*Math.cos(I.h*Math.PI/180)-j.c*Math.cos(j.h*Math.PI/180),I.c*Math.sin(I.h*Math.PI/180)-j.c*Math.sin(j.h*Math.PI/180))>.18},P=[];for(const S of[...u.ranked(),_(r?.accent1),_(r?.accent2)])S&&R(S).c>.05&&P.every(b=>$(S,b))&&P.push(S);const v=P[0]??y,T=[.35,.6,.2,.75,.5].map(S=>W(v,f,S)),m=[...P.slice(1,6),...T],d=a?[...P].sort((S,b)=>R(S).l-R(b).l)[0]??y:W(f,"#000000",.3),x=Pe(t),g=re(s,{chinese:x?.majorEastAsian||"微软雅黑",latin:x?.majorLatin||"Arial"}),M=re(l,{chinese:x?.minorEastAsian||"微软雅黑",latin:x?.minorLatin||"Arial"}),k=S=>ne(e.filter(b=>S.includes(b.page.kind)).flatMap(b=>b.title?[b.title.size]:[])),U=Math.round(k(["content","data","agenda"])??28),L=l.filter(S=>O(S.text)>12).map(S=>S.size),F=Math.round(Math.min(U,Math.max(12,ne(L)??16)));return{palette:{background:f,surface:W(f,v,.07),text:y,muted:W(y,f,.3),dark:d,primary:v,accent:m[0],data3:m[1],data4:m[2],data5:m[3],data6:m[4]},fonts:{heading:g,body:M},type:{display:Math.round(Math.max(U,k(["cover","section"])??U*1.6)),title:U,subtitle:Math.round((U+F)/2),body:F,small:Math.max(10,Math.round(F*.8))},margin:Math.round(i.width*.05/36e3)/10}}const ie=/^(?:[\d0-9]{1,2}[.、]?|[一二三四五六七八九十]{1,2}[、.]?|(?:part|chapter|section|no\.?)\s*[\d0-9a-z]*|contents?|catalogue|agenda|目\s*录|thanks?|thank\s+you!?)$/iu;function St(){const t=new Map;return{next(e){const n=(t.get(e)??0)+1;return t.set(e,n),n===1?e:`${e}${n}`}}}function oe(t,e,n){const r=t.text.trim(),i=ie.test(r),o=n??(!i&&(O(r)>12||r.includes(`
|
|
2
|
+
`))?"text":"label");return{key:e.next(o),role:o,shape:t.id,sample:r.slice(0,60),limit:ee(t),...i?{fixed:i}:{}}}function bn(t){const e=St(),n=t.filter(i=>!ie.test(i.text.trim())),r=n.length>1?[...n].sort((i,o)=>o.size-i.size||O(i.text)-O(o.text))[0]:n.find(i=>O(i.text)<=12);return t.map(i=>oe(i,e,i===r?"title":void 0))}const En=12,jn=3;function Ln(t){const e=Math.min(...t.map(r=>r.x)),n=Math.min(...t.map(r=>r.y));return{x:e,y:n,width:Math.max(...t.map(r=>r.x+r.width))-e,height:Math.max(...t.map(r=>r.y+r.height))-n}}const On=(t,e)=>Math.hypot(Math.max(0,t.x-e.x-e.width,e.x-t.x-t.width),Math.max(0,t.y-e.y-e.height,e.y-t.y-t.height)),In=(t,e)=>Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)>.1*Math.min(t.width,e.width)&&Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y)>.1*Math.min(t.height,e.height),An=(t,e)=>Math.abs(t.width-e.width)<=.2*Math.max(t.width,e.width)&&Math.abs(t.height-e.height)<=.2*Math.max(t.height,e.height),q=t=>({x:t.x+t.width/2,y:t.y+t.height/2});function se(t,e){const n=Math.floor(t.length/e);return n<=jn&&t.length-n*e<=(n===1&&e>=3?1:0)?n:0}function zn(t){const e=[...new Set(t.map(r=>r.length))].filter(r=>r>=2&&r<=En),n=r=>t.reduce((i,o)=>i+se(o,r)*r,0);return e.sort((r,i)=>n(i)-n(r)||i-r)[0]}function ae(t,e,n){const r=zn(t);if(r===void 0)return;const i=t.filter(m=>m.length===r).sort((m,d)=>Math.max(...d.map(x=>x.box.height))-Math.max(...m.map(x=>x.box.height)))[0],o=i.map(m=>[m]);for(const m of t){const d=se(m,r);if(m===i||d===0)continue;const x=o.map(()=>d),g=m.flatMap(k=>i.map((U,L)=>({text:k,item:L,distance:Math.hypot(q(k.box).x-q(U.box).x,q(k.box).y-q(U.box).y)}))).sort((k,U)=>k.distance-U.distance),M=new Set;for(const{text:k,item:U}of g)M.has(k)||x[U]===0||(M.add(k),x[U]-=1,o[U].push(k))}const s=o.map(m=>Ln(m.map(d=>d.box)));if(s.some((m,d)=>s.some((x,g)=>g>d&&In(m,x))))return;const l=new Map(n.map(m=>[m.id,m])),u=new Map(o.flatMap((m,d)=>m.map(x=>[x.id,d]))),p=new Set(e.map(m=>m.id)),c=m=>new Set([...p.has(m.id)?[u.get(m.id)??-1]:[],...m.children.flatMap(d=>[...c(d)])]),h=o.map(()=>new Set);o.forEach((m,d)=>m.forEach(x=>{let g=x.box;for(let M=g.parent===null?void 0:l.get(g.parent);M&&c(M).size===1;M=M.parent===null?void 0:l.get(M.parent))g=M;h[d].add(g.id)}));const f=o.map(()=>[]);for(const m of n){if(m.parent!==null||c(m).size>0)continue;const d=s.map((x,g)=>({index:g,gap:On(x,m)})).sort((x,g)=>x.gap-g.gap);d[0].gap<45e4&&d[1].gap>Math.max(d[0].gap*2,9e4)&&f[d[0].index].push(m)}f.forEach((m,d)=>m.forEach(x=>{f.every(g=>g.some(M=>An(x,M)))&&h[d].add(x.id)}));const a=Math.min(...s.map(m=>m.height))/2,y=s.map((m,d)=>d).sort((m,d)=>Math.abs(q(s[m]).y-q(s[d]).y)>a?s[m].y-s[d].y:s[m].x-s[d].x),$=m=>Math.max(...s.map(d=>q(d)[m]))-Math.min(...s.map(d=>q(d)[m])),P=$("y")<=a*2?"row":$("x")<=Math.min(...s.map(m=>m.width))?"column":"grid",v=y.map(m=>bn([...o[m]].sort((d,x)=>d.box.y-x.box.y||d.box.x-x.box.x))),T=v.map(m=>m.length===v[0].length?m.map((d,x)=>({...d,key:v[0][x].key,role:v[0][x].role})):m);return{layout:P,members:y.map((m,d)=>({shapes:[...h[m]],slots:T[d]}))}}function Fn(t,e){const n=r=>{const i=new Map;for(const o of t)i.set(r(o),[...i.get(r(o))??[],o]);return[...i.values()]};return ae(n(r=>`${Math.round(r.size)}|${Math.round(r.box.height/18e4)}`),t,e)??ae(n(r=>`${Math.round(r.size)}`),t,e)}const qn=.02;function Cn(t){return t[0]===255&&t[1]===216||t[0]===137&&t[1]===80&&t[25]===2}function Rn(t,e,n){return e.filter(r=>{if(r.children.length>0||r.width*r.height<n.width*n.height*qn)return!1;const i=Pt(t,r.id),o=i&&(r.kind==="picture"?r.parent===null&&Oe(i):Ie(i));return o?Cn(o):!1})}const ce=36e4,Vn=10,Dn=.4;function Bn(t,e,n,r,i){const o=Be(t),s=o?Ot(o):null,l=p=>n.some(c=>O(c.text)<=14&&p.test(c.text));if(e.index===0)return"cover";if(l(/目\s*录|contents?|agenda/iu))return"agenda";if(e.index===e.count-1&&(l(/谢|thank|再见|the end/iu)||!i.items&&n.length<=5))return"closing";if(i.data)return"data";const u=n.reduce((p,c)=>p+O(c.text),0);return s==="secHead"||!i.items&&n.length<=4&&u<=60&&(r?.size??0)>=32?"section":"content"}function Nn(t,e,n){if(t.length===0)return;const r=n.width*.04,i=Math.max(r,Math.min(...t.map(c=>c.x))),o=Math.min(n.width-r,Math.max(...t.map(c=>c.x+c.width))),s=e&&e.y+e.height<n.height*.4?e.y+e.height+r*.25:0,l=Math.max(s,Math.min(...t.map(c=>c.y)),r*.5),u=Math.min(n.height-r*.75,Math.max(...t.map(c=>c.y+c.height)));if(o-i<n.width*.4||u-l<n.height*.35)return;const p=c=>Math.round(c/ce*10)/10;return{x:p(i),y:p(l),w:p(o-i),h:p(u-l)}}function Hn(t,e,n){const r=t.members.map(i=>e.filter(o=>i.shapes.includes(o.id)||i.shapes.includes(n(o.id))));return r.some(i=>i.length!==1)?t:{...t,members:t.members.map((i,o)=>({...i,slots:[...i.slots,{key:"picture",role:"picture",shape:r[o][0].id}]}))}}function Gn(t,e,n,r){const i=X(t),o=G(t,e,{lines:!0}),s=new Map(o.map(w=>[w.id,w])),l=te(t,e,o),u=w=>{const E=l.get(w);return[...E?[E]:[],...s.get(w)?.children.flatMap(ut=>u(ut.id))??[]]},p=w=>w.box.y+w.box.height<i.height*.85&&/\D/u.test(w.text.trim())&&r.shown(w.text)<r.count*Dn,c=new Set(n.furniture.flatMap(w=>u(w).filter(E=>!p(E)).map(E=>E.id))),h=[...l.values()].filter(w=>!c.has(w.id));if(h.length===0)return null;const f=[...h].sort((w,E)=>w.box.y-E.box.y||w.box.x-E.box.x),a=f.filter(w=>n.header.includes(w.id)),y=w=>w.filter(E=>!/^[\d.、\s]+$/u.test(E.text)).sort((E,ut)=>ut.size-E.size)[0],$=y(a)??y(f),P=new Set(n.furniture),v=w=>w.parent===null?w:v(s.get(w.parent)),T=o.filter(w=>!P.has(v(w).id)&&w.id!==$?.id),m=r.index===0?void 0:Fn(f.filter(w=>w!==$),T),d=w=>w.x<=i.width*.01||w.y<=i.height*.01||w.x+w.width>=i.width*.99||w.y+w.height>=i.height*.99,x=Rn(e,T.filter(w=>!d(w)),i),g=m&&Hn(m,x,w=>v(s.get(w)).id),M=new Set(g?.members.flatMap(w=>w.slots.map(E=>E.shape))),k=St(),U=f.filter(w=>!M.has(w.id)).map(w=>oe(w,k,w===$?"title":void 0)),L=Bn(e,r,h,$,{items:g!==void 0,data:o.some(w=>w.kind==="chart"||w.kind==="table")});for(const w of x)M.has(w.id)||U.push({key:k.next("picture"),role:"picture",shape:w.id});const F=L==="content"||L==="data",S=F?T.filter(w=>w.parent===null&&(u(w.id).length>0||!d(w))&&!u(w.id).includes($)):[],b=F?Nn(S,$?.box,i):void 0,I=b!==void 0&&U.length>Vn,j=new Set(I?S.flatMap(w=>[w.id,...u(w.id).map(E=>E.id)]):[]),Q=U.filter(w=>!j.has(w.shape));return{page:{kind:L,source:{slide:r.index+1},slots:Q,...g&&!I?{items:g}:{},...b?{area:b,body:S.map(w=>w.id)}:{}},texts:l,title:$,signature:[L,g?.layout,g?.members.length,U.map(w=>w.role).sort().join(),S.length].join("|")}}const _n={title:"cover",secHead:"section"},Qn=new Set(["title","ctrTitle","subTitle","body","obj"]);function Kn(t){const e=X(t),n=new Set;return He(t).flatMap(r=>{const i=Ne(r),o=Ot(r);if(!i||n.has(i)||o==="blank"||/^vert/iu.test(o??""))return[];const s=ve(t,{layout:r});try{for(const g of B(s))try{Xe(g,"示例")}catch{}const l=G(t,s),u=te(t,s,l),p=St(),c=new Map(B(s).map(g=>[z(g),Et(g)??0])),h=l.flatMap(g=>{if(g.placeholder==="pic")return[{key:p.next("picture"),role:"picture",placeholder:c.get(g.id)}];if(!Qn.has(g.placeholder??""))return[];const M=u.get(g.id),k=/title$/iu.test(g.placeholder)?g.placeholder==="subTitle"?"subtitle":"title":"text";return[{key:p.next(k),role:k,placeholder:c.get(g.id),...M?{limit:ee(M)}:{}}]}),f=l.find(g=>g.placeholder==="title"||g.placeholder==="ctrTitle");if(!f)return[];n.add(i);const a=_n[o??""]??"content",y=l.filter(g=>g.placeholder==="body"||g.placeholder==="obj"),$=g=>Math.round(g/ce*10)/10,P=e.width*.05,v=f.y+f.height+P*.25,T=y.length>0?Math.min(...y.map(g=>g.x)):f.x,m=y.length>0?Math.max(...y.map(g=>g.x+g.width)):f.x+f.width,d=y.length>0?Math.max(...y.map(g=>g.y+g.height)):e.height-P,x=a==="content"&&d-v>e.height*.35?{x:$(T),y:$(v),w:$(m-T),h:$(d-v)}:void 0;return[{name:i,texts:u,title:u.get(f.id),signature:`layout|${i}`,page:{kind:a,source:{layout:i},slots:h,...x?{area:x,body:[]}:{}}}]}finally{We(t,s)}})}const Jn=30,Zn=4,Wn={cover:"封面",agenda:"目录",section:"章节",content:"内容",data:"数据",quote:"引言",closing:"结尾"};function Xn(t,e){const n=ft(t),r=Wt(),i=new Set,o=new Map;for(const c of n)for(const h of new Set(B(c).flatMap(f=>nt(f)==="shape"?[K(f).trim()]:[])))o.set(h,(o.get(h)??0)+1);const s=n.flatMap((c,h)=>{const f=Gn(t,c,r.read(t,c),{index:h,count:n.length,shown:a=>o.get(a.trim())??0});return!f||i.has(f.signature)?[]:(i.add(f.signature),[f])}),l=s.length<Zn?Kn(t):[],u=new Map,p=[...s,...l].slice(0,Jn).map(c=>{const h=(u.get(c.page.kind)??0)+1;u.set(c.page.kind,h);const f="name"in c?c.name:`${Wn[c.page.kind]}${h===1?"":` ${h}`}`;return{key:`${c.page.kind}${h===1?"":h}`,name:f,...c.page}});return{format:kt,formatVersion:1,id:e.id,version:e.version??"1",name:e.name,pages:p,design:Pn(t,[...s,...l],n)}}const he="QuireKit.Template",le="QuireKit.TemplateRef";function ue(t){if(t!==void 0)try{return JSON.parse(t)}catch{return}}function Yn(t){const e=ue(bt(t)[le]);return e&&[e.source,e.id,e.version,e.name].every(n=>typeof n=="string")?e:null}const vt=t=>t.replace(/\.(?:pptx|potx|ppsx)$/iu,"");let ht;function de(t){if(!ht){ht=new Uint32Array(256);for(let n=0;n<256;n+=1){let r=n;for(let i=0;i<8;i+=1)r=r&1?3988292384^r>>>1:r>>>1;ht[n]=r>>>0}}let e=4294967295;for(const n of t)e=ht[(e^n)&255]^e>>>8;return(e^4294967295)>>>0}function tr(t){const e=new TextEncoder,n=[],r=[];let i=0;for(const c of t){const h=e.encode(c.name),f=de(c.bytes),a=new DataView(new ArrayBuffer(30));a.setUint32(0,67324752,!0),a.setUint16(4,20,!0),a.setUint16(6,2048,!0),a.setUint32(14,f,!0),a.setUint32(18,c.bytes.length,!0),a.setUint32(22,c.bytes.length,!0),a.setUint16(26,h.length,!0),n.push(new Uint8Array(a.buffer),h,c.bytes);const y=new DataView(new ArrayBuffer(46));y.setUint32(0,33639248,!0),y.setUint16(4,20,!0),y.setUint16(6,20,!0),y.setUint16(8,2048,!0),y.setUint32(16,f,!0),y.setUint32(20,c.bytes.length,!0),y.setUint32(24,c.bytes.length,!0),y.setUint16(28,h.length,!0),y.setUint32(42,i,!0),r.push(new Uint8Array(y.buffer),h),i+=30+h.length+c.bytes.length}const o=r.reduce((c,h)=>c+h.length,0),s=new DataView(new ArrayBuffer(22));s.setUint32(0,101010256,!0),s.setUint16(8,t.length,!0),s.setUint16(10,t.length,!0),s.setUint32(12,o,!0),s.setUint32(16,i,!0);const l=[...n,...r,new Uint8Array(s.buffer)],u=new Uint8Array(l.reduce((c,h)=>c+h.length,0));let p=0;for(const c of l)u.set(c,p),p+=c.length;return u}function er(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);let n=-1;for(let s=t.length-22;s>=Math.max(0,t.length-65557);s-=1)if(e.getUint32(s,!0)===101010256){n=s;break}if(n<0)throw new Error("Not a zip archive.");const r=e.getUint16(n+10,!0);let i=e.getUint32(n+16,!0);const o=[];for(let s=0;s<r;s+=1){if(e.getUint32(i,!0)!==33639248)throw new Error("Broken zip directory.");const l=e.getUint16(i+28,!0),u=e.getUint16(i+30,!0),p=e.getUint16(i+32,!0);o.push({name:new TextDecoder().decode(t.subarray(i+46,i+46+l)),offset:e.getUint32(i+42,!0),record:i,recordLength:46+l+u+p,method:e.getUint16(i+10,!0),size:e.getUint32(i+20,!0)}),i+=46+l+u+p}return o}async function nr(t){const e=new Blob([t]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(e).arrayBuffer())}async function rr(t,e,n){const r=er(t),i=r.find(v=>v.name===e);if(!i)throw new Error(`${e} is not in the archive.`);const o=new DataView(t.buffer,t.byteOffset,t.byteLength),s=[...r].sort((v,T)=>v.offset-T.offset),l=Math.min(...r.map(v=>v.record)),u=[],p=new Map;let c=0,h=null;for(const[v,T]of s.entries()){if(p.set(T,c),T!==i){const L=t.subarray(T.offset,s[v+1]?.offset??l);u.push(L),c+=L.length;continue}const m=o.getUint16(T.offset+26,!0),d=o.getUint16(T.offset+28,!0),x=T.offset+30+m+d,g=t.subarray(x,x+T.size),M=n(T.method===8?await nr(g):g.slice());h={data:M,crc:de(M)};const k=new Uint8Array(30+m);k.set(t.subarray(T.offset,T.offset+30+m));const U=new DataView(k.buffer);U.setUint16(6,U.getUint16(6,!0)&-9,!0),U.setUint16(8,0,!0),U.setUint32(14,h.crc,!0),U.setUint32(18,M.length,!0),U.setUint32(22,M.length,!0),U.setUint16(28,0,!0),u.push(k,M),c+=k.length+M.length}const f=c;for(const v of r){const T=t.slice(v.record,v.record+v.recordLength),m=new DataView(T.buffer);m.setUint32(42,p.get(v),!0),v===i&&h&&(m.setUint16(8,m.getUint16(8,!0)&-9,!0),m.setUint16(10,0,!0),m.setUint32(16,h.crc,!0),m.setUint32(20,h.data.length,!0),m.setUint32(24,h.data.length,!0)),u.push(T),c+=T.length}const a=new Uint8Array(22),y=new DataView(a.buffer);y.setUint32(0,101010256,!0),y.setUint16(8,r.length,!0),y.setUint16(10,r.length,!0),y.setUint32(12,c-f,!0),y.setUint32(16,f,!0),u.push(a);const $=new Uint8Array(c+a.length);let P=0;for(const v of u)$.set(v,P),P+=v.length;return $}const V={presentation:"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml",template:"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml",slideShow:"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml"};function Ut(t,e,n){return rr(t,"[Content_Types].xml",r=>{let i=new TextDecoder().decode(r);for(const o of e)i=i.replace(o,n);return new TextEncoder().encode(i)})}function ir(t){return Ut(t,[V.presentation],V.template)}function or(t){return Ut(t,[V.presentation],V.slideShow)}function sr(t){return Ut(t,[V.template,V.slideShow],V.presentation)}async function fe(t,e){return/\.(potx|ppsx)$/iu.test(t)?{name:t.replace(/\.(potx|ppsx)$/iu,".pptx"),bytes:await sr(e).catch(()=>e)}:{name:t,bytes:e}}const ar={type:"string",pattern:"^#[0-9A-Fa-f]{6}$"},pe={type:"object",properties:{chinese:{type:"string",minLength:1},latin:{type:"string",minLength:1}},required:["chinese","latin"]},me={type:"array",items:{type:"integer"}},D={type:"number",exclusiveMinimum:0},ge={type:"object",properties:{key:{type:"string",minLength:1},role:{enum:["title","subtitle","text","label","picture"]},shape:{type:"integer"},placeholder:{type:"integer"},sample:{type:"string"},limit:{type:"integer",minimum:1},fixed:{type:"boolean"}},required:["key","role"]},ye={$schema:"https://json-schema.org/draft/2020-12/schema",title:"QuireKit presentation template",type:"object",properties:{format:{const:kt},formatVersion:{const:1},id:{type:"string",minLength:1},version:{type:"string",minLength:1},name:{type:"string",minLength:1},description:{type:"string"},tags:{type:"array",items:{type:"string"}},notes:{type:"array",items:{type:"string"}},pages:{type:"array",minItems:1,items:{type:"object",properties:{key:{type:"string",minLength:1},kind:{enum:["cover","agenda","section","content","data","quote","closing"]},name:{type:"string",minLength:1},source:{oneOf:[{type:"object",properties:{slide:{type:"integer",minimum:1}},required:["slide"]},{type:"object",properties:{layout:{type:"string",minLength:1}},required:["layout"]}]},slots:{type:"array",items:ge},items:{type:"object",properties:{layout:{enum:["row","column","grid"]},members:{type:"array",minItems:1,items:{type:"object",properties:{shapes:me,slots:{type:"array",items:ge}},required:["shapes","slots"]}}},required:["layout","members"]},area:{type:"object",properties:{x:{type:"number"},y:{type:"number"},w:D,h:D},required:["x","y","w","h"]},body:me},required:["key","kind","name","source","slots"]}},design:{type:"object",properties:{palette:{type:"object",properties:Object.fromEntries(rt.map(t=>[t,ar])),required:[...rt]},fonts:{type:"object",properties:{heading:pe,body:pe},required:["heading","body"]},type:{type:"object",properties:{display:D,title:D,subtitle:D,body:D,small:D},required:["display","title","subtitle","body","small"]},margin:{type:"number",minimum:0}},required:["palette","fonts","type","margin"]}},required:["format","formatVersion","id","version","name","pages"]},we=t=>t===null?"null":Array.isArray(t)?"array":typeof t;function lt(t,e,n){if("const"in t&&e!==t.const)return`${n} must be ${JSON.stringify(t.const)}`;if(t.enum&&!t.enum.includes(e))return`${n} must be one of ${t.enum.join(", ")}`;if(t.type&&(t.type==="integer"?!Number.isInteger(e):we(e)!==t.type))return`${n} must be ${t.type==="integer"?"a whole number":`of type ${t.type}`}`;if(typeof e=="string"&&(e.length<(t.minLength??0)||t.pattern&&!new RegExp(t.pattern,"u").test(e)))return`${n} is empty or malformed`;if(typeof e=="number"&&(e<(t.minimum??-1/0)||e<=(t.exclusiveMinimum??-1/0)))return`${n} is too small`;if(t.oneOf&&!t.oneOf.some(r=>lt(r,e,n)===void 0))return`${n} matches none of its forms`;if(Array.isArray(e)){if(e.length<(t.minItems??0))return`${n} needs at least ${t.minItems} entries`;for(const[r,i]of e.entries()){const o=t.items&<(t.items,i,`${n}[${r}]`);if(o)return o}}else if(we(e)==="object"){const r=e,i=t.required?.find(o=>r[o]===void 0);if(i)return`${n}.${i} is missing`;for(const[o,s]of Object.entries(t.properties??{})){const l=r[o]===void 0?void 0:lt(s,r[o],`${n}.${o}`);if(l)return l}}}function $t(t){const e=lt(ye,t,"template");if(e)return{problem:e};const n=t,r=n.pages.map(o=>o.key),i=r.find((o,s)=>r.indexOf(o)!==s);return i===void 0?n:{problem:`template.pages has two pages named "${i}"`}}async function xe(t,e,n){const r=vt(t.name),i=await Ze((await fe(t.name,t.bytes)).bytes),o=$t(ue(bt(i)[he]));let s="problem"in o?void 0:o;if(t.manifest!==void 0){const p=$t(t.manifest);if("problem"in p)throw new Error(p.problem);s=p}const l=s?.design?void 0:Xn(i,{id:n,name:r}),u={...s??l,design:s?.design??l.design};if(u.pages.length===0)throw new Error("The template has no pages to fill.");return{presentation:i,manifest:u,reference:{source:e,id:n,version:u.version,name:u.name}}}async function cr(t){return(await xe(t,"file",vt(t.name))).manifest}export{A,Vt as C,ot as D,Ct as E,At as F,tn as I,Ye as L,nn as M,W as N,Rt as O,Ft as P,pt as R,rn as S,gt as T,Wt as _,fe as a,X as b,tr as c,le as d,vt as f,kt as g,O as h,$t as i,rt as j,en as k,he as l,Yt as m,xe as n,or as o,Xt as p,ye as r,ir as s,cr as t,Yn as u,hn as v,qt as w,on as x,G as y,Z as z};
|
package/dist/styles.css
CHANGED
|
@@ -544,6 +544,35 @@
|
|
|
544
544
|
.pptx-size-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
+
.pptx-templates { display: grid; gap: 14px; width: 500px; max-height: min(560px, 72vh); overflow-y: auto; padding: 14px; justify-items: start;
|
|
548
|
+
}
|
|
549
|
+
.pptx-templates section { display: grid; gap: 8px; width: 100%;
|
|
550
|
+
}
|
|
551
|
+
.pptx-templates h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--qk-color-text-secondary);
|
|
552
|
+
}
|
|
553
|
+
.pptx-templates p { margin: 0; font-size: 13px; color: var(--qk-color-text-secondary);
|
|
554
|
+
}
|
|
555
|
+
.pptx-templates-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
|
|
556
|
+
}
|
|
557
|
+
.pptx-template-item { position: relative;
|
|
558
|
+
}
|
|
559
|
+
.pptx-template-tile { display: grid; gap: 5px; width: 100%; padding: 0; border: 0; background: none; color: var(--qk-color-text-primary); font: inherit; font-size: 12px; cursor: pointer;
|
|
560
|
+
}
|
|
561
|
+
.pptx-template-art { display: block; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid var(--qk-color-border-subtle); border-radius: 4px; background: var(--qk-color-surface-subtle) center / contain no-repeat;
|
|
562
|
+
}
|
|
563
|
+
.pptx-template-art > svg { display: block; width: 100%; height: 100%; pointer-events: none;
|
|
564
|
+
}
|
|
565
|
+
.pptx-template-tile:hover .pptx-template-art { border-color: var(--qk-color-border-strong);
|
|
566
|
+
}
|
|
567
|
+
.pptx-template-tile:focus-visible { outline: 2px solid var(--qk-color-focus-ring); outline-offset: 2px; border-radius: 4px;
|
|
568
|
+
}
|
|
569
|
+
.pptx-template-name { overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap;
|
|
570
|
+
}
|
|
571
|
+
.pptx-template-remove { position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 4px; background: var(--qk-color-surface-page); color: var(--qk-color-text-secondary); opacity: 0; cursor: pointer;
|
|
572
|
+
}
|
|
573
|
+
.pptx-template-item:hover .pptx-template-remove, .pptx-template-remove:focus-visible { opacity: 1;
|
|
574
|
+
}
|
|
575
|
+
|
|
547
576
|
.pptx-theme-gallery { display: grid; grid-template-columns: repeat(4, 128px); gap: 10px; padding: 10px;
|
|
548
577
|
}
|
|
549
578
|
.pptx-theme-tile { display: grid; gap: 4px; padding: 0; border: 0; background: none; color: var(--qk-color-text-secondary); font: inherit; font-size: 12px; cursor: pointer;
|
|
@@ -769,64 +798,64 @@
|
|
|
769
798
|
.pptx-sorter-card.drop-after::after { right: -13px;
|
|
770
799
|
}
|
|
771
800
|
|
|
772
|
-
.pptx-directions[data-v-
|
|
801
|
+
.pptx-directions[data-v-df747f64] { height: 100%; overflow: auto; padding: 20px 28px 32px; display: grid; align-content: start; gap: 14px;
|
|
773
802
|
}
|
|
774
|
-
.pptx-directions-head[data-v-
|
|
803
|
+
.pptx-directions-head[data-v-df747f64] { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
|
|
775
804
|
}
|
|
776
|
-
.pptx-directions-title[data-v-
|
|
805
|
+
.pptx-directions-title[data-v-df747f64] { margin: 0;
|
|
777
806
|
}
|
|
778
|
-
.pptx-directions-hint[data-v-
|
|
807
|
+
.pptx-directions-hint[data-v-df747f64] { margin: 6px 0 0; color: var(--qk-color-text-secondary);
|
|
779
808
|
}
|
|
780
|
-
.pptx-direction[data-v-
|
|
809
|
+
.pptx-direction[data-v-df747f64] { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; padding: 14px; background: var(--qk-color-surface-raised); border-radius: var(--qk-radius-overlay);
|
|
781
810
|
}
|
|
782
|
-
.pptx-direction-info[data-v-
|
|
811
|
+
.pptx-direction-info[data-v-df747f64] { display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
|
|
783
812
|
}
|
|
784
|
-
.pptx-direction-colors[data-v-
|
|
813
|
+
.pptx-direction-colors[data-v-df747f64] { display: flex; gap: 4px;
|
|
785
814
|
}
|
|
786
|
-
.pptx-direction-color[data-v-
|
|
815
|
+
.pptx-direction-color[data-v-df747f64] { width: 22px; height: 22px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%);
|
|
787
816
|
}
|
|
788
|
-
.pptx-direction-style[data-v-
|
|
817
|
+
.pptx-direction-style[data-v-df747f64] { margin-top: 2px; color: var(--qk-color-text-secondary); font-size: 12px;
|
|
789
818
|
}
|
|
790
|
-
.pptx-direction-motif[data-v-
|
|
819
|
+
.pptx-direction-motif[data-v-df747f64] { margin: 0; color: var(--qk-color-text-secondary); font-size: 12px; line-height: 1.5;
|
|
791
820
|
}
|
|
792
|
-
.pptx-direction-samples[data-v-
|
|
821
|
+
.pptx-direction-samples[data-v-df747f64] { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
|
|
793
822
|
}
|
|
794
|
-
.pptx-direction-sample[data-v-
|
|
823
|
+
.pptx-direction-sample[data-v-df747f64] { width: 100%; border-radius: 6px; box-shadow: 0 1px 3px rgb(0 0 0 / 12%); background: #fff;
|
|
795
824
|
}
|
|
796
|
-
.pptx-directions-describe[data-v-
|
|
825
|
+
.pptx-directions-describe[data-v-df747f64] { display: flex; gap: 8px; align-items: flex-end;
|
|
797
826
|
}
|
|
798
827
|
|
|
799
|
-
.pptx-storyline[data-v-
|
|
828
|
+
.pptx-storyline[data-v-bf65e27e] { height: 100%; overflow: auto; padding: 20px 28px 32px;
|
|
800
829
|
}
|
|
801
|
-
.pptx-storyline-head[data-v-
|
|
830
|
+
.pptx-storyline-head[data-v-bf65e27e] { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px;
|
|
802
831
|
}
|
|
803
|
-
.pptx-storyline-title[data-v-
|
|
832
|
+
.pptx-storyline-title[data-v-bf65e27e] { margin: 0;
|
|
804
833
|
}
|
|
805
|
-
.pptx-storyline-count[data-v-
|
|
834
|
+
.pptx-storyline-count[data-v-bf65e27e] { color: var(--qk-color-text-secondary); font-weight: 400;
|
|
806
835
|
}
|
|
807
|
-
.pptx-storyline-chips[data-v-
|
|
836
|
+
.pptx-storyline-chips[data-v-bf65e27e] { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
|
|
808
837
|
}
|
|
809
|
-
.pptx-storyline-actions[data-v-
|
|
838
|
+
.pptx-storyline-actions[data-v-bf65e27e] { display: flex; gap: 8px; flex-shrink: 0;
|
|
810
839
|
}
|
|
811
|
-
.pptx-storyline-empty[data-v-
|
|
840
|
+
.pptx-storyline-empty[data-v-bf65e27e] { color: var(--qk-color-text-secondary); margin: 24px 0;
|
|
812
841
|
}
|
|
813
|
-
.pptx-storyline-list[data-v-
|
|
842
|
+
.pptx-storyline-list[data-v-bf65e27e] { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px;
|
|
814
843
|
}
|
|
815
|
-
.pptx-storyline-section[data-v-
|
|
844
|
+
.pptx-storyline-section[data-v-bf65e27e] { grid-column: 1 / -1; color: var(--qk-color-text-secondary); font-size: 12px; font-weight: 600; padding: 6px 2px 0;
|
|
816
845
|
}
|
|
817
|
-
.pptx-storyline-card[data-v-
|
|
846
|
+
.pptx-storyline-card[data-v-bf65e27e] { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 10px 8px 10px 14px; background: var(--qk-color-surface-raised); border-radius: var(--qk-radius-overlay);
|
|
818
847
|
}
|
|
819
|
-
.pptx-storyline-number[data-v-
|
|
848
|
+
.pptx-storyline-number[data-v-bf65e27e] { color: var(--qk-color-text-tertiary, var(--qk-color-text-secondary)); font-variant-numeric: tabular-nums; font-weight: 600; padding-top: 6px;
|
|
820
849
|
}
|
|
821
|
-
.pptx-storyline-point[data-v-
|
|
850
|
+
.pptx-storyline-point[data-v-bf65e27e] textarea { font-weight: 600; font-size: 14px;
|
|
822
851
|
}
|
|
823
|
-
.pptx-storyline-proof[data-v-
|
|
852
|
+
.pptx-storyline-proof[data-v-bf65e27e] textarea { color: var(--qk-color-text-secondary);
|
|
824
853
|
}
|
|
825
|
-
.pptx-storyline-tools[data-v-
|
|
854
|
+
.pptx-storyline-tools[data-v-bf65e27e] { display: flex; flex-direction: column; gap: 2px; opacity: 0.6;
|
|
826
855
|
}
|
|
827
|
-
.pptx-storyline-card:hover .pptx-storyline-tools[data-v-
|
|
856
|
+
.pptx-storyline-card:hover .pptx-storyline-tools[data-v-bf65e27e], .pptx-storyline-card:focus-within .pptx-storyline-tools[data-v-bf65e27e] { opacity: 1;
|
|
828
857
|
}
|
|
829
|
-
.pptx-storyline-add[data-v-
|
|
858
|
+
.pptx-storyline-add[data-v-bf65e27e] { display: flex; align-items: center; justify-content: center; min-height: 64px; border-radius: var(--qk-radius-overlay); outline: 1px dashed var(--qk-color-border-default, #d6d3d1); outline-offset: -1px;
|
|
830
859
|
}
|
|
831
860
|
|
|
832
861
|
.pptx-export-handout { display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: end;
|
|
@@ -1021,11 +1050,11 @@
|
|
|
1021
1050
|
.pptx-paragraph-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px;
|
|
1022
1051
|
}
|
|
1023
1052
|
|
|
1024
|
-
.pptx-assist-prompt[data-v-
|
|
1053
|
+
.pptx-assist-prompt[data-v-5a0b8be3] { position: fixed; z-index: 4; width: 360px; padding: 12px; display: grid; gap: 8px; background: var(--qk-color-surface-raised); border-radius: var(--qk-radius-overlay); box-shadow: var(--qk-shadow-overlay, 0 8px 24px rgb(0 0 0 / 12%));
|
|
1025
1054
|
}
|
|
1026
|
-
.pptx-assist-prompt-title[data-v-
|
|
1055
|
+
.pptx-assist-prompt-title[data-v-5a0b8be3] { color: var(--qk-color-text-secondary);
|
|
1027
1056
|
}
|
|
1028
|
-
.pptx-assist-prompt-actions[data-v-
|
|
1057
|
+
.pptx-assist-prompt-actions[data-v-5a0b8be3] { display: flex; justify-content: flex-end; gap: 8px;
|
|
1029
1058
|
}
|
|
1030
1059
|
|
|
1031
1060
|
.pptx-chart-data { display: grid; gap: 8px; padding: 12px; border-top: 1px solid var(--qk-color-border-subtle);
|
|
@@ -1258,25 +1287,25 @@
|
|
|
1258
1287
|
.pptx-effect-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
1259
1288
|
}
|
|
1260
1289
|
|
|
1261
|
-
.pptx-split[data-v-
|
|
1290
|
+
.pptx-split[data-v-e6781205] { min-width: 0; min-height: 0; display: flex;
|
|
1262
1291
|
}
|
|
1263
|
-
.pptx-split[data-v-
|
|
1292
|
+
.pptx-split[data-v-e6781205] > .qk-splitter-frame { flex: 1; min-width: 0; min-height: 0; display: flex;
|
|
1264
1293
|
}
|
|
1265
|
-
.pptx-split[data-v-
|
|
1294
|
+
.pptx-split[data-v-e6781205] .qk-splitter { flex: 1; min-width: 0; min-height: 0;
|
|
1266
1295
|
}
|
|
1267
|
-
.pptx-split[data-v-
|
|
1296
|
+
.pptx-split[data-v-e6781205] .qk-splitter__panel { min-width: 0; min-height: 0; overflow: hidden;
|
|
1268
1297
|
}
|
|
1269
|
-
.pptx-split[data-collapsed][data-v-
|
|
1298
|
+
.pptx-split[data-collapsed][data-v-e6781205] .qk-splitter__handle { display: none;
|
|
1270
1299
|
}
|
|
1271
|
-
.pptx-split-main[data-v-
|
|
1300
|
+
.pptx-split-main[data-v-e6781205], .pptx-split-side[data-v-e6781205] { height: 100%; min-width: 0; min-height: 0; display: flex; flex-direction: column;
|
|
1272
1301
|
}
|
|
1273
1302
|
/* The open panel is a white card on the stage's tone, one gap from every edge; the handle sits in the left gap. */
|
|
1274
|
-
.pptx-split-side[data-v-
|
|
1303
|
+
.pptx-split-side[data-v-e6781205] { padding: 8px;
|
|
1275
1304
|
}
|
|
1276
|
-
.pptx-split-main[data-v-
|
|
1305
|
+
.pptx-split-main[data-v-e6781205] > *, .pptx-split-side[data-v-e6781205] > * { flex: 1; min-height: 0;
|
|
1277
1306
|
}
|
|
1278
1307
|
|
|
1279
|
-
.pptx-shape-gallery[data-v-
|
|
1308
|
+
.pptx-shape-gallery[data-v-ba8be53b] {
|
|
1280
1309
|
display: grid;
|
|
1281
1310
|
gap: var(--qk-space-surface-compact);
|
|
1282
1311
|
width: min(380px, calc(100vw - 56px));
|
|
@@ -1533,6 +1562,7 @@
|
|
|
1533
1562
|
grid-template-columns: 208px minmax(0, 1fr) auto;
|
|
1534
1563
|
min-height: 0;
|
|
1535
1564
|
display: grid;
|
|
1565
|
+
position: relative;
|
|
1536
1566
|
}
|
|
1537
1567
|
|
|
1538
1568
|
.pptx-body[data-slides="hidden"] {
|
|
@@ -1989,6 +2019,29 @@
|
|
|
1989
2019
|
}
|
|
1990
2020
|
.pptx-qr-error { margin: 0; font-size: 12px; color: var(--qk-color-danger-solid);
|
|
1991
2021
|
}
|
|
2022
|
+
|
|
2023
|
+
.pptx-license[data-v-a635db96] {
|
|
2024
|
+
position: absolute;
|
|
2025
|
+
inset: 0;
|
|
2026
|
+
z-index: 1;
|
|
2027
|
+
overflow: hidden;
|
|
2028
|
+
pointer-events: none;
|
|
2029
|
+
}
|
|
2030
|
+
.pptx-license-badge[data-v-a635db96] {
|
|
2031
|
+
position: absolute;
|
|
2032
|
+
inset-inline-end: 28px;
|
|
2033
|
+
inset-block-end: 20px;
|
|
2034
|
+
padding: 6px 14px;
|
|
2035
|
+
border-radius: 999px;
|
|
2036
|
+
background: var(--qk-color-warning-solid);
|
|
2037
|
+
color: var(--qk-color-warning-on-solid);
|
|
2038
|
+
box-shadow: var(--qk-elevation-overlay);
|
|
2039
|
+
font-size: 13px;
|
|
2040
|
+
font-weight: 600;
|
|
2041
|
+
line-height: 20px;
|
|
2042
|
+
text-decoration: none;
|
|
2043
|
+
pointer-events: auto;
|
|
2044
|
+
}
|
|
1992
2045
|
@layer qk-recipes {
|
|
1993
2046
|
.qk-type-body {
|
|
1994
2047
|
font-family: var(--qk-type-body-font-family);
|
|
@@ -2094,6 +2147,10 @@
|
|
|
2094
2147
|
margin-bottom: 1rem;
|
|
2095
2148
|
}
|
|
2096
2149
|
|
|
2150
|
+
.me {
|
|
2151
|
+
margin-inline-end: 1rem;
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2097
2154
|
.ms {
|
|
2098
2155
|
margin-inline-start: 1rem;
|
|
2099
2156
|
}
|