@coco-vexel/coco-office-editor 1.0.6 → 1.0.8
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/THIRD_PARTY_NOTICES.md +2 -2
- package/dist/index.cjs +51 -44
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +51 -44
- package/dist/{native-CYm_SwYR.d.ts → native-C3ZdrIcW.d.ts} +2 -1
- package/dist/{native-TMv552dv.d.cts → native-DxWyYM4C.d.cts} +2 -1
- package/dist/{native-TMv552dv.d.ts → native-DxWyYM4C.d.ts} +2 -1
- package/dist/{native-C8FmLU7F.d.cts → native-wR2uhZvi.d.cts} +2 -1
- package/dist/ppt-native.cjs +7 -7
- package/dist/ppt-native.d.cts +1 -1
- package/dist/ppt-native.d.ts +1 -1
- package/dist/ppt-native.js +7 -7
- package/dist/ppt.cjs +7 -7
- package/dist/ppt.d.cts +1 -1
- package/dist/ppt.d.ts +1 -1
- package/dist/ppt.js +7 -7
- package/dist/spreadsheet.cjs +13 -11
- package/dist/spreadsheet.d.cts +63 -7
- package/dist/spreadsheet.d.ts +63 -7
- package/dist/spreadsheet.js +13 -11
- package/dist/word-editing.d.cts +3 -2
- package/dist/word-editing.d.ts +3 -2
- package/dist/word-native.cjs +21 -16
- package/dist/word-native.d.cts +1 -1
- package/dist/word-native.d.ts +1 -1
- package/dist/word-native.js +21 -16
- package/dist/word-prosemirror.d.cts +4 -3
- package/dist/word-prosemirror.d.ts +4 -3
- package/dist/word.cjs +27 -22
- package/dist/word.d.cts +4 -3
- package/dist/word.d.ts +4 -3
- package/dist/word.js +27 -22
- package/package.json +8 -8
- package/src/styles/editor.css +5 -0
package/dist/ppt.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';var ppt=require('@coco-vexel/coco-office/ppt');var
|
|
2
|
-
`)}function pn(t,e){if(!t.table)return e;let n=Ze(t.table.columnWidths),i=Ze(t.table.rowHeights);return n===void 0&&i===void 0?e:C(C(C({},e),qe(e.width,n)?{width:n}:{}),qe(e.height,i)?{height:i}:{})}function Ze(t){if(!(t!=null&&t.length))return;let e=t.reduce((n,i)=>n+i,0);return Number.isFinite(e)&&e>0?e:void 0}function qe(t,e){return e===void 0?false:!Number.isFinite(t)||t<=0?true:e/t>1.15}function hn(t,e){var r;let n=te(t.geometry),i=e.slideSize;if(e.index===0&&t.kind==="geometricShape"&&!((r=t.text)!=null&&r.text)&&i&&n.left<=0&&n.top<=0&&n.width>=i.width*.95&&n.height>=i.height*.95)return "#1D3F80"}function fn(t,e){var i,r;if(t!=null&&t.color)return t;let n=(r=e.fillColor)!=null?r:(i=e.background)==null?void 0:i.fillColor;return !n||!mn(n)?t:G(C({},t),{color:"#FFFFFF"})}function mn(t){let e=/^#?([0-9a-f]{6})$/i.exec(t);if(!e)return false;let n=e[1],i=Number.parseInt(n.slice(0,2),16),r=Number.parseInt(n.slice(2,4),16),o=Number.parseInt(n.slice(4,6),16);return (.2126*i+.7152*r+.0722*o)/255<.45}function qr(t){let e=tt(t);return e.editText||e.editTextStyle||e.editTableCells||e.editGeometry||e.editShapeStyle}function tt(t){if(bn(t))return {select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:false,editShapeStyle:false,reason:"Inherited from layout/master",reasons:Ke("\u7EE7\u627F\u81EA\u6BCD\u7248/\u7248\u5F0F\uFF0C\u5F53\u524D\u53EA\u652F\u6301\u67E5\u770B")};if(yn(t)){let n=!!t.text&&pe.has(t.kind),i=t.kind==="table"&&!!t.table;return {select:true,editText:n,editTextStyle:n,editTableCells:i,editGeometry:true,editShapeStyle:false,reason:"Flattened group child",reasons:ee({editText:n?void 0:ue(t),editTextStyle:n?void 0:ue(t),editTableCells:i?void 0:"\u5F53\u524D\u5BF9\u8C61\u4E0D\u662F\u8868\u683C",editShapeStyle:"\u7EC4\u5185\u5B50\u5BF9\u8C61\u6682\u4E0D\u652F\u6301\u8BE5\u9879\u76F4\u63A5\u7F16\u8F91"})}}if(t.kind==="table")return {select:true,editText:false,editTextStyle:false,editTableCells:true,editGeometry:true,editShapeStyle:true,reasons:ee({editText:"\u8868\u683C\u6587\u5B57\u8BF7\u4F7F\u7528\u5355\u5143\u683C\u7F16\u8F91",editTextStyle:"\u8868\u683C\u6587\u5B57\u6837\u5F0F\u5F53\u524D\u4E0D\u5728\u9AD8\u9891\u5DE5\u5177\u680F\u5F00\u653E"})};if(t.kind==="picture")return {select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:true,editShapeStyle:true,reasons:ee({editText:"\u56FE\u7247\u5BF9\u8C61\u6CA1\u6709\u53EF\u7F16\u8F91\u6587\u5B57",editTextStyle:"\u56FE\u7247\u5BF9\u8C61\u6CA1\u6709\u53EF\u7F16\u8F91\u6587\u5B57\u6837\u5F0F",editTableCells:"\u5F53\u524D\u5BF9\u8C61\u4E0D\u662F\u8868\u683C"})};if(t.kind==="chart"||t.kind==="smartArt"||t.kind==="group"){let n=gn(t.kind);return {select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:true,editShapeStyle:false,reason:"Limited editor support for this object type",reasons:ee({editText:n.text,editTextStyle:n.textStyle,editTableCells:"\u5F53\u524D\u5BF9\u8C61\u4E0D\u662F\u8868\u683C",editShapeStyle:n.shapeStyle})}}let e=!!t.text&&pe.has(t.kind);return pe.has(t.kind)?{select:true,editText:e,editTextStyle:e,editTableCells:false,editGeometry:true,editShapeStyle:true,reasons:ee({editText:e?void 0:ue(t),editTextStyle:e?void 0:ue(t),editTableCells:"\u5F53\u524D\u5BF9\u8C61\u4E0D\u662F\u8868\u683C"})}:{select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:false,editShapeStyle:false,reason:"Unsupported object type",reasons:Ke("\u5F53\u524D\u5BF9\u8C61\u7C7B\u578B\u6682\u4E0D\u652F\u6301\u5E38\u89C4\u7F16\u8F91")}}function ee(t){return Object.fromEntries(Object.entries(t).filter(e=>!!e[1]))}function Ke(t){return {editText:t,editTextStyle:t,editTableCells:t,editGeometry:t,editShapeStyle:t}}function ue(t){return t.text?pe.has(t.kind)?"\u5F53\u524D\u5BF9\u8C61\u6587\u5B57\u6682\u4E0D\u652F\u6301\u7F16\u8F91":"\u5F53\u524D\u5BF9\u8C61\u7C7B\u578B\u6682\u4E0D\u652F\u6301\u6587\u5B57\u7F16\u8F91":"\u5F53\u524D\u5BF9\u8C61\u6CA1\u6709\u53EF\u7F16\u8F91\u6587\u5B57\u5185\u5BB9"}function gn(t){return t==="chart"?{text:"\u56FE\u8868\u6587\u5B57\u7ED1\u5B9A\u5728\u56FE\u8868\u6570\u636E\u4E2D\uFF0C\u5F53\u524D\u4EC5\u5F00\u653E\u6574\u4F53\u4F4D\u7F6E\u5C3A\u5BF8",textStyle:"\u56FE\u8868\u5185\u90E8\u6587\u5B57\u6837\u5F0F\u6682\u672A\u5F00\u653E",shapeStyle:"\u56FE\u8868\u5F62\u72B6\u6837\u5F0F\u6682\u672A\u5F00\u653E"}:t==="smartArt"?{text:"SmartArt \u5185\u90E8\u6587\u672C\u7ED3\u6784\u6682\u672A\u5F00\u653E",textStyle:"SmartArt \u5185\u90E8\u6587\u5B57\u6837\u5F0F\u6682\u672A\u5F00\u653E",shapeStyle:"SmartArt \u6837\u5F0F\u6682\u672A\u5F00\u653E"}:{text:"\u7EC4\u5408\u5BF9\u8C61\u8BF7\u53CC\u51FB\u6216\u70B9\u9009\u7EC4\u5185\u5B50\u5BF9\u8C61\u7F16\u8F91\u6587\u5B57",textStyle:"\u7EC4\u5408\u5BF9\u8C61\u8BF7\u9009\u4E2D\u7EC4\u5185\u6587\u672C\u5B50\u5BF9\u8C61\u7F16\u8F91\u6587\u5B57\u6837\u5F0F",shapeStyle:"\u7EC4\u5408\u5BF9\u8C61\u6682\u4E0D\u652F\u6301\u6574\u4F53\u5F62\u72B6\u6837\u5F0F\u7F16\u8F91"}}function bn(t){return t.id.startsWith("layout:")||t.id.startsWith("master:")}function yn(t){return t.id.includes(":")}function nt(t,e){var f;if(!t.groupContext)return e;let n=t.groupContext.parentBounds,i=t.groupContext.parentTransform,r=C(C({},t.bounds),e),o=n.width/(i.childWidth||n.width||1),s=n.height/(i.childHeight||n.height||1),a=Sn(r.left+r.width/2,r.top+r.height/2,n),l=a.x-r.width/2,d=a.y-r.height/2,c=n.flipHorizontal?n.left+n.width-l-r.width:l-n.left,u=n.flipVertical?n.top+n.height-d-r.height:d-n.top,p={};return e.left!==void 0&&(p.left=c/o+i.childLeft),e.top!==void 0&&(p.top=u/s+i.childTop),e.width!==void 0&&(p.width=r.width/o),e.height!==void 0&&(p.height=r.height/s),e.rotation!==void 0&&(p.rotation=et(e.rotation-((f=n.rotation)!=null?f:0))),e.flipHorizontal!==void 0&&(p.flipHorizontal=!!n.flipHorizontal!=!!e.flipHorizontal),e.flipVertical!==void 0&&(p.flipVertical=!!n.flipVertical!=!!e.flipVertical),p}function xn(t){return Ye.get(t)}function Sn(t,e,n){if(!n.rotation)return {x:t,y:e};let i=-n.rotation*Math.PI/180,r=n.left+n.width/2,o=n.top+n.height/2,s=t-r,a=e-o;return {x:r+s*Math.cos(i)-a*Math.sin(i),y:o+s*Math.sin(i)+a*Math.cos(i)}}function te(t={}){var e,n,i,r;return {left:(e=t.left)!=null?e:0,top:(n=t.top)!=null?n:0,width:(i=t.width)!=null?i:0,height:(r=t.height)!=null?r:0,rotation:t.rotation,flipHorizontal:t.flipHorizontal,flipVertical:t.flipVertical}}function z(t,e){var n,i;return typeof e=="number"?(n=t.slides.find(r=>r.index===e))!=null?n:null:(i=t.slides.find(r=>r.id===e||r.name===e))!=null?i:null}function re(t,e){let n=[...t.nodes,...t.groups];for(;n.length>0;){let i=n.shift();if(i.id===e||i.name===e)return i;n.unshift(...i.children);}return null}async function Jr(t,e={}){let n=await ppt.Presentation.fromZip(t,{presentationId:e.presentationId,mode:"inline"});return rt(n,e)}async function eo(t,e={}){var i;let n=await ppt.Presentation.fromModel(t,{presentationId:(i=e.presentationId)!=null?i:t.id,mode:"inline"});return rt(n,e)}async function rt(t,e={}){let[n,i,r]=await Promise.all([t.toModel(),Pn(t,e),wn(t)]);return {presentation:t,model:n,scene:ne(n),images:i,fonts:r}}async function Pn(t,e){if(typeof Blob=="undefined"||typeof URL=="undefined"||typeof URL.createObjectURL!="function")return {};let n=await t.exportImages(),i=await Promise.all(n.map(async r=>{var s;let o=await((s=e.resolveImagePreview)==null?void 0:s.call(e,{path:r.path,contentType:r.contentType,bytes:r.bytes}));return [r.path,o!=null?o:{url:URL.createObjectURL(new Blob([ot(r.bytes)],{type:r.contentType})),contentType:r.contentType}]}));return Object.fromEntries(i)}async function wn(t){return typeof Blob=="undefined"||typeof URL=="undefined"||typeof URL.createObjectURL!="function"?[]:(await t.exportFonts()).map(n=>C(C({url:URL.createObjectURL(new Blob([ot(n.bytes)],{type:n.contentType})),contentType:n.contentType,family:n.family},n.weight?{weight:n.weight}:{}),n.style?{style:n.style}:{}))}function ot(t){let e=new Uint8Array(t.byteLength);return e.set(t),e.buffer}var he=class{constructor(e,n={}){M(this,"presentationValue");M(this,"modelValue");M(this,"sceneValue");M(this,"selectionValue",null);M(this,"revisionValue",0);M(this,"undoStack",[]);M(this,"redoStack",[]);M(this,"textBodyOverrides",new Map);M(this,"maxHistory");M(this,"readOnlyValue");M(this,"changeListeners",new Set);M(this,"selectionListeners",new Set);var i;this.presentationValue=e.presentation,this.modelValue=e.model,this.sceneValue=e.scene,this.maxHistory=(i=n.maxHistory)!=null?i:50,this.readOnlyValue=n.readOnly===true,this.selectionValue=e.scene.slides[0]?{kind:"slide",slideId:e.scene.slides[0].id}:null;}presentation(){return this.assertWritable(),this.presentationValue}model(){return this.modelValue}scene(){return this.sceneValue}selection(){return this.selectionValue}revision(){return this.revisionValue}isReadOnly(){return this.readOnlyValue}setReadOnly(e){this.readOnlyValue=e;}canUndo(){return !this.readOnlyValue&&this.undoStack.length>0}canRedo(){return !this.readOnlyValue&&this.redoStack.length>0}subscribe(e,n){let i=e==="change"?this.changeListeners:this.selectionListeners;return i.add(n),()=>i.delete(n)}async dispatch(e){if(e.kind==="select-slide"||e.kind==="select-shape"){await this.applySelectionCommand(e);return}this.assertWritable();let n=await this.presentationValue.toZip(),i=await this.applyEditCommand(e);this.pushUndo(n),this.redoStack.length=0,await this.refreshAfterChange(e),i!==void 0&&this.setSelection(i);}async undo(){this.assertWritable();let e=this.undoStack.pop();if(!e)return;let n=this.selectionValue;this.redoStack.push(this.historyEntry(await this.presentationValue.toZip())),this.restoreTextBodyOverrides(e.textBodyOverrides),await this.replacePresentation(e.bytes,n);}async redo(){this.assertWritable();let e=this.redoStack.pop();if(!e)return;let n=this.selectionValue;this.undoStack.push(this.historyEntry(await this.presentationValue.toZip())),this.restoreTextBodyOverrides(e.textBodyOverrides),await this.replacePresentation(e.bytes,n);}async loadPresentation(e){this.undoStack.length=0,this.redoStack.length=0,this.textBodyOverrides.clear(),await this.replacePresentation(e);}async toPptx(){return this.presentationValue.toZip()}async verifyExport(){let e=await this.toPptx(),n=await ppt.Presentation.fromZip(e,{mode:"inline"});try{return await n.toModel()}finally{await n.dispose();}}async destroy(){await this.presentationValue.dispose(),this.undoStack.length=0,this.redoStack.length=0,this.changeListeners.clear(),this.selectionListeners.clear();}assertWritable(){if(this.readOnlyValue)throw new J("ppt")}async applySelectionCommand(e){let n=z(this.sceneValue,e.slideIdOrIndex);if(!n)throw new Error(`PPT slide not found: ${String(e.slideIdOrIndex)}`);if(e.kind==="select-slide"){this.setSelection({kind:"slide",slideId:n.id});return}let i=re(n,e.shapeIdOrName);if(!i)throw new Error(`PPT shape not found: ${e.shapeIdOrName}`);this.setSelection({kind:"shape",slideId:n.id,shapeId:i.id});}async applyEditCommand(e){var s,a;if(e.kind==="delete-shape"||e.kind==="duplicate-shape"||e.kind==="paste-shape"||e.kind==="bring-shape-to-front"||e.kind==="send-shape-to-back")return this.applyShapeCollectionCommand(e);let n=this.assertEditableSceneNodeForCommand(e),i=z(this.sceneValue,e.slideIdOrIndex);if(!i)throw new Error(`PPT slide not found: ${String(e.slideIdOrIndex)}`);let r=this.presentationValue.slides.getItem(e.slideIdOrIndex),o=kn(r.shapes,e.shapeIdOrName);if(e.kind==="set-shape-text"){await o.text.setText(e.text,{preserveFirstRunStyle:true});return}if(e.kind==="set-shape-text-style"){await o.text.setTextStyle(e.style);return}if(e.kind==="set-table-cell-text"){await o.table.setCellText(e.row,e.column,e.text);return}if(e.kind==="set-shape-geometry"){if(e.preserveTextSizeOnResize&&En(n)){let l=G(C({},n.textBody),{autoFit:"none",wrap:(a=(s=n.textBody)==null?void 0:s.wrap)!=null?a:"square"});await o.text.setBodyProperties(l),this.textBodyOverrides.set(vn(i.id,n.id),l);}await o.setGeometry(nt(n,e.geometry));return}await o.setStyle(e.style);}assertEditableSceneNodeForCommand(e){var r;let n=z(this.sceneValue,e.slideIdOrIndex);if(!n)throw new Error(`PPT slide not found: ${String(e.slideIdOrIndex)}`);let i=(r=re(n,e.shapeIdOrName))!=null?r:Cn(n,e.shapeIdOrName);if(!i)throw new Error(`PPT shape not found: ${e.shapeIdOrName}`);if(Nn(e)&&(i.locked||i.id.includes(":")||!i.editable))throw new Error(`PPT shape collection operation is not editable: ${i.id}`);if(e.kind==="set-shape-text"&&!i.capabilities.editText)throw new Error(`PPT shape is not text-editable: ${i.id}`);if(e.kind==="set-shape-text-style"&&!i.capabilities.editTextStyle)throw new Error(`PPT shape text style is not editable: ${i.id}`);if(e.kind==="set-table-cell-text"&&!i.capabilities.editTableCells)throw new Error(`PPT shape table cells are not editable: ${i.id}`);if(e.kind==="set-shape-geometry"&&!i.capabilities.editGeometry)throw new Error(`PPT shape geometry is not editable: ${i.id}`);if(e.kind==="set-shape-style"&&!i.capabilities.editShapeStyle)throw new Error(`PPT shape style is not editable: ${i.id}`);return i}async applyShapeCollectionCommand(e){var d,c,u,p,f,m,b,h;this.assertEditableSceneNodeForCommand(e);let n=z(this.sceneValue,e.slideIdOrIndex);if(!n)throw new Error(`PPT slide not found: ${String(e.slideIdOrIndex)}`);let i=re(n,e.shapeIdOrName);if(!i)throw new Error(`PPT shape not found: ${e.shapeIdOrName}`);let o=this.presentationValue.slides.getItem(e.slideIdOrIndex).shapes.getItem(e.shapeIdOrName);if(e.kind==="delete-shape")return await o.delete(),{kind:"slide",slideId:n.id};if(e.kind==="bring-shape-to-front")return await o.bringToFront(),{kind:"shape",slideId:n.id,shapeId:i.id};if(e.kind==="send-shape-to-back")return await o.sendToBack(),{kind:"shape",slideId:n.id,shapeId:i.id};let s={left:typeof i.bounds.left=="number"?i.bounds.left+((c=(d=e.offset)==null?void 0:d.left)!=null?c:18e4):i.bounds.left,top:typeof i.bounds.top=="number"?i.bounds.top+((p=(u=e.offset)==null?void 0:u.top)!=null?p:18e4):i.bounds.top,width:(m=(f=e.offset)==null?void 0:f.width)!=null?m:i.bounds.width,height:(h=(b=e.offset)==null?void 0:b.height)!=null?h:i.bounds.height},l=await(await o.duplicate({geometry:s})).toModel();return {kind:"shape",slideId:n.id,shapeId:l.id}}async refreshAfterChange(e){this.modelValue=await this.presentationValue.toModel(),this.sceneValue=ne(this.modelValue),this.applyTextBodyOverrides(),this.revisionValue+=1,this.changeListeners.forEach(n=>n({revision:this.revisionValue,command:e,model:this.modelValue,scene:this.sceneValue}));}async replacePresentation(e,n=null){let i=await ppt.Presentation.fromZip(e,{mode:"inline"});if(await this.presentationValue.dispose(),this.presentationValue=i,this.modelValue=await i.toModel(),this.sceneValue=ne(this.modelValue),this.applyTextBodyOverrides(),n){let o=this.sceneValue.slides.find(s=>s.id===n.slideId);if(n.kind==="slide"&&o){this.setSelection({kind:"slide",slideId:o.id});return}if(n.kind==="shape"&&(o!=null&&o.nodes.some(s=>s.id===n.shapeId))){this.setSelection({kind:"shape",slideId:o.id,shapeId:n.shapeId});return}}let r=this.sceneValue.slides[0];this.setSelection(r?{kind:"slide",slideId:r.id}:null);}setSelection(e){this.selectionValue=e,this.selectionListeners.forEach(n=>n({selection:e}));}pushUndo(e){this.undoStack.push(this.historyEntry(e)),this.undoStack.length>this.maxHistory&&this.undoStack.shift();}historyEntry(e){return {bytes:e,textBodyOverrides:new Map(this.textBodyOverrides)}}restoreTextBodyOverrides(e){this.textBodyOverrides.clear(),e.forEach((n,i)=>this.textBodyOverrides.set(i,C({},n)));}applyTextBodyOverrides(){var e;for(let[n,i]of this.textBodyOverrides){let[r,o]=n.split("\0");if(!r||!o)continue;let s=z(this.sceneValue,r),a=s?re(s,o):null;!a||!a.text&&!((e=a.textParagraphs)!=null&&e.length)||(a.textBody=C(C({},a.textBody),i));}}};function vn(t,e){return `${t}\0${e}`}function En(t){var e;return !!(t.capabilities.editGeometry&&Mn(t)&&(t.text||(e=t.textParagraphs)!=null&&e.length))}function Mn(t){return t.kind==="placeholder"||t.kind==="textBox"||t.kind==="geometricShape"}function Cn(t,e){let n=t.source.shapes.find(i=>i.id===e||i.name===e);return n?ie(n,{slideSize:t.size,background:t.background}):null}function kn(t,e){let n=e.split(":").filter(Boolean);if(n.length<=1)return t.getItem(e);let i=t.getItem(n[0]);for(let r of n.slice(1))i=i.group.getItem(r);return i}function Nn(t){return t.kind==="delete-shape"||t.kind==="duplicate-shape"||t.kind==="paste-shape"||t.kind==="bring-shape-to-front"||t.kind==="send-shape-to-back"}var at=24e4,se=91440,Tn=91440,Ie=4,lt=7,D=128,An=8,fe=2,In=2,me=4;function po(t,e,n={}){return new $e(t,e,n)}function Gn(t){if(t.kind==="line"||t.kind!=="geometricShape"||t.customGeometry||t.presetGeometry&&t.presetGeometry!=="ellipse"||t.text||!t.fillColor)return false;let e=Math.min(t.bounds.width,t.bounds.height),n=Math.max(t.bounds.width,t.bounds.height);return e<=0?false:n/e<1.2}function O(t,e,n){var d,c,u,p;let i=Math.max(se,(d=n.width)!=null?d:t.width),r=Math.max(se,(c=n.height)!=null?c:t.height),o=Math.min(at,i),s=Math.min(at,r),a=ve((u=n.left)!=null?u:t.left,-i+o,e.width-o),l=ve((p=n.top)!=null?p:t.top,-r+s,e.height-s);return G(C({},t),{left:a,top:l,width:i,height:r})}function ve(t,e,n){return Math.max(e,Math.min(n,t))}function ge(t,e,n){let i=n==="x"?t.size.width:t.size.height,r=[{value:0,kind:"slide",role:"start"},{value:i/2,kind:"slide",role:"center"},{value:i,kind:"slide",role:"end"}];for(let o of t.nodes){if(!Ln(o,e))continue;let s=n==="x"?o.bounds.left:o.bounds.top,a=n==="x"?o.bounds.width:o.bounds.height;r.push({value:s,kind:"shape",role:"start",referenceShapeId:o.id},{value:s+a/2,kind:"shape",role:"center",referenceShapeId:o.id},{value:s+a,kind:"shape",role:"end",referenceShapeId:o.id});}return r}function Ln(t,e){return t.id!==e&&t.kind!=="line"&&!t.locked&&!t.id.includes(":")&&t.capabilities.select&&t.capabilities.editGeometry&&t.bounds.width>se&&t.bounds.height>se}function be(t,e,n,i={}){let r=null;for(let o of t)for(let s of e){if(i.matchRole!==false&&o.role!==s.role)continue;let a=Math.abs(o.value-s.value);a>n||(!r||a<r.distance)&&(r={source:o,target:s,distance:a});}return r}function dt(t,e,n,i){let r=e/2,o=Math.abs(n.offset-r)<1?(i-t)*2:i-t;return Math.max(se,o)}function F(t){return !t.locked&&!t.id.includes(":")&&(t.capabilities.editGeometry||t.capabilities.editText||t.capabilities.editShapeStyle||t.capabilities.editTableCells)}function $n(t){let e=t.groupContext;return e?G(C({},t),{id:e.parentId,name:e.parentName,kind:"group",bounds:e.parentBounds,text:void 0,textStyle:void 0,textParagraphs:void 0,textBody:void 0,groupContext:void 0,locked:false,editable:true,capabilities:{select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:true,editShapeStyle:false,reason:"Parent group"},children:[]}):t}function Rn(t){var o,s;if(t.kind!=="picture"||!t.customGeometry||t.customGeometry.paths.length!==1)return false;let e=Math.min(t.bounds.width,t.bounds.height),n=Math.max(t.bounds.width,t.bounds.height);if(e<=0||n/e>1.12)return false;let i=(s=(o=t.customGeometry.paths[0])==null?void 0:o.commands)!=null?s:[];return i.filter(a=>a.kind==="cubicBezierTo").length>=4&&i.some(a=>a.kind==="close")}var $e=class{constructor(e,n,i){M(this,"root");M(this,"sessionValue");M(this,"imageResources");M(this,"fontResources");M(this,"referencedFontFamilies");M(this,"slideList",document.createElement("div"));M(this,"canvas",document.createElement("div"));M(this,"contextMenu",document.createElement("div"));M(this,"snapGuides",document.createElement("div"));M(this,"options");M(this,"handleCanvasClick",()=>{this.dispatchCurrentSlideSelection();});M(this,"handleWindowMouseMove",e=>{this.updateDrag(e);});M(this,"handleWindowMouseUp",e=>{this.finishDrag(e);});M(this,"handleWindowKeyDown",e=>{this.handleKeyDown(e);});M(this,"handleWindowPointerDown",e=>{this.dismissContextMenu(e);});M(this,"handleWindowScroll",()=>this.hideContextMenu());M(this,"handleCanvasSelectStart",e=>this.handleSelectStart(e));M(this,"handleSlideListScroll",()=>this.scheduleThumbnailRender());M(this,"dragState",null);M(this,"suppressClickAfterDrag",false);M(this,"clipboardShape",null);M(this,"thumbnailFrame",0);M(this,"thumbnailRasterEpoch",0);M(this,"thumbnailCanvasCache",new Map);M(this,"pendingCommands",new Set);this.options=i,this.root=i.styleIsolation==="none"?e:e.attachShadow({mode:"open"}),this.sessionValue=new he(n,{readOnly:i.readOnly}),this.imageResources=n.images,this.fontResources=n.fonts,this.referencedFontFamilies=qn(n);let r=Zn(this.fontResources,this.referencedFontFamilies);Kn(this.scheduleFontRenderRefresh(r)),this.mount(),this.sessionValue.subscribe("change",async o=>{var s,a;this.thumbnailRasterEpoch++,this.render(),await((a=(s=this.options).onChange)==null?void 0:a.call(s,{revision:o.revision,bytes:await this.sessionValue.toPptx()}));}),this.sessionValue.subscribe("selectionChange",()=>this.renderSelection()),this.render();}session(){return this.sessionValue}selection(){return this.sessionValue.selection()}isReadOnly(){return this.sessionValue.isReadOnly()}setReadOnly(e){if(this.isReadOnly()===e)return;let n=this.root.querySelector('[contenteditable="true"]');n==null||n.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:true,cancelable:true})),this.dragState&&(this.restoreDragElementBounds(this.dragState),this.clearDragVisualState(this.dragState.element,true),this.dragState=null,this.hideSnapGuides()),this.hideContextMenu(),this.sessionValue.setReadOnly(e),this.render();}async dispatch(e){let n=this.dispatchAndRender(e);this.pendingCommands.add(n);try{await n;}finally{this.pendingCommands.delete(n);}}async dispatchAndRender(e){var i,r;let n=(i=this.currentSlide())==null?void 0:i.id;if(await this.sessionValue.dispatch(e),e.kind==="select-slide"||e.kind==="select-shape"){if(((r=this.currentSlide())==null?void 0:r.id)!==n){this.render();return}this.renderSelection();return}this.render();}async loadPresentation(e){await this.sessionValue.loadPresentation(e),this.thumbnailCanvasCache.clear(),this.thumbnailRasterEpoch++,this.render();}async toPptx(){var e;return (e=this.root.querySelector('[contenteditable="true"]'))==null||e.dispatchEvent(new FocusEvent("blur")),await Promise.all([...this.pendingCommands]),this.sessionValue.toPptx()}canUndo(){return this.sessionValue.canUndo()}canRedo(){return this.sessionValue.canRedo()}async undo(){await this.sessionValue.undo(),this.render();}async redo(){await this.sessionValue.redo(),this.render();}async destroy(){for(this.canvas.removeEventListener("click",this.handleCanvasClick),this.canvas.removeEventListener("selectstart",this.handleCanvasSelectStart),this.slideList.removeEventListener("scroll",this.handleSlideListScroll),this.thumbnailFrame&&cancelAnimationFrame(this.thumbnailFrame),this.thumbnailRasterEpoch++,window.removeEventListener("mousemove",this.handleWindowMouseMove),window.removeEventListener("mouseup",this.handleWindowMouseUp),window.removeEventListener("keydown",this.handleWindowKeyDown),window.removeEventListener("pointerdown",this.handleWindowPointerDown),window.removeEventListener("scroll",this.handleWindowScroll,true),await this.sessionValue.destroy();this.root.firstChild;)this.root.removeChild(this.root.firstChild);}mount(){let e=document.createElement("style");e.textContent=`
|
|
3
|
-
${
|
|
1
|
+
'use strict';var ppt=require('@coco-vexel/coco-office/ppt');var nn=Object.defineProperty,rn=Object.defineProperties;var on=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var We=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var Te=(t,e,n)=>e in t?nn(t,e,{enumerable:true,configurable:true,writable:true,value:n}):t[e]=n,C=(t,e)=>{for(var n in e||(e={}))We.call(e,n)&&Te(t,n,e[n]);if(ce)for(var n of ce(e))je.call(e,n)&&Te(t,n,e[n]);return t},G=(t,e)=>rn(t,on(e));var Ue=(t,e)=>{var n={};for(var i in t)We.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&ce)for(var i of ce(t))e.indexOf(i)<0&&je.call(t,i)&&(n[i]=t[i]);return n};var M=(t,e,n)=>Te(t,typeof e!="symbol"?e+"":e,n);var Q=class extends Error{constructor(n){super(`${n} editor is read-only`);M(this,"code","EDITOR_READ_ONLY");this.name="EditorReadOnlyError";}};var an={width:9144e3,height:5143500},pe=new Set(["placeholder","textBox","geometricShape","line"]),Ze=new WeakMap;function ne(t){var n;let e=(n=t.slideSize)!=null?n:an;return {size:e,slides:t.slides.map(i=>ln(i,e))}}function ln(t,e){var l,d,c,u,p,f,m,b,h,x;let n=(d=(l=t.layout)==null?void 0:l.shapes)!=null?d:[],r=[...[...((p=(u=(c=t.layout)==null?void 0:c.master)==null?void 0:u.shapes)!=null?p:[]).map(S=>Ae(S,"master")),...n.map(S=>Ae(S,"layout"))].filter(cn),...t.shapes.map(S=>pn(S,t.layout))],o=r.flatMap(Ye),s=(x=(m=t.background)!=null?m:(f=t.layout)==null?void 0:f.background)!=null?x:(h=(b=t.layout)==null?void 0:b.master)==null?void 0:h.background,a=s!=null?s:dn(r,e);return G(C({id:t.id,index:t.index,name:t.name,title:t.title,size:e},s?{background:s}:{}),{nodes:o.map((S,g)=>ie(S,{slideSize:e,index:g,background:s,backgroundFill:a})),groups:r.flatMap(S=>Xe(S,{background:s,backgroundFill:a})),source:t})}function dn(t,e){var i;let n=t.find(r=>{var s;let o=te(r.geometry);return r.kind==="picture"&&!!((s=r.image)!=null&&s.targetPath)&&o.left<=e.width*.02&&o.top<=e.height*.02&&o.width>=e.width*.96&&o.height>=e.height*.96});return (i=n==null?void 0:n.image)!=null&&i.targetPath?{imagePath:n.image.targetPath}:void 0}function Ae(t,e){var n;return G(C({},t),{id:`${e}:${t.id}`,children:(n=t.children)==null?void 0:n.map(i=>Ae(i,e))})}function cn(t){return t.placeholder?false:t.kind==="group"||t.kind==="picture"||t.kind==="geometricShape"||t.kind==="line"||t.kind==="textBox"}function Ye(t){var e;return t.kind!=="group"?[t]:((e=t.children)!=null?e:[]).flatMap(n=>Ye(Je(t,n)))}function Xe(t,e={}){var n;return t.kind!=="group"?[]:[ie(t,{background:e.background,backgroundFill:e.backgroundFill}),...((n=t.children)!=null?n:[]).map(i=>Je(t,i)).flatMap(i=>Xe(i,e))]}function Je(t,e){var y,P,w,E,v;let n=te(t.geometry),i=(y=t.raw)==null?void 0:y.groupTransform,r=te(e.geometry),o=(P=i==null?void 0:i.childLeft)!=null?P:n.left,s=(w=i==null?void 0:i.childTop)!=null?w:n.top,a=(i==null?void 0:i.childWidth)||n.width||1,l=(i==null?void 0:i.childHeight)||n.height||1,d=n.width/a,c=n.height/l,u=(r.left-o)*d,p=(r.top-s)*c,f=r.width*d,m=r.height*c,b=n.flipHorizontal?n.left+n.width-u-f:n.left+u,h=n.flipVertical?n.top+n.height-p-m:n.top+p,x=un({left:b,top:h,width:f,height:m},n),S=Qe(((E=n.rotation)!=null?E:0)+((v=r.rotation)!=null?v:0)),g=G(C({},e),{id:`${t.id}:${e.id}`,geometry:G(C({},e.geometry),{left:x.left,top:x.top,width:f,height:m,rotation:S,flipHorizontal:!!n.flipHorizontal!=!!r.flipHorizontal,flipVertical:!!n.flipVertical!=!!r.flipVertical}),children:e.children});return Ze.set(g,{parentId:t.id,parentName:t.name,parentBounds:n,parentTransform:{childLeft:o,childTop:s,childWidth:a,childHeight:l}}),g}function un(t,e){if(!e.rotation)return t;let n=e.rotation*Math.PI/180,i=e.left+e.width/2,r=e.top+e.height/2,o=t.left+t.width/2,s=t.top+t.height/2,a=o-i,l=s-r,d=i+a*Math.cos(n)-l*Math.sin(n),c=r+a*Math.sin(n)+l*Math.cos(n);return G(C({},t),{left:d-t.width/2,top:c-t.height/2})}function Qe(t){let e=(t%360+360)%360;return e===0?void 0:e}function pn(t,e){if(!t.placeholder)return t;let n=ppt.resolvePptEffectivePlaceholderProperties(t,e);return C(G(C({},t),{placeholder:n.placeholder,geometry:n.geometry,style:n.style}),t.text?{text:G(C({},t.text),{style:n.textStyle,body:n.textBody})}:{})}function ie(t,e={}){var d,c,u,p,f,m,b,h,x,S,g,y,P,w,E,v,k;let n=et(t),i=n.editText||n.editTextStyle||n.editTableCells||n.editGeometry||n.editShapeStyle,r=t.style,o=((d=t.raw)==null?void 0:d.useBackgroundFill)===true,s=o?void 0:(u=(c=t.style)==null?void 0:c.fillColor)!=null?u:mn(t,e),a=gn((p=t.text)==null?void 0:p.style,{fillColor:s,background:e.background}),l=te(t.geometry);return G(C({id:t.id,name:t.name,kind:t.kind,bounds:fn(t,l),text:(m=(f=t.text)==null?void 0:f.text)!=null?m:hn(t),textStyle:a,textParagraphs:(b=t.text)==null?void 0:b.paragraphs,textBody:(h=t.text)==null?void 0:h.body,imagePath:(x=t.image)==null?void 0:x.targetPath,imageCrop:(S=t.image)==null?void 0:S.crop,imageFillRect:(g=t.image)==null?void 0:g.fillRect,imageOpacity:(y=t.image)==null?void 0:y.opacity,chart:t.chart,table:t.table,fillColor:s,fillGradient:o||r==null?void 0:r.fillGradient,opacity:r==null?void 0:r.opacity,lineColor:r==null?void 0:r.lineColor,lineGradient:r==null?void 0:r.lineGradient,lineOpacity:r==null?void 0:r.lineOpacity,lineWidth:r==null?void 0:r.lineWidth,lineCap:r==null?void 0:r.lineCap,lineDash:r==null?void 0:r.lineDash,lineHeadEnd:r==null?void 0:r.lineHeadEnd,lineTailEnd:r==null?void 0:r.lineTailEnd,shadow:r==null?void 0:r.shadow,presetGeometry:(P=t.raw)==null?void 0:P.presetGeometry,presetAdjustments:(w=t.raw)==null?void 0:w.presetAdjustments,customGeometry:(E=t.raw)==null?void 0:E.customGeometry,threeD:(v=t.raw)==null?void 0:v.threeD,usesBackgroundFill:o},o&&e.backgroundFill?{backgroundFill:e.backgroundFill}:{}),{locked:!i,editable:i,capabilities:n,groupContext:Pn(t),source:t,children:((k=t.children)!=null?k:[]).map(L=>ie(L,{background:e.background,backgroundFill:e.backgroundFill}))})}function hn(t){if(t.table)return t.table.values.map(e=>e.join(" ")).join(`
|
|
2
|
+
`)}function fn(t,e){if(!t.table)return e;let n=_e(t.table.columnWidths),i=_e(t.table.rowHeights);return n===void 0&&i===void 0?e:C(C(C({},e),Ke(e.width,n)?{width:n}:{}),Ke(e.height,i)?{height:i}:{})}function _e(t){if(!(t!=null&&t.length))return;let e=t.reduce((n,i)=>n+i,0);return Number.isFinite(e)&&e>0?e:void 0}function Ke(t,e){return e===void 0?false:!Number.isFinite(t)||t<=0?true:e/t>1.15}function mn(t,e){var r;let n=te(t.geometry),i=e.slideSize;if(e.index===0&&t.kind==="geometricShape"&&!((r=t.text)!=null&&r.text)&&i&&n.left<=0&&n.top<=0&&n.width>=i.width*.95&&n.height>=i.height*.95)return "#1D3F80"}function gn(t,e){var i,r;if(t!=null&&t.color)return t;let n=(r=e.fillColor)!=null?r:(i=e.background)==null?void 0:i.fillColor;return !n||!bn(n)?t:G(C({},t),{color:"#FFFFFF"})}function bn(t){let e=/^#?([0-9a-f]{6})$/i.exec(t);if(!e)return false;let n=e[1],i=Number.parseInt(n.slice(0,2),16),r=Number.parseInt(n.slice(2,4),16),o=Number.parseInt(n.slice(4,6),16);return (.2126*i+.7152*r+.0722*o)/255<.45}function Jr(t){let e=et(t);return e.editText||e.editTextStyle||e.editTableCells||e.editGeometry||e.editShapeStyle}function et(t){if(xn(t))return {select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:false,editShapeStyle:false,reason:"Inherited from layout/master",reasons:qe("\u7EE7\u627F\u81EA\u6BCD\u7248/\u7248\u5F0F\uFF0C\u5F53\u524D\u53EA\u652F\u6301\u67E5\u770B")};if(Sn(t)){let n=!!t.text&&pe.has(t.kind),i=t.kind==="table"&&!!t.table;return {select:true,editText:n,editTextStyle:n,editTableCells:i,editGeometry:true,editShapeStyle:false,reason:"Flattened group child",reasons:ee({editText:n?void 0:ue(t),editTextStyle:n?void 0:ue(t),editTableCells:i?void 0:"\u5F53\u524D\u5BF9\u8C61\u4E0D\u662F\u8868\u683C",editShapeStyle:"\u7EC4\u5185\u5B50\u5BF9\u8C61\u6682\u4E0D\u652F\u6301\u8BE5\u9879\u76F4\u63A5\u7F16\u8F91"})}}if(t.kind==="table")return {select:true,editText:false,editTextStyle:false,editTableCells:true,editGeometry:true,editShapeStyle:true,reasons:ee({editText:"\u8868\u683C\u6587\u5B57\u8BF7\u4F7F\u7528\u5355\u5143\u683C\u7F16\u8F91",editTextStyle:"\u8868\u683C\u6587\u5B57\u6837\u5F0F\u5F53\u524D\u4E0D\u5728\u9AD8\u9891\u5DE5\u5177\u680F\u5F00\u653E"})};if(t.kind==="picture")return {select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:true,editShapeStyle:true,reasons:ee({editText:"\u56FE\u7247\u5BF9\u8C61\u6CA1\u6709\u53EF\u7F16\u8F91\u6587\u5B57",editTextStyle:"\u56FE\u7247\u5BF9\u8C61\u6CA1\u6709\u53EF\u7F16\u8F91\u6587\u5B57\u6837\u5F0F",editTableCells:"\u5F53\u524D\u5BF9\u8C61\u4E0D\u662F\u8868\u683C"})};if(t.kind==="chart"||t.kind==="smartArt"||t.kind==="group"){let n=yn(t.kind);return {select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:true,editShapeStyle:false,reason:"Limited editor support for this object type",reasons:ee({editText:n.text,editTextStyle:n.textStyle,editTableCells:"\u5F53\u524D\u5BF9\u8C61\u4E0D\u662F\u8868\u683C",editShapeStyle:n.shapeStyle})}}let e=!!t.text&&pe.has(t.kind);return pe.has(t.kind)?{select:true,editText:e,editTextStyle:e,editTableCells:false,editGeometry:true,editShapeStyle:true,reasons:ee({editText:e?void 0:ue(t),editTextStyle:e?void 0:ue(t),editTableCells:"\u5F53\u524D\u5BF9\u8C61\u4E0D\u662F\u8868\u683C"})}:{select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:false,editShapeStyle:false,reason:"Unsupported object type",reasons:qe("\u5F53\u524D\u5BF9\u8C61\u7C7B\u578B\u6682\u4E0D\u652F\u6301\u5E38\u89C4\u7F16\u8F91")}}function ee(t){return Object.fromEntries(Object.entries(t).filter(e=>!!e[1]))}function qe(t){return {editText:t,editTextStyle:t,editTableCells:t,editGeometry:t,editShapeStyle:t}}function ue(t){return t.text?pe.has(t.kind)?"\u5F53\u524D\u5BF9\u8C61\u6587\u5B57\u6682\u4E0D\u652F\u6301\u7F16\u8F91":"\u5F53\u524D\u5BF9\u8C61\u7C7B\u578B\u6682\u4E0D\u652F\u6301\u6587\u5B57\u7F16\u8F91":"\u5F53\u524D\u5BF9\u8C61\u6CA1\u6709\u53EF\u7F16\u8F91\u6587\u5B57\u5185\u5BB9"}function yn(t){return t==="chart"?{text:"\u56FE\u8868\u6587\u5B57\u7ED1\u5B9A\u5728\u56FE\u8868\u6570\u636E\u4E2D\uFF0C\u5F53\u524D\u4EC5\u5F00\u653E\u6574\u4F53\u4F4D\u7F6E\u5C3A\u5BF8",textStyle:"\u56FE\u8868\u5185\u90E8\u6587\u5B57\u6837\u5F0F\u6682\u672A\u5F00\u653E",shapeStyle:"\u56FE\u8868\u5F62\u72B6\u6837\u5F0F\u6682\u672A\u5F00\u653E"}:t==="smartArt"?{text:"SmartArt \u5185\u90E8\u6587\u672C\u7ED3\u6784\u6682\u672A\u5F00\u653E",textStyle:"SmartArt \u5185\u90E8\u6587\u5B57\u6837\u5F0F\u6682\u672A\u5F00\u653E",shapeStyle:"SmartArt \u6837\u5F0F\u6682\u672A\u5F00\u653E"}:{text:"\u7EC4\u5408\u5BF9\u8C61\u8BF7\u53CC\u51FB\u6216\u70B9\u9009\u7EC4\u5185\u5B50\u5BF9\u8C61\u7F16\u8F91\u6587\u5B57",textStyle:"\u7EC4\u5408\u5BF9\u8C61\u8BF7\u9009\u4E2D\u7EC4\u5185\u6587\u672C\u5B50\u5BF9\u8C61\u7F16\u8F91\u6587\u5B57\u6837\u5F0F",shapeStyle:"\u7EC4\u5408\u5BF9\u8C61\u6682\u4E0D\u652F\u6301\u6574\u4F53\u5F62\u72B6\u6837\u5F0F\u7F16\u8F91"}}function xn(t){return t.id.startsWith("layout:")||t.id.startsWith("master:")}function Sn(t){return t.id.includes(":")}function tt(t,e){var f;if(!t.groupContext)return e;let n=t.groupContext.parentBounds,i=t.groupContext.parentTransform,r=C(C({},t.bounds),e),o=n.width/(i.childWidth||n.width||1),s=n.height/(i.childHeight||n.height||1),a=wn(r.left+r.width/2,r.top+r.height/2,n),l=a.x-r.width/2,d=a.y-r.height/2,c=n.flipHorizontal?n.left+n.width-l-r.width:l-n.left,u=n.flipVertical?n.top+n.height-d-r.height:d-n.top,p={};return e.left!==void 0&&(p.left=c/o+i.childLeft),e.top!==void 0&&(p.top=u/s+i.childTop),e.width!==void 0&&(p.width=r.width/o),e.height!==void 0&&(p.height=r.height/s),e.rotation!==void 0&&(p.rotation=Qe(e.rotation-((f=n.rotation)!=null?f:0))),e.flipHorizontal!==void 0&&(p.flipHorizontal=!!n.flipHorizontal!=!!e.flipHorizontal),e.flipVertical!==void 0&&(p.flipVertical=!!n.flipVertical!=!!e.flipVertical),p}function Pn(t){return Ze.get(t)}function wn(t,e,n){if(!n.rotation)return {x:t,y:e};let i=-n.rotation*Math.PI/180,r=n.left+n.width/2,o=n.top+n.height/2,s=t-r,a=e-o;return {x:r+s*Math.cos(i)-a*Math.sin(i),y:o+s*Math.sin(i)+a*Math.cos(i)}}function te(t={}){var e,n,i,r;return {left:(e=t.left)!=null?e:0,top:(n=t.top)!=null?n:0,width:(i=t.width)!=null?i:0,height:(r=t.height)!=null?r:0,rotation:t.rotation,flipHorizontal:t.flipHorizontal,flipVertical:t.flipVertical}}function z(t,e){var n,i;return typeof e=="number"?(n=t.slides.find(r=>r.index===e))!=null?n:null:(i=t.slides.find(r=>r.id===e||r.name===e))!=null?i:null}function re(t,e){let n=[...t.nodes,...t.groups];for(;n.length>0;){let i=n.shift();if(i.id===e||i.name===e)return i;n.unshift(...i.children);}return null}async function io(t,e={}){let n=await ppt.Presentation.fromZip(t,{presentationId:e.presentationId,mode:"inline"});return it(n,e)}async function ro(t,e={}){var i;let n=await ppt.Presentation.fromModel(t,{presentationId:(i=e.presentationId)!=null?i:t.id,mode:"inline"});return it(n,e)}async function it(t,e={}){let[n,i,r]=await Promise.all([t.toModel(),vn(t,e),En(t)]);return {presentation:t,model:n,scene:ne(n),images:i,fonts:r}}async function vn(t,e){if(typeof Blob=="undefined"||typeof URL=="undefined"||typeof URL.createObjectURL!="function")return {};let n=await t.exportImages(),i=await Promise.all(n.map(async r=>{var s;let o=await((s=e.resolveImagePreview)==null?void 0:s.call(e,{path:r.path,contentType:r.contentType,bytes:r.bytes}));return [r.path,o!=null?o:{url:URL.createObjectURL(new Blob([rt(r.bytes)],{type:r.contentType})),contentType:r.contentType}]}));return Object.fromEntries(i)}async function En(t){return typeof Blob=="undefined"||typeof URL=="undefined"||typeof URL.createObjectURL!="function"?[]:(await t.exportFonts()).map(n=>C(C({url:URL.createObjectURL(new Blob([rt(n.bytes)],{type:n.contentType})),contentType:n.contentType,family:n.family},n.weight?{weight:n.weight}:{}),n.style?{style:n.style}:{}))}function rt(t){let e=new Uint8Array(t.byteLength);return e.set(t),e.buffer}var he=class{constructor(e,n={}){M(this,"presentationValue");M(this,"modelValue");M(this,"sceneValue");M(this,"selectionValue",null);M(this,"revisionValue",0);M(this,"undoStack",[]);M(this,"redoStack",[]);M(this,"textBodyOverrides",new Map);M(this,"maxHistory");M(this,"readOnlyValue");M(this,"changeListeners",new Set);M(this,"selectionListeners",new Set);var i;this.presentationValue=e.presentation,this.modelValue=e.model,this.sceneValue=e.scene,this.maxHistory=(i=n.maxHistory)!=null?i:50,this.readOnlyValue=n.readOnly===true,this.selectionValue=e.scene.slides[0]?{kind:"slide",slideId:e.scene.slides[0].id}:null;}presentation(){return this.assertWritable(),this.presentationValue}model(){return this.modelValue}scene(){return this.sceneValue}selection(){return this.selectionValue}revision(){return this.revisionValue}isReadOnly(){return this.readOnlyValue}setReadOnly(e){this.readOnlyValue=e;}canUndo(){return !this.readOnlyValue&&this.undoStack.length>0}canRedo(){return !this.readOnlyValue&&this.redoStack.length>0}subscribe(e,n){let i=e==="change"?this.changeListeners:this.selectionListeners;return i.add(n),()=>i.delete(n)}async dispatch(e){if(e.kind==="select-slide"||e.kind==="select-shape"){await this.applySelectionCommand(e);return}this.assertWritable();let n=await this.presentationValue.toZip(),i=await this.applyEditCommand(e);this.pushUndo(n),this.redoStack.length=0,await this.refreshAfterChange(e),i!==void 0&&this.setSelection(i);}async undo(){this.assertWritable();let e=this.undoStack.pop();if(!e)return;let n=this.selectionValue;this.redoStack.push(this.historyEntry(await this.presentationValue.toZip())),this.restoreTextBodyOverrides(e.textBodyOverrides),await this.replacePresentation(e.bytes,n);}async redo(){this.assertWritable();let e=this.redoStack.pop();if(!e)return;let n=this.selectionValue;this.undoStack.push(this.historyEntry(await this.presentationValue.toZip())),this.restoreTextBodyOverrides(e.textBodyOverrides),await this.replacePresentation(e.bytes,n);}async loadPresentation(e){this.undoStack.length=0,this.redoStack.length=0,this.textBodyOverrides.clear(),await this.replacePresentation(e);}async toPptx(){return this.presentationValue.toZip()}async verifyExport(){let e=await this.toPptx(),n=await ppt.Presentation.fromZip(e,{mode:"inline"});try{return await n.toModel()}finally{await n.dispose();}}async destroy(){await this.presentationValue.dispose(),this.undoStack.length=0,this.redoStack.length=0,this.changeListeners.clear(),this.selectionListeners.clear();}assertWritable(){if(this.readOnlyValue)throw new Q("ppt")}async applySelectionCommand(e){let n=z(this.sceneValue,e.slideIdOrIndex);if(!n)throw new Error(`PPT slide not found: ${String(e.slideIdOrIndex)}`);if(e.kind==="select-slide"){this.setSelection({kind:"slide",slideId:n.id});return}let i=re(n,e.shapeIdOrName);if(!i)throw new Error(`PPT shape not found: ${e.shapeIdOrName}`);this.setSelection({kind:"shape",slideId:n.id,shapeId:i.id});}async applyEditCommand(e){var s,a;if(e.kind==="delete-shape"||e.kind==="duplicate-shape"||e.kind==="paste-shape"||e.kind==="bring-shape-to-front"||e.kind==="send-shape-to-back")return this.applyShapeCollectionCommand(e);let n=this.assertEditableSceneNodeForCommand(e),i=z(this.sceneValue,e.slideIdOrIndex);if(!i)throw new Error(`PPT slide not found: ${String(e.slideIdOrIndex)}`);let r=this.presentationValue.slides.getItem(e.slideIdOrIndex),o=Tn(r.shapes,e.shapeIdOrName);if(e.kind==="set-shape-text"){await o.text.setText(e.text,{preserveFirstRunStyle:true});return}if(e.kind==="set-shape-text-style"){await o.text.setTextStyle(e.style);return}if(e.kind==="set-table-cell-text"){await o.table.setCellText(e.row,e.column,e.text);return}if(e.kind==="set-shape-geometry"){if(e.preserveTextSizeOnResize&&Cn(n)){let l=G(C({},n.textBody),{autoFit:"none",wrap:(a=(s=n.textBody)==null?void 0:s.wrap)!=null?a:"square"});await o.text.setBodyProperties(l),this.textBodyOverrides.set(Mn(i.id,n.id),l);}await o.setGeometry(tt(n,e.geometry));return}await o.setStyle(e.style);}assertEditableSceneNodeForCommand(e){var r;let n=z(this.sceneValue,e.slideIdOrIndex);if(!n)throw new Error(`PPT slide not found: ${String(e.slideIdOrIndex)}`);let i=(r=re(n,e.shapeIdOrName))!=null?r:Nn(n,e.shapeIdOrName);if(!i)throw new Error(`PPT shape not found: ${e.shapeIdOrName}`);if(An(e)&&(i.locked||i.id.includes(":")||!i.editable))throw new Error(`PPT shape collection operation is not editable: ${i.id}`);if(e.kind==="set-shape-text"&&!i.capabilities.editText)throw new Error(`PPT shape is not text-editable: ${i.id}`);if(e.kind==="set-shape-text-style"&&!i.capabilities.editTextStyle)throw new Error(`PPT shape text style is not editable: ${i.id}`);if(e.kind==="set-table-cell-text"&&!i.capabilities.editTableCells)throw new Error(`PPT shape table cells are not editable: ${i.id}`);if(e.kind==="set-shape-geometry"&&!i.capabilities.editGeometry)throw new Error(`PPT shape geometry is not editable: ${i.id}`);if(e.kind==="set-shape-style"&&!i.capabilities.editShapeStyle)throw new Error(`PPT shape style is not editable: ${i.id}`);return i}async applyShapeCollectionCommand(e){var d,c,u,p,f,m,b,h;this.assertEditableSceneNodeForCommand(e);let n=z(this.sceneValue,e.slideIdOrIndex);if(!n)throw new Error(`PPT slide not found: ${String(e.slideIdOrIndex)}`);let i=re(n,e.shapeIdOrName);if(!i)throw new Error(`PPT shape not found: ${e.shapeIdOrName}`);let o=this.presentationValue.slides.getItem(e.slideIdOrIndex).shapes.getItem(e.shapeIdOrName);if(e.kind==="delete-shape")return await o.delete(),{kind:"slide",slideId:n.id};if(e.kind==="bring-shape-to-front")return await o.bringToFront(),{kind:"shape",slideId:n.id,shapeId:i.id};if(e.kind==="send-shape-to-back")return await o.sendToBack(),{kind:"shape",slideId:n.id,shapeId:i.id};let s={left:typeof i.bounds.left=="number"?i.bounds.left+((c=(d=e.offset)==null?void 0:d.left)!=null?c:18e4):i.bounds.left,top:typeof i.bounds.top=="number"?i.bounds.top+((p=(u=e.offset)==null?void 0:u.top)!=null?p:18e4):i.bounds.top,width:(m=(f=e.offset)==null?void 0:f.width)!=null?m:i.bounds.width,height:(h=(b=e.offset)==null?void 0:b.height)!=null?h:i.bounds.height},l=await(await o.duplicate({geometry:s})).toModel();return {kind:"shape",slideId:n.id,shapeId:l.id}}async refreshAfterChange(e){this.modelValue=await this.presentationValue.toModel(),this.sceneValue=ne(this.modelValue),this.applyTextBodyOverrides(),this.revisionValue+=1,this.changeListeners.forEach(n=>n({revision:this.revisionValue,command:e,model:this.modelValue,scene:this.sceneValue}));}async replacePresentation(e,n=null){let i=await ppt.Presentation.fromZip(e,{mode:"inline"});if(await this.presentationValue.dispose(),this.presentationValue=i,this.modelValue=await i.toModel(),this.sceneValue=ne(this.modelValue),this.applyTextBodyOverrides(),n){let o=this.sceneValue.slides.find(s=>s.id===n.slideId);if(n.kind==="slide"&&o){this.setSelection({kind:"slide",slideId:o.id});return}if(n.kind==="shape"&&(o!=null&&o.nodes.some(s=>s.id===n.shapeId))){this.setSelection({kind:"shape",slideId:o.id,shapeId:n.shapeId});return}}let r=this.sceneValue.slides[0];this.setSelection(r?{kind:"slide",slideId:r.id}:null);}setSelection(e){this.selectionValue=e,this.selectionListeners.forEach(n=>n({selection:e}));}pushUndo(e){this.undoStack.push(this.historyEntry(e)),this.undoStack.length>this.maxHistory&&this.undoStack.shift();}historyEntry(e){return {bytes:e,textBodyOverrides:new Map(this.textBodyOverrides)}}restoreTextBodyOverrides(e){this.textBodyOverrides.clear(),e.forEach((n,i)=>this.textBodyOverrides.set(i,C({},n)));}applyTextBodyOverrides(){var e;for(let[n,i]of this.textBodyOverrides){let[r,o]=n.split("\0");if(!r||!o)continue;let s=z(this.sceneValue,r),a=s?re(s,o):null;!a||!a.text&&!((e=a.textParagraphs)!=null&&e.length)||(a.textBody=C(C({},a.textBody),i));}}};function Mn(t,e){return `${t}\0${e}`}function Cn(t){var e;return !!(t.capabilities.editGeometry&&kn(t)&&(t.text||(e=t.textParagraphs)!=null&&e.length))}function kn(t){return t.kind==="placeholder"||t.kind==="textBox"||t.kind==="geometricShape"}function Nn(t,e){let n=t.source.shapes.find(i=>i.id===e||i.name===e);return n?ie(n,{slideSize:t.size,background:t.background}):null}function Tn(t,e){let n=e.split(":").filter(Boolean);if(n.length<=1)return t.getItem(e);let i=t.getItem(n[0]);for(let r of n.slice(1))i=i.group.getItem(r);return i}function An(t){return t.kind==="delete-shape"||t.kind==="duplicate-shape"||t.kind==="paste-shape"||t.kind==="bring-shape-to-front"||t.kind==="send-shape-to-back"}var st=[{matches:/(?:楷体|kaiti|stkaiti)/i,families:["Kaiti SC","STKaiti","KaiTi","KaiTi_GB2312","DFKai-SB"],generic:"serif"},{matches:/(?:仿宋|fangsong|stfangsong)/i,families:["STFangsong","FangSong","FangSong_GB2312","Noto Serif CJK SC"],generic:"serif"},{matches:/(?:黑体|heiti|simhei|微软雅黑|microsoft yahei|pingfang)/i,families:["STHeiti","Heiti SC","PingFang SC","Microsoft YaHei","Noto Sans CJK SC"],generic:"sans-serif"},{matches:/(?:宋体|simsun|songti|stsong)/i,families:["SimSun","Songti SC","STSong","Noto Serif CJK SC"],generic:"serif"}],In=st[3];function at(t,e=In){var s;let n=t.split(",").map(a=>a.trim()).filter(Boolean),i=n.join(" "),r=(s=st.find(a=>a.matches.test(i)))!=null?s:e;return [...[...new Set([...n,...r.families])].map(a=>`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/[\r\n\f]/g," ")}"`),...r.generic?[r.generic]:[]].join(", ")}async function lt(t,e="\u6C49\u5B57Aa0"){var n;typeof document=="undefined"||!((n=document.fonts)!=null&&n.load)||await Promise.all([...new Set(t)].map(i=>document.fonts.load(i,e).catch(()=>[])));}var dt=24e4,se=91440,Gn=91440,Ie=4,ct=7,D=128,Ln=8,fe=2,$n=2,me=4;function yo(t,e,n={}){return new $e(t,e,n)}function Rn(t){if(t.kind==="line"||t.kind!=="geometricShape"||t.customGeometry||t.presetGeometry&&t.presetGeometry!=="ellipse"||t.text||!t.fillColor)return false;let e=Math.min(t.bounds.width,t.bounds.height),n=Math.max(t.bounds.width,t.bounds.height);return e<=0?false:n/e<1.2}function O(t,e,n){var d,c,u,p;let i=Math.max(se,(d=n.width)!=null?d:t.width),r=Math.max(se,(c=n.height)!=null?c:t.height),o=Math.min(dt,i),s=Math.min(dt,r),a=ve((u=n.left)!=null?u:t.left,-i+o,e.width-o),l=ve((p=n.top)!=null?p:t.top,-r+s,e.height-s);return G(C({},t),{left:a,top:l,width:i,height:r})}function ve(t,e,n){return Math.max(e,Math.min(n,t))}function ge(t,e,n){let i=n==="x"?t.size.width:t.size.height,r=[{value:0,kind:"slide",role:"start"},{value:i/2,kind:"slide",role:"center"},{value:i,kind:"slide",role:"end"}];for(let o of t.nodes){if(!Bn(o,e))continue;let s=n==="x"?o.bounds.left:o.bounds.top,a=n==="x"?o.bounds.width:o.bounds.height;r.push({value:s,kind:"shape",role:"start",referenceShapeId:o.id},{value:s+a/2,kind:"shape",role:"center",referenceShapeId:o.id},{value:s+a,kind:"shape",role:"end",referenceShapeId:o.id});}return r}function Bn(t,e){return t.id!==e&&t.kind!=="line"&&!t.locked&&!t.id.includes(":")&&t.capabilities.select&&t.capabilities.editGeometry&&t.bounds.width>se&&t.bounds.height>se}function be(t,e,n,i={}){let r=null;for(let o of t)for(let s of e){if(i.matchRole!==false&&o.role!==s.role)continue;let a=Math.abs(o.value-s.value);a>n||(!r||a<r.distance)&&(r={source:o,target:s,distance:a});}return r}function ut(t,e,n,i){let r=e/2,o=Math.abs(n.offset-r)<1?(i-t)*2:i-t;return Math.max(se,o)}function V(t){return !t.locked&&!t.id.includes(":")&&(t.capabilities.editGeometry||t.capabilities.editText||t.capabilities.editShapeStyle||t.capabilities.editTableCells)}function On(t){let e=t.groupContext;return e?G(C({},t),{id:e.parentId,name:e.parentName,kind:"group",bounds:e.parentBounds,text:void 0,textStyle:void 0,textParagraphs:void 0,textBody:void 0,groupContext:void 0,locked:false,editable:true,capabilities:{select:true,editText:false,editTextStyle:false,editTableCells:false,editGeometry:true,editShapeStyle:false,reason:"Parent group"},children:[]}):t}function Fn(t){var o,s;if(t.kind!=="picture"||!t.customGeometry||t.customGeometry.paths.length!==1)return false;let e=Math.min(t.bounds.width,t.bounds.height),n=Math.max(t.bounds.width,t.bounds.height);if(e<=0||n/e>1.12)return false;let i=(s=(o=t.customGeometry.paths[0])==null?void 0:o.commands)!=null?s:[];return i.filter(a=>a.kind==="cubicBezierTo").length>=4&&i.some(a=>a.kind==="close")}var $e=class{constructor(e,n,i){M(this,"root");M(this,"sessionValue");M(this,"imageResources");M(this,"fontResources");M(this,"referencedFontFamilies");M(this,"slideList",document.createElement("div"));M(this,"canvas",document.createElement("div"));M(this,"contextMenu",document.createElement("div"));M(this,"snapGuides",document.createElement("div"));M(this,"options");M(this,"handleCanvasClick",()=>{this.dispatchCurrentSlideSelection();});M(this,"handleWindowMouseMove",e=>{this.updateDrag(e);});M(this,"handleWindowMouseUp",e=>{this.finishDrag(e);});M(this,"handleWindowKeyDown",e=>{this.handleKeyDown(e);});M(this,"handleWindowPointerDown",e=>{this.dismissContextMenu(e);});M(this,"handleWindowScroll",()=>this.hideContextMenu());M(this,"handleCanvasSelectStart",e=>this.handleSelectStart(e));M(this,"handleSlideListScroll",()=>this.scheduleThumbnailRender());M(this,"dragState",null);M(this,"suppressClickAfterDrag",false);M(this,"clipboardShape",null);M(this,"thumbnailFrame",0);M(this,"thumbnailRasterEpoch",0);M(this,"thumbnailCanvasCache",new Map);M(this,"pendingCommands",new Set);this.options=i,this.root=i.styleIsolation==="none"?e:e.attachShadow({mode:"open"}),this.sessionValue=new he(n,{readOnly:i.readOnly}),this.imageResources=n.images,this.fontResources=n.fonts,this.referencedFontFamilies=Xn(n);let r=Yn(this.fontResources,this.referencedFontFamilies);Jn(this.scheduleFontRenderRefresh(r)),this.mount(),this.sessionValue.subscribe("change",async o=>{var s,a;this.thumbnailRasterEpoch++,this.render(),await((a=(s=this.options).onChange)==null?void 0:a.call(s,{revision:o.revision,bytes:await this.sessionValue.toPptx()}));}),this.sessionValue.subscribe("selectionChange",()=>this.renderSelection()),this.render();}session(){return this.sessionValue}selection(){return this.sessionValue.selection()}isReadOnly(){return this.sessionValue.isReadOnly()}setReadOnly(e){if(this.isReadOnly()===e)return;let n=this.root.querySelector('[contenteditable="true"]');n==null||n.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:true,cancelable:true})),this.dragState&&(this.restoreDragElementBounds(this.dragState),this.clearDragVisualState(this.dragState.element,true),this.dragState=null,this.hideSnapGuides()),this.hideContextMenu(),this.sessionValue.setReadOnly(e),this.render();}async dispatch(e){let n=this.dispatchAndRender(e);this.pendingCommands.add(n);try{await n;}finally{this.pendingCommands.delete(n);}}async dispatchAndRender(e){var i,r;let n=(i=this.currentSlide())==null?void 0:i.id;if(await this.sessionValue.dispatch(e),e.kind==="select-slide"||e.kind==="select-shape"){if(((r=this.currentSlide())==null?void 0:r.id)!==n){this.render();return}this.renderSelection();return}this.render();}async loadPresentation(e){await this.sessionValue.loadPresentation(e),this.thumbnailCanvasCache.clear(),this.thumbnailRasterEpoch++,this.render();}async toPptx(){var e;return (e=this.root.querySelector('[contenteditable="true"]'))==null||e.dispatchEvent(new FocusEvent("blur")),await Promise.all([...this.pendingCommands]),this.sessionValue.toPptx()}canUndo(){return this.sessionValue.canUndo()}canRedo(){return this.sessionValue.canRedo()}async undo(){await this.sessionValue.undo(),this.render();}async redo(){await this.sessionValue.redo(),this.render();}async destroy(){for(this.canvas.removeEventListener("click",this.handleCanvasClick),this.canvas.removeEventListener("selectstart",this.handleCanvasSelectStart),this.slideList.removeEventListener("scroll",this.handleSlideListScroll),this.thumbnailFrame&&cancelAnimationFrame(this.thumbnailFrame),this.thumbnailRasterEpoch++,window.removeEventListener("mousemove",this.handleWindowMouseMove),window.removeEventListener("mouseup",this.handleWindowMouseUp),window.removeEventListener("keydown",this.handleWindowKeyDown),window.removeEventListener("pointerdown",this.handleWindowPointerDown),window.removeEventListener("scroll",this.handleWindowScroll,true),await this.sessionValue.destroy();this.root.firstChild;)this.root.removeChild(this.root.firstChild);}mount(){let e=document.createElement("style");e.textContent=`
|
|
3
|
+
${qn(this.fontResources)}
|
|
4
4
|
:host, .coco-ppt-editor { box-sizing: border-box; width: 100%; height: 100%; min-height: 360px; }
|
|
5
5
|
.coco-ppt-editor { display: grid; grid-template-columns: 160px minmax(0, 1fr); background: #f4f6f8; color: #17202a; font: 13px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
6
6
|
.coco-ppt-editor[data-show-slide-list="false"] { grid-template-columns: minmax(0, 1fr); }
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
.coco-ppt-context-menu button:disabled { color: #94a3b8; cursor: default; }
|
|
73
73
|
.coco-ppt-context-menu span { color: #64748b; font-size: 11px; }
|
|
74
74
|
.coco-ppt-context-menu hr { border: 0; border-top: 1px solid #e2e8f0; margin: 4px 0; }
|
|
75
|
-
`;let n=document.createElement("div");n.className="coco-ppt-editor",n.dataset.showSlideList=String(this.options.showSlideList!==false),n.dataset.readOnly=String(this.isReadOnly()),this.slideList.className="coco-ppt-slides";let i=document.createElement("div");i.className="coco-ppt-stage",this.canvas.className="coco-ppt-canvas",this.contextMenu.className="coco-ppt-context-menu",this.snapGuides.className="coco-ppt-snap-guides",i.append(this.canvas),n.append(this.slideList,i),this.root.append(e,n,this.contextMenu),this.canvas.addEventListener("click",this.handleCanvasClick),this.canvas.addEventListener("selectstart",this.handleCanvasSelectStart),this.slideList.addEventListener("scroll",this.handleSlideListScroll,{passive:true}),window.addEventListener("mousemove",this.handleWindowMouseMove),window.addEventListener("mouseup",this.handleWindowMouseUp),window.addEventListener("keydown",this.handleWindowKeyDown),window.addEventListener("pointerdown",this.handleWindowPointerDown),window.addEventListener("scroll",this.handleWindowScroll,true);}scheduleFontRenderRefresh(e){return typeof document=="undefined"||!document.fonts?Promise.resolve():e.then(()=>Promise.all([...new Set(this.fontResources.map(n=>n.family))].map(n=>document.fonts.load(`16px ${Re(n)}`)))).then(()=>Promise.all(this.referencedFontFamilies.map(n=>document.fonts.load(`16px ${Re(n)}`)))).then(()=>document.fonts.ready).then(()=>{this.render();}).catch(()=>{})}render(){let e=this.root.querySelector(".coco-ppt-editor");e&&(e.dataset.readOnly=String(this.isReadOnly()));let n=this.sessionValue.scene();this.slideList.replaceChildren(...this.options.showSlideList===false?[]:n.slides.map(o=>{var c;let s=document.createElement("button");s.className="coco-ppt-thumb",s.type="button",s.dataset.slideId=o.id,s.dataset.slideIndex=String(o.index),s.dataset.selected=((c=this.sessionValue.selection())==null?void 0:c.slideId)===o.id?"true":"false";let a=document.createElement("div");a.className="coco-ppt-thumb-preview";let l=document.createElement("div");l.className="coco-ppt-thumb-placeholder";let d=document.createElement("span");return d.className="coco-ppt-thumb-number",d.textContent=String(o.index+1),s.append(a,l,d),s.addEventListener("click",()=>{this.dispatch({kind:"select-slide",slideIdOrIndex:o.id});}),s})),this.options.showSlideList!==false&&this.renderVisibleThumbnails(n.slides);let i=this.currentSlide();if(!i){this.canvas.replaceChildren(),this.hideContextMenu();return}let r=this.computeScale(i);this.canvas.style.width=`${i.size.width*r}px`,this.canvas.style.height=`${i.size.height*r}px`,this.canvas.style.background=Be(i.background,this.imageResources),this.canvas.replaceChildren(...i.nodes.map(o=>this.renderNode(o,r,i)),this.snapGuides),this.hideSnapGuides(),this.hideContextMenu(),this.renderSelection();}renderVisibleThumbnails(e){let n=Array.from(this.slideList.querySelectorAll(".coco-ppt-thumb")),i=this.visibleThumbnailRange(e.length);n.forEach((r,o)=>{let s=r.querySelector(".coco-ppt-thumb-preview"),a=r.querySelector(".coco-ppt-thumb-placeholder");if(!s||!a)return;if(o<i.start||o>=i.end){s.replaceChildren(),delete r.dataset.previewRendered,delete r.dataset.previewMode,a.hidden=false;return}if(r.dataset.previewRendered==="true")return;let l=e[o];if(!l)return;let d=Ge(l),c=this.thumbnailCanvasCache.get(l.id);(c==null?void 0:c.fingerprint)===d?(s.replaceChildren(ut(c.canvas)),r.dataset.previewMode="canvas"):(s.replaceChildren(this.renderThumbnailSlide(l)),r.dataset.previewMode="dom",this.rasterizeThumbnail(r,l)),r.dataset.previewRendered="true",a.hidden=true;});}visibleThumbnailRange(e){let n=D*.5625+An,i=this.slideList.clientHeight||n*Math.min(e,5),r=Math.max(0,Math.floor(this.slideList.scrollTop/n)-fe),o=Math.ceil(i/n)+fe*2,s=this.sessionValue.selection(),a=(s==null?void 0:s.slideId)!==void 0?this.sessionValue.scene().slides.findIndex(c=>c.id===s.slideId):-1,l=a>=0?Math.min(r,Math.max(0,a-fe)):r,d=a>=0?Math.max(r+o,Math.min(e,a+fe+1)):r+o;return {start:l,end:Math.min(e,d)}}renderThumbnailSlide(e){let n=document.createElement("div");n.className="coco-ppt-thumb-slide";let r=D*me/e.size.width;return n.style.width=`${e.size.width*r}px`,n.style.height=`${e.size.height*r}px`,n.style.transform=`scale(${1/me})`,n.style.background=Be(e.background,this.imageResources),n.replaceChildren(...e.nodes.map(o=>this.renderNode(o,r,e,false))),n}async rasterizeThumbnail(e,n){var d,c;let i=this.thumbnailRasterEpoch,r=Ge(n);if(await ct(),await ct(),i!==this.thumbnailRasterEpoch||!e.isConnected)return;let o=e.querySelector(".coco-ppt-thumb-preview"),s=o==null?void 0:o.querySelector(".coco-ppt-thumb-slide");if(!o||!s)return;let a=await Fn(s,D,D*(n.size.height/n.size.width),In,(c=(d=this.root.querySelector("style"))==null?void 0:d.textContent)!=null?c:"",D*me,D*me*(n.size.height/n.size.width));if(!a||i!==this.thumbnailRasterEpoch||!e.isConnected)return;let l=this.sessionValue.scene().slides.find(u=>u.id===n.id);!l||Ge(l)!==r||(this.thumbnailCanvasCache.set(n.id,{fingerprint:r,canvas:a}),o.replaceChildren(ut(a)),e.dataset.previewMode="canvas");}scheduleThumbnailRender(){this.thumbnailFrame||(this.thumbnailFrame=requestAnimationFrame(()=>{this.thumbnailFrame=0,this.renderVisibleThumbnails(this.sessionValue.scene().slides);}));}renderNode(e,n,i,r=true){var h,x,S;let o=document.createElement("div"),s=Ft(e),a=e.presetGeometry==="frame",l=s?Ht(e):"horizontal",d=Math.max(s&&l==="vertical"?12:1,e.bounds.width*n),c=Math.max(s&&l==="horizontal"?12:1,e.bounds.height*n);o.className=r?"coco-ppt-node":"coco-ppt-thumb-node",o.dataset.kind=e.kind,o.dataset.locked=String(e.locked),r&&(o.dataset.draggable=String(!this.isReadOnly()&&e.capabilities.editGeometry),o.dataset.resizable=String(!this.isReadOnly()&&e.capabilities.editGeometry),o.dataset.shapeId=e.id),o.style.left=`${e.bounds.left*n-(s&&l==="vertical"?d/2:0)}px`,o.style.top=`${e.bounds.top*n-(s&&l==="horizontal"?c/2:0)}px`,o.style.width=`${d}px`,o.style.height=`${c}px`;let u=[];e.bounds.rotation&&u.push(`rotate(${e.bounds.rotation}deg)`),e.bounds.flipHorizontal&&u.push("scaleX(-1)"),e.bounds.flipVertical&&u.push("scaleY(-1)"),u.length>0&&(o.style.transform=u.join(" "));let p=Wt(e),f=Di(e.presetGeometry),m=!!(f&&e.text&&!e.customGeometry&&!p);if(e.usesBackgroundFill&&e.backgroundFill?Ri(o,e.backgroundFill,e,i,n,this.imageResources):e.customGeometry||p||m||e.kind==="table"||s||a?o.style.background="transparent":e.fillGradient&&e.fillGradient.colors.length>1?o.style.background=Y(e.fillGradient,K(e)):e.fillColor&&(o.style.background=q(e.fillColor,K(e))),wi(e)&&(o.style.overflow="visible"),(e.presetGeometry==="roundRect"||e.presetGeometry==="round1Rect")&&(o.style.borderRadius=`${_(e)*n}px`),e.presetGeometry==="round2DiagRect"){let g=`${_(e)*n}px`;o.style.borderRadius=`${g} 0 ${g} 0`;}if(e.presetGeometry==="round2SameRect"){let g=`${_(e)*n}px`;o.style.borderRadius=`${g} ${g} 0 0`;}if((e.presetGeometry==="ellipse"||Gn(e)||Rn(e))&&(o.style.borderRadius="9999px"),f&&!m&&!p&&(o.style.clipPath=f),a?(o.style.borderStyle="solid",o.style.borderWidth=`${Bi(e,n)}px`,e.fillGradient&&e.fillGradient.colors.length>1?(o.style.borderImageSource=Y(e.fillGradient),o.style.borderImageSlice="1"):e.fillColor&&(o.style.borderColor=e.fillColor)):!e.customGeometry&&!p&&!m&&!s&&e.kind!=="picture"&&e.lineColor&&(o.style.borderStyle=He(e.lineDash),o.style.borderWidth=`${Math.max(1,((h=e.lineWidth)!=null?h:9525)*n)}px`,o.style.borderColor=q(e.lineColor,e.lineOpacity)),e.shadow&&(o.style.boxShadow=_t(e.shadow,n)),this.applyTextStyle(o,e,n),hi(o,e,n),m&&f&&o.append(Vi(e,n,f)),e.customGeometry&&e.kind!=="picture"&&o.append(nr(e)),p&&o.append(Wi(e,n)),s)o.append(ar(e,n));else if(e.kind==="chart")o.append(br(e));else if(e.kind==="table"){let g=ur(e,n,r);r&&(g.addEventListener("click",y=>{y.stopPropagation(),!this.consumeSuppressedClick()&&(this.notifyTableCellSelection(i,e,y),this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:e.id}));}),g.addEventListener("dblclick",y=>{if(this.isReadOnly())return;let P=ht(y);if(!P||!e.capabilities.editTableCells)return;y.stopPropagation();let w=Number(P.dataset.row),E=Number(P.dataset.column);!Number.isInteger(w)||!Number.isInteger(E)||this.startTableCellEdit(P,i,e,w,E);})),o.append(g);}else if(e.kind==="picture"){let g=e.imagePath?this.imageResources[e.imagePath]:void 0,y=g==null?void 0:g.url;if(y&&Ve(g.contentType,e.imagePath)){if(Xi(e,i))o.append(er(e,y));else {let P=document.createElement("img");P.src=y,P.alt=(x=e.name)!=null?x:"",si(P,e),e.imageOpacity!==void 0&&(P.style.opacity=String(Math.max(0,Math.min(1,e.imageOpacity)))),o.append(P);}e.lineColor&&o.append(sr(e,n));}else o.dataset.unsupportedImage=e.imagePath?"true":"missing",g!=null&&g.contentType&&(o.dataset.imageContentType=g.contentType),e.imagePath&&(o.dataset.imagePath=e.imagePath),o.append(di(e,g==null?void 0:g.contentType));}else {let g=(S=e.text)!=null?S:"";if(e.customGeometry||p||m||ui(e)){let y=document.createElement("div");y.className="coco-ppt-text-layer",pi(y,e),yt(y,e,n,g),o.append(y),xt(y,e),St(y,e);}else yt(o,e,n,g),xt(o,e),St(o,e);}if(Oi(e)&&o.append(or(e,n)),!r)return o;let b=document.createElement("div");return b.className="coco-ppt-resize-handle",b.addEventListener("mousedown",g=>{this.isReadOnly()||!e.capabilities.editGeometry||(g.preventDefault(),g.stopPropagation(),this.startDrag(g,"resize",i,e,n,o));}),o.append(b),o.addEventListener("click",g=>{var P,w;if(this.hideContextMenu(),g.stopPropagation(),this.consumeSuppressedClick())return;if(g.altKey){let E=this.selection(),v=ei(i,g,n,(E==null?void 0:E.kind)==="shape"?E.shapeId:e.id);if(v){this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:v.node.id}),(w=(P=this.options).onObjectAction)==null||w.call(P,{action:"cycle-selection",slideId:i.id,shapeId:v.node.id,kind:v.node.kind,name:v.node.name,reason:`\u5DF2\u5207\u6362\u5230\u91CD\u53E0\u5BF9\u8C61 ${v.index+1}/${v.count}`,candidateIndex:v.index,candidateCount:v.count});return}}let y=this.pointerOperationNode(i,e,g,n);if(y){this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:y.id});return}this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:e.id});}),o.addEventListener("contextmenu",g=>{var P;if(this.isReadOnly())return;g.preventDefault(),g.stopPropagation();let y=(P=this.pointerOperationNode(i,e,g,n))!=null?P:e;this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:y.id}).then(()=>this.showContextMenu(g,i,y));}),o.addEventListener("mousedown",g=>{var w,E;let y=(w=this.pointerOperationNode(i,e,g,n))!=null?w:e,P=(E=Le(this.canvas,y.id))!=null?E:o;Qn(P,g.target)||this.isReadOnly()||g.button!==0||!y.capabilities.editGeometry||(g.preventDefault(),g.stopPropagation(),this.startDrag(g,"move",i,y,n,P));}),o.addEventListener("dblclick",g=>{var P,w,E;if(this.isReadOnly())return;g.stopPropagation();let y=gt(i,e,g,n);if(y){this.startTextEdit((P=Le(this.canvas,y.id))!=null?P:o,i,y);return}if(!e.capabilities.editText){this.sessionValue.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:e.id}).then(()=>this.renderSelection()),(E=(w=this.options).onObjectAction)==null||E.call(w,{action:"blocked-text-edit",slideId:i.id,shapeId:e.id,kind:e.kind,name:e.name,reason:ii(e)});return}this.startTextEdit(o,i,e);}),o}pointerOperationNode(e,n,i,r){let o=this.selection();return (o==null?void 0:o.kind)==="shape"&&o.slideId===e.id&&o.shapeId===n.id?n:gt(e,n,i,r)}notifyTableCellSelection(e,n,i){var a,l;let r=ht(i);if(!r||!n.capabilities.editTableCells)return;let o=Number(r.dataset.row),s=Number(r.dataset.column);!Number.isInteger(o)||!Number.isInteger(s)||(l=(a=this.options).onTableCellSelectionChange)==null||l.call(a,{slideId:e.id,shapeId:n.id,row:o,column:s,text:Ct(r,n,o,s)});}applyTextStyle(e,n,i){var s,a,l,d;let r=n.textStyle;r&&(Oe(e,Jn(n,r),i),r.alignment&&(Fe(e,r.alignment),r.alignment==="center"&&(e.style.justifyContent="center"),r.alignment==="right"&&(e.style.justifyContent="flex-end")));let o=n.kind==="table"?void 0:n.textBody;if(o){let c=(s=o.insetLeft)!=null?s:91440,u=(a=o.insetTop)!=null?a:45720,p=(l=o.insetRight)!=null?l:91440,f=(d=o.insetBottom)!=null?d:45720,m=fi(n,i);e.style.padding=`${u*i+m}px ${p*i}px ${f*i}px ${c*i}px`,Rt(o)&&(e.style.writingMode="vertical-rl",e.style.textOrientation="upright"),o.anchor==="middle"&&(e.style.alignItems="center"),o.anchor==="bottom"&&(e.style.alignItems="flex-end"),o.anchor==="top"&&(e.style.alignItems="flex-start");}}startTextEdit(e,n,i){var p,f,m,b;if(this.isReadOnly())return;let r=(p=i.text)!=null?p:"",o=Yn(e),s=false;this.sessionValue.dispatch({kind:"select-shape",slideIdOrIndex:n.id,shapeIdOrName:i.id}).then(()=>this.renderSelection()),(m=(f=this.options).onTextEditStateChange)==null||m.call(f,{state:"start",slideId:n.id,shapeId:i.id,text:r}),o.contentEditable="true",o.spellcheck=false,o.setAttribute("role","textbox"),o.setAttribute("aria-label",(b=i.name)!=null?b:"PPT text"),e.dataset.editing="true",this.canvas.dataset.interactionMode="editing",o.textContent=r,o.focus();let a=o.ownerDocument.getSelection();if(a){let h=o.ownerDocument.createRange();h.selectNodeContents(o),h.collapse(false),a.removeAllRanges(),a.addRange(h);}let l=h=>{var S,g,y,P,w;if(s)return;s=true,o.contentEditable="false",o.removeAttribute("role"),o.removeAttribute("aria-label"),delete e.dataset.editing,delete this.canvas.dataset.interactionMode,o.removeEventListener("blur",u),o.removeEventListener("keydown",d),o.removeEventListener("paste",c);let x=(S=o.textContent)!=null?S:"";if(!h){o.textContent=r,(y=(g=this.options).onTextEditStateChange)==null||y.call(g,{state:"cancel",slideId:n.id,shapeId:i.id,text:r}),this.render();return}(w=(P=this.options).onTextEditStateChange)==null||w.call(P,{state:"commit",slideId:n.id,shapeId:i.id,text:x}),x!==r?this.dispatch({kind:"set-shape-text",slideIdOrIndex:n.id,shapeIdOrName:i.id,text:x}):this.render();},d=h=>{if(h.key==="Escape"){h.preventDefault(),l(false);return}h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),l(true));},c=h=>{var S;let x=(S=h.clipboardData)==null?void 0:S.getData("text/plain");x!==void 0&&(h.preventDefault(),bt(o,x));},u=()=>l(true);o.addEventListener("blur",u),o.addEventListener("keydown",d),o.addEventListener("paste",c);}startTableCellEdit(e,n,i,r,o){var f,m,b;if(this.isReadOnly())return;let s=Ct(e,i,r,o),a=false;this.sessionValue.dispatch({kind:"select-shape",slideIdOrIndex:n.id,shapeIdOrName:i.id}).then(()=>this.renderSelection()),(m=(f=this.options).onTableCellSelectionChange)==null||m.call(f,{slideId:n.id,shapeId:i.id,row:r,column:o,text:s}),e.contentEditable="true",e.spellcheck=false,this.canvas.dataset.interactionMode="editing",e.setAttribute("role","textbox"),e.setAttribute("aria-label",`${(b=i.name)!=null?b:"PPT table"} cell ${r+1},${o+1}`),e.textContent=s,e.focus();let l=e.ownerDocument.getSelection();if(l){let h=e.ownerDocument.createRange();h.selectNodeContents(e),h.collapse(false),l.removeAllRanges(),l.addRange(h);}let d=h=>{var S;if(a)return;a=true,e.contentEditable="false",delete this.canvas.dataset.interactionMode,e.removeAttribute("role"),e.removeAttribute("aria-label"),e.removeEventListener("blur",p),e.removeEventListener("keydown",c),e.removeEventListener("paste",u);let x=(S=e.textContent)!=null?S:"";if(!h){e.textContent=s,e.dataset.cellText=s;return}x!==s?(e.dataset.cellText=x,this.dispatch({kind:"set-table-cell-text",slideIdOrIndex:n.id,shapeIdOrName:i.id,row:r,column:o,text:x})):this.render();},c=h=>{if(h.key==="Escape"){h.preventDefault(),d(false);return}h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),d(true));},u=h=>{var S;let x=(S=h.clipboardData)==null?void 0:S.getData("text/plain");x!==void 0&&(h.preventDefault(),bt(e,x));},p=()=>d(true);e.addEventListener("blur",p),e.addEventListener("keydown",c),e.addEventListener("paste",u);}startDrag(e,n,i,r,o,s){this.isReadOnly()||(n==="resize"&&Bn(s,r),this.dragState={mode:n,slideId:i.id,shapeId:r.id,slideSize:i.size,startClientX:e.clientX,startClientY:e.clientY,startBounds:C({},r.bounds),scale:o,element:s,active:false},this.sessionValue.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:r.id}).then(()=>this.renderSelection()));}updateDrag(e){let n=this.dragState;if(!n)return;if(Math.hypot(e.clientX-n.startClientX,e.clientY-n.startClientY)<=Ie){this.restoreDragElementBounds(n),this.hideSnapGuides(),n.active=false,this.clearDragVisualState(n.element,true);return}n.active=true,n.element.dataset.dragging="true",this.canvas.dataset.interactionMode="dragging";let r=(e.clientX-n.startClientX)/n.scale,o=(e.clientY-n.startClientY)/n.scale;if(n.mode==="move"){let{bounds:a}=e.altKey?{bounds:O(n.startBounds,n.slideSize,{left:n.startBounds.left+r,top:n.startBounds.top+o})}:this.snapDragBounds(n,{left:n.startBounds.left+r,top:n.startBounds.top+o});e.altKey&&this.hideSnapGuides(),n.element.style.left=`${a.left*n.scale}px`,n.element.style.top=`${a.top*n.scale}px`;return}let{bounds:s}=e.altKey?{bounds:O(n.startBounds,n.slideSize,{width:n.startBounds.width+r,height:n.startBounds.height+o})}:this.snapResizeBounds(n,{width:n.startBounds.width+r,height:n.startBounds.height+o});e.altKey&&this.hideSnapGuides(),n.element.style.width=`${s.width*n.scale}px`,n.element.style.height=`${s.height*n.scale}px`;}async finishDrag(e){var a,l;let n=this.dragState;if(!n)return;this.dragState=null;let i=(e.clientX-n.startClientX)/n.scale,r=(e.clientY-n.startClientY)/n.scale,o=Math.hypot(e.clientX-n.startClientX,e.clientY-n.startClientY);if(o<=Ie||!n.active){this.hideSnapGuides(),this.clearDragVisualState(n.element);return}this.suppressClickAfterDrag=this.suppressClickAfterDrag||o>Ie;let s=e.altKey?O(n.startBounds,n.slideSize,n.mode==="move"?{left:n.startBounds.left+i,top:n.startBounds.top+r}:{width:n.startBounds.width+i,height:n.startBounds.height+r}):n.mode==="move"?this.snapDragBounds(n,{left:n.startBounds.left+i,top:n.startBounds.top+r}):this.snapResizeBounds(n,{width:n.startBounds.width+i,height:n.startBounds.height+r});if(this.hideSnapGuides(),this.clearDragVisualState(n.element),await this.dispatch({kind:"set-shape-geometry",slideIdOrIndex:n.slideId,shapeIdOrName:n.shapeId,geometry:"bounds"in s?s.bounds:s,preserveTextSizeOnResize:n.mode==="resize"}),"snapped"in s&&s.snapped){let d=this.currentSlide(),c=d==null?void 0:d.nodes.find(u=>u.id===n.shapeId);d&&c&&((l=(a=this.options).onObjectAction)==null||l.call(a,{action:"snap-geometry",slideId:d.id,shapeId:c.id,kind:c.kind,name:c.name,reason:this.snapActionReason(s,d)}));}}snapActionReason(e,n){let i=[...new Set(e.guides.map(r=>r.referenceShapeId).filter(r=>!!r))].map(r=>n.nodes.find(o=>o.id===r)).filter(r=>!!r).map(r=>r.name||r.id);return i.length>0?`\u5DF2\u5438\u9644\u5230 ${i.join("\u3001")}`:"\u5DF2\u5438\u9644\u5230\u9875\u9762\u53C2\u8003\u7EBF"}snapDragBounds(e,n){let i=O(e.startBounds,e.slideSize,n),r=this.sessionValue.scene().slides.find(c=>c.id===e.slideId);if(!r)return this.hideSnapGuides(),{bounds:i,guides:[],snapped:false};let o=Math.min(18e4,lt/e.scale),s=be([{offset:0,value:i.left,role:"start"},{offset:i.width/2,value:i.left+i.width/2,role:"center"},{offset:i.width,value:i.left+i.width,role:"end"}],ge(r,e.shapeId,"x"),o),a=be([{offset:0,value:i.top,role:"start"},{offset:i.height/2,value:i.top+i.height/2,role:"center"},{offset:i.height,value:i.top+i.height,role:"end"}],ge(r,e.shapeId,"y"),o),l=O(e.startBounds,e.slideSize,{left:s?s.target.value-s.source.offset:i.left,top:a?a.target.value-a.source.offset:i.top}),d=[...s?[{axis:"x",value:s.target.value,kind:s.target.kind,referenceShapeId:s.target.referenceShapeId}]:[],...a?[{axis:"y",value:a.target.value,kind:a.target.kind,referenceShapeId:a.target.referenceShapeId}]:[]];return this.renderSnapGuides(d,e.scale),{bounds:l,guides:d,snapped:d.length>0}}snapResizeBounds(e,n){let i=O(e.startBounds,e.slideSize,n),r=this.sessionValue.scene().slides.find(c=>c.id===e.slideId);if(!r)return this.hideSnapGuides(),{bounds:i,guides:[],snapped:false};let o=Math.min(18e4,lt/e.scale),s=be([{offset:i.width/2,value:i.left+i.width/2,role:"center"},{offset:i.width,value:i.left+i.width,role:"end"}],ge(r,e.shapeId,"x"),o,{matchRole:false}),a=be([{offset:i.height/2,value:i.top+i.height/2,role:"center"},{offset:i.height,value:i.top+i.height,role:"end"}],ge(r,e.shapeId,"y"),o,{matchRole:false}),l=O(e.startBounds,e.slideSize,{width:s?dt(i.left,i.width,s.source,s.target.value):i.width,height:a?dt(i.top,i.height,a.source,a.target.value):i.height}),d=[...s?[{axis:"x",value:s.target.value,kind:s.target.kind,referenceShapeId:s.target.referenceShapeId}]:[],...a?[{axis:"y",value:a.target.value,kind:a.target.kind,referenceShapeId:a.target.referenceShapeId}]:[]];return this.renderSnapGuides(d,e.scale),{bounds:l,guides:d,snapped:d.length>0}}renderSnapGuides(e,n){this.clearSnapReferenceHighlights();let i=new Set(e.map(r=>r.referenceShapeId).filter(r=>!!r));for(let r of i){let o=Le(this.canvas,r);o&&(o.dataset.snapReference="true");}this.snapGuides.replaceChildren(...e.map(r=>{let o=document.createElement("div");return o.className="coco-ppt-snap-guide",o.dataset.axis=r.axis,o.dataset.kind=r.kind,r.referenceShapeId&&(o.dataset.referenceShapeId=r.referenceShapeId),r.axis==="x"?o.style.left=`${r.value*n}px`:o.style.top=`${r.value*n}px`,o}));}hideSnapGuides(){this.clearSnapReferenceHighlights(),this.snapGuides.replaceChildren();}clearDragVisualState(e,n=false){delete e.dataset.dragging,(n||!this.dragState)&&delete this.canvas.dataset.interactionMode;}restoreDragElementBounds(e){if(e.mode==="move"){e.element.style.left=`${e.startBounds.left*e.scale}px`,e.element.style.top=`${e.startBounds.top*e.scale}px`;return}e.element.style.width=`${e.startBounds.width*e.scale}px`,e.element.style.height=`${e.startBounds.height*e.scale}px`;}clearSnapReferenceHighlights(){this.canvas.querySelectorAll('.coco-ppt-node[data-snap-reference="true"]').forEach(e=>{delete e.dataset.snapReference;});}handleKeyDown(e){if(e.defaultPrevented||this.dragState||mt(e.target)||this.root.querySelector('[contenteditable="true"]'))return;let n=this.selection();if((n==null?void 0:n.kind)!=="shape")return;let i=this.sessionValue.scene().slides.find(d=>d.id===n.slideId),r=i==null?void 0:i.nodes.find(d=>d.id===n.shapeId);if(!i||!r)return;let o=e.ctrlKey||e.metaKey;if(this.isReadOnly())return;if(o&&e.key.toLowerCase()==="c"){e.preventDefault(),this.copySelectedShape(i,r);return}if(o&&e.key.toLowerCase()==="v"){e.preventDefault(),this.pasteClipboardShape(i,r);return}if(o&&e.key.toLowerCase()==="d"){e.preventDefault(),this.duplicateSelectedShape(i,r);return}if(o&&e.shiftKey&&e.key==="]"){e.preventDefault(),this.bringSelectedShapeToFront(i,r);return}if(o&&e.shiftKey&&e.key==="["){e.preventDefault(),this.sendSelectedShapeToBack(i,r);return}if(e.key==="Delete"||e.key==="Backspace"){if(!F(r))return;e.preventDefault(),this.deleteSelectedShape(i,r);return}let s=Xn(e.key);if(!s||!r.capabilities.editGeometry)return;let a=Tn*(e.shiftKey?10:1),l=O(r.bounds,i.size,{left:r.bounds.left+s.dx*a,top:r.bounds.top+s.dy*a});e.preventDefault(),this.dispatch({kind:"set-shape-geometry",slideIdOrIndex:i.id,shapeIdOrName:r.id,geometry:{left:l.left,top:l.top}}).then(()=>{var d,c;(c=(d=this.options).onObjectAction)==null||c.call(d,{action:"nudge-geometry",slideId:i.id,shapeId:r.id,kind:r.kind,name:r.name,reason:`\u5DF2\u79FB\u52A8\u5BF9\u8C61 ${s.label}${e.shiftKey?" 10\u6B65":" 1\u6B65"}`});});}handleSelectStart(e){this.isReadOnly()||mt(e.target)||e.target instanceof HTMLElement&&e.target.closest('[contenteditable="true"]')||e.preventDefault();}copySelectedShape(e,n){var i,r;F(n)&&(this.clipboardShape={slideId:e.id,shapeId:n.id},(r=(i=this.options).onObjectAction)==null||r.call(i,{action:"copy-shape",slideId:e.id,shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u590D\u5236\u5BF9\u8C61"}));}pasteClipboardShape(e,n){if(!this.clipboardShape)return;let i=this.clipboardShape;this.dispatch({kind:"paste-shape",slideIdOrIndex:i.slideId,shapeIdOrName:i.shapeId}).then(()=>{var o,s;let r=this.selection();(s=(o=this.options).onObjectAction)==null||s.call(o,{action:"paste-shape",slideId:i.slideId,shapeId:(r==null?void 0:r.kind)==="shape"?r.shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u7C98\u8D34\u5BF9\u8C61"});});}duplicateSelectedShape(e,n){F(n)&&this.dispatch({kind:"duplicate-shape",slideIdOrIndex:e.id,shapeIdOrName:n.id}).then(()=>{var r,o;let i=this.selection();(o=(r=this.options).onObjectAction)==null||o.call(r,{action:"duplicate-shape",slideId:e.id,shapeId:(i==null?void 0:i.kind)==="shape"?i.shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u91CD\u590D\u5BF9\u8C61"});});}bringSelectedShapeToFront(e,n){F(n)&&this.dispatch({kind:"bring-shape-to-front",slideIdOrIndex:e.id,shapeIdOrName:n.id}).then(()=>{var i,r;(r=(i=this.options).onObjectAction)==null||r.call(i,{action:"bring-shape-to-front",slideId:e.id,shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u7F6E\u4E8E\u9876\u5C42"});});}sendSelectedShapeToBack(e,n){F(n)&&this.dispatch({kind:"send-shape-to-back",slideIdOrIndex:e.id,shapeIdOrName:n.id}).then(()=>{var i,r;(r=(i=this.options).onObjectAction)==null||r.call(i,{action:"send-shape-to-back",slideId:e.id,shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u7F6E\u4E8E\u5E95\u5C42"});});}showContextMenu(e,n,i){if(this.isReadOnly())return;let r=F(i),o=!!this.clipboardShape,s=c=>()=>{this.hideContextMenu(),c();};this.contextMenu.replaceChildren(W("\u590D\u5236","Ctrl+C",r,s(()=>this.copySelectedShape(n,i))),W("\u7C98\u8D34","Ctrl+V",o,s(()=>this.pasteClipboardShape(n,i))),W("\u91CD\u590D","Ctrl+D",r,s(()=>this.duplicateSelectedShape(n,i))),ft(),W("\u7F6E\u4E8E\u9876\u5C42","Ctrl+Shift+]",r,s(()=>this.bringSelectedShapeToFront(n,i))),W("\u7F6E\u4E8E\u5E95\u5C42","Ctrl+Shift+[",r,s(()=>this.sendSelectedShapeToBack(n,i))),ft(),W("\u5220\u9664","Del",r,s(()=>this.deleteSelectedShape(n,i))));let a=this.root instanceof ShadowRoot?this.root.host.getBoundingClientRect():this.root.getBoundingClientRect(),l=ve(e.clientX,a.left+4,window.innerWidth-170),d=ve(e.clientY,a.top+4,window.innerHeight-220);this.contextMenu.style.left=`${l}px`,this.contextMenu.style.top=`${d}px`,this.contextMenu.dataset.shapeId=i.id,this.contextMenu.dataset.open="true";}deleteSelectedShape(e,n){F(n)&&this.dispatch({kind:"delete-shape",slideIdOrIndex:e.id,shapeIdOrName:n.id}).then(()=>{var i,r;(r=(i=this.options).onObjectAction)==null||r.call(i,{action:"delete-shape",slideId:e.id,shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u5220\u9664\u5BF9\u8C61"});});}async dispatchCurrentSlideSelection(){if(this.consumeSuppressedClick())return;let e=this.currentSlide();e&&await this.dispatch({kind:"select-slide",slideIdOrIndex:e.id});}consumeSuppressedClick(){return this.suppressClickAfterDrag?(this.suppressClickAfterDrag=false,true):false}dismissContextMenu(e){let n=e.composedPath()[0];n instanceof Node&&this.contextMenu.contains(n)||this.hideContextMenu();}hideContextMenu(){delete this.contextMenu.dataset.open,delete this.contextMenu.dataset.shapeId;}renderSelection(){this.canvas.querySelectorAll(".coco-ppt-parent-group-outline").forEach(n=>n.remove());let e=this.sessionValue.selection();this.slideList.querySelectorAll(".coco-ppt-thumb").forEach((n,i)=>{let r=this.sessionValue.scene().slides[i];n.dataset.selected=(e==null?void 0:e.slideId)===(r==null?void 0:r.id)?"true":"false";}),this.canvas.querySelectorAll(".coco-ppt-node").forEach(n=>{n.dataset.selected=(e==null?void 0:e.kind)==="shape"&&n.dataset.shapeId===e.shapeId?"true":"false";}),this.renderParentGroupSelection(e);}renderParentGroupSelection(e){var d,c;if((e==null?void 0:e.kind)!=="shape")return;let n=this.sessionValue.scene().slides.find(u=>u.id===e.slideId),i=(d=n==null?void 0:n.nodes.find(u=>u.id===e.shapeId))!=null?d:n==null?void 0:n.groups.find(u=>u.id===e.shapeId),r=i!=null&&i.groupContext?(c=n==null?void 0:n.groups.find(u=>{var p;return u.id===((p=i.groupContext)==null?void 0:p.parentId)}))!=null?c:$n(i):(i==null?void 0:i.kind)==="group"?i:null;if(!n||!r)return;let o=this.computeScale(n),s=document.createElement("div");s.className="coco-ppt-parent-group-outline",s.dataset.shapeId=r.id,s.dataset.selected=e.shapeId===r.id?"true":"false",s.title=`\u7236\u7EC4\uFF1A${r.name||r.id}`,s.style.left=`${r.bounds.left*o}px`,s.style.top=`${r.bounds.top*o}px`,s.style.width=`${r.bounds.width*o}px`,s.style.height=`${r.bounds.height*o}px`;let a=u=>{u.preventDefault(),u.stopPropagation(),this.startDrag(u,"move",n,r,o,s);};["top","right","bottom","left"].forEach(u=>{let p=document.createElement("div");p.className="coco-ppt-parent-group-edge",p.dataset.edge=u,p.title="\u62D6\u52A8\u7236\u7EC4",p.addEventListener("mousedown",a),s.append(p);});let l=document.createElement("div");l.className="coco-ppt-parent-group-handle",l.title="\u62D6\u52A8\u7236\u7EC4",l.addEventListener("mousedown",a),s.append(l),this.canvas.append(s);}currentSlide(){var i,r,o;let e=this.sessionValue.scene(),n=this.sessionValue.selection();return (n==null?void 0:n.kind)==="slide"||(n==null?void 0:n.kind)==="shape"?(r=(i=e.slides.find(s=>s.id===n.slideId))!=null?i:e.slides[0])!=null?r:null:(o=e.slides[0])!=null?o:null}computeScale(e){let n=this.canvas.parentElement,i=n?Math.max(1,n.clientWidth-48):960,r=n?Math.max(1,n.clientHeight-48):540;return Math.min(960/e.size.width,540/e.size.height,i/e.size.width,r/e.size.height)}};function Bn(t,e){var i,r;if(!On(e))return;let n=(r=(i=t.querySelector(".coco-ppt-rich-text, .coco-ppt-distributed-text"))!=null?i:t.querySelector(".coco-ppt-text-layer"))!=null?r:t;t.dataset.textResizePreview="wrap",n.dataset.textResizePreview="wrap",n.style.transform="",n.style.transformOrigin="",n.style.width="",t.style.whiteSpace="pre-wrap",t.style.overflowWrap="anywhere",t.querySelectorAll(".coco-ppt-rich-text, .coco-ppt-paragraph").forEach(o=>{o.style.whiteSpace="pre-wrap",o.style.overflowWrap="anywhere";});}function On(t){var e;return !!(t.capabilities.editGeometry&&Vn(t)&&(t.text||(e=t.textParagraphs)!=null&&e.length))}function Vn(t){return t.kind==="placeholder"||t.kind==="textBox"||t.kind==="geometricShape"}function ct(){return new Promise(t=>requestAnimationFrame(()=>t()))}async function Fn(t,e,n,i,r,o=e,s=n){if(typeof XMLSerializer=="undefined"||typeof Blob=="undefined"||typeof URL=="undefined"||typeof URL.createObjectURL!="function")return null;await Hn(t);let a=document.createElement("canvas");a.width=Math.max(1,Math.round(e*i)),a.height=Math.max(1,Math.round(n*i));let l=a.getContext("2d");if(!l)return null;let d=document.createElement("div");d.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),d.style.width=`${o}px`,d.style.height=`${s}px`,d.style.position="relative",d.style.overflow="hidden",d.style.background="#fff";let c=document.createElement("style");c.textContent=r;let u=t.cloneNode(true);await zn(u),u.style.position="relative",u.style.left="0",u.style.top="0",u.style.transform="none",d.append(c,u);let p=new XMLSerializer().serializeToString(d),f=`<svg xmlns="http://www.w3.org/2000/svg" width="${a.width}" height="${a.height}" viewBox="0 0 ${o} ${s}"><foreignObject width="100%" height="100%">${p}</foreignObject></svg>`,m=URL.createObjectURL(new Blob([f],{type:"image/svg+xml;charset=utf-8"}));try{let b=await jn(m);return l.drawImage(b,0,0,a.width,a.height),a}catch(b){return null}finally{URL.revokeObjectURL(m);}}function ut(t){let e=document.createElement("canvas");e.className="coco-ppt-thumb-canvas",e.width=t.width,e.height=t.height;let n=e.getContext("2d");return n&&n.drawImage(t,0,0),e}function Ge(t){return JSON.stringify({size:t.size,background:t.background,nodes:t.nodes.map(e=>It(e))})}function It(t){return {id:t.id,kind:t.kind,bounds:t.bounds,text:t.text,textParagraphs:t.textParagraphs,textStyle:t.textStyle,textBody:t.textBody,table:t.table,fillColor:t.fillColor,fillGradient:t.fillGradient,opacity:t.opacity,lineColor:t.lineColor,lineGradient:t.lineGradient,lineOpacity:t.lineOpacity,lineWidth:t.lineWidth,lineDash:t.lineDash,presetGeometry:t.presetGeometry,presetAdjustments:t.presetAdjustments,customGeometry:t.customGeometry,imagePath:t.imagePath,imageCrop:t.imageCrop,imageFillRect:t.imageFillRect,imageOpacity:t.imageOpacity,shadow:t.shadow,threeD:t.threeD,children:t.children.map(e=>It(e))}}async function Hn(t){let e=Array.from(t.querySelectorAll("img"));await Promise.all(e.map(async n=>{if(!(n.complete&&n.naturalWidth>0)){if(typeof n.decode=="function"){await n.decode().catch(()=>{});return}await new Promise(i=>{let r=()=>i();n.addEventListener("load",r,{once:true}),n.addEventListener("error",r,{once:true}),setTimeout(r,500);});}}));}async function zn(t){let e=Array.from(t.querySelectorAll("img"));await Promise.all(e.map(async n=>{n.alt="";let i=n.getAttribute("src");if(!i||i.startsWith("data:"))return;let r=await Dn(i).catch(()=>{});r&&n.setAttribute("src",r);}));}async function Dn(t){let e=await fetch(t);if(!e.ok)throw new Error(`Failed to inline thumbnail image: ${e.status}`);let n=await e.blob();return Wn(n)}function Wn(t){return new Promise((e,n)=>{let i=new FileReader;i.onload=()=>{typeof i.result=="string"?e(i.result):n(new Error("Failed to read thumbnail image blob."));},i.onerror=()=>{var r;return n((r=i.error)!=null?r:new Error("Failed to read thumbnail image blob."))},i.readAsDataURL(t);})}function jn(t){return new Promise((e,n)=>{let i=new Image;i.onload=()=>e(i),i.onerror=()=>n(new Error("Failed to rasterize PPT thumbnail.")),i.src=t;})}function Un(t){return t.filter(_n).map(n=>{var s,a;let i=$t(n.family),r=(s=n.weight)!=null?s:400,o=(a=n.style)!=null?a:"normal";return `@font-face { font-family: ${i}; src: url(${oi(n.url)}); font-weight: ${r}; font-style: ${o}; }`}).join(`
|
|
76
|
-
`)}function _n(t){return /font\/(ttf|otf|woff|woff2)|application\/font-(sfnt|woff|woff2)/i.test(t.contentType)}function Zn(t,e=[]){if(typeof document=="undefined")return Promise.resolve();let n=new Set(t.map(r=>r.family));for(let r of e)n.add(r);let i=[];for(let r of n){let o=ri(r);if(!o)continue;let s=`coco-ppt-google-font-${r.replace(/[^a-zA-Z0-9_-]/g,"_")}`,a=document.getElementById(s);if(a){i.push(pt(a));continue}let l=document.createElement("link");l.id=s,l.rel="stylesheet",l.href=o,i.push(pt(l)),document.head.append(l);}return Promise.all(i).then(()=>{})}function qn(t){let e=new Set,n=r=>{r!=null&&r.trim()&&e.add(r.trim());},i=r=>{var o,s,a,l,d,c,u,p;n((o=r.textStyle)==null?void 0:o.fontFamily);for(let f of (s=r.textParagraphs)!=null?s:[]){n((a=f.style)==null?void 0:a.bulletFontFamily);for(let m of (l=f.runs)!=null?l:[])n((d=m.style)==null?void 0:d.fontFamily);}for(let f of (u=(c=r.table)==null?void 0:c.cellStyles)!=null?u:[])for(let m of f)n((p=m==null?void 0:m.textStyle)==null?void 0:p.fontFamily);for(let f of r.children)i(f);};for(let r of t.scene.slides)for(let o of r.nodes)i(o);return [...e]}function Kn(t){globalThis.__cocoPptFontRenderReady=t;}function pt(t){return t.sheet?Promise.resolve():new Promise(e=>{let n=()=>e();t.addEventListener("load",n,{once:true}),t.addEventListener("error",n,{once:true}),window.setTimeout(n,5e3);})}function Yn(t){var e;return (e=t.querySelector(".coco-ppt-text-layer"))!=null?e:t}function ht(t){let e=t.target;return e instanceof HTMLElement?e.closest("td[data-row][data-column]"):null}function W(t,e,n,i){let r=document.createElement("button");r.type="button",r.disabled=!n;let o=document.createElement("strong");o.textContent=t;let s=document.createElement("span");return s.textContent=e,r.append(o,s),r.addEventListener("click",()=>{r.disabled||i();}),r}function ft(){return document.createElement("hr")}function Xn(t){return t==="ArrowLeft"?{dx:-1,dy:0,label:"\u5DE6"}:t==="ArrowRight"?{dx:1,dy:0,label:"\u53F3"}:t==="ArrowUp"?{dx:0,dy:-1,label:"\u4E0A"}:t==="ArrowDown"?{dx:0,dy:1,label:"\u4E0B"}:null}function mt(t){if(!(t instanceof HTMLElement))return false;if(t.isContentEditable)return true;let e=t.tagName.toLowerCase();return e==="input"||e==="textarea"||e==="select"}function Qn(t,e){return t.isContentEditable||e instanceof HTMLElement&&e.isContentEditable?true:!!t.querySelector('[contenteditable="true"]')}function Jn(t,e){var a;let n=(a=t.textParagraphs)==null?void 0:a.filter(d=>d.runs.length>0);if(!(n!=null&&n.length)||!Vt(t,n))return e;let l=e,{textGradient:i,textFill:r,textOutlineColor:o}=l;return _e(l,["textGradient","textFill","textOutlineColor"])}function gt(t,e,n,i){if(e.capabilities.editText||ni(e))return null;let r=Gt(n,i);if(!r)return null;let o=t.nodes.findIndex(a=>a.id===e.id),s=t.nodes.slice(0,o<0?t.nodes.length:o);for(let a=s.length-1;a>=0;a--){let l=s[a];if(l.capabilities.editText&&Lt(r.x,r.y,l.bounds))return l}return null}function ei(t,e,n,i){let r=ti(t,e,n);if(r.length<2)return null;let s=(Math.max(0,r.findIndex(a=>a.id===i))+1)%r.length;return {node:r[s],index:s,count:r.length}}function ti(t,e,n){let i=Gt(e,n);if(!i)return [];let r=[];for(let o=t.nodes.length-1;o>=0;o--){let s=t.nodes[o];s.capabilities.select&&Lt(i.x,i.y,s.bounds)&&r.push(s);}return r}function ni(t){return t.kind==="table"||t.kind==="chart"||t.kind==="smartArt"}function Gt(t,e){var r;let n=t.currentTarget&&typeof t.currentTarget.parentElement=="object"&&(r=t.currentTarget.parentElement)!=null?r:null,i=n==null?void 0:n.getBoundingClientRect();return i?{x:(t.clientX-i.left)/e,y:(t.clientY-i.top)/e}:null}function Lt(t,e,n){return t>=n.left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height}function Le(t,e){for(let n of Array.from(t.querySelectorAll(".coco-ppt-node")))if(n.dataset.shapeId===e)return n;return null}function bt(t,e){var s,a;let n=t.ownerDocument.getSelection();if(!n||n.rangeCount===0){t.textContent=`${(s=t.textContent)!=null?s:""}${e}`;return}let i=n.getRangeAt(0);if(!(t===i.commonAncestorContainer||t.contains(i.commonAncestorContainer))){t.textContent=`${(a=t.textContent)!=null?a:""}${e}`;return}i.deleteContents();let o=t.ownerDocument.createTextNode(e);i.insertNode(o),i.setStartAfter(o),i.setEndAfter(o),n.removeAllRanges(),n.addRange(i);}function ii(t){var e;return (e=t.capabilities.reasons)!=null&&e.editText?t.capabilities.reasons.editText:t.capabilities.reason?t.capabilities.reason:t.kind==="table"?"\u8868\u683C\u8BF7\u4F7F\u7528\u5355\u5143\u683C\u7F16\u8F91":t.kind==="picture"?"\u56FE\u7247\u5BF9\u8C61\u4E0D\u652F\u6301\u6587\u5B57\u7F16\u8F91":t.kind==="chart"?"\u56FE\u8868\u5F53\u524D\u4EC5\u652F\u6301\u9009\u62E9\u548C\u4F4D\u7F6E\u7F16\u8F91":t.kind==="smartArt"?"SmartArt \u5F53\u524D\u4EC5\u652F\u6301\u9009\u62E9\u548C\u4F4D\u7F6E\u7F16\u8F91":t.kind==="group"?"\u7EC4\u5408\u5BF9\u8C61\u5F53\u524D\u4EC5\u652F\u6301\u9009\u62E9\u548C\u4F4D\u7F6E\u7F16\u8F91":"\u8BE5\u5BF9\u8C61\u4E0D\u652F\u6301\u6587\u5B57\u7F16\u8F91"}function ri(t){return {Cuprum:"https://fonts.googleapis.com/css2?family=Cuprum:ital,wght@0,400;0,700;1,400;1,700&display=swap",Podkova:"https://fonts.googleapis.com/css2?family=Podkova:wght@400;700&display=swap",Ubuntu:"https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,400;0,700;1,400;1,700&display=swap"}[t]}function Re(t){return [$t(t),'"Calibri"','"Microsoft YaHei"','"Segoe UI"',"sans-serif"].join(", ")}function $t(t){return `"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function oi(t){return `"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function q(t,e){var a;if(e===void 0||e>=1)return t;let n=Math.max(0,Math.min(1,e)),i=(a=t.match(/^#([0-9a-fA-F]{6})$/))==null?void 0:a[1];if(!i)return t;let r=Number.parseInt(i.slice(0,2),16),o=Number.parseInt(i.slice(2,4),16),s=Number.parseInt(i.slice(4,6),16);return `rgba(${r}, ${o}, ${s}, ${n})`}function K(t){var e;return t.opacity!==void 0?Math.max(0,Math.min(1,t.opacity)):((e=t.threeD)==null?void 0:e.material)==="translucentPowder"?.52:void 0}function si(t,e){if(e.imageFillRect){li(t,e);return}ai(t,e);}function ai(t,e){var d,c,u,p;let n=e.imageCrop;if(!n)return;let i=(d=n.left)!=null?d:0,r=(c=n.right)!=null?c:0,o=(u=n.top)!=null?u:0,s=(p=n.bottom)!=null?p:0,a=Math.max(.01,1-i-r),l=Math.max(.01,1-o-s);t.style.position="absolute",t.style.left=`${-i/a*100}%`,t.style.top=`${-o/l*100}%`,t.style.width=`${1/a*100}%`,t.style.height=`${1/l*100}%`;}function li(t,e){var a,l,d,c;let n=e.imageFillRect;if(!n)return;let i=(a=n.left)!=null?a:0,r=(l=n.right)!=null?l:0,o=(d=n.top)!=null?d:0,s=(c=n.bottom)!=null?c:0;t.style.position="absolute",t.style.left=`${i*100}%`,t.style.top=`${o*100}%`,t.style.width=`${Math.max(.01,1-i-r)*100}%`,t.style.height=`${Math.max(.01,1-o-s)*100}%`;}function di(t,e){var r,o;let n=document.createElement("div");n.className="coco-ppt-unsupported-image";let i=(o=(r=t.imagePath)==null?void 0:r.split(".").pop())==null?void 0:o.toUpperCase();return n.textContent=i||ci(e)||"IMAGE",n.title=t.imagePath?`Unsupported image: ${t.imagePath}`:"Missing image resource",n}function ci(t){if(t)return t.includes("emf")?"EMF":t.includes("wmf")?"WMF":t.includes("svg")?"SVG":"IMAGE"}function yt(t,e,n,i){var a,l;let r=(a=e.textParagraphs)==null?void 0:a.filter(d=>d.runs.length>0),o=Rt(e.textBody);if(!(r!=null&&r.length)||!Vt(e,r)){!o&&((l=e.textStyle)==null?void 0:l.alignment)==="distributed"&&Array.from(i).length>1?Mi(t,i):t.textContent=i;return}let s=document.createElement("div");s.className="coco-ppt-rich-text",r.forEach(d=>{var p,f,m,b;let c=document.createElement("div");c.className="coco-ppt-paragraph",(p=d.style)!=null&&p.alignment&&Fe(c,d.style.alignment),ki(c,d.style,n,{verticalText:o});let u=!o&&((f=d.style)==null?void 0:f.alignment)==="distributed"&&!((m=d.style)!=null&&m.bullet);if(u&&(c.style.display="flex",c.style.justifyContent="space-between",c.style.alignItems="baseline",c.style.width="100%"),(b=d.style)!=null&&b.bullet){c.dataset.bullet="true";let h=document.createElement("span");h.className="coco-ppt-bullet",h.textContent=d.style.bullet,d.style.bulletColor&&(h.style.color=d.style.bulletColor),Ti(h,d.style,n,d.text),c.append(h);}d.runs.forEach((h,x)=>{(u?Array.from(h.text):[h.text]).forEach(g=>{let y=document.createElement("span");y.textContent=g;let P=Gi(e,d,h,x);P&&Oe(y,P,n),c.append(y);});}),s.append(c);}),t.append(s);}function Rt(t){return (t==null?void 0:t.vertical)==="eastAsian"||(t==null?void 0:t.vertical)==="vertical"}function xt(t,e){var n;((n=e.textBody)==null?void 0:n.wrap)==="none"&&Bt(t);}function St(t,e){var n,i;((n=e.textBody)==null?void 0:n.autoFit)==="normal"&&(!e.text&&!((i=e.textParagraphs)!=null&&i.length)||(yi(e)&&!Si(e)&&Bt(t),requestAnimationFrame(()=>{var p;if(t.dataset.textResizePreview==="wrap")return;let r=t.clientWidth,o=t.clientHeight;if(r<=0||o<=0)return;let s=t.scrollWidth,a=t.scrollHeight,l=s>r?r/s:1,d=a>o?o/a:1,c=Math.max(.25,Math.min(1,l,d));if(c>=.995)return;let u=(p=t.querySelector(".coco-ppt-rich-text, .coco-ppt-distributed-text"))!=null?p:t;u.dataset.textResizePreview!=="wrap"&&(u.style.transformOrigin=Pi(e),u.style.transform=`scale(${c})`,u.style.width=`${100/c}%`);})));}function ui(t){var e;return !!((t.text||(e=t.textParagraphs)!=null&&e.length)&&(t.bounds.flipHorizontal||t.bounds.flipVertical))}function pi(t,e){let n=[];e.bounds.flipHorizontal&&n.push("scaleX(-1)"),e.bounds.flipVertical&&n.push("scaleY(-1)"),n.length!==0&&(t.style.transform=n.join(" "),t.style.transformOrigin="center");}function Bt(t){t.style.whiteSpace="nowrap",t.querySelectorAll(".coco-ppt-rich-text, .coco-ppt-paragraph").forEach(e=>{e.style.whiteSpace="nowrap";});}function hi(t,e,n){var r,o,s;if(!gi(e,n))return;let i=((s=(o=(r=e.textStyle)==null?void 0:r.fontSize)!=null?o:Ce(e))!=null?s:28)*12700*n;t.style.letterSpacing=`${Math.max(1,Math.min(2.4,i*.035))}px`;}function fi(t,e){var i,r;if(!mi(t))return 0;let n=(r=(i=t.textStyle)==null?void 0:i.fontSize)!=null?r:Ce(t);return n?n*12700*e*.18:0}function mi(t){var o,s,a,l,d,c,u,p,f;if(t.kind!=="textBox"&&t.kind!=="placeholder"||((o=t.textBody)==null?void 0:o.anchor)!=="top"||t.textBody.wrap!=="square"||t.fillColor||t.fillGradient||t.lineColor||t.lineGradient)return false;let e=(a=(s=t.textStyle)==null?void 0:s.fontFamily)!=null?a:Ot(t);if(!e||!/\bCuprum\b/i.test(e))return false;let n=(d=(l=t.textStyle)==null?void 0:l.fontSize)!=null?d:Ce(t);if(!n||n<72)return false;let i=(c=t.textParagraphs)==null?void 0:c.filter(m=>{var h;return ((h=m.text)!=null?h:m.runs.map(x=>x.text).join("")).trim().length>0});if(i&&i.length!==1)return false;let r=((f=(p=(u=i==null?void 0:i[0])==null?void 0:u.text)!=null?p:t.text)!=null?f:"").trim();return r.length>=12&&!/[\u3400-\u9fff]/.test(r)}function gi(t,e){var l,d,c,u,p,f,m,b,h,x,S,g,y,P,w,E,v,k,L,$;if(((l=t.textBody)==null?void 0:l.wrap)!=="square"||bi(t)||((f=(d=t.textStyle)==null?void 0:d.alignment)!=null?f:(p=(u=(c=t.textParagraphs)==null?void 0:c[0])==null?void 0:u.style)==null?void 0:p.alignment)!=="center")return false;let i=(b=(m=t.textStyle)==null?void 0:m.fontFamily)!=null?b:Ot(t);if(!i||!/\bJosefin Sans\b/i.test(i))return false;let r=((g=(S=(x=(h=t.textParagraphs)==null?void 0:h[0])==null?void 0:x.text)!=null?S:t.text)!=null?g:"").replace(/\s+/g," ").trim();if(r.length<24||/[a-z\u3400-\u9fff]/.test(r)||!/^[A-Z0-9][A-Z0-9\s&:;,.!?'"()/+-]*$/.test(r))return false;let o=(P=(y=t.textStyle)==null?void 0:y.fontSize)!=null?P:Ce(t);if(!o)return false;let s=($=(L=(w=t.textStyle)==null?void 0:w.lineHeight)!=null?L:(k=(v=(E=t.textParagraphs)==null?void 0:E[0])==null?void 0:v.style)==null?void 0:k.lineHeight)!=null?$:1.2,a=o*12700*e*s;return t.bounds.height*e>=a*1.75}function bi(t){var e,n;return !!(((e=t.textStyle)==null?void 0:e.characterSpacing)!==void 0||(n=t.textParagraphs)!=null&&n.some(i=>i.runs.some(r=>{var o;return ((o=r.style)==null?void 0:o.characterSpacing)!==void 0})))}function Ce(t){var e,n;for(let i of (e=t.textParagraphs)!=null?e:[])for(let r of i.runs)if(((n=r.style)==null?void 0:n.fontSize)!==void 0)return r.style.fontSize}function Ot(t){var e,n;for(let i of (e=t.textParagraphs)!=null?e:[])for(let r of i.runs)if((n=r.style)!=null&&n.fontFamily)return r.style.fontFamily}function yi(t){var i,r,o,s,a,l;let e=(i=t.textParagraphs)==null?void 0:i.filter(d=>d.runs.length>0);if(e&&e.length!==1||(o=(r=e==null?void 0:e[0])==null?void 0:r.style)!=null&&o.bullet)return false;let n=(l=(a=(s=e==null?void 0:e[0])==null?void 0:s.text)!=null?a:t.text)!=null?l:"";return n.length>0&&!n.includes(`
|
|
77
|
-
`)&&!n.includes("\r")}function xi(t){var r,o,s,a,l,d,c,u,p,f;if(((r=t.textBody)==null?void 0:r.wrap)!=="square"||((d=(o=t.textStyle)==null?void 0:o.alignment)!=null?d:(l=(a=(s=t.textParagraphs)==null?void 0:s[0])==null?void 0:a.style)==null?void 0:l.alignment)!=="center")return false;let e=((f=(p=(u=(c=t.textParagraphs)==null?void 0:c[0])==null?void 0:u.text)!=null?p:t.text)!=null?f:"").trim();if(!/^[\u3400-\u9fff]{4,6}$/.test(e))return false;let n=Math.min(t.bounds.width,t.bounds.height),i=Math.max(t.bounds.width,t.bounds.height);return n>0&&i<=11e5&&i/n<1.25}function Si(t){var i,r,o,s,a,l,d;if(xi(t))return true;if(((i=t.textBody)==null?void 0:i.wrap)!=="square")return false;let e=((a=(s=(o=(r=t.textParagraphs)==null?void 0:r[0])==null?void 0:o.text)!=null?s:t.text)!=null?a:"").trim();return e.length<18?false:((d=(l=e.match(/[\u3400-\u9fff]/g))==null?void 0:l.length)!=null?d:0)>=12?true:/[\s,。;、,.]/.test(e)}function Pi(t){var n,i,r,o,s;let e=(s=(n=t.textStyle)==null?void 0:n.alignment)!=null?s:(o=(r=(i=t.textParagraphs)==null?void 0:i[0])==null?void 0:r.style)==null?void 0:o.alignment;return e==="right"?"right top":e==="center"?"center top":"top left"}function wi(t){var e;return t.kind!=="textBox"||!t.text&&!((e=t.textParagraphs)!=null&&e.length)||t.customGeometry||Wt(t)||Ft(t)?false:!vi(t)&&!Ei(t)}function vi(t){var e,n;return (e=t.fillGradient)!=null&&e.colors.length?((n=t.fillGradient.opacities)!=null?n:[]).some(i=>i>0)||!t.fillGradient.opacities:!!(t.fillColor&&t.opacity!==0)}function Ei(t){var e,n;return !t.lineColor&&!((e=t.lineGradient)!=null&&e.colors.length)||t.lineOpacity===0?false:((n=t.lineWidth)!=null?n:9525)>0}function Mi(t,e){let n=document.createElement("div");n.className="coco-ppt-distributed-text",Array.from(e).forEach(i=>{let r=document.createElement("span");r.textContent=i,n.append(r);}),t.append(n);}function Vt(t,e){return e.some(n=>{var i;return !!((i=n.style)!=null&&i.bullet)||Ci(n.style)||n.runs.some(r=>!!r.hyperlink||r.style!==void 0&&Ii(r.style,t.textStyle))})}function Ci(t){return (t==null?void 0:t.lineHeight)!==void 0||(t==null?void 0:t.marginLeft)!==void 0||(t==null?void 0:t.textIndent)!==void 0||(t==null?void 0:t.spaceBefore)!==void 0||(t==null?void 0:t.spaceAfter)!==void 0}function ki(t,e,n,i={}){if(e){if(e.lineHeight!==void 0&&(t.style.lineHeight=String(Ni(e))),e.marginLeft!==void 0&&(t.style.paddingLeft=`${e.marginLeft*n}px`),e.textIndent!==void 0&&(t.style.textIndent=`${e.textIndent*n}px`),i.verticalText){e.spaceBefore!==void 0&&(t.style.marginRight=ye(e.spaceBefore,n)),e.spaceAfter!==void 0&&(t.style.marginLeft=ye(e.spaceAfter,n));return}e.spaceBefore!==void 0&&(t.style.marginTop=ye(e.spaceBefore,n)),e.spaceAfter!==void 0&&(t.style.marginBottom=ye(e.spaceAfter,n));}}function Ni(t){var n;let e=(n=t.lineHeight)!=null?n:1.2;return t.bullet?e*1.15:e}function Ti(t,e,n,i=""){(e==null?void 0:e.bulletSize)!==void 0&&(e.bulletSize>4?t.style.fontSize=`${e.bulletSize*12700*n}px`:e.bulletSize>0&&(t.style.fontSize=`${e.bulletSize}em`)),Ai(e,i)&&(t.style.width="0.5em",t.style.marginRight="0.12em",t.style.transform="scale(0.62)",t.style.transformOrigin="center",t.style.verticalAlign="middle");}function Ai(t,e=""){var r,o;if(!t)return false;let n=(o=(r=t.bulletFontFamily)==null?void 0:r.toLowerCase())!=null?o:"",i=Array.from(e.trim()).length;return t.bullet==="\u25A1"&&t.alignment==="center"&&i>0&&i<=4&&(n.includes("wingdings")||n.includes("webdings"))&&t.textIndent!==void 0&&t.textIndent<0&&t.marginLeft!==void 0&&t.marginLeft<=Math.abs(t.textIndent)*1.25}function ye(t,e){return t>10?`${t*e}px`:`${t}em`}function Ii(t,e){let n=t,i=e;return t.fontSize!==void 0&&t.fontSize!==(e==null?void 0:e.fontSize)||t.fontFamily!==void 0&&t.fontFamily!==(e==null?void 0:e.fontFamily)||t.color!==void 0&&t.color!==(e==null?void 0:e.color)||n.textFill!==void 0&&n.textFill!==(i==null?void 0:i.textFill)||n.textGradient!==void 0&&n.textGradient!==(i==null?void 0:i.textGradient)||n.textOutlineColor!==void 0&&n.textOutlineColor!==(i==null?void 0:i.textOutlineColor)||n.textShadow!==void 0&&n.textShadow!==(i==null?void 0:i.textShadow)||t.bold!==void 0&&t.bold!==(e==null?void 0:e.bold)||t.italic!==void 0&&t.italic!==(e==null?void 0:e.italic)||t.underline!==void 0&&t.underline!==(e==null?void 0:e.underline)||t.characterSpacing!==void 0&&t.characterSpacing!==(e==null?void 0:e.characterSpacing)}function Gi(t,e,n,i){var o,s,a,l;if(!Li(t,e,n,i))return Pt(n,n.style);let r=$i(e.runs.slice(0,i));return Pt(n,G(C({},n.style),{color:(s=(o=n.style)==null?void 0:o.color)!=null?s:"#000000",fontSize:(l=(a=n.style)==null?void 0:a.fontSize)!=null?l:Math.max(12,Math.round((r!=null?r:28)*.72))}))}function Pt(t,e){if(!t.hyperlink)return e;let n=C({},e!=null?e:{});return n.textFill===void 0&&n.textGradient===void 0&&(n.color="#0563C1"),n.underline===void 0&&(n.underline=true),n}function Li(t,e,n,i){var a,l,d;if(i<=0||(a=n.style)!=null&&a.color&&n.style.fontSize!==void 0||((l=t.textBody)==null?void 0:l.autoFit)!=="shape"||!/[\u3400-\u9fff]/.test(n.text))return false;let r=e.runs.slice(0,i).map(c=>c.text).join(""),o=/^\s*\d{1,2}\s*[、..,,]\s*(.*)$/u.exec(r);return !o||Array.from((d=o[1])!=null?d:"").filter(c=>/[\u3400-\u9fff]/.test(c)).length>2?false:e.runs.slice(0,i).some(c=>{let u=c.style;return (u==null?void 0:u.color)!==void 0||(u==null?void 0:u.fontSize)!==void 0})}function $i(t){var e;for(let n of t)if(((e=n.style)==null?void 0:e.fontSize)!==void 0)return n.style.fontSize}function Oe(t,e,n){var i,r,o;e.fontSize&&(t.style.fontSize=`${Math.max(1,e.fontSize*12700*n)}px`),e.fontFamily&&(t.style.fontFamily=Re(e.fontFamily)),e.lineHeight&&(t.style.lineHeight=String(e.lineHeight)),e.characterSpacing!==void 0&&(t.style.letterSpacing=`${e.characterSpacing*12700*n}px`),e.color&&(t.style.color=e.color),(i=e.textGradient)!=null&&i.colors.length&&e.textGradient.colors.length>1&&(t.style.backgroundImage=Y(e.textGradient),t.style.backgroundClip="text",t.style.setProperty("-webkit-background-clip","text"),t.style.color="transparent",t.style.setProperty("-webkit-text-fill-color","transparent")),e.textFill==="none"&&(t.style.color=(o=(r=e.textOutlineColor)!=null?r:e.color)!=null?o:"transparent",t.style.setProperty("-webkit-text-fill-color","transparent")),e.textOutlineColor&&t.style.setProperty("-webkit-text-stroke",`1px ${e.textOutlineColor}`),e.textShadow&&(t.style.textShadow=_t(e.textShadow,n)),e.bold!==void 0&&(t.style.fontWeight=e.bold?"700":"400"),e.italic!==void 0&&(t.style.fontStyle=e.italic?"italic":"normal"),e.underline!==void 0&&(t.style.textDecorationLine=e.underline?"underline":"none");}function Ve(t,e){var i;let n=(i=t==null?void 0:t.toLowerCase())!=null?i:"";return n==="image/png"||n==="image/jpeg"||n==="image/jpg"||n==="image/gif"||n==="image/webp"||n==="image/svg+xml"?true:!!(e&&/\.(?:png|jpe?g|gif|webp|svg)$/i.test(e))}function Fe(t,e){if(e==="distributed"){t.style.textAlign="justify",t.style.textAlignLast="justify";return}t.style.textAlign=e==="justify"?"justify":e;}function Ft(t){if(t.customGeometry)return false;let e=t.presetGeometry,n=Math.min(t.bounds.width,t.bounds.height),i=Math.max(t.bounds.width,t.bounds.height);return (e==="line"||e==="straightConnector1")&&i>0&&(n===0||n/i<.02)}function Ht(t){return t.bounds.height>t.bounds.width?"vertical":"horizontal"}function Be(t,e={}){var n;if(t!=null&&t.imagePath){let i=e[t.imagePath],r=i==null?void 0:i.url;if(r&&Ve(i.contentType,t.imagePath))return `url("${r}") center / cover no-repeat`}return t!=null&&t.fillGradient&&t.fillGradient.colors.length>1?Y(t.fillGradient):(n=t==null?void 0:t.fillColor)!=null?n:"#fff"}function Ri(t,e,n,i,r,o){if(e!=null&&e.imagePath){let s=o[e.imagePath],a=s==null?void 0:s.url;if(a&&Ve(s.contentType,e.imagePath)){t.style.backgroundImage=`url("${a}")`,t.style.backgroundRepeat="no-repeat",t.style.backgroundSize=`${i.size.width*r}px ${i.size.height*r}px`,t.style.backgroundPosition=`${-n.bounds.left*r}px ${-n.bounds.top*r}px`;return}}t.style.background=Be(e,o);}function _(t){var i;let e=(i=t.presetAdjustments)==null?void 0:i.adj,n=e===void 0?.08:Math.max(0,Math.min(.5,e/1e5));return Math.min(t.bounds.width,t.bounds.height)*n}function Bi(t,e){var r,o,s;let n=(s=(r=t.presetAdjustments)==null?void 0:r.adj)!=null?s:(o=t.presetAdjustments)==null?void 0:o.adj1,i=n===void 0?.125:Math.max(.02,Math.min(.45,n/1e5));return Math.max(1,Math.min(t.bounds.width,t.bounds.height)*i*e)}function Oi(t){return !t.customGeometry&&t.kind!=="line"&&!t.lineColor&&!!t.lineGradient&&t.lineGradient.colors.length>1&&(t.presetGeometry==="roundRect"||t.presetGeometry==="round1Rect"||t.presetGeometry==="ellipse")}function Vi(t,e,n){var r;let i=document.createElement("div");return i.className="coco-ppt-css-geometry",i.style.clipPath=n,t.fillGradient&&t.fillGradient.colors.length>1?i.style.background=Y(t.fillGradient,K(t)):t.fillColor&&(i.style.background=q(t.fillColor,K(t))),t.lineColor&&(i.style.borderStyle=He(t.lineDash),i.style.borderWidth=`${Math.max(1,((r=t.lineWidth)!=null?r:9525)*e)}px`,i.style.borderColor=q(t.lineColor,t.lineOpacity)),i}function Y(t,e=1){return `linear-gradient(${zt(t)}deg, ${Hi(t,e).join(", ")})`}function zt(t){return t.angle===void 0?160:Fi(t.angle+90)}function Fi(t){return (t%360+360)%360}function Hi(t,e=1){return zi(t).map(n=>{let i=Math.max(0,Math.min(1,n.opacity*e)),r=i<1?Dt(n.color,i):n.color;return n.position===void 0?r:`${r} ${n.position}%`})}function zi(t){return t.colors.map((e,n)=>{var s,a,l,d,c;let i=ze(e),r=(s=t.positions)==null?void 0:s[n],o=Math.max(0,Math.min(1,(d=(l=(a=t.opacities)==null?void 0:a[n])!=null?l:i==null?void 0:i.opacity)!=null?d:1));return {color:(c=i==null?void 0:i.color)!=null?c:e,position:r===void 0?void 0:Math.max(0,Math.min(100,r)),opacity:o,index:n}}).sort((e,n)=>e.position===void 0&&n.position===void 0?e.index-n.index:e.position===void 0?1:n.position===void 0?-1:e.position-n.position||e.index-n.index).map(({color:e,position:n,opacity:i})=>({color:e,position:n,opacity:i}))}function Dt(t,e){var s;let n=(s=t.match(/^#([0-9a-fA-F]{6})$/))==null?void 0:s[1];if(!n)return t;let i=Number.parseInt(n.slice(0,2),16),r=Number.parseInt(n.slice(2,4),16),o=Number.parseInt(n.slice(4,6),16);return `rgba(${i}, ${r}, ${o}, ${Math.max(0,Math.min(1,e))})`}function Di(t){switch(t){case "parallelogram":return "polygon(18% 0, 100% 0, 82% 100%, 0 100%)";case "trapezoid":return "polygon(18% 0, 82% 0, 100% 100%, 0 100%)";case "snip2DiagRect":return "polygon(8% 0, 100% 0, 100% 92%, 92% 100%, 0 100%, 0 8%)";case "rtTriangle":return "polygon(0 0, 100% 100%, 0 100%)";case "triangle":return "polygon(50% 0, 100% 100%, 0 100%)";case "diamond":return "polygon(50% 0, 100% 50%, 50% 100%, 0 50%)";case "pentagon":return "polygon(0 0, 72% 0, 100% 50%, 72% 100%, 0 100%, 22% 50%)";case "hexagon":return "polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%)";case "homePlate":return "polygon(50% 0, 100% 25%, 100% 100%, 0 100%, 0 25%)";case "leftRightArrow":return "polygon(0 50%, 18% 0, 82% 0, 100% 50%, 82% 100%, 18% 100%)";case "chevron":return "polygon(0 0, 72% 0, 100% 50%, 72% 100%, 0 100%, 28% 50%)";case "plaque":return "polygon(0 12%, 3% 12%, 3% 0, 97% 0, 97% 12%, 100% 12%, 100% 88%, 97% 88%, 97% 100%, 3% 100%, 3% 88%, 0 88%)";case "rightArrow":return "polygon(0 0, 78% 0, 100% 50%, 78% 100%, 0 100%)";case "leftArrow":return "polygon(22% 0, 100% 0, 100% 100%, 22% 100%, 0 50%)";case "bentArrow":return "polygon(0 0, 30% 0, 30% 58%, 82% 58%, 82% 35%, 100% 70%, 82% 100%, 82% 77%, 12% 77%, 12% 18%, 0 18%)";default:return}}function He(t){return t==="dot"||t==="sysDot"?"dotted":t&&t!=="solid"?"dashed":"solid"}function ke(t,e){if(!t||t==="solid"||e<=0)return;let n=Math.max(1,e),i=/^cust:(\d+):(\d+)$/i.exec(t);if(i){let r=Number(i[1])/1e5,o=Number(i[2])/1e5;if(r>0&&o>=0)return `${n*r} ${n*o}`}switch(t){case "dot":case "sysDot":return `${n} ${n*2}`;case "dash":case "sysDash":return `${n*4} ${n*2}`;case "dashDot":case "sysDashDot":return `${n*4} ${n*2} ${n} ${n*2}`;case "lgDash":return `${n*8} ${n*3}`;case "lgDashDot":return `${n*8} ${n*3} ${n} ${n*3}`;case "lgDashDotDot":return `${n*8} ${n*3} ${n} ${n*3} ${n} ${n*3}`;default:return `${n*4} ${n*2}`}}function Wt(t){return t.presetGeometry==="curvedUpArrow"||t.presetGeometry==="donut"||t.presetGeometry==="arc"||t.presetGeometry==="blockArc"||t.presetGeometry==="plaque"||t.presetGeometry==="parallelogram"||t.presetGeometry==="trapezoid"||t.presetGeometry==="snip2DiagRect"||t.presetGeometry==="rtTriangle"||t.presetGeometry==="triangle"||t.presetGeometry==="diamond"||t.presetGeometry==="pentagon"||t.presetGeometry==="hexagon"||t.presetGeometry==="homePlate"||t.presetGeometry==="leftRightArrow"||t.presetGeometry==="chevron"||t.presetGeometry==="rightArrow"||t.presetGeometry==="leftArrow"||t.presetGeometry==="bentArrow"}function Wi(t,e){var p,f,m;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-preset-geometry");let i=Math.max(1,t.bounds.width*e),r=Math.max(1,t.bounds.height*e),o=ji(t,e,i,r);(t.shadow||o>0)&&(n.style.overflow="visible"),n.setAttribute("viewBox","0 0 100 100"),n.setAttribute("preserveAspectRatio","none");let s=t.fillGradient&&t.fillGradient.colors.length>1?`coco-ppt-preset-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0,a=t.lineGradient&&t.lineGradient.colors.length>1?`coco-ppt-preset-line-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0;if(s&&t.fillGradient&&H(n,s,t.fillGradient),a&&t.lineGradient&&H(n,a,t.lineGradient),o>0){let b=document.createElementNS("http://www.w3.org/2000/svg","path");b.classList.add("coco-ppt-preset-extrusion"),b.setAttribute("d",wt(t)),(t.presetGeometry==="donut"||t.presetGeometry==="blockArc")&&b.setAttribute("fill-rule","evenodd"),b.setAttribute("fill",Ui(t)),b.setAttribute("transform",`translate(${j(o*.38)} ${j(o)})`),b.setAttribute("stroke","none"),n.append(b);}let l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",wt(t)),(t.presetGeometry==="donut"||t.presetGeometry==="blockArc")&&l.setAttribute("fill-rule","evenodd");let d=t.lineColor||t.lineGradient?Math.max(.5,((p=t.lineWidth)!=null?p:9525)*e*100/Math.max(i,r)):0;l.setAttribute("fill",t.presetGeometry==="arc"?"none":s?`url(#${s})`:(f=t.fillColor)!=null?f:"none");let c=K(t);c!==void 0&&t.presetGeometry!=="arc"&&l.setAttribute("fill-opacity",String(c)),l.setAttribute("stroke",a?`url(#${a})`:(m=t.lineColor)!=null?m:"none"),l.setAttribute("stroke-width",String(d)),t.lineOpacity!==void 0&&l.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,t.lineOpacity))));let u=ke(t.lineDash,d);return u&&l.setAttribute("stroke-dasharray",u),l.setAttribute("stroke-linejoin","round"),t.presetGeometry==="arc"&&(l.setAttribute("stroke-linecap","round"),Yi(n,l,t)),n.append(l),n}function ji(t,e,n,i){var s,a;let r=(a=(s=t.threeD)==null?void 0:s.extrusionHeight)!=null?a:0;if(r<=0||t.presetGeometry==="arc")return 0;let o=r*e*100/Math.max(n,i);return Math.max(.8,Math.min(3,o))}function Ui(t){var r,o,s,a,l;let e=(s=(o=(r=t.fillGradient)==null?void 0:r.colors[0])!=null?o:t.fillColor)!=null?s:"#64748B",n=ze(e),i=((a=t.threeD)==null?void 0:a.material)==="translucentPowder"?.12:.18;return Dt(_i((l=n==null?void 0:n.color)!=null?l:e,.8),i)}function _i(t,e){let n=/^#?([0-9a-f]{6})$/i.exec(t);if(!n)return t;let i=n[1],r=Number.parseInt(i.slice(0,2),16),o=Number.parseInt(i.slice(2,4),16),s=Number.parseInt(i.slice(4,6),16);return `#${Z(r*e)}${Z(o*e)}${Z(s*e)}`}function wt(t){switch(t.presetGeometry){case "curvedUpArrow":return ["M 16 88","C 3 61 9 28 38 13","C 60 2 87 9 97 34","L 82 36","C 74 22 59 18 45 24","C 23 33 17 61 28 82","Z","M 76 21","L 100 38","L 74 53","Z"].join(" ");case "donut":return ["M 50 2","A 48 48 0 1 1 49.99 2","M 50 27","A 23 23 0 1 0 50.01 27"].join(" ");case "blockArc":return Zi(t);case "plaque":return "M 4 0 H 96 Q 96 8 100 8 V 92 Q 96 92 96 100 H 4 Q 4 92 0 92 V 8 Q 4 8 4 0 Z";case "parallelogram":return "M 18 0 H 100 L 82 100 H 0 Z";case "trapezoid":return "M 18 0 H 82 L 100 100 H 0 Z";case "snip2DiagRect":return "M 8 0 H 100 V 92 L 92 100 H 0 V 8 Z";case "rtTriangle":return "M 0 0 L 100 100 H 0 Z";case "triangle":return "M 50 0 L 100 100 H 0 Z";case "diamond":return "M 50 0 L 100 50 L 50 100 L 0 50 Z";case "pentagon":return "M 0 0 H 72 L 100 50 L 72 100 H 0 L 22 50 Z";case "hexagon":return "M 25 0 H 75 L 100 50 L 75 100 H 25 L 0 50 Z";case "homePlate":return "M 50 0 L 100 25 V 100 H 0 V 25 Z";case "leftRightArrow":return "M 0 50 L 18 0 H 82 L 100 50 L 82 100 H 18 Z";case "chevron":return "M 0 0 H 72 L 100 50 L 72 100 H 0 L 28 50 Z";case "rightArrow":return "M 0 0 H 78 L 100 50 L 78 100 H 0 Z";case "leftArrow":return "M 22 0 H 100 V 100 H 22 L 0 50 Z";case "bentArrow":return "M 0 0 H 30 V 58 H 82 V 35 L 100 70 L 82 100 V 77 H 12 V 18 H 0 Z";case "arc":return Ki(t);default:return ""}}function Zi(t){var b,h,x,S,g,y;let e=((h=(b=t.presetAdjustments)==null?void 0:b.adj1)!=null?h:0)/6e4,n=((S=(x=t.presetAdjustments)==null?void 0:x.adj2)!=null?S:54e5)/6e4,i=qi(n-e),r=e+i,o=48,s=Math.max(.08,Math.min(.42,((y=(g=t.presetAdjustments)==null?void 0:g.adj3)!=null?y:25e3)/1e5)),a=o*(1-s),l=oe(e,o),d=oe(r,o),c=oe(r,a),u=oe(e,a),p=Math.abs(i)>180?1:0,f=i>=0?1:0,m=f?0:1;return [`M ${l.x.toFixed(3)} ${l.y.toFixed(3)}`,`A ${o} ${o} 0 ${p} ${f} ${d.x.toFixed(3)} ${d.y.toFixed(3)}`,`L ${c.x.toFixed(3)} ${c.y.toFixed(3)}`,`A ${a.toFixed(3)} ${a.toFixed(3)} 0 ${p} ${m} ${u.x.toFixed(3)} ${u.y.toFixed(3)}`,"Z"].join(" ")}function qi(t){if(!Number.isFinite(t)||t===0)return 90;let e=t%360;return e>330&&(e=330),e<-330&&(e=-330),Math.abs(e)<8&&(e=e<0?-8:8),e}function Ki(t){var a,l,d,c,u,p,f,m;let e=vt((l=(a=t.presetAdjustments)==null?void 0:a.adj1)!=null?l:18e6),n=vt((c=(d=t.presetAdjustments)==null?void 0:d.adj2)!=null?c:0),i=((p=(u=t.presetAdjustments)==null?void 0:u.adj1)!=null?p:18e6)/6e4,s=((((m=(f=t.presetAdjustments)==null?void 0:f.adj2)!=null?m:0)/6e4-i)%360+360)%360>180?1:0;return `M ${e.x.toFixed(3)} ${e.y.toFixed(3)} A 48 48 0 ${s} 1 ${n.x.toFixed(3)} ${n.y.toFixed(3)}`}function vt(t){return oe(t/6e4,48)}function oe(t,e){let n=t/180*Math.PI;return {x:50+e*Math.cos(n),y:50+e*Math.sin(n)}}function Yi(t,e,n){var s,a;if(n.lineHeadEnd!=="triangle"&&n.lineTailEnd!=="triangle")return;let i=`coco-ppt-arc-arrow-${n.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`,r=document.createElementNS("http://www.w3.org/2000/svg","marker");r.setAttribute("id",i),r.setAttribute("viewBox","0 0 10 10"),r.setAttribute("markerWidth","7"),r.setAttribute("markerHeight","7"),r.setAttribute("refX","5"),r.setAttribute("refY","5"),r.setAttribute("orient","auto-start-reverse");let o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d","M 0 0 L 10 5 L 0 10 Z"),o.setAttribute("fill",(a=(s=n.lineColor)!=null?s:n.fillColor)!=null?a:"#000000"),r.append(o),t.append(r),n.lineHeadEnd==="triangle"&&e.setAttribute("marker-start",`url(#${i})`),n.lineTailEnd==="triangle"&&e.setAttribute("marker-end",`url(#${i})`);}function Xi(t,e){if(!t.customGeometry||Qi(t.customGeometry))return false;let n=Math.max(0,t.bounds.width)*Math.max(0,t.bounds.height),i=Math.max(1,e.size.width*e.size.height),r=n/i>.85,o=Math.abs(t.bounds.left)<e.size.width*.05&&Math.abs(t.bounds.top)<e.size.height*.05;return !(r&&o)}function Qi(t){var a,l;if(t.paths.length!==1)return false;let e=t.paths[0];if(!e)return false;let n=(a=e.width)!=null?a:0,i=(l=e.height)!=null?l:0;if(n<=0||i<=0)return false;let r=[];for(let d of e.commands)if(d.kind==="moveTo"||d.kind==="lineTo")r.push({x:d.x,y:d.y});else if(d.kind!=="close")return false;let o=Ji(r);return o.length!==4&&o.length!==5?false:[{x:0,y:0},{x:n,y:0},{x:n,y:i},{x:0,y:i}].every(d=>o.some(c=>Ee(c.x,d.x)&&Ee(c.y,d.y)))}function Ji(t){let e=[];for(let n of t)e.some(i=>Ee(i.x,n.x)&&Ee(i.y,n.y))||e.push(n);return e}function Ee(t,e){return Math.abs(t-e)<=1}function er(t,e){var c,u,p,f,m,b,h,x;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-custom-geometry","coco-ppt-picture-clip");let i=Math.max(1,(p=(u=(c=t.customGeometry)==null?void 0:c.paths[0])==null?void 0:u.width)!=null?p:t.bounds.width),r=Math.max(1,(b=(m=(f=t.customGeometry)==null?void 0:f.paths[0])==null?void 0:m.height)!=null?b:t.bounds.height);n.setAttribute("viewBox",`0 0 ${i} ${r}`),n.setAttribute("preserveAspectRatio","none");let o=`coco-ppt-picture-clip-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`,s=document.createElementNS("http://www.w3.org/2000/svg","defs"),a=document.createElementNS("http://www.w3.org/2000/svg","clipPath");a.setAttribute("id",o);for(let S of (x=(h=t.customGeometry)==null?void 0:h.paths)!=null?x:[]){let g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d",Ut(S.commands)),jt(S.commands)&&g.setAttribute("fill-rule","evenodd"),a.append(g);}s.append(a),n.append(s);let l=document.createElementNS("http://www.w3.org/2000/svg","image");l.setAttribute("href",e),l.setAttributeNS("http://www.w3.org/1999/xlink","href",e);let d=tr(t,i,r);return l.setAttribute("x",String(d.x)),l.setAttribute("y",String(d.y)),l.setAttribute("width",String(d.width)),l.setAttribute("height",String(d.height)),l.setAttribute("preserveAspectRatio","none"),l.setAttribute("clip-path",`url(#${o})`),t.imageOpacity!==void 0&&l.setAttribute("opacity",String(Math.max(0,Math.min(1,t.imageOpacity)))),n.append(l),n}function tr(t,e,n){var c,u,p,f,m,b,h,x;if(t.imageFillRect){let S=(c=t.imageFillRect.left)!=null?c:0,g=(u=t.imageFillRect.right)!=null?u:0,y=(p=t.imageFillRect.top)!=null?p:0,P=(f=t.imageFillRect.bottom)!=null?f:0;return {x:S*e,y:y*n,width:Math.max(.01,1-S-g)*e,height:Math.max(.01,1-y-P)*n}}let i=t.imageCrop;if(!i)return {x:0,y:0,width:e,height:n};let r=(m=i.left)!=null?m:0,o=(b=i.right)!=null?b:0,s=(h=i.top)!=null?h:0,a=(x=i.bottom)!=null?x:0,l=Math.max(.01,1-r-o),d=Math.max(.01,1-s-a);return {x:-r/l*e,y:-s/d*n,width:1/l*e,height:1/d*n}}function nr(t,e){var a,l,d,c,u,p,f,m,b,h;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-custom-geometry");let i=(d=(l=(a=t.customGeometry)==null?void 0:a.paths[0])==null?void 0:l.width)!=null?d:t.bounds.width,r=(p=(u=(c=t.customGeometry)==null?void 0:c.paths[0])==null?void 0:u.height)!=null?p:t.bounds.height;n.setAttribute("viewBox",`0 0 ${Math.max(1,i)} ${Math.max(1,r)}`),n.setAttribute("preserveAspectRatio","none");let o=t.fillGradient&&t.fillGradient.colors.length>1?`coco-ppt-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0,s=t.lineGradient&&t.lineGradient.colors.length>1?`coco-ppt-custom-line-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0;o&&t.fillGradient&&H(n,o,t.fillGradient),s&&t.lineGradient&&H(n,s,t.lineGradient);for(let x of (m=(f=t.customGeometry)==null?void 0:f.paths)!=null?m:[]){let S=rr(t,x),g=ir(x),y=g?document.createElementNS("http://www.w3.org/2000/svg","ellipse"):document.createElementNS("http://www.w3.org/2000/svg","path");g?(y.setAttribute("cx",String(g.cx)),y.setAttribute("cy",String(g.cy)),y.setAttribute("rx",String(g.rx)),y.setAttribute("ry",String(g.ry))):(y.setAttribute("d",Ut(x.commands)),jt(x.commands)&&y.setAttribute("fill-rule","evenodd"));let P=!(t.kind==="line"&&t.lineDash);y.setAttribute("fill",P?o?`url(#${o})`:(b=t.fillColor)!=null?b:"none":"none");let w=K(t);P&&w!==void 0&&y.setAttribute("fill-opacity",String(w)),y.setAttribute("stroke",s?`url(#${s})`:(h=t.lineColor)!=null?h:"none"),y.setAttribute("stroke-width",String(S)),t.lineOpacity!==void 0&&y.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,t.lineOpacity))));let E=ke(t.lineDash,S);E&&y.setAttribute("stroke-dasharray",E),y.setAttribute("stroke-linejoin","round"),y.setAttribute("stroke-linecap","round"),n.append(y);}return n}function ir(t){var c,u,p,f,m,b;let e=t.width,n=t.height;if(!e||!n||e<=0||n<=0)return;let i=t.commands;if(i.length!==6||((c=i[0])==null?void 0:c.kind)!=="moveTo"||((u=i[1])==null?void 0:u.kind)!=="cubicBezierTo"||((p=i[2])==null?void 0:p.kind)!=="cubicBezierTo"||((f=i[3])==null?void 0:f.kind)!=="cubicBezierTo"||((m=i[4])==null?void 0:m.kind)!=="cubicBezierTo"||((b=i[5])==null?void 0:b.kind)!=="close")return;let r=e/2,o=n/2,s=[i[0],i[1],i[2],i[3],i[4]],a=[{x:e,y:o},{x:r,y:n},{x:0,y:o},{x:r,y:0},{x:e,y:o}],l=Math.max(e,n)*.003;return s.every((h,x)=>h.kind!=="moveTo"&&h.kind!=="cubicBezierTo"?false:Math.abs(h.x-a[x].x)<=l&&Math.abs(h.y-a[x].y)<=l)?{cx:r,cy:o,rx:e/2,ry:n/2}:void 0}function jt(t){return t.filter(e=>e.kind==="moveTo").length>1}function rr(t,e){if(!t.lineWidth)return 0;let n=e.width&&t.bounds.width?e.width/t.bounds.width:void 0,i=e.height&&t.bounds.height?e.height/t.bounds.height:void 0,r=[n,i].filter(s=>s!==void 0&&Number.isFinite(s)&&s>0),o=r.length>0?Math.max(...r):1;return Math.max(.5,t.lineWidth*o)}function or(t,e){var c;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-gradient-outline");let i=Math.max(1,t.bounds.width*e),r=Math.max(1,t.bounds.height*e),o=Math.max(1,((c=t.lineWidth)!=null?c:9525)*e),s=o/2,a=`coco-ppt-line-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`;n.setAttribute("viewBox",`0 0 ${i} ${r}`),n.setAttribute("preserveAspectRatio","none"),H(n,a,t.lineGradient);let l=t.presetGeometry==="ellipse"?document.createElementNS("http://www.w3.org/2000/svg","ellipse"):document.createElementNS("http://www.w3.org/2000/svg","rect");l.tagName==="ellipse"?(l.setAttribute("cx",String(i/2)),l.setAttribute("cy",String(r/2)),l.setAttribute("rx",String(Math.max(0,i/2-s))),l.setAttribute("ry",String(Math.max(0,r/2-s)))):(l.setAttribute("x",String(s)),l.setAttribute("y",String(s)),l.setAttribute("width",String(Math.max(0,i-o))),l.setAttribute("height",String(Math.max(0,r-o))),l.setAttribute("rx",String(Math.max(0,_(t)*e-s))),l.setAttribute("ry",String(Math.max(0,_(t)*e-s)))),l.setAttribute("fill","none"),l.setAttribute("stroke",`url(#${a})`),l.setAttribute("stroke-width",String(o)),t.lineOpacity!==void 0&&l.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,t.lineOpacity))));let d=ke(t.lineDash,o);return d&&l.setAttribute("stroke-dasharray",d),n.append(l),n}function sr(t,e){var c,u;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-solid-outline");let i=Math.max(1,t.bounds.width*e),r=Math.max(1,t.bounds.height*e),o=Math.max(1,((c=t.lineWidth)!=null?c:9525)*e),s=t.kind!=="picture",a=s?o/2:0;s||(n.style.overflow="visible"),n.setAttribute("viewBox",`0 0 ${i} ${r}`),n.setAttribute("preserveAspectRatio","none");let l=t.presetGeometry==="ellipse"?document.createElementNS("http://www.w3.org/2000/svg","ellipse"):document.createElementNS("http://www.w3.org/2000/svg","rect");if(l.tagName==="ellipse")l.setAttribute("cx",String(i/2)),l.setAttribute("cy",String(r/2)),l.setAttribute("rx",String(Math.max(0,i/2-a))),l.setAttribute("ry",String(Math.max(0,r/2-a)));else {l.setAttribute("x",String(a)),l.setAttribute("y",String(a)),l.setAttribute("width",String(Math.max(0,i-a*2))),l.setAttribute("height",String(Math.max(0,r-a*2)));let p=t.presetGeometry==="roundRect"||t.presetGeometry==="round1Rect"?Math.max(0,_(t)*e-a):0;l.setAttribute("rx",String(p)),l.setAttribute("ry",String(p));}l.setAttribute("fill","none"),l.setAttribute("stroke",(u=t.lineColor)!=null?u:"none"),l.setAttribute("stroke-width",String(o)),t.lineOpacity!==void 0&&l.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,t.lineOpacity))));let d=ke(t.lineDash,o);return d&&l.setAttribute("stroke-dasharray",d),n.append(l),n}function ar(t,e){var m,b;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-line-geometry");let i=Ht(t)==="vertical",r=Math.max(i?12:1,t.bounds.width*e),o=Math.max(i?1:12,t.bounds.height*e);n.setAttribute("viewBox",`0 0 ${r} ${o}`),n.setAttribute("preserveAspectRatio","none");let s=Math.max(1,((m=t.lineWidth)!=null?m:9525)*e),a=t.lineGradient&&t.lineGradient.colors.length>1?`coco-ppt-connector-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0;a&&t.lineGradient&&H(n,a,t.lineGradient);let l=a?`url(#${a})`:q((b=t.lineColor)!=null?b:"#000000",t.lineOpacity),d=lr(s),c=Math.max(5,s*3.2),u=Math.max(5,s*2.6),p=Et(t.lineHeadEnd),f=Et(t.lineTailEnd);if(i){let h=r/2,x=p?Math.min(o,c):0,S=f?Math.max(0,o-c):o;X(n,h,x,h,S,l,s,t.lineOpacity,t.lineCap),t.lineHeadEnd==="oval"&&V(n,h,0,d,l),t.lineTailEnd==="oval"&&V(n,h,o,d,l),p&&Pe(n,h,0,"up",c,u,l,t.lineOpacity),f&&Pe(n,h,o,"down",c,u,l,t.lineOpacity);}else {let h=o/2,x=p?Math.min(r,c):0,S=f?Math.max(0,r-c):r;X(n,x,h,S,h,l,s,t.lineOpacity,t.lineCap),t.lineHeadEnd==="oval"&&V(n,0,h,d,l),t.lineTailEnd==="oval"&&V(n,r,h,d,l),p&&Pe(n,0,h,"left",c,u,l,t.lineOpacity),f&&Pe(n,r,h,"right",c,u,l,t.lineOpacity);}return n}function lr(t){return Math.max(3,t*3)}function Et(t){return t==="arrow"||t==="triangle"}function Ut(t){let e=[],n;for(let i of t)if(i.kind==="moveTo")e.push(`M ${i.x} ${i.y}`),n={x:i.x,y:i.y};else if(i.kind==="lineTo")e.push(`L ${i.x} ${i.y}`),n={x:i.x,y:i.y};else if(i.kind==="cubicBezierTo")e.push(`C ${i.x1} ${i.y1} ${i.x2} ${i.y2} ${i.x} ${i.y}`),n={x:i.x,y:i.y};else if(i.kind==="arcTo"){let r=dr(i,n);r&&(e.push(r.path),n=r.end);}else e.push("Z");return e.join(" ")}function dr(t,e){if(!e||t.wR<=0||t.hR<=0||t.swAng===0)return;let n=t.stAng/6e4,i=t.swAng/6e4,r=n+i,o=Mt(t.wR,t.hR,n),s={x:e.x-o.x,y:e.y-o.y},a=Mt(t.wR,t.hR,r),l={x:s.x+a.x,y:s.y+a.y},d=Math.abs(i)>180?1:0,c=i>=0?1:0;return {path:`A ${j(t.wR)} ${j(t.hR)} 0 ${d} ${c} ${j(l.x)} ${j(l.y)}`,end:l}}function Mt(t,e,n){let i=n/180*Math.PI;return {x:t*Math.cos(i),y:e*Math.sin(i)}}function j(t){return Number.isInteger(t)?String(t):t.toFixed(3).replace(/\.?0+$/,"")}function H(t,e,n){let i=document.createElementNS("http://www.w3.org/2000/svg","defs"),r=Array.isArray(n)?n:n.colors,o=Array.isArray(n)?void 0:n.positions,s=Array.isArray(n)?void 0:n.opacities,a=document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),l=Array.isArray(n)?{x1:0,y1:0,x2:100,y2:100}:cr(zt(n));a.setAttribute("id",e),a.setAttribute("x1",`${l.x1}%`),a.setAttribute("y1",`${l.y1}%`),a.setAttribute("x2",`${l.x2}%`),a.setAttribute("y2",`${l.y2}%`),r.map((d,c)=>{var m,b,h,x;let u=(m=o==null?void 0:o[c])!=null?m:c/Math.max(1,r.length-1)*100,p=ze(d),f=Math.max(0,Math.min(1,(h=(b=s==null?void 0:s[c])!=null?b:p==null?void 0:p.opacity)!=null?h:1));return {color:(x=p==null?void 0:p.color)!=null?x:d,offset:Math.max(0,Math.min(100,u)),opacity:f}}).sort((d,c)=>d.offset-c.offset).forEach(d=>{let c=document.createElementNS("http://www.w3.org/2000/svg","stop");c.setAttribute("offset",`${d.offset}%`),c.setAttribute("stop-color",d.color),d.opacity<1&&c.setAttribute("stop-opacity",String(d.opacity)),a.append(c);}),i.append(a),t.append(i);}function cr(t){let e=t*Math.PI/180,n=Math.sin(e),i=-Math.cos(e),r=50/Math.max(Math.abs(n),Math.abs(i),1e-4);return {x1:xe(50-n*r),y1:xe(50-i*r),x2:xe(50+n*r),y2:xe(50+i*r)}}function xe(t){return Math.round(Math.max(0,Math.min(100,t))*1e3)/1e3}function ze(t){let e=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*([0-9.]+)\s*)?\)$/i.exec(t);if(!e)return;let n=Math.max(0,Math.min(255,Number(e[1]))),i=Math.max(0,Math.min(255,Number(e[2]))),r=Math.max(0,Math.min(255,Number(e[3]))),o=e[4]===void 0?1:Math.max(0,Math.min(1,Number(e[4])));return {color:`#${Z(n)}${Z(i)}${Z(r)}`,opacity:o}}function Z(t){return Math.round(t).toString(16).padStart(2,"0").toUpperCase()}function ur(t,e,n=true){var d,c,u,p,f,m,b,h,x,S,g,y,P,w,E;let i=document.createElement("table");i.className="coco-ppt-table";let r=t.table;if(!r)return i;let o=Math.max(r.rowCount,r.values.length),s=Math.max(r.columnCount,...r.values.map(v=>v.length),1),a=(c=(d=r.columnWidths)==null?void 0:d.reduce((v,k)=>v+k,0))!=null?c:0;if(a>0){let v=document.createElement("colgroup");for(let k=0;k<s;k++){let L=document.createElement("col"),$=(u=r.columnWidths)==null?void 0:u[k];$&&(L.style.width=`${$/a*100}%`),v.append(L);}i.append(v);}let l=(f=(p=r.rowHeights)==null?void 0:p.reduce((v,k)=>v+k,0))!=null?f:0;for(let v=0;v<o;v++){let k=document.createElement("tr"),L=(m=r.rowHeights)==null?void 0:m[v];k.style.height=l>0&&L?`${L/l*100}%`:`${100/o}%`;for(let $=0;$<s;$++){let T=gr(r,v,$);if(T!=null&&T.hMerge||T!=null&&T.vMerge)continue;let A=document.createElement("td"),N=(h=(b=r.cellStyles)==null?void 0:b[v])==null?void 0:h[$];n&&(A.dataset.row=String(v),A.dataset.column=String($));let Q=(S=(x=r.values[v])==null?void 0:x[$])!=null?S:"";if(A.dataset.cellText=Q,hr(A,Q),T!=null&&T.columnSpan&&T.columnSpan>1&&(A.colSpan=T.columnSpan),T!=null&&T.rowSpan&&T.rowSpan>1&&(A.rowSpan=T.rowSpan),N!=null&&N.fillGradient&&N.fillGradient.colors.length>1?A.style.background=Y(N.fillGradient):N!=null&&N.fillColor&&!fr(N.fillColor)&&(A.style.background=N.fillColor),N!=null&&N.body){let I=N.body,B=(g=I.insetLeft)!=null?g:91440,le=(y=I.insetTop)!=null?y:45720,de=(P=I.insetRight)!=null?P:91440,Jt=(w=I.insetBottom)!=null?w:45720;A.style.padding=`${le*e}px ${de*e}px ${Jt*e}px ${B*e}px`,I.anchor==="middle"&&(A.style.verticalAlign="middle"),I.anchor==="bottom"&&(A.style.verticalAlign="bottom"),I.anchor==="top"&&(A.style.verticalAlign="top");}N!=null&&N.textStyle&&Oe(A,N.textStyle,e),(E=N==null?void 0:N.textStyle)!=null&&E.alignment&&Fe(A,N.textStyle.alignment),pr(A,N,e),k.append(A);}i.append(k);}return i}function pr(t,e,n){let i=e==null?void 0:e.borders;i&&(Se(t,"Left",i.left,n),Se(t,"Right",i.right,n),Se(t,"Top",i.top,n),Se(t,"Bottom",i.bottom,n));}function Se(t,e,n,i){var a,l;if(!n)return;let r=`border${e}Style`,o=`border${e}Width`,s=`border${e}Color`;if(n.hidden){t.style[r]="none",t.style[o]="0";return}t.style[r]=He(n.dash),t.style[o]=`${Math.max(1,((a=n.width)!=null?a:9525)*i)}px`,t.style[s]=q((l=n.color)!=null?l:"#94A3B8",n.opacity);}function hr(t,e){let n=e.split(/\r?\n/);if(n.length<=1){t.textContent=e;return}n.forEach((i,r)=>{r>0&&t.append(document.createElement("br"));let o=document.createElement("span");o.textContent=i,r>0&&(o.className="coco-ppt-table-cell-secondary-line",o.style.fontSize="0.7em",o.style.fontWeight="400"),t.append(o);});}function Ct(t,e,n,i){var r,o,s,a,l;return (l=(a=(s=t.dataset.cellText)!=null?s:(o=(r=e.table)==null?void 0:r.values[n])==null?void 0:o[i])!=null?a:t.textContent)!=null?l:""}function fr(t){let e=/^#?([0-9a-f]{6})$/i.exec(t);if(!e)return false;let n=e[1],i=Number.parseInt(n.slice(0,2),16),r=Number.parseInt(n.slice(2,4),16),o=Number.parseInt(n.slice(4,6),16);return (.2126*i+.7152*r+.0722*o)/255>.9}function _t(t,e){var a,l,d;let n=((a=t.distance)!=null?a:0)*e,i=((l=t.direction)!=null?l:0)*Math.PI/180,r=Math.cos(i)*n,o=Math.sin(i)*n,s=((d=t.blur)!=null?d:0)*e;return `${r}px ${o}px ${s}px ${mr(t)}`}function mr(t){var l,d;let e=(l=t.color)!=null?l:"#000000",n=(d=t.opacity)!=null?d:.25,i=/^#?([0-9a-f]{6})$/i.exec(e);if(!i)return e;let r=i[1],o=Number.parseInt(r.slice(0,2),16),s=Number.parseInt(r.slice(2,4),16),a=Number.parseInt(r.slice(4,6),16);return `rgba(${o}, ${s}, ${a}, ${Math.max(0,Math.min(1,n))})`}function gr(t,e,n){var i;return (i=t.mergedCells)==null?void 0:i.find(r=>r.row===e&&r.column===n)}function br(t){var h,x,S,g,y,P,w,E,v,k,L,$,T,A,N,Q;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 100 60"),e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("preserveAspectRatio","none");let n=(h=t.chart)==null?void 0:h.data;if(!(n!=null&&n.series.length))return R(e,(x=t.name)!=null?x:"Chart",4,8,4,"#17202a"),e;let i=(g=(S=t.chart)==null?void 0:S.type)!=null?g:"",r=(y=t.chart)==null?void 0:y.grouping,o=yr(n.series,i,r),s=Math.max(...o,1),a=Math.min(...o,0),l=(w=(P=t.chart)==null?void 0:P.axes)==null?void 0:w.value,d=(v=(E=t.chart)==null?void 0:E.axes)==null?void 0:v.category,c=(k=l==null?void 0:l.min)!=null?k:a>=0?0:a,u=(L=l==null?void 0:l.max)!=null?L:a>=0?Pr(s):s,p=xr(t),f=wr(c,u,l==null?void 0:l.majorUnit);if(i.includes("doughnut")||i.includes("pie"))return $r(e,n.series,p),e;if(i.includes("radar"))return Vr(e,n.series,p,($=l==null?void 0:l.max)!=null?$:s),e;(l==null?void 0:l.majorGridlines)!==false&&Mr(e,p,f,t,l,d),(l==null?void 0:l.deleted)!==true&&(l==null?void 0:l.tickLabelPosition)!=="none"&&Cr(e,p,c,u,f),vr(e,t,p);let m=n.series.filter(I=>{var B,le,de;return ((de=(le=I.type)!=null?le:(B=t.chart)==null?void 0:B.type)!=null?de:"").includes("bar")}),b=n.series.filter(I=>{var B;return ((B=I.type)!=null?B:"").includes("line")});return m.length>0?(Tr(e,m,p,c,u,t,r),Tt(e,(A=(T=m[0])==null?void 0:T.categories)!=null?A:[],p),m.some(I=>I.showValueLabels)&&Lr(e,m,p,c,u),b.length>0&&kt(e,b,p,c,u,void 0,t),b.some(I=>I.showValueLabels)&&At(e,b,p,c,u)):(kt(e,n.series,p,c,u,["#22C7F2","#22C7F2","#94A3B8","#F59E0B"],t),Tt(e,(Q=(N=n.series.find(I=>{var B;return (B=I.categories)==null?void 0:B.length}))==null?void 0:N.categories)!=null?Q:[],p),n.series.some(I=>I.showValueLabels)&&At(e,n.series,p,c,u)),e}function yr(t,e,n){var s;let i=t.filter(a=>{var l;return ((l=a.type)!=null?l:e).includes("bar")});if(!qt(n)||i.length<=1)return t.flatMap(a=>a.values);let r=Math.max(...i.map(a=>a.values.length),1),o=[];for(let a=0;a<r;a++){let l=0,d=0;for(let c of i){let u=(s=c.values[a])!=null?s:0;u>=0?l+=u:d+=u;}o.push(l,d);}return o}function xr(t){var c,u,p,f,m,b,h,x,S,g,y,P,w,E,v,k;let e=(c=t.chart)==null?void 0:c.plotLayout,n=(p=(u=t.chart)==null?void 0:u.type)!=null?p:"";if(!e)return Kt((b=(m=(f=t.chart)==null?void 0:f.data)==null?void 0:m.series)!=null?b:[])?{left:7,top:8,width:88,height:40}:Sr(t)?{left:18,top:8,width:72,height:40}:((S=(x=(h=t.chart)==null?void 0:h.axes)==null?void 0:x.value)==null?void 0:S.deleted)===true?{left:6,top:8,width:90,height:40}:{left:18,top:8,width:76,height:40};let r=((P=(y=(g=t.chart)==null?void 0:g.axes)==null?void 0:y.value)==null?void 0:P.deleted)!==true&&!n.includes("doughnut")&&!n.includes("pie")&&!n.includes("radar")?14:4,o=((w=e.x)!=null?w:.12)*100,s=((E=e.y)!=null?E:.13)*60,a=((v=e.width)!=null?v:.82)*100,l=((k=e.height)!=null?k:.67)*60,d=Math.max(r,Math.min(20,o));return {left:d,top:Math.max(3,Math.min(12,s)),width:Math.max(40,Math.min(92,Math.min(a,96-d))),height:Math.max(24,Math.min(50,l))}}function Sr(t){var o,s,a,l,d,c,u,p;let e=t.chart,n=(o=e==null?void 0:e.type)!=null?o:"";if(!e||!n.includes("bar")||e.plotLayout)return false;let i=(a=(s=e.data)==null?void 0:s.series)!=null?a:[];if(i.length!==1)return false;let r=Math.max((c=(d=(l=i[0])==null?void 0:l.categories)==null?void 0:d.length)!=null?c:0,(p=(u=i[0])==null?void 0:u.values.length)!=null?p:0);return r>0&&r<=2}function Pr(t){if(t<=0)return 1;if(t<=10)return Math.max(1,Math.ceil(t));let e=t*1.1,n=10**Math.floor(Math.log10(e));return Math.ceil(e/n)*n}function wr(t,e,n){let i=Math.abs(e-t);return n&&n>0?Math.max(1,Math.min(8,Math.round(i/n))):Number.isInteger(i)&&i>0&&i<=6?i:4}function vr(t,e,n){var d,c,u,p,f,m,b;let i=(p=(d=e.chart)==null?void 0:d.title)!=null?p:(u=(c=e.chart)==null?void 0:c.data)==null?void 0:u.title;i&&R(t,i,n.left+n.width*.5,Math.max(4,n.top-3.2),3.1,"#17202A","middle");let r=(b=(m=(f=e.chart)==null?void 0:f.data)==null?void 0:m.series)!=null?b:[],o=r.map(h=>h.name).filter(h=>!!h).slice(0,4);if(o.length===0)return;let s=["#C50D13","#0EA5E9","#F59E0B","#A3E635"],a=n.left+n.width*.78,l=Math.max(4,n.top-2.4);o.forEach((h,x)=>{var y,P,w,E,v,k;let S=(y=r.find(L=>L.name===h))!=null?y:r[x],g=S?Er(t,S,x,s):s[x];S&&((P=S.type)!=null?P:"").includes("line")?(X(t,a,l-1.1,a+2.3,l-1.1,g,.45),V(t,a+1.15,l-1.1,.45,(E=(w=S.marker)==null?void 0:w.fillColor)!=null?E:"#FFFFFF",(k=(v=S.marker)==null?void 0:v.lineColor)!=null?k:g,.32),R(t,h,a+2.8,l-.45,2.2,"#64748B")):(ae(t,a,l-1.8,1.4,1.4,g),R(t,h,a+2,l-.45,2.2,"#64748B")),a+=Math.max(9,Array.from(h).length*2.2+4.5);});}function Er(t,e,n,i){var r,o;return ((r=e.type)!=null?r:"").includes("line")?(o=e.lineColor)!=null?o:i[n]:Ne(t,e,n,i)}function Mr(t,e,n,i,r,o){var l,d;let s=(l=r==null?void 0:r.gridlineColor)!=null?l:"#E8EDF3",a=Nt(r==null?void 0:r.gridlineWidth,i,.35);for(let c=0;c<=n;c++){let u=e.top+e.height/n*c;X(t,e.left,u,e.left+e.width,u,s,a);}X(t,e.left,e.top+e.height,e.left+e.width,e.top+e.height,(d=o==null?void 0:o.lineColor)!=null?d:"#CBD5E1",Nt(o==null?void 0:o.lineWidth,i,.45));}function Cr(t,e,n,i,r){for(let o=0;o<=r;o++){let s=i-(i-n)/r*o,a=e.top+e.height/r*o+1;R(t,De(s),e.left-1.8,a,3,"#9AA6B2","end");}}function De(t){return Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,"")}function kt(t,e,n,i,r,o=["#CBD5E1","#94A3B8","#F59E0B","#A3E635"],s){e.forEach((a,l)=>{var p,f,m,b,h,x,S;if(a.values.length===0)return;let d=a.values.map((g,y)=>{let P=n.left+(a.values.length===1?n.width/2:n.width*y/(a.values.length-1)),w=n.top+n.height-(g-i)/Math.max(1,r-i)*n.height;return {x:P,y:w}}),c=Nr(d,a.smooth===true),u=(p=a.lineColor)!=null?p:o[l%o.length];if(Qt(t,c,u,Zt(a,s)),((f=a.marker)==null?void 0:f.symbol)!=="none"){let g=Math.max(.5,Math.min(1.6,((b=(m=a.marker)==null?void 0:m.size)!=null?b:5)*.18)),y=(x=(h=a.marker)==null?void 0:h.fillColor)!=null?x:u,P=(S=a.marker)==null?void 0:S.lineColor,w=kr(a,s);d.forEach(E=>V(t,E.x,E.y,g,y,P,w));}});}function kr(t,e){var n;if(!(!((n=t.marker)!=null&&n.lineWidth)||!(e!=null&&e.bounds.width)))return Math.max(.25,Math.min(1,t.marker.lineWidth/e.bounds.width*100))}function Zt(t,e){return !t.lineWidth||!(e!=null&&e.bounds.width)?.8:Math.max(.3,Math.min(1.2,t.lineWidth/e.bounds.width*100))}function Nr(t,e){if(t.length===0)return "";if(!e||t.length<3)return t.map((i,r)=>`${r===0?"M":"L"} ${i.x} ${i.y}`).join(" ");let n=[`M ${t[0].x} ${t[0].y}`];for(let i=0;i<t.length-1;i++){let r=t[Math.max(0,i-1)],o=t[i],s=t[i+1],a=t[Math.min(t.length-1,i+2)],l={x:o.x+(s.x-r.x)/6,y:o.y+(s.y-r.y)/6},d={x:s.x-(a.x-o.x)/6,y:s.y-(a.y-o.y)/6};n.push(`C ${l.x} ${l.y} ${d.x} ${d.y} ${s.x} ${s.y}`);}return n.join(" ")}function Tr(t,e,n,i,r,o,s){if(qt(s)&&e.length>1){Ir(t,e,n,i,r,o);return}if(Kt(e)){Ar(t,e,n,i,r,o);return}let a=["#C50D13","#0EA5E9","#F59E0B","#A3E635"],l=Math.max(...e.map(u=>u.values.length),1),d=n.width/l,c=Math.max(1,d*.48/Math.max(e.length,1));e.forEach((u,p)=>{let f=Ne(t,u,p,a);u.values.forEach((m,b)=>{var g,y;let h=(m-i)/Math.max(1,r-i)*n.height,x=n.left+b*d+(d-c*e.length)/2+p*c,S=n.top+n.height-h;ae(t,x,S,c,h,(y=(g=u.pointColors)==null?void 0:g[b])!=null?y:f,u.borderColor,We(u,o));});});}function Ar(t,e,n,i,r,o){let s=["#C50D13","#0EA5E9","#F59E0B","#A3E635"],a=Math.max(...e.map(c=>c.values.length),1),l=n.width/a,d=Math.max(1,l*.34);e.forEach((c,u)=>{let p=Ne(t,c,u,s);c.values.forEach((f,m)=>{var S,g;let b=Me(f,n,i,r),h=Me(0,n,i,r),x=n.left+m*l+(l-d)/2;ae(t,x,Math.min(b,h),d,Math.max(.1,Math.abs(h-b)),(g=(S=c.pointColors)==null?void 0:S[m])!=null?g:p,c.borderColor,We(c,o));});});}function Ir(t,e,n,i,r,o){let s=["#C50D13","#0EA5E9","#F59E0B","#A3E635"],a=Math.max(...e.map(p=>p.values.length),1),l=n.width/a,d=Math.max(1,l*.46),c=new Array(a).fill(Math.max(0,i)),u=new Array(a).fill(Math.min(0,r));e.forEach((p,f)=>{let m=Ne(t,p,f,s);p.values.forEach((b,h)=>{var w,E;let x=b>=0?c[h]:u[h],S=x+b,g=Me(x,n,i,r),y=Me(S,n,i,r),P=n.left+h*l+(l-d)/2;ae(t,P,Math.min(g,y),d,Math.max(.1,Math.abs(y-g)),(E=(w=p.pointColors)==null?void 0:w[h])!=null?E:m,p.borderColor,We(p,o)),b>=0?c[h]=S:u[h]=S;});});}function Me(t,e,n,i){return e.top+e.height-(t-n)/Math.max(1,i-n)*e.height}function qt(t){return t==="stacked"||t==="percentStacked"}function Kt(t){return new Set(t.map(n=>{var i;return (i=n.chartGroup)!=null?i:0})).size>1&&t.every(n=>!n.type||n.type.includes("bar"))}function We(t,e){if(t.borderWidth)return Yt(e!=null&&e.bounds.width?t.borderWidth/e.bounds.width*100:void 0,void 0)}function Nt(t,e,n){var i;return (i=Yt(t!==void 0&&e.bounds.width?t/e.bounds.width*100:void 0,n))!=null?i:n}function Yt(t,e){return t===void 0?e:Math.max(.15,Math.min(1.4,t))}function Ne(t,e,n,i){var r,o;if((r=e.fillGradient)!=null&&r.colors.length&&e.fillGradient.colors.length>1){let s=`coco-chart-gradient-${n}-${e.fillGradient.colors.join("-").replace(/[^a-zA-Z0-9_-]/g,"_")}`;return H(t,s,e.fillGradient),`url(#${s})`}return (o=e.fillColor)!=null?o:i[n%i.length]}function Gr(t,e,n){var i,r,o;return (o=(r=(i=t.pointColors)==null?void 0:i[e])!=null?r:t.fillColor)!=null?o:n[e%n.length]}function Tt(t,e,n){if(e.length===0)return;let i=n.width/e.length;e.forEach((r,o)=>{R(t,r,n.left+i*o+i/2,n.top+n.height+5.2,3.2,"#64748B","middle");});}function Lr(t,e,n,i,r){let o=Math.max(...e.map(l=>l.values.length),1),s=n.width/o,a=Math.max(1,s*.48/Math.max(e.length,1));e.forEach((l,d)=>{l.showValueLabels&&l.values.forEach((c,u)=>{let p=(c-i)/Math.max(1,r-i)*n.height,f=n.left+u*s+(s-a*e.length)/2+d*a+a/2,m=n.top+n.height-p-2;R(t,String(c),f,m,3,"#A7AEB8","middle");});});}function At(t,e,n,i,r){e.forEach(o=>{!o.showValueLabels||o.values.length===0||o.values.forEach((s,a)=>{let l=n.left+(o.values.length===1?n.width/2:n.width*a/(o.values.length-1)),d=n.top+n.height-(s-i)/Math.max(1,r-i)*n.height;R(t,String(s),l,Math.max(n.top+2,d-2.2),2.6,"#374151","middle");});});}function $r(t,e,n){var f;let i=e[0];if(!(i!=null&&i.values.length))return;let r=["#1D4ED8","#E3B363","#60A5FA","#94A3B8","#F59E0B","#22C7F2"],o=i.values.reduce((m,b)=>m+Math.max(0,b),0)||1,s=n.left+n.width*.42,a=n.top+n.height*.5,l=Math.min(n.width,n.height)*.34,d=l*.58,c=-90;i.values.forEach((m,b)=>{let h=Math.max(0,m)/o*360,x=c,S=c+h;if(Fr(t,s,a,l,d,x,S,Gr(i,b,r)),i.showCategoryNameLabels||i.showPercentLabels||i.showValueLabels){let g=Rr(i,m,b,o);if(g.length>0){let y=Br(i,b,s,a,l+3.6,n,(x+S)/2);Wr(t,g,y.x,y.y,1.9,"#334155",y.x>=s?"start":"end");}}c+=h;}),V(t,s,a,d*.92,"#FFFFFF");let u=Or(i.name);u&&R(t,u,s,a-1.8,1.8,"#64748B","middle");let p=i.values[0];p!==void 0&&R(t,Xt(p,o),s,a+3.4,3.9,"#1E3A8A","middle"),Hr(t,(f=i.categories)!=null?f:[],r,n.left+n.width*.72,n.top+9);}function Rr(t,e,n,i){var s;let r=[],o=(s=t.categories)==null?void 0:s[n];return t.showCategoryNameLabels&&o&&r.push(o),t.showValueLabels&&r.push(De(e)),t.showPercentLabels&&r.push(Xt(e,i)),r}function Br(t,e,n,i,r,o,s){return U(n,i,r,s)}function Xt(t,e){let i=(t>0&&t<=1&&e<=2?t:t/Math.max(1,e))*100;return `${Number.isInteger(i)?i.toFixed(0):i.toFixed(1)}%`}function Or(t){let e=(t!=null?t:"").trim();if(!e)return "";let n=Array.from(e);return n.length<=6?e:`${n.slice(0,5).join("")}\u2026`}function Vr(t,e,n,i){var d;let r=e[0];if(!(r!=null&&r.values.length))return;let o=r.values.length,s=n.left+n.width*.48,a=n.top+n.height*.5,l=Math.min(n.width,n.height)*.35;for(let c=1;c<=4;c++)Qt(t,zr(o,s,a,l*c/4),"#CBD5E1",.25);for(let c=0;c<o;c++){let u=we(c,o,s,a,l);X(t,s,a,u.x,u.y,"#E2E8F0",.25);}e.forEach((c,u)=>{var m;if(!c.values.length)return;let p=c.values.slice(0,o).map((b,h)=>we(h,o,s,a,Math.max(0,b)/Math.max(1,i)*l)),f=document.createElementNS("http://www.w3.org/2000/svg","path");f.setAttribute("d",p.map((b,h)=>`${h===0?"M":"L"} ${b.x} ${b.y}`).join(" ")+" Z"),f.setAttribute("fill",u===0?"rgba(37, 99, 235, 0.08)":"none"),f.setAttribute("stroke",(m=c.lineColor)!=null?m:"#2563EB"),f.setAttribute("stroke-width",String(Zt(c,void 0))),t.append(f),c.marker&&c.marker.symbol!=="none"&&p.forEach(b=>{var h;return V(t,b.x,b.y,.9,(h=c.lineColor)!=null?h:"#2563EB")}),c.showValueLabels&&c.values.slice(0,o).forEach((b,h)=>{var S;let x=p[h];R(t,De(b),x.x,x.y-1.2,2.2,(S=c.lineColor)!=null?S:"#2563EB","middle");});}),((d=r.categories)!=null?d:[]).slice(0,o).forEach((c,u)=>{let p=we(u,o,s,a,l+5);R(t,c,p.x,p.y+1,2.6,"#64748B","middle");});}function Fr(t,e,n,i,r,o,s,a){let d=Math.max(.01,s-o)>180?1:0,c=U(e,n,i,o),u=U(e,n,i,s),p=U(e,n,r,s),f=U(e,n,r,o),m=document.createElementNS("http://www.w3.org/2000/svg","path");m.setAttribute("d",[`M ${c.x} ${c.y}`,`A ${i} ${i} 0 ${d} 1 ${u.x} ${u.y}`,`L ${p.x} ${p.y}`,`A ${r} ${r} 0 ${d} 0 ${f.x} ${f.y}`,"Z"].join(" ")),m.setAttribute("fill",a),t.append(m);}function Hr(t,e,n,i,r){e.slice(0,6).forEach((o,s)=>{ae(t,i,r+s*5,2.4,2.4,n[s%n.length]),R(t,o,i+3.6,r+s*5+2.2,2.7,"#334155");});}function zr(t,e,n,i,r){return Array.from({length:t},(o,s)=>{let a=we(s,t,e,n,i);return `${s===0?"M":"L"} ${a.x} ${a.y}`}).join(" ")+(" Z")}function we(t,e,n,i,r){return U(n,i,r,-90+360*t/e)}function U(t,e,n,i){let r=i*Math.PI/180;return {x:t+Math.cos(r)*n,y:e+Math.sin(r)*n}}function X(t,e,n,i,r,o,s,a,l){let d=document.createElementNS("http://www.w3.org/2000/svg","line");d.setAttribute("x1",String(e)),d.setAttribute("y1",String(n)),d.setAttribute("x2",String(i)),d.setAttribute("y2",String(r)),d.setAttribute("stroke",o),d.setAttribute("stroke-width",String(s)),d.setAttribute("stroke-linecap",Dr(l)),a!==void 0&&d.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,a)))),t.append(d);}function Dr(t){return t==="rnd"?"round":t==="sq"?"square":"butt"}function Qt(t,e,n,i){let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",e),r.setAttribute("fill","none"),r.setAttribute("stroke",n),r.setAttribute("stroke-width",String(i)),r.setAttribute("stroke-linejoin","round"),r.setAttribute("stroke-linecap","round"),t.append(r);}function V(t,e,n,i,r,o,s){let a=document.createElementNS("http://www.w3.org/2000/svg","circle");a.setAttribute("cx",String(e)),a.setAttribute("cy",String(n)),a.setAttribute("r",String(i)),a.setAttribute("fill",r),o&&a.setAttribute("stroke",o),s!==void 0&&a.setAttribute("stroke-width",String(s)),t.append(a);}function Pe(t,e,n,i,r,o,s,a){let l=o/2,d=i==="right"?[[e,n],[e-r,n-l],[e-r,n+l]]:i==="left"?[[e,n],[e+r,n-l],[e+r,n+l]]:i==="down"?[[e,n],[e-l,n-r],[e+l,n-r]]:[[e,n],[e-l,n+r],[e+l,n+r]],c=document.createElementNS("http://www.w3.org/2000/svg","polygon");c.classList.add("coco-ppt-line-arrow"),c.setAttribute("points",d.map(u=>u.join(",")).join(" ")),c.setAttribute("fill",s),a!==void 0&&c.setAttribute("fill-opacity",String(Math.max(0,Math.min(1,a)))),t.append(c);}function ae(t,e,n,i,r,o,s,a){let l=document.createElementNS("http://www.w3.org/2000/svg","rect");l.setAttribute("x",String(e)),l.setAttribute("y",String(n)),l.setAttribute("width",String(i)),l.setAttribute("height",String(r)),l.setAttribute("fill",o),s&&a!==void 0&&(l.setAttribute("stroke",s),l.setAttribute("stroke-width",String(a))),t.append(l);}function R(t,e,n,i,r,o,s="start"){let a=document.createElementNS("http://www.w3.org/2000/svg","text");a.setAttribute("x",String(n)),a.setAttribute("y",String(i)),a.setAttribute("font-size",String(r)),a.setAttribute("fill",o),a.setAttribute("text-anchor",s),a.textContent=e,t.append(a);}function Wr(t,e,n,i,r,o,s="start"){e.forEach((a,l)=>{R(t,a,n,i+l*r*1.2,r,o,s);});}
|
|
78
|
-
exports.DEFAULT_PPT_SLIDE_SIZE=
|
|
75
|
+
`;let n=document.createElement("div");n.className="coco-ppt-editor",n.dataset.showSlideList=String(this.options.showSlideList!==false),n.dataset.readOnly=String(this.isReadOnly()),this.slideList.className="coco-ppt-slides";let i=document.createElement("div");i.className="coco-ppt-stage",this.canvas.className="coco-ppt-canvas",this.contextMenu.className="coco-ppt-context-menu",this.snapGuides.className="coco-ppt-snap-guides",i.append(this.canvas),n.append(this.slideList,i),this.root.append(e,n,this.contextMenu),this.canvas.addEventListener("click",this.handleCanvasClick),this.canvas.addEventListener("selectstart",this.handleCanvasSelectStart),this.slideList.addEventListener("scroll",this.handleSlideListScroll,{passive:true}),window.addEventListener("mousemove",this.handleWindowMouseMove),window.addEventListener("mouseup",this.handleWindowMouseUp),window.addEventListener("keydown",this.handleWindowKeyDown),window.addEventListener("pointerdown",this.handleWindowPointerDown),window.addEventListener("scroll",this.handleWindowScroll,true);}scheduleFontRenderRefresh(e){return typeof document=="undefined"||!document.fonts?Promise.resolve():e.then(()=>lt([...this.fontResources.map(n=>n.family),...this.referencedFontFamilies].map(n=>`16px ${Bt(n)}`))).then(()=>{this.render();}).catch(()=>{})}render(){let e=this.root.querySelector(".coco-ppt-editor");e&&(e.dataset.readOnly=String(this.isReadOnly()));let n=this.sessionValue.scene();this.slideList.replaceChildren(...this.options.showSlideList===false?[]:n.slides.map(o=>{var c;let s=document.createElement("button");s.className="coco-ppt-thumb",s.type="button",s.dataset.slideId=o.id,s.dataset.slideIndex=String(o.index),s.dataset.selected=((c=this.sessionValue.selection())==null?void 0:c.slideId)===o.id?"true":"false";let a=document.createElement("div");a.className="coco-ppt-thumb-preview";let l=document.createElement("div");l.className="coco-ppt-thumb-placeholder";let d=document.createElement("span");return d.className="coco-ppt-thumb-number",d.textContent=String(o.index+1),s.append(a,l,d),s.addEventListener("click",()=>{this.dispatch({kind:"select-slide",slideIdOrIndex:o.id});}),s})),this.options.showSlideList!==false&&this.renderVisibleThumbnails(n.slides);let i=this.currentSlide();if(!i){this.canvas.replaceChildren(),this.hideContextMenu();return}let r=this.computeScale(i);this.canvas.style.width=`${i.size.width*r}px`,this.canvas.style.height=`${i.size.height*r}px`,this.canvas.style.background=Re(i.background,this.imageResources),this.canvas.replaceChildren(...i.nodes.map(o=>this.renderNode(o,r,i)),this.snapGuides),this.hideSnapGuides(),this.hideContextMenu(),this.renderSelection();}renderVisibleThumbnails(e){let n=Array.from(this.slideList.querySelectorAll(".coco-ppt-thumb")),i=this.visibleThumbnailRange(e.length);n.forEach((r,o)=>{let s=r.querySelector(".coco-ppt-thumb-preview"),a=r.querySelector(".coco-ppt-thumb-placeholder");if(!s||!a)return;if(o<i.start||o>=i.end){s.replaceChildren(),delete r.dataset.previewRendered,delete r.dataset.previewMode,a.hidden=false;return}if(r.dataset.previewRendered==="true")return;let l=e[o];if(!l)return;let d=Ge(l),c=this.thumbnailCanvasCache.get(l.id);(c==null?void 0:c.fingerprint)===d?(s.replaceChildren(ht(c.canvas)),r.dataset.previewMode="canvas"):(s.replaceChildren(this.renderThumbnailSlide(l)),r.dataset.previewMode="dom",this.rasterizeThumbnail(r,l)),r.dataset.previewRendered="true",a.hidden=true;});}visibleThumbnailRange(e){let n=D*.5625+Ln,i=this.slideList.clientHeight||n*Math.min(e,5),r=Math.max(0,Math.floor(this.slideList.scrollTop/n)-fe),o=Math.ceil(i/n)+fe*2,s=this.sessionValue.selection(),a=(s==null?void 0:s.slideId)!==void 0?this.sessionValue.scene().slides.findIndex(c=>c.id===s.slideId):-1,l=a>=0?Math.min(r,Math.max(0,a-fe)):r,d=a>=0?Math.max(r+o,Math.min(e,a+fe+1)):r+o;return {start:l,end:Math.min(e,d)}}renderThumbnailSlide(e){let n=document.createElement("div");n.className="coco-ppt-thumb-slide";let r=D*me/e.size.width;return n.style.width=`${e.size.width*r}px`,n.style.height=`${e.size.height*r}px`,n.style.transform=`scale(${1/me})`,n.style.background=Re(e.background,this.imageResources),n.replaceChildren(...e.nodes.map(o=>this.renderNode(o,r,e,false))),n}async rasterizeThumbnail(e,n){var d,c;let i=this.thumbnailRasterEpoch,r=Ge(n);if(await pt(),await pt(),i!==this.thumbnailRasterEpoch||!e.isConnected)return;let o=e.querySelector(".coco-ppt-thumb-preview"),s=o==null?void 0:o.querySelector(".coco-ppt-thumb-slide");if(!o||!s)return;let a=await Dn(s,D,D*(n.size.height/n.size.width),$n,(c=(d=this.root.querySelector("style"))==null?void 0:d.textContent)!=null?c:"",D*me,D*me*(n.size.height/n.size.width));if(!a||i!==this.thumbnailRasterEpoch||!e.isConnected)return;let l=this.sessionValue.scene().slides.find(u=>u.id===n.id);!l||Ge(l)!==r||(this.thumbnailCanvasCache.set(n.id,{fingerprint:r,canvas:a}),o.replaceChildren(ht(a)),e.dataset.previewMode="canvas");}scheduleThumbnailRender(){this.thumbnailFrame||(this.thumbnailFrame=requestAnimationFrame(()=>{this.thumbnailFrame=0,this.renderVisibleThumbnails(this.sessionValue.scene().slides);}));}renderNode(e,n,i,r=true){var h,x,S;let o=document.createElement("div"),s=zt(e),a=e.presetGeometry==="frame",l=s?Dt(e):"horizontal",d=Math.max(s&&l==="vertical"?12:1,e.bounds.width*n),c=Math.max(s&&l==="horizontal"?12:1,e.bounds.height*n);o.className=r?"coco-ppt-node":"coco-ppt-thumb-node",o.dataset.kind=e.kind,o.dataset.locked=String(e.locked),r&&(o.dataset.draggable=String(!this.isReadOnly()&&e.capabilities.editGeometry),o.dataset.resizable=String(!this.isReadOnly()&&e.capabilities.editGeometry),o.dataset.shapeId=e.id),o.style.left=`${e.bounds.left*n-(s&&l==="vertical"?d/2:0)}px`,o.style.top=`${e.bounds.top*n-(s&&l==="horizontal"?c/2:0)}px`,o.style.width=`${d}px`,o.style.height=`${c}px`;let u=[];e.bounds.rotation&&u.push(`rotate(${e.bounds.rotation}deg)`),e.bounds.flipHorizontal&&u.push("scaleX(-1)"),e.bounds.flipVertical&&u.push("scaleY(-1)"),u.length>0&&(o.style.transform=u.join(" "));let p=Ut(e),f=_i(e.presetGeometry),m=!!(f&&e.text&&!e.customGeometry&&!p);if(e.usesBackgroundFill&&e.backgroundFill?Vi(o,e.backgroundFill,e,i,n,this.imageResources):e.customGeometry||p||m||e.kind==="table"||s||a?o.style.background="transparent":e.fillGradient&&e.fillGradient.colors.length>1?o.style.background=Y(e.fillGradient,Z(e)):e.fillColor&&(o.style.background=q(e.fillColor,Z(e))),Ci(e)&&(o.style.overflow="visible"),(e.presetGeometry==="roundRect"||e.presetGeometry==="round1Rect")&&(o.style.borderRadius=`${_(e)*n}px`),e.presetGeometry==="round2DiagRect"){let g=`${_(e)*n}px`;o.style.borderRadius=`${g} 0 ${g} 0`;}if(e.presetGeometry==="round2SameRect"){let g=`${_(e)*n}px`;o.style.borderRadius=`${g} ${g} 0 0`;}if((e.presetGeometry==="ellipse"||Rn(e)||Fn(e))&&(o.style.borderRadius="9999px"),f&&!m&&!p&&(o.style.clipPath=f),a?(o.style.borderStyle="solid",o.style.borderWidth=`${Hi(e,n)}px`,e.fillGradient&&e.fillGradient.colors.length>1?(o.style.borderImageSource=Y(e.fillGradient),o.style.borderImageSlice="1"):e.fillColor&&(o.style.borderColor=e.fillColor)):!e.customGeometry&&!p&&!m&&!s&&e.kind!=="picture"&&e.lineColor&&(o.style.borderStyle=Ve(e.lineDash),o.style.borderWidth=`${Math.max(1,((h=e.lineWidth)!=null?h:9525)*n)}px`,o.style.borderColor=q(e.lineColor,e.lineOpacity)),e.shadow&&(o.style.boxShadow=qt(e.shadow,n)),this.applyTextStyle(o,e,n),bi(o,e,n),m&&f&&o.append(Di(e,n,f)),e.customGeometry&&e.kind!=="picture"&&o.append(sr(e)),p&&o.append(Ki(e,n)),s)o.append(ur(e,n));else if(e.kind==="chart")o.append(Pr(e));else if(e.kind==="table"){let g=mr(e,n,r);r&&(g.addEventListener("click",y=>{y.stopPropagation(),!this.consumeSuppressedClick()&&(this.notifyTableCellSelection(i,e,y),this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:e.id}));}),g.addEventListener("dblclick",y=>{if(this.isReadOnly())return;let P=mt(y);if(!P||!e.capabilities.editTableCells)return;y.stopPropagation();let w=Number(P.dataset.row),E=Number(P.dataset.column);!Number.isInteger(w)||!Number.isInteger(E)||this.startTableCellEdit(P,i,e,w,E);})),o.append(g);}else if(e.kind==="picture"){let g=e.imagePath?this.imageResources[e.imagePath]:void 0,y=g==null?void 0:g.url;if(y&&Oe(g.contentType,e.imagePath)){if(tr(e,i))o.append(rr(e,y));else {let P=document.createElement("img");P.src=y,P.alt=(x=e.name)!=null?x:"",ci(P,e),e.imageOpacity!==void 0&&(P.style.opacity=String(Math.max(0,Math.min(1,e.imageOpacity)))),o.append(P);}e.lineColor&&o.append(cr(e,n));}else o.dataset.unsupportedImage=e.imagePath?"true":"missing",g!=null&&g.contentType&&(o.dataset.imageContentType=g.contentType),e.imagePath&&(o.dataset.imagePath=e.imagePath),o.append(hi(e,g==null?void 0:g.contentType));}else {let g=(S=e.text)!=null?S:"";if(e.customGeometry||p||m||mi(e)){let y=document.createElement("div");y.className="coco-ppt-text-layer",gi(y,e),St(y,e,n,g),o.append(y),Pt(y,e),wt(y,e);}else St(o,e,n,g),Pt(o,e),wt(o,e);}if(zi(e)&&o.append(dr(e,n)),!r)return o;let b=document.createElement("div");return b.className="coco-ppt-resize-handle",b.addEventListener("mousedown",g=>{this.isReadOnly()||!e.capabilities.editGeometry||(g.preventDefault(),g.stopPropagation(),this.startDrag(g,"resize",i,e,n,o));}),o.append(b),o.addEventListener("click",g=>{var P,w;if(this.hideContextMenu(),g.stopPropagation(),this.consumeSuppressedClick())return;if(g.altKey){let E=this.selection(),v=ii(i,g,n,(E==null?void 0:E.kind)==="shape"?E.shapeId:e.id);if(v){this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:v.node.id}),(w=(P=this.options).onObjectAction)==null||w.call(P,{action:"cycle-selection",slideId:i.id,shapeId:v.node.id,kind:v.node.kind,name:v.node.name,reason:`\u5DF2\u5207\u6362\u5230\u91CD\u53E0\u5BF9\u8C61 ${v.index+1}/${v.count}`,candidateIndex:v.index,candidateCount:v.count});return}}let y=this.pointerOperationNode(i,e,g,n);if(y){this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:y.id});return}this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:e.id});}),o.addEventListener("contextmenu",g=>{var P;if(this.isReadOnly())return;g.preventDefault(),g.stopPropagation();let y=(P=this.pointerOperationNode(i,e,g,n))!=null?P:e;this.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:y.id}).then(()=>this.showContextMenu(g,i,y));}),o.addEventListener("mousedown",g=>{var w,E;let y=(w=this.pointerOperationNode(i,e,g,n))!=null?w:e,P=(E=Le(this.canvas,y.id))!=null?E:o;ti(P,g.target)||this.isReadOnly()||g.button!==0||!y.capabilities.editGeometry||(g.preventDefault(),g.stopPropagation(),this.startDrag(g,"move",i,y,n,P));}),o.addEventListener("dblclick",g=>{var P,w,E;if(this.isReadOnly())return;g.stopPropagation();let y=yt(i,e,g,n);if(y){this.startTextEdit((P=Le(this.canvas,y.id))!=null?P:o,i,y);return}if(!e.capabilities.editText){this.sessionValue.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:e.id}).then(()=>this.renderSelection()),(E=(w=this.options).onObjectAction)==null||E.call(w,{action:"blocked-text-edit",slideId:i.id,shapeId:e.id,kind:e.kind,name:e.name,reason:si(e)});return}this.startTextEdit(o,i,e);}),o}pointerOperationNode(e,n,i,r){let o=this.selection();return (o==null?void 0:o.kind)==="shape"&&o.slideId===e.id&&o.shapeId===n.id?n:yt(e,n,i,r)}notifyTableCellSelection(e,n,i){var a,l;let r=mt(i);if(!r||!n.capabilities.editTableCells)return;let o=Number(r.dataset.row),s=Number(r.dataset.column);!Number.isInteger(o)||!Number.isInteger(s)||(l=(a=this.options).onTableCellSelectionChange)==null||l.call(a,{slideId:e.id,shapeId:n.id,row:o,column:s,text:Nt(r,n,o,s)});}applyTextStyle(e,n,i){var s,a,l,d;let r=n.textStyle;r&&(Be(e,ni(n,r),i),r.alignment&&(Fe(e,r.alignment),r.alignment==="center"&&(e.style.justifyContent="center"),r.alignment==="right"&&(e.style.justifyContent="flex-end")));let o=n.kind==="table"?void 0:n.textBody;if(o){let c=(s=o.insetLeft)!=null?s:91440,u=(a=o.insetTop)!=null?a:45720,p=(l=o.insetRight)!=null?l:91440,f=(d=o.insetBottom)!=null?d:45720,m=yi(n,i);e.style.padding=`${u*i+m}px ${p*i}px ${f*i}px ${c*i}px`,Ot(o)&&(e.style.writingMode="vertical-rl",e.style.textOrientation="upright"),o.anchor==="middle"&&(e.style.alignItems="center"),o.anchor==="bottom"&&(e.style.alignItems="flex-end"),o.anchor==="top"&&(e.style.alignItems="flex-start");}}startTextEdit(e,n,i){var p,f,m,b;if(this.isReadOnly())return;let r=(p=i.text)!=null?p:"",o=Qn(e),s=false;this.sessionValue.dispatch({kind:"select-shape",slideIdOrIndex:n.id,shapeIdOrName:i.id}).then(()=>this.renderSelection()),(m=(f=this.options).onTextEditStateChange)==null||m.call(f,{state:"start",slideId:n.id,shapeId:i.id,text:r}),o.contentEditable="true",o.spellcheck=false,o.setAttribute("role","textbox"),o.setAttribute("aria-label",(b=i.name)!=null?b:"PPT text"),e.dataset.editing="true",this.canvas.dataset.interactionMode="editing",o.textContent=r,o.focus();let a=o.ownerDocument.getSelection();if(a){let h=o.ownerDocument.createRange();h.selectNodeContents(o),h.collapse(false),a.removeAllRanges(),a.addRange(h);}let l=h=>{var S,g,y,P,w;if(s)return;s=true,o.contentEditable="false",o.removeAttribute("role"),o.removeAttribute("aria-label"),delete e.dataset.editing,delete this.canvas.dataset.interactionMode,o.removeEventListener("blur",u),o.removeEventListener("keydown",d),o.removeEventListener("paste",c);let x=(S=o.textContent)!=null?S:"";if(!h){o.textContent=r,(y=(g=this.options).onTextEditStateChange)==null||y.call(g,{state:"cancel",slideId:n.id,shapeId:i.id,text:r}),this.render();return}(w=(P=this.options).onTextEditStateChange)==null||w.call(P,{state:"commit",slideId:n.id,shapeId:i.id,text:x}),x!==r?this.dispatch({kind:"set-shape-text",slideIdOrIndex:n.id,shapeIdOrName:i.id,text:x}):this.render();},d=h=>{if(h.key==="Escape"){h.preventDefault(),l(false);return}h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),l(true));},c=h=>{var S;let x=(S=h.clipboardData)==null?void 0:S.getData("text/plain");x!==void 0&&(h.preventDefault(),xt(o,x));},u=()=>l(true);o.addEventListener("blur",u),o.addEventListener("keydown",d),o.addEventListener("paste",c);}startTableCellEdit(e,n,i,r,o){var f,m,b;if(this.isReadOnly())return;let s=Nt(e,i,r,o),a=false;this.sessionValue.dispatch({kind:"select-shape",slideIdOrIndex:n.id,shapeIdOrName:i.id}).then(()=>this.renderSelection()),(m=(f=this.options).onTableCellSelectionChange)==null||m.call(f,{slideId:n.id,shapeId:i.id,row:r,column:o,text:s}),e.contentEditable="true",e.spellcheck=false,this.canvas.dataset.interactionMode="editing",e.setAttribute("role","textbox"),e.setAttribute("aria-label",`${(b=i.name)!=null?b:"PPT table"} cell ${r+1},${o+1}`),e.textContent=s,e.focus();let l=e.ownerDocument.getSelection();if(l){let h=e.ownerDocument.createRange();h.selectNodeContents(e),h.collapse(false),l.removeAllRanges(),l.addRange(h);}let d=h=>{var S;if(a)return;a=true,e.contentEditable="false",delete this.canvas.dataset.interactionMode,e.removeAttribute("role"),e.removeAttribute("aria-label"),e.removeEventListener("blur",p),e.removeEventListener("keydown",c),e.removeEventListener("paste",u);let x=(S=e.textContent)!=null?S:"";if(!h){e.textContent=s,e.dataset.cellText=s;return}x!==s?(e.dataset.cellText=x,this.dispatch({kind:"set-table-cell-text",slideIdOrIndex:n.id,shapeIdOrName:i.id,row:r,column:o,text:x})):this.render();},c=h=>{if(h.key==="Escape"){h.preventDefault(),d(false);return}h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),d(true));},u=h=>{var S;let x=(S=h.clipboardData)==null?void 0:S.getData("text/plain");x!==void 0&&(h.preventDefault(),xt(e,x));},p=()=>d(true);e.addEventListener("blur",p),e.addEventListener("keydown",c),e.addEventListener("paste",u);}startDrag(e,n,i,r,o,s){this.isReadOnly()||(n==="resize"&&Vn(s,r),this.dragState={mode:n,slideId:i.id,shapeId:r.id,slideSize:i.size,startClientX:e.clientX,startClientY:e.clientY,startBounds:C({},r.bounds),scale:o,element:s,active:false},this.sessionValue.dispatch({kind:"select-shape",slideIdOrIndex:i.id,shapeIdOrName:r.id}).then(()=>this.renderSelection()));}updateDrag(e){let n=this.dragState;if(!n)return;if(Math.hypot(e.clientX-n.startClientX,e.clientY-n.startClientY)<=Ie){this.restoreDragElementBounds(n),this.hideSnapGuides(),n.active=false,this.clearDragVisualState(n.element,true);return}n.active=true,n.element.dataset.dragging="true",this.canvas.dataset.interactionMode="dragging";let r=(e.clientX-n.startClientX)/n.scale,o=(e.clientY-n.startClientY)/n.scale;if(n.mode==="move"){let{bounds:a}=e.altKey?{bounds:O(n.startBounds,n.slideSize,{left:n.startBounds.left+r,top:n.startBounds.top+o})}:this.snapDragBounds(n,{left:n.startBounds.left+r,top:n.startBounds.top+o});e.altKey&&this.hideSnapGuides(),n.element.style.left=`${a.left*n.scale}px`,n.element.style.top=`${a.top*n.scale}px`;return}let{bounds:s}=e.altKey?{bounds:O(n.startBounds,n.slideSize,{width:n.startBounds.width+r,height:n.startBounds.height+o})}:this.snapResizeBounds(n,{width:n.startBounds.width+r,height:n.startBounds.height+o});e.altKey&&this.hideSnapGuides(),n.element.style.width=`${s.width*n.scale}px`,n.element.style.height=`${s.height*n.scale}px`;}async finishDrag(e){var a,l;let n=this.dragState;if(!n)return;this.dragState=null;let i=(e.clientX-n.startClientX)/n.scale,r=(e.clientY-n.startClientY)/n.scale,o=Math.hypot(e.clientX-n.startClientX,e.clientY-n.startClientY);if(o<=Ie||!n.active){this.hideSnapGuides(),this.clearDragVisualState(n.element);return}this.suppressClickAfterDrag=this.suppressClickAfterDrag||o>Ie;let s=e.altKey?O(n.startBounds,n.slideSize,n.mode==="move"?{left:n.startBounds.left+i,top:n.startBounds.top+r}:{width:n.startBounds.width+i,height:n.startBounds.height+r}):n.mode==="move"?this.snapDragBounds(n,{left:n.startBounds.left+i,top:n.startBounds.top+r}):this.snapResizeBounds(n,{width:n.startBounds.width+i,height:n.startBounds.height+r});if(this.hideSnapGuides(),this.clearDragVisualState(n.element),await this.dispatch({kind:"set-shape-geometry",slideIdOrIndex:n.slideId,shapeIdOrName:n.shapeId,geometry:"bounds"in s?s.bounds:s,preserveTextSizeOnResize:n.mode==="resize"}),"snapped"in s&&s.snapped){let d=this.currentSlide(),c=d==null?void 0:d.nodes.find(u=>u.id===n.shapeId);d&&c&&((l=(a=this.options).onObjectAction)==null||l.call(a,{action:"snap-geometry",slideId:d.id,shapeId:c.id,kind:c.kind,name:c.name,reason:this.snapActionReason(s,d)}));}}snapActionReason(e,n){let i=[...new Set(e.guides.map(r=>r.referenceShapeId).filter(r=>!!r))].map(r=>n.nodes.find(o=>o.id===r)).filter(r=>!!r).map(r=>r.name||r.id);return i.length>0?`\u5DF2\u5438\u9644\u5230 ${i.join("\u3001")}`:"\u5DF2\u5438\u9644\u5230\u9875\u9762\u53C2\u8003\u7EBF"}snapDragBounds(e,n){let i=O(e.startBounds,e.slideSize,n),r=this.sessionValue.scene().slides.find(c=>c.id===e.slideId);if(!r)return this.hideSnapGuides(),{bounds:i,guides:[],snapped:false};let o=Math.min(18e4,ct/e.scale),s=be([{offset:0,value:i.left,role:"start"},{offset:i.width/2,value:i.left+i.width/2,role:"center"},{offset:i.width,value:i.left+i.width,role:"end"}],ge(r,e.shapeId,"x"),o),a=be([{offset:0,value:i.top,role:"start"},{offset:i.height/2,value:i.top+i.height/2,role:"center"},{offset:i.height,value:i.top+i.height,role:"end"}],ge(r,e.shapeId,"y"),o),l=O(e.startBounds,e.slideSize,{left:s?s.target.value-s.source.offset:i.left,top:a?a.target.value-a.source.offset:i.top}),d=[...s?[{axis:"x",value:s.target.value,kind:s.target.kind,referenceShapeId:s.target.referenceShapeId}]:[],...a?[{axis:"y",value:a.target.value,kind:a.target.kind,referenceShapeId:a.target.referenceShapeId}]:[]];return this.renderSnapGuides(d,e.scale),{bounds:l,guides:d,snapped:d.length>0}}snapResizeBounds(e,n){let i=O(e.startBounds,e.slideSize,n),r=this.sessionValue.scene().slides.find(c=>c.id===e.slideId);if(!r)return this.hideSnapGuides(),{bounds:i,guides:[],snapped:false};let o=Math.min(18e4,ct/e.scale),s=be([{offset:i.width/2,value:i.left+i.width/2,role:"center"},{offset:i.width,value:i.left+i.width,role:"end"}],ge(r,e.shapeId,"x"),o,{matchRole:false}),a=be([{offset:i.height/2,value:i.top+i.height/2,role:"center"},{offset:i.height,value:i.top+i.height,role:"end"}],ge(r,e.shapeId,"y"),o,{matchRole:false}),l=O(e.startBounds,e.slideSize,{width:s?ut(i.left,i.width,s.source,s.target.value):i.width,height:a?ut(i.top,i.height,a.source,a.target.value):i.height}),d=[...s?[{axis:"x",value:s.target.value,kind:s.target.kind,referenceShapeId:s.target.referenceShapeId}]:[],...a?[{axis:"y",value:a.target.value,kind:a.target.kind,referenceShapeId:a.target.referenceShapeId}]:[]];return this.renderSnapGuides(d,e.scale),{bounds:l,guides:d,snapped:d.length>0}}renderSnapGuides(e,n){this.clearSnapReferenceHighlights();let i=new Set(e.map(r=>r.referenceShapeId).filter(r=>!!r));for(let r of i){let o=Le(this.canvas,r);o&&(o.dataset.snapReference="true");}this.snapGuides.replaceChildren(...e.map(r=>{let o=document.createElement("div");return o.className="coco-ppt-snap-guide",o.dataset.axis=r.axis,o.dataset.kind=r.kind,r.referenceShapeId&&(o.dataset.referenceShapeId=r.referenceShapeId),r.axis==="x"?o.style.left=`${r.value*n}px`:o.style.top=`${r.value*n}px`,o}));}hideSnapGuides(){this.clearSnapReferenceHighlights(),this.snapGuides.replaceChildren();}clearDragVisualState(e,n=false){delete e.dataset.dragging,(n||!this.dragState)&&delete this.canvas.dataset.interactionMode;}restoreDragElementBounds(e){if(e.mode==="move"){e.element.style.left=`${e.startBounds.left*e.scale}px`,e.element.style.top=`${e.startBounds.top*e.scale}px`;return}e.element.style.width=`${e.startBounds.width*e.scale}px`,e.element.style.height=`${e.startBounds.height*e.scale}px`;}clearSnapReferenceHighlights(){this.canvas.querySelectorAll('.coco-ppt-node[data-snap-reference="true"]').forEach(e=>{delete e.dataset.snapReference;});}handleKeyDown(e){if(e.defaultPrevented||this.dragState||bt(e.target)||this.root.querySelector('[contenteditable="true"]'))return;let n=this.selection();if((n==null?void 0:n.kind)!=="shape")return;let i=this.sessionValue.scene().slides.find(d=>d.id===n.slideId),r=i==null?void 0:i.nodes.find(d=>d.id===n.shapeId);if(!i||!r)return;let o=e.ctrlKey||e.metaKey;if(this.isReadOnly())return;if(o&&e.key.toLowerCase()==="c"){e.preventDefault(),this.copySelectedShape(i,r);return}if(o&&e.key.toLowerCase()==="v"){e.preventDefault(),this.pasteClipboardShape(i,r);return}if(o&&e.key.toLowerCase()==="d"){e.preventDefault(),this.duplicateSelectedShape(i,r);return}if(o&&e.shiftKey&&e.key==="]"){e.preventDefault(),this.bringSelectedShapeToFront(i,r);return}if(o&&e.shiftKey&&e.key==="["){e.preventDefault(),this.sendSelectedShapeToBack(i,r);return}if(e.key==="Delete"||e.key==="Backspace"){if(!V(r))return;e.preventDefault(),this.deleteSelectedShape(i,r);return}let s=ei(e.key);if(!s||!r.capabilities.editGeometry)return;let a=Gn*(e.shiftKey?10:1),l=O(r.bounds,i.size,{left:r.bounds.left+s.dx*a,top:r.bounds.top+s.dy*a});e.preventDefault(),this.dispatch({kind:"set-shape-geometry",slideIdOrIndex:i.id,shapeIdOrName:r.id,geometry:{left:l.left,top:l.top}}).then(()=>{var d,c;(c=(d=this.options).onObjectAction)==null||c.call(d,{action:"nudge-geometry",slideId:i.id,shapeId:r.id,kind:r.kind,name:r.name,reason:`\u5DF2\u79FB\u52A8\u5BF9\u8C61 ${s.label}${e.shiftKey?" 10\u6B65":" 1\u6B65"}`});});}handleSelectStart(e){this.isReadOnly()||bt(e.target)||e.target instanceof HTMLElement&&e.target.closest('[contenteditable="true"]')||e.preventDefault();}copySelectedShape(e,n){var i,r;V(n)&&(this.clipboardShape={slideId:e.id,shapeId:n.id},(r=(i=this.options).onObjectAction)==null||r.call(i,{action:"copy-shape",slideId:e.id,shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u590D\u5236\u5BF9\u8C61"}));}pasteClipboardShape(e,n){if(!this.clipboardShape)return;let i=this.clipboardShape;this.dispatch({kind:"paste-shape",slideIdOrIndex:i.slideId,shapeIdOrName:i.shapeId}).then(()=>{var o,s;let r=this.selection();(s=(o=this.options).onObjectAction)==null||s.call(o,{action:"paste-shape",slideId:i.slideId,shapeId:(r==null?void 0:r.kind)==="shape"?r.shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u7C98\u8D34\u5BF9\u8C61"});});}duplicateSelectedShape(e,n){V(n)&&this.dispatch({kind:"duplicate-shape",slideIdOrIndex:e.id,shapeIdOrName:n.id}).then(()=>{var r,o;let i=this.selection();(o=(r=this.options).onObjectAction)==null||o.call(r,{action:"duplicate-shape",slideId:e.id,shapeId:(i==null?void 0:i.kind)==="shape"?i.shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u91CD\u590D\u5BF9\u8C61"});});}bringSelectedShapeToFront(e,n){V(n)&&this.dispatch({kind:"bring-shape-to-front",slideIdOrIndex:e.id,shapeIdOrName:n.id}).then(()=>{var i,r;(r=(i=this.options).onObjectAction)==null||r.call(i,{action:"bring-shape-to-front",slideId:e.id,shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u7F6E\u4E8E\u9876\u5C42"});});}sendSelectedShapeToBack(e,n){V(n)&&this.dispatch({kind:"send-shape-to-back",slideIdOrIndex:e.id,shapeIdOrName:n.id}).then(()=>{var i,r;(r=(i=this.options).onObjectAction)==null||r.call(i,{action:"send-shape-to-back",slideId:e.id,shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u7F6E\u4E8E\u5E95\u5C42"});});}showContextMenu(e,n,i){if(this.isReadOnly())return;let r=V(i),o=!!this.clipboardShape,s=c=>()=>{this.hideContextMenu(),c();};this.contextMenu.replaceChildren(W("\u590D\u5236","Ctrl+C",r,s(()=>this.copySelectedShape(n,i))),W("\u7C98\u8D34","Ctrl+V",o,s(()=>this.pasteClipboardShape(n,i))),W("\u91CD\u590D","Ctrl+D",r,s(()=>this.duplicateSelectedShape(n,i))),gt(),W("\u7F6E\u4E8E\u9876\u5C42","Ctrl+Shift+]",r,s(()=>this.bringSelectedShapeToFront(n,i))),W("\u7F6E\u4E8E\u5E95\u5C42","Ctrl+Shift+[",r,s(()=>this.sendSelectedShapeToBack(n,i))),gt(),W("\u5220\u9664","Del",r,s(()=>this.deleteSelectedShape(n,i))));let a=this.root instanceof ShadowRoot?this.root.host.getBoundingClientRect():this.root.getBoundingClientRect(),l=ve(e.clientX,a.left+4,window.innerWidth-170),d=ve(e.clientY,a.top+4,window.innerHeight-220);this.contextMenu.style.left=`${l}px`,this.contextMenu.style.top=`${d}px`,this.contextMenu.dataset.shapeId=i.id,this.contextMenu.dataset.open="true";}deleteSelectedShape(e,n){V(n)&&this.dispatch({kind:"delete-shape",slideIdOrIndex:e.id,shapeIdOrName:n.id}).then(()=>{var i,r;(r=(i=this.options).onObjectAction)==null||r.call(i,{action:"delete-shape",slideId:e.id,shapeId:n.id,kind:n.kind,name:n.name,reason:"\u5DF2\u5220\u9664\u5BF9\u8C61"});});}async dispatchCurrentSlideSelection(){if(this.consumeSuppressedClick())return;let e=this.currentSlide();e&&await this.dispatch({kind:"select-slide",slideIdOrIndex:e.id});}consumeSuppressedClick(){return this.suppressClickAfterDrag?(this.suppressClickAfterDrag=false,true):false}dismissContextMenu(e){let n=e.composedPath()[0];n instanceof Node&&this.contextMenu.contains(n)||this.hideContextMenu();}hideContextMenu(){delete this.contextMenu.dataset.open,delete this.contextMenu.dataset.shapeId;}renderSelection(){this.canvas.querySelectorAll(".coco-ppt-parent-group-outline").forEach(n=>n.remove());let e=this.sessionValue.selection();this.slideList.querySelectorAll(".coco-ppt-thumb").forEach((n,i)=>{let r=this.sessionValue.scene().slides[i];n.dataset.selected=(e==null?void 0:e.slideId)===(r==null?void 0:r.id)?"true":"false";}),this.canvas.querySelectorAll(".coco-ppt-node").forEach(n=>{n.dataset.selected=(e==null?void 0:e.kind)==="shape"&&n.dataset.shapeId===e.shapeId?"true":"false";}),this.renderParentGroupSelection(e);}renderParentGroupSelection(e){var d,c;if((e==null?void 0:e.kind)!=="shape")return;let n=this.sessionValue.scene().slides.find(u=>u.id===e.slideId),i=(d=n==null?void 0:n.nodes.find(u=>u.id===e.shapeId))!=null?d:n==null?void 0:n.groups.find(u=>u.id===e.shapeId),r=i!=null&&i.groupContext?(c=n==null?void 0:n.groups.find(u=>{var p;return u.id===((p=i.groupContext)==null?void 0:p.parentId)}))!=null?c:On(i):(i==null?void 0:i.kind)==="group"?i:null;if(!n||!r)return;let o=this.computeScale(n),s=document.createElement("div");s.className="coco-ppt-parent-group-outline",s.dataset.shapeId=r.id,s.dataset.selected=e.shapeId===r.id?"true":"false",s.title=`\u7236\u7EC4\uFF1A${r.name||r.id}`,s.style.left=`${r.bounds.left*o}px`,s.style.top=`${r.bounds.top*o}px`,s.style.width=`${r.bounds.width*o}px`,s.style.height=`${r.bounds.height*o}px`;let a=u=>{u.preventDefault(),u.stopPropagation(),this.startDrag(u,"move",n,r,o,s);};["top","right","bottom","left"].forEach(u=>{let p=document.createElement("div");p.className="coco-ppt-parent-group-edge",p.dataset.edge=u,p.title="\u62D6\u52A8\u7236\u7EC4",p.addEventListener("mousedown",a),s.append(p);});let l=document.createElement("div");l.className="coco-ppt-parent-group-handle",l.title="\u62D6\u52A8\u7236\u7EC4",l.addEventListener("mousedown",a),s.append(l),this.canvas.append(s);}currentSlide(){var i,r,o;let e=this.sessionValue.scene(),n=this.sessionValue.selection();return (n==null?void 0:n.kind)==="slide"||(n==null?void 0:n.kind)==="shape"?(r=(i=e.slides.find(s=>s.id===n.slideId))!=null?i:e.slides[0])!=null?r:null:(o=e.slides[0])!=null?o:null}computeScale(e){let n=this.canvas.parentElement,i=n?Math.max(1,n.clientWidth-48):960,r=n?Math.max(1,n.clientHeight-48):540;return Math.min(960/e.size.width,540/e.size.height,i/e.size.width,r/e.size.height)}};function Vn(t,e){var i,r;if(!Hn(e))return;let n=(r=(i=t.querySelector(".coco-ppt-rich-text, .coco-ppt-distributed-text"))!=null?i:t.querySelector(".coco-ppt-text-layer"))!=null?r:t;t.dataset.textResizePreview="wrap",n.dataset.textResizePreview="wrap",n.style.transform="",n.style.transformOrigin="",n.style.width="",t.style.whiteSpace="pre-wrap",t.style.overflowWrap="anywhere",t.querySelectorAll(".coco-ppt-rich-text, .coco-ppt-paragraph").forEach(o=>{o.style.whiteSpace="pre-wrap",o.style.overflowWrap="anywhere";});}function Hn(t){var e;return !!(t.capabilities.editGeometry&&zn(t)&&(t.text||(e=t.textParagraphs)!=null&&e.length))}function zn(t){return t.kind==="placeholder"||t.kind==="textBox"||t.kind==="geometricShape"}function pt(){return new Promise(t=>requestAnimationFrame(()=>t()))}async function Dn(t,e,n,i,r,o=e,s=n){if(typeof XMLSerializer=="undefined"||typeof Blob=="undefined"||typeof URL=="undefined"||typeof URL.createObjectURL!="function")return null;await Wn(t);let a=document.createElement("canvas");a.width=Math.max(1,Math.round(e*i)),a.height=Math.max(1,Math.round(n*i));let l=a.getContext("2d");if(!l)return null;let d=document.createElement("div");d.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),d.style.width=`${o}px`,d.style.height=`${s}px`,d.style.position="relative",d.style.overflow="hidden",d.style.background="#fff";let c=document.createElement("style");c.textContent=r;let u=t.cloneNode(true);await jn(u),u.style.position="relative",u.style.left="0",u.style.top="0",u.style.transform="none",d.append(c,u);let p=new XMLSerializer().serializeToString(d),f=`<svg xmlns="http://www.w3.org/2000/svg" width="${a.width}" height="${a.height}" viewBox="0 0 ${o} ${s}"><foreignObject width="100%" height="100%">${p}</foreignObject></svg>`,m=URL.createObjectURL(new Blob([f],{type:"image/svg+xml;charset=utf-8"}));try{let b=await Kn(m);return l.drawImage(b,0,0,a.width,a.height),a}catch(b){return null}finally{URL.revokeObjectURL(m);}}function ht(t){let e=document.createElement("canvas");e.className="coco-ppt-thumb-canvas",e.width=t.width,e.height=t.height;let n=e.getContext("2d");return n&&n.drawImage(t,0,0),e}function Ge(t){return JSON.stringify({size:t.size,background:t.background,nodes:t.nodes.map(e=>Lt(e))})}function Lt(t){return {id:t.id,kind:t.kind,bounds:t.bounds,text:t.text,textParagraphs:t.textParagraphs,textStyle:t.textStyle,textBody:t.textBody,table:t.table,fillColor:t.fillColor,fillGradient:t.fillGradient,opacity:t.opacity,lineColor:t.lineColor,lineGradient:t.lineGradient,lineOpacity:t.lineOpacity,lineWidth:t.lineWidth,lineDash:t.lineDash,presetGeometry:t.presetGeometry,presetAdjustments:t.presetAdjustments,customGeometry:t.customGeometry,imagePath:t.imagePath,imageCrop:t.imageCrop,imageFillRect:t.imageFillRect,imageOpacity:t.imageOpacity,shadow:t.shadow,threeD:t.threeD,children:t.children.map(e=>Lt(e))}}async function Wn(t){let e=Array.from(t.querySelectorAll("img"));await Promise.all(e.map(async n=>{if(!(n.complete&&n.naturalWidth>0)){if(typeof n.decode=="function"){await n.decode().catch(()=>{});return}await new Promise(i=>{let r=()=>i();n.addEventListener("load",r,{once:true}),n.addEventListener("error",r,{once:true}),setTimeout(r,500);});}}));}async function jn(t){let e=Array.from(t.querySelectorAll("img"));await Promise.all(e.map(async n=>{n.alt="";let i=n.getAttribute("src");if(!i||i.startsWith("data:"))return;let r=await Un(i).catch(()=>{});r&&n.setAttribute("src",r);}));}async function Un(t){let e=await fetch(t);if(!e.ok)throw new Error(`Failed to inline thumbnail image: ${e.status}`);let n=await e.blob();return _n(n)}function _n(t){return new Promise((e,n)=>{let i=new FileReader;i.onload=()=>{typeof i.result=="string"?e(i.result):n(new Error("Failed to read thumbnail image blob."));},i.onerror=()=>{var r;return n((r=i.error)!=null?r:new Error("Failed to read thumbnail image blob."))},i.readAsDataURL(t);})}function Kn(t){return new Promise((e,n)=>{let i=new Image;i.onload=()=>e(i),i.onerror=()=>n(new Error("Failed to rasterize PPT thumbnail.")),i.src=t;})}function qn(t){return t.filter(Zn).map(n=>{var s,a;let i=li(n.family),r=(s=n.weight)!=null?s:400,o=(a=n.style)!=null?a:"normal";return `@font-face { font-family: ${i}; src: url(${di(n.url)}); font-weight: ${r}; font-style: ${o}; }`}).join(`
|
|
76
|
+
`)}function Zn(t){return /font\/(ttf|otf|woff|woff2)|application\/font-(sfnt|woff|woff2)/i.test(t.contentType)}function Yn(t,e=[]){if(typeof document=="undefined")return Promise.resolve();let n=new Set(t.map(r=>r.family));for(let r of e)n.add(r);let i=[];for(let r of n){let o=ai(r);if(!o)continue;let s=`coco-ppt-google-font-${r.replace(/[^a-zA-Z0-9_-]/g,"_")}`,a=document.getElementById(s);if(a){i.push(ft(a));continue}let l=document.createElement("link");l.id=s,l.rel="stylesheet",l.href=o,i.push(ft(l)),document.head.append(l);}return Promise.all(i).then(()=>{})}function Xn(t){let e=new Set,n=r=>{r!=null&&r.trim()&&e.add(r.trim());},i=r=>{var o,s,a,l,d,c,u,p;n((o=r.textStyle)==null?void 0:o.fontFamily);for(let f of (s=r.textParagraphs)!=null?s:[]){n((a=f.style)==null?void 0:a.bulletFontFamily);for(let m of (l=f.runs)!=null?l:[])n((d=m.style)==null?void 0:d.fontFamily);}for(let f of (u=(c=r.table)==null?void 0:c.cellStyles)!=null?u:[])for(let m of f)n((p=m==null?void 0:m.textStyle)==null?void 0:p.fontFamily);for(let f of r.children)i(f);};for(let r of t.scene.slides)for(let o of r.nodes)i(o);return [...e]}function Jn(t){globalThis.__cocoPptFontRenderReady=t;}function ft(t){return t.sheet?Promise.resolve():new Promise(e=>{let n=()=>e();t.addEventListener("load",n,{once:true}),t.addEventListener("error",n,{once:true}),window.setTimeout(n,5e3);})}function Qn(t){var e;return (e=t.querySelector(".coco-ppt-text-layer"))!=null?e:t}function mt(t){let e=t.target;return e instanceof HTMLElement?e.closest("td[data-row][data-column]"):null}function W(t,e,n,i){let r=document.createElement("button");r.type="button",r.disabled=!n;let o=document.createElement("strong");o.textContent=t;let s=document.createElement("span");return s.textContent=e,r.append(o,s),r.addEventListener("click",()=>{r.disabled||i();}),r}function gt(){return document.createElement("hr")}function ei(t){return t==="ArrowLeft"?{dx:-1,dy:0,label:"\u5DE6"}:t==="ArrowRight"?{dx:1,dy:0,label:"\u53F3"}:t==="ArrowUp"?{dx:0,dy:-1,label:"\u4E0A"}:t==="ArrowDown"?{dx:0,dy:1,label:"\u4E0B"}:null}function bt(t){if(!(t instanceof HTMLElement))return false;if(t.isContentEditable)return true;let e=t.tagName.toLowerCase();return e==="input"||e==="textarea"||e==="select"}function ti(t,e){return t.isContentEditable||e instanceof HTMLElement&&e.isContentEditable?true:!!t.querySelector('[contenteditable="true"]')}function ni(t,e){var a;let n=(a=t.textParagraphs)==null?void 0:a.filter(d=>d.runs.length>0);if(!(n!=null&&n.length)||!Ht(t,n))return e;let l=e,{textGradient:i,textFill:r,textOutlineColor:o}=l;return Ue(l,["textGradient","textFill","textOutlineColor"])}function yt(t,e,n,i){if(e.capabilities.editText||oi(e))return null;let r=$t(n,i);if(!r)return null;let o=t.nodes.findIndex(a=>a.id===e.id),s=t.nodes.slice(0,o<0?t.nodes.length:o);for(let a=s.length-1;a>=0;a--){let l=s[a];if(l.capabilities.editText&&Rt(r.x,r.y,l.bounds))return l}return null}function ii(t,e,n,i){let r=ri(t,e,n);if(r.length<2)return null;let s=(Math.max(0,r.findIndex(a=>a.id===i))+1)%r.length;return {node:r[s],index:s,count:r.length}}function ri(t,e,n){let i=$t(e,n);if(!i)return [];let r=[];for(let o=t.nodes.length-1;o>=0;o--){let s=t.nodes[o];s.capabilities.select&&Rt(i.x,i.y,s.bounds)&&r.push(s);}return r}function oi(t){return t.kind==="table"||t.kind==="chart"||t.kind==="smartArt"}function $t(t,e){var r;let n=t.currentTarget&&typeof t.currentTarget.parentElement=="object"&&(r=t.currentTarget.parentElement)!=null?r:null,i=n==null?void 0:n.getBoundingClientRect();return i?{x:(t.clientX-i.left)/e,y:(t.clientY-i.top)/e}:null}function Rt(t,e,n){return t>=n.left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height}function Le(t,e){for(let n of Array.from(t.querySelectorAll(".coco-ppt-node")))if(n.dataset.shapeId===e)return n;return null}function xt(t,e){var s,a;let n=t.ownerDocument.getSelection();if(!n||n.rangeCount===0){t.textContent=`${(s=t.textContent)!=null?s:""}${e}`;return}let i=n.getRangeAt(0);if(!(t===i.commonAncestorContainer||t.contains(i.commonAncestorContainer))){t.textContent=`${(a=t.textContent)!=null?a:""}${e}`;return}i.deleteContents();let o=t.ownerDocument.createTextNode(e);i.insertNode(o),i.setStartAfter(o),i.setEndAfter(o),n.removeAllRanges(),n.addRange(i);}function si(t){var e;return (e=t.capabilities.reasons)!=null&&e.editText?t.capabilities.reasons.editText:t.capabilities.reason?t.capabilities.reason:t.kind==="table"?"\u8868\u683C\u8BF7\u4F7F\u7528\u5355\u5143\u683C\u7F16\u8F91":t.kind==="picture"?"\u56FE\u7247\u5BF9\u8C61\u4E0D\u652F\u6301\u6587\u5B57\u7F16\u8F91":t.kind==="chart"?"\u56FE\u8868\u5F53\u524D\u4EC5\u652F\u6301\u9009\u62E9\u548C\u4F4D\u7F6E\u7F16\u8F91":t.kind==="smartArt"?"SmartArt \u5F53\u524D\u4EC5\u652F\u6301\u9009\u62E9\u548C\u4F4D\u7F6E\u7F16\u8F91":t.kind==="group"?"\u7EC4\u5408\u5BF9\u8C61\u5F53\u524D\u4EC5\u652F\u6301\u9009\u62E9\u548C\u4F4D\u7F6E\u7F16\u8F91":"\u8BE5\u5BF9\u8C61\u4E0D\u652F\u6301\u6587\u5B57\u7F16\u8F91"}function ai(t){return {Cuprum:"https://fonts.googleapis.com/css2?family=Cuprum:ital,wght@0,400;0,700;1,400;1,700&display=swap",Podkova:"https://fonts.googleapis.com/css2?family=Podkova:wght@400;700&display=swap",Ubuntu:"https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,400;0,700;1,400;1,700&display=swap"}[t]}function Bt(t){return at(t,{families:["Calibri","Microsoft YaHei","Segoe UI"],generic:"sans-serif"})}function li(t){return `"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function di(t){return `"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function q(t,e){var a;if(e===void 0||e>=1)return t;let n=Math.max(0,Math.min(1,e)),i=(a=t.match(/^#([0-9a-fA-F]{6})$/))==null?void 0:a[1];if(!i)return t;let r=Number.parseInt(i.slice(0,2),16),o=Number.parseInt(i.slice(2,4),16),s=Number.parseInt(i.slice(4,6),16);return `rgba(${r}, ${o}, ${s}, ${n})`}function Z(t){var e;return t.opacity!==void 0?Math.max(0,Math.min(1,t.opacity)):((e=t.threeD)==null?void 0:e.material)==="translucentPowder"?.52:void 0}function ci(t,e){if(e.imageFillRect){pi(t,e);return}ui(t,e);}function ui(t,e){var d,c,u,p;let n=e.imageCrop;if(!n)return;let i=(d=n.left)!=null?d:0,r=(c=n.right)!=null?c:0,o=(u=n.top)!=null?u:0,s=(p=n.bottom)!=null?p:0,a=Math.max(.01,1-i-r),l=Math.max(.01,1-o-s);t.style.position="absolute",t.style.left=`${-i/a*100}%`,t.style.top=`${-o/l*100}%`,t.style.width=`${1/a*100}%`,t.style.height=`${1/l*100}%`;}function pi(t,e){var a,l,d,c;let n=e.imageFillRect;if(!n)return;let i=(a=n.left)!=null?a:0,r=(l=n.right)!=null?l:0,o=(d=n.top)!=null?d:0,s=(c=n.bottom)!=null?c:0;t.style.position="absolute",t.style.left=`${i*100}%`,t.style.top=`${o*100}%`,t.style.width=`${Math.max(.01,1-i-r)*100}%`,t.style.height=`${Math.max(.01,1-o-s)*100}%`;}function hi(t,e){var r,o;let n=document.createElement("div");n.className="coco-ppt-unsupported-image";let i=(o=(r=t.imagePath)==null?void 0:r.split(".").pop())==null?void 0:o.toUpperCase();return n.textContent=i||fi(e)||"IMAGE",n.title=t.imagePath?`Unsupported image: ${t.imagePath}`:"Missing image resource",n}function fi(t){if(t)return t.includes("emf")?"EMF":t.includes("wmf")?"WMF":t.includes("svg")?"SVG":"IMAGE"}function St(t,e,n,i){var a,l;let r=(a=e.textParagraphs)==null?void 0:a.filter(d=>d.runs.length>0),o=Ot(e.textBody);if(!(r!=null&&r.length)||!Ht(e,r)){!o&&((l=e.textStyle)==null?void 0:l.alignment)==="distributed"&&Array.from(i).length>1?Ti(t,i):t.textContent=i;return}let s=document.createElement("div");s.className="coco-ppt-rich-text",r.forEach(d=>{var p,f,m,b;let c=document.createElement("div");c.className="coco-ppt-paragraph",(p=d.style)!=null&&p.alignment&&Fe(c,d.style.alignment),Ii(c,d.style,n,{verticalText:o});let u=!o&&((f=d.style)==null?void 0:f.alignment)==="distributed"&&!((m=d.style)!=null&&m.bullet);if(u&&(c.style.display="flex",c.style.justifyContent="space-between",c.style.alignItems="baseline",c.style.width="100%"),(b=d.style)!=null&&b.bullet){c.dataset.bullet="true";let h=document.createElement("span");h.className="coco-ppt-bullet",h.textContent=d.style.bullet,d.style.bulletColor&&(h.style.color=d.style.bulletColor),Li(h,d.style,n,d.text),c.append(h);}d.runs.forEach((h,x)=>{(u?Array.from(h.text):[h.text]).forEach(g=>{let y=document.createElement("span");y.textContent=g;let P=Bi(e,d,h,x);P&&Be(y,P,n),c.append(y);});}),s.append(c);}),t.append(s);}function Ot(t){return (t==null?void 0:t.vertical)==="eastAsian"||(t==null?void 0:t.vertical)==="vertical"}function Pt(t,e){var n;((n=e.textBody)==null?void 0:n.wrap)==="none"&&Ft(t);}function wt(t,e){var n,i;((n=e.textBody)==null?void 0:n.autoFit)==="normal"&&(!e.text&&!((i=e.textParagraphs)!=null&&i.length)||(wi(e)&&!Ei(e)&&Ft(t),requestAnimationFrame(()=>{var p;if(t.dataset.textResizePreview==="wrap")return;let r=t.clientWidth,o=t.clientHeight;if(r<=0||o<=0)return;let s=t.scrollWidth,a=t.scrollHeight,l=s>r?r/s:1,d=a>o?o/a:1,c=Math.max(.25,Math.min(1,l,d));if(c>=.995)return;let u=(p=t.querySelector(".coco-ppt-rich-text, .coco-ppt-distributed-text"))!=null?p:t;u.dataset.textResizePreview!=="wrap"&&(u.style.transformOrigin=Mi(e),u.style.transform=`scale(${c})`,u.style.width=`${100/c}%`);})));}function mi(t){var e;return !!((t.text||(e=t.textParagraphs)!=null&&e.length)&&(t.bounds.flipHorizontal||t.bounds.flipVertical))}function gi(t,e){let n=[];e.bounds.flipHorizontal&&n.push("scaleX(-1)"),e.bounds.flipVertical&&n.push("scaleY(-1)"),n.length!==0&&(t.style.transform=n.join(" "),t.style.transformOrigin="center");}function Ft(t){t.style.whiteSpace="nowrap",t.querySelectorAll(".coco-ppt-rich-text, .coco-ppt-paragraph").forEach(e=>{e.style.whiteSpace="nowrap";});}function bi(t,e,n){var r,o,s;if(!Si(e,n))return;let i=((s=(o=(r=e.textStyle)==null?void 0:r.fontSize)!=null?o:Ce(e))!=null?s:28)*12700*n;t.style.letterSpacing=`${Math.max(1,Math.min(2.4,i*.035))}px`;}function yi(t,e){var i,r;if(!xi(t))return 0;let n=(r=(i=t.textStyle)==null?void 0:i.fontSize)!=null?r:Ce(t);return n?n*12700*e*.18:0}function xi(t){var o,s,a,l,d,c,u,p,f;if(t.kind!=="textBox"&&t.kind!=="placeholder"||((o=t.textBody)==null?void 0:o.anchor)!=="top"||t.textBody.wrap!=="square"||t.fillColor||t.fillGradient||t.lineColor||t.lineGradient)return false;let e=(a=(s=t.textStyle)==null?void 0:s.fontFamily)!=null?a:Vt(t);if(!e||!/\bCuprum\b/i.test(e))return false;let n=(d=(l=t.textStyle)==null?void 0:l.fontSize)!=null?d:Ce(t);if(!n||n<72)return false;let i=(c=t.textParagraphs)==null?void 0:c.filter(m=>{var h;return ((h=m.text)!=null?h:m.runs.map(x=>x.text).join("")).trim().length>0});if(i&&i.length!==1)return false;let r=((f=(p=(u=i==null?void 0:i[0])==null?void 0:u.text)!=null?p:t.text)!=null?f:"").trim();return r.length>=12&&!/[\u3400-\u9fff]/.test(r)}function Si(t,e){var l,d,c,u,p,f,m,b,h,x,S,g,y,P,w,E,v,k,L,$;if(((l=t.textBody)==null?void 0:l.wrap)!=="square"||Pi(t)||((f=(d=t.textStyle)==null?void 0:d.alignment)!=null?f:(p=(u=(c=t.textParagraphs)==null?void 0:c[0])==null?void 0:u.style)==null?void 0:p.alignment)!=="center")return false;let i=(b=(m=t.textStyle)==null?void 0:m.fontFamily)!=null?b:Vt(t);if(!i||!/\bJosefin Sans\b/i.test(i))return false;let r=((g=(S=(x=(h=t.textParagraphs)==null?void 0:h[0])==null?void 0:x.text)!=null?S:t.text)!=null?g:"").replace(/\s+/g," ").trim();if(r.length<24||/[a-z\u3400-\u9fff]/.test(r)||!/^[A-Z0-9][A-Z0-9\s&:;,.!?'"()/+-]*$/.test(r))return false;let o=(P=(y=t.textStyle)==null?void 0:y.fontSize)!=null?P:Ce(t);if(!o)return false;let s=($=(L=(w=t.textStyle)==null?void 0:w.lineHeight)!=null?L:(k=(v=(E=t.textParagraphs)==null?void 0:E[0])==null?void 0:v.style)==null?void 0:k.lineHeight)!=null?$:1.2,a=o*12700*e*s;return t.bounds.height*e>=a*1.75}function Pi(t){var e,n;return !!(((e=t.textStyle)==null?void 0:e.characterSpacing)!==void 0||(n=t.textParagraphs)!=null&&n.some(i=>i.runs.some(r=>{var o;return ((o=r.style)==null?void 0:o.characterSpacing)!==void 0})))}function Ce(t){var e,n;for(let i of (e=t.textParagraphs)!=null?e:[])for(let r of i.runs)if(((n=r.style)==null?void 0:n.fontSize)!==void 0)return r.style.fontSize}function Vt(t){var e,n;for(let i of (e=t.textParagraphs)!=null?e:[])for(let r of i.runs)if((n=r.style)!=null&&n.fontFamily)return r.style.fontFamily}function wi(t){var i,r,o,s,a,l;let e=(i=t.textParagraphs)==null?void 0:i.filter(d=>d.runs.length>0);if(e&&e.length!==1||(o=(r=e==null?void 0:e[0])==null?void 0:r.style)!=null&&o.bullet)return false;let n=(l=(a=(s=e==null?void 0:e[0])==null?void 0:s.text)!=null?a:t.text)!=null?l:"";return n.length>0&&!n.includes(`
|
|
77
|
+
`)&&!n.includes("\r")}function vi(t){var r,o,s,a,l,d,c,u,p,f;if(((r=t.textBody)==null?void 0:r.wrap)!=="square"||((d=(o=t.textStyle)==null?void 0:o.alignment)!=null?d:(l=(a=(s=t.textParagraphs)==null?void 0:s[0])==null?void 0:a.style)==null?void 0:l.alignment)!=="center")return false;let e=((f=(p=(u=(c=t.textParagraphs)==null?void 0:c[0])==null?void 0:u.text)!=null?p:t.text)!=null?f:"").trim();if(!/^[\u3400-\u9fff]{4,6}$/.test(e))return false;let n=Math.min(t.bounds.width,t.bounds.height),i=Math.max(t.bounds.width,t.bounds.height);return n>0&&i<=11e5&&i/n<1.25}function Ei(t){var i,r,o,s,a,l,d;if(vi(t))return true;if(((i=t.textBody)==null?void 0:i.wrap)!=="square")return false;let e=((a=(s=(o=(r=t.textParagraphs)==null?void 0:r[0])==null?void 0:o.text)!=null?s:t.text)!=null?a:"").trim();return e.length<18?false:((d=(l=e.match(/[\u3400-\u9fff]/g))==null?void 0:l.length)!=null?d:0)>=12?true:/[\s,。;、,.]/.test(e)}function Mi(t){var n,i,r,o,s;let e=(s=(n=t.textStyle)==null?void 0:n.alignment)!=null?s:(o=(r=(i=t.textParagraphs)==null?void 0:i[0])==null?void 0:r.style)==null?void 0:o.alignment;return e==="right"?"right top":e==="center"?"center top":"top left"}function Ci(t){var e;return t.kind!=="textBox"||!t.text&&!((e=t.textParagraphs)!=null&&e.length)||t.customGeometry||Ut(t)||zt(t)?false:!ki(t)&&!Ni(t)}function ki(t){var e,n;return (e=t.fillGradient)!=null&&e.colors.length?((n=t.fillGradient.opacities)!=null?n:[]).some(i=>i>0)||!t.fillGradient.opacities:!!(t.fillColor&&t.opacity!==0)}function Ni(t){var e,n;return !t.lineColor&&!((e=t.lineGradient)!=null&&e.colors.length)||t.lineOpacity===0?false:((n=t.lineWidth)!=null?n:9525)>0}function Ti(t,e){let n=document.createElement("div");n.className="coco-ppt-distributed-text",Array.from(e).forEach(i=>{let r=document.createElement("span");r.textContent=i,n.append(r);}),t.append(n);}function Ht(t,e){return e.some(n=>{var i;return !!((i=n.style)!=null&&i.bullet)||Ai(n.style)||n.runs.some(r=>!!r.hyperlink||r.style!==void 0&&Ri(r.style,t.textStyle))})}function Ai(t){return (t==null?void 0:t.lineHeight)!==void 0||(t==null?void 0:t.marginLeft)!==void 0||(t==null?void 0:t.textIndent)!==void 0||(t==null?void 0:t.spaceBefore)!==void 0||(t==null?void 0:t.spaceAfter)!==void 0}function Ii(t,e,n,i={}){if(e){if(e.lineHeight!==void 0&&(t.style.lineHeight=String(Gi(e))),e.marginLeft!==void 0&&(t.style.paddingLeft=`${e.marginLeft*n}px`),e.textIndent!==void 0&&(t.style.textIndent=`${e.textIndent*n}px`),i.verticalText){e.spaceBefore!==void 0&&(t.style.marginRight=ye(e.spaceBefore,n)),e.spaceAfter!==void 0&&(t.style.marginLeft=ye(e.spaceAfter,n));return}e.spaceBefore!==void 0&&(t.style.marginTop=ye(e.spaceBefore,n)),e.spaceAfter!==void 0&&(t.style.marginBottom=ye(e.spaceAfter,n));}}function Gi(t){var n;let e=(n=t.lineHeight)!=null?n:1.2;return t.bullet?e*1.15:e}function Li(t,e,n,i=""){(e==null?void 0:e.bulletSize)!==void 0&&(e.bulletSize>4?t.style.fontSize=`${e.bulletSize*12700*n}px`:e.bulletSize>0&&(t.style.fontSize=`${e.bulletSize}em`)),$i(e,i)&&(t.style.width="0.5em",t.style.marginRight="0.12em",t.style.transform="scale(0.62)",t.style.transformOrigin="center",t.style.verticalAlign="middle");}function $i(t,e=""){var r,o;if(!t)return false;let n=(o=(r=t.bulletFontFamily)==null?void 0:r.toLowerCase())!=null?o:"",i=Array.from(e.trim()).length;return t.bullet==="\u25A1"&&t.alignment==="center"&&i>0&&i<=4&&(n.includes("wingdings")||n.includes("webdings"))&&t.textIndent!==void 0&&t.textIndent<0&&t.marginLeft!==void 0&&t.marginLeft<=Math.abs(t.textIndent)*1.25}function ye(t,e){return t>10?`${t*e}px`:`${t}em`}function Ri(t,e){let n=t,i=e;return t.fontSize!==void 0&&t.fontSize!==(e==null?void 0:e.fontSize)||t.fontFamily!==void 0&&t.fontFamily!==(e==null?void 0:e.fontFamily)||t.color!==void 0&&t.color!==(e==null?void 0:e.color)||n.textFill!==void 0&&n.textFill!==(i==null?void 0:i.textFill)||n.textGradient!==void 0&&n.textGradient!==(i==null?void 0:i.textGradient)||n.textOutlineColor!==void 0&&n.textOutlineColor!==(i==null?void 0:i.textOutlineColor)||n.textShadow!==void 0&&n.textShadow!==(i==null?void 0:i.textShadow)||t.bold!==void 0&&t.bold!==(e==null?void 0:e.bold)||t.italic!==void 0&&t.italic!==(e==null?void 0:e.italic)||t.underline!==void 0&&t.underline!==(e==null?void 0:e.underline)||t.characterSpacing!==void 0&&t.characterSpacing!==(e==null?void 0:e.characterSpacing)}function Bi(t,e,n,i){var o,s,a,l;if(!Oi(t,e,n,i))return vt(n,n.style);let r=Fi(e.runs.slice(0,i));return vt(n,G(C({},n.style),{color:(s=(o=n.style)==null?void 0:o.color)!=null?s:"#000000",fontSize:(l=(a=n.style)==null?void 0:a.fontSize)!=null?l:Math.max(12,Math.round((r!=null?r:28)*.72))}))}function vt(t,e){if(!t.hyperlink)return e;let n=C({},e!=null?e:{});return n.textFill===void 0&&n.textGradient===void 0&&(n.color="#0563C1"),n.underline===void 0&&(n.underline=true),n}function Oi(t,e,n,i){var a,l,d;if(i<=0||(a=n.style)!=null&&a.color&&n.style.fontSize!==void 0||((l=t.textBody)==null?void 0:l.autoFit)!=="shape"||!/[\u3400-\u9fff]/.test(n.text))return false;let r=e.runs.slice(0,i).map(c=>c.text).join(""),o=/^\s*\d{1,2}\s*[、..,,]\s*(.*)$/u.exec(r);return !o||Array.from((d=o[1])!=null?d:"").filter(c=>/[\u3400-\u9fff]/.test(c)).length>2?false:e.runs.slice(0,i).some(c=>{let u=c.style;return (u==null?void 0:u.color)!==void 0||(u==null?void 0:u.fontSize)!==void 0})}function Fi(t){var e;for(let n of t)if(((e=n.style)==null?void 0:e.fontSize)!==void 0)return n.style.fontSize}function Be(t,e,n){var i,r,o;e.fontSize&&(t.style.fontSize=`${Math.max(1,e.fontSize*12700*n)}px`),e.fontFamily&&(t.style.fontFamily=Bt(e.fontFamily)),e.lineHeight&&(t.style.lineHeight=String(e.lineHeight)),e.characterSpacing!==void 0&&(t.style.letterSpacing=`${e.characterSpacing*12700*n}px`),e.color&&(t.style.color=e.color),(i=e.textGradient)!=null&&i.colors.length&&e.textGradient.colors.length>1&&(t.style.backgroundImage=Y(e.textGradient),t.style.backgroundClip="text",t.style.setProperty("-webkit-background-clip","text"),t.style.color="transparent",t.style.setProperty("-webkit-text-fill-color","transparent")),e.textFill==="none"&&(t.style.color=(o=(r=e.textOutlineColor)!=null?r:e.color)!=null?o:"transparent",t.style.setProperty("-webkit-text-fill-color","transparent")),e.textOutlineColor&&t.style.setProperty("-webkit-text-stroke",`1px ${e.textOutlineColor}`),e.textShadow&&(t.style.textShadow=qt(e.textShadow,n)),e.bold!==void 0&&(t.style.fontWeight=e.bold?"700":"400"),e.italic!==void 0&&(t.style.fontStyle=e.italic?"italic":"normal"),e.underline!==void 0&&(t.style.textDecorationLine=e.underline?"underline":"none");}function Oe(t,e){var i;let n=(i=t==null?void 0:t.toLowerCase())!=null?i:"";return n==="image/png"||n==="image/jpeg"||n==="image/jpg"||n==="image/gif"||n==="image/webp"||n==="image/svg+xml"?true:!!(e&&/\.(?:png|jpe?g|gif|webp|svg)$/i.test(e))}function Fe(t,e){if(e==="distributed"){t.style.textAlign="justify",t.style.textAlignLast="justify";return}t.style.textAlign=e==="justify"?"justify":e;}function zt(t){if(t.customGeometry)return false;let e=t.presetGeometry,n=Math.min(t.bounds.width,t.bounds.height),i=Math.max(t.bounds.width,t.bounds.height);return (e==="line"||e==="straightConnector1")&&i>0&&(n===0||n/i<.02)}function Dt(t){return t.bounds.height>t.bounds.width?"vertical":"horizontal"}function Re(t,e={}){var n;if(t!=null&&t.imagePath){let i=e[t.imagePath],r=i==null?void 0:i.url;if(r&&Oe(i.contentType,t.imagePath))return `url("${r}") center / cover no-repeat`}return t!=null&&t.fillGradient&&t.fillGradient.colors.length>1?Y(t.fillGradient):(n=t==null?void 0:t.fillColor)!=null?n:"#fff"}function Vi(t,e,n,i,r,o){if(e!=null&&e.imagePath){let s=o[e.imagePath],a=s==null?void 0:s.url;if(a&&Oe(s.contentType,e.imagePath)){t.style.backgroundImage=`url("${a}")`,t.style.backgroundRepeat="no-repeat",t.style.backgroundSize=`${i.size.width*r}px ${i.size.height*r}px`,t.style.backgroundPosition=`${-n.bounds.left*r}px ${-n.bounds.top*r}px`;return}}t.style.background=Re(e,o);}function _(t){var i;let e=(i=t.presetAdjustments)==null?void 0:i.adj,n=e===void 0?.08:Math.max(0,Math.min(.5,e/1e5));return Math.min(t.bounds.width,t.bounds.height)*n}function Hi(t,e){var r,o,s;let n=(s=(r=t.presetAdjustments)==null?void 0:r.adj)!=null?s:(o=t.presetAdjustments)==null?void 0:o.adj1,i=n===void 0?.125:Math.max(.02,Math.min(.45,n/1e5));return Math.max(1,Math.min(t.bounds.width,t.bounds.height)*i*e)}function zi(t){return !t.customGeometry&&t.kind!=="line"&&!t.lineColor&&!!t.lineGradient&&t.lineGradient.colors.length>1&&(t.presetGeometry==="roundRect"||t.presetGeometry==="round1Rect"||t.presetGeometry==="ellipse")}function Di(t,e,n){var r;let i=document.createElement("div");return i.className="coco-ppt-css-geometry",i.style.clipPath=n,t.fillGradient&&t.fillGradient.colors.length>1?i.style.background=Y(t.fillGradient,Z(t)):t.fillColor&&(i.style.background=q(t.fillColor,Z(t))),t.lineColor&&(i.style.borderStyle=Ve(t.lineDash),i.style.borderWidth=`${Math.max(1,((r=t.lineWidth)!=null?r:9525)*e)}px`,i.style.borderColor=q(t.lineColor,t.lineOpacity)),i}function Y(t,e=1){return `linear-gradient(${Wt(t)}deg, ${ji(t,e).join(", ")})`}function Wt(t){return t.angle===void 0?160:Wi(t.angle+90)}function Wi(t){return (t%360+360)%360}function ji(t,e=1){return Ui(t).map(n=>{let i=Math.max(0,Math.min(1,n.opacity*e)),r=i<1?jt(n.color,i):n.color;return n.position===void 0?r:`${r} ${n.position}%`})}function Ui(t){return t.colors.map((e,n)=>{var s,a,l,d,c;let i=He(e),r=(s=t.positions)==null?void 0:s[n],o=Math.max(0,Math.min(1,(d=(l=(a=t.opacities)==null?void 0:a[n])!=null?l:i==null?void 0:i.opacity)!=null?d:1));return {color:(c=i==null?void 0:i.color)!=null?c:e,position:r===void 0?void 0:Math.max(0,Math.min(100,r)),opacity:o,index:n}}).sort((e,n)=>e.position===void 0&&n.position===void 0?e.index-n.index:e.position===void 0?1:n.position===void 0?-1:e.position-n.position||e.index-n.index).map(({color:e,position:n,opacity:i})=>({color:e,position:n,opacity:i}))}function jt(t,e){var s;let n=(s=t.match(/^#([0-9a-fA-F]{6})$/))==null?void 0:s[1];if(!n)return t;let i=Number.parseInt(n.slice(0,2),16),r=Number.parseInt(n.slice(2,4),16),o=Number.parseInt(n.slice(4,6),16);return `rgba(${i}, ${r}, ${o}, ${Math.max(0,Math.min(1,e))})`}function _i(t){switch(t){case "parallelogram":return "polygon(18% 0, 100% 0, 82% 100%, 0 100%)";case "trapezoid":return "polygon(18% 0, 82% 0, 100% 100%, 0 100%)";case "snip2DiagRect":return "polygon(8% 0, 100% 0, 100% 92%, 92% 100%, 0 100%, 0 8%)";case "rtTriangle":return "polygon(0 0, 100% 100%, 0 100%)";case "triangle":return "polygon(50% 0, 100% 100%, 0 100%)";case "diamond":return "polygon(50% 0, 100% 50%, 50% 100%, 0 50%)";case "pentagon":return "polygon(0 0, 72% 0, 100% 50%, 72% 100%, 0 100%, 22% 50%)";case "hexagon":return "polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%)";case "homePlate":return "polygon(50% 0, 100% 25%, 100% 100%, 0 100%, 0 25%)";case "leftRightArrow":return "polygon(0 50%, 18% 0, 82% 0, 100% 50%, 82% 100%, 18% 100%)";case "chevron":return "polygon(0 0, 72% 0, 100% 50%, 72% 100%, 0 100%, 28% 50%)";case "plaque":return "polygon(0 12%, 3% 12%, 3% 0, 97% 0, 97% 12%, 100% 12%, 100% 88%, 97% 88%, 97% 100%, 3% 100%, 3% 88%, 0 88%)";case "rightArrow":return "polygon(0 0, 78% 0, 100% 50%, 78% 100%, 0 100%)";case "leftArrow":return "polygon(22% 0, 100% 0, 100% 100%, 22% 100%, 0 50%)";case "bentArrow":return "polygon(0 0, 30% 0, 30% 58%, 82% 58%, 82% 35%, 100% 70%, 82% 100%, 82% 77%, 12% 77%, 12% 18%, 0 18%)";default:return}}function Ve(t){return t==="dot"||t==="sysDot"?"dotted":t&&t!=="solid"?"dashed":"solid"}function ke(t,e){if(!t||t==="solid"||e<=0)return;let n=Math.max(1,e),i=/^cust:(\d+):(\d+)$/i.exec(t);if(i){let r=Number(i[1])/1e5,o=Number(i[2])/1e5;if(r>0&&o>=0)return `${n*r} ${n*o}`}switch(t){case "dot":case "sysDot":return `${n} ${n*2}`;case "dash":case "sysDash":return `${n*4} ${n*2}`;case "dashDot":case "sysDashDot":return `${n*4} ${n*2} ${n} ${n*2}`;case "lgDash":return `${n*8} ${n*3}`;case "lgDashDot":return `${n*8} ${n*3} ${n} ${n*3}`;case "lgDashDotDot":return `${n*8} ${n*3} ${n} ${n*3} ${n} ${n*3}`;default:return `${n*4} ${n*2}`}}function Ut(t){return t.presetGeometry==="curvedUpArrow"||t.presetGeometry==="donut"||t.presetGeometry==="arc"||t.presetGeometry==="blockArc"||t.presetGeometry==="plaque"||t.presetGeometry==="parallelogram"||t.presetGeometry==="trapezoid"||t.presetGeometry==="snip2DiagRect"||t.presetGeometry==="rtTriangle"||t.presetGeometry==="triangle"||t.presetGeometry==="diamond"||t.presetGeometry==="pentagon"||t.presetGeometry==="hexagon"||t.presetGeometry==="homePlate"||t.presetGeometry==="leftRightArrow"||t.presetGeometry==="chevron"||t.presetGeometry==="rightArrow"||t.presetGeometry==="leftArrow"||t.presetGeometry==="bentArrow"}function Ki(t,e){var p,f,m;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-preset-geometry");let i=Math.max(1,t.bounds.width*e),r=Math.max(1,t.bounds.height*e),o=qi(t,e,i,r);(t.shadow||o>0)&&(n.style.overflow="visible"),n.setAttribute("viewBox","0 0 100 100"),n.setAttribute("preserveAspectRatio","none");let s=t.fillGradient&&t.fillGradient.colors.length>1?`coco-ppt-preset-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0,a=t.lineGradient&&t.lineGradient.colors.length>1?`coco-ppt-preset-line-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0;if(s&&t.fillGradient&&H(n,s,t.fillGradient),a&&t.lineGradient&&H(n,a,t.lineGradient),o>0){let b=document.createElementNS("http://www.w3.org/2000/svg","path");b.classList.add("coco-ppt-preset-extrusion"),b.setAttribute("d",Et(t)),(t.presetGeometry==="donut"||t.presetGeometry==="blockArc")&&b.setAttribute("fill-rule","evenodd"),b.setAttribute("fill",Zi(t)),b.setAttribute("transform",`translate(${j(o*.38)} ${j(o)})`),b.setAttribute("stroke","none"),n.append(b);}let l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",Et(t)),(t.presetGeometry==="donut"||t.presetGeometry==="blockArc")&&l.setAttribute("fill-rule","evenodd");let d=t.lineColor||t.lineGradient?Math.max(.5,((p=t.lineWidth)!=null?p:9525)*e*100/Math.max(i,r)):0;l.setAttribute("fill",t.presetGeometry==="arc"?"none":s?`url(#${s})`:(f=t.fillColor)!=null?f:"none");let c=Z(t);c!==void 0&&t.presetGeometry!=="arc"&&l.setAttribute("fill-opacity",String(c)),l.setAttribute("stroke",a?`url(#${a})`:(m=t.lineColor)!=null?m:"none"),l.setAttribute("stroke-width",String(d)),t.lineOpacity!==void 0&&l.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,t.lineOpacity))));let u=ke(t.lineDash,d);return u&&l.setAttribute("stroke-dasharray",u),l.setAttribute("stroke-linejoin","round"),t.presetGeometry==="arc"&&(l.setAttribute("stroke-linecap","round"),er(n,l,t)),n.append(l),n}function qi(t,e,n,i){var s,a;let r=(a=(s=t.threeD)==null?void 0:s.extrusionHeight)!=null?a:0;if(r<=0||t.presetGeometry==="arc")return 0;let o=r*e*100/Math.max(n,i);return Math.max(.8,Math.min(3,o))}function Zi(t){var r,o,s,a,l;let e=(s=(o=(r=t.fillGradient)==null?void 0:r.colors[0])!=null?o:t.fillColor)!=null?s:"#64748B",n=He(e),i=((a=t.threeD)==null?void 0:a.material)==="translucentPowder"?.12:.18;return jt(Yi((l=n==null?void 0:n.color)!=null?l:e,.8),i)}function Yi(t,e){let n=/^#?([0-9a-f]{6})$/i.exec(t);if(!n)return t;let i=n[1],r=Number.parseInt(i.slice(0,2),16),o=Number.parseInt(i.slice(2,4),16),s=Number.parseInt(i.slice(4,6),16);return `#${K(r*e)}${K(o*e)}${K(s*e)}`}function Et(t){switch(t.presetGeometry){case "curvedUpArrow":return ["M 16 88","C 3 61 9 28 38 13","C 60 2 87 9 97 34","L 82 36","C 74 22 59 18 45 24","C 23 33 17 61 28 82","Z","M 76 21","L 100 38","L 74 53","Z"].join(" ");case "donut":return ["M 50 2","A 48 48 0 1 1 49.99 2","M 50 27","A 23 23 0 1 0 50.01 27"].join(" ");case "blockArc":return Xi(t);case "plaque":return "M 4 0 H 96 Q 96 8 100 8 V 92 Q 96 92 96 100 H 4 Q 4 92 0 92 V 8 Q 4 8 4 0 Z";case "parallelogram":return "M 18 0 H 100 L 82 100 H 0 Z";case "trapezoid":return "M 18 0 H 82 L 100 100 H 0 Z";case "snip2DiagRect":return "M 8 0 H 100 V 92 L 92 100 H 0 V 8 Z";case "rtTriangle":return "M 0 0 L 100 100 H 0 Z";case "triangle":return "M 50 0 L 100 100 H 0 Z";case "diamond":return "M 50 0 L 100 50 L 50 100 L 0 50 Z";case "pentagon":return "M 0 0 H 72 L 100 50 L 72 100 H 0 L 22 50 Z";case "hexagon":return "M 25 0 H 75 L 100 50 L 75 100 H 25 L 0 50 Z";case "homePlate":return "M 50 0 L 100 25 V 100 H 0 V 25 Z";case "leftRightArrow":return "M 0 50 L 18 0 H 82 L 100 50 L 82 100 H 18 Z";case "chevron":return "M 0 0 H 72 L 100 50 L 72 100 H 0 L 28 50 Z";case "rightArrow":return "M 0 0 H 78 L 100 50 L 78 100 H 0 Z";case "leftArrow":return "M 22 0 H 100 V 100 H 22 L 0 50 Z";case "bentArrow":return "M 0 0 H 30 V 58 H 82 V 35 L 100 70 L 82 100 V 77 H 12 V 18 H 0 Z";case "arc":return Qi(t);default:return ""}}function Xi(t){var b,h,x,S,g,y;let e=((h=(b=t.presetAdjustments)==null?void 0:b.adj1)!=null?h:0)/6e4,n=((S=(x=t.presetAdjustments)==null?void 0:x.adj2)!=null?S:54e5)/6e4,i=Ji(n-e),r=e+i,o=48,s=Math.max(.08,Math.min(.42,((y=(g=t.presetAdjustments)==null?void 0:g.adj3)!=null?y:25e3)/1e5)),a=o*(1-s),l=oe(e,o),d=oe(r,o),c=oe(r,a),u=oe(e,a),p=Math.abs(i)>180?1:0,f=i>=0?1:0,m=f?0:1;return [`M ${l.x.toFixed(3)} ${l.y.toFixed(3)}`,`A ${o} ${o} 0 ${p} ${f} ${d.x.toFixed(3)} ${d.y.toFixed(3)}`,`L ${c.x.toFixed(3)} ${c.y.toFixed(3)}`,`A ${a.toFixed(3)} ${a.toFixed(3)} 0 ${p} ${m} ${u.x.toFixed(3)} ${u.y.toFixed(3)}`,"Z"].join(" ")}function Ji(t){if(!Number.isFinite(t)||t===0)return 90;let e=t%360;return e>330&&(e=330),e<-330&&(e=-330),Math.abs(e)<8&&(e=e<0?-8:8),e}function Qi(t){var a,l,d,c,u,p,f,m;let e=Mt((l=(a=t.presetAdjustments)==null?void 0:a.adj1)!=null?l:18e6),n=Mt((c=(d=t.presetAdjustments)==null?void 0:d.adj2)!=null?c:0),i=((p=(u=t.presetAdjustments)==null?void 0:u.adj1)!=null?p:18e6)/6e4,s=((((m=(f=t.presetAdjustments)==null?void 0:f.adj2)!=null?m:0)/6e4-i)%360+360)%360>180?1:0;return `M ${e.x.toFixed(3)} ${e.y.toFixed(3)} A 48 48 0 ${s} 1 ${n.x.toFixed(3)} ${n.y.toFixed(3)}`}function Mt(t){return oe(t/6e4,48)}function oe(t,e){let n=t/180*Math.PI;return {x:50+e*Math.cos(n),y:50+e*Math.sin(n)}}function er(t,e,n){var s,a;if(n.lineHeadEnd!=="triangle"&&n.lineTailEnd!=="triangle")return;let i=`coco-ppt-arc-arrow-${n.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`,r=document.createElementNS("http://www.w3.org/2000/svg","marker");r.setAttribute("id",i),r.setAttribute("viewBox","0 0 10 10"),r.setAttribute("markerWidth","7"),r.setAttribute("markerHeight","7"),r.setAttribute("refX","5"),r.setAttribute("refY","5"),r.setAttribute("orient","auto-start-reverse");let o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d","M 0 0 L 10 5 L 0 10 Z"),o.setAttribute("fill",(a=(s=n.lineColor)!=null?s:n.fillColor)!=null?a:"#000000"),r.append(o),t.append(r),n.lineHeadEnd==="triangle"&&e.setAttribute("marker-start",`url(#${i})`),n.lineTailEnd==="triangle"&&e.setAttribute("marker-end",`url(#${i})`);}function tr(t,e){if(!t.customGeometry||nr(t.customGeometry))return false;let n=Math.max(0,t.bounds.width)*Math.max(0,t.bounds.height),i=Math.max(1,e.size.width*e.size.height),r=n/i>.85,o=Math.abs(t.bounds.left)<e.size.width*.05&&Math.abs(t.bounds.top)<e.size.height*.05;return !(r&&o)}function nr(t){var a,l;if(t.paths.length!==1)return false;let e=t.paths[0];if(!e)return false;let n=(a=e.width)!=null?a:0,i=(l=e.height)!=null?l:0;if(n<=0||i<=0)return false;let r=[];for(let d of e.commands)if(d.kind==="moveTo"||d.kind==="lineTo")r.push({x:d.x,y:d.y});else if(d.kind!=="close")return false;let o=ir(r);return o.length!==4&&o.length!==5?false:[{x:0,y:0},{x:n,y:0},{x:n,y:i},{x:0,y:i}].every(d=>o.some(c=>Ee(c.x,d.x)&&Ee(c.y,d.y)))}function ir(t){let e=[];for(let n of t)e.some(i=>Ee(i.x,n.x)&&Ee(i.y,n.y))||e.push(n);return e}function Ee(t,e){return Math.abs(t-e)<=1}function rr(t,e){var c,u,p,f,m,b,h,x;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-custom-geometry","coco-ppt-picture-clip");let i=Math.max(1,(p=(u=(c=t.customGeometry)==null?void 0:c.paths[0])==null?void 0:u.width)!=null?p:t.bounds.width),r=Math.max(1,(b=(m=(f=t.customGeometry)==null?void 0:f.paths[0])==null?void 0:m.height)!=null?b:t.bounds.height);n.setAttribute("viewBox",`0 0 ${i} ${r}`),n.setAttribute("preserveAspectRatio","none");let o=`coco-ppt-picture-clip-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`,s=document.createElementNS("http://www.w3.org/2000/svg","defs"),a=document.createElementNS("http://www.w3.org/2000/svg","clipPath");a.setAttribute("id",o);for(let S of (x=(h=t.customGeometry)==null?void 0:h.paths)!=null?x:[]){let g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d",Kt(S.commands)),_t(S.commands)&&g.setAttribute("fill-rule","evenodd"),a.append(g);}s.append(a),n.append(s);let l=document.createElementNS("http://www.w3.org/2000/svg","image");l.setAttribute("href",e),l.setAttributeNS("http://www.w3.org/1999/xlink","href",e);let d=or(t,i,r);return l.setAttribute("x",String(d.x)),l.setAttribute("y",String(d.y)),l.setAttribute("width",String(d.width)),l.setAttribute("height",String(d.height)),l.setAttribute("preserveAspectRatio","none"),l.setAttribute("clip-path",`url(#${o})`),t.imageOpacity!==void 0&&l.setAttribute("opacity",String(Math.max(0,Math.min(1,t.imageOpacity)))),n.append(l),n}function or(t,e,n){var c,u,p,f,m,b,h,x;if(t.imageFillRect){let S=(c=t.imageFillRect.left)!=null?c:0,g=(u=t.imageFillRect.right)!=null?u:0,y=(p=t.imageFillRect.top)!=null?p:0,P=(f=t.imageFillRect.bottom)!=null?f:0;return {x:S*e,y:y*n,width:Math.max(.01,1-S-g)*e,height:Math.max(.01,1-y-P)*n}}let i=t.imageCrop;if(!i)return {x:0,y:0,width:e,height:n};let r=(m=i.left)!=null?m:0,o=(b=i.right)!=null?b:0,s=(h=i.top)!=null?h:0,a=(x=i.bottom)!=null?x:0,l=Math.max(.01,1-r-o),d=Math.max(.01,1-s-a);return {x:-r/l*e,y:-s/d*n,width:1/l*e,height:1/d*n}}function sr(t,e){var a,l,d,c,u,p,f,m,b,h;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-custom-geometry");let i=(d=(l=(a=t.customGeometry)==null?void 0:a.paths[0])==null?void 0:l.width)!=null?d:t.bounds.width,r=(p=(u=(c=t.customGeometry)==null?void 0:c.paths[0])==null?void 0:u.height)!=null?p:t.bounds.height;n.setAttribute("viewBox",`0 0 ${Math.max(1,i)} ${Math.max(1,r)}`),n.setAttribute("preserveAspectRatio","none");let o=t.fillGradient&&t.fillGradient.colors.length>1?`coco-ppt-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0,s=t.lineGradient&&t.lineGradient.colors.length>1?`coco-ppt-custom-line-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0;o&&t.fillGradient&&H(n,o,t.fillGradient),s&&t.lineGradient&&H(n,s,t.lineGradient);for(let x of (m=(f=t.customGeometry)==null?void 0:f.paths)!=null?m:[]){let S=lr(t,x),g=ar(x),y=g?document.createElementNS("http://www.w3.org/2000/svg","ellipse"):document.createElementNS("http://www.w3.org/2000/svg","path");g?(y.setAttribute("cx",String(g.cx)),y.setAttribute("cy",String(g.cy)),y.setAttribute("rx",String(g.rx)),y.setAttribute("ry",String(g.ry))):(y.setAttribute("d",Kt(x.commands)),_t(x.commands)&&y.setAttribute("fill-rule","evenodd"));let P=!(t.kind==="line"&&t.lineDash);y.setAttribute("fill",P?o?`url(#${o})`:(b=t.fillColor)!=null?b:"none":"none");let w=Z(t);P&&w!==void 0&&y.setAttribute("fill-opacity",String(w)),y.setAttribute("stroke",s?`url(#${s})`:(h=t.lineColor)!=null?h:"none"),y.setAttribute("stroke-width",String(S)),t.lineOpacity!==void 0&&y.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,t.lineOpacity))));let E=ke(t.lineDash,S);E&&y.setAttribute("stroke-dasharray",E),y.setAttribute("stroke-linejoin","round"),y.setAttribute("stroke-linecap","round"),n.append(y);}return n}function ar(t){var c,u,p,f,m,b;let e=t.width,n=t.height;if(!e||!n||e<=0||n<=0)return;let i=t.commands;if(i.length!==6||((c=i[0])==null?void 0:c.kind)!=="moveTo"||((u=i[1])==null?void 0:u.kind)!=="cubicBezierTo"||((p=i[2])==null?void 0:p.kind)!=="cubicBezierTo"||((f=i[3])==null?void 0:f.kind)!=="cubicBezierTo"||((m=i[4])==null?void 0:m.kind)!=="cubicBezierTo"||((b=i[5])==null?void 0:b.kind)!=="close")return;let r=e/2,o=n/2,s=[i[0],i[1],i[2],i[3],i[4]],a=[{x:e,y:o},{x:r,y:n},{x:0,y:o},{x:r,y:0},{x:e,y:o}],l=Math.max(e,n)*.003;return s.every((h,x)=>h.kind!=="moveTo"&&h.kind!=="cubicBezierTo"?false:Math.abs(h.x-a[x].x)<=l&&Math.abs(h.y-a[x].y)<=l)?{cx:r,cy:o,rx:e/2,ry:n/2}:void 0}function _t(t){return t.filter(e=>e.kind==="moveTo").length>1}function lr(t,e){if(!t.lineWidth)return 0;let n=e.width&&t.bounds.width?e.width/t.bounds.width:void 0,i=e.height&&t.bounds.height?e.height/t.bounds.height:void 0,r=[n,i].filter(s=>s!==void 0&&Number.isFinite(s)&&s>0),o=r.length>0?Math.max(...r):1;return Math.max(.5,t.lineWidth*o)}function dr(t,e){var c;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-gradient-outline");let i=Math.max(1,t.bounds.width*e),r=Math.max(1,t.bounds.height*e),o=Math.max(1,((c=t.lineWidth)!=null?c:9525)*e),s=o/2,a=`coco-ppt-line-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`;n.setAttribute("viewBox",`0 0 ${i} ${r}`),n.setAttribute("preserveAspectRatio","none"),H(n,a,t.lineGradient);let l=t.presetGeometry==="ellipse"?document.createElementNS("http://www.w3.org/2000/svg","ellipse"):document.createElementNS("http://www.w3.org/2000/svg","rect");l.tagName==="ellipse"?(l.setAttribute("cx",String(i/2)),l.setAttribute("cy",String(r/2)),l.setAttribute("rx",String(Math.max(0,i/2-s))),l.setAttribute("ry",String(Math.max(0,r/2-s)))):(l.setAttribute("x",String(s)),l.setAttribute("y",String(s)),l.setAttribute("width",String(Math.max(0,i-o))),l.setAttribute("height",String(Math.max(0,r-o))),l.setAttribute("rx",String(Math.max(0,_(t)*e-s))),l.setAttribute("ry",String(Math.max(0,_(t)*e-s)))),l.setAttribute("fill","none"),l.setAttribute("stroke",`url(#${a})`),l.setAttribute("stroke-width",String(o)),t.lineOpacity!==void 0&&l.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,t.lineOpacity))));let d=ke(t.lineDash,o);return d&&l.setAttribute("stroke-dasharray",d),n.append(l),n}function cr(t,e){var c,u;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-solid-outline");let i=Math.max(1,t.bounds.width*e),r=Math.max(1,t.bounds.height*e),o=Math.max(1,((c=t.lineWidth)!=null?c:9525)*e),s=t.kind!=="picture",a=s?o/2:0;s||(n.style.overflow="visible"),n.setAttribute("viewBox",`0 0 ${i} ${r}`),n.setAttribute("preserveAspectRatio","none");let l=t.presetGeometry==="ellipse"?document.createElementNS("http://www.w3.org/2000/svg","ellipse"):document.createElementNS("http://www.w3.org/2000/svg","rect");if(l.tagName==="ellipse")l.setAttribute("cx",String(i/2)),l.setAttribute("cy",String(r/2)),l.setAttribute("rx",String(Math.max(0,i/2-a))),l.setAttribute("ry",String(Math.max(0,r/2-a)));else {l.setAttribute("x",String(a)),l.setAttribute("y",String(a)),l.setAttribute("width",String(Math.max(0,i-a*2))),l.setAttribute("height",String(Math.max(0,r-a*2)));let p=t.presetGeometry==="roundRect"||t.presetGeometry==="round1Rect"?Math.max(0,_(t)*e-a):0;l.setAttribute("rx",String(p)),l.setAttribute("ry",String(p));}l.setAttribute("fill","none"),l.setAttribute("stroke",(u=t.lineColor)!=null?u:"none"),l.setAttribute("stroke-width",String(o)),t.lineOpacity!==void 0&&l.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,t.lineOpacity))));let d=ke(t.lineDash,o);return d&&l.setAttribute("stroke-dasharray",d),n.append(l),n}function ur(t,e){var m,b;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("coco-ppt-line-geometry");let i=Dt(t)==="vertical",r=Math.max(i?12:1,t.bounds.width*e),o=Math.max(i?1:12,t.bounds.height*e);n.setAttribute("viewBox",`0 0 ${r} ${o}`),n.setAttribute("preserveAspectRatio","none");let s=Math.max(1,((m=t.lineWidth)!=null?m:9525)*e),a=t.lineGradient&&t.lineGradient.colors.length>1?`coco-ppt-connector-gradient-${t.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0;a&&t.lineGradient&&H(n,a,t.lineGradient);let l=a?`url(#${a})`:q((b=t.lineColor)!=null?b:"#000000",t.lineOpacity),d=pr(s),c=Math.max(5,s*3.2),u=Math.max(5,s*2.6),p=Ct(t.lineHeadEnd),f=Ct(t.lineTailEnd);if(i){let h=r/2,x=p?Math.min(o,c):0,S=f?Math.max(0,o-c):o;X(n,h,x,h,S,l,s,t.lineOpacity,t.lineCap),t.lineHeadEnd==="oval"&&F(n,h,0,d,l),t.lineTailEnd==="oval"&&F(n,h,o,d,l),p&&Pe(n,h,0,"up",c,u,l,t.lineOpacity),f&&Pe(n,h,o,"down",c,u,l,t.lineOpacity);}else {let h=o/2,x=p?Math.min(r,c):0,S=f?Math.max(0,r-c):r;X(n,x,h,S,h,l,s,t.lineOpacity,t.lineCap),t.lineHeadEnd==="oval"&&F(n,0,h,d,l),t.lineTailEnd==="oval"&&F(n,r,h,d,l),p&&Pe(n,0,h,"left",c,u,l,t.lineOpacity),f&&Pe(n,r,h,"right",c,u,l,t.lineOpacity);}return n}function pr(t){return Math.max(3,t*3)}function Ct(t){return t==="arrow"||t==="triangle"}function Kt(t){let e=[],n;for(let i of t)if(i.kind==="moveTo")e.push(`M ${i.x} ${i.y}`),n={x:i.x,y:i.y};else if(i.kind==="lineTo")e.push(`L ${i.x} ${i.y}`),n={x:i.x,y:i.y};else if(i.kind==="cubicBezierTo")e.push(`C ${i.x1} ${i.y1} ${i.x2} ${i.y2} ${i.x} ${i.y}`),n={x:i.x,y:i.y};else if(i.kind==="arcTo"){let r=hr(i,n);r&&(e.push(r.path),n=r.end);}else e.push("Z");return e.join(" ")}function hr(t,e){if(!e||t.wR<=0||t.hR<=0||t.swAng===0)return;let n=t.stAng/6e4,i=t.swAng/6e4,r=n+i,o=kt(t.wR,t.hR,n),s={x:e.x-o.x,y:e.y-o.y},a=kt(t.wR,t.hR,r),l={x:s.x+a.x,y:s.y+a.y},d=Math.abs(i)>180?1:0,c=i>=0?1:0;return {path:`A ${j(t.wR)} ${j(t.hR)} 0 ${d} ${c} ${j(l.x)} ${j(l.y)}`,end:l}}function kt(t,e,n){let i=n/180*Math.PI;return {x:t*Math.cos(i),y:e*Math.sin(i)}}function j(t){return Number.isInteger(t)?String(t):t.toFixed(3).replace(/\.?0+$/,"")}function H(t,e,n){let i=document.createElementNS("http://www.w3.org/2000/svg","defs"),r=Array.isArray(n)?n:n.colors,o=Array.isArray(n)?void 0:n.positions,s=Array.isArray(n)?void 0:n.opacities,a=document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),l=Array.isArray(n)?{x1:0,y1:0,x2:100,y2:100}:fr(Wt(n));a.setAttribute("id",e),a.setAttribute("x1",`${l.x1}%`),a.setAttribute("y1",`${l.y1}%`),a.setAttribute("x2",`${l.x2}%`),a.setAttribute("y2",`${l.y2}%`),r.map((d,c)=>{var m,b,h,x;let u=(m=o==null?void 0:o[c])!=null?m:c/Math.max(1,r.length-1)*100,p=He(d),f=Math.max(0,Math.min(1,(h=(b=s==null?void 0:s[c])!=null?b:p==null?void 0:p.opacity)!=null?h:1));return {color:(x=p==null?void 0:p.color)!=null?x:d,offset:Math.max(0,Math.min(100,u)),opacity:f}}).sort((d,c)=>d.offset-c.offset).forEach(d=>{let c=document.createElementNS("http://www.w3.org/2000/svg","stop");c.setAttribute("offset",`${d.offset}%`),c.setAttribute("stop-color",d.color),d.opacity<1&&c.setAttribute("stop-opacity",String(d.opacity)),a.append(c);}),i.append(a),t.append(i);}function fr(t){let e=t*Math.PI/180,n=Math.sin(e),i=-Math.cos(e),r=50/Math.max(Math.abs(n),Math.abs(i),1e-4);return {x1:xe(50-n*r),y1:xe(50-i*r),x2:xe(50+n*r),y2:xe(50+i*r)}}function xe(t){return Math.round(Math.max(0,Math.min(100,t))*1e3)/1e3}function He(t){let e=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*([0-9.]+)\s*)?\)$/i.exec(t);if(!e)return;let n=Math.max(0,Math.min(255,Number(e[1]))),i=Math.max(0,Math.min(255,Number(e[2]))),r=Math.max(0,Math.min(255,Number(e[3]))),o=e[4]===void 0?1:Math.max(0,Math.min(1,Number(e[4])));return {color:`#${K(n)}${K(i)}${K(r)}`,opacity:o}}function K(t){return Math.round(t).toString(16).padStart(2,"0").toUpperCase()}function mr(t,e,n=true){var d,c,u,p,f,m,b,h,x,S,g,y,P,w,E;let i=document.createElement("table");i.className="coco-ppt-table";let r=t.table;if(!r)return i;let o=Math.max(r.rowCount,r.values.length),s=Math.max(r.columnCount,...r.values.map(v=>v.length),1),a=(c=(d=r.columnWidths)==null?void 0:d.reduce((v,k)=>v+k,0))!=null?c:0;if(a>0){let v=document.createElement("colgroup");for(let k=0;k<s;k++){let L=document.createElement("col"),$=(u=r.columnWidths)==null?void 0:u[k];$&&(L.style.width=`${$/a*100}%`),v.append(L);}i.append(v);}let l=(f=(p=r.rowHeights)==null?void 0:p.reduce((v,k)=>v+k,0))!=null?f:0;for(let v=0;v<o;v++){let k=document.createElement("tr"),L=(m=r.rowHeights)==null?void 0:m[v];k.style.height=l>0&&L?`${L/l*100}%`:`${100/o}%`;for(let $=0;$<s;$++){let T=Sr(r,v,$);if(T!=null&&T.hMerge||T!=null&&T.vMerge)continue;let A=document.createElement("td"),N=(h=(b=r.cellStyles)==null?void 0:b[v])==null?void 0:h[$];n&&(A.dataset.row=String(v),A.dataset.column=String($));let J=(S=(x=r.values[v])==null?void 0:x[$])!=null?S:"";if(A.dataset.cellText=J,br(A,J),T!=null&&T.columnSpan&&T.columnSpan>1&&(A.colSpan=T.columnSpan),T!=null&&T.rowSpan&&T.rowSpan>1&&(A.rowSpan=T.rowSpan),N!=null&&N.fillGradient&&N.fillGradient.colors.length>1?A.style.background=Y(N.fillGradient):N!=null&&N.fillColor&&!yr(N.fillColor)&&(A.style.background=N.fillColor),N!=null&&N.body){let I=N.body,B=(g=I.insetLeft)!=null?g:91440,le=(y=I.insetTop)!=null?y:45720,de=(P=I.insetRight)!=null?P:91440,tn=(w=I.insetBottom)!=null?w:45720;A.style.padding=`${le*e}px ${de*e}px ${tn*e}px ${B*e}px`,I.anchor==="middle"&&(A.style.verticalAlign="middle"),I.anchor==="bottom"&&(A.style.verticalAlign="bottom"),I.anchor==="top"&&(A.style.verticalAlign="top");}N!=null&&N.textStyle&&Be(A,N.textStyle,e),(E=N==null?void 0:N.textStyle)!=null&&E.alignment&&Fe(A,N.textStyle.alignment),gr(A,N,e),k.append(A);}i.append(k);}return i}function gr(t,e,n){let i=e==null?void 0:e.borders;i&&(Se(t,"Left",i.left,n),Se(t,"Right",i.right,n),Se(t,"Top",i.top,n),Se(t,"Bottom",i.bottom,n));}function Se(t,e,n,i){var a,l;if(!n)return;let r=`border${e}Style`,o=`border${e}Width`,s=`border${e}Color`;if(n.hidden){t.style[r]="none",t.style[o]="0";return}t.style[r]=Ve(n.dash),t.style[o]=`${Math.max(1,((a=n.width)!=null?a:9525)*i)}px`,t.style[s]=q((l=n.color)!=null?l:"#94A3B8",n.opacity);}function br(t,e){let n=e.split(/\r?\n/);if(n.length<=1){t.textContent=e;return}n.forEach((i,r)=>{r>0&&t.append(document.createElement("br"));let o=document.createElement("span");o.textContent=i,r>0&&(o.className="coco-ppt-table-cell-secondary-line",o.style.fontSize="0.7em",o.style.fontWeight="400"),t.append(o);});}function Nt(t,e,n,i){var r,o,s,a,l;return (l=(a=(s=t.dataset.cellText)!=null?s:(o=(r=e.table)==null?void 0:r.values[n])==null?void 0:o[i])!=null?a:t.textContent)!=null?l:""}function yr(t){let e=/^#?([0-9a-f]{6})$/i.exec(t);if(!e)return false;let n=e[1],i=Number.parseInt(n.slice(0,2),16),r=Number.parseInt(n.slice(2,4),16),o=Number.parseInt(n.slice(4,6),16);return (.2126*i+.7152*r+.0722*o)/255>.9}function qt(t,e){var a,l,d;let n=((a=t.distance)!=null?a:0)*e,i=((l=t.direction)!=null?l:0)*Math.PI/180,r=Math.cos(i)*n,o=Math.sin(i)*n,s=((d=t.blur)!=null?d:0)*e;return `${r}px ${o}px ${s}px ${xr(t)}`}function xr(t){var l,d;let e=(l=t.color)!=null?l:"#000000",n=(d=t.opacity)!=null?d:.25,i=/^#?([0-9a-f]{6})$/i.exec(e);if(!i)return e;let r=i[1],o=Number.parseInt(r.slice(0,2),16),s=Number.parseInt(r.slice(2,4),16),a=Number.parseInt(r.slice(4,6),16);return `rgba(${o}, ${s}, ${a}, ${Math.max(0,Math.min(1,n))})`}function Sr(t,e,n){var i;return (i=t.mergedCells)==null?void 0:i.find(r=>r.row===e&&r.column===n)}function Pr(t){var h,x,S,g,y,P,w,E,v,k,L,$,T,A,N,J;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 100 60"),e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("preserveAspectRatio","none");let n=(h=t.chart)==null?void 0:h.data;if(!(n!=null&&n.series.length))return R(e,(x=t.name)!=null?x:"Chart",4,8,4,"#17202a"),e;let i=(g=(S=t.chart)==null?void 0:S.type)!=null?g:"",r=(y=t.chart)==null?void 0:y.grouping,o=wr(n.series,i,r),s=Math.max(...o,1),a=Math.min(...o,0),l=(w=(P=t.chart)==null?void 0:P.axes)==null?void 0:w.value,d=(v=(E=t.chart)==null?void 0:E.axes)==null?void 0:v.category,c=(k=l==null?void 0:l.min)!=null?k:a>=0?0:a,u=(L=l==null?void 0:l.max)!=null?L:a>=0?Mr(s):s,p=vr(t),f=Cr(c,u,l==null?void 0:l.majorUnit);if(i.includes("doughnut")||i.includes("pie"))return Fr(e,n.series,p),e;if(i.includes("radar"))return Dr(e,n.series,p,($=l==null?void 0:l.max)!=null?$:s),e;(l==null?void 0:l.majorGridlines)!==false&&Tr(e,p,f,t,l,d),(l==null?void 0:l.deleted)!==true&&(l==null?void 0:l.tickLabelPosition)!=="none"&&Ar(e,p,c,u,f),kr(e,t,p);let m=n.series.filter(I=>{var B,le,de;return ((de=(le=I.type)!=null?le:(B=t.chart)==null?void 0:B.type)!=null?de:"").includes("bar")}),b=n.series.filter(I=>{var B;return ((B=I.type)!=null?B:"").includes("line")});return m.length>0?(Lr(e,m,p,c,u,t,r),It(e,(A=(T=m[0])==null?void 0:T.categories)!=null?A:[],p),m.some(I=>I.showValueLabels)&&Or(e,m,p,c,u),b.length>0&&Tt(e,b,p,c,u,void 0,t),b.some(I=>I.showValueLabels)&&Gt(e,b,p,c,u)):(Tt(e,n.series,p,c,u,["#22C7F2","#22C7F2","#94A3B8","#F59E0B"],t),It(e,(J=(N=n.series.find(I=>{var B;return (B=I.categories)==null?void 0:B.length}))==null?void 0:N.categories)!=null?J:[],p),n.series.some(I=>I.showValueLabels)&&Gt(e,n.series,p,c,u)),e}function wr(t,e,n){var s;let i=t.filter(a=>{var l;return ((l=a.type)!=null?l:e).includes("bar")});if(!Yt(n)||i.length<=1)return t.flatMap(a=>a.values);let r=Math.max(...i.map(a=>a.values.length),1),o=[];for(let a=0;a<r;a++){let l=0,d=0;for(let c of i){let u=(s=c.values[a])!=null?s:0;u>=0?l+=u:d+=u;}o.push(l,d);}return o}function vr(t){var c,u,p,f,m,b,h,x,S,g,y,P,w,E,v,k;let e=(c=t.chart)==null?void 0:c.plotLayout,n=(p=(u=t.chart)==null?void 0:u.type)!=null?p:"";if(!e)return Xt((b=(m=(f=t.chart)==null?void 0:f.data)==null?void 0:m.series)!=null?b:[])?{left:7,top:8,width:88,height:40}:Er(t)?{left:18,top:8,width:72,height:40}:((S=(x=(h=t.chart)==null?void 0:h.axes)==null?void 0:x.value)==null?void 0:S.deleted)===true?{left:6,top:8,width:90,height:40}:{left:18,top:8,width:76,height:40};let r=((P=(y=(g=t.chart)==null?void 0:g.axes)==null?void 0:y.value)==null?void 0:P.deleted)!==true&&!n.includes("doughnut")&&!n.includes("pie")&&!n.includes("radar")?14:4,o=((w=e.x)!=null?w:.12)*100,s=((E=e.y)!=null?E:.13)*60,a=((v=e.width)!=null?v:.82)*100,l=((k=e.height)!=null?k:.67)*60,d=Math.max(r,Math.min(20,o));return {left:d,top:Math.max(3,Math.min(12,s)),width:Math.max(40,Math.min(92,Math.min(a,96-d))),height:Math.max(24,Math.min(50,l))}}function Er(t){var o,s,a,l,d,c,u,p;let e=t.chart,n=(o=e==null?void 0:e.type)!=null?o:"";if(!e||!n.includes("bar")||e.plotLayout)return false;let i=(a=(s=e.data)==null?void 0:s.series)!=null?a:[];if(i.length!==1)return false;let r=Math.max((c=(d=(l=i[0])==null?void 0:l.categories)==null?void 0:d.length)!=null?c:0,(p=(u=i[0])==null?void 0:u.values.length)!=null?p:0);return r>0&&r<=2}function Mr(t){if(t<=0)return 1;if(t<=10)return Math.max(1,Math.ceil(t));let e=t*1.1,n=10**Math.floor(Math.log10(e));return Math.ceil(e/n)*n}function Cr(t,e,n){let i=Math.abs(e-t);return n&&n>0?Math.max(1,Math.min(8,Math.round(i/n))):Number.isInteger(i)&&i>0&&i<=6?i:4}function kr(t,e,n){var d,c,u,p,f,m,b;let i=(p=(d=e.chart)==null?void 0:d.title)!=null?p:(u=(c=e.chart)==null?void 0:c.data)==null?void 0:u.title;i&&R(t,i,n.left+n.width*.5,Math.max(4,n.top-3.2),3.1,"#17202A","middle");let r=(b=(m=(f=e.chart)==null?void 0:f.data)==null?void 0:m.series)!=null?b:[],o=r.map(h=>h.name).filter(h=>!!h).slice(0,4);if(o.length===0)return;let s=["#C50D13","#0EA5E9","#F59E0B","#A3E635"],a=n.left+n.width*.78,l=Math.max(4,n.top-2.4);o.forEach((h,x)=>{var y,P,w,E,v,k;let S=(y=r.find(L=>L.name===h))!=null?y:r[x],g=S?Nr(t,S,x,s):s[x];S&&((P=S.type)!=null?P:"").includes("line")?(X(t,a,l-1.1,a+2.3,l-1.1,g,.45),F(t,a+1.15,l-1.1,.45,(E=(w=S.marker)==null?void 0:w.fillColor)!=null?E:"#FFFFFF",(k=(v=S.marker)==null?void 0:v.lineColor)!=null?k:g,.32),R(t,h,a+2.8,l-.45,2.2,"#64748B")):(ae(t,a,l-1.8,1.4,1.4,g),R(t,h,a+2,l-.45,2.2,"#64748B")),a+=Math.max(9,Array.from(h).length*2.2+4.5);});}function Nr(t,e,n,i){var r,o;return ((r=e.type)!=null?r:"").includes("line")?(o=e.lineColor)!=null?o:i[n]:Ne(t,e,n,i)}function Tr(t,e,n,i,r,o){var l,d;let s=(l=r==null?void 0:r.gridlineColor)!=null?l:"#E8EDF3",a=At(r==null?void 0:r.gridlineWidth,i,.35);for(let c=0;c<=n;c++){let u=e.top+e.height/n*c;X(t,e.left,u,e.left+e.width,u,s,a);}X(t,e.left,e.top+e.height,e.left+e.width,e.top+e.height,(d=o==null?void 0:o.lineColor)!=null?d:"#CBD5E1",At(o==null?void 0:o.lineWidth,i,.45));}function Ar(t,e,n,i,r){for(let o=0;o<=r;o++){let s=i-(i-n)/r*o,a=e.top+e.height/r*o+1;R(t,ze(s),e.left-1.8,a,3,"#9AA6B2","end");}}function ze(t){return Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,"")}function Tt(t,e,n,i,r,o=["#CBD5E1","#94A3B8","#F59E0B","#A3E635"],s){e.forEach((a,l)=>{var p,f,m,b,h,x,S;if(a.values.length===0)return;let d=a.values.map((g,y)=>{let P=n.left+(a.values.length===1?n.width/2:n.width*y/(a.values.length-1)),w=n.top+n.height-(g-i)/Math.max(1,r-i)*n.height;return {x:P,y:w}}),c=Gr(d,a.smooth===true),u=(p=a.lineColor)!=null?p:o[l%o.length];if(en(t,c,u,Zt(a,s)),((f=a.marker)==null?void 0:f.symbol)!=="none"){let g=Math.max(.5,Math.min(1.6,((b=(m=a.marker)==null?void 0:m.size)!=null?b:5)*.18)),y=(x=(h=a.marker)==null?void 0:h.fillColor)!=null?x:u,P=(S=a.marker)==null?void 0:S.lineColor,w=Ir(a,s);d.forEach(E=>F(t,E.x,E.y,g,y,P,w));}});}function Ir(t,e){var n;if(!(!((n=t.marker)!=null&&n.lineWidth)||!(e!=null&&e.bounds.width)))return Math.max(.25,Math.min(1,t.marker.lineWidth/e.bounds.width*100))}function Zt(t,e){return !t.lineWidth||!(e!=null&&e.bounds.width)?.8:Math.max(.3,Math.min(1.2,t.lineWidth/e.bounds.width*100))}function Gr(t,e){if(t.length===0)return "";if(!e||t.length<3)return t.map((i,r)=>`${r===0?"M":"L"} ${i.x} ${i.y}`).join(" ");let n=[`M ${t[0].x} ${t[0].y}`];for(let i=0;i<t.length-1;i++){let r=t[Math.max(0,i-1)],o=t[i],s=t[i+1],a=t[Math.min(t.length-1,i+2)],l={x:o.x+(s.x-r.x)/6,y:o.y+(s.y-r.y)/6},d={x:s.x-(a.x-o.x)/6,y:s.y-(a.y-o.y)/6};n.push(`C ${l.x} ${l.y} ${d.x} ${d.y} ${s.x} ${s.y}`);}return n.join(" ")}function Lr(t,e,n,i,r,o,s){if(Yt(s)&&e.length>1){Rr(t,e,n,i,r,o);return}if(Xt(e)){$r(t,e,n,i,r,o);return}let a=["#C50D13","#0EA5E9","#F59E0B","#A3E635"],l=Math.max(...e.map(u=>u.values.length),1),d=n.width/l,c=Math.max(1,d*.48/Math.max(e.length,1));e.forEach((u,p)=>{let f=Ne(t,u,p,a);u.values.forEach((m,b)=>{var g,y;let h=(m-i)/Math.max(1,r-i)*n.height,x=n.left+b*d+(d-c*e.length)/2+p*c,S=n.top+n.height-h;ae(t,x,S,c,h,(y=(g=u.pointColors)==null?void 0:g[b])!=null?y:f,u.borderColor,De(u,o));});});}function $r(t,e,n,i,r,o){let s=["#C50D13","#0EA5E9","#F59E0B","#A3E635"],a=Math.max(...e.map(c=>c.values.length),1),l=n.width/a,d=Math.max(1,l*.34);e.forEach((c,u)=>{let p=Ne(t,c,u,s);c.values.forEach((f,m)=>{var S,g;let b=Me(f,n,i,r),h=Me(0,n,i,r),x=n.left+m*l+(l-d)/2;ae(t,x,Math.min(b,h),d,Math.max(.1,Math.abs(h-b)),(g=(S=c.pointColors)==null?void 0:S[m])!=null?g:p,c.borderColor,De(c,o));});});}function Rr(t,e,n,i,r,o){let s=["#C50D13","#0EA5E9","#F59E0B","#A3E635"],a=Math.max(...e.map(p=>p.values.length),1),l=n.width/a,d=Math.max(1,l*.46),c=new Array(a).fill(Math.max(0,i)),u=new Array(a).fill(Math.min(0,r));e.forEach((p,f)=>{let m=Ne(t,p,f,s);p.values.forEach((b,h)=>{var w,E;let x=b>=0?c[h]:u[h],S=x+b,g=Me(x,n,i,r),y=Me(S,n,i,r),P=n.left+h*l+(l-d)/2;ae(t,P,Math.min(g,y),d,Math.max(.1,Math.abs(y-g)),(E=(w=p.pointColors)==null?void 0:w[h])!=null?E:m,p.borderColor,De(p,o)),b>=0?c[h]=S:u[h]=S;});});}function Me(t,e,n,i){return e.top+e.height-(t-n)/Math.max(1,i-n)*e.height}function Yt(t){return t==="stacked"||t==="percentStacked"}function Xt(t){return new Set(t.map(n=>{var i;return (i=n.chartGroup)!=null?i:0})).size>1&&t.every(n=>!n.type||n.type.includes("bar"))}function De(t,e){if(t.borderWidth)return Jt(e!=null&&e.bounds.width?t.borderWidth/e.bounds.width*100:void 0,void 0)}function At(t,e,n){var i;return (i=Jt(t!==void 0&&e.bounds.width?t/e.bounds.width*100:void 0,n))!=null?i:n}function Jt(t,e){return t===void 0?e:Math.max(.15,Math.min(1.4,t))}function Ne(t,e,n,i){var r,o;if((r=e.fillGradient)!=null&&r.colors.length&&e.fillGradient.colors.length>1){let s=`coco-chart-gradient-${n}-${e.fillGradient.colors.join("-").replace(/[^a-zA-Z0-9_-]/g,"_")}`;return H(t,s,e.fillGradient),`url(#${s})`}return (o=e.fillColor)!=null?o:i[n%i.length]}function Br(t,e,n){var i,r,o;return (o=(r=(i=t.pointColors)==null?void 0:i[e])!=null?r:t.fillColor)!=null?o:n[e%n.length]}function It(t,e,n){if(e.length===0)return;let i=n.width/e.length;e.forEach((r,o)=>{R(t,r,n.left+i*o+i/2,n.top+n.height+5.2,3.2,"#64748B","middle");});}function Or(t,e,n,i,r){let o=Math.max(...e.map(l=>l.values.length),1),s=n.width/o,a=Math.max(1,s*.48/Math.max(e.length,1));e.forEach((l,d)=>{l.showValueLabels&&l.values.forEach((c,u)=>{let p=(c-i)/Math.max(1,r-i)*n.height,f=n.left+u*s+(s-a*e.length)/2+d*a+a/2,m=n.top+n.height-p-2;R(t,String(c),f,m,3,"#A7AEB8","middle");});});}function Gt(t,e,n,i,r){e.forEach(o=>{!o.showValueLabels||o.values.length===0||o.values.forEach((s,a)=>{let l=n.left+(o.values.length===1?n.width/2:n.width*a/(o.values.length-1)),d=n.top+n.height-(s-i)/Math.max(1,r-i)*n.height;R(t,String(s),l,Math.max(n.top+2,d-2.2),2.6,"#374151","middle");});});}function Fr(t,e,n){var f;let i=e[0];if(!(i!=null&&i.values.length))return;let r=["#1D4ED8","#E3B363","#60A5FA","#94A3B8","#F59E0B","#22C7F2"],o=i.values.reduce((m,b)=>m+Math.max(0,b),0)||1,s=n.left+n.width*.42,a=n.top+n.height*.5,l=Math.min(n.width,n.height)*.34,d=l*.58,c=-90;i.values.forEach((m,b)=>{let h=Math.max(0,m)/o*360,x=c,S=c+h;if(Wr(t,s,a,l,d,x,S,Br(i,b,r)),i.showCategoryNameLabels||i.showPercentLabels||i.showValueLabels){let g=Vr(i,m,b,o);if(g.length>0){let y=Hr(i,b,s,a,l+3.6,n,(x+S)/2);Kr(t,g,y.x,y.y,1.9,"#334155",y.x>=s?"start":"end");}}c+=h;}),F(t,s,a,d*.92,"#FFFFFF");let u=zr(i.name);u&&R(t,u,s,a-1.8,1.8,"#64748B","middle");let p=i.values[0];p!==void 0&&R(t,Qt(p,o),s,a+3.4,3.9,"#1E3A8A","middle"),jr(t,(f=i.categories)!=null?f:[],r,n.left+n.width*.72,n.top+9);}function Vr(t,e,n,i){var s;let r=[],o=(s=t.categories)==null?void 0:s[n];return t.showCategoryNameLabels&&o&&r.push(o),t.showValueLabels&&r.push(ze(e)),t.showPercentLabels&&r.push(Qt(e,i)),r}function Hr(t,e,n,i,r,o,s){return U(n,i,r,s)}function Qt(t,e){let i=(t>0&&t<=1&&e<=2?t:t/Math.max(1,e))*100;return `${Number.isInteger(i)?i.toFixed(0):i.toFixed(1)}%`}function zr(t){let e=(t!=null?t:"").trim();if(!e)return "";let n=Array.from(e);return n.length<=6?e:`${n.slice(0,5).join("")}\u2026`}function Dr(t,e,n,i){var d;let r=e[0];if(!(r!=null&&r.values.length))return;let o=r.values.length,s=n.left+n.width*.48,a=n.top+n.height*.5,l=Math.min(n.width,n.height)*.35;for(let c=1;c<=4;c++)en(t,Ur(o,s,a,l*c/4),"#CBD5E1",.25);for(let c=0;c<o;c++){let u=we(c,o,s,a,l);X(t,s,a,u.x,u.y,"#E2E8F0",.25);}e.forEach((c,u)=>{var m;if(!c.values.length)return;let p=c.values.slice(0,o).map((b,h)=>we(h,o,s,a,Math.max(0,b)/Math.max(1,i)*l)),f=document.createElementNS("http://www.w3.org/2000/svg","path");f.setAttribute("d",p.map((b,h)=>`${h===0?"M":"L"} ${b.x} ${b.y}`).join(" ")+" Z"),f.setAttribute("fill",u===0?"rgba(37, 99, 235, 0.08)":"none"),f.setAttribute("stroke",(m=c.lineColor)!=null?m:"#2563EB"),f.setAttribute("stroke-width",String(Zt(c,void 0))),t.append(f),c.marker&&c.marker.symbol!=="none"&&p.forEach(b=>{var h;return F(t,b.x,b.y,.9,(h=c.lineColor)!=null?h:"#2563EB")}),c.showValueLabels&&c.values.slice(0,o).forEach((b,h)=>{var S;let x=p[h];R(t,ze(b),x.x,x.y-1.2,2.2,(S=c.lineColor)!=null?S:"#2563EB","middle");});}),((d=r.categories)!=null?d:[]).slice(0,o).forEach((c,u)=>{let p=we(u,o,s,a,l+5);R(t,c,p.x,p.y+1,2.6,"#64748B","middle");});}function Wr(t,e,n,i,r,o,s,a){let d=Math.max(.01,s-o)>180?1:0,c=U(e,n,i,o),u=U(e,n,i,s),p=U(e,n,r,s),f=U(e,n,r,o),m=document.createElementNS("http://www.w3.org/2000/svg","path");m.setAttribute("d",[`M ${c.x} ${c.y}`,`A ${i} ${i} 0 ${d} 1 ${u.x} ${u.y}`,`L ${p.x} ${p.y}`,`A ${r} ${r} 0 ${d} 0 ${f.x} ${f.y}`,"Z"].join(" ")),m.setAttribute("fill",a),t.append(m);}function jr(t,e,n,i,r){e.slice(0,6).forEach((o,s)=>{ae(t,i,r+s*5,2.4,2.4,n[s%n.length]),R(t,o,i+3.6,r+s*5+2.2,2.7,"#334155");});}function Ur(t,e,n,i,r){return Array.from({length:t},(o,s)=>{let a=we(s,t,e,n,i);return `${s===0?"M":"L"} ${a.x} ${a.y}`}).join(" ")+(" Z")}function we(t,e,n,i,r){return U(n,i,r,-90+360*t/e)}function U(t,e,n,i){let r=i*Math.PI/180;return {x:t+Math.cos(r)*n,y:e+Math.sin(r)*n}}function X(t,e,n,i,r,o,s,a,l){let d=document.createElementNS("http://www.w3.org/2000/svg","line");d.setAttribute("x1",String(e)),d.setAttribute("y1",String(n)),d.setAttribute("x2",String(i)),d.setAttribute("y2",String(r)),d.setAttribute("stroke",o),d.setAttribute("stroke-width",String(s)),d.setAttribute("stroke-linecap",_r(l)),a!==void 0&&d.setAttribute("stroke-opacity",String(Math.max(0,Math.min(1,a)))),t.append(d);}function _r(t){return t==="rnd"?"round":t==="sq"?"square":"butt"}function en(t,e,n,i){let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",e),r.setAttribute("fill","none"),r.setAttribute("stroke",n),r.setAttribute("stroke-width",String(i)),r.setAttribute("stroke-linejoin","round"),r.setAttribute("stroke-linecap","round"),t.append(r);}function F(t,e,n,i,r,o,s){let a=document.createElementNS("http://www.w3.org/2000/svg","circle");a.setAttribute("cx",String(e)),a.setAttribute("cy",String(n)),a.setAttribute("r",String(i)),a.setAttribute("fill",r),o&&a.setAttribute("stroke",o),s!==void 0&&a.setAttribute("stroke-width",String(s)),t.append(a);}function Pe(t,e,n,i,r,o,s,a){let l=o/2,d=i==="right"?[[e,n],[e-r,n-l],[e-r,n+l]]:i==="left"?[[e,n],[e+r,n-l],[e+r,n+l]]:i==="down"?[[e,n],[e-l,n-r],[e+l,n-r]]:[[e,n],[e-l,n+r],[e+l,n+r]],c=document.createElementNS("http://www.w3.org/2000/svg","polygon");c.classList.add("coco-ppt-line-arrow"),c.setAttribute("points",d.map(u=>u.join(",")).join(" ")),c.setAttribute("fill",s),a!==void 0&&c.setAttribute("fill-opacity",String(Math.max(0,Math.min(1,a)))),t.append(c);}function ae(t,e,n,i,r,o,s,a){let l=document.createElementNS("http://www.w3.org/2000/svg","rect");l.setAttribute("x",String(e)),l.setAttribute("y",String(n)),l.setAttribute("width",String(i)),l.setAttribute("height",String(r)),l.setAttribute("fill",o),s&&a!==void 0&&(l.setAttribute("stroke",s),l.setAttribute("stroke-width",String(a))),t.append(l);}function R(t,e,n,i,r,o,s="start"){let a=document.createElementNS("http://www.w3.org/2000/svg","text");a.setAttribute("x",String(n)),a.setAttribute("y",String(i)),a.setAttribute("font-size",String(r)),a.setAttribute("fill",o),a.setAttribute("text-anchor",s),a.textContent=e,t.append(a);}function Kr(t,e,n,i,r,o,s="start"){e.forEach((a,l)=>{R(t,a,n,i+l*r*1.2,r,o,s);});}
|
|
78
|
+
exports.DEFAULT_PPT_SLIDE_SIZE=an;exports.EditorReadOnlyError=Q;exports.PptEditorSession=he;exports.buildPptEditorViewFromModel=ro;exports.buildPptEditorViewFromPptx=io;exports.buildPptEditorViewFromPresentation=it;exports.buildPptPresentationScene=ne;exports.buildPptSceneNode=ie;exports.buildPptSlideScene=ln;exports.findPptSceneNode=re;exports.findPptSceneSlide=z;exports.isPptShapeEditable=Jr;exports.normalizePptGeometry=te;exports.pptSceneGeometryToSourceGeometry=tt;exports.pptSceneNodeCapabilities=et;exports.renderNativePptEditor=yo;
|