@sigma-studio/editor 0.535.0 → 0.535.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -8836,7 +8836,7 @@ ${n}
8836
8836
  `}),I.childNodes.forEach(z=>D(z,_,M+1))};D(g,{});let k=T.map(I=>I.type==="text"?I.text:"").join("");!F.align&&/^[\s¥$€£+−-]*\d[\d,.\s]*%?$/.test(k)&&(F.align="right");let P=k.split(`
8837
8837
  `).length;if(y===1&&P>1){let I=Math.max(11,...T.map(B=>B.fontSize??11));u[m]=Math.max(u[m],P*I*2+4)}d.push({id:rt("cell"),rowId:s[m],columnId:l[h],rowSpan:y,colSpan:b,content:[{type:"paragraph",id:rt("p"),children:T}],style:F}),h+=b}}if(!d.length)return null;let p=l.map((m,h)=>c[h]??96),f={id:rt("table"),type:"tableShape",x:0,y:0,props:{w:p.reduce((m,h)=>m+h,0),h:u.reduce((m,h)=>m+h,0),table:{version:1,kind:"plain",columns:l.map((m,h)=>({id:m,width:{mode:"fixed",value:p[h]}})),rows:s.map((m,h)=>({id:m,height:{mode:"fixed",value:u[h]}})),cells:d,grid:{borderColor:"#b7b7b7",borderWidth:1,showInnerBorders:!0,showOuterBorder:!0},defaultCellStyle:{paddingX:4,paddingY:2,fontSize:11,align:"left",verticalAlign:"middle",backgroundColor:"#ffffff"}}}};return Nw([f],{})}function Sye(e){let t=e?.trim().match(/^(\d+(?:\.\d+)?)(px|pt)?$/i);if(!t)return;let n=Number(t[1])*(t[2]?.toLowerCase()==="pt"?96/72:1);return n>0&&n<=4096?n:void 0}function yVn(e){return e&&/^(#[\da-f]{3,8}|[a-z]+|rgba?\([\d.,%\s]+\))$/i.test(e)?e:void 0}var lNe,F$o,eCt,tCt=X(()=>{"use strict";Sp();ai();lNe=1e4,F$o=4e6,eCt=new WeakMap});function dNe(e){return nCt.includes(e.type.toLowerCase())||/\.tiff?$/i.test(e.name)}function xVn(e){return bVn.has(e.type)||dNe(e)}function ate(e){return e?Array.from(e).filter(xVn):[]}function rCt(e){let t=e.getData?.("text/html")??"";if(e.getData&&(e.getData(Zb)||t.includes("data-sigma-studio-clipboard"))&&Kf(e))return[];if(cNe(e))return[];let r=T$o(e.items).filter(xVn),o=r.length>0?r:ate(e.files),i=/<svg[\s>]|data:image\/svg\+xml[;,]/i.test(t);if(o.length>0&&(o.length>1||o.some(s=>s.type==="image/svg+xml")||!i))return o;let a=/<(?:svg|img)[\s>]/i.test(t)&&t.length<=16e6?new DOMParser().parseFromString(t,"text/html"):null;if(a&&o.length<=1&&!o.some(s=>s.type==="image/svg+xml")){let s=A$o(a);if(s)return[s]}return o.length>0?o:a?Array.from(a.querySelectorAll("img")).flatMap(s=>{let l=s.getAttribute("src")?.match(/^data:(image\/(?:png|jpeg|webp));base64,([a-z\d+/=\s]+)$/i);if(!l)return[];try{let c=Uint8Array.from(atob(l[2]),u=>u.charCodeAt(0));return[new File([c],"clipboard-chart",{type:l[1].toLowerCase()})]}catch{return[]}}):[]}function A$o(e){let t=e.body.querySelectorAll("svg, img");if(t.length!==1)return null;let n=t[0];if(n.localName!=="svg"&&!/^data:image\/svg\+xml[;,]/i.test(n.getAttribute("src")??""))return null;let r=new Set(["div","span","p","a","figure","br"]);if(Array.from(e.body.querySelectorAll("*")).some(i=>i!==n&&!n.contains(i)&&!r.has(i.localName)))return null;let o=e.body.cloneNode(!0);if(o.querySelector("svg, img").remove(),o.textContent?.trim())return null;try{let i=n.localName==="svg"?new XMLSerializer().serializeToString(n):WB(n.getAttribute("src")??"");return Xce(EC(Vce(i))),new File([i],"clipboard.svg",{type:"image/svg+xml"})}catch{return null}}function vVn(e){return e.items.length>0?Array.from(e.items).some(t=>{if(t.kind!=="file")return!1;if(bVn.has(t.type)||nCt.includes(t.type))return!0;let n=t.getAsFile?.();return!!(n&&dNe(n))}):ate(e.files).length>0}function T$o(e){return Array.from(e).flatMap(t=>{if(t.kind!=="file")return[];let n=t.getAsFile();return n?[n]:[]})}var bVn,nCt,uNe,tj=X(()=>{"use strict";ZN();ZN();Sp();tCt();pY();bVn=new Set(qse),nCt=["image/tiff","image/x-tiff"],uNe=[...qse,...nCt,".tif",".tiff"].join(",")});import{jsx as Zk}from"react/jsx-runtime";function ste(...e){return e.filter(Boolean).join(" ")}function pNe({ariaLabel:e,bordered:t=!1,className:n,inert:r,children:o}){return Zk("div",{className:ste("quick-toolbar-row",t&&"bordered",n),"aria-label":e,"data-editor-toolbar":"quick",inert:r,children:o})}function CA({ariaLabel:e,push:t=!1,className:n,children:r}){return Zk("div",{className:ste("toolbar-group flat",t&&"push",n),"aria-label":e,children:r})}function pP(){return Zk("div",{className:"toolbar-splitter","aria-hidden":"true"})}function oCt(e,t,n){t&&e.preventDefault(),n?.(e)}function Oo({buttonRef:e,active:t=!1,danger:n=!1,withText:r=!1,large:o=!1,preserveFocus:i=!0,tooltip:a,disabledReason:s,className:l,type:c="button",onMouseDown:u,children:d,...p}){let f=Zk("button",{ref:e,type:c,className:ste("icon-button",r&&"with-text",o&&"large",n&&"danger",t&&"active",l),onMouseDown:h=>oCt(h,i,u),...p,children:d}),m=p.disabled&&s?{label:s}:a;return m?Zk(Rk,{...m,children:f}):f}function Hd({buttonRef:e,active:t=!1,activeFormat:n=!1,variant:r,preserveFocus:o=!0,tooltip:i,disabledReason:a,className:s,type:l="button",onMouseDown:c,children:u,...d}){let p=Zk("button",{ref:e,type:l,className:ste("shape-menu-button icon-only",r?E$o[r]:void 0,t&&"active",n&&"active-format",s),onMouseDown:m=>oCt(m,o,c),...d,children:u}),f=d.disabled&&a?{label:a}:i;return f?Zk(Rk,{...f,children:p}):p}function wVn({compact:e=!1,fontFamily:t=!1,className:n,...r}){return Zk(Aa,{...r,className:ste("toolbar-select",e&&"compact",t&&"font-family-select",n)})}function rj({buttonRef:e,active:t=!1,text:n=!1,preserveFocus:r=!0,tooltip:o,disabledReason:i,className:a,type:s="button",onMouseDown:l,children:c,...u}){let d=Zk("button",{ref:e,type:s,className:ste("toolbar-icon-color",n&&"toolbar-icon-color-text",t&&"active",a),onMouseDown:f=>oCt(f,r,l),...u,children:c}),p=u.disabled&&i?{label:i}:o;return p?Zk(Rk,{...p,children:d}):d}var ya,Qf,Jk,E$o,Qk=X(()=>{"use strict";"use client";Jw();Vhe();ya=17,Qf=16,Jk=13;E$o={boxedText:"boxed-text-menu-button",lineHeight:"line-height-menu-button",textAlign:"text-align-menu-button",lineDash:"line-dash-menu-button",lineWidth:"line-width-menu-button",lineEndpoint:"line-endpoint-menu-button"}});import{Fragment as B$o,jsx as ql,jsxs as oj}from"react/jsx-runtime";function CVn({option:e,y:t,selected:n}){let r=`line-dash-sample ${n?"selected":""}`;return e.hidden?ql("line",{className:r,x1:"8",y1:t+3,x2:"30",y2:t-3}):e.double?oj(B$o,{children:[ql("line",{className:r,x1:"5",y1:t-1.4,x2:"33",y2:t-1.4}),ql("line",{className:r,x1:"5",y1:t+1.4,x2:"33",y2:t+1.4})]}):ql("line",{className:r,x1:"5",y1:t,x2:"33",y2:t,strokeDasharray:e.dasharray})}function P$o({options:e,value:t,mixed:n}){return ql("svg",{className:`line-dash-preview line-dash-preview-button ${n?"mixed":""}`,viewBox:"0 0 38 24","aria-hidden":"true",children:e.map((r,o)=>ql(CVn,{option:r,y:e.length===1?12:4+o*(16/(e.length-1)),selected:t===r.value&&!n},r.value))})}function M$o({option:e}){return ql("svg",{className:"line-dash-preview",viewBox:"0 0 38 18","aria-hidden":"true",children:ql(CVn,{option:e,y:9,selected:!1})})}function FVn({size:e,mixed:t=!1,variant:n="menu",options:r}){let o=r??fNe.map(a=>({...a,label:""})),i=o.find(a=>a.value===e)??{value:e,label:"",strokeWidth:2};return n==="button"?ql("svg",{className:`line-width-preview line-width-preview-button ${t?"mixed":""}`,viewBox:"0 0 38 24","aria-hidden":"true",children:o.map((a,s)=>ql("line",{className:`line-width-sample ${e===a.value&&!t?"selected":""}`,x1:"5",y1:5+s*5,x2:"33",y2:5+s*5,strokeWidth:a.strokeWidth},a.value))}):ql("svg",{className:`line-width-preview ${t?"mixed":""}`,viewBox:"0 0 36 18","aria-hidden":"true",children:ql("line",{x1:"5",y1:"9",x2:"31",y2:"9",strokeWidth:i.strokeWidth,strokeDasharray:t?"3 3":void 0})})}function aF({buttonRef:e,options:t,currentValue:n,open:r,disabled:o=!1,onToggle:i,onSelect:a,popoverZIndex:s}){let l=We("chrome"),c=t??I$o.map(f=>({...f,label:l(`format.lineDash.${f.value}`)})),d=c.find(f=>f.value===n)?.label??l("format.mixed"),p=l("format.currentValue",{label:l("format.lineDash.label"),value:d});return oj("div",{className:"shape-menu-anchor",children:[ql(Hd,{buttonRef:e,variant:"lineDash",active:r,tooltip:{label:l("format.lineDash.tooltip",{value:d})},"aria-label":p,"aria-haspopup":"menu","aria-expanded":r,disabled:o,onClick:i,children:ql(P$o,{options:c,value:n,mixed:!n})}),ql(Wo,{open:r,anchorRef:e,onClose:i,className:"shape-menu line-dash-menu",role:"menu",ariaLabel:l("format.lineDash.label"),zIndex:s,children:c.map(f=>{let m=n===f.value;return oj("button",{type:"button",role:"menuitemradio","aria-label":f.label,"aria-checked":m,className:m?"selected":"",onClick:()=>a(f.value),children:[ql("span",{className:"line-dash-menu-check","aria-hidden":"true",children:m?ql(bi,{size:14}):null}),ql(M$o,{option:f}),ql("span",{children:f.label})]},f.value)})})]})}function eE({buttonRef:e,options:t,currentValue:n,open:r,disabled:o=!1,onToggle:i,onSelect:a,popoverZIndex:s}){let l=We("chrome"),c=t??fNe.map(m=>({...m,label:l(`format.lineWidth.${m.value}`)})),d=c.find(m=>m.value===n)?.label??l("format.mixed"),p=l("format.currentValue",{label:l("format.lineWidth.label"),value:d}),f=n??c[Math.min(1,c.length-1)]?.value??c[0].value;return oj("div",{className:"shape-menu-anchor",children:[ql(Hd,{buttonRef:e,variant:"lineWidth",active:r,tooltip:{label:l("format.lineWidth.tooltip",{value:d})},"aria-label":p,"aria-haspopup":"menu","aria-expanded":r,disabled:o,onClick:i,children:ql(FVn,{size:f,mixed:!n,variant:"button",options:t})}),ql(Wo,{open:r,anchorRef:e,onClose:i,className:"shape-menu line-width-menu",role:"menu",ariaLabel:l("format.lineWidth.label"),zIndex:s,children:c.map(m=>{let h=n===m.value;return oj("button",{type:"button",role:"menuitemradio","aria-label":m.label,"aria-checked":h,className:h?"selected":"",onClick:()=>a(m.value),children:[ql("span",{className:"line-width-menu-check","aria-hidden":"true",children:h?ql(bi,{size:14}):null}),ql(FVn,{size:m.value,options:t}),ql("span",{children:m.label})]},m.value)})})]})}function AVn({buttonRef:e,options:t,currentValue:n,open:r,disabled:o=!1,onToggle:i,onSelect:a}){let s=We("shape"),l=t.find(d=>d.value===n)??t[0],c=l.icon,u=s("textAlign.currentAria",{align:l.label});return oj("div",{className:"shape-menu-anchor",children:[oj(Hd,{buttonRef:e,variant:"textAlign",active:r,tooltip:{label:s("textAlign.tooltip",{align:l.label})},"aria-label":u,"aria-haspopup":"menu","aria-expanded":r,disabled:o,onClick:i,children:[ql(c,{size:16}),ql(ta,{size:12})]}),ql(Wo,{open:r,anchorRef:e,onClose:i,className:"shape-menu text-align-menu",role:"menu",ariaLabel:s("textAlign.menuAria"),children:t.map(({value:d,label:p,icon:f})=>ql("button",{type:"button",role:"menuitemradio","aria-checked":n===d,"aria-label":p,title:p,className:n===d?"selected":"",onClick:()=>a(d),children:ql(f,{size:18})},d))})]})}var I$o,fNe,ij=X(()=>{"use strict";"use client";er();Qk();Qb();un();I$o=[{value:"solid"},{value:"dashed",dasharray:"8 5"},{value:"dotted",dasharray:"1 5"}],fNe=[{value:"xs",strokeWidth:.75},{value:"s",strokeWidth:1.25},{value:"m",strokeWidth:2},{value:"l",strokeWidth:3},{value:"xl",strokeWidth:5}]});function c_(e,t){return t.width===0&&t.height===0&&e.getClientRects().length===0}function gNe(e){if(e)return e.undrawn?e:{...e,undrawn:!0}}function yNe(e,t){return e.undrawn===!0==(t.undrawn===!0)}function fP(e){return e.undrawn!==!0}var mP=X(()=>{"use strict"});function IVn(){return{epoch:0,nodes:new Map}}function kVn(e){let t=Number(e.getAttribute(sj)??0),n=Number(e.getAttribute(Fye)??0);return{dx:Number.isFinite(t)?t:0,dy:Number.isFinite(n)?n:0}}function PVn(e,t){let n=t.zoomFactor>0?t.zoomFactor:1,r=e.getBoundingClientRect(),o=t.cache;o&&t.cacheEpoch!==void 0&&o.epoch!==t.cacheEpoch&&(o.epoch=t.cacheEpoch,o.nodes.clear());let i=new Set,a=(d,p)=>({top:(d.top-r.top)/n-p.dy,bottom:(d.bottom-r.top)/n-p.dy,left:(d.left-r.left)/n-p.dx,width:d.width/n}),s=(d,p)=>(d-r.top)/n-p.dy,l=(d,p)=>{if(d.parentElement?.closest(DVn))return null;let f=d.getAttribute(u_),m=f!==null,h=m?f:d.getAttribute("data-sigma-doc-id");if(!h)return null;let g=d.getBoundingClientRect();if(c_(d,g))return i.add(h),null;let y=kVn(d),b={dx:p.dx+y.dx,dy:p.dy+y.dy},x=a(g,b),v=x.bottom-x.top;if(m&&(v<=.5||i.has(h)))return null;i.add(h);let S=(m?d.getAttribute(sCt):d.closest(".ProseMirror")?.dataset.flowMeasureRevision)??"0",F=o?.nodes.get(h),w,C;if(F&&F.element===d&&F.revision===S&&Math.abs(F.width-x.width)<.01&&Math.abs(F.height-v)<.01)w=F.ink,C=F.chrome;else{let T=X$o(d,D=>s(D,b)-x.top,m?z$o:N$o);w=T.ink,C=T.chrome,o?.nodes.set(h,{element:d,revision:S,width:x.width,height:v,ink:w,chrome:C})}let A=m||j$o.has(d.tagName.toUpperCase())||t.breakHostIds!==void 0&&!t.breakHostIds.has(h)?[]:V$o(d,t.breakIds,T=>s(T,b));return{id:h,...m?{kind:"extension"}:{},rect:x,ink:w.map(T=>({...T,top:T.top+x.top,bottom:T.bottom+x.top})),chrome:C.map(T=>({...T,top:T.top+x.top,bottom:T.bottom+x.top})),breakBefore:!m&&t.breakIds.has(h),...A.length>0?{innerBreaks:A}:{}}},c=(d,p)=>{let f=[];return d.querySelectorAll(R$o).forEach(m=>{let h=l(m,p);h&&f.push(h)}),f},u=[];if(e.querySelectorAll(":scope > [data-flow-unit-id]").forEach(d=>{let p=d.getAttribute("data-flow-unit-id");if(!p)return;let f=kVn(d),m=a(d.getBoundingClientRect(),f),h=d.getAttribute(Aye)==="full"?"full":"column",g=d.getAttribute(Cye)==="true";if(d.querySelector("[data-large-paste-deferred]")){u.push({id:p,rect:m,span:h,breakBefore:g,nodes:[],attachments:[],placeholder:!0});return}let y=Array.from(d.querySelectorAll(":scope > .layout-section-paper-body > .layout-section-independent-columns > .layout-section-independent-column[data-layout-column-index]")),b=[],x;y.length>0?x=y.map(C=>({index:Number(C.getAttribute("data-layout-column-index")??0),rect:a(C.getBoundingClientRect(),f),nodes:c(C,f)})):b=c(d,f);let v=[];d.querySelectorAll(".problem-number-marker").forEach(C=>{if(C.closest(DVn))return;let A=C.getBoundingClientRect();A.height>.5&&v.push({top:s(A.top,f),bottom:s(A.bottom,f),kind:"atom"})});let S;if(d.classList.contains("with-frame")){let C=d.getAttribute("data-problem-id")??p,A=getComputedStyle(d);S={borderLeft:Number.parseFloat(A.borderLeftWidth)||0,borderTop:Number.parseFloat(A.borderTopWidth)||0,key:`${C}:frame`,first:d.classList.contains("first-frame-area"),last:d.classList.contains("last-frame-area"),top:m.top,bottom:m.bottom}}let F;if(Number.parseFloat(d.style.minHeight||"0")>0){let C=d.querySelector(":scope > .problem-area-paper-content, :scope > .layout-section-paper-body");if(C){let A=Math.max(s(C.getBoundingClientRect().bottom,f),...b.filter(P=>P.kind==="extension").map(P=>P.rect.bottom)),T=getComputedStyle(d),D=(Number.parseFloat(T.paddingBottom)||0)+(Number.parseFloat(T.borderBottomWidth)||0),k=m.bottom-(S?.last?D:0);k>A+.5&&(F={top:A,bottom:k})}}u.push({id:p,rect:m,span:h,breakBefore:g,leadingSpace:Math.max(0,Number.parseFloat(d.style.marginTop)||0),nodes:b,...x?{columns:x}:{},attachments:v,...S?{frame:S}:{},...F?{reservation:F}:{}})}),o)for(let d of o.nodes.keys())i.has(d)||o.nodes.delete(d);return{units:u}}function V$o(e,t,n){if(t.size===0)return[];let r=new Map;e.querySelectorAll(".page-break-marker[data-page-break-block-id]").forEach(i=>{let a=i.getAttribute("data-page-break-block-id");a&&!r.has(a)&&r.set(a,n(i.getBoundingClientRect().top))});let o=[];return e.querySelectorAll("[data-sigma-doc-id]").forEach(i=>{let a=i.getAttribute("data-sigma-doc-id");if(!a||!t.has(a))return;let s=i.parentElement?.closest(".sigma-doc-layout-section-block");if(s&&e.contains(s)&&Number(s.getAttribute("data-column-count")??1)>1)return;let l=n(i.getBoundingClientRect().top);o.push({top:l,contentEnd:Math.min(l,r.get(a)??l)})}),o.sort((i,a)=>i.top-a.top)}function X$o(e,t,n){let r=[],o=[],i=e.ownerDocument.createRange(),a=e.ownerDocument.defaultView,s=e.getAttribute("data-sigma-doc-id")??e.getAttribute(u_),l={top:Number.NEGATIVE_INFINITY,bottom:Number.POSITIVE_INFINITY},c=(f,m)=>{let h=Math.max(f.top,m.top),g=Math.min(f.bottom,m.bottom);return g-h>.5?{top:h,bottom:g}:null},u=(f,m,h)=>{if(f.height<=.5)return;let g=c(f,h);g&&r.push({top:t(g.top),bottom:t(g.bottom),kind:m})},d=(f,m)=>{if(!n.clipToOverflow||f===e||!a)return m;let h=a.getComputedStyle(f),g=h.overflowY||h.overflow;if(!g||g==="visible")return m;let y=f.getBoundingClientRect();return{top:Math.max(m.top,y.top),bottom:Math.min(m.bottom,y.bottom)}},p=(f,m)=>{if(f!==e&&f.matches(n.excluded))return;if(f.matches(G$o)){let g=c(f.getBoundingClientRect(),m);g&&o.push({id:f.getAttribute("data-sigma-doc-id")??`${s}:chrome:${o.length}`,top:t(g.top),bottom:t(g.bottom)})}if(f.matches(".sigma-doc-box-title")&&!(f.textContent??"").trim())return;if(f!==e&&f.matches(U$o)){for(let g of Array.from(f.getClientRects()))u(g,"atom",m);return}if(H$o.has(f.tagName.toUpperCase())){u(f.getBoundingClientRect(),"object",m);return}let h=d(f,m);for(let g of Array.from(f.childNodes)){if(g.nodeType===Node.TEXT_NODE){if(!(g.textContent??"").trim())continue;i.selectNodeContents(g);for(let y of Array.from(i.getClientRects()))u(y,"text",h);continue}if(g instanceof HTMLBRElement){i.selectNode(g),u(i.getBoundingClientRect(),"empty",h);continue}g instanceof Element&&p(g,h)}};return p(e,l),{ink:r,chrome:o}}var sj,Fye,Cye,Aye,u_,sCt,EVn,R$o,DVn,_$o,O$o,N$o,z$o,U$o,H$o,G$o,j$o,lj=X(()=>{"use strict";mP();sj="data-flow-dx",Fye="data-flow-dy",Cye="data-flow-break-before",Aye="data-flow-span",u_="data-flow-extension-node-id",sCt="data-flow-measure-revision",EVn="data-flow-extension-replica",R$o=`.ProseMirror > [data-sigma-doc-id], [${u_}]`,DVn=`[${u_}]`,_$o=["[data-formatting-mark]",".text-formatting-mark",".ProseMirror-separator",".sigma-doc-block-action-button",".sigma-doc-box-corner",".page-break-marker",".page-break-spacer","math-field",".katex-mathml","[data-editor-only]","button"].join(","),O$o=[".katex-mathml","[data-editor-only]"].join(","),N$o={excluded:_$o,clipToOverflow:!1},z$o={excluded:O$o,clipToOverflow:!0},U$o=".inline-math-node, .boxed-run-frame, .math-preview",H$o=new Set(["HR","IMG","SVG","CANVAS","VIDEO","IFRAME","OBJECT","EMBED"]),G$o=".sigma-doc-box-block, pre",j$o=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","HR"])});function _Vn(e){return e.columns===1?{}:{[MVn]:e.mode,[BVn]:String(e.pageWidth)}}function W2(e){let t=e?.closest?.(".page-canvas");if(!t||t.getAttribute(MVn)!=="spread")return null;let n=Number(t.getAttribute(BVn)),r=Number(t.getAttribute(W$o)),o=Number(t.getAttribute(q$o));return!(n>0)||!(r>0)||!(o>=r)?null:kB({mode:"spread",pageWidth:n,pageHeight:r,pageGap:o-r})}function OVn(e){return!e||!e.pageShiftX&&!e.pageShiftY?{}:{[LVn]:String(e.pageShiftX??0),[RVn]:String(e.pageShiftY??0)}}function hP(e){let t=e.closest(`[${sj}]`);if(!t)return CC;let n=Number(t.getAttribute(LVn)??0),r=Number(t.getAttribute(RVn)??0);return n===0&&r===0?CC:{x:n,y:r}}function bNe(e,t){let n=W2(e);return n?O5(n,_K(n,t)):CC}function K$o(e){return!e||e.closest(".a4-page-sheet, .page-layout-controls")?null:W2(e)}function xNe(e,t,n,r){let o=K$o(e);if(e.closest(".page-canvas")&&!e.closest(".a4-page-sheet, .page-layout-controls"))return{scaleX:1/G0(e,"x"),scaleY:1/G0(e,"y"),shiftOf:o?hP:()=>CC};if(!o)return{scaleX:n/t.width,scaleY:r/t.height,shiftOf:()=>CC};let i=Eb(o,1).width/t.width;return{scaleX:i,scaleY:i,shiftOf:hP}}var MVn,BVn,W$o,q$o,LVn,RVn,sF=X(()=>{"use strict";Dn();lj();Gc();MVn="data-page-arrangement",BVn="data-page-width",W$o="data-page-height",q$o="data-page-stride",LVn="data-flow-page-shift-x",RVn="data-flow-page-shift-y"});function J$o(e,t){if(e.left===void 0||t.left===void 0)return!0;let n=e.width??0,r=t.width??0,o=Math.max(4,Math.min(n||0,r||0)*.08);return Math.abs(e.left-t.left)<=o}function Q$o(e,t,n){let r=n.lines;if(!r?.length)return;let o=[...r].sort((a,s)=>a.top-s.top),i=o[0];for(let a of o)if(a.top<=e+.5)i=a;else break;return{index:i.index,dy:t-i.top}}function dCt(e,t){let n=e.anchor?.type==="shape"&&e.anchor.shapeId===t.id?e.anchor:null,r=yi(t),o=n?.rx,i=n?.ry,a=typeof o=="number"?r.x+r.w*o:t.x,s=typeof i=="number"?r.y+r.h*i:t.y;return{type:"shape",shapeId:t.id,dx:e.x-a,dy:e.y-s,...o===void 0?{}:{rx:o},...i===void 0?{}:{ry:i}}}function gP(e,t,n,r,o){let i=n.filter(h=>fP(h));if(i.length===0)return{type:"page"};let a=i.filter(h=>!h.derived),s=a.length>0?a:i,l=pCt(s),c=Number.isFinite(r)?qVn(r,l):void 0,u=c?s.filter(h=>c.blockIds.has(h.id)):[],d=u.length>0?u:s,p=tZo(e,d,l,c?.index),f=p.left===void 0||o===void 0?void 0:o-p.left,m=Q$o(e,t,p);return{type:"block",blockId:p.id,dy:t-p.top,...f===void 0?{}:{dx:f},...m===void 0?{}:{line:m}}}function UVn(e){let t=jVn(e),n=VVn(e),r=e.top+(e.height??0),o=[...e.lines??[]].sort((i,a)=>i.top-a.top);return o.length===0?[{blockId:e.id,y:r,left:t,width:n}]:o.map((i,a)=>({blockId:e.id,lineIndex:i.index,y:a===o.length-1?Math.max(i.top+i.height,r):i.top+i.height,left:t,width:n}))}function HVn(e,t){let n=UVn(t);return e.line?n.find(r=>r.lineIndex===e.line?.index)??n[n.length-1]:{blockId:t.id,y:t.top,left:jVn(t),width:VVn(t)}}function eZo(e,t){let n=UVn(e),r=[...e.lines??[]].sort((i,a)=>i.top-a.top);if(r.length===0)return n[0];let o=0;for(let i=0;i<r.length&&r[i].top<=t+.5;i+=1)o=i;return n[o]}function vNe(e,t,n){if(t.length===0)return;let r=t.filter(d=>fP(d)),o=r.length>0?r:t,i=pCt(o),a=Number.isFinite(e.x)?qVn(e.x,i):void 0,s=a?o.filter(d=>a.blockIds.has(d.id)):[],l=s.length>0?s:o,c,u=Number.POSITIVE_INFINITY;for(let d of l){let p=eZo(d,n),f=Math.abs(p.y-e.y);f<u&&(u=f,c=p)}return c}function GVn(e,t,n,r){let o=e.lineIndex===void 0?void 0:t.lines?.find(a=>a.index===e.lineIndex),i=t.left===void 0||r===void 0?void 0:r-t.left;return{type:"block",blockId:t.id,dy:n-t.top,...i===void 0?{}:{dx:i},...o===void 0?{}:{line:{index:o.index,dy:n-o.top}}}}function jVn(e){return typeof e.left=="number"?e.left:$$o}function VVn(e){return Math.max(Y$o,e.width??Z$o)}function tZo(e,t,n,r){let o=nZo(t,n);if(o.length===0)return t[0];if(n.length<=1){let l=o[0];for(let c of o)if(c.top<=e)l=c;else break;return l}let i=WVn(e),a={page:i.page,column:r??Number.MAX_SAFE_INTEGER,localY:i.localY,top:e,index:Number.MAX_SAFE_INTEGER},s=o[0];for(let l=0;l<o.length;l+=1){let c=o[l],u=uCt(c,l,n);if(XVn(u,a)<=0)s=c;else break}return s}function nZo(e,t=pCt(e)){return t.length<=1?[...e].sort((n,r)=>n.top-r.top):e.map((n,r)=>({block:n,index:r})).sort((n,r)=>XVn(uCt(n.block,n.index,t),uCt(r.block,r.index,t))).map(n=>n.block)}function uCt(e,t,n){let r=WVn(e.top);return{page:r.page,column:rZo(e,n)??0,localY:r.localY,top:e.top,index:t}}function XVn(e,t){return e.page-t.page||e.column-t.column||e.localY-t.localY||e.top-t.top||e.index-t.index}function WVn(e){let t=Math.max(0,Math.floor((e+lCt)/j5));return{page:t,localY:e-t*j5}}function pCt(e){let t=[];for(let n of e){if(typeof n.left!="number"||typeof n.width!="number")continue;let r=t.find(o=>J$o(o.representative,n));if(r){r.left=Math.min(r.left,n.left),r.right=Math.max(r.right,n.left+n.width),r.blockIds.add(n.id);continue}t.push({representative:n,left:n.left,right:n.left+n.width,blockIds:new Set([n.id])})}return t.sort((n,r)=>n.left-r.left).map((n,r)=>({index:r,left:n.left,right:n.right,center:(n.left+n.right)/2,blockIds:n.blockIds}))}function qVn(e,t){if(t.length<=1)return;let n=t.filter(r=>e>=r.left-lCt&&e<=r.right+lCt).sort((r,o)=>Math.abs(r.center-e)-Math.abs(o.center-e));return n[0]?n[0]:[...t].sort((r,o)=>Math.abs(r.center-e)-Math.abs(o.center-e))[0]}function rZo(e,t){return t.find(n=>n.blockIds.has(e.id))?.index}function KVn(e,t,n,r){let o=!1,i=e.map(a=>{let s=a.anchor;if(!s||s.type!=="block"||!t.has(s.blockId))return a;let l=n.get(s.blockId);if(!l)return a;let c=l.top+s.dy,u=0;for(let m of t){let h=n.get(m);h&&(m===s.blockId||h.top<c)&&(u+=h.height)}let d=c-u,p=typeof a.x=="number"?a.x:void 0;o=!0;let f=gP(d,d,r,p,p);return{...a,y:d,anchor:f.type==="block"&&s.reserveSpace!==void 0?{...f,reserveSpace:s.reserveSpace}:f}});return{shapes:o?i:e,changed:o}}function yP(e,t,n=ole.height,r=ole.width,o){Ci("Overlay.measureBlockTops");let i=new Map,a=new Map,s=[],l=e.getBoundingClientRect();if(l.height<=0)return{tops:i,rects:a,ordered:s};let{scaleX:c,scaleY:u,shiftOf:d}=xNe(e,l,r,n),p=new Set;return t.querySelectorAll(cCt).forEach(f=>{let m=f.getAttribute("data-sigma-doc-id")??f.id;if(!m||p.has(m))return;p.add(m);let h=f.getBoundingClientRect();if(c_(f,h)){let F=gNe(o?.get(m));F&&(i.set(m,F.top),a.set(m,F),s.push(F));return}let g=d(f),y=(h.top-l.top)*u-g.y,b=(h.left-l.left)*c-g.x,x=mCt(f,m),v=lte(f,l,c,u),S={id:m,top:y,left:b,width:h.width*c,height:h.height*u,lines:g.x===0&&g.y===0?v:v.map(F=>({...F,top:F.top-g.y,left:(F.left??0)-g.x})),...x?{containerId:x}:{},...fCt(f,m)?{derived:!0}:{}};i.set(m,y),a.set(m,S),s.push(S)}),s.sort((f,m)=>f.top-m.top),{tops:i,rects:a,ordered:s}}function fCt(e,t){let n=e.closest("[data-problem-area][data-problem-id]"),r=n?.getAttribute("data-problem-id"),o=n?.getAttribute("data-problem-area")??null;return!!(r&&tI(o)&&dx(r,o)===t)}function mCt(e,t){let n=e.parentElement?.closest(cCt)??null;for(;n;){let r=n.getAttribute("data-sigma-doc-id")??n.id;if(r&&r!==t)return r;n=n.parentElement?.closest(cCt)??null}}function lte(e,t,n,r){let o=YVn(e);return oZo(o.length>0?o:[e.getBoundingClientRect()]).map((a,s)=>({index:s,top:(a.top-t.top)*r,left:(a.left-t.left)*n,width:Math.max(0,(a.right-a.left)*n),height:Math.max(0,(a.bottom-a.top)*r)}))}function hCt(e,t=0){let n=[...e].filter(r=>Number.isFinite(r.top)&&Number.isFinite(r.height)&&r.height>0).sort((r,o)=>r.top-o.top||r.height-o.height);return n.map((r,o)=>{let i=r.top+r.height,a=n[o+1]?.top;return(a!==void 0&&a>i?i+(a-i)/2:i)-t})}function YVn(e){return Array.from(e.children).some(t=>t.matches("p, h1, h2, h3, h4, h5, h6, ol, ul, li, blockquote, pre"))?Array.from(e.childNodes).flatMap(t=>t.nodeType===1?YVn(t):NVn(t)):NVn(e)}function NVn(e){let t=e.ownerDocument;if(!t)return[];let n=t.createRange();try{return n.selectNodeContents(e),Array.from(n.getClientRects()).filter(r=>r.width>0&&r.height>0)}finally{n.detach()}}function oZo(e){let t=[],n=[...e].sort((o,i)=>o.top-i.top||o.left-i.left),r=0;for(let o of n){for(;r<t.length&&iZo(t[r],o);)r+=1;let i=t.slice(r).find(a=>aZo(o,a));if(!i){t.push({top:o.top,right:o.right,bottom:o.bottom,left:o.left});continue}i.top=Math.min(i.top,o.top),i.right=Math.max(i.right,o.right),i.bottom=Math.max(i.bottom,o.bottom),i.left=Math.min(i.left,o.left)}return t.sort((o,i)=>o.top-i.top||o.left-i.left)}function iZo(e,t){let n=(e.top+e.bottom)/2,r=(t.top+t.bottom)/2;return e.bottom<t.top&&r-n>zVn}function aZo(e,t){let n=(e.top+e.bottom)/2,r=(t.top+t.bottom)/2;if(Math.abs(n-r)<=zVn)return!0;let o=Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top),i=Math.min(e.height,t.bottom-t.top);return o>Math.max(1,i*.45)}var zVn,lCt,cCt,Y$o,$$o,Z$o,My=X(()=>{"use strict";Pn();Dt();Dn();xi();Pn();kh();sF();mP();zVn=2,lCt=.5,cCt="[data-sigma-doc-id], [data-page-block]",Y$o=48,$$o=24,Z$o=120});var jh=X(()=>{"use strict";vh();Pn()});var SNe=X(()=>{"use strict";Pn()});var gCt=X(()=>{"use strict";Pn()});function cj(e,t){if(t?.length)return t.join(" ");if(e==="dashed")return"8 6";if(e==="dotted")return"1 6"}function ZVn(e,t,n,r,o,i,a){return e==="blockArrow"?V5(t,n,o,i,1).map(s=>`${s.x},${s.y}`).join(" "):e==="triangle"?`${Yo(r??t/2,1,Math.max(1,t-1))},1 ${Math.max(1,t-1)},${Math.max(1,n-1)} 1,${Math.max(1,n-1)}`:e==="diamond"?`${t/2},1 ${Math.max(1,t-1)},${n/2} ${t/2},${Math.max(1,n-1)} 1,${n/2}`:lw(t,n,e==="pentagon"?5:Z5(a),1).map(s=>`${s.x},${s.y}`).join(" ")}function bCt(e,t){let n=t==="start"?e.props.startAngle:e.props.endAngle;return yCt(e,n)}function yCt(e,t){let{rx:n,ry:r}=Pd(e);return{x:n+Math.cos(t)*n,y:r+Math.sin(t)*r}}function JVn(e){let{rx:t,ry:n}=Pd(e),r=_De(e),o=yCt(e,r.startAngle),i=yCt(e,r.endAngle),s=xh(r.endAngle-r.startAngle)>Math.PI?1:0;return e.props.kind==="sector"?`M ${t} ${n} L ${o.x} ${o.y} A ${t} ${n} 0 ${s} 1 ${i.x} ${i.y} Z`:`M ${o.x} ${o.y} A ${t} ${n} 0 ${s} 1 ${i.x} ${i.y}`}function QVn(e){return e.props.kind!=="sector"||e.props.fill==="none"?"none":e.props.fillColor??e.props.color}function uj(e,t,n){let r=Ile(n,e,t);return r?`url(#${r})`:void 0}function d_(e,t){let n=t===void 0?e.opacity:t;return{...e,opacity:n===void 0||n>=1?void 0:n}}var wNe=X(()=>{"use strict";Dn();Pn();jh();SNe();gCt();Dn()});var Tye=X(()=>{"use strict";Pn()});function eXn(e){return e.type==="text"||e.type==="geo"||e.type==="arrow"||e.type==="line"||e.type==="arc"}function xCt(e){return e.type==="text"||e.type==="geo"||e.type==="arc"&&e.props.kind==="sector"||e.type==="line"&&Zg(e.props.kind,e.props.points,e.props.closed)}function tXn(e){return e.type==="text"||e.type==="geo"||e.type==="arrow"||e.type==="line"||e.type==="arc"||e.type==="callout"}function nXn(e){return e.type==="line"?!Zg(e.props.kind,e.props.points,e.props.closed):e.type==="arrow"||oXn(e)}function FNe(e){return e.type==="arrow"||e.type==="line"||e.type==="arc"}function vCt(e,t){let n=null;for(let r of e){if(r.type!=="arrow"&&r.type!=="line"&&!oXn(r)||r.type==="line"&&Zg(r.props.kind,r.props.points,r.props.closed))continue;let o=t==="start"?r.props.arrowheadStart??"none":r.props.arrowheadEnd??"none";if(n===null)n=o;else if(n!==o)return null}return n}function rXn(e){let t=null;for(let n of e){if(!xCt(n))continue;let r=n.props,o=r.fill==="solid"?{kind:"solid",fillColor:r.fillColor??r.color,fillOpacity:dOe(r.fillOpacity)}:{kind:"none"};if(t===null)t=o;else if(!dZo(t,o))return{kind:"mixed"}}return t??{kind:"unavailable"}}function dZo(e,t){return e.kind!==t.kind?!1:e.kind==="solid"&&t.kind==="solid"?e.fillColor===t.fillColor&&e.fillOpacity===t.fillOpacity:!0}function cte(e,t){if(e.type==="geo"){let r={...d_(e,t.opacity),props:{...e.props,color:t.color??e.props.color,fillColor:t.fillColor??e.props.fillColor,strokeOpacity:t.strokeOpacity??e.props.strokeOpacity,fillOpacity:t.fillOpacity??e.props.fillOpacity,labelColor:t.color??e.props.labelColor,fill:t.fill??e.props.fill,dash:t.dash??e.props.dash,...t.dash!==void 0?{dashPattern:void 0}:{},size:t.size??e.props.size}};if(!Nc(r))return r;let o=t.dash!==void 0?rnn(r,t.dash):r;return t.size!==void 0?inn(o,t.size):o}if(e.type==="arrow")return{...d_(e,t.opacity),props:{...e.props,color:t.color??e.props.color,strokeOpacity:t.strokeOpacity??e.props.strokeOpacity,labelColor:t.color??e.props.labelColor,dash:t.dash??e.props.dash,...t.dash!==void 0?{dashPattern:void 0}:{},size:t.size??e.props.size,arrowheadStart:t.arrowheadStart??e.props.arrowheadStart,arrowheadEnd:t.arrowheadEnd??e.props.arrowheadEnd}};if(e.type==="line"){let n=d_(e,t.opacity),r=Zg(e.props.kind,e.props.points,e.props.closed);return{...n,props:{...e.props,color:t.color??e.props.color,fillColor:r?t.fillColor??e.props.fillColor:e.props.fillColor,strokeOpacity:t.strokeOpacity??e.props.strokeOpacity,fillOpacity:r?t.fillOpacity??e.props.fillOpacity:e.props.fillOpacity,fill:r?t.fill??e.props.fill:e.props.fill,labelColor:t.color??e.props.labelColor,dash:t.dash??e.props.dash,...t.dash!==void 0?{dashPattern:void 0}:{},size:t.size??e.props.size,arrowheadStart:r?e.props.arrowheadStart:t.arrowheadStart??e.props.arrowheadStart,arrowheadEnd:r?e.props.arrowheadEnd:t.arrowheadEnd??e.props.arrowheadEnd}}}if(e.type==="arc"){let n=d_(e,t.opacity),r=e.props.kind==="sector";return{...n,props:{...e.props,color:t.color??e.props.color,fillColor:r?t.fillColor??e.props.fillColor:e.props.fillColor,fillOpacity:r?t.fillOpacity??e.props.fillOpacity:e.props.fillOpacity,fill:r?t.fill??e.props.fill:e.props.fill,strokeOpacity:t.strokeOpacity??e.props.strokeOpacity,dash:t.dash??e.props.dash,...t.dash!==void 0?{dashPattern:void 0}:{},size:t.size??e.props.size,arrowheadStart:r?e.props.arrowheadStart:t.arrowheadStart??e.props.arrowheadStart,arrowheadEnd:r?e.props.arrowheadEnd:t.arrowheadEnd??e.props.arrowheadEnd}}}return e.type==="text"?{...d_(e,t.opacity),props:{...e.props,fill:t.fill??e.props.fill,fillColor:t.fillColor??e.props.fillColor,fillOpacity:t.fillOpacity??e.props.fillOpacity,strokeColor:t.color??e.props.strokeColor,strokeOpacity:t.strokeOpacity??e.props.strokeOpacity,dash:t.dash??(t.color!==void 0||t.size!==void 0||(t.strokeOpacity??0)>0?e.props.dash??"solid":e.props.dash),strokeWidth:t.size??e.props.strokeWidth}}:e.type==="callout"?{...d_(e,t.opacity),props:{...e.props,dash:t.dash??e.props.dash,strokeWidth:t.size??e.props.strokeWidth}}:d_(e,t.opacity)}function oXn(e){return e.type==="arc"&&e.props.kind!=="sector"}var dj=X(()=>{"use strict";$R();wNe();Pn();Tye()});function ff(){return rt("overlay_shape")}function ute(){return rt("overlay_asset")}function iXn(){return rt("overlay_group")}function SCt(e){return[{type:"paragraph",id:rt("p"),children:e?[{type:"text",text:e}]:[]}]}var tE=X(()=>{"use strict";ai()});function hZo(e="blank"){let t=R3n(e),n=pZo,r=O3n({...t,width:n},n),o=Math.max(e==="numberLine"?128:190,r??Math.round(n*(t.height/t.width))),i={...t,title:"",width:n,height:o,axes:{...t.axes,grid:!1,showX:t.axes.showX??!0,showY:t.kind==="cartesian"?t.axes.showY??!0:!1,showTicks:!1,xLabel:"",yLabel:"",originLabel:""},curves:t.curves.map(u=>({...u,color:G3n(u.color)})),showFormulaLabels:!1},a=qs(i),s=Math.max(1,n-a.left-a.right),l=Math.max(1,o-a.top-a.bottom),c=myt(i,s,l);return{boundsMode:SB,w:s,h:l,spec:c}}function aXn(e,t,n="blank"){let r=hZo(n),o=qs(r.spec),i=Math.max(1,r.w),a=Math.max(1,r.h),s=Math.max(fZo,t.w),l=Math.max(mZo,t.h<16?Math.round(s*(a/i)):t.h),c=s+o.left+o.right,u=l+o.top+o.bottom,d=myt({...r.spec,width:c,height:u},s,l);return{id:e,type:lF,x:t.x,y:t.y,rotation:0,props:{boundsMode:SB,w:s,h:l,spec:d}}}function sXn(e,t){let n=sx(e),r=(t.left-n.plotBox.left)*n.scaleX,o=(t.top-n.plotBox.top)*n.scaleY,i=typeof e.rotation=="number"&&Number.isFinite(e.rotation)?e.rotation:0;if(i===0)return{x:e.x+r,y:e.y+o};let a=Math.cos(i),s=Math.sin(i),l=(g,y)=>({x:g*a-y*s,y:g*s+y*a}),c=dl(e),u=l(e.x+r-c.x,e.y+o-c.y),d=c.x+u.x,p=c.y+u.y,f=t.width*n.scaleX,m=t.height*n.scaleY,h=l(f/2,m/2);return{x:d+h.x-f/2,y:p+h.y-m/2}}function lXn(e,t,n){if(!n)return{hidden:!0};let r=n.anchor;return!r||r.type!=="shape"?{}:t.hidden?{x:n.x,y:n.y,hidden:void 0,anchor:r}:{x:t.x,y:t.y,hidden:void 0,anchor:gZo(e,t,r)}}function gZo(e,t,n){let r=typeof n.rx=="number"?e.x+e.props.w*n.rx:e.x,o=typeof n.ry=="number"?e.y+e.props.h*n.ry:e.y;return{...n,dx:t.x-r,dy:t.y-o}}function CNe(e){return{w:e.w,h:e.h,blocks:e.blocks,color:e.color,size:e.size}}function cXn(e,t){return Zrt(e,Dye,t)}function dte(e,t,n,r){return WDe(e,t,n,Dye,r)}function pte(e,t,n){return YDe(e,t,Dye,n)}function p_(e,t,n){return $De(e,t,Dye,n)}function f_(e,t,n){return ZDe(e,t,Dye,n)}var lF,wCt,pZo,fZo,mZo,Dye,Yx=X(()=>{"use strict";Pn();Ak();Gc();Pn();Dt();Pn();lF="graph2dShape",wCt="sigma-studio:edit-overlay-graph-shape",pZo=360,fZo=64,mZo=48,Dye=m6e()});function uXn(e="plain",t=yZo,n=bZo){let r=e==="variation"?xZo():ACt();return{w:t,h:n,table:r}}function ACt(e=3,t=3){let n=Array.from({length:e},(o,i)=>({id:rt("table_row"),height:{mode:"auto",min:i===0?34:32},role:i===0?"header":"body"})),r=Array.from({length:t},()=>({id:rt("table_col"),width:{mode:"fr",value:1,min:kye}}));return{version:1,kind:"plain",columns:r,rows:n,cells:n.flatMap(o=>r.map(i=>f1(o.id,i.id))),grid:{borderColor:"#111827",borderWidth:1,borderStyle:"solid",showOuterBorder:!0,showInnerBorders:!0},defaultCellStyle:{align:"center",verticalAlign:"middle",paddingX:8,paddingY:5,color:"#111827",fontSize:15,fontWeight:"normal"}}}function xZo(){let e=[{id:rt("table_row"),height:{mode:"auto",min:32},role:"variable"},{id:rt("table_row"),height:{mode:"auto",min:32},role:"derivative"},{id:rt("table_row"),height:{mode:"auto",min:38},role:"variation"}],t=[{id:rt("table_col"),width:{mode:"auto",min:48,max:96},role:"label"},{id:rt("table_col"),width:{mode:"fr",value:1,min:56},role:"interval"},{id:rt("table_col"),width:{mode:"auto",min:52,max:96},role:"point"},{id:rt("table_col"),width:{mode:"fr",value:1,min:56},role:"interval"}],[n,r,o,i]=t,[a,s,l]=e;return{version:1,kind:"variation",columns:t,rows:e,cells:[f1(a.id,n.id,bP("x")),f1(a.id,r.id),f1(a.id,o.id,bP("a")),f1(a.id,i.id),f1(s.id,n.id,bP("f'(x)")),f1(s.id,r.id,bP("+")),f1(s.id,o.id,bP("0")),f1(s.id,i.id,bP("-")),f1(l.id,n.id,bP("f(x)")),f1(l.id,r.id,bP("\\nearrow")),f1(l.id,o.id),f1(l.id,i.id,bP("\\searrow"))],grid:{borderColor:"#111827",borderWidth:1,borderStyle:"solid",showOuterBorder:!0,showInnerBorders:!0},defaultCellStyle:{align:"center",verticalAlign:"middle",paddingX:8,paddingY:5,color:"#111827",fontSize:15,fontWeight:"normal"}}}function dXn(e,t,n){if(!lDe(e,t))return e;let r=art(e,t),o={...t,style:{...r?.style??{},...n}},i=!1,a=(e.grid.lineOverrides??[]).map(s=>srt(s,t)?(i=!0,o):s);return i||a.push(o),{...e,grid:{...e.grid,lineOverrides:a}}}function pXn(e,t,n,r){return t<0||t>=e.columns.length-1?e:{...e,columns:e.columns.map((o,i)=>i===t?FCt(o,n):i===t+1?FCt(o,r):o)}}function fXn(e,t,n){if(e.columns.length===0)return e;let r=t==="left"?0:e.columns.length-1;return{...e,columns:e.columns.map((o,i)=>i===r?FCt(o,n):o)}}function mXn(e,t,n,r){return t<0||t>=e.rows.length-1?e:{...e,rows:e.rows.map((o,i)=>i===t?CCt(o,n):i===t+1?CCt(o,r):o)}}function hXn(e,t,n){if(e.rows.length===0)return e;let r=t==="top"?0:e.rows.length-1;return{...e,rows:e.rows.map((o,i)=>i===r?CCt(o,n):o)}}function TCt(e,t){let n=ANe(t,0,e.columns.length),r={id:rt("table_col"),width:{mode:"auto",min:40}},o=[...e.columns.slice(0,n),r,...e.columns.slice(n)];return{...e,columns:o,grid:TNe(e.grid,o,e.rows),cells:e.rows.flatMap(i=>{let a=e.cells.filter(s=>s.rowId===i.id);return[...a.filter(s=>o.findIndex(l=>l.id===s.columnId)<n),f1(i.id,r.id),...a.filter(s=>o.findIndex(l=>l.id===s.columnId)>n)]})}}function gXn(e,t){let n=new Set(t);if(n.size===0||e.columns.length<=1)return e;let r=e.columns.filter(o=>!n.has(o.id));return r.length===0||r.length===e.columns.length?e:{...e,columns:r,cells:bXn(e.cells.filter(o=>!n.has(o.columnId)),r,e.rows),grid:TNe(e.grid,r,e.rows)}}function DCt(e,t){let n=ANe(t,0,e.rows.length),r={id:rt("table_row"),height:{mode:"auto",min:Eye},role:"body"},o=[...e.rows.slice(0,n),r,...e.rows.slice(n)];return{...e,rows:o,grid:TNe(e.grid,e.columns,o),cells:[...e.cells.filter(i=>o.findIndex(a=>a.id===i.rowId)<n),...e.columns.map(i=>f1(r.id,i.id)),...e.cells.filter(i=>o.findIndex(a=>a.id===i.rowId)>n)]}}function yXn(e,t){let n=new Set(t);if(n.size===0||e.rows.length<=1)return e;let r=e.rows.filter(o=>!n.has(o.id));return r.length===0||r.length===e.rows.length?e:{...e,rows:r,cells:bXn(e.cells.filter(o=>!n.has(o.rowId)),e.columns,r),grid:TNe(e.grid,e.columns,r)}}function TNe(e,t,n){if(!e.lineOverrides?.length)return e;let r=e.lineOverrides.filter(i=>vZo(i,t,n));if(r.length===e.lineOverrides.length)return e;let o={...e};return r.length>0?o.lineOverrides=r:delete o.lineOverrides,o}function bXn(e,t,n){return e.flatMap(r=>{let o=n.findIndex(l=>l.id===r.rowId),i=t.findIndex(l=>l.id===r.columnId);if(o<0||i<0)return[];let a=ANe(r.rowSpan??1,1,Math.max(1,n.length-o)),s=ANe(r.colSpan??1,1,Math.max(1,t.length-i));return[{...r,...a===1?{rowSpan:void 0}:{rowSpan:a},...s===1?{colSpan:void 0}:{colSpan:s}}]})}function vZo(e,t,n){return e.axis==="vertical"?"edge"in e?e.edge==="left"||e.edge==="right":t.findIndex(r=>r.id===e.beforeColumnId)>0:"edge"in e?e.edge==="top"||e.edge==="bottom":n.findIndex(r=>r.id===e.beforeRowId)>0}function f1(e,t,n=[SZo()]){return{id:rt("table_cell"),rowId:e,columnId:t,content:n}}function SZo(){return{type:"paragraph",id:rt("table_p"),children:[],align:"center"}}function bP(e){return[{type:"paragraph",id:rt("table_p"),children:[{type:"mathInline",id:rt("table_math"),tex:e,display:"inline",semanticRole:"expression"}],align:"center"}]}function FCt(e,t){return{...e,width:{mode:"fixed",value:Math.max(pj,t)}}}function CCt(e,t){return{...e,height:{mode:"fixed",value:Math.max(fj,t)}}}function ANe(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.trunc(e))):t}var nE,yZo,bZo,kye,Eye,pj,fj,m_=X(()=>{"use strict";ai();Dn();nE="tableShape",yZo=260,bZo=124,kye=64,Eye=32,pj=1,fj=1});function mj(e){return{surface:e("graph3dPresetName.surface"),surfacePlane:e("graph3dPresetName.surfacePlane"),surfaceContour:e("graph3dPresetName.surfaceContour"),cutHeight:e("graph3dPresetName.cutHeight"),cylinderZ:e("graph3dPresetName.cylinderZ"),cylinderX:e("graph3dPresetName.cylinderX"),cylinderY:e("graph3dPresetName.cylinderY"),cutPlaneH:e("graph3dPresetName.cutPlaneH"),tricylinderIntersection:e("graph3dPresetName.tricylinderIntersection"),cylinderZPlane:e("graph3dPresetName.cylinderZPlane"),cylinderXPlane:e("graph3dPresetName.cylinderXPlane"),cylinderYPlane:e("graph3dPresetName.cylinderYPlane"),intersectionSection:e("graph3dPresetName.intersectionSection"),sphereRadius:e("graph3dPresetName.sphereRadius"),tetrahedron:e("graph3dPresetName.tetrahedron"),sphere:e("graph3dPresetName.sphere"),tetrahedronSphereIntersection:e("graph3dPresetName.tetrahedronSphereIntersection"),sectionHeight:e("graph3dPresetName.sectionHeight"),revolution:e("graph3dPresetName.revolution"),cutPlaneS:e("graph3dPresetName.cutPlaneS"),section:e("graph3dPresetName.section")}}var DNe=X(()=>{"use strict"});function CZo(e,t={}){let n={version:1,kind:"bar",orientation:"columns",headerRow:!0,labelColumn:!0,legend:!0,seriesColors:{}},r=gK(e,n,t);return{...n,seriesColors:H$t(r.series.map(o=>o.id))}}function vXn(e,t,n,r,o={}){let i=CZo(e,o);return{w:Math.max(kNe,n),h:Math.max(ENe,r),spec:i,sourceTableShapeId:t,dataSnapshot:gK(e,i,o)}}function SXn(e){let t=Math.max(kNe,e.w);return{x:e.x,y:e.y+e.h+FZo,w:t,h:Math.max(ENe,Math.round(t*wZo))}}var xXn,wZo,FZo,kNe,ENe,kCt=X(()=>{"use strict";Dt();xXn="chartShape",wZo=.62,FZo=16,kNe=160,ENe=120});function wXn(e){return e==="ArrowUp"||e==="ArrowDown"||e==="ArrowLeft"||e==="ArrowRight"}function FXn(e,t){return e==="ArrowLeft"?{x:-t,y:0}:e==="ArrowRight"?{x:t,y:0}:e==="ArrowUp"?{x:0,y:-t}:{x:0,y:t}}function Iye(e){return e.command==="curve"||e.command==="polyline"||e.command==="threePointArc"}function hj(e){return e.command==="curve"||e.command==="polyline"}function CXn(e){return e.command==="line"||e.command==="arrow"}function AXn(e){return e.command==="line"||e.command==="arrow"||e.command==="blockArrow"}function h_(e){return e.command==="arc"||e.command==="sector"}function ECt(e){return e===" "||e==="Space"||e==="Spacebar"}function ICt(e){return e==="Shift"||e==="Control"}function TXn(e){if(Eke(e.command)!==null)return 1;let t=Cce(e.command);return t?Fke(t):e.command==="rectangle"||e.command==="circle"||e.command==="ellipse"||e.command==="diamond"?1:e.command==="triangle"?AZo:null}function DZo(e){return structuredClone(e)}function gj(e,t,n,r,o,i=!1,a={}){let s=e.command,l=a,c=Eke(s),u=Math.min(t.x,n.x),d=Math.min(t.y,n.y),p=Math.max(2,Math.abs(n.x-t.x)),f=Math.max(2,Math.abs(n.y-t.y));if(s==="circle"||s==="ellipse"){let h=xZt(t,n,!1);return{id:r,type:"geo",x:h.x,y:h.y,rotation:0,props:{w:h.w,h:h.h,geo:"ellipse",fill:l.fill??"none",color:l.color??"black",strokeOpacity:l.strokeOpacity,fillColor:l.fillColor??"#ffffff",fillOpacity:l.fillOpacity,labelColor:l.color??"black",dash:l.dash??"solid",size:l.size??"m"}}}let m=Cce(s);if(m){let h=l.dash??"solid";return{id:r,type:"geo",x:u,y:d,rotation:0,props:{w:p,h:f,geo:m.geo,...m.baseSides?{baseSides:m.baseSides}:{},fill:l.fill??"none",color:l.color??"black",strokeOpacity:l.strokeOpacity,fillColor:l.fillColor??"#ffffff",fillOpacity:l.fillOpacity,labelColor:l.color??"black",dash:h,size:l.size??"m",solidEdgeDash:Qtn(m,h)}}}if(s==="blockArrow"){let h=n.x-t.x,g=Math.max(48,Math.abs(h)),y=Math.max(28,Math.min(96,Math.abs(n.y-t.y))),b=h<0;return{id:r,type:"geo",x:Math.min(t.x,n.x),y:(t.y+n.y)/2-y/2,rotation:b?Math.PI:0,props:{w:g,h:y,geo:"blockArrow",fill:l.fill??"solid",color:l.color??"black",strokeOpacity:l.strokeOpacity,fillColor:l.fillColor??"#bfdbfe",fillOpacity:l.fillOpacity??.85,labelColor:l.color??"black",dash:l.dash??"solid",size:l.size??"m"}}}if(s==="rectangle"||s==="triangle"||s==="diamond"||c!==null||s==="highlight")return{id:r,type:"geo",x:u,y:d,rotation:0,opacity:s==="highlight"?.45:void 0,props:{w:p,h:f,geo:s==="highlight"?"rectangle":c!==null?"regularPolygon":s,fill:s==="highlight"?"solid":l.fill??"none",color:s==="highlight"?"#facc15":l.color??"black",strokeOpacity:s==="highlight"?void 0:l.strokeOpacity,fillColor:s==="highlight"?"#facc15":l.fillColor??"#ffffff",fillOpacity:s==="highlight"?1:l.fillOpacity,labelColor:s==="highlight"?"black":l.color??"black",dash:s==="highlight"?"solid":l.dash??"solid",size:s==="highlight"?"m":l.size??"m",apexX:s==="triangle"?p/2:void 0,polygonSides:c??void 0}};if(s==="arc"||s==="sector")return MDe(r,t,n,s,{...l,arrowheadStart:s==="arc"?l.arrowheadStart??"none":void 0,arrowheadEnd:s==="arc"?l.arrowheadEnd??"none":void 0});if(s==="threePointArc"){let h=o&&o.length>0?o:[t,n];if(h.length>=3)return PDe(r,h[0],h[1],h[2],{...l,arrowheadStart:l.arrowheadStart??"none",arrowheadEnd:l.arrowheadEnd??"none"});let g=h[0]??t,y=h[1]??n;return{id:r,type:"line",x:g.x,y:g.y,rotation:0,props:{kind:"polyline",points:[{x:0,y:0},{x:y.x-g.x,y:y.y-g.y}],closed:!1,arrowheadStart:l.arrowheadStart??"none",arrowheadEnd:l.arrowheadEnd??"none",fill:"none",fillColor:"#ffffff",color:l.color??"black",strokeOpacity:l.strokeOpacity,labelColor:l.color??"black",dash:l.dash??"solid",size:l.size??"m"}}}if(s==="arrow")return{id:r,type:"arrow",x:t.x,y:t.y,rotation:0,props:{start:{x:0,y:0},end:{x:n.x-t.x,y:n.y-t.y},arrowheadStart:l.arrowheadStart??"none",arrowheadEnd:l.arrowheadEnd===void 0||l.arrowheadEnd==="none"?"arrow":l.arrowheadEnd,fill:"none",color:l.color??"black",strokeOpacity:l.strokeOpacity,labelColor:l.color??"black",dash:l.dash??"solid",size:l.size??"m"}};if(s==="line"||s==="polyline"||s==="curve"||s==="freehand"){let h=s==="line"||s==="polyline"?"polyline":s,g=s==="curve"||s==="polyline"?o&&o.length>=2?Ort(o,t,n):s==="curve"?_rt(t,n):[{x:0,y:0},{x:n.x-t.x,y:n.y-t.y}]:s==="freehand"?Nrt(o??[t,n],t,n):[{x:0,y:0},{x:n.x-t.x,y:n.y-t.y}];return{id:r,type:"line",x:t.x,y:t.y,rotation:0,props:{kind:h,points:g,closed:s==="polyline"&&i&&g.length>=3,arrowheadStart:l.arrowheadStart??"none",arrowheadEnd:l.arrowheadEnd??"none",fill:"none",fillColor:"#ffffff",color:l.color??"black",strokeOpacity:l.strokeOpacity,labelColor:l.color??"black",dash:l.dash??"solid",size:l.size??"m"}}}if(s==="text")return{id:r,type:"text",x:u,y:d,rotation:0,props:{w:n.x===t.x?OK:Math.max(wD,p),h:e9("m"),blocks:SCt(""),color:"black",size:"m"}};if(s==="callout"){let h=Math.min(36,Math.max(18,f*.28)),g=Math.max(24,f-h);return{id:r,type:"callout",x:u,y:d,rotation:0,props:{w:p,h:g,radius:k9(e.calloutRadius??CD,p,g),tail:{baseStart:{x:p*.22,y:g},baseEnd:{x:p*.42,y:g},tip:{x:p*.14,y:f}},blocks:SCt(""),color:"black",size:"m",dash:"solid",strokeWidth:"m"}}}if(s==="graph")return aXn(r,{x:u,y:d,w:p,h:f},e.graphPreset??"blank");if(s==="graph3d")return{id:r,type:"graph3dShape",x:u,y:d,rotation:0,props:{w:p,h:f,spec:j9(e.graph3dPreset??"revolution",mj(TZo))}};if(s==="table"){if(e.tableCellSize){let y=hD(t,n,e.tableCellSize),{cellW:b,cellH:x,columns:v,rows:S}=y,F=ACt(S,v);return F.columns.forEach(w=>{w.width={mode:"fr",value:1,min:b}}),F.rows.forEach(w=>{w.height={mode:"auto",min:x}}),{id:r,type:nE,x:y.x,y:y.y,rotation:0,props:{w:y.w,h:y.h,table:F}}}let h=Math.max(120,p,e.tableSize?.w??0),g=Math.max(72,f,e.tableSize?.h??0);return{id:r,type:nE,x:u,y:d,rotation:0,props:e.table?{w:h,h:g,table:DZo(e.table)}:uXn("plain",h,g)}}return s==="chart"&&e.chart?{id:r,type:xXn,x:u,y:d,rotation:0,props:{w:Math.max(kNe,p),h:Math.max(ENe,f),spec:structuredClone(e.chart.spec),...e.chart.sourceTableShapeId?{sourceTableShapeId:e.chart.sourceTableShapeId}:{},dataSnapshot:structuredClone(e.chart.dataSnapshot)}}:null}var AZo,TZo,xP=X(()=>{"use strict";tE();jh();Pn();Yx();Tye();gCt();m_();DNe();ho();kCt();Pn();AZo=Math.sqrt(3)/2,TZo=Fr("shape")});function yj(e){return e.type==="geo"||e.type==="arc"||e.type==="arrow"||e.type==="line"||e.type==="callout"}function INe(e){return e!=="select"&&e!=="threePointArc"&&e!=="highlight"&&e!=="text"&&e!=="graph"&&e!=="graph3d"&&e!=="table"&&e!=="chart"}function DXn(e,t){if(!yj(e))return null;let n=PB(e),r={x:n.x+n.w/2,y:n.y+n.h/2},o=t==="circle"||t==="ellipse"||t==="arc"||t==="sector"?r:{x:n.x,y:n.y},i={x:n.x+n.w,y:n.y+n.h},a=kZo(e),s=Cce(t)!==null,l=gj({kind:"insert",command:t},o,i,e.id,void 0,!1,s&&a.dash?{dash:a.dash}:{});if(!l)return null;let c=l.type==="geo"||l.type==="arc"||l.type==="callout"?K9(l,n):l,u=cte(c,s?{...a,dash:void 0}:a),d=EZo(e),p=IZo(e);return{...d!==void 0||p!==void 0?PZo(u,d,p):u,id:e.id,rotation:Oi(e),...e.flipX?{flipX:!0}:{},...e.flipY?{flipY:!0}:{},...e.parentId?{parentId:e.parentId}:{},...e.groupId?{groupId:e.groupId}:{},...e.stackLayer?{stackLayer:e.stackLayer}:{},...e.locked?{locked:!0}:{},...e.hidden?{hidden:!0}:{},...e.opacity!==void 0?{opacity:e.opacity}:{},...e.anchor?{anchor:e.anchor}:{}}}function kZo(e){if(e.type==="geo"||e.type==="arc"||e.type==="arrow"||e.type==="line"){let t={color:e.props.color,strokeOpacity:e.props.strokeOpacity,fill:e.props.fill,dash:e.props.dash,size:e.props.size};return(e.type==="geo"||e.type==="arc"||e.type==="line")&&(t.fillColor=e.props.fillColor,t.fillOpacity=e.props.fillOpacity),(e.type==="arc"||e.type==="arrow"||e.type==="line")&&(t.arrowheadStart=e.props.arrowheadStart,t.arrowheadEnd=e.props.arrowheadEnd),t}return{}}function EZo(e){if(e.type==="geo"||e.type==="arrow"||e.type==="line")return e.props.label}function IZo(e){if(e.type==="geo"||e.type==="arrow"||e.type==="line")return e.props.labelColor}function PZo(e,t,n){return e.type==="geo"||e.type==="arrow"||e.type==="line"?{...e,props:{...e.props,...t!==void 0?{label:t}:{},...n!==void 0?{labelColor:n}:{}}}:e}var fte=X(()=>{"use strict";Pn();dj();xP()});import{useCallback as PCt,useEffect as MZo,useLayoutEffect as BZo,useRef as PNe,useState as MCt}from"react";import{createPortal as LZo}from"react-dom";import{Fragment as g_,jsx as zn,jsxs as Vh}from"react/jsx-runtime";function EXn({x:e,y:t,canGroup:n,canUngroup:r,canAlign:o,canDistribute:i,canChangeShapeType:a,imageHasCrop:s,imageEditable:l,imageOpacity:c,graphEditable:u,graphCanFill:d,graph3dEditable:p,onChartSettings:f,onCreateChartFromTable:m,onGraphSettings:h,onGraph3DSettings:g,onGraphCrop:y,onGraphOriginPick:b,onGraphFillPick:x,onImageCrop:v,onImageReplace:S,onImageResetCrop:F,onImageNaturalSize:w,onSvgConvert:C,onImageOpacityChange:A,onDuplicate:T,onDelete:D,onGroup:k,onUngroup:P,arrangeShortcutLabels:I,onArrange:B,onTransform:M,onAlign:L,onDistribute:_,onChangeShapeType:R,onSaveAsMaterial:O}){let N=We("shape"),z=We("chrome"),[U,H]=MCt(!1),[V,ne]=MCt(null),Z=typeof window<"u"&&e+456>window.innerWidth?"left":"right";return Vh("div",{className:"overlay-shape-context-menu",role:"menu",style:{left:e,top:t},onPointerDown:ee=>ee.stopPropagation(),onContextMenu:ee=>ee.preventDefault(),children:[m&&Vh(g_,{children:[zn(Zs,{icon:zn(ID,{size:14}),onClick:m,children:N("table.createChart")}),zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"})]}),f&&Vh(g_,{children:[zn(Zs,{icon:zn(ef,{size:14}),onClick:f,children:N("chartPanel.title")}),zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"})]}),h&&y&&b&&x&&Vh(g_,{children:[zn(Zs,{icon:zn(ef,{size:14}),disabled:!u,onClick:h,children:N("menu.graphSettings")}),zn(Zs,{icon:zn(PC,{size:14}),disabled:!u,onClick:y,children:N("graph.trim")}),zn(Zs,{icon:zn(e4,{size:14}),disabled:!u,onClick:b,children:N("graph.pickOrigin")}),zn(Zs,{icon:zn(mw,{size:14}),disabled:!u||!d,onClick:x,children:N("graph.fillArea")}),zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"})]}),g&&Vh(g_,{children:[zn(Zs,{icon:zn(ef,{size:14}),disabled:!p,onClick:g,children:N("graph3d.menuSettings")}),zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"})]}),v&&S&&F&&w&&A&&Vh(g_,{children:[C&&zn(Zs,{icon:zn(k0,{size:14}),disabled:!l,onClick:C,children:N("menu.svgConvert")}),zn(Zs,{icon:zn(PC,{size:14}),disabled:!l,onClick:v,children:N("menu.imageCrop")}),zn(Zs,{icon:zn(e2,{size:14}),disabled:!l,onClick:S,children:N("menu.imageReplace")}),zn(Zs,{icon:zn(Uu,{size:14}),disabled:!l||!s,onClick:F,children:N("menu.imageResetCrop")}),zn(Zs,{icon:zn(Ez,{size:14}),disabled:!l,onClick:w,children:N("menu.imageNaturalSize")}),Vh("label",{className:"overlay-shape-context-menu-opacity",children:[zn("span",{children:N("menu.opacity")}),zn("input",{type:"range",min:"0",max:"1",step:"0.01",value:c,disabled:!l,"aria-label":N("menu.imageOpacityAria"),"data-testid":"overlay-image-opacity-slider",onChange:ee=>A(Number(ee.target.value))}),Vh("output",{children:[Math.round(c*100),"%"]})]}),zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"})]}),n&&zn(Zs,{icon:zn(Cz,{size:14}),onClick:k,children:N("menu.group")}),r&&zn(Zs,{icon:zn(Rz,{size:14}),onClick:P,children:N("menu.ungroup")}),(n||r)&&zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"}),a&&Vh(g_,{children:[zn(Zs,{icon:zn(k0,{size:14}),onClick:()=>H(ee=>!ee),children:N("menu.changeShapeType")}),U&&zn("div",{className:"overlay-shape-type-picker",children:o0e(N).map(ee=>Vh("div",{className:"overlay-shape-type-section",children:[zn("div",{className:"overlay-shape-type-section-label",children:ee.label}),zn("div",{className:"overlay-shape-type-grid",children:ee.items.map(J=>{if(!J.command||!INe(J.command))return null;let te=J.icon;return zn("button",{type:"button",role:"menuitem",title:J.label,"aria-label":J.label,onClick:()=>R(J.command),children:zn(te,{size:16})},J.command)})})]},ee.id))}),zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"})]}),Vh(kXn,{icon:zn(nL,{size:14}),label:N("menu.order"),open:V==="order",side:Z,onOpen:()=>ne("order"),onClose:()=>ne(ee=>ee==="order"?null:ee),children:[zn(Zs,{icon:zn(ED,{size:14}),shortcut:I?.front,onClick:()=>B("front"),children:z("shapeStyle.arrange.front")}),zn(Zs,{icon:zn(_D,{size:14}),shortcut:I?.forward,onClick:()=>B("forward"),children:z("shapeStyle.arrange.forward")}),zn(Zs,{icon:zn(RD,{size:14}),shortcut:I?.backward,onClick:()=>B("backward"),children:z("shapeStyle.arrange.backward")}),zn(Zs,{icon:zn(OD,{size:14}),shortcut:I?.back,onClick:()=>B("back"),children:z("shapeStyle.arrange.back")})]}),Vh(kXn,{icon:zn(zf,{size:14}),label:N("menu.rotate"),open:V==="rotation",side:Z,onOpen:()=>ne("rotation"),onClose:()=>ne(ee=>ee==="rotation"?null:ee),children:[zn(Zs,{icon:zn(zf,{size:14}),onClick:()=>M("rotateClockwise"),children:N("menu.rotateRight")}),zn(Zs,{icon:zn(Uu,{size:14}),onClick:()=>M("rotateCounterclockwise"),children:N("menu.rotateLeft")}),zn(Zs,{icon:zn(zD,{size:14}),onClick:()=>M("horizontal"),children:N("menu.flipHorizontal")}),zn(Zs,{icon:zn(UD,{size:14}),onClick:()=>M("vertical"),children:N("menu.flipVertical")})]}),o&&Vh(g_,{children:[zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"}),Vh("div",{className:"overlay-shape-context-menu-grid",role:"group","aria-label":N("menu.align"),children:[zn(Zs,{compact:!0,icon:zn(dz,{size:14}),onClick:()=>L("left"),children:N("menu.alignLeft")}),zn(Zs,{compact:!0,icon:zn(cz,{size:14}),onClick:()=>L("center"),children:N("menu.alignCenter")}),zn(Zs,{compact:!0,icon:zn(uz,{size:14}),onClick:()=>L("right"),children:N("menu.alignRight")}),zn(Zs,{compact:!0,icon:zn(hz,{size:14}),onClick:()=>L("top"),children:N("menu.alignTop")}),zn(Zs,{compact:!0,icon:zn(fz,{size:14}),onClick:()=>L("middle"),children:N("menu.alignMiddle")}),zn(Zs,{compact:!0,icon:zn(mz,{size:14}),onClick:()=>L("bottom"),children:N("menu.alignBottom")})]})]}),i&&Vh(g_,{children:[zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"}),zn(Zs,{icon:zn(lz,{size:14}),onClick:()=>_("horizontal"),children:N("menu.distributeHorizontal")}),zn(Zs,{icon:zn(pz,{size:14}),onClick:()=>_("vertical"),children:N("menu.distributeVertical")})]}),zn("div",{className:"overlay-shape-context-menu-separator",role:"separator"}),O&&zn(Zs,{icon:zn(_C,{size:14}),onClick:O,children:N("menu.saveAsMaterial")}),zn(Zs,{icon:zn(nu,{size:14}),onClick:T,children:N("menu.duplicate")}),zn(Zs,{icon:zn(Ro,{size:14}),onClick:D,danger:!0,children:N("menu.delete")})]})}function Zs({icon:e,children:t,danger:n=!1,compact:r=!1,disabled:o=!1,shortcut:i,onClick:a}){return Vh("button",{type:"button",role:"menuitem","aria-label":typeof t=="string"?t:void 0,className:`${n?"danger":""} ${r?"compact":""}`.trim(),disabled:o,onClick:a,children:[zn("span",{"aria-hidden":"true",children:e}),zn("span",{children:t}),i&&zn("kbd",{children:i})]})}function kXn({icon:e,label:t,open:n,side:r,onOpen:o,onClose:i,children:a}){let s=PNe(null),l=PNe(null),c=PNe(null),u=PNe(null),[d,p]=MCt(null),f=PCt(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},[]),m=PCt(()=>{f(),o()},[f,o]),h=PCt(()=>{f(),u.current=setTimeout(()=>{u.current=null,!s.current?.matches(":hover")&&!c.current?.matches(":hover")&&i()},300)},[f,i]),g=()=>{requestAnimationFrame(()=>c.current?.querySelector("[role='menuitem']")?.focus())};return BZo(()=>{if(!n)return;let y=()=>{let b=l.current?.getBoundingClientRect(),x=c.current?.getBoundingClientRect();if(!b||!x)return;let v=window.visualViewport,S=v?.offsetLeft??0,F=v?.offsetTop??0,w=S+(v?.width??window.innerWidth),C=F+(v?.height??window.innerHeight),A=8,T=r==="right"?b.right-3:b.left-x.width+3,D=b.top-5;p({left:Math.min(Math.max(T,S+A),w-x.width-A),top:Math.min(Math.max(D,F+A),C-x.height-A)})};return y(),window.addEventListener("resize",y),window.visualViewport?.addEventListener("resize",y),()=>{window.removeEventListener("resize",y),window.visualViewport?.removeEventListener("resize",y)}},[n,r]),MZo(()=>()=>f(),[f]),Vh("div",{ref:s,className:"overlay-shape-context-submenu",onMouseEnter:m,onMouseLeave:h,onBlur:y=>{!y.currentTarget.contains(y.relatedTarget)&&!c.current?.contains(y.relatedTarget)&&i()},children:[Vh("button",{ref:l,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":n,onFocus:m,onClick:()=>n?i():m(),onKeyDown:y=>{(y.key==="ArrowRight"||y.key==="Enter"||y.key===" ")&&(y.preventDefault(),m(),g())},children:[zn("span",{"aria-hidden":"true",children:e}),zn("span",{children:t}),zn(tu,{size:14,className:"overlay-shape-context-menu-caret","aria-hidden":"true"})]}),n&&typeof document<"u"&&LZo(zn("div",{ref:c,className:"overlay-shape-context-submenu-panel",role:"menu","aria-label":t,style:{left:d?.left??0,top:d?.top??0,visibility:d?"visible":"hidden"},onMouseEnter:f,onMouseLeave:h,onBlur:y=>{!y.currentTarget.contains(y.relatedTarget)&&!s.current?.contains(y.relatedTarget)&&i()},onKeyDown:y=>{(y.key==="ArrowLeft"||y.key==="Escape")&&(y.preventDefault(),y.stopPropagation(),i(),l.current?.focus())},children:a}),document.body)]})}var IXn=X(()=>{"use strict";"use client";un();er();LQ();fte()});function PXn(e,t,n){let r=Qr(e),o=RXn(r,t);if(o.length<2)return{shapes:r,selectedIds:t};let i=zZo(o),a=GZo(o);if(!a)return{shapes:r,selectedIds:t};let s=new Set(r.map(h=>h.id)),l=HZo(n,s),c={id:l,type:"group",x:a.x,y:a.y,...i?{parentId:i}:{},props:{w:a.w,h:a.h}},u=new Set(o.map(h=>h.id)),d=r.findIndex(h=>u.has(h.id)),p=r.map(h=>u.has(h.id)?UZo({...h,parentId:l}):h),f=d<0?p.length:d,m=[...p.slice(0,f),c,...p.slice(f)];return{shapes:Qr(m),selectedIds:[l]}}function MXn(e,t){let n=Qr(e),r=new Set(t),o=n.filter(u=>wh(u)&&r.has(u.id));if(o.length===0)return{shapes:n,selectedIds:t};let i=new Set(o.map(u=>u.id)),a=new Map(o.map(u=>[u.id,u.parentId])),s=[],l=n.flatMap(u=>{if(i.has(u.id))return[];if(u.parentId&&i.has(u.parentId)){s.push(u.id);let d=a.get(u.parentId),p={...u};return d?p.parentId=d:delete p.parentId,[p]}return[u]}),c=t.filter(u=>!i.has(u));return{shapes:Qr(l),selectedIds:[...c,...s]}}function BCt(e,t,n){let r=bj(e,t);return r?n&&hte(e,r.id,n)?OZo(e,r,n).id:n&&r.id===n?r.id:_Zo(e,r).id:t}function cF(e,t,n){return[BCt(e,t,n)]}function LCt(e,t){return _5(e).filter(n=>(n.parentId??null)===t).map(n=>n.id)}function mte(e,t){return t.hidden?!0:MNe(e,t).some(n=>n.hidden)}function Ac(e,t){return t.locked?!0:MNe(e,t).some(n=>n.locked)}function Js(e,t,n){return n.size===0?!1:n.has(t.id)?!0:MNe(e,t).some(r=>n.has(r.id))}function AA(e,t){let n=new Set(t);return _5(e).filter(r=>n.has(r.id))}function y_(e,t){let n=RCt(e,t,{includeGroups:!0}),r=new Set(n);return _5(e).filter(o=>r.has(o.id))}function $x(e,t,n=RZo){let r=RCt(e,t,{includeGroups:!1}),o=new Set(r);return _5(e).filter(i=>o.has(i.id)&&!Ac(e,i)&&!Js(e,i,n))}function By(e,t,n={}){return RCt(e,t,{includeGroups:n.includeGroups??!0})}function BXn(e,t){let n=new Set(t);for(let r of e){if(!wh(r))continue;let o=e.filter(i=>!wh(i)&&hte(e,i.id,r.id)).map(i=>i.id);o.length>0&&o.every(i=>n.has(i))&&n.add(r.id)}return n}function hte(e,t,n){let r=bj(e,t);if(!r)return!1;let o=r.parentId,i=new Set([r.id]);for(;o;){if(o===n)return!0;if(i.has(o))return!1;i.add(o),o=bj(e,o)?.parentId}return!1}function LXn(e,t){return!!t.parentId&&vP(e,t.parentId)!==null}function vP(e,t){let n=t?bj(e,t):null;return n&&wh(n)?n:null}function RXn(e,t){let n=new Set(t);return e.filter(r=>n.has(r.id)?!MNe(e,r).some(o=>n.has(o.id)):!1)}function RCt(e,t,n){let r=RXn(e,t),o=[],i=a=>{(n.includeGroups||!wh(a))&&o.push(a.id);for(let s of NZo(e,a.id))i(s)};for(let a of r)i(a);return[...new Set(o)]}function _Zo(e,t){let n=t,r=new Set([t.id]);for(;n.parentId;){let o=bj(e,n.parentId);if(!o||r.has(o.id))return n;r.add(o.id),n=o}return n}function OZo(e,t,n){let r=t,o=new Set([t.id]);for(;r.parentId&&r.parentId!==n;){let i=bj(e,r.parentId);if(!i||o.has(i.id))return r;o.add(i.id),r=i}return r}function NZo(e,t){return e.filter(n=>n.parentId===t)}function MNe(e,t){let n=[],r=t.parentId,o=new Set([t.id]);for(;r;){let i=bj(e,r);if(!i||o.has(i.id))break;n.push(i),o.add(i.id),r=i.parentId}return n}function zZo(e){if(e.length===0)return;let t=e[0].parentId;return e.every(n=>n.parentId===t)?t:void 0}function bj(e,t){return e.find(n=>n.id===t)}function UZo(e){if(!e.groupId)return e;let t={...e};return delete t.groupId,t}function HZo(e,t){let n=e(),r=1;for(;t.has(n);)n=`${e()}_${r}`,r+=1;return t.add(n),n}function GZo(e){return e.length===0?null:e.map(Zp).reduce((t,n)=>jZo(t,n))}function jZo(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y),o=Math.max(e.x+e.w,t.x+t.w),i=Math.max(e.y+e.h,t.y+t.h);return{x:n,y:r,w:o-n,h:i-r}}var RZo,Tc=X(()=>{"use strict";Dt();Pn();Dn();RZo=new Set});function _Xn(e){let t=document.createElement("div");Object.assign(t.style,{position:"fixed",left:"-10000px",top:"0",opacity:"0",pointerEvents:"none"});let n=r=>{let o=document.createElementNS("http://www.w3.org/2000/svg",r.tag);for(let[i,a]of Object.entries(r.attrs))o.setAttribute(i,a);for(let i of r.children)o.append(typeof i=="string"?document.createTextNode(i):n(i));return o};try{let r=n(e);r.style.display="block",r.style.width=`${e.attrs.width}px`,r.style.height=`${e.attrs.height}px`,t.append(r),document.body.append(t);let o=r.getBBox(),i=r.getScreenCTM(),a=t.getBoundingClientRect();if(!i||o.width<=0&&o.height<=0)return null;let s=[[o.x,o.y],[o.x+o.width,o.y],[o.x,o.y+o.height],[o.x+o.width,o.y+o.height]].map(([p,f])=>({x:i.a*p+i.c*f+i.e-a.left,y:i.b*p+i.d*f+i.f-a.top})),l=Math.min(...s.map(p=>p.x)),c=Math.min(...s.map(p=>p.y)),u=2,d=Array.from(r.querySelectorAll("marker"));for(let p of Array.from(r.querySelectorAll("path, rect, circle, ellipse, line, polyline, polygon, text"))){let f=getComputedStyle(p),m=p.getScreenCTM();if(!m)continue;let h=Math.max(Math.hypot(m.a,m.b),Math.hypot(m.c,m.d)),g=Number.parseFloat(f.strokeWidth||"1");u=Math.max(u,g*h*Math.max(1,Number.parseFloat(f.strokeMiterlimit||"4")));for(let y of[f.markerStart,f.markerMid,f.markerEnd]){let b=/#([^'"\s)]+)['"]?\)/.exec(y)?.[1];if(!b)continue;let x=d.find(D=>D.id===b);if(!x)return null;let v=Number(x.getAttribute("markerWidth")??3),S=Number(x.getAttribute("markerHeight")??3),F=(x.getAttribute("viewBox")??`0 0 ${v} ${S}`).trim().split(/[\s,]+/).map(Number),w=Number(x.getAttribute("refX")??0),C=Number(x.getAttribute("refY")??0);if(![v,S,w,C,...F].every(Number.isFinite)||F.length!==4||F[2]<=0||F[3]<=0)return null;let A=x.getAttribute("markerUnits")==="userSpaceOnUse"?1:g,T=v+S+Math.abs(w-F[0])*v/F[2]+Math.abs(C-F[1])*S/F[3];u=Math.max(u,T*A*h*2)}}return Number.isFinite(u)?{x:l-u,y:c-u,w:Math.max(...s.map(p=>p.x))-l+u*2,h:Math.max(...s.map(p=>p.y))-c+u*2}:null}catch{return null}finally{t.remove()}}var OXn=X(()=>{"use strict"});import{useEffect as NXn,useRef as zXn,useState as VZo}from"react";function Pye(e,t){if(t?.rotated)return Math.ceil(Math.max(e.scrollHeight,e.offsetHeight));let n=e.getBoundingClientRect(),r=G0(e),o=Array.from(e.querySelectorAll("*")).map(a=>a.getBoundingClientRect()).filter(a=>a.width>0||a.height>0).map(a=>a.bottom),i=Math.max(n.bottom,...o);return Math.ceil(Math.max(e.scrollHeight,n.height/r,(i-n.top)/r))}function BNe(e,t){let n=QS(e),r=Math.max(n,t);return e.type==="callout"?r+FD*2:r}function UXn(e,t){let n=t?.rotated??!1,r=t?.remeasureKey,[o,i]=VZo(null),a=zXn(e),s=zXn(null);return NXn(()=>{a.current=e},[e]),NXn(()=>{if(!o||!a.current)return;s.current=null;let l=()=>{let f=a.current;if(!f)return;let m=Pye(o,{rotated:n}),h=s.current;h!==null&&Math.abs(h-m)<XZo||(s.current=m,f(m))},c=null,u=()=>{c!==null&&window.cancelAnimationFrame(c),c=window.requestAnimationFrame(()=>{c=null,l()})};l();let d=typeof ResizeObserver>"u"?null:new ResizeObserver(u),p=typeof MutationObserver>"u"?null:new MutationObserver(u);return d?.observe(o),p?.observe(o,{attributes:!0,attributeFilter:[..._Ct],childList:!0,subtree:!0}),()=>{c!==null&&window.cancelAnimationFrame(c),d?.disconnect(),p?.disconnect()}},[o,r,n]),i}var _Ct,XZo,LNe=X(()=>{"use strict";"use client";Pn();Gc();_Ct=["class","style","data-boxed-run-aligned","data-sigma-doc-boxed-padding-y","data-sigma-doc-boxed-variant","data-sigma-doc-boxed-tone","data-sigma-doc-boxed-roundness","data-sigma-doc-boxed-math"],XZo=1});import{flushSync as HXn}from"react-dom";import{createRoot as WZo}from"react-dom/client";import{jsx as GXn}from"react/jsx-runtime";async function jXn(){document.fonts&&(await Promise.allSettled(Array.from(document.fonts).filter(e=>e.family.startsWith("KaTeX_")).map(e=>e.load())),await document.fonts.ready)}function VXn(e,t=Rx){let n=document.createElement("div");n.className="overlay-text-shape",Object.assign(n.style,{position:"fixed",left:"-100000px",top:"0",visibility:"hidden",pointerEvents:"none",width:"max-content",minWidth:"0",lineHeight:"1",fontSize:`${e.props.fontSize}pt`,color:e.props.color}),document.body.appendChild(n);let r=WZo(n);try{HXn(()=>r.render(GXn(hy,{environment:t,children:GXn(see,{blocks:e.props.blocks,selfContained:!0})})));let o=n.querySelector(".overlay-text-shape-content"),i=o?.querySelector("p");if(!o||!i)return null;o.style.whiteSpace="nowrap";let a=document.createElement("span");Object.assign(a.style,{display:"inline-block",width:"0",height:"0",verticalAlign:"baseline"}),i.appendChild(a);let s=o.getBoundingClientRect();return{width:s.width+2,height:Pye(o),baseline:a.getBoundingClientRect().top-s.top}}finally{HXn(()=>r.unmount()),n.remove()}}var XXn=X(()=>{"use strict";O_e();b2();Ys();LNe()});import{useCallback as qZo,useLayoutEffect as OCt,useRef as KZo,useState as YZo}from"react";function WXn({documentId:e,shapesRef:t,assetsRef:n,extensionsRef:r,editPolicyLockedShapeIdsRef:o,explicitlySavedShapeStatesRef:i,notifyEditPolicyBlocked:a,setShapes:s,setAssets:l,setSelectedShapeIds:c,commitOverlayChangeNow:u,readAssetSource:d,tShape:p}){let[f,m]=YZo(null),h=aI(),g=KZo(0);OCt(()=>{g.current++},[e]),OCt(()=>()=>{g.current++},[]);let y=qZo(async b=>{let x=g.current,v=()=>{let w=t.current.find(C=>C.id===b&&C.type==="image");return!w||Ac(t.current,w)?null:Js(t.current,w,o.current)?(a(),null):w.type==="image"?w:null},S=v();if(!S)return;let F=n.current[S.props.assetId];try{if(!F)throw new gu("source");let w=await d(F.props.src),C=w.startsWith("blob:")?await(await fetch(w)).text():WB(w);if(await jXn(),x!==g.current)return;let A=v();if(!A||A.props.assetId!==F.id||n.current[F.id]!==F)return;let T=Won({version:1,shapes:t.current,assets:n.current,...r.current?{extensions:r.current}:{}},b,C,_Xn,D=>VXn(D,h));t.current=T.snapshot.shapes,n.current=T.snapshot.assets,i.current.add(T.snapshot.shapes),s(T.snapshot.shapes),l(T.snapshot.assets),u(),c(T.selectedIds),m(p(T.preservedCount?"svgConversion.partial":"svgConversion.done",{count:T.convertedCount}))}catch(w){if(x!==g.current)return;let C=w instanceof gu?w.reason:"source";m(p(`svgConversion.${C}`))}},[n,u,o,i,r,h,a,d,l,c,s,t,p]);return OCt(()=>{if(!f)return;let b=window.setTimeout(()=>m(null),12e3);return()=>window.clearTimeout(b)},[f]),{convertSvg:y,svgConversionMessage:f}}var qXn=X(()=>{"use strict";"use client";Wce();Tc();OXn();XXn();Ys()});import{Fragment as $Zo,jsx as KXn}from"react/jsx-runtime";function Gd({arrangement:e,y:t,children:n}){if(!e||e.columns===1)return KXn($Zo,{children:n});let r=O5(e,gDe(e,t));return KXn("div",{className:"overlay-page-shift",style:{left:r.x,top:r.y},children:n})}var gte=X(()=>{"use strict";"use client";Dn()});var yte=X(()=>{"use strict";Wot()});function ZZo(e,t){let n=Math.round(e),r=Math.round(t);return n===r?`r=${n}`:`${n}\xD7${r}`}function JZo(e,t){return`${Math.round(xh(t-e)*180/Math.PI)}\xB0`}function RNe(e,t){let{rx:n,ry:r}=Pd(e),o=ZZo(n,r),i=JZo(e.props.startAngle,e.props.endAngle);return t==="angle"?i:t==="radius"?o:`${o} ${i}`}var NCt=X(()=>{"use strict";Pn()});var bte=X(()=>{"use strict";Pn()});function xte(e){return e.type==="arc"||e.type==="arcRadius"||e.type==="triangleApex"||e.type==="blockArrowHead"||e.type==="blockArrowShaft"||e.type==="calloutCornerRadius"}function YXn(e,t){if(e.type==="arc"&&(t.type==="arc"||t.type==="arcRadius")){let n=RNe(e,t.type==="arc"?"angle":"radius");return n===null?null:{id:"raw",values:{value:n}}}if(e.type==="geo"&&e.props.geo==="triangle"&&t.type==="triangleApex"){let n=(e.props.apexX??e.props.w/2)/Math.max(1,e.props.w);return{id:"apex",values:{value:zCt(n)}}}if(e.type==="geo"&&e.props.geo==="blockArrow"){if(t.type==="blockArrowHead")return{id:"arrowHead",values:{value:zCt(tce(e.props.headLengthRatio))}};if(t.type==="blockArrowShaft")return{id:"arrowShaft",values:{value:zCt(nce(e.props.shaftRatio))}}}return e.type==="callout"&&t.type==="calloutCornerRadius"?{id:"cornerRadius",values:{value:Math.round(zK(e))}}:null}function zCt(e){return`${Math.round(e*100)}%`}var _Ne=X(()=>{"use strict";NCt();SNe();bte()});function JXn(e,t){let n=iw(e,t),r=GB(e,t,n);return{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}function QXn(e,t,n,r,o){let i=yke(t)??{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},a=Iot(e,n,i),s=e.x+a.x,l=e.y+a.y,c=s+a.width,u=l+a.height,d=e.x+e.w,p=e.y+e.h,f=Math.min(e.w,Math.max(ZXn,a.width*.02)),m=Math.min(e.h,Math.max(ZXn,a.height*.02)),h=e.x,g=e.y,y=d,b=p;return r.includes("w")&&(h=xj(e.x+o.x,s,d-f)),r.includes("e")&&(y=xj(d+o.x,e.x+f,c)),r.includes("n")&&(g=xj(e.y+o.y,l,p-m)),r.includes("s")&&(b=xj(p+o.y,e.y+m,u)),{bounds:{x:h,y:g,w:y-h,h:b-g},crop:{topLeft:{x:ONe((h-s)/a.width),y:ONe((g-l)/a.height)},bottomRight:{x:ONe((y-s)/a.width),y:ONe((b-l)/a.height)}}}}function eWn(e,t,n,r){let o=iw(e,t),i=o.bottomRight.x-o.topLeft.x,a=o.bottomRight.y-o.topLeft.y,s=GB(e,t,o),l=-n/s.width,c=-r/s.height,u=xj(o.topLeft.x+l,0,1-i),d=xj(o.topLeft.y+c,0,1-a);return QZo(e,{topLeft:{x:u,y:d},bottomRight:{x:u+i,y:d+a}})}function QZo(e,t){return{...e,props:{...e.props,crop:t}}}function ONe(e){return xj(e,0,1)}function xj(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,e)):t}var ZXn,NNe=X(()=>{"use strict";Pn();Pn();ZXn=16});import{createContext as eJo}from"react";var zNe,UCt=X(()=>{"use strict";"use client";zNe=eJo(null)});import{memo as HNe,useCallback as oWn,useContext as tJo,useMemo as nJo,useState as rJo,useSyncExternalStore as oJo}from"react";import{Fragment as jNe,jsx as io,jsxs as m1}from"react/jsx-runtime";function iWn(e,t,n){if(!n)return"center";let r=dl(e);return`${r.x-t.x}px ${r.y-t.y}px`}function nWn(e,t){let n=wce(e);return n?{x:n.anchor.x-t.x,y:n.anchor.y-t.y}:null}function vj({shape:e,assets:t,externalRevision:n=0,diffClassName:r,decoration:o,chartSourceTable:i}){let[a,s]=rJo(null),l=e.type==="text"||e.type==="callout"?e:null,c=l?JSON.stringify([l.id,l.type,l.props.w,l.props.fontSize,l.props.size,l.props.blocks]):null,u=oWn((p,f)=>{c&&s(m=>m?.key===c&&Math.abs(m.height-f)<1?m:{key:c,height:f})},[c]),d=e;return l?.type==="callout"&&a?.key===c?d={...l,props:{...l.props,h:Math.max(l.props.h,a.height)}}:l?.type==="text"&&a?.key===c&&(d={...l,props:{...l.props,h:a.height}}),io(GNe,{shape:d,assets:t,chartSourceTable:i,externalRevision:n,selected:!1,editing:!1,disableGraphCrop:!0,hideGraphAxes:!1,originPickPreview:null,dragTranslate:null,diffClassName:r,decoration:o,onPointerDown:GCt,onDoubleClick:jCt,onGraphSpecChange:Mye,onGraphCropEnd:Bye,onTextMeasuredHeight:l?u:void 0})}function Lye(e,t,n=!1,r=!1){let o=[];return t&&(t.x!==0||t.y!==0)&&o.push(`translate(${t.x}px, ${t.y}px)`),e&&o.push(`rotate(${e}rad)`),(n||r)&&o.push(`scale(${n?-1:1}, ${r?-1:1})`),o.length>0?o.join(" "):void 0}function VCt({shape:e,assets:t,bounds:n,chartSourceTable:r,externalRevision:o,editing:i,disableGraphCrop:a,hideGraphAxes:s,originPickPreview:l,onGraphSpecChange:c,onGraphCropEnd:u,editorRenderers:d,onTextMeasuredHeight:p}){if(e.type==="geo"){let f=oc(e.props.size,e.props.strokeScale),m={x:e.props.w/2,y:e.props.h/2};return m1("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${e.props.w} ${e.props.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:f,strokeDasharray:cj(e.props.dash,e.props.dashPattern)},children:[io(sJo,{shape:e}),e.props.label&&io("text",{x:m.x,y:m.y,fill:e.props.labelColor,stroke:"none",textAnchor:"middle",dominantBaseline:"middle",fontSize:R5(e.props.size),children:e.props.label})]})}if(e.type==="arrow"){let f={x:e.x+e.props.start.x-n.x,y:e.y+e.props.start.y-n.y},m={x:e.x+e.props.end.x-n.x,y:e.y+e.props.end.y-n.y},h=nWn(e,n),g=oc(e.props.size,e.props.strokeScale),y=TC(e),[b,x]=HK([f,m],y.start.trimPx,y.end.trimPx);return m1("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${n.w} ${n.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:g,strokeDasharray:cj(e.props.dash,e.props.dashPattern)},children:[io("defs",{children:io(HCt,{shapeId:e.id,color:e.props.color,opacity:e.props.strokeOpacity,plan:y})}),io("line",{x1:b.x,y1:b.y,x2:x.x,y2:x.y,strokeOpacity:e.props.strokeOpacity,markerStart:uj(e.id,"start",y.start.spec?.kind),markerEnd:uj(e.id,"end",y.end.spec?.kind)}),h&&io("text",{x:h.x,y:h.y,fill:e.props.labelColor,stroke:"none",textAnchor:"middle",fontSize:R5(e.props.size),children:e.props.label})]})}if(e.type==="line"){let f=Pb(e.props.kind),m=e.props.points.map(C=>({x:e.x+C.x-n.x,y:e.y+C.y-n.y})),h=Zg(f,m,e.props.closed),g=nWn(e,n),y=oc(e.props.size,e.props.strokeScale),b=TC(e),x=HK(m,b.start.trimPx,b.end.trimPx),v=uj(e.id,"start",b.start.spec?.kind),S=uj(e.id,"end",b.end.spec?.kind),F=`fill-${e.id}`,w=h&&e.props.fill==="solid"?e.props.fillPattern==="diagonalHatch"||e.props.fillPattern==="dots"?`url(#${F})`:e.props.fillColor??e.props.color:"none";return m1("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${n.w} ${n.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:y,strokeDasharray:cj(e.props.dash,e.props.dashPattern)},children:[m1("defs",{children:[io(HCt,{shapeId:e.id,color:e.props.color,opacity:e.props.strokeOpacity,plan:b}),e.props.fillPattern==="diagonalHatch"&&m1("pattern",{id:F,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[io("rect",{width:"6",height:"6",fill:e.props.fillColor??"#ffffff",stroke:"none"}),io("path",{d:"M -1 7 L 7 -1",stroke:e.props.color,strokeWidth:"1"})]}),e.props.fillPattern==="dots"&&m1("pattern",{id:F,patternUnits:"userSpaceOnUse",width:"4",height:"4",children:[io("rect",{width:"4",height:"4",fill:e.props.fillColor??"#ffffff",stroke:"none"}),io("circle",{cx:"2",cy:"2",r:"0.4",fill:e.props.color,stroke:"none"})]})]}),h?io("polygon",{points:I9(m),fill:w,fillOpacity:e.props.fillOpacity,strokeOpacity:e.props.strokeOpacity}):f==="polyline"?io("polyline",{points:I9(x),strokeOpacity:e.props.strokeOpacity,markerStart:v,markerEnd:S}):io("path",{d:Qle(m,f,RDe(b)),strokeOpacity:e.props.strokeOpacity,markerStart:v,markerEnd:S}),g&&io("text",{x:g.x,y:g.y,fill:e.props.labelColor??e.props.color,stroke:"none",textAnchor:"middle",fontSize:R5(e.props.size),children:e.props.label})]})}if(e.type==="arc"){let f=oc(e.props.size,e.props.strokeScale),m=TC(e),h=uj(e.id,"start",m.start.spec?.kind),g=uj(e.id,"end",m.end.spec?.kind);return m1("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${n.w} ${n.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:f,strokeDasharray:cj(e.props.dash,e.props.dashPattern)},children:[io("defs",{children:io(HCt,{shapeId:e.id,color:e.props.color,opacity:e.props.strokeOpacity,plan:m})}),io("path",{d:JVn(e),fill:QVn(e),fillOpacity:e.props.kind==="sector"?e.props.fillOpacity:void 0,stroke:"currentColor",strokeOpacity:e.props.strokeOpacity,markerStart:h,markerEnd:g})]})}if(e.type==="image"){let f=t[e.props.assetId];return f?io(cJo,{shape:e,asset:f,editing:i}):null}if(e.type==="callout"){let f=G5(e),m=TDe(e),h=e.x-n.x,g=e.y-n.y;return m1("div",{className:"callout-shape overlay-callout-shape",children:[io("svg",{className:"callout-shape-svg",viewBox:`${f.bounds.x} ${f.bounds.y} ${f.bounds.w} ${f.bounds.h}`,"aria-hidden":"true",style:{strokeWidth:oc(e.props.strokeWidth),strokeDasharray:cj(e.props.dash)},children:io("path",{d:qle(e)})}),io("div",{className:"overlay-callout-text-frame",style:{left:h+m.x,top:g+m.y,width:m.w,height:m.h},children:i&&d?d.renderTextEditor({editing:i,externalRevision:o,shape:e}):io(rWn,{shape:e,onMeasuredHeight:p})})]})}if(e.type==="graph2dShape"){let f=sx(e),m=f.spec,h=s?dJo(m):m,g=i||a||s||l!==null;return m1("div",{id:e.id,className:"graph-shape overlay-graph-shape","data-testid":"overlay-graph2d",style:{position:"absolute",left:f.renderBounds.x-e.x,top:f.renderBounds.y-e.y,width:f.renderBounds.w,height:f.renderBounds.h,pointerEvents:g?"auto":"none"},children:[io(sI,{shapeId:e.id,spec:h,originLabeled:qDe(e),autoStartCrop:i,disableCropInteraction:a,onSpecChange:(y,b)=>c(e.id,y,b),onCropEnd:u}),l&&m1("div",{className:"graph-origin-preview","data-testid":"overlay-graph-origin-preview","aria-hidden":"true",children:[io(sI,{spec:pJo(l.spec),className:"graph-origin-preview-graph",staticMode:!0,disableCropInteraction:!0}),m1("svg",{className:"graph-origin-preview-marker","data-testid":"overlay-graph-origin-preview-target",viewBox:`0 0 ${l.spec.width} ${l.spec.height}`,"aria-hidden":"true",children:[io("line",{x1:Math.max(0,l.point.x-UNe),x2:Math.min(l.spec.width,l.point.x+UNe),y1:l.point.y,y2:l.point.y}),io("line",{x1:l.point.x,x2:l.point.x,y1:Math.max(0,l.point.y-UNe),y2:Math.min(l.spec.height,l.point.y+UNe)}),io("circle",{cx:l.point.x,cy:l.point.y,r:"6"})]})]})]})}if(e.type==="graph3dShape"){let f=e.props.previewAssetId?t[e.props.previewAssetId]:void 0,m=!!(f&&e.props.previewSourceHash!==AD(e.props.spec));return io("div",{className:"graph3d-shape overlay-graph3d-shape","data-testid":"overlay-graph3d",style:{width:e.props.w,height:e.props.h},children:d&&(i||m||!f)?d.renderGraph3DEditor({interactive:i,shape:e}):f?m1(jNe,{children:[io("img",{alt:f.props.name,draggable:!1,src:f.props.src,style:{display:"block",width:"100%",height:"100%",objectFit:"cover"}}),io(ext,{spec:e.props.spec,width:e.props.w,height:e.props.h}),m&&io("span",{className:"overlay-graph3d-stale",children:tWn("graph3d.previewWaiting")})]}):io("div",{className:"overlay-graph3d-placeholder","aria-label":tWn("graph3d.aria"),children:io("span",{"aria-hidden":"true",children:"3D"})})})}return e.type==="tableShape"?d?d.renderTableEditor({editing:i,shape:e}):io(Hhe,{height:e.props.h,table:e.props.table,width:e.props.w}):e.type==="chartShape"?io(aJo,{shape:e,sourceTable:r??null}):e.type==="group"?null:!i||!d?io(rWn,{shape:e,onMeasuredHeight:p}):d.renderTextEditor({editing:i,externalRevision:o,shape:e})}function aJo({shape:e,sourceTable:t}){let n=nJo(()=>yK(e.props,t),[e.props,t]);return io("div",{className:"chart-shape","data-testid":"overlay-chart",children:io(zhe,{data:n,height:e.props.h,spec:e.props.spec,width:e.props.w})})}function sJo({shape:e}){let t=e.props.fill==="solid"?e.props.fillColor??e.props.color:"transparent",n={fill:t,stroke:e.props.color,fillOpacity:e.props.fillOpacity,strokeOpacity:e.props.strokeOpacity};if(Nc(e))return io(lJo,{shape:e,fill:t});if(e.props.geo==="ellipse")return io("ellipse",{cx:e.props.w/2,cy:e.props.h/2,rx:e.props.w/2,ry:e.props.h/2,...n});if(e.props.geo==="triangle"||e.props.geo==="diamond"||e.props.geo==="pentagon"||e.props.geo==="regularPolygon"||e.props.geo==="blockArrow")return io("polygon",{points:ZVn(e.props.geo,e.props.w,e.props.h,e.props.apexX,e.props.headLengthRatio,e.props.shaftRatio,e.props.polygonSides),...n});let r=typeof e.props.radius=="number"&&e.props.radius>0?Math.max(0,Math.min(e.props.radius,e.props.w/2-1,e.props.h/2-1)):void 0;return io("rect",{x:1,y:1,width:Math.max(1,e.props.w-2),height:Math.max(1,e.props.h-2),rx:r,ry:r,...n})}function lJo({shape:e,fill:t}){let n=q9(e);return m1(jNe,{children:[e.props.fill==="solid"&&(e.props.geo==="sphere"?io("ellipse",{cx:e.props.w/2,cy:e.props.h/2,rx:e.props.w/2,ry:e.props.h/2,fill:t,fillOpacity:e.props.fillOpacity,stroke:"none"}):io("polygon",{points:tY(e).map(r=>`${r.x},${r.y}`).join(" "),fill:t,fillOpacity:e.props.fillOpacity,stroke:"none"})),n.map(r=>io("path",{d:r.d,fill:"none",stroke:e.props.color,strokeOpacity:e.props.strokeOpacity,strokeWidth:oc(r.size),strokeDasharray:cj(r.dash)??"none",strokeLinecap:r.dash==="solid"?"round":"butt","data-solid-edge":r.index},r.index))]})}function HCt({shapeId:e,color:t,opacity:n,plan:r}){return io(jNe,{children:GTe(e,r).map(({spec:o,endpoint:i,id:a,refX:s})=>io("marker",{id:a,markerWidth:o.markerWidth,markerHeight:o.markerHeight,refX:s,refY:o.refY,orient:jTe(o,i),markerUnits:"strokeWidth",children:o.geometry.kind==="circle"?io("circle",{cx:o.geometry.cx,cy:o.geometry.cy,r:o.geometry.r,fill:o.geometry.filled?t:"none",opacity:n,stroke:"none"}):io("path",{d:yD(o.geometry),fill:o.geometry.filled?t:"none",opacity:n,stroke:o.geometry.filled?"none":t,strokeWidth:o.geometry.filled?void 0:o.geometry.strokeWidth,strokeLinecap:"butt",strokeLinejoin:"miter"})},a))})}function rWn({shape:e,onMeasuredHeight:t}){let n=QS(e),r=e.type==="callout",o=oWn(a=>{t?.(e.id,BNe(e,a))},[t,e]),i=UXn(t?o:void 0,{rotated:Oi(e)!==0,remeasureKey:e.props.w});return io("div",{className:`overlay-text-shape ${r?"embedded-callout":""} ${e.type==="text"&&e.props.textWrap==="none"?"no-auto-wrap":""}`,"data-boxed-run-frames":!r&&Oi(e)===0?"true":void 0,style:{width:r?"100%":e.props.w,...e.type==="text"?LK(e):{},minWidth:r?0:wD,minHeight:r?n:Math.max(e.props.h,n),color:e.props.color,fontSize:`${xC(e)}pt`,pointerEvents:"none"},children:io(see,{blocks:e.props.blocks,contentRef:i,noWrap:e.type==="text"&&e.props.textWrap==="none"})})}function cJo({shape:e,asset:t,editing:n}){let r=HD();oJo(a=>r?.subscribeAssets?.(a)??(()=>{}),()=>r?.assetSourceVersion?.()??0,()=>0);let o=r?.resolveAssetSource?.(t.props.src)??t.props.src,i=JXn(e,t);return m1("div",{className:`overlay-image-frame ${n?"cropping":""}`,children:[n&&io("div",{className:"overlay-image-crop-ghost",style:{width:i.width,height:i.height,transform:i.transform},"aria-hidden":"true",children:io("img",{src:o,alt:"",draggable:!1})}),io("div",{className:"overlay-image-crop-viewport",children:io("div",{className:"overlay-image-crop-inner",style:{width:i.width,height:i.height,transform:i.transform},children:io("img",{className:"overlay-image-shape",src:o,alt:t.props.name,draggable:!1})})})]})}function uJo(e){return`${Math.max(1,Math.round(e.w))} x ${Math.max(1,Math.round(e.h))}`}function dJo(e){return{...e,axes:{...e.axes,grid:!1,showX:!1,showY:!1,showTicks:!1}}}function pJo(e){return{...e,title:"",axes:{...e.axes,grid:!1,showX:!0,showY:e.kind==="cartesian",showTicks:!1},points:void 0,annotations:void 0,fills:void 0,showFormulaLabels:!1}}var UNe,tWn,Mye,Bye,GCt,jCt,GNe,aWn,iJo,sWn,vte=X(()=>{"use strict";O_e();Dn();Ys();Dn();Dt();Pn();kh();ho();u4();NNe();UCt();jh();wNe();bte();LNe();Yx();Tye();UNe=14,tWn=Fr("shape");Mye=()=>{},Bye=()=>{},GCt=()=>{},jCt=()=>{};GNe=HNe(function({shape:t,assets:n,chartSourceTable:r,externalRevision:o,selected:i,editing:a,disableGraphCrop:s,hideGraphAxes:l,originPickPreview:c,dragTranslate:u,onPointerDown:d,onDoubleClick:p,onGraphSpecChange:f,onGraphCropEnd:m,diffClassName:h,decoration:g,editorRenderers:y,onTextMeasuredHeight:b,textPaintRevision:x}){Ci("OverlayShapeView.render");let v=tJo(zNe),S=t.type==="image"&&v?.shapeId===t.id?v:null,F=S&&t.type==="image"?{...t,props:{...t.props,h:t.props.w*S.height/S.width,crop:void 0}}:t,w=t.type==="image"?n[t.props.assetId]:void 0,C=S&&w?{...n,[w.id]:{...w,props:{...w.props,src:S.src,w:S.width,h:S.height}}}:n,A=yi(F),T=t.type==="text"?FDe(t):null,D=Oi(t),k=`overlay-shape overlay-shape-${t.type} ${i?"selected":""} ${t.locked?"locked":""} ${g?.className??""} ${h??""}`;return m1("div",{"data-overlay-shape-id":t.id,className:k,style:{left:A.x,top:A.y,width:A.w,height:A.h,transform:Lye(D,u,t.flipX,t.flipY),transformOrigin:iWn(t,A,D),opacity:t.opacity,isolation:T?"isolate":void 0,...(t.type==="geo"||t.type==="line")&&t.props.hitTestMode==="stroke"?{pointerEvents:"none"}:{}},onPointerDown:P=>d(P,t),onDoubleClickCapture:P=>{t.type!=="graph2dShape"&&t.type!=="graph3dShape"||(P.preventDefault(),P.stopPropagation(),p(P,t))},onDoubleClick:P=>{t.type==="graph2dShape"||t.type==="graph3dShape"||(P.preventDefault(),P.stopPropagation(),p(P,t))},children:[T&&io("svg",{className:"overlay-text-box-decoration","aria-hidden":"true",width:A.w,height:A.h,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none",zIndex:-1},children:io("rect",{width:A.w,height:A.h,...T})}),io(VCt,{shape:F,assets:C,bounds:A,chartSourceTable:r,externalRevision:o,editing:a,disableGraphCrop:s,hideGraphAxes:l,originPickPreview:c,onGraphSpecChange:f,onGraphCropEnd:m,editorRenderers:y,onTextMeasuredHeight:b},!a&&(t.type==="text"||t.type==="callout")?x:void 0),g?.content]})}),aWn=HNe(function({shapes:t,dragTranslate:n,movingShapeIds:r}){return io(jNe,{children:t.map(o=>io(iJo,{shape:o,dragTranslate:r?.has(o.id)?n:null},`dimension-${o.id}`))})}),iJo=HNe(function({shape:t,dragTranslate:n}){let r=PB(t),o=FK(r,Oi(t)),i=r.x+r.w/2,a=n?.x??0,s=n?.y??0;return io("div",{className:"overlay-shape-dimension-label",style:{left:i+a,top:o.y+o.h+2+s},"aria-hidden":"true",children:uJo(r)})}),sWn=HNe(function({shape:t,selected:n,dragTranslate:r,onPointerDown:o,onDoubleClick:i}){let a=yi(t),s=Oi(t);return io("div",{"data-overlay-shape-id":t.id,className:`overlay-shape overlay-shape-hit-target ${n?"selected":""}`,style:{left:a.x,top:a.y,width:a.w,height:a.h,transform:Lye(s,r,t.flipX,t.flipY),transformOrigin:iWn(t,a,s),...(t.type==="geo"||t.type==="line")&&t.props.hitTestMode==="stroke"?{pointerEvents:"none"}:{}},onPointerDown:l=>o(l,t),onDoubleClick:l=>{l.preventDefault(),l.stopPropagation(),i(l,t)}})})});import{useEffect as fJo,useState as mJo}from"react";import{Fragment as gJo,jsx as q2,jsxs as VNe}from"react/jsx-runtime";function cWn({tool:e,surfaceRef:t,pointFromClient:n,assets:r,styleDefaults:o,arrangement:i=null}){let[a,s]=mJo(null);return fJo(()=>{let l=0,c=d=>{cancelAnimationFrame(l);let p=d.target instanceof Node&&t.current?.contains(d.target);l=requestAnimationFrame(()=>{s(p?n(d.clientX,d.clientY):null)})},u=()=>{cancelAnimationFrame(l),s(null)};return document.addEventListener("pointermove",c),document.addEventListener("pointerleave",u),window.addEventListener("blur",u),()=>{cancelAnimationFrame(l),document.removeEventListener("pointermove",c),document.removeEventListener("pointerleave",u),window.removeEventListener("blur",u)}},[n,t]),a?q2("div",{"data-table-placement-preview":"","aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none"},children:q2(Gd,{arrangement:i,y:a.y,children:q2(XCt,{tool:e,start:a,current:a,bounds:{...a,w:0,h:0},assets:r,styleDefaults:o})})}):null}function uWn(e,t,n,r){let o=kce(e);if(o.kind==="insert"&&o.command==="table")return r("table.placeHint");if(o.kind!=="insert"||!Iye(o))return null;let i=o.command,a=ien(t?{kind:"drawing",command:i,pointCount:t.points.length,canClose:n}:{kind:"armed",command:i});return r(`drawingHint.${a.id}`,"values"in a?a.values:{})}function dWn({points:e,current:t,closeArmed:n}){return VNe("div",{className:"overlay-drawing-markers","aria-hidden":"true",children:[e.map((r,o)=>q2("div",{className:`overlay-drawing-vertex-marker ${o===0&&n?"close-target":""}`,style:{left:r.x,top:r.y}},o)),!n&&q2("div",{className:"overlay-drawing-vertex-marker pending",style:{left:t.x,top:t.y}})]})}function XCt({tool:e,start:t,current:n,points:r,closed:o,bounds:i,assets:a,styleDefaults:s}){if(e.command==="table"&&e.tableCellSize)return q2(hJo,{start:t,current:n,cellSize:e.tableCellSize});let l=gj(e,t,n,lWn,r,o,s);if(!l)return null;let c=yi(l);return l.type===nE&&(l.props.table.grid={...l.props.table.grid,borderStyle:"dashed",borderColor:"#9ca3af"}),VNe(gJo,{children:[q2("div",{className:`overlay-insert-preview-frame${e.command==="table"?" table-placement":""}`,style:{left:e.command==="table"?c.x:i.x,top:e.command==="table"?c.y:i.y,width:e.command==="table"?c.w:i.w,height:e.command==="table"?c.h:i.h}}),q2("div",{className:`overlay-insert-preview-shape overlay-shape${e.command==="table"?" table-placement":""}`,style:{left:c.x,top:c.y,width:c.w,height:c.h},children:q2(VCt,{shape:l,assets:a,bounds:c,externalRevision:0,editing:!1,disableGraphCrop:!0,hideGraphAxes:l.type===lF,originPickPreview:null,onGraphSpecChange:Mye,onGraphCropEnd:Bye})})]})}function hJo({start:e,current:t,cellSize:n}){let r=We("shape"),o=hD(e,t,n),i=[...Array.from({length:o.columns-1},(a,s)=>`M${(s+1)*o.cellW} 0V${o.h}`),...Array.from({length:o.rows-1},(a,s)=>`M0 ${(s+1)*o.cellH}H${o.w}`)].join(" ");return VNe("div",{className:"overlay-insert-preview-shape overlay-shape table-grid-placement","data-table-preview-rows":o.rows,"data-table-preview-columns":o.columns,style:{left:o.x,top:o.y,width:o.w,height:o.h},children:[VNe("svg",{width:"100%",height:"100%","aria-hidden":"true",className:"table-grid-placement-lines",children:[q2("rect",{x:"0.5",y:"0.5",width:o.w-1,height:o.h-1}),q2("path",{d:i})]}),q2("div",{className:"table-placement-hint",children:r("table.dragHint")})]})}function pWn(e){return e==="frame"||e==="thick"||e==="double"||e==="oval"||e==="shade"||e==="compact"?e:void 0}function fWn(e,t,n,r,o){if(!n)return null;if(e.id==="overlay.point"&&xte(e.handle)){let i=e.shape.id,a=t.find(l=>l.id===i);if(!a)return null;let s=YXn(a,e.handle);return s?{text:o(`adjustment.${s.id}`,{replace:s.values}),position:n}:null}if(e.id==="overlay.insertDrag"&&h_(e.tool)){let i=gj(e.tool,e.start,e.current,lWn,void 0,!1,J9(e.tool.command,r));return i?.type!=="arc"?null:{text:RNe(i,"both"),position:n}}return null}function mWn({text:e,position:t}){return q2("div",{className:"overlay-drag-readout",style:{left:t.x+16,top:t.y+16},children:e})}var lWn,XNe=X(()=>{"use strict";"use client";Pn();gte();un();yte();_Ne();vte();NCt();xP();Yx();m_();lWn="__overlay_insert_preview__"});function hWn(e,t){return e.id==="overlay.move"?{id:"overlay.move",labelId:"moving"}:e.id==="overlay.resize"?{id:"overlay.resize",labelId:"resizing"}:e.id==="overlay.rotate"?{id:"overlay.rotate",labelId:"rotating"}:e.id==="overlay.anchor"?{id:"overlay.anchor",labelId:"anchoring"}:e.id==="overlay.marquee"?{id:"overlay.marquee",labelId:"marquee"}:e.id==="overlay.textEditing"?{id:"overlay.textEditing",labelId:"textEditing"}:e.id==="overlay.imageCropping"||e.id==="overlay.imageCropResize"||e.id==="overlay.imageCropPan"?{id:"overlay.imageCropping",labelId:"imageCropping"}:e.id==="overlay.graphEditing"?{id:"overlay.graphEditing",labelId:"graphEditing"}:e.id==="overlay.graph3dEditing"?{id:"overlay.graph3dEditing",labelId:"graph3dEditing"}:e.id==="overlay.tableEditing"?{id:"overlay.tableEditing",labelId:"tableEditing"}:e.id==="overlay.originPicking"?{id:"overlay.originPicking",labelId:"originPicking"}:e.id==="overlay.graphFillPicking"?{id:"overlay.graphFillPicking",labelId:"fillPicking"}:e.id==="overlay.curveDrawing"?e.tool.command==="threePointArc"?{id:"overlay.curveDrawing",labelId:"threePointArc"}:{id:"overlay.curveDrawing",labelId:e.tool.command==="polyline"?"polyline":"curve"}:e.id==="overlay.insertDrag"?{id:"overlay.insertDrag",labelId:e.tool.command==="graph"||e.tool.command==="graph3d"?"pickViewport":"placeShape"}:e.tool.kind==="insert"?{id:"overlay.select",labelId:"insert"}:{id:"overlay.select",labelId:t>0?"select":"shape"}}var gWn=X(()=>{"use strict"});function bWn(){if(typeof window>"u")return WNe;try{let e=window.localStorage.getItem(yWn),t=e===null?Number.NaN:Number(e);Number.isFinite(t)&&t>=0&&(WNe=t)}catch{}return WNe}function qNe(e){if(WNe=e,!(typeof window>"u"))try{window.localStorage.setItem(yWn,String(e))}catch{}}var yWn,WNe,KNe=X(()=>{"use strict";bte();yWn="sigma-studio:overlay-callout-corner-radius",WNe=CD});var WCt=X(()=>{"use strict";$ot()});function b_(e,t){return e.type==="group"?aw([e],t)??A0(e):bke(e)}function Sj(e,t,n={},r={}){let o=YNe(e);if(o.size===0)return e;let i=t instanceof Map?t:new Map(t.map(u=>[u.id,u])),a=new Map;for(let u of e)!u.parentId||!o.has(u.parentId)||a.set(u.parentId,[...a.get(u.parentId)??[],u]);let s=new Map,l=new Set,c=u=>{if(!l.has(u.id)){l.add(u.id);for(let d of a.get(u.id)??[]){let f=r.onlyUnanchored===!0&&d.anchor!==void 0&&!(r.rebindPageAnchoredMembers===!0&&d.anchor.type==="page")?null:bJo(d,u.anchor,i,n),m=f&&!Zx(d.anchor,f)?{...d,anchor:f}:d;m!==d&&s.set(d.id,m),o.has(d.id)&&c(m)}}};for(let u of e)o.has(u.id)&&!(u.parentId&&o.has(u.parentId))&&c(u);return s.size===0?e:e.map(u=>s.get(u.id)??u)}function bJo(e,t,n,r){if(!t)return null;if(t.type==="page")return{type:"page"};if(t.type!=="block")return null;let o=n.get(t.blockId);if(!o)return null;let i=t.reserveSpace===!0?Math.max(0,Number.isFinite(r[t.blockId])?r[t.blockId]:0):0,a=t.line?.index,s=a===void 0?void 0:o.lines?.find(l=>l.index===a)?.top;return{type:"block",blockId:t.blockId,dy:e.y-(o.top-i),...t.dx!==void 0&&o.left!==void 0?{dx:e.x-o.left}:{},...a!==void 0&&s!==void 0?{line:{index:a,dy:e.y-(s-i)}}:{},...t.reserveSpace!==void 0?{reserveSpace:t.reserveSpace}:{}}}function YNe(e){let t=new Set;for(let n of e)n.type==="group"&&t.add(n.id);return t}function qCt(e,t){return!!e.parentId&&t.has(e.parentId)}function $Ne(e,t){let n=new Set(t),r=new Map(e.map(o=>[o.id,o]));for(let o of t){let i=r.get(o)?.parentId,a=new Set([o]);for(;i&&!a.has(i);){a.add(i);let s=r.get(i);if(!s||s.type!=="group")break;n.add(s.id),i=s.parentId}}return n}function Zx(e,t){let n=e??{type:"page"},r=t??{type:"page"};return n.type!==r.type?!1:n.type==="page"||r.type==="page"?!0:n.type==="shape"||r.type==="shape"?n.type==="shape"&&r.type==="shape"&&n.shapeId===r.shapeId&&n.dx===r.dx&&n.dy===r.dy&&n.rx===r.rx&&n.ry===r.ry:n.blockId===r.blockId&&n.dy===r.dy&&n.dx===r.dx&&n.reserveSpace===r.reserveSpace&&n.line?.index===r.line?.index&&n.line?.dy===r.line?.dy}function x_(e,t,n){if(t===e||!n||n.size===0)return t;let r=new Map(e.filter(a=>Js(e,a,n)).map(a=>[a.id,a]));if(r.size===0)return t;let o=t.length!==e.length,i=t.map((a,s)=>{let l=r.get(a.id)??a;return o||=l!==e[s],l});return o?i:e}function xWn(e,t,n={},r){if(t.length===0)return e;let o=YNe(e),i=!1,a=e.map(s=>{if(s.anchor?.type==="page"||s.anchor?.type==="shape"||qCt(s,o))return s;let l=b_(s,e),c=s.anchor?.type==="block"?s.anchor:null,u=c?.blockId??null,d=c?.reserveSpace===!0&&u?n[u]??0:0,p=d>0?t.map(y=>y.id===u?{...y,top:y.top-d,lines:y.lines?.map(b=>({...b,top:b.top-d}))}:y):t,f=u?p.find(y=>y.id===u):void 0,h=f&&!f.derived&&fP(f)&&(!c?.line||Brt(c,f))?gP(l.y,s.y,[f],l.x+l.w/2,s.x):gP(l.y,s.y,p,l.x+l.w/2,s.x);if(h.type!=="block")return s;let g=KCt(c??void 0,h);return Zx(s.anchor,g)?s:(i=!0,{...s,anchor:g})});return x_(e,Md(Sj(i?a:e,t,n)),r)}function ZNe(e,t,n=j5,r){let o=e.reduce((l,c)=>l+(c.anchor===void 0?1:0),0);if(t.length===0||o===0||o>yJo)return e;let i=YNe(e),a=!1,s=e.map(l=>{if(l.anchor!==void 0||qCt(l,i))return l;let c=b_(l,e),u=gP(c.y,l.y,t,c.x+c.w/2,l.x);if(u.type!=="block")return l;let d=t.find(p=>p.id===u.blockId);return!d||E9(d.top,n).pageIndex!==E9(c.y,n).pageIndex?l:(a=!0,{...l,anchor:u})});return x_(e,Md(Sj(a?s:e,t,{},{onlyUnanchored:!0})),r)}function Jx(e,t,n){if(t.size===0)return e;let r=YNe(e),o=$Ne(e,t),i=!1,a=e.map(s=>{if(!o.has(s.id)||s.anchor?.type==="page"||s.anchor?.type!=="shape"&&qCt(s,r))return s;if(s.anchor?.type==="shape"){let d=s.anchor,p=e.find(m=>m.id===d.shapeId);if(!p)return s;let f=dCt(s,p);return Zx(s.anchor,f)?s:(i=!0,{...s,anchor:f})}if(n.length===0)return s;let l=b_(s,e),c=gP(l.y,s.y,n,l.x+l.w/2,s.x),u=KCt(s.anchor,c);return Zx(s.anchor,u)?s:(i=!0,{...s,anchor:u})});return Md(Sj(i?a:e,n))}function vWn(e,t,n,r){let o=t.anchor;if(!o||o.type==="page")return e;if(o.type==="shape"){let l=n.find(c=>c.id===o.shapeId);return l?{...e,anchor:dCt(e,l)}:e}let i=r.get(o.blockId);if(!i||!fP(i))return e;let a=b_(e,n),s=gP(a.y,e.y,[i],a.x+a.w/2,e.x);return{...e,anchor:KCt(o,s)}}function KCt(e,t){return e?.type==="block"&&e.reserveSpace!==void 0&&t.type==="block"?{...t,reserveSpace:e.reserveSpace}:t}var yJo,Ly=X(()=>{"use strict";My();Pn();mP();Tc();yJo=64});import{Fragment as Ste,jsx as ng,jsxs as JNe}from"react/jsx-runtime";function e9e(e){return e.type==="line"||e.type==="arrow"}function AJo(e){return e9e(e)||e.type==="callout"}function FWn(e,t){let n=Math.max(1,Math.min(e.w,e.h)),r=Math.round(Yo(n*.22,4,9)),o=t?Math.max(1,Math.max(e.w,e.h)):n,i=Math.round(Yo(o*.2,4,8)),a=Math.round(Yo(n*.24,6,15)),s=Math.round(Yo(n*.16,5,10));return{"--overlay-corner-handle-size":`${r}px`,"--overlay-corner-handle-offset":`${r/-2}px`,"--overlay-point-handle-size":`${i}px`,"--overlay-crop-corner-handle-size":`${a}px`,"--overlay-crop-corner-handle-offset":`${a/-2}px`,"--overlay-crop-edge-handle-thickness":`${s}px`}}function CWn({shape:e,bounds:t,onPointPointerDown:n,onLineInsertPointerDown:r}){let o=We("shape");if(!AJo(e)&&!SZt(Zp(e)))return null;if(e.type==="arc")return ng(Ste,{children:[["start",bCt(e,"start")],["end",bCt(e,"end")]].map(([l,c])=>{let u=rw(e,t,c);return ng(wj,{className:`overlay-arc-point-handle ${l}`,style:{left:u.x,top:u.y},onPointerDown:d=>n(d,e,{type:"arc",endpoint:l})},l)})});if(e.type==="geo"&&Nc(e))return e.props.geo==="sphere"?null:ng(Ste,{children:TD(e).map((l,c)=>{let u=AWn(e,t,l);return ng("div",{className:"overlay-point-handle overlay-solid-vertex-handle",title:o("point.moveVertex"),style:{left:u.x,top:u.y},onPointerDown:d=>n(d,e,{type:"solidVertex",index:c})},c)})});if(e.type==="geo"&&e.props.geo==="triangle"){let l=rw(e,t,{x:DJo(e),y:0});return ng(wj,{className:"overlay-triangle-apex-handle",style:{left:l.x,top:l.y},onPointerDown:c=>n(c,e,{type:"triangleApex"})})}if(e.type==="geo"&&e.props.geo==="blockArrow"){let l=rw(e,t,ODe(e)),c=rw(e,t,Vrt(e));return JNe(Ste,{children:[ng(wj,{className:"overlay-block-arrow-head-handle",style:{left:l.x,top:l.y},onPointerDown:u=>n(u,e,{type:"blockArrowHead"})}),ng(wj,{className:"overlay-block-arrow-shaft-handle",style:{left:c.x,top:c.y},onPointerDown:u=>n(u,e,{type:"blockArrowShaft"})})]})}if(e.type==="arrow")return ng(Ste,{children:[["start",e.props.start],["end",e.props.end]].map(([l,c])=>{let u=rw(e,t,c);return ng("div",{className:`overlay-point-handle overlay-arrow-point-handle ${l}`,style:{left:u.x,top:u.y},onPointerDown:d=>n(d,e,{type:"arrow",endpoint:l})},l)})});if(e.type==="callout"){let l=G5(e),c=rw(e,t,l.tip),u=rw(e,t,Drt(e));return JNe(Ste,{children:[ng(wj,{className:"overlay-callout-corner-radius-handle",style:{left:u.x,top:u.y},onPointerDown:d=>n(d,e,{type:"calloutCornerRadius"})}),ng(wj,{className:"overlay-callout-tail-tip-handle",style:{left:c.x,top:c.y},onPointerDown:d=>n(d,e,{type:"calloutTailTip"})}),[["start",l.baseStart],["end",l.baseEnd]].map(([d,p])=>{let f=rw(e,t,p);return ng(wj,{className:`overlay-callout-tail-base-handle ${d}`,style:{left:f.x,top:f.y},onPointerDown:m=>n(m,e,{type:"calloutTailBase",endpoint:d})},d)})]})}if(e.type!=="line")return null;let i=Pb(e.props.kind),a=i==="freehand"&&e.props.points.length>1?[[0,e.props.points[0]],[e.props.points.length-1,e.props.points[e.props.points.length-1]]]:e.props.points.map((l,c)=>[c,l]),s=jQt(e.props.points,i,e.props.closed===!0);return JNe(Ste,{children:[s.map(({index:l,point:c})=>{let u=rw(e,t,c);return ng("div",{className:"overlay-line-insert-handle",title:o("point.add"),style:{left:u.x,top:u.y},onPointerDown:d=>r(d,e,l,c)},`insert-${l}`)}),a.map(([l,c])=>{let u=rw(e,t,c);return ng("div",{className:"overlay-point-handle overlay-line-point-handle",title:l===0||!UK(i)?void 0:o("point.move"),style:{left:u.x,top:u.y},onPointerDown:d=>n(d,e,{type:"line",index:l})},l)})]})}function AWn(e,t,n){return rw(e,t,{x:e.flipX?e.props.w-n.x:n.x,y:e.flipY?e.props.h-n.y:n.y})}function ZCt({shape:e,bounds:t,edge:n,hover:r=!1}){let o=q9(e).find(a=>a.index===n);if(!o)return null;let i=o.points.map(a=>AWn(e,t,a)).map(a=>`${a.x},${a.y}`).join(" ");return JNe("svg",{className:r?"overlay-solid-edge-highlight hover":"overlay-solid-edge-highlight",width:t.w,height:t.h,"aria-hidden":"true","data-solid-edge-highlight":r?void 0:n,"data-solid-edge-hover":r?n:void 0,children:[ng("polyline",{className:"halo",points:i}),ng("polyline",{className:"core",points:i})]})}function wj({className:e,style:t,onPointerDown:n}){return ng("div",{className:`overlay-point-handle overlay-adjust-handle ${e}`,style:t,onPointerDown:n})}function TWn(e,t,n,r,o,i,a,s){let l=yi(e),c=i!==null,u={width:r,height:o,bleed:s};if(i){let p=vNe(i,n.ordered,l.y),f=p?n.rects.get(p.blockId):void 0;return p&&f?wWn(e,l,p,f,u,!0):$Ct(e,l,"page",void 0,i,u,!0)}let d=TJo(e,b_(e,t),n.ordered,a);if(d.type==="block"){let p=n.rects.get(d.blockId);return p?wWn(e,l,HVn(d,p),p,u,c):$Ct(e,l,"missing",d.blockId,null,u,c)}return $Ct(e,l,d.type==="shape"?"shape":"page",void 0,null,u,c)}function wWn(e,t,n,r,o,i){let a=kWn(n.left,n.width,n.y,o);return{shape:e,rule:a,gripX:JCt(t,a,o),leader:DWn(t,a,o),targetRect:{left:n.left,top:r.top,width:n.width,height:r.height??0},blockId:n.blockId,state:"block",below:t.y>=a.y,dragging:i}}function $Ct(e,t,n,r,o,i,a){let s=Yo(t.w,QNe,Math.max(QNe,i.width-24)),l=o?.x??t.x+t.w/2,c=o?.y??t.y-CJo,u=kWn(l-s/2,s,c,i);return{shape:e,rule:u,gripX:JCt(t,u,i),leader:DWn(t,u,i),targetRect:null,blockId:r,state:n,below:t.y>=u.y,dragging:a}}function JCt(e,t,n){let r=Math.min(xJo,t.width/2),o=Yo(e.x+e.w/2,t.left+r,t.left+t.width-r);if(!(t.y>=e.y-SJo&&t.y<=e.y+e.h+wJo))return o;let a=n.bleed?.x??0,s=vJo+YCt;return e.x-s-YCt>=-a?e.x-s:e.x+e.w+s+YCt<=n.width+a?e.x+e.w+s:o}function DWn(e,t,n){let r=e.y,o=e.y+e.h,i=t.y<=r||t.y<o&&t.y-r<=o-t.y?r:o,a=Math.abs(i-t.y),s=JCt(e,t,n),l=s>=e.x&&s<=e.x+e.w;return a<FJo&&l?null:{x1:s,y1:i>=t.y?t.y+SWn:t.y-SWn,x2:e.x+e.w/2,y2:i}}function TJo(e,t,n,r=!1){return!r&&(e.anchor?.type==="block"||e.anchor?.type==="page"||e.anchor?.type==="shape")?e.anchor:gP(t.y,e.y,n,t.x+t.w/2,e.x)}function kWn(e,t,n,r){let o=r.bleed?.x??0,i=r.bleed?.top??0,a=4-o,s=Math.max(a+QNe,r.width+o-4),l=Yo(t,QNe,s-a);return{left:Yo(e,a,s-l),width:l,y:Yo(n,12-i,Math.max(12-i,r.height-12))}}function DJo(e){return Yo(e.props.apexX??e.props.w/2,0,e.props.w)}var QNe,SWn,xJo,YCt,vJo,SJo,wJo,FJo,CJo,QCt=X(()=>{"use strict";"use client";Pn();un();My();jh();Ly();wNe();SNe();bte();Tye();QNe=48,SWn=9,xJo=36,YCt=42,vJo=8,SJo=36,wJo=20,FJo=24,CJo=18});import{useState as kJo}from"react";import{Fragment as n9e,jsx as mf,jsxs as Fj}from"react/jsx-runtime";function IJo(e,t){return e.state==="page"?{title:t("anchor.noneTitle"),body:t("anchor.noneBody")}:e.state==="shape"?{title:t("anchor.shapeTitle"),body:t("anchor.shapeBody")}:e.state==="missing"?{title:t("anchor.missingTitle"),body:t("anchor.missingBody")}:{title:e.below?t("anchor.belowTitle"):t("anchor.aboveTitle"),body:t("anchor.belowBody")}}function PJo(e,t){return t(e==="block"?"anchor.moveBody":e==="shape"?"anchor.connectShapeToBody":e==="missing"?"anchor.relink":"anchor.connectToBody")}function PWn({indicators:e,onAnchorPointerDown:t,arrangement:n=null}){let r=We("shape"),[o,i]=kJo(null);return mf(n9e,{children:e.map(a=>{let s=a.dragging||o===a.shape.id,l=IJo(a,r),c=`overlay-anchor-tip-${a.shape.id.replace(/[^A-Za-z0-9_-]/g,"-")}`,u=["overlay-anchor-handle",`state-${a.state}`,a.dragging?"dragging":"",a.below?"":"above"].filter(Boolean).join(" ");return Fj(Gd,{arrangement:n,y:a.rule.y,children:[s&&a.targetRect&&a.targetRect.height>0&&mf("div",{className:`overlay-anchor-target${a.dragging?" dragging":""}`,style:{left:a.targetRect.left,top:a.targetRect.top,width:a.targetRect.width,height:a.targetRect.height}}),a.leader&&s&&mf(MJo,{leader:a.leader,state:a.state}),Fj("button",{type:"button",className:u,style:{left:a.rule.left,top:a.rule.y,width:a.rule.width,"--overlay-anchor-grip-x":`${a.gripX-a.rule.left}px`},"data-overlay-anchor-handle":"","data-overlay-shape-id":a.shape.id,"data-anchor-block-id":a.blockId,"data-anchor-state":a.state,"aria-label":PJo(a.state,r),"aria-describedby":c,onBlur:()=>i(d=>d===a.shape.id?null:d),onFocus:()=>i(a.shape.id),onMouseEnter:()=>i(a.shape.id),onMouseLeave:()=>i(d=>d===a.shape.id?null:d),onPointerDown:d=>t(d,a.shape,{x:a.gripX,y:a.rule.y}),children:[mf("span",{className:"overlay-anchor-rule","aria-hidden":"true"}),mf("span",{className:"overlay-anchor-grip","aria-hidden":"true",children:mf(aue,{size:12,strokeWidth:2.4})}),Fj("span",{id:c,className:"overlay-anchor-tip",role:"tooltip",children:[mf("span",{className:"overlay-anchor-tip-title",children:l.title}),mf("span",{className:"overlay-anchor-tip-body",children:l.body})]})]})]},`anchor-handle-${a.shape.id}`)})})}function MJo({leader:e,state:t}){let n=Math.min(e.x1,e.x2)-4,r=Math.min(e.y1,e.y2)-4,o=Math.abs(e.x2-e.x1)+8,i=Math.abs(e.y2-e.y1)+8,a=e.x1-n,s=e.x2-n,l=e.y1-r,c=e.y2-r,u=(l+c)/2;return Fj("svg",{className:`overlay-anchor-leader state-${t}`,style:{left:n,top:r,width:o,height:i},viewBox:`0 0 ${o} ${i}`,"aria-hidden":"true",children:[mf("path",{d:`M ${a} ${l} V ${u} H ${s} V ${c}`}),mf("circle",{cx:s,cy:c,r:2.5})]})}function MWn({shapes:e,allShapes:t,bounds:n,resizable:r,rotatable:o,cropShape:i,dragTranslate:a,movingShapeIds:s,onResizePointerDown:l,onImageCropResizePointerDown:c,onRotatePointerDown:u,onPointPointerDown:d,onLineInsertPointerDown:p,solidEdge:f,solidHoverEdge:m}){let h=e.length===1?e[0]:null,g=h?Oi(h):0,y=h&&g?IWn(h,n):void 0,b=h?e9e(h):!1,x=Lnn(Bnn(e),n),v=e.length>1,S=a&&e.every(w=>s?.has(w.id))?a:null,F=FWn(n,b);return Fj(n9e,{children:[v&&e.map(w=>{let C=w.type==="group"?aw([w],t)??A0(w):A0(w),A=Oi(w),T=A?IWn(w,C):void 0,D=s?.has(w.id)?a:null;return mf("div",{className:`overlay-selection-box ${e9e(w)?"point-only":""}`,style:{left:C.x,top:C.y,width:C.w,height:C.h,transform:Lye(A,D),transformOrigin:T},"aria-hidden":"true"},`item-${w.id}`)}),Fj("div",{className:`overlay-selection-box ${b?"point-only":""} ${v?"multi":""} ${i?"image-cropping":""} ${x.grabOutside?"resize-grab-outside":""}`,style:{left:n.x,top:n.y,width:n.w,height:n.h,transform:Lye(g,S),transformOrigin:y,...F},"aria-hidden":"true",children:[!i&&!b&&o&&mf("div",{className:"overlay-rotate-handle",onPointerDown:u,children:mf(zf,{size:12,strokeWidth:2.2})}),h&&!i&&m!==null&&m!==f&&Nc(h)&&mf(ZCt,{shape:h,bounds:n,edge:m,hover:!0}),h&&!i&&f!==null&&Nc(h)&&mf(ZCt,{shape:h,bounds:n,edge:f}),h&&!i&&mf(CWn,{shape:h,bounds:n,onPointPointerDown:d,onLineInsertPointerDown:p}),i&&mf(BJo,{shape:i,bounds:n,onPointerDown:c}),!i&&!b&&r&&mf(n9e,{children:[...x.visible.map(w=>({handle:w,hitOnly:!1})),...x.hitOnly.map(w=>({handle:w,hitOnly:!0}))].map(({handle:w,hitOnly:C})=>mf("div",{className:`overlay-resize-handle ${w} ${C?"hit-only":""}`,style:Ice(w)||x.grabOutside?void 0:BWn(w,n),onPointerDown:A=>l(A,w)},w))})]})]})}function BJo({shape:e,bounds:t,onPointerDown:n}){return Fj(n9e,{children:[Pke.map(r=>mf("div",{className:`overlay-crop-handle ${r}`,style:BWn(r,t),onPointerDown:o=>n(o,e,r)},`crop-${r}`)),Ece.map(r=>mf("div",{className:`overlay-crop-handle ${r}`,onPointerDown:o=>n(o,e,r)},`crop-${r}`))]})}function BWn(e,t){if(e==="n"||e==="s")return{"--overlay-resize-handle-length":`${EWn(t.w)}px`,left:`${t9e(t.w)}px`,right:`${t9e(t.w)}px`};if(e==="e"||e==="w")return{"--overlay-resize-handle-length":`${Math.min(EWn(t.h),Math.max(2,t.w*.4))}px`,"--overlay-resize-handle-thickness":`${Math.min(EJo,Math.max(1,t.w*.1))}px`,top:`${t9e(t.h)}px`,bottom:`${t9e(t.h)}px`}}function t9e(e){return Math.max(0,Math.min(12,(e-12)/2))}function EWn(e){let t=Math.max(8,e-24),n=Math.min(48,t),r=Math.min(12,n);return Math.round(Yo(e*.24,r,n))}function IWn(e,t){return eAt(dl(e),t)}function eAt(e,t){return`${e.x-t.x}px ${e.y-t.y}px`}var EJo,tAt=X(()=>{"use strict";"use client";Pn();gte();un();er();jh();WCt();QCt();vte();EJo=3});function _Wn(e){let t=e.flatMap(s=>s.entries),n=new Map,r=new Map,o=new Map,i=[],a=[];for(let{block:s,isFlowUnit:l}of t)n.set(s.id,s.top),r.set(s.id,s),o.set(s.id,{top:s.top,height:s.height??0}),a.push(s),l&&i.push(s);return i.sort(LWn),a.sort(LWn),{ordered:i,anchorable:a,tops:n,rects:r,extents:o,segments:[...e]}}function LWn(e,t){return e.top-t.top}function OWn(e,t){if(t.length===0)return e;let n=new Map(t.map(s=>[s.id,s])),r=s=>s.map(l=>n.get(l.id)??l),o=new Map(e.tops),i=new Map(e.rects),a=new Map(e.extents);for(let s of t)o.set(s.id,s.top),i.set(s.id,s),a.set(s.id,{top:s.top,height:s.height??0});return{ordered:r(e.ordered),anchorable:r(e.anchorable),tops:o,rects:i,extents:a,segments:e.segments.map(s=>({unitId:s.unitId,entries:s.entries.map(l=>{let c=n.get(l.block.id);return c?{block:c,isFlowUnit:l.isFlowUnit}:l})}))}}function NWn(e,t){if(!e)return!1;let n=e.segments.filter(r=>r.unitId!==null).map(r=>r.unitId);return n.length===t.length&&n.every((r,o)=>r===t[o])}function zWn({dirtyUnitIds:e,fullDirty:t,hasPrevious:n,incrementalEligible:r,unitsChangedSinceMeasure:o,units:i}){if(t||!n||!r)return{kind:"all"};if(e.size===0)return o?{kind:"all"}:{kind:"carry"};let a=new Set;for(let c of i)a.add(c.id);for(let c of e)if(!a.has(c))return{kind:"all"};let s=i.filter(c=>e.has(c.id));if(s.length===1)return{kind:"dirtyUnit",unitId:s[0].id};let l=s[0];return l?{kind:"fromUnit",unitId:l.id}:{kind:"all"}}function UWn(e,t){return!t&&e.every(n=>n.type==="textFlow")}function nAt(e,t){return t!==void 0&&Math.abs(e.top-t.top)<=RWn&&Math.abs((e.height??0)-(t.height??0))<=RWn&&yNe(e,t)}var RWn,HWn,rAt=X(()=>{"use strict";mP();RWn=.05,HWn=40});function Qx(e,t){return{}}function iAt(e,t,n,r,o={}){let i=e.getBoundingClientRect(),a=i.top+n*t,s=o.previous??null,l=s?o.scope??{kind:"all"}:{kind:"all"},c=Array.from(e.querySelectorAll(XWn)),u=c.map(v=>v.getAttribute(oAt)??""),d=NWn(s,u),p=l.kind==="fromUnit"||l.kind==="dirtyUnit"?u.indexOf(l.unitId):-1,f=!d||l.kind==="all"||(l.kind==="fromUnit"||l.kind==="dirtyUnit")&&p<0,m=new Set,h=[],g=!1,y=(v,S,F)=>{let w=v.getAttribute("data-sigma-doc-id")??v.id;if(!w||m.has(w))return;m.add(w);let C=v.getBoundingClientRect();if(c_(v,C)){let O=gNe(s?.rects.get(w)??r?.get(w)?.block);O&&(nAt(O,s?.rects.get(w))||(g=!0),h.push(O),F.push({block:O,isFlowUnit:S}));return}let A=mCt(v,w),T=hP(v),D=(C.top-a)/t+n-T.y,k=(C.left-i.left)/t-T.x,P=C.width/t,I=C.height/t,B=v.closest(".ProseMirror")?.dataset.flowMeasureRevision??"0",M=r?.get(w),L,_=null;M&&M.element===v&&M.contentRevision===B&&M.zoomFactor===t&&Math.abs(M.width-P)<=GWn&&Math.abs(M.height-I)<=GWn?L=M.relLines.map(O=>({index:O.index,top:D+O.top,left:k+(O.left??0),width:O.width,height:O.height})):(Ci("PageCanvasEditor.lineBoxMeasure"),L=lte(v,i,1/t,1/t),T!==CC&&(L=L.map(O=>({...O,top:O.top-T.y,left:(O.left??0)-T.x}))),_={contentRevision:B,element:v,zoomFactor:t,width:P,height:I,relLines:L.map(O=>({index:O.index,top:O.top-D,left:(O.left??k)-k,width:O.width,height:O.height}))});let R={id:w,top:D,left:k,width:P,height:I,lines:L,...A?{containerId:A}:{},...fCt(v,w)?{derived:!0}:{}};_?r?.set(w,{..._,block:R}):M&&(M.block=R),nAt(R,s?.rects.get(w))||(g=!0),h.push(R),F.push({block:R,isFlowUnit:S})},b=(v,S)=>{v.querySelectorAll(VWn).forEach(F=>y(F,!0,S)),v.querySelectorAll(jWn).forEach(F=>y(F,!1,S))},x=[];if(f){let v=new Map,S=w=>{let C=w.closest(XWn)?.getAttribute(oAt)??null,A=v.get(C);if(A)return A;let T=[];return v.set(C,T),T};e.querySelectorAll(VWn).forEach(w=>y(w,!0,S(w))),e.querySelectorAll(jWn).forEach(w=>y(w,!1,S(w)));for(let w of u)x.push({unitId:w,entries:v.get(w)??[]});let F=v.get(null);F&&x.push({unitId:null,entries:F})}else{let v=new Map(s.segments.map(w=>[w.unitId,w])),S=!1;c.forEach((w,C)=>{let A=u[C],T=C===p;if(!(l.kind==="carry"?!1:l.kind==="fromUnit"?C>=p:T||C>p&&S)){let M=v.get(A);if(M){for(let L of M.entries)m.add(L.block.id);x.push(M);return}}let k=[],P=g;b(w,k);let I=v.get(A)?.entries??[],B=k.length!==I.length||k.some((M,L)=>M.block.id!==I[L]?.block.id);B&&(g=!0),T&&(B||g!==P)&&(S=!0),x.push({unitId:A,entries:k})});let F=v.get(null);if(F){for(let w of F.entries)m.add(w.block.id);x.push(F)}}if(r)for(let v of r.keys())m.has(v)||r.delete(v);return s&&!g&&m.size===s.rects.size?OWn(s,h):_Wn(x)}function WWn(e,t,n={}){let r=e.getBoundingClientRect(),o={};return e.querySelectorAll(".sigma-doc-layout-section-block").forEach(i=>{let a=i.getAttribute("data-sigma-doc-id"),s=i.closest(".sigma-doc-box-block");if(!a||o[a]||!s)return;let l=i.getBoundingClientRect(),c=l.top,u=l.bottom;for(;s;){let d=s.getAttribute("data-sigma-doc-id"),p=d?n[d]:void 0;if(p&&p.totalHeight>p.visibleHeight+.5){let f=s.getBoundingClientRect();if(c=Math.max(c,f.top),u=Math.min(u,f.top+p.visibleHeight*t),u<=c)return}s=s.parentElement?.closest(".sigma-doc-box-block")??null}o[a]=LJo({x:(l.left-r.left)/t,y:(c-r.top)/t,width:l.width/t,height:(u-c)/t})}),o}function LJo(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),...typeof e.height=="number"?{height:Math.round(e.height)}:{}}}var GWn,jWn,VWn,oAt,XWn,v_=X(()=>{"use strict";My();kh();rAt();sF();mP();Dn();Dn();GWn=.5,jWn="[data-sigma-doc-id], [data-page-block]",VWn=".ProseMirror > [data-sigma-doc-id], [data-page-block]",oAt="data-flow-unit-id",XWn=`[${oAt}]`});function qWn(e,t,n,r,o=null,i,a){if(!t)return e;let s=o??t.closest(".page-canvas")??t.ownerDocument,{ordered:l}=yP(t,s,n,r,i);return l.length===0?e:xWn(e,l,Qx(e),a)}function KWn(e){return e.map(t=>[t.id,Math.round(t.top*10)/10,t.left===void 0?"":Math.round(t.left*10)/10,t.width===void 0?"":Math.round(t.width*10)/10,t.height===void 0?"":Math.round(t.height*10)/10,t.lines?.map(n=>[n.index,Math.round(n.top*10)/10,Math.round(n.height*10)/10].join("/")).join(",")??"",t.undrawn?"undrawn":""].join(":")).join("|")}var aAt=X(()=>{"use strict";v_();My();Ly()});function YWn(){let e=t=>{sAt={x:t.clientX,y:t.clientY}};return document.addEventListener("pointermove",e,!0),()=>{document.removeEventListener("pointermove",e,!0),Cj()}}function _ye(){return Aj!==null}function $Wn(e,t){requestAnimationFrame(()=>requestAnimationFrame(()=>{Aj===e&&t()}))}function Rye(e,t){let n=e.start??t,r=e.binding?.bounds(n,t)??hD(n,t,{w:64,h:36});Object.assign(e.grid.style,{left:`${r.x}px`,top:`${r.y}px`,width:`${r.w}px`,height:`${r.h}px`}),e.grid.dataset.tablePreviewRows=String(r.rows),e.grid.dataset.tablePreviewColumns=String(r.columns);let o=[`M0.5 0.5H${r.w-.5}V${r.h-.5}H0.5Z`,...Array.from({length:r.columns-1},(i,a)=>`M${(a+1)*r.cellW} 0V${r.h}`),...Array.from({length:r.rows-1},(i,a)=>`M0 ${(a+1)*r.cellH}H${r.w}`)];e.path.setAttribute("d",o.join(" ")),e.root.style.display=""}function ZWn(e){!e.binding||!e.start||!e.end||e.committing||(e.committing=!0,e.binding.freeze(),$Wn(e,()=>{let t=e.binding;if(!t){e.committing=!1;return}try{t.commit(e.start,e.end)}catch(n){throw wte(),n}}))}function JWn(e,t,n,r){Cj();let o=document.createElement("div");Object.assign(o.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"10000"}),o.dataset.tablePlacementPreview="",o.dataset.tablePlacementFeedback="",o.setAttribute("aria-hidden","true");let i=document.createElement("div");i.className="overlay-insert-preview-shape table-grid-placement",Object.assign(i.style,{position:"fixed",zIndex:"10000",pointerEvents:"none"});let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.classList.add("table-grid-placement-lines");let s=document.createElementNS("http://www.w3.org/2000/svg","path");a.append(s);let l=document.createElement("div");l.className="table-placement-hint",l.textContent=t,i.append(a,l),o.append(i),document.body.append(o);let c={id:e,root:o,grid:i,svg:a,path:s,hint:l,start:null,pointerId:null,end:null,binding:null,committing:!1,cancelRequest:n,dispose:()=>{}};Aj=c;let u=g=>g.target instanceof Element&&!!g.target.closest(".page-canvas, .overlay-canvas-editor"),d=g=>{if(!c.end){if(!c.start&&!u(g)){o.style.display="none",delete o.dataset.tablePlacementPreview;return}o.dataset.tablePlacementPreview="",Rye(c,{x:g.clientX,y:g.clientY})}},p=g=>{if(g.button===0){if(c.start&&u(g)){g.preventDefault(),g.stopPropagation();return}if(!u(g)){Cj();return}c.start={x:g.clientX,y:g.clientY},c.pointerId=g.pointerId,c.binding||(g.preventDefault(),g.stopPropagation()),Rye(c,c.start)}},f=g=>{c.start&&(g.preventDefault(),g.stopPropagation(),!(c.end||c.pointerId!==g.pointerId)&&(c.end={x:g.clientX,y:g.clientY,pointerId:g.pointerId,ctrlKey:g.ctrlKey,shiftKey:g.shiftKey},Rye(c,c.end),delete o.dataset.tablePlacementPreview,o.dataset.tablePlacementPending="",Object.assign(a.style,{stroke:"#111827",strokeDasharray:"none",background:"transparent"}),l.style.display="none",c.binding?.freeze(),ZWn(c)))},m=()=>Cj(),h=g=>{g.key==="Escape"&&m()};document.addEventListener("pointermove",d,!0),document.addEventListener("pointerdown",p,!0),document.addEventListener("pointerup",f,!0),document.addEventListener("pointercancel",m,!0),document.addEventListener("keydown",h,!0),window.addEventListener("blur",m),c.dispose=()=>{o.remove(),document.removeEventListener("pointermove",d,!0),document.removeEventListener("pointerdown",p,!0),document.removeEventListener("pointerup",f,!0),document.removeEventListener("pointercancel",m,!0),document.removeEventListener("keydown",h,!0),window.removeEventListener("blur",m)},Rye(c,sAt),$Wn(c,r)}function QWn(e,t){let n=Aj;if(!(!n||n.id!==e))return n.binding=t,n.start&&Rye(n,n.end??sAt),ZWn(n),()=>{n.binding===t&&(n.binding=null)}}function wte(){let e=Aj;Aj=null,e?.dispose()}function Cj(){let e=Aj;wte(),e?.cancelRequest(),e?.binding?.cancel()}var Aj,sAt,Oye=X(()=>{"use strict";Pn();Aj=null,sAt={x:120,y:160}});function lAt(e){return e.open?e:{open:!0,openedBy:"hover"}}function eqn(e){return e.open&&e.openedBy==="click"?r9e:{open:!0,openedBy:"click"}}function o9e(){return r9e}var r9e,tqn=X(()=>{"use strict";r9e={open:!1,openedBy:null}});import{useEffect as Nye,useRef as zye,useState as RJo}from"react";import{Fragment as _Jo,jsx as i9e,jsxs as OJo}from"react/jsx-runtime";function Tj({label:e,testId:t,className:n,hoverAnchorRef:r,onCloseNestedMenus:o,children:i}){let a=zye(null),s=zye(null),l=zye(null),c=zye(()=>{}),u=zye(o),[d,p]=RJo(r9e),f=d.open;Nye(()=>{u.current=o},[o]);let m=()=>{l.current&&(clearTimeout(l.current),l.current=null)},h=()=>{m(),p(o9e()),o()},g=()=>{let b=r?.current??a.current,x=s.current?.closest("[data-toolbar-popover]");return b?.matches(":hover")===!0||x?.matches(":hover")===!0},y=()=>{m(),l.current=setTimeout(()=>{l.current=null,!g()&&(p(o9e()),o())},320)};return Nye(()=>{c.current=y}),Nye(()=>()=>{l.current&&clearTimeout(l.current)},[]),Nye(()=>{let b=r?.current;if(!b)return;let x=()=>{l.current&&clearTimeout(l.current),l.current=null,p(lAt)},v=()=>c.current();return b.addEventListener("mouseenter",x),b.addEventListener("mouseleave",v),()=>{b.removeEventListener("mouseenter",x),b.removeEventListener("mouseleave",v)}},[r]),Nye(()=>{if(!f)return;let b=x=>{x.key!=="Escape"||x.defaultPrevented||(x.target instanceof Element?x.target:null)?.closest("[data-toolbar-popover]")||(x.preventDefault(),x.stopPropagation(),m(),p(o9e()),u.current())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[f]),OJo(_Jo,{children:[i9e(Ur,{ref:a,label:e,tone:"ghost",size:"sm",className:"graph-item-actions-trigger","aria-haspopup":"dialog","aria-expanded":f,"data-open":f?"true":void 0,"data-testid":t,onMouseEnter:()=>{m(),p(lAt)},onMouseLeave:y,onClick:()=>{m();let b=eqn(d);p(b),b.open||o()},children:i9e(fd,{size:15,"aria-hidden":"true"})}),i9e(Wo,{open:f,anchorRef:a,onClose:h,className:`shape-menu graph-item-actions-menu ${n??""}`,role:"dialog",ariaLabel:e,placement:"right",gap:4,zIndex:h1,onMouseEnter:m,onMouseLeave:b=>{let x=b.relatedTarget;x instanceof Element&&x.closest("[data-toolbar-popover]")||y()},children:i9e("div",{ref:s,className:"graph-item-actions-menu-content","data-non-modal-surface":"",onPointerDown:b=>{s.current?.contains(b.target)||b.stopPropagation()},children:i})})]})}var h1,Uye=X(()=>{"use strict";"use client";er();ga();Qb();tqn();h1="var(--z-modal-nested)"});var Sn,Hye=X(()=>{Sn={inspector:"ni",cardGrid:"di",card:"I",addCard:"pe",choicePopover:"Ui",choiceGroupTitle:"ci",choiceGrid:"si",choiceCard:"Oe",choiceThumbnailFrame:"fi",choiceThumbnail:"li",styleRow:"Je",field:"i",checkbox:"Qe",vectorGrid:"Ve",vectorAxisHeading:"pi",vectorRowLabel:"bi",widgetTitle:"mi",widgetSummary:"tr",quickControls:"gi",quickControlGrid:"or",compactFormulaGrid:"ir",objectOverview:"nr",objectThumbnailFrame:"We",objectThumbnail:"xi",objectThumbnailFallback:"ui",memberList:"hi",objectOverviewText:"dr",objectFormula:"vi",detailsPopover:"wi",detailsContent:"yi",fieldset:"G",titleInput:"Ze",parameterName:"ea",expression:"ki",expressionError:"Ur",relationRow:"aa",inequalitySystem:"zi",inequalityBrace:"Mi",compactExpression:"cr",relationSymbol:"Li",slider:"_i",parameterValue:"Si",compactGrid:"Pi",colorField:"sr",colorButton:"be",colorSwatch:"ji",axisColorGrid:"fr",axisStyleControls:"Fi",cardHeaderActions:"Xi",detailsTriggerHidden:"Ci",cardHidden:"ra",viewGroups:"Ti",axisAppearance:"Ki",dimensionStyle:"lr",section2d:"Ai",sectionSummary:"Yi",section2dActions:"qi",sectionStatus:"Bi",axisHint:"Ei",empty:"Di",videoExport:"Ri",videoExportNote:"Ni",videoLabelStage:"Hi",gridCell:"Ii"}});import{Children as zJo,useId as UJo,useLayoutEffect as HJo,useRef as nqn,useState as GJo}from"react";import{jsx as rg,jsxs as Fte}from"react/jsx-runtime";function rE({children:e,className:t=""}){let n=nqn(null);return HJo(()=>{let r=n.current;if(!r)return;let o=()=>{let a=parseFloat(getComputedStyle(r).rowGap)||0;for(let s of r.children){let l=s.firstElementChild;if(!(s instanceof HTMLElement)||!l)continue;let u=`span ${Math.max(1,Math.ceil((l.getBoundingClientRect().height+a)/(1+a)))}`;s.style.gridRowEnd!==u&&(s.style.gridRowEnd=u)}};o();let i=new ResizeObserver(o);i.observe(r);for(let a of r.children)a.firstElementChild&&i.observe(a.firstElementChild);return()=>i.disconnect()},[e]),rg("div",{ref:n,className:`${Sn.cardGrid} ${t}`,"data-graph-card-grid":!0,children:zJo.toArray(e).map((r,o)=>rg("div",{className:Sn.gridCell,children:r},typeof r=="object"&&r&&"key"in r?r.key:o))})}function K2({title:e,count:t,defaultOpen:n=!0,children:r}){let[o,i]=GJo(n),a=UJo();return Fte("section",{className:"editor-settings-accordion",children:[Fte("button",{type:"button",className:"editor-settings-accordion-header","aria-expanded":o,"aria-controls":a,onClick:()=>i(s=>!s),children:[o?rg(ta,{size:14,"aria-hidden":"true"}):rg(tu,{size:14,"aria-hidden":"true"}),rg("span",{className:"editor-settings-accordion-title",children:e}),t!==void 0&&t>0&&rg("span",{className:"editor-settings-accordion-count",children:t})]}),o&&rg(_n,{className:"editor-settings-accordion-body",id:a,gap:"sm",children:r})]})}function SP({label:e,disabled:t=!1,onClick:n}){return Fte("button",{type:"button",className:Sn.addCard,disabled:t,onClick:n,children:[rg(zi,{size:17,"aria-hidden":"true"}),rg("span",{children:e})]})}function Cte({label:e,title:t,summary:n,controls:r,headerAction:o,visibility:i,openDetailsOnCardHover:a=!1,children:s}){let l=We("shape"),c=nqn(null),u=i?.visible===!1;return Fte("div",{ref:c,className:[Sn.card,"graph-curve-editor",u?Sn.cardHidden:""].filter(Boolean).join(" "),children:[Fte(fr,{gap:"sm",justify:"between",children:[rg("div",{className:Sn.widgetTitle,children:t}),Fte(fr,{className:Sn.cardHeaderActions,gap:"xs",children:[o,i&&rg(Ur,{label:l("graph3dUi.displaySection"),tooltip:{label:i.visible?l("graph3dUi.visible"):l("graph3dUi.hidden")},size:"sm",tone:"ghost","aria-pressed":i.visible,onClick:()=>i.onChange(!i.visible),children:i.visible?rg(t4,{size:15,"aria-hidden":"true"}):rg(nue,{size:15,"aria-hidden":"true"})}),rg("span",{className:i?Sn.detailsTriggerHidden:void 0,children:rg(Tj,{label:e,className:Sn.detailsPopover,hoverAnchorRef:a?c:void 0,onCloseNestedMenus:()=>{},children:rg(_n,{className:Sn.detailsContent,gap:"sm",children:s})})})]})]}),n,r&&rg("div",{className:Sn.quickControls,children:r})]})}var a9e=X(()=>{"use strict";"use client";er();Uye();ga();Qc();un();Hye()});import{useCallback as rqn,useEffect as oqn,useRef as Ate,useState as iqn}from"react";import{jsx as Tte}from"react/jsx-runtime";function wP({tex:e,ariaLabel:t,placeholderTex:n,invalid:r=!1,disabled:o=!1,className:i,ariaDescribedBy:a,"data-testid":s,onCommit:l,onInputTex:c}){let u=_m(),[d,p]=iqn(!1),[f,m]=iqn(e),h=Ate(null),g=Ate(!1),y=Ate(e),b=Ate(!1),x=Ate(l),v=Ate(c);oqn(()=>{x.current=l,v.current=c},[l,c]),oqn(()=>{g.current&&!d&&h.current?.focus({preventScroll:!0}),g.current=d},[d]);let S=rqn((A,T)=>{b.current||(b.current=!0,A?x.current(T):v.current?.(y.current),p(!1))},[]),F=rqn(A=>{v.current?.(A)},[]),w=["math-expression-input",r?"is-invalid":null,d?"is-editing":null,i??null].filter(Boolean).join(" "),C=e.trim();return Tte("span",{className:w,children:d?Tte(ivt,{ariaDescribedBy:a,ariaLabel:t,className:"math-expression-input-field",dataTestId:s?`${s}-field`:void 0,invalid:r,locked:o,tex:f,mathEnvironment:u,initialCursorPosition:"end",initialLatexCommandTrigger:null,initialPlaceholderIndex:null,onInput:F,onCancel:()=>S(!1,y.current),onCommit:A=>S(!0,A),onReturnToTextAfter:A=>S(!0,A),onReturnToTextBefore:A=>S(!0,A),onPointerDown:A=>A.stopPropagation(),onMouseDown:A=>A.stopPropagation(),onKeyDown:A=>A.stopPropagation()}):Tte("button",{ref:h,type:"button",className:"math-expression-input-button","aria-label":t,"aria-describedby":a,"data-testid":s,disabled:o,onClick:()=>{b.current=!1,y.current=e,m(e),p(!0)},children:C?Tte(hl,{tex:C,className:"math-expression-input-preview"}):Tte("span",{className:"math-expression-input-placeholder",children:n?Tte(hl,{tex:n}):null})})})}var s9e=X(()=>{"use strict";"use client";hA();Ys()});function VJo(e){let t=e.trim(),n=0,r="atom";for(let o of t){if(o==="("){n+=1;continue}if(o===")"){n=Math.max(0,n-1);continue}if(!(n>0)){if(o==="+"||o==="-")return"sum";(o==="*"||o==="/")&&Dte.product<Dte[r]?r="product":o==="^"&&Dte.power<Dte[r]&&(r="power")}}return r}function Y2(e,t){let n=e.trim();return Dte[VJo(n)]<Dte[t]?`(${n})`:n}function l9e(e){let t=e.trim();for(;;){if(!t.startsWith("(")||!t.endsWith(")"))return t;let n=0;for(let r=0;r<t.length;r+=1)if(t[r]==="(")n+=1;else if(t[r]===")"&&(n-=1,n===0&&r<t.length-1))return t;if(n!==0)return t;t=t.slice(1,-1).trim()}}function kte(e){try{return new c9e(e).convert()}catch{return null}}function FP(e){try{let t=new c9e(e).convert();return t?{expression:t}:{error:"empty"}}catch(t){let n=t instanceof Error?t.message:"";return n.includes('unsupported character "="')?{error:"hasEquals"}:n.includes("unsupported command")?{error:"unsupportedCommand"}:{error:"unparsable"}}}function cqn(e){let t=e.split("=");if(t.length!==2)return null;let n=t[0].trim(),r=t[1].trim();if(!n||!r)return null;let o=kte(n),i=kte(r);return o===null||i===null?null:lqn(i)?{expression:o,tex:`${n}=${r}`}:lqn(o)?{expression:`-${Y2(i,"product")}`,tex:`${n}=${r}`}:{expression:`${o}-${Y2(i,"product")}`,tex:`${n}=${r}`}}function uqn(e){let{segments:t,delimiters:n}=WJo(e.trim(),s=>Object.hasOwn(sqn,s));if(n.length!==1||t.length!==2)return null;let r=t[0].trim(),o=t[1].trim();if(!r||!o)return null;let i=kte(r),a=kte(o);return i===null||a===null?null:{left:i,right:a,leftTex:r,rightTex:o,operator:sqn[n[0]]}}function dqn(e,t,n){return`${dd(e)} ${XJo[t]} ${dd(n)}`}function lqn(e){let t=Number(e);return Number.isFinite(t)&&Math.abs(t)<1e-9}function WJo(e,t){let n=[],r=[],o=0,i="",a=0;for(;a<e.length;){let s=e[a];if(s==="{"||s==="("||s==="["){o+=1,i+=s,a+=1;continue}if(s==="}"||s===")"||s==="]"){o-=1,i+=s,a+=1;continue}if(s==="\\"){let l=/^[a-zA-Z]+/.exec(e.slice(a+1)),c=l?l[0]:e.slice(a+1,a+2);if(c==="left")o+=1;else if(c==="right")o-=1;else if(o===0&&t(c)){n.push(i),r.push(c),i="",a+=1+c.length;continue}i+=e.slice(a,a+1+c.length),a+=1+c.length;continue}if(o===0&&t(s)){n.push(i),r.push(s),i="",a+=1;continue}i+=s,a+=1}return n.push(i),{segments:n,delimiters:r}}var aqn,jJo,Dte,sqn,XJo,c9e,u9e=X(()=>{"use strict";Dn();Dn();aqn={sin:"sin",cos:"cos",tan:"tan",arcsin:"asin",arccos:"acos",arctan:"atan",ln:"ln",log:"log",exp:"exp"},jJo=new Set([",",";","!",":"," ","quad","qquad","displaystyle","textstyle"]),Dte={sum:0,product:1,power:2,atom:3};sqn={le:"<=",leq:"<=",leqq:"<=",leqslant:"<=",ge:">=",geq:">=",geqq:">=",geqslant:">=",lt:"<","<":"<",gt:">",">":">"},XJo={"<=":"\\leqq",">=":"\\geqq","<":"<",">":">"};c9e=class{constructor(t){this.source=t;this.index=0}convert(){let t=this.parseSequence(new Set,new Set);if(this.skipIgnorable(),this.index<this.source.length)throw new Error(`unexpected trailing input at ${this.index}`);return t}parseSequence(t,n){let r="",o=!1;for(;this.skipIgnorable(),!(this.index>=this.source.length);){let i=this.source[this.index];if(t.has(i))break;if(i==="+"||i==="-"){this.index+=1,r+=i,o=!1;continue}if(i==="\u2212"){this.index+=1,r+="-",o=!1;continue}if(i==="*"||i==="/"){this.index+=1,r+=i,o=!1;continue}if(i==="\\"){let s=this.peekCommandName();if(n.has(s))break;if(s==="cdot"||s==="times"){this.consumeCommand(),r+="*",o=!1;continue}if(s==="div"){this.consumeCommand(),r+="/",o=!1;continue}}let a=this.parseFactor();o&&(r+="*"),r+=a,o=!0}if(!r||!o)throw new Error("incomplete expression");return r}parseFactor(){this.skipIgnorable();let t=this.source[this.index];if(t===void 0)throw new Error("unexpected end of input");let n;if(/[0-9.]/.test(t))n=this.readNumber();else if(t==="(")n=this.parseParenGroup();else if(t==="{")this.index+=1,n=Y2(this.parseSequence(new Set(["}"]),new Set),"atom"),this.expectChar("}");else if(t==="|")this.index+=1,n=`abs(${l9e(this.parseSequence(new Set(["|"]),new Set))})`,this.expectChar("|");else if(t==="\u03C0")this.index+=1,n="pi";else if(/[a-zA-Z]/.test(t))this.index+=1,n=t;else if(t==="\\")n=this.parseCommandFactor();else throw new Error(`unsupported character "${t}"`);return this.applyPostfix(n)}parseCommandFactor(){let t=this.peekCommandName();if(this.consumeCommand(),t==="pi")return"pi";if(t==="frac"||t==="dfrac"||t==="tfrac"){let r=this.parseBracedGroup(),o=this.parseBracedGroup();return`${Y2(r,"product")}/${Y2(o,"power")}`}if(t==="sqrt"){if(this.skipIgnorable(),this.source[this.index]==="["){this.index+=1;let o=this.parseSequence(new Set(["]"]),new Set);this.expectChar("]");let i=this.parseBracedGroup(),a=`1/${Y2(o,"power")}`;return`${Y2(i,"atom")}^${Y2(a,"atom")}`}return`sqrt(${this.parseBracedGroup()})`}if(t==="left")return this.parseLeftRightGroup();if(t==="lvert"||t==="vert"){let r=this.parseSequence(new Set,new Set(["rvert","vert"]));return this.expectCommand(new Set(["rvert","vert"])),`abs(${l9e(r)})`}if(t==="mathrm"||t==="mathit"||t==="text"){let r=this.parseBracedRawGroup().trim();if(!/^[a-zA-Z]$/.test(r))throw new Error(`unsupported ${t} content "${r}"`);return r}if(t==="operatorname"){let r=this.parseBracedRawGroup().trim().toLowerCase(),o=aqn[r];if(!o)throw new Error(`unsupported operator "${r}"`);return this.parseFunctionApplication(o)}let n=aqn[t];if(n)return this.parseFunctionApplication(n);throw new Error(`unsupported command "\\${t}"`)}parseFunctionApplication(t){this.skipIgnorable();let n=null;this.source[this.index]==="^"&&(this.index+=1,n=this.parseExponentArgument());let r=this.tryParseParenGroupArgument()??this.parseFunctionArgument(),o=`${t}(${l9e(r)})`;return n===null?o:`${o}^${Y2(n,"atom")}`}tryParseParenGroupArgument(){if(this.skipIgnorable(),this.source[this.index]==="(")return this.parseParenGroup();if(this.source[this.index]==="\\"&&this.peekCommandName()==="left"){let t=this.index;if(this.consumeCommand(),this.skipIgnorable(),this.source[this.index]==="(")return this.parseLeftRightGroup();this.index=t}return null}parseParenGroup(){this.index+=1;let t=this.parseSequence(new Set([")"]),new Set);return this.expectChar(")"),Y2(t,"atom")}parseFunctionArgument(){this.skipIgnorable();let t=this.parseFactor();if(/^[0-9.]/.test(t))for(;;){this.skipIgnorable();let n=this.source[this.index];if(n===void 0||!(/[a-zA-Z(π]/.test(n)||n==="\\"&&!this.isOperatorOrTerminatorCommand()))break;t+=`*${this.parseFactor()}`}return t}isOperatorOrTerminatorCommand(){let t=this.peekCommandName();return t==="cdot"||t==="times"||t==="div"||t==="right"||t==="rvert"||t==="vert"}parseLeftRightGroup(){this.skipIgnorable();let t=this.readDelimiterToken(),n=this.parseSequence(new Set,new Set(["right"]));this.skipIgnorable(),this.expectCommand(new Set(["right"])),this.skipIgnorable();let r=this.readDelimiterToken(),o=t==="|"||t==="lvert"||t==="vert";if(o!==(r==="|"||r==="rvert"||r==="vert"))throw new Error(`mismatched \\left${t} ... \\right${r}`);return o?`abs(${l9e(n)})`:Y2(n,"atom")}readDelimiterToken(){let t=this.source[this.index];if(t==="("||t===")"||t==="["||t==="]"||t==="|"||t===".")return this.index+=1,t;if(t==="\\"){let n=this.peekCommandName();if(n==="{"||n==="}")return this.consumeCommand(),n;if(n==="lvert"||n==="rvert"||n==="vert")return this.consumeCommand(),n}throw new Error(`unsupported delimiter at ${this.index}`)}applyPostfix(t){let n=t;for(;;){this.skipIgnorable();let r=/^(?:\{\s*\}\s*)+(?=\^)/.exec(this.source.slice(this.index));r&&(this.index+=r[0].length);let o=this.source[this.index];if(o==="^"){this.index+=1;let i=this.parseExponentArgument();n=`${Y2(n,"atom")}^${Y2(i,"atom")}`;continue}if(o==="_")throw new Error("subscripts are not supported");return n}}parseExponentArgument(){this.skipIgnorable();let t=this.source[this.index];if(t==="{"){this.index+=1;let n=this.parseSequence(new Set(["}"]),new Set);return this.expectChar("}"),n}if(t!==void 0&&/[0-9]/.test(t))return this.index+=1,t;if(t!==void 0&&/[a-zA-Z]/.test(t))return this.index+=1,t;if(t==="\\"&&this.peekCommandName()==="pi")return this.consumeCommand(),"pi";throw new Error("unsupported exponent")}parseBracedGroup(){this.skipIgnorable(),this.expectChar("{");let t=this.parseSequence(new Set(["}"]),new Set);return this.expectChar("}"),t}parseBracedRawGroup(){this.skipIgnorable(),this.expectChar("{");let t=1,n="";for(;this.index<this.source.length;){let r=this.source[this.index];if(r==="{")t+=1;else if(r==="}"&&(t-=1,t===0))return this.index+=1,n;n+=r,this.index+=1}throw new Error("unterminated group")}readNumber(){let t=/^(?:\d+\.?\d*|\.\d+)/.exec(this.source.slice(this.index));if(!t)throw new Error("invalid number");return this.index+=t[0].length,t[0]}skipIgnorable(){for(;;){let t=this.source[this.index];if(t===void 0)return;if(/\s/.test(t)||t==="~"){this.index+=1;continue}if(t==="\\"){let n=this.peekCommandName();if(jJo.has(n)){this.consumeCommand();continue}}return}}peekCommandName(){if(this.source[this.index]!=="\\")return"";let t=this.source.slice(this.index+1),n=/^[a-zA-Z]+/.exec(t);return n?n[0]:t.slice(0,1)}consumeCommand(){let t=this.peekCommandName();this.index+=1+t.length}expectChar(t){if(this.skipIgnorable(),this.source[this.index]!==t)throw new Error(`expected "${t}" at ${this.index}`);this.index+=1}expectCommand(t){if(this.skipIgnorable(),this.source[this.index]!=="\\"||!t.has(this.peekCommandName()))throw new Error(`expected \\${[...t][0]} at ${this.index}`);this.consumeCommand()}}});import{useEffect as qJo,useLayoutEffect as KJo,useRef as pqn,useState as cAt}from"react";import{jsx as Xm,jsxs as oE}from"react/jsx-runtime";function p9e({parameters:e,onChange:t,onPreview:n}){let r=We("shape"),[o,i]=cAt(null);return oE(rE,{children:[e.map(a=>Xm(YJo,{parameter:a,playing:o===a.id,onPlayingChange:s=>i(s?a.id:null),onChange:t,onPreview:n},a.id)),Xm(SP,{label:r("graph3dUi.addParameter"),onClick:()=>t(a=>{let s=1,l=new Set(a.map(c=>c.name.toLowerCase()));for(;l.has(s===1?"s":`s${s}`);)s+=1;return[...a,{id:rt("graph_parameter"),name:s===1?"s":`s${s}`,value:0,min:-1,max:1,animation:d9e()}]})})]})}function YJo({parameter:e,playing:t,onPlayingChange:n,onChange:r,onPreview:o}){let i=We("shape"),a=pqn({onChange:r,onPreview:o,onPlayingChange:n});KJo(()=>{a.current={onChange:r,onPreview:o,onPlayingChange:n}});let[s,l]=cAt(e.value),[c,u]=cAt(e.value);c!==e.value&&(u(e.value),t||l(e.value));let d=pqn(null);qJo(()=>{if(!t)return;let h=performance.now(),g=0,y=0,b=e.value,x=!0,v=F=>{x&&(x=!1,cancelAnimationFrame(g),F&&a.current.onChange(w=>w.map(C=>C.id===e.id?{...C,value:b}:C)),a.current.onPreview({[e.name]:b},!1))};d.current=v;let S=F=>{if(x){if(F-y>=50&&(b=BB(e,F-h),l(b),a.current.onPreview({[e.name]:b},!0),y=F,e.animation?.loop==="once"&&F-h>=(e.animation.durationMs??4e3))){v(!0),a.current.onPlayingChange(!1);return}g=requestAnimationFrame(S)}};return g=requestAnimationFrame(S),()=>{v(!0),d.current=null}},[t,e.id]);let p=h=>{d.current?.(!1),n(!1),h.value!==void 0&&l(h.value),r(g=>g.map(y=>y.id===e.id?{...y,value:s,...h}:y))},f=s,m=h=>Xm(wP,{ariaLabel:i(h==="min"?"graph3dUi.rangeMin":"graph3dUi.rangeMax"),tex:dd(String(e[h])),onCommit:g=>{let y=FP(g);if("expression"in y)try{let b=Ni(y.expression);if(!Number.isFinite(b))return;let x=h==="min"?b:e.min,v=h==="max"?b:e.max;if(x>v)return;p({min:x,max:v,value:Math.min(v,Math.max(x,f))})}catch{}}});return oE(Cte,{label:i("graph3dFormat.details",{name:e.label||e.name}),title:Xm("strong",{children:e.label||e.name}),headerAction:Xm(Ur,{label:i(t?"graph3dUi.stop":"graph3dUi.play"),tooltip:{label:i(t?"graph3dUi.stopPreviewTooltip":"graph3dUi.playPreviewTooltip")},size:"sm",tone:"ghost",disabled:e.max<=e.min,onClick:()=>{t?d.current?.(!0):l(e.value),n(!t)},children:t?Xm(Sue,{size:14,"aria-hidden":"true"}):Xm(Fue,{size:14,"aria-hidden":"true"})}),summary:oE(fr,{gap:"sm",children:[Xm("input",{className:Sn.slider,type:"range","aria-label":e.label||e.name,min:e.min,max:e.max,step:t?"any":Math.max(.001,Math.abs(e.max-e.min)/200),value:f,onChange:h=>p({value:Number(h.target.value)})}),Xm("output",{className:Sn.parameterValue,children:f.toFixed(2)})]}),children:[oE("label",{className:Sn.field,children:[Xm("span",{children:i("graph3dUi.parameterName")}),Xm("input",{className:Sn.parameterName,value:e.name,onChange:h=>p({name:h.target.value})})]}),oE("div",{className:Sn.relationRow,children:[m("min"),Xm(hl,{tex:`\\leqq ${dd(e.name||"s")} \\leqq`}),m("max")]}),oE("div",{className:Sn.compactGrid,children:[oE("label",{className:Sn.field,children:[Xm("span",{children:i("graph3dUi.seconds")}),Xm("input",{type:"number",min:.1,step:.1,value:(e.animation?.durationMs??4e3)/1e3,onChange:h=>{let g=Number(h.target.value);Number.isFinite(g)&&p({animation:{...e.animation??d9e(),durationMs:Math.max(100,g*1e3)}})}})]}),oE("div",{className:Sn.field,children:[Xm("span",{children:i("graph3dUi.loop")}),Xm(Aa,{value:e.animation?.loop??"pingPong",options:[{value:"pingPong",label:i("graph3dUi.loopPingPong")},{value:"repeat",label:i("graph3dUi.loopRepeat")},{value:"once",label:i("graph3dUi.loopOnce")}],onChange:h=>p({animation:{...e.animation??d9e(),loop:h}})})]})]}),oE("label",{className:Sn.checkbox,children:[Xm("input",{type:"checkbox",checked:e.animation?.playOnPage===!0,onChange:h=>p({animation:{...e.animation??d9e(),playOnPage:h.target.checked}})}),Xm("span",{children:i("graph3dUi.animateOnPage")})]}),oE(Cn,{tone:"danger",size:"sm",onClick:()=>{document.querySelector("[data-graph-settings-panel]")?.focus({preventScroll:!0}),d.current?.(!1),n(!1),r(h=>h.filter(g=>g.id!==e.id))},children:[Xm(Ro,{size:14})," ",i("graph3dUi.deleteParameter")]})]})}var d9e,uAt=X(()=>{"use strict";"use client";er();Pn();s9e();Ys();ga();Qc();Jw();u9e();ai();un();a9e();Hye();d9e=()=>({durationMs:4e3,loop:"pingPong"})});function S_(e){return e.trim().replace(/[\t\n\r\v\f]+/gu,"-")}function f9e(e){let t=/^(.*?)(\.(?:sigma|sigmadoc)\.json|\.[^.]+)$/iu.exec(e);return t&&t[1]?{stem:t[1],extension:t[2]}:{stem:e,extension:""}}var Ete=X(()=>{"use strict"});async function m9e(e,t){t=S_(t);let n=yr()?.file.saveToDownloads;if(n){let r=await $Jo(e);return n({fileName:t,dataBase64:r})}return dAt(e,t),{filePath:null}}function dAt(e,t){let n=URL.createObjectURL(e),r;try{r=document.createElement("a"),r.href=n,r.download=S_(t),r.rel="noopener",document.body.append(r),r.click()}finally{r?.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}}async function mqn(e){await yr()?.file.showInFolder?.(e)}async function $Jo(e){let t=await new Promise((r,o)=>{let i=new FileReader;i.addEventListener("load",()=>{typeof i.result=="string"?r(i.result):o(new Error(fqn("download.fileReadFailed")))},{once:!0}),i.addEventListener("error",()=>o(new Error(fqn("download.fileReadFailed"))),{once:!0}),i.readAsDataURL(e)}),n=t.indexOf(",");return n>=0?t.slice(n+1):""}var fqn,Gye=X(()=>{"use strict";Ete();jc();ho();fqn=Fr("error")});import{jsx as pAt,jsxs as hqn}from"react/jsx-runtime";function h9e({parameters:e,state:t,onExport:n}){let r=We("shape"),o=LB(e),i=t.status==="preparing"||t.status==="recording"||t.status==="saving",a=t.status==="done"?t.filePath:null;return hqn("div",{className:Sn.videoExport,children:[hqn(Cn,{size:"sm",onClick:n,disabled:i||e.length===0,children:[pAt(_ue,{size:14})," ",r("graph3dUi.exportVideo")]}),pAt("span",{className:Sn.videoExportNote,role:"status",children:ZJo(t,e.length,o,r)}),a&&pAt(Cn,{size:"sm",tone:"ghost",onClick:()=>{mqn(a)},children:r("graph3dUi.openFolder")})]})}function ZJo(e,t,n,r){switch(e.status){case"preparing":return r("graph3dUi.exportPreparing");case"recording":return r("graph3dFormat.recording",{progress:Math.round(e.progress*100)});case"saving":return r("graph3dUi.exportSaving");case"done":return e.filePath?r("graph3dFormat.savedPath",{path:e.filePath}):r("graph3dUi.exportDownloaded");case"error":return e.message;default:return t===0?r("graph3d.noAnimatableParameters"):r("graph3dFormat.downloadEstimate",{seconds:(n/1e3).toFixed(1)})}}var fAt=X(()=>{"use strict";"use client";er();Pn();ga();Gye();un();Hye()});import{useEffect as JJo,useRef as QJo,useState as eQo}from"react";import{jsx as tQo}from"react/jsx-runtime";function gqn({spec:e}){let t=We("shape"),n=_m(),[r,o]=eQo({status:"idle"}),i=QJo(null);JJo(()=>()=>{i.current?.abort()},[]);let a=async()=>{if(i.current)return;let s=new AbortController;i.current=s,o({status:"preparing"});try{let l=await abt({spec:e,mathEnvironment:n,signal:s.signal,onProgress:u=>o({status:"recording",progress:u})});s.signal.throwIfAborted(),o({status:"saving"});let c=await m9e(l.blob,t("graphPanel.animationExportName",{extension:l.extension}));s.signal.aborted||o({status:"done",filePath:c.filePath})}catch(l){s.signal.aborted||o({status:"error",message:l instanceof Error?l.message:t("graph3dUi.videoExportFailed")})}finally{i.current===s&&(i.current=null)}};return tQo(h9e,{parameters:P9(e.parameters??[]),state:r,onExport:()=>{a()}})}var yqn=X(()=>{"use strict";"use client";Pn();Ys();Gye();un();fAt()});import{Fragment as nQo,useRef as rQo}from"react";import{jsx as hf,jsxs as Ite}from"react/jsx-runtime";function iE({endpoint:e,label:t,currentValue:n,open:r,disabled:o=!1,popoverZIndex:i,onToggle:a,onSelect:s}){let l=We("chrome"),c=e==="start"?n??"none":"none",u=e==="end"?n??"none":"none",d=t??l(e==="start"?"format.lineEndpoint.start":"format.lineEndpoint.end"),p=yvt.find(g=>g.value===n),f=l(p?`format.lineEndpoint.${p.value}`:"format.mixed"),m=l("format.currentValue",{label:d,value:f}),h=rQo(null);return Ite("div",{className:"shape-menu-anchor",children:[hf(Hd,{buttonRef:h,variant:"lineEndpoint",active:r,tooltip:{label:l("format.lineEndpoint.tooltip",{endpoint:d,value:f})},"aria-label":m,"aria-haspopup":"menu","aria-expanded":r,disabled:o,onClick:a,children:hf(vqn,{start:c,end:u,focus:e})}),Ite(Wo,{open:r,anchorRef:h,onClose:a,className:"shape-menu endpoint-menu",role:"menu",ariaLabel:d,zIndex:i,children:[hf("div",{className:"endpoint-menu-header","aria-hidden":"true",children:d}),hf(bqn,{option:{...q8e,label:l("format.lineEndpoint.none")},endpoint:e,selected:n===q8e.value,withLabel:!0,onSelect:s}),Ite("div",{className:"endpoint-size-grid",role:"none",children:[hf("span",{"aria-hidden":"true"}),W8e.map(({size:g})=>hf("span",{className:"endpoint-size-heading","aria-hidden":"true",children:l(`format.lineEndpoint.size.${g}`)},g)),gvt.map(g=>Ite(nQo,{children:[hf("span",{className:"endpoint-shape-label","aria-hidden":"true",children:l(`format.lineEndpoint.${g.values.normal}`)}),W8e.map(({size:y})=>{let b=g.values[y];return hf(bqn,{option:{value:b,label:l(`format.lineEndpoint.${b}`)},endpoint:e,selected:n===b,onSelect:s},y)})]},g.values.normal))]})]})]})}function bqn({option:e,endpoint:t,selected:n,withLabel:r=!1,onSelect:o}){return Ite("button",{type:"button",role:"menuitemradio","aria-label":e.label,"aria-checked":n,className:`${r?"endpoint-menu-row":"endpoint-menu-cell"}${n?" selected":""}`,onClick:()=>o(e.value),children:[r&&hf("span",{className:"endpoint-menu-check","aria-hidden":"true",children:n?hf(bi,{size:14}):null}),hf(vqn,{start:t==="start"?e.value:"none",end:t==="end"?e.value:"none",focus:t,size:"menu"}),r&&hf("span",{children:e.label})]})}function vqn({start:e,end:t,focus:n,size:r="toolbar"}){let o=n==="start"&&e==="none",i=n==="end"&&t==="none",a=r==="menu"?{width:64,height:24,startX:9,endX:55,y:12,markerScale:1.5,cueRadius:2.5}:{width:32,height:16,startX:7,endX:25,y:8,markerScale:.85,cueRadius:1.7},s=Ple(e)*a.markerScale,l=Ple(t)*a.markerScale;return Ite("svg",{className:`line-endpoint-preview line-endpoint-preview-${r}`,viewBox:`0 0 ${a.width} ${a.height}`,width:a.width,height:a.height,"aria-hidden":"true",children:[hf("line",{x1:a.startX+s,y1:a.y,x2:a.endX-l,y2:a.y}),o?hf("circle",{className:"endpoint-side-cue",cx:a.startX,cy:a.y,r:a.cueRadius}):null,i?hf("circle",{className:"endpoint-side-cue",cx:a.endX,cy:a.y,r:a.cueRadius}):null,hf(xqn,{kind:e,x:a.startX,y:a.y,direction:"start",scale:a.markerScale}),hf(xqn,{kind:t,x:a.endX,y:a.y,direction:"end",scale:a.markerScale})]})}function xqn({kind:e,x:t,y:n,direction:r,scale:o}){let i=S0(e);if(!i)return null;let a=VTe(i,o,r==="start"&&i.reversibleOrient);return a.kind==="circle"?hf("circle",{cx:t+a.cx,cy:n+a.cy,r:a.r}):hf("path",{className:a.filled?"endpoint-mark-filled":void 0,d:yD({...a,points:a.points.map(s=>({x:t+s.x,y:n+s.y}))})})}function g9e(){return hf("span",{className:"boxed-text-icon","aria-hidden":"true",children:"A"})}function y9e({variant:e}){return hf("span",{className:`boxed-text-style-preview boxed-text-style-preview-${e}`,"aria-hidden":"true",children:"A"})}function Sqn(e){return`${e.trim().replace(/[<>:"/\\|?*\u0000-\u001F]/g,"_").slice(0,DLn).trim()||"lesson"}.pdf`}var Dj=X(()=>{"use strict";er();Qk();un();Qb();Dn();Ap()});var wqn,Fqn,Cqn,Aqn=X(()=>{"use strict";wqn=[{id:"functions",templates:[{id:"sin",label:"sin",tex:"\\sin #?"},{id:"cos",label:"cos",tex:"\\cos #?"},{id:"tan",label:"tan",tex:"\\tan #?"},{id:"sin-power",label:"sin power",tex:"\\sin^{#?} #?"},{id:"log-base",label:"log base",tex:"\\log_{#?} #?"},{id:"function",label:"f(x)",tex:"f\\left(#?\\right)"}]},{id:"sigma-limit",templates:[{id:"sum",label:"sum",tex:"\\sum_{#?}^{#?} #?"},{id:"integral",label:"integral",tex:"\\int #?"},{id:"definite-integral",label:"definite integral",tex:"\\int_{#?}^{#?} #?"},{id:"limit",label:"limit",tex:"\\lim_{#?\\to#?}"},{id:"arg",label:"arg",tex:"\\arg #?"},{id:"mod",label:"mod",tex:"\\bmod #?"}]},{id:"combinatorics",templates:[{id:"combination",label:"nCr",tex:"_{#?}\\mathrm{C}_{#?}"},{id:"permutation",label:"nPr",tex:"_{#?}\\mathrm{P}_{#?}"},{id:"repeated-combination",label:"nHr",tex:"_{#?}\\mathrm{H}_{#?}"},{id:"binomial-coefficient",label:"binomial coefficient",tex:"\\binom{#?}{#?}"},{id:"factorial",label:"factorial",tex:"#?!"}]},{id:"arrows",templates:[{id:"to",label:"to",tex:"\\to"},{id:"leftarrow",label:"left arrow",tex:"\\leftarrow"},{id:"leftrightarrow",label:"left right arrow",tex:"\\leftrightarrow"},{id:"implies",label:"implies",tex:"\\Rightarrow"},{id:"iff",label:"iff",tex:"\\Leftrightarrow"},{id:"tex-iff",label:"iff command",tex:"\\iff"}]},{id:"scripts",templates:[{id:"superscript",label:"superscript",tex:"{#?}^{#?}"},{id:"subscript",label:"subscript",tex:"{#?}_{#?}"},{id:"subscript-superscript",label:"subscript superscript",tex:"{#?}_{#?}^{#?}"},{id:"superscript-subscript",label:"superscript subscript",tex:"{#?}^{#?}_{#?}"}]},{id:"fractions-roots",templates:[{id:"fraction",label:"fraction",tex:"\\frac{#?}{#?}"},{id:"sqrt",label:"square root",tex:"\\sqrt{#?}"},{id:"nth-root",label:"nth root",tex:"\\sqrt[#?]{#?}"}]},{id:"brackets",templates:[{id:"parentheses",label:"parentheses",tex:"\\left(#?\\right)"},{id:"braces",label:"braces",tex:"\\left\\{#?\\right\\}"},{id:"brackets",label:"brackets",tex:"\\left[#?\\right]"},{id:"absolute-value",label:"absolute value",tex:"\\left|#?\\right|"}]},{id:"matrices",templates:[{id:"matrix-2x2",label:"2 by 2 matrix",tex:"\\begin{pmatrix}#?&#?\\\\#?&#?\\end{pmatrix}"},{id:"vector-2",label:"2 vector",tex:"\\begin{pmatrix}#?\\\\#?\\end{pmatrix}"},{id:"cases-2",label:"2 cases",tex:"\\begin{cases}#?\\\\#?\\end{cases}"}]},{id:"accents",templates:[{id:"vector-accent",label:"vector",tex:"\\vv{#?}"},{id:"overline",label:"overline",tex:"\\overline{#?}"},{id:"hat",label:"hat",tex:"\\hat{#?}"},{id:"dot",label:"dot",tex:"\\dot{#?}"}]},{id:"exponential-log",templates:[{id:"exp",label:"exp",tex:"\\exp #?"},{id:"ln",label:"ln",tex:"\\ln #?"},{id:"lg",label:"lg",tex:"\\operatorname{lg} #?"}]},{id:"inverse-trig",templates:[{id:"sin-inverse-power",label:"sin inverse power",tex:"\\sin^{-1} #?"},{id:"cos-inverse-power",label:"cos inverse power",tex:"\\cos^{-1} #?"},{id:"tan-inverse-power",label:"tan inverse power",tex:"\\tan^{-1} #?"},{id:"sin-inverse",label:"Sin inverse",tex:"\\operatorname{Sin}^{-1} #?"},{id:"cos-inverse",label:"Cos inverse",tex:"\\operatorname{Cos}^{-1} #?"},{id:"tan-inverse",label:"Tan inverse",tex:"\\operatorname{Tan}^{-1} #?"},{id:"arcsin",label:"arcsin",tex:"\\arcsin #?"},{id:"arccos",label:"arccos",tex:"\\arccos #?"},{id:"arctan",label:"arctan",tex:"\\arctan #?"},{id:"Arcsin",label:"Arcsin",tex:"\\operatorname{Arcsin} #?"},{id:"Arccos",label:"Arccos",tex:"\\operatorname{Arccos} #?"},{id:"Arctan",label:"Arctan",tex:"\\operatorname{Arctan} #?"}]},{id:"hyperbolic",templates:[{id:"sinh",label:"sinh",tex:"\\sinh #?"},{id:"cosh",label:"cosh",tex:"\\cosh #?"},{id:"tanh",label:"tanh",tex:"\\tanh #?"},{id:"sinh-power",label:"sinh power",tex:"\\sinh^{#?} #?"},{id:"cosh-power",label:"cosh power",tex:"\\cosh^{#?} #?"},{id:"tanh-power",label:"tanh power",tex:"\\tanh^{#?} #?"}]},{id:"sets-products",templates:[{id:"sum-indexed",label:"indexed sum",tex:"\\sum_{#?} #?"},{id:"product-indexed",label:"indexed product",tex:"\\prod_{#?} #?"},{id:"coproduct-indexed",label:"indexed coproduct",tex:"\\coprod_{#?} #?"},{id:"bigcup-indexed",label:"indexed union",tex:"\\bigcup_{#?} #?"},{id:"cup-indexed",label:"union",tex:"\\cup_{#?} #?"},{id:"bigcap-indexed",label:"indexed intersection",tex:"\\bigcap_{#?} #?"},{id:"cap-indexed",label:"intersection",tex:"\\cap_{#?} #?"},{id:"bigoplus-indexed",label:"indexed direct sum",tex:"\\bigoplus_{#?} #?"},{id:"oplus-indexed",label:"direct sum",tex:"\\oplus_{#?} #?"}]},{id:"integrals",templates:[{id:"integral-with-differential",label:"integral with differential",tex:"\\int #?\\,d#?"},{id:"double-integral",label:"double integral",tex:"\\iint #?\\,d#?"},{id:"triple-integral",label:"triple integral",tex:"\\iiint #?\\,d#?"},{id:"contour-integral",label:"contour integral",tex:"\\oint #?\\,d#?"}]},{id:"max-min",templates:[{id:"max",label:"max",tex:"\\max #?"},{id:"min",label:"min",tex:"\\min #?"},{id:"max-under",label:"max with condition",tex:"\\max_{#?} #?"},{id:"min-under",label:"min with condition",tex:"\\min_{#?} #?"}]},{id:"sup-inf",templates:[{id:"sup",label:"sup",tex:"\\sup #?"},{id:"inf",label:"inf",tex:"\\inf #?"},{id:"sup-under",label:"sup with condition",tex:"\\sup_{#?} #?"},{id:"inf-under",label:"inf with condition",tex:"\\inf_{#?} #?"}]},{id:"limit-variants",templates:[{id:"limsup-overline",label:"overline limit",tex:"\\overline{\\lim}_{#?\\to#?} #?"},{id:"limit-to",label:"limit to",tex:"\\lim_{#?\\to#?} #?"},{id:"limsup",label:"limsup",tex:"\\limsup_{#?\\to#?} #?"},{id:"liminf",label:"liminf",tex:"\\liminf_{#?\\to#?} #?"}]},{id:"linear-algebra",templates:[{id:"det",label:"det",tex:"\\det #?"},{id:"sgn",label:"sgn",tex:"\\operatorname{sgn} #?"},{id:"rank",label:"rank",tex:"\\operatorname{rank} #?"},{id:"dim",label:"dim",tex:"\\dim #?"},{id:"tr",label:"tr",tex:"\\operatorname{tr} #?"},{id:"Tr",label:"Tr",tex:"\\operatorname{Tr} #?"},{id:"Ker",label:"Ker",tex:"\\operatorname{Ker} #?"},{id:"Im",label:"Im",tex:"\\operatorname{Im} #?"}]}],Fqn=new Set(["exponential-log","inverse-trig","hyperbolic","sets-products","integrals","max-min","sup-inf","limit-variants","linear-algebra"]),Cqn=[...wqn.filter(e=>!Fqn.has(e.id)),...wqn.filter(e=>Fqn.has(e.id))]});function Mqn(e){e=$p(e);let t=e.curves.filter(a=>Rh(a.mode)!=="implicit");if(t.length<2)return[];let n;try{n=F2(e)}catch{return[]}let r=[];for(let a=0;a<t.length-1;a+=1)for(let s=a+1;s<t.length;s+=1){let l=t[a],c=t[s];try{let u=Rh(l.mode),d=Rh(c.mode);r.push(...u==="yOfX"&&d==="yOfX"?pQo(l,c,n):fQo(l,c,e,n))}catch{}}let o=hQo(r,n).filter(a=>b9e(a,n)),i=(e.points??[]).map(a=>bJ(a)).filter(a=>a!==null);return o.filter(a=>!i.some(s=>Math.hypot(a.x-s.x,a.y-s.y)<=iQo)).sort((a,s)=>a.x-s.x||a.y-s.y)}function uQo(e,t,n){if(!Number.isFinite(t.min)||!Number.isFinite(t.max)||t.min>t.max)return[];let r=[],o=null,i=null,a=null,s=0,l=0,c=!1,u=()=>{i&&(r.push(i.value),i=null)};for(let d=0;d<=Tqn;d+=1){let p=t.min+(t.max-t.min)*d/Tqn,f;try{f=e(p)}catch{u(),o=null;continue}if(!Number.isFinite(f)){u(),o=null;continue}if(s+=1,(!a||Math.abs(f)<Math.abs(a.delta))&&(a={value:p,delta:f}),Math.abs(f)<=n)l+=1,(!i||Math.abs(f)<Math.abs(i.delta))&&(i={value:p,delta:f});else if(o&&o.delta*f<0){u(),c=!0;try{r.push(dQo(e,o.value,p,n))}catch{}}else u();o={value:p,delta:f}}return u(),s>0&&s===l?[]:(!c&&r.length===0&&a&&Math.abs(a.delta)<=n&&r.push(a.value),gQo(r,n))}function dQo(e,t,n,r){let o=Math.min(t,n),i=Math.max(t,n),a=e(o),s=e(i),l=Math.min(Math.max(Math.abs(r),Number.EPSILON),oQo);if(!Number.isFinite(a)||!Number.isFinite(s))throw new Error("Root interval produced a non-finite value");if(a===0)return o;if(s===0)return i;if(a*s>0)throw new Error("Root interval does not contain a sign change");for(let c=0;c<64;c+=1){let u=(o+i)/2,d=e(u);if(!Number.isFinite(d))throw new Error("Root refinement produced a non-finite value");if(d===0)return u;a*d<=0?(i=u,s=d):(o=u,a=d);let p=Number.EPSILON*Math.max(1,Math.abs(o),Math.abs(i));if(i-o<=Math.max(l,p))break}return(o+i)/2}function pQo(e,t,n){let r=rA(e,"yOfX",n),o=rA(t,"yOfX",n);if(!r||!o)return[];let i={min:Math.max(r.min,o.min),max:Math.min(r.max,o.max)};if(i.min>i.max)return[];if(i.min===i.max)try{let s=wc(e.expr,i.min,"x"),l=wc(t.expr,i.min,"x");if(Math.abs(s-l)>TA*4)return[];let c={x:i.min,y:(s+l)/2};return b9e(c,n)?[c]:[]}catch{return[]}return uQo(s=>wc(e.expr,s,"x")-wc(t.expr,s,"x"),i,TA).flatMap(s=>{try{let l=wc(e.expr,s,"x"),c=wc(t.expr,s,"x");if(Math.abs(l-c)>TA*4)return[];let u={x:s,y:(l+c)/2};return b9e(u,n)?[u]:[]}catch{return[]}})}function fQo(e,t,n,r){let o;try{o=X0(n)}catch{return[]}let i=qs(n),a=j6e(e,n,o,r,i),s=j6e(t,n,o,r,i),l=[];for(let c of a)for(let u of s)try{let d=tbt(c,u);if(!d)continue;let p=yJ(d.point.x,d.point.y,o,n,i);if(!b9e(p,r))continue;let f=mQo(e,t,p,r);f&&l.push(f)}catch{}return l}function mQo(e,t,n,r){let o=Dqn(e,n,r),i=Dqn(t,n,r);if(!o||!i)return null;let a=o.value,s=i.value;for(let u=0;u<cQo;u+=1){let d=kj(e,a),p=kj(t,s),f=d.x-p.x,m=d.y-p.y;if(Math.hypot(f,m)<TA)return Pqn(d,p);let h=kqn(e,a,o.range),g=kqn(t,s,i.range),y=h.x,b=-g.x,x=h.y,v=-g.y,S=y*v-b*x;if(Math.abs(S)<1e-12)break;let F=(-f*v+b*m)/S,w=(-y*m+f*x)/S;a=Iqn(a+Eqn(F,o.range),o.range),s=Iqn(s+Eqn(w,i.range),i.range)}let l=kj(e,a),c=kj(t,s);return Math.hypot(l.x-c.x,l.y-c.y)<TA*4?Pqn(l,c):null}function Dqn(e,t,n){let r=Rh(e.mode),o=rA(e,r,n);if(!o)return null;let i=yQo(e.samples??aQo,sQo,lQo),a=Math.max(TA,n.xMax-n.xMin),s=Math.max(TA,n.yMax-n.yMin),l=null;for(let c=0;c<=i;c+=1){let u=o.min+(o.max-o.min)*c/i;try{let d=kj(e,u),p=((d.x-t.x)/a)**2+((d.y-t.y)/s)**2;(!l||p<l.distance)&&(l={value:u,distance:p})}catch{}}return l?{value:l.value,range:o}:null}function kj(e,t){let n=Rh(e.mode);if(n==="parametric"){let o=e.yExpr?.trim();if(!o)throw new Error("Parametric curve requires a y expression");return{x:wc(e.expr,t,"t"),y:wc(o,t,"t")}}let r=wc(e.expr,t,n==="xOfY"?"y":"x");return n==="xOfY"?{x:r,y:t}:{x:t,y:r}}function kqn(e,t,n){let r=Math.max((n.max-n.min)*1e-5,1e-7),o=Math.max(n.min,t-r),i=Math.min(n.max,t+r);if(i<=o)throw new Error("Curve derivative range is empty");let a=kj(e,o),s=kj(e,i);return{x:(s.x-a.x)/(i-o),y:(s.y-a.y)/(i-o)}}function Eqn(e,t){let n=(t.max-t.min)/4;return Math.max(-n,Math.min(n,e))}function Iqn(e,t){return Math.max(t.min,Math.min(t.max,e))}function Pqn(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function b9e(e,t){return e.x>=t.xMin-TA&&e.x<=t.xMax+TA&&e.y>=t.yMin-TA&&e.y<=t.yMax+TA}function hQo(e,t){let n=t.xMax-t.xMin,r=t.yMax-t.yMin,o=n>0?Math.max(1,1/n):mAt,i=r>0?Math.max(1,1/r):mAt,a=new Map;for(let s of e){if(!Number.isFinite(s.x)||!Number.isFinite(s.y))continue;let l=`${Math.round(s.x*o)}:${Math.round(s.y*i)}`;a.has(l)||a.set(l,s)}return[...a.values()]}function gQo(e,t){return[...e].sort((n,r)=>n-r).filter((n,r,o)=>r===0||Math.abs(n-o[r-1])>t)}function yQo(e,t,n){return Math.max(t,Math.min(n,Math.round(e)))}var TA,oQo,mAt,iQo,Tqn,aQo,sQo,lQo,cQo,Bqn=X(()=>{"use strict";Dn();Bme();Ak();TA=1e-6,oQo=1e-10,mAt=1e3,iQo=1/mAt,Tqn=512,aQo=220,sQo=32,lQo=360,cQo=12});import{useEffect as Pte,useId as bQo,useMemo as Lqn,useRef as CP,useState as Ej}from"react";import{Fragment as v9e,jsx as zt,jsxs as Ar}from"react/jsx-runtime";function xQo(e,t){let n=0,r=e.replace(/#\?/g,()=>(n+=1,`\\placeholder[${n}]{\\square}`));return A2(r,t)}function Rqn(e,t){let n=(e.tex.match(/#\?/g)??[]).length;return n===0?e.label:t("math.templateHint",{replace:{name:e.label,slots:n}})}function vQo(e,t){return Number.isFinite(e)?Math.min(Math.max(Math.round(e),0),t.length):t.length}function SQo(e,t){let n=e.match(/未許可のTeXコマンド (.+) があります。$/)?.[1];return n?t("tex.disallowedCommand",{replace:{command:n}}):t("tex.cannotRender")}function wQo(){let e=We("shape"),[t,n]=g8e();return Ar("div",{className:"inline-math-input-mode-row",role:"group","aria-label":e("math.inputMode"),children:[zt("button",{type:"button",className:t==="tex"?"selected":"","aria-pressed":t==="tex",onClick:()=>n("tex"),children:"TeX"}),zt("button",{type:"button",className:t==="mathlive"?"selected":"","aria-pressed":t==="mathlive",onClick:()=>n("mathlive"),children:e("math.realtimeInput")})]})}function Nqn({onInsertTemplate:e,selectedInlineMath:t}){let n=We("shape"),r=_m(),o=t?vQo(t.cursor,t.tex):0,i=a=>{if(qxt(a))return;if(!t){e?.(a);return}let s=QTn(t.tex,o,a);t.updateTex(s.tex,s.cursor)};return Ar("div",{className:"editor-settings-section",children:[zt(wQo,{}),t||e?zt("div",{className:"inline-math-template-palette","aria-label":n("math.templates"),children:Cqn.map(a=>Ar("section",{className:"inline-math-template-group",children:[zt("h3",{children:n(`mathTemplateGroup.${a.id}`)}),zt("div",{className:"inline-math-template-row",children:a.templates.map(s=>zt("button",{type:"button",className:"inline-math-template-button",title:Rqn(s,n),"aria-label":Rqn(s,n),onMouseDown:l=>l.preventDefault(),onClick:()=>i(s.tex),dangerouslySetInnerHTML:{__html:xQo(s.tex,r)}},s.id))})]},a.id))}):null,t?hH(t.tex,t.id).map((a,s)=>zt("p",{className:"inline-error",children:SQo(a,n)},`${a}-${s}`)):null]})}function CQo(e){return[{value:"solid",label:e("format.lineDash.solid")},{value:"dashed",label:e("format.lineDash.dashed"),dasharray:"8 5"},{value:"dotted",label:e("format.lineDash.dotted"),dasharray:"1 5"}]}function AQo(e){return P3n.map(t=>({value:String(t.value),label:e(`graphStrokeWidth.${t.id}`),strokeWidth:t.value}))}function DQo(e){let t=new Set(e.map(n=>n.label).filter(n=>!!n));if(!t.has("P"))return"P";for(let n=2;;n+=1){let r=`P_${n}`;if(!t.has(r))return r}}function zqn({selectedOverlayGraph:e}){let{spec:t,axisLabelShapeIdsByKey:n,axisLabelTextsByKey:r,formulaLabelShapeIdsByCurveId:o,pickingOrigin:i,pickingFill:a,onSpecChange:s,onAxisLabelChange:l,onAxisLabelTextChange:c,onFormulaLabelChange:u,onStartCrop:d,onStartOriginPick:p,onStartFillPick:f}=e,m=CP(t);Pte(()=>{m.current=t},[t]);let h=We("shape"),g=Lqn(()=>d6e(t,e.shapeId),[e.shapeId,t]),y=Lqn(()=>p6e(t),[t]),b=[...g.map(re=>c6e(re,h)),...y.map(re=>u6e(re,h))],[x,v]=Ej(null),[S,F]=Ej(null),w=CP(null),[C,A]=Ej(!1),T=CP(null),[D,k]=Ej(a);D!==a&&(k(a),A(!1)),Pte(()=>(Xyt(e.shapeId,!0),()=>Xyt(e.shapeId,!1)),[e.shapeId]);let P=t.axes.tickFontSize??9;Pte(()=>()=>{w.current&&clearTimeout(w.current)},[]),Pte(()=>{let re=le=>{(le instanceof CustomEvent?le.detail:null)?.shapeId===e.shapeId&&(A(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>A(!1),5e3))};return window.addEventListener(x9e,re),()=>window.removeEventListener(x9e,re)},[e.shapeId]),Pte(()=>()=>{T.current&&clearTimeout(T.current)},[]);let I=a&&C?h("graph.fillUnresolved"):"",B=I||(i?h("graph.pickOriginHint"):"")||(a?h("graph.pickFillHint"):""),M=re=>{let le=re(m.current);m.current=le,s(le)},L=(re,le)=>{M(Q=>({...Q,curves:Q.curves.map(se=>se.id===re?{...se,...le}:se)}))},_=(re,le)=>{M(Q=>({...Q,curves:Q.curves.map(se=>{if(se.id!==re)return se;let De={...se};return!le||le.min===void 0&&le.max===void 0?(delete De.domain,De):(De.domain={...le.min!==void 0?{min:le.min}:{},...le.max!==void 0?{max:le.max}:{}},De)})}))},R=(re,le)=>{let Q=NQo(re,le);L(re.id,Q)},O=(re,le)=>{M(Q=>({...Q,viewBox:{...Q.viewBox,...re==="x"?{xMin:le.min??Q.viewBox.xMin,xMax:le.max??Q.viewBox.xMax}:{yMin:le.min??Q.viewBox.yMin,yMax:le.max??Q.viewBox.yMax}}}))},N=(re,le)=>{M(Q=>{let se=Q.graphViewBox??Q.viewBox;return{...Q,graphViewBox:{...se,...re==="x"?{xMin:le.min??se.xMin,xMax:le.max??se.xMax}:{yMin:le.min??se.yMin,yMax:le.max??se.yMax}}}})},z=(re,le)=>{M(Q=>({...Q,axes:{...Q.axes,...re==="x"?{xTickStep:le??""}:{yTickStep:le??""}}}))},U=re=>{M(le=>{if(re){let Q={...le};return delete Q.graphViewBox,Q}return{...le,graphViewBox:{...le.viewBox}}})},H=()=>{M(re=>({...re,curves:[...re.curves,V3n(re.curves.length)]}))},V=re=>{M(le=>({...le,curves:le.curves.filter(Q=>Q.id!==re)}))},ne=()=>{M(re=>({...re,points:[...re.points??[],Syt(re.points?.length??0)]}))},Z=()=>{let re=m.current,le=Mqn(re);if(le.length===0){w.current&&clearTimeout(w.current),F("noIntersection"),w.current=setTimeout(()=>{F(null),w.current=null},2e3);return}w.current&&(clearTimeout(w.current),w.current=null),F(null);let Q=[...re.points??[]],se=le.map(De=>{let Ae=V0(De.x),ye=V0(De.y),$e={...Syt(Q.length),x:Ae,y:ye,xTex:dd(Ae),yTex:dd(ye),label:DQo(Q)};return Q.push($e),$e});M(De=>({...De,points:[...De.points??[],...se]}))},ee=(re,le)=>{M(Q=>({...Q,points:(Q.points??[]).map(se=>se.id===re?{...se,...le}:se)}))},J=re=>{M(le=>{let Q=(le.points??[]).filter(se=>se.id!==re);if(Q.length===0){let se={...le};return delete se.points,se}return{...le,points:Q}})},te=(re,le)=>{M(Q=>({...Q,fills:(Q.fills??[]).map(se=>se.id===re?{...se,...le}:se)}))},K=re=>{M(le=>{let Q=(le.fills??[]).filter(se=>se.id!==re);if(Q.length===0){let se={...le};return delete se.fills,se}return{...le,fills:Q}})},G=re=>n[re]?!0:re==="x"?!!t.axes.xLabel?.trim():re==="y"?!!t.axes.yLabel?.trim():!!t.axes.originLabel?.trim(),ie=(re,le)=>{l(re,le)},fe=re=>{let le=r[re];return le!==void 0?le:re==="x"?t.axes.xLabel?.trim()||"x":re==="y"?t.axes.yLabel?.trim()||"y":t.axes.originLabel?.trim()||I3n},$=t.graphViewBox??t.viewBox,j=t.curves.filter(re=>{let le=Rh(re.mode);return le==="yOfX"||le==="xOfY"||le==="parametric"}),pe=[{key:"x",label:"x",textLabel:"x",disabled:t.axes.showX===!1},{key:"y",label:"y",textLabel:"y",disabled:t.kind!=="cartesian"||t.axes.showY===!1},{key:"origin",label:h("graph.origin"),textLabel:h("graph.origin"),disabled:t.axes.showX===!1||t.kind==="cartesian"&&t.axes.showY===!1}];return zt(Kp,{className:"editor-settings-section overlay-graph-inspector",space:"md",children:Ar(_n,{gap:"none",children:[Ar(fr,{className:"graph-tool-row",gap:"xs",role:"group","aria-label":h("graph.toolsAria"),children:[zt(Ur,{label:h("graph.pickOrigin"),tooltip:{label:h("graph.pickOriginTooltip")},tone:"secondary",className:`graph-tool-button ${i?"active":""}`,"aria-pressed":i,onClick:p,"data-testid":"overlay-graph-origin-button",children:zt(e4,{size:15,"aria-hidden":"true"})}),zt(Ur,{label:h("graph.fillArea"),title:t.kind==="cartesian"?void 0:h("graph.fillCartesianOnlyTooltip"),tooltip:t.kind==="cartesian"?{label:h("graph.fillTooltip")}:void 0,tone:"secondary",className:`graph-tool-button ${a?"active":""}`,"aria-pressed":a,disabled:t.kind!=="cartesian",onClick:f,"data-testid":"overlay-graph-fill-button",children:zt(mw,{size:15,"aria-hidden":"true"})}),zt(Ur,{label:h("graph.trim"),tooltip:{label:h("graph.trimTooltip")},tone:"secondary",className:"graph-tool-button",onClick:d,"data-testid":"overlay-graph-crop-button",children:zt(PC,{size:15,"aria-hidden":"true"})})]}),zt("div",{className:"graph-mode-status",role:"status","data-empty":B?void 0:"true","data-tone":I?"warning":"info","data-testid":"overlay-graph-mode-status",children:B}),Ar(K2,{title:h("graph3dUi.parametersSection"),count:t.parameters?.length??0,children:[zt(p9e,{parameters:t.parameters??[],onChange:re=>M(le=>({...le,parameters:re(le.parameters??[])})),onPreview:(re,le)=>Q5n({shapeId:e.shapeId,overrides:re,playing:le})},e.shapeId),zt(gqn,{spec:t},e.shapeId)]}),zt(K2,{title:h("graph.curve"),count:t.curves.length,defaultOpen:!0,children:Ar(rE,{className:"graph-curve-list",children:[t.curves.map((re,le)=>zt(IQo,{curve:re,index:le,graphViewBox:$,formulaLabelVisible:!!o[re.id],openStyleMenu:x,onOpenStyleMenuChange:v,onFormulaLabelToggle:Q=>u(re.id,Q),onPatch:Q=>L(re.id,Q),onModeChange:Q=>R(re,Q),onDomainCommit:Q=>_(re.id,Q),onRemove:()=>V(re.id)},re.id)),zt(SP,{label:h("graph.addCurve"),onClick:H})]})}),Ar(K2,{title:h("graph.point"),count:(t.points??[]).length,defaultOpen:!0,children:[Ar(rE,{className:"graph-curve-list",children:[(t.points??[]).map((re,le)=>zt(BQo,{point:re,index:le,cartesian:t.kind==="cartesian",openStyleMenu:x,onOpenStyleMenuChange:v,onPatch:Q=>ee(re.id,Q),onRemove:()=>J(re.id)},re.id)),zt(SP,{label:h("graph.addPoint"),onClick:ne})]}),j.length>=2&&zt(Cn,{tone:"ghost",size:"sm",className:"graph-find-intersections-button",onClick:Z,"aria-label":h("graph.addIntersection"),children:h("graph.addIntersection")}),S&&zt("div",{className:"intersection-message",role:"status",children:h(`graph.${S}`)})]}),(t.fills??[]).length>0&&zt(K2,{title:h("graph.fill"),count:(t.fills??[]).length,defaultOpen:!0,children:zt(rE,{className:"graph-curve-list",children:(t.fills??[]).map((re,le)=>zt(RQo,{fill:re,index:le,openStyleMenu:x,onOpenStyleMenuChange:v,onPatch:Q=>te(re.id,Q),onRemove:()=>K(re.id)},re.id))})}),Ar(K2,{title:h("graph.displayRange"),defaultOpen:!1,children:[zt("label",{className:"field-label",children:h("graph.axisRangeLabel")}),Ar(_n,{className:"graph-range-input-grid",gap:"sm",children:[zt(jye,{min:t.viewBox.xMin,max:t.viewBox.xMax,variableName:"x",requireBoth:!0,ariaLabel:h("graph.xAxisRange"),dataTestId:"overlay-graph-x-range",onCommitRange:re=>re&&O("x",re)}),t.kind==="cartesian"&&zt(jye,{min:t.viewBox.yMin,max:t.viewBox.yMax,variableName:"y",requireBoth:!0,ariaLabel:h("graph.yAxisRange"),dataTestId:"overlay-graph-y-range",onCommitRange:re=>re&&O("y",re)})]}),Ar(fr,{className:"graph-range-heading",gap:"sm",justify:"between",children:[zt("label",{className:"field-label",children:h("graph.graphRangeLabel")}),Ar("label",{className:"checkbox-field",children:[zt("input",{type:"checkbox",checked:!t.graphViewBox,onChange:re=>U(re.target.checked)}),zt("span",{children:h("graph.sameAsAxisRange")})]})]}),t.graphViewBox&&Ar(_n,{className:"graph-range-input-grid",gap:"sm",children:[zt(jye,{min:$.xMin,max:$.xMax,variableName:"x",requireBoth:!0,ariaLabel:h("graph.xDisplayRange"),dataTestId:"overlay-graph-display-x-range",onCommitRange:re=>re&&N("x",re)}),t.kind==="cartesian"&&zt(jye,{min:$.yMin,max:$.yMax,variableName:"y",requireBoth:!0,ariaLabel:h("graph.yDisplayRange"),dataTestId:"overlay-graph-display-y-range",onCommitRange:re=>re&&N("y",re)})]}),zt("label",{className:"field-label",children:h("graph.tickStepLabel")}),Ar(cp,{className:"graph-range-input-grid halves",columns:2,gap:"sm",responsive:!1,children:[Ar(_n,{className:"graph-style-field",gap:"xs",children:[zt("span",{children:"x"}),zt(aE,{tex:t.axes.xTickStep?.trim()?dd(t.axes.xTickStep):"",ariaLabel:h("graph.xTickStep"),placeholderTex:"1",allowEmpty:!0,dataTestId:"overlay-graph-x-tick-step",onCommitExpression:re=>z("x",re),onClear:()=>z("x",null)})]}),Ar(_n,{className:"graph-style-field",gap:"xs",children:[zt("span",{children:"y"}),zt(aE,{tex:t.axes.yTickStep?.trim()?dd(t.axes.yTickStep):"",ariaLabel:h("graph.yTickStep"),placeholderTex:"1",allowEmpty:!0,dataTestId:"overlay-graph-y-tick-step",onCommitExpression:re=>z("y",re),onClear:()=>z("y",null)})]})]}),zt(OQo,{value:P,onCommit:re=>{M(le=>({...le,axes:{...le.axes,tickFontSize:re}}))}},P),zt("label",{className:"field-label",children:h("graph.axisVisibility")}),Ar(cp,{className:"graph-checkbox-grid",columns:2,gap:"sm",responsive:!1,children:[Ar("label",{className:"checkbox-field",children:[zt("input",{type:"checkbox",checked:t.axes.showX!==!1,onChange:re=>{let le=re.target.checked;M(Q=>({...Q,axes:{...Q.axes,showX:le}}))}}),zt("span",{children:h("graph.xAxis")})]}),Ar("label",{className:"checkbox-field",children:[zt("input",{type:"checkbox",checked:t.axes.showY!==!1&&t.kind==="cartesian",disabled:t.kind!=="cartesian",onChange:re=>{let le=re.target.checked;M(Q=>({...Q,axes:{...Q.axes,showY:le}}))}}),zt("span",{children:h("graph.yAxis")})]}),Ar("label",{className:"checkbox-field",children:[zt("input",{type:"checkbox",checked:t.axes.showTicks!==!1,onChange:re=>{let le=re.target.checked;M(Q=>({...Q,axes:{...Q.axes,showTicks:le}}))}}),zt("span",{children:h("graph.ticks")})]}),Ar("label",{className:"checkbox-field",children:[zt("input",{type:"checkbox",checked:t.axes.grid,onChange:re=>{let le=re.target.checked;M(Q=>({...Q,axes:{...Q.axes,grid:le}}))}}),zt("span",{children:h("graph.grid")})]})]}),zt("label",{className:"field-label",children:h("graph.axisEnd")}),zt(cp,{className:"graph-checkbox-grid",columns:2,gap:"sm",responsive:!1,children:[{axis:"x",name:h("graph.xAxis"),label:h("graph.xAxisEnd"),value:t.axes.xAxisEndStyle,drawn:t.axes.showX!==!1},{axis:"y",name:h("graph.yAxis"),label:h("graph.yAxisEnd"),value:t.axes.yAxisEndStyle,drawn:t.kind==="cartesian"&&t.axes.showY!==!1}].map(({axis:re,name:le,label:Q,value:se,drawn:De})=>{let Ae=TQo[re],ye=re==="x"?"xAxisEndStyle":"yAxisEndStyle";return Ar(fr,{className:"graph-style-field",gap:"sm",align:"center",children:[zt("span",{children:le}),zt(iE,{endpoint:"end",label:Q,currentValue:se??Tle,open:x===Ae,disabled:!De,popoverZIndex:h1,onToggle:()=>v($e=>$e===Ae?null:Ae),onSelect:$e=>{M(Pe=>({...Pe,axes:{...Pe.axes,[ye]:$e}})),v(null)}})]},re)})})]}),zt(K2,{title:h("graph.axisName"),defaultOpen:!1,children:zt(_n,{className:"graph-axis-label-list",gap:"sm",children:pe.map(({key:re,label:le,textLabel:Q,disabled:se})=>{let De=G(re);return Ar(fr,{className:"graph-axis-label-row",gap:"sm",align:"center",children:[Ar("label",{className:"checkbox-field graph-axis-label-toggle",children:[zt("input",{type:"checkbox",checked:De,disabled:se,"data-testid":`overlay-graph-axis-label-${re}`,onChange:Ae=>ie(re,Ae.target.checked)}),zt("span",{children:le})]}),zt(wP,{tex:fe(re),disabled:se||!De,ariaLabel:re==="origin"?h("graph.originLabelName"):h("graph.axisNameOf",{replace:{axis:Q}}),"data-testid":`overlay-graph-axis-label-text-${re}`,onCommit:Ae=>c(re,Ae.trim())})]},re)})})}),b.map((re,le)=>zt("p",{className:"graph-settings-message",children:re},`${re}-${le}`)),y.length>0&&zt(Cn,{tone:"secondary","data-testid":"overlay-graph-fit-view-box",onClick:()=>M(U3n),children:h("graph.fitToCurves")})]})})}function kQo({curve:e,label:t,menuKeyPrefix:n,openStyleMenu:r,onOpenStyleMenuChange:o,onPatch:i,popoverZIndex:a=h1,testIdPrefix:s}){let l=We("shape"),c=We("chrome"),u=CP(null),d=CP(null),p=C2(e.color),f=Sme(e.dash),m=BH(e.strokeWidth),h=`${n}-color`,g=`${n}-dash`,y=`${n}-width`;return Ar(v9e,{children:[zt(bAt,{label:l("graphStyle.colorOf",{target:t}),value:p,menuKey:h,openStyleMenu:r,onOpenStyleMenuChange:o,onChange:b=>i({color:b}),popoverZIndex:a,"data-testid":s?`${s}-color-select`:void 0}),zt("span",{className:"graph-style-menu","data-testid":s?`${s}-dash-select`:void 0,children:zt(aF,{buttonRef:u,options:CQo(c),currentValue:f,open:r===g,onToggle:()=>o(r===g?null:g),onSelect:b=>{i({dash:b}),o(null)},popoverZIndex:a})}),zt("span",{className:"graph-style-menu","data-testid":s?`${s}-stroke-width-select`:void 0,children:zt(eE,{buttonRef:d,options:AQo(l),currentValue:String(m),open:r===y,onToggle:()=>o(r===y?null:y),onSelect:b=>{i({strokeWidth:Number(b)}),o(null)},popoverZIndex:a})})]})}function yAt(){typeof document>"u"||document.querySelector("[data-graph-settings-panel]")?.focus({preventScroll:!0})}function EQo({curve:e,index:t,formulaLabelVisible:n,openStyleMenu:r,onOpenStyleMenuChange:o,onFormulaLabelToggle:i,onPatch:a,onRemove:s}){let l=We("shape");return Ar(v9e,{children:[zt("div",{className:"graph-item-style-row",role:"group","aria-label":l("graph.curveLineStyle",{index:t+1}),children:zt(kQo,{curve:e,label:l("graph.curveN",{index:t+1}),menuKeyPrefix:`curve-${e.id}`,openStyleMenu:r,onOpenStyleMenuChange:o,onPatch:a,testIdPrefix:t===0?"overlay-graph":void 0})}),zt("div",{className:"graph-item-actions-separator",role:"separator"}),Ar("button",{type:"button","aria-pressed":n,onClick:()=>i(!n),children:[zt(ND,{size:13,"aria-hidden":"true"}),zt("span",{children:l("graph.toggleFormula",{action:l(n?"graph.hide":"graph.show")})})]}),Ar(Cn,{tone:"danger",size:"sm","aria-label":l("graph.curveDelete",{index:t+1}),onClick:()=>{yAt(),s()},children:[zt(Ro,{size:14,"aria-hidden":"true"}),zt("span",{children:l("graph.deleteCurve")})]})]})}function IQo({curve:e,index:t,graphViewBox:n,formulaLabelVisible:r,openStyleMenu:o,onOpenStyleMenuChange:i,onFormulaLabelToggle:a,onPatch:s,onModeChange:l,onDomainCommit:c,onRemove:u}){let d=We("shape"),p=Rh(e.mode),f=p==="parametric"?"t":p==="xOfY"?"y":"x",m=CB(e),h=Rle(e),g=p==="parametric"?gJ:{min:p==="xOfY"?n.yMin:n.xMin,max:p==="xOfY"?n.yMax:n.xMax},y=p!=="yOfX"||!!e.domain?.min?.trim()||!!e.domain?.max?.trim(),b=(v,S)=>{s({expr:v,exprTex:S,label:p==="parametric"?LH("parametric",S,h):LH(p,S)})},x=(v,S)=>{s({yExpr:v,yExprTex:S,label:LH("parametric",m,S)})};return zt(Kp,{className:"graph-curve-editor",space:"sm",children:Ar(_n,{gap:"sm",children:[Ar(fr,{className:"graph-curve-header",gap:"sm",justify:"between",children:[Ar(fr,{className:"graph-curve-heading",gap:"xs",children:[zt("span",{className:"graph-curve-style-summary",style:{borderTopColor:C2(e.color),borderTopStyle:Sme(e.dash)==="solid"?"solid":Sme(e.dash),borderTopWidth:Math.max(1,BH(e.strokeWidth))},"aria-hidden":"true"}),zt("span",{className:"graph-curve-title",children:d("graph.curveN",{index:t+1})})]}),zt(fr,{className:"graph-curve-header-actions",gap:"xs",children:zt(Tj,{label:d("graph.curveActions",{index:t+1}),testId:t===0?"overlay-graph-curve-actions":void 0,onCloseNestedMenus:()=>i(null),children:zt(EQo,{curve:e,index:t,formulaLabelVisible:r,openStyleMenu:o,onOpenStyleMenuChange:i,onFormulaLabelToggle:a,onPatch:s,onRemove:u})})})]}),p==="parametric"?Ar(_n,{className:"graph-function-rows",gap:"sm",children:[Ar(fr,{className:"graph-function-row",gap:"sm",children:[zt(hl,{tex:"x=",className:"graph-function-prefix"}),zt(aE,{tex:m,ariaLabel:d("graph.curveXtExpr",{index:t+1}),dataTestId:t===0?"overlay-graph-expr-input":void 0,live:!0,onCommitExpression:b})]}),Ar(fr,{className:"graph-function-row",gap:"sm",children:[zt(hl,{tex:"y=",className:"graph-function-prefix"}),zt(aE,{tex:h,ariaLabel:d("graph.curveYtExpr",{index:t+1}),dataTestId:t===0?"overlay-graph-y-expr-input":void 0,live:!0,onCommitExpression:x})]})]}):p==="implicit"?zt(fr,{className:"graph-function-row",gap:"sm",children:zt(aE,{tex:m,ariaLabel:d("graph.curveImplicitExpr",{index:t+1}),dataTestId:t===0?"overlay-graph-expr-input":void 0,allowImplicitEquation:!0,live:!0,onCommitExpression:b})}):Ar(fr,{className:"graph-function-row",gap:"sm",children:[zt(hl,{tex:p==="xOfY"?"x=":"y=",className:"graph-function-prefix"}),zt(aE,{tex:m,ariaLabel:d("graph.curveExpr",{index:t+1}),dataTestId:t===0?"overlay-graph-expr-input":void 0,live:!0,onCommitExpression:b})]}),zt(uP,{label:d("graph.curveAdvanced",{index:t+1}),defaultOpen:y,className:"graph-card-detail",children:Ar(cp,{className:"graph-curve-select-grid",columns:2,gap:"sm",responsive:!1,children:[Ar(_n,{className:"graph-style-field",gap:"xs",children:[zt("span",{children:d("graph.direction")}),zt(PQo,{value:p,menuKey:`curve-mode-${e.id}`,openStyleMenu:o,onOpenStyleMenuChange:i,"data-testid":t===0?"overlay-graph-mode-select":void 0,onChange:l})]}),Ar(_n,{className:"graph-style-field",gap:"xs",children:[zt("span",{children:d(p==="parametric"?"graph.tRange":p==="implicit"?"graph.xRange":"graph.domain")}),zt(jye,{min:e.domain?.min,max:e.domain?.max,variableName:f,allowEmpty:!0,ariaLabel:d("graph.curveDomain",{index:t+1}),minPlaceholderTex:dd(g.min),maxPlaceholderTex:dd(g.max),dataTestId:t===0?"overlay-graph-domain-input":void 0,onCommitRange:c})]})]})})]})})}function PQo({value:e,menuKey:t,openStyleMenu:n,onOpenStyleMenuChange:r,onChange:o,"data-testid":i}){let a=We("shape"),s=CP(null),l=n===t,c=pyt.find(u=>u.value===e)??{label:"y=f(x)",value:"yOfX"};return Ar("div",{className:"graph-mode-control",children:[Ar("button",{ref:s,type:"button",className:`graph-mode-button ${l?"active":""}`,"aria-label":a("graph.curveModeCurrent",{mode:c.label}),"aria-haspopup":"dialog","aria-expanded":l,"data-testid":i,onClick:()=>r(l?null:t),children:[zt(hl,{tex:_qn(e),className:"graph-mode-preview"}),zt(ta,{size:12,"aria-hidden":"true"})]}),zt(Wo,{open:l,anchorRef:s,onClose:()=>r(null),className:"shape-menu graph-mode-menu",ariaLabel:a("graph.curveModeAria"),zIndex:h1,children:pyt.map(u=>zt("button",{type:"button",className:u.value===e?"active":"","aria-label":u.label,onClick:()=>{o(u.value),r(null)},children:zt(hl,{tex:_qn(u.value),className:"graph-mode-preview"})},u.value))})]})}function _qn(e){return e==="xOfY"?"x=f(y)":e==="parametric"?"x=f(t),\\ y=g(t)":e==="implicit"?"F(x,y)=c":"y=f(x)"}function MQo({point:e,index:t,cartesian:n,openStyleMenu:r,onOpenStyleMenuChange:o,onPatch:i,onRemove:a}){let s=We("shape"),l=e.fill==="none"?"none":"solid",c=C2(e.color);return Ar(v9e,{children:[Ar("div",{className:"graph-fill-action-grid",children:[Ar("div",{className:"graph-item-action-field",children:[zt("span",{children:s("graph.color")}),zt(bAt,{label:s("graph.pointColor",{index:t+1}),value:c,menuKey:`point-color-${e.id}`,openStyleMenu:r,onOpenStyleMenuChange:o,onChange:u=>i({color:u})})]}),Ar("div",{className:"graph-item-action-field",children:[zt("span",{children:s("graph.pointShapeLabel")}),Ar(fr,{className:"graph-segmented",gap:"xs",role:"group","aria-label":s("graph.pointShape",{index:t+1}),"data-testid":t===0?"overlay-graph-point-fill":void 0,children:[zt("button",{type:"button","aria-label":s("graph.pointFilled"),"aria-pressed":l==="solid",className:l==="solid"?"selected":"",onClick:()=>i({fill:"solid"}),children:zt("span",{className:"graph-point-fill-swatch solid","aria-hidden":"true"})}),zt("button",{type:"button","aria-label":s("graph.pointHollow"),"aria-pressed":l==="none",className:l==="none"?"selected":"",onClick:()=>i({fill:"none"}),children:zt("span",{className:"graph-point-fill-swatch open","aria-hidden":"true"})})]})]})]}),Ar("label",{className:"graph-item-number-field",children:[zt("span",{children:s("graph.radius")}),zt("input",{className:"mono-input",type:"number",min:"1.5",max:"12",step:"0.1",value:e.radius??"",onChange:u=>{let d=Number.parseFloat(u.target.value);i({radius:Number.isFinite(d)?d:void 0})},"aria-label":s("graph.pointRadius",{index:t+1})})]}),Ar("div",{className:"graph-item-checkboxes",children:[Ar("label",{className:"checkbox-field",children:[zt("input",{type:"checkbox",checked:e.showXProjection===!0,"data-testid":t===0?"overlay-graph-point-x-projection":void 0,onChange:u=>i({showXProjection:u.target.checked})}),zt("span",{children:s("graph.dropToX")})]}),Ar("label",{className:"checkbox-field",children:[zt("input",{type:"checkbox",checked:e.showYProjection===!0,"data-testid":t===0?"overlay-graph-point-y-projection":void 0,disabled:!n,onChange:u=>i({showYProjection:u.target.checked})}),zt("span",{children:s("graph.dropToY")})]})]}),zt("div",{className:"graph-item-actions-separator",role:"separator"}),Ar(Cn,{tone:"danger",size:"sm","aria-label":s("graph.pointDelete",{index:t+1}),onClick:()=>{yAt(),a()},children:[zt(Ro,{size:14,"aria-hidden":"true"}),zt("span",{children:s("graph.deletePoint")})]})]})}function BQo({point:e,index:t,cartesian:n,openStyleMenu:r,onOpenStyleMenuChange:o,onPatch:i,onRemove:a}){let s=We("shape"),l=C2(e.color);return zt(Kp,{className:"graph-curve-editor",space:"sm",children:Ar(_n,{gap:"sm",children:[Ar(fr,{className:"graph-curve-header",gap:"sm",justify:"between",children:[Ar(fr,{className:"graph-curve-heading",gap:"xs",children:[zt("span",{className:"graph-point-style-summary","data-fill":e.fill==="none"?"none":"solid",style:{borderColor:l,background:e.fill==="none"?"var(--background)":l},"aria-hidden":"true"}),zt("span",{className:"graph-curve-title",children:s("graph.pointN",{index:t+1})})]}),zt(fr,{className:"graph-curve-header-actions",gap:"xs",children:zt(Tj,{label:s("graph.pointActions",{index:t+1}),testId:t===0?"overlay-graph-point-actions":void 0,onCloseNestedMenus:()=>o(null),children:zt(MQo,{point:e,index:t,cartesian:n,openStyleMenu:r,onOpenStyleMenuChange:o,onPatch:i,onRemove:a})})})]}),Ar(_n,{className:"graph-style-field",gap:"xs",children:[zt("span",{children:s("graph.coordinates")}),Ar(cp,{className:"graph-coordinate-pair",columns:2,gap:"sm",responsive:!1,children:[Ar("label",{className:"graph-coordinate-field",children:[zt(hl,{tex:"x:"}),zt(aE,{tex:e.xTex?.trim()||dd(e.x),ariaLabel:s("graph.pointX",{index:t+1}),placeholderTex:"1",live:!0,dataTestId:t===0?"overlay-graph-point-x-input":void 0,onCommitExpression:(c,u)=>i({x:c,xTex:u})})]}),Ar("label",{className:"graph-coordinate-field",children:[zt(hl,{tex:"y:"}),zt(aE,{tex:e.yTex?.trim()||dd(e.y),ariaLabel:s("graph.pointY",{index:t+1}),placeholderTex:"2",live:!0,dataTestId:t===0?"overlay-graph-point-y-input":void 0,onCommitExpression:(c,u)=>i({y:c,yTex:u})})]})]})]}),Ar(_n,{className:"graph-style-field",gap:"xs",children:[zt("span",{children:s("graph.name")}),zt(wP,{tex:e.label??"",ariaLabel:s("graph.pointName",{index:t+1}),"data-testid":t===0?"overlay-graph-point-label":void 0,onCommit:c=>i({label:c.trim()})})]})]})})}function LQo({fill:e,index:t,openStyleMenu:n,onOpenStyleMenuChange:r,onPatch:o,onRemove:i}){let a=We("shape"),s=C2(e.color,oK);return Ar(v9e,{children:[Ar("div",{className:"graph-fill-action-grid",children:[Ar("label",{className:"graph-item-action-field",children:[zt("span",{children:a("graph.color")}),zt(bAt,{label:a("graph.fillColor",{index:t+1}),value:s,menuKey:`fill-color-${e.id}`,openStyleMenu:n,onOpenStyleMenuChange:r,onChange:l=>o({color:l}),"data-testid":t===0?"overlay-graph-fill-color-select":void 0})]}),Ar("label",{className:"graph-item-action-field",children:[zt("span",{children:a("graph.fillPatternLabel")}),zt(_Qo,{value:t9(e.pattern),color:s,menuKey:`fill-pattern-${e.id}`,openStyleMenu:n,onOpenStyleMenuChange:r,onChange:l=>o({pattern:l}),"data-testid":t===0?"overlay-graph-fill-pattern-select":void 0})]})]}),Ar("label",{className:"graph-item-opacity-field",children:[zt("span",{children:a("graph.opacity")}),zt("input",{type:"range",min:"0",max:"1",step:"0.01",value:n9(e.opacity),"aria-label":a("graph.fillOpacity",{index:t+1}),onChange:l=>o({opacity:Number(l.target.value)})}),Ar("output",{children:[Math.round(n9(e.opacity)*100),"%"]})]}),zt("div",{className:"graph-item-actions-separator",role:"separator"}),Ar(Cn,{tone:"danger",size:"sm","aria-label":a("graph.fillDelete",{index:t+1}),onClick:()=>{yAt(),i()},children:[zt(Ro,{size:14,"aria-hidden":"true"}),zt("span",{children:a("graph.deleteFill")})]})]})}function RQo({fill:e,index:t,openStyleMenu:n,onOpenStyleMenuChange:r,onPatch:o,onRemove:i}){let a=We("shape"),s=C2(e.color,oK),l=t9(e.pattern),c=a(`graphFill.${l}`);return zt(Kp,{className:"graph-curve-editor graph-fill-editor",space:"sm",children:Ar(fr,{className:"graph-curve-header",gap:"sm",justify:"between",children:[Ar(fr,{className:"graph-fill-heading",gap:"sm",children:[zt("span",{className:"graph-fill-swatch",style:gAt(l,s),"aria-hidden":"true"}),zt("span",{className:"graph-curve-title",children:a("graph.fillN",{index:t+1})}),zt("span",{className:"graph-fill-summary",children:a("graph.fillSummary",{pattern:c,percent:Math.round(n9(e.opacity)*100)})})]}),zt(Tj,{label:a("graph.fillActions",{index:t+1}),testId:t===0?"overlay-graph-fill-actions":void 0,onCloseNestedMenus:()=>r(null),children:zt(LQo,{fill:e,index:t,openStyleMenu:n,onOpenStyleMenuChange:r,onPatch:o,onRemove:i})})]})})}function _Qo({value:e,color:t,menuKey:n,openStyleMenu:r,onOpenStyleMenuChange:o,onChange:i,"data-testid":a}){let s=CP(null),l=r===n,c=We("shape"),u=iK.find(p=>p.value===e)??iK[0],d=c(`graphFill.${u.value}`);return Ar("div",{className:"shape-menu-anchor graph-fill-pattern-control",children:[Ar("button",{ref:s,type:"button",className:`graph-fill-pattern-button ${l?"active":""}`,"aria-label":c("graphFill.currentAria",{pattern:d}),"aria-haspopup":"menu","aria-expanded":l,"data-testid":a,onClick:()=>o(l?null:n),children:[zt("span",{className:"graph-fill-swatch",style:gAt(e,t),"aria-hidden":"true"}),zt("span",{children:d}),zt(ta,{size:12,"aria-hidden":"true"})]}),zt(Wo,{open:l,anchorRef:s,onClose:()=>o(null),className:"shape-menu graph-fill-pattern-menu",role:"menu",ariaLabel:c("graphFill.menuAria"),zIndex:h1,children:iK.map(p=>Ar("button",{type:"button",role:"menuitemradio","aria-checked":p.value===e,className:p.value===e?"selected":"",onClick:()=>{i(p.value),o(null)},children:[zt("span",{className:"graph-fill-swatch",style:gAt(p.value,t),"aria-hidden":"true"}),zt("span",{children:c(`graphFill.${p.value}`)})]},p.value))})]})}function bAt({label:e,value:t,menuKey:n,openStyleMenu:r,onOpenStyleMenuChange:o,onChange:i,popoverZIndex:a=h1,"data-testid":s}){let l=We("shape"),c=CP(null),u=r===n;return Ar("div",{className:"shape-menu-anchor",children:[Ar("button",{ref:c,type:"button",className:`graph-color-button ${u?"active":""}`,title:e,"aria-label":e,"aria-haspopup":"dialog","aria-expanded":u,"data-testid":s,onClick:()=>o(u?null:n),children:[zt("span",{className:"graph-color-button-swatch",style:{background:t},"aria-hidden":"true"}),zt(ta,{size:12,"aria-hidden":"true"})]}),zt(Wo,{open:u,anchorRef:c,onClose:()=>o(null),className:"color-popover",ariaLabel:e,zIndex:a,children:zt(vd,{value:t,presetColors:FQo,presetLabel:l("graph.recommendedPalette"),onChange:d=>{d&&i(d),o(null)}})})]})}function OQo({value:e,onCommit:t}){let n=We("shape"),[r,o]=Ej(()=>String(e)),i=()=>{let a=Number(r);if(!r.trim()||!Number.isFinite(a)){o(String(e));return}let s=Math.min(48,Math.max(6,a));o(String(s)),t(s)};return Ar("label",{className:"graph-style-field graph-tick-font-size-field",htmlFor:"graph-tick-font-size",children:[zt("span",{children:n("graph.tickFontSize")}),Ar("span",{className:"graph-number-input",children:[zt("input",{id:"graph-tick-font-size","data-testid":"overlay-graph-tick-font-size",type:"number",min:6,max:48,step:.5,value:r,onChange:a=>o(a.target.value),onBlur:i,onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),a.currentTarget.blur())}}),zt("span",{className:"graph-number-input-unit","aria-hidden":"true",children:"pt"})]})]})}function aE({tex:e,ariaLabel:t,placeholderTex:n,dataTestId:r,allowEmpty:o=!1,allowImplicitEquation:i=!1,disabled:a=!1,live:s=!1,onCommitExpression:l,onClear:c}){let u=We("shape"),d=bQo(),[p,f]=Ej(null),[m,h]=Ej(null),g=CP(e);return Pte(()=>{g.current!==e&&(g.current=e,f(null),h(null))},[e]),Ar("div",{className:"graph-expression-field",children:[zt(wP,{tex:p??e,ariaLabel:t,placeholderTex:n,invalid:p!==null,ariaDescribedBy:m?d:void 0,disabled:a,"data-testid":r,onCommit:b=>{let x=b.trim();if(!x){o?(f(null),h(null),c?.()):(f(b),h("empty"));return}let v=Oqn(x,{allowImplicitEquation:i});if(v===null){f(b);let S=FP(x);"error"in S&&h(S.error);return}f(null),h(null),l(v.expression,v.tex)},onInputTex:s?b=>{let x=b.trim();if(!x){o||(f(b),h("empty"));return}let v=Oqn(x,{allowImplicitEquation:i});if(v===null){f(b);let S=FP(x);"error"in S&&h(S.error);return}f(null),h(null),l(v.expression,v.tex)}:void 0}),zt("p",{id:d,className:"graph-expression-error","data-empty":m?void 0:"true","aria-live":"polite",children:m?u(`texError.${m}`):null})]})}function Oqn(e,t={}){let n=e.trim();if(t.allowImplicitEquation){let a=cqn(n);if(a!==null)return a}let r=n,o=r.match(/^([yxt])\s*=\s*/i);o&&(r=r.slice(o[0].length));let i=kte(r);return i!==null?{expression:i,tex:r}:null}function jye({min:e,max:t,variableName:n,ariaLabel:r,minPlaceholderTex:o,maxPlaceholderTex:i,requireBoth:a=!1,allowEmpty:s=!1,disabled:l=!1,dataTestId:c,onCommitRange:u}){let d=We("shape"),p=e?.trim()?dd(e):"",f=t?.trim()?dd(t):"",m=s||!a,h=(g,y)=>{let b={...e?.trim()?{min:e}:{},...t?.trim()?{max:t}:{}};y===null?delete b[g]:b[g]=y;let x=!!b.min?.trim(),v=!!b.max?.trim();if(!x&&!v){s&&u(null);return}a&&(!x||!v)||u(b)};return Ar(fr,{className:"graph-range-pair",gap:"xs","aria-label":r,"data-testid":c?`${c}-pair`:void 0,children:[zt(aE,{tex:p,ariaLabel:d("graph.rangeStart",{name:r}),placeholderTex:o,allowEmpty:m,disabled:l,dataTestId:c?`${c}-min`:void 0,onCommitExpression:g=>h("min",g),onClear:()=>h("min",null)}),zt(hl,{tex:`\\leqq ${n} \\leqq`,className:"graph-range-separator"}),zt(aE,{tex:f,ariaLabel:d("graph.rangeEnd",{name:r}),placeholderTex:i,allowEmpty:m,disabled:l,dataTestId:c?`${c}-max`:void 0,onCommitExpression:g=>h("max",g),onClear:()=>h("max",null)})]})}function NQo(e,t){let n=Rh(e.mode);if(t==="parametric"){let i=n==="parametric"||hAt(e.expr,"t"),a=i?e.expr:"cos(t)",s=i?CB(e):"\\cos(t)",l=!!e.yExpr?.trim(),c=l?e.yExpr:"sin(t)",u=l?Rle(e):"\\sin(t)";return{mode:t,expr:a,exprTex:s,yExpr:c,yExprTex:u,label:LH(t,s,u),domain:n==="parametric"?e.domain:{...gJ}}}if(t==="implicit"){let i=n==="implicit"||hAt(e.expr,"y"),a=i?e.expr:"x^2 + y^2 - 1",s=i?CB(e):"x^{2}+y^{2}-1";return{mode:t,expr:a,exprTex:s,yExpr:void 0,yExprTex:void 0,label:LH(t,s),domain:n==="parametric"?void 0:e.domain}}let r=e.expr,o=CB(e);return(n==="parametric"||n==="implicit"||hAt(e.expr,"t"))&&(r=t==="xOfY"?"y^2":"sin(x)",o=t==="xOfY"?"y^{2}":"\\sin(x)"),{mode:t,expr:r,exprTex:o,yExpr:void 0,yExprTex:void 0,label:LH(t,o),domain:n==="parametric"?void 0:e.domain}}function hAt(e,t){return new RegExp(`\\b${t}\\b`,"i").test(e)}function gAt(e,t){let n=t9(e),r=zQo(t,n==="solid"?.32:.12);switch(n){case"solid":return{backgroundColor:r};case"diagonal":return{backgroundColor:r,backgroundImage:`repeating-linear-gradient(135deg, transparent 0 5px, ${t} 5px 6.5px, transparent 6.5px 10px)`};case"diagonalBack":return{backgroundColor:r,backgroundImage:`repeating-linear-gradient(45deg, transparent 0 5px, ${t} 5px 6.5px, transparent 6.5px 10px)`};case"cross":return{backgroundColor:r,backgroundImage:[`repeating-linear-gradient(135deg, transparent 0 5px, ${t} 5px 6px, transparent 6px 10px)`,`repeating-linear-gradient(45deg, transparent 0 5px, ${t} 5px 6px, transparent 6px 10px)`].join(", ")};case"horizontal":return{backgroundColor:r,backgroundImage:`repeating-linear-gradient(0deg, transparent 0 5px, ${t} 5px 6.5px, transparent 6.5px 10px)`};case"vertical":return{backgroundColor:r,backgroundImage:`repeating-linear-gradient(90deg, transparent 0 5px, ${t} 5px 6.5px, transparent 6.5px 10px)`};case"dots":return{backgroundColor:r,backgroundImage:`radial-gradient(${t} 1.2px, transparent 1.3px)`,backgroundSize:"7px 7px"}}return{backgroundColor:r}}function zQo(e,t){let n=/^#([0-9a-f]{6})$/i.exec(e);if(!n)return`rgba(156, 163, 175, ${t})`;let r=Number.parseInt(n[1],16),o=r>>16&255,i=r>>8&255,a=r&255;return`rgba(${o}, ${i}, ${a}, ${t})`}var Mte,w_,Ij,Pj,x9e,FQo,TQo,sE=X(()=>{"use strict";"use client";Dn();er();Uye();a9e();uAt();yqn();Wyt();YI();Dj();ij();Qb();s9e();ga();J7e();Qc();Gc();Ys();Lm();gxt();Aqn();u9e();Bqn();I8();P8e();o6e();Ak();Dt();un();Uye();Mte="sigma-studio:select-overlay-chart",w_="sigma-studio:open-overlay-chart-settings",Ij="sigma-studio:select-overlay-graph",Pj="sigma-studio:open-overlay-graph-settings",x9e="sigma-studio:graph-fill-unresolved";FQo=["#0d0d0d","#374151","#6b7280","#9ca3af","#d1d5db","#dc2626","#2563eb"];TQo={x:"axis-end-x",y:"axis-end-y"}});function S9e(e,t,n,r){let a=Math.max(1,n.width-16),s=Math.min(Math.max(1,t.width||300),a),l=Math.min(Math.max(1,t.minWidth??s),s),c=Math.max(1,n.height-16),u=Math.min(Math.max(1,t.height),c),d=e.left+e.width,p=e.top+e.height,f=n.width-8-(d+12),m=e.left-12-8,h=n.height-8-(p+12),g,y;f>=l?(g="right",y=Math.min(s,f)):m>=l?(g="left",y=Math.min(s,m)):h>=Math.min(u,160)?(g="below",y=s,c=Math.min(c,h),u=Math.min(u,c)):(g="clamped",y=s);let b=F=>Math.max(8,Math.min(F,n.width-8-y)),x=F=>Math.max(8,Math.min(F,n.height-8-u)),v,S;return g==="right"?(v=d+12,S=x(e.top)):g==="left"?(v=e.left-12-y,S=x(e.top)):g==="below"?(v=b(e.left),S=p+12):(g="clamped",v=b(n.width-8-y),S=x(e.top)),r&&(v+=r.dx,S+=r.dy),{left:b(v),top:x(S),width:y,maxHeight:c,side:g}}var xAt=X(()=>{"use strict"});var Bte,Uqn=X(()=>{Bte={panel:"Gi",header:"pr",headerActions:"Oi",title:"Ji",body:"br","overlay-graph-inspector":"Qi"}});import{useCallback as Vye,useEffect as w9e,useLayoutEffect as HQo,useRef as F9e,useState as GQo,useSyncExternalStore as jQo}from"react";import{createPortal as VQo}from"react-dom";import{jsx as Rte,jsxs as vAt}from"react/jsx-runtime";function XQo(){return()=>{}}function Gqn(e){if(typeof document>"u")return[];let t=CSS.escape(e);return[...document.querySelectorAll(`.overlay-shape[data-overlay-shape-id="${t}"]`),...document.querySelectorAll(`.graph-shape[id="${t}"]`)]}function jqn(e){let t=Gqn(e),n=1/0,r=1/0,o=-1/0,i=-1/0;for(let a of t){let s=a.getBoundingClientRect();s.width<=0&&s.height<=0||(n=Math.min(n,s.left),r=Math.min(r,s.top),o=Math.max(o,s.right),i=Math.max(i,s.bottom))}return!Number.isFinite(n)||!Number.isFinite(r)?null:{left:n,top:r,width:o-n,height:i-r}}function WQo(e,t,n,r,o){let i=jqn(e)??{left:8,top:8,width:0,height:0},a={width:n,minWidth:r,height:o||Hqn},s={width:window.innerWidth,height:window.innerHeight},l=S9e(i,a,s,null),c=S9e(i,a,s,t);return{dx:c.left-l.left,dy:c.top-l.top}}function Vqn({selectedOverlayGraph:e,onClose:t}){let n=We("shape");return Rte(AP,{shapeId:e.shapeId,title:n("graphPanel.title"),ariaLabel:n("graphPanel.title"),closeLabel:n("common.close"),onClose:t,width:620,minWidth:300,children:Rte(zqn,{selectedOverlayGraph:e})})}function AP({shapeId:e,title:t,ariaLabel:n,closeLabel:r,children:o,width:i=300,minWidth:a=i,headerActions:s,onClose:l}){let c=We("shape"),u=r??c("common.close"),d=F9e(null),p=F9e(null),f=F9e(null),m=F9e(null),[h,g]=GQo(null),y=jQo(XQo,()=>!0,()=>!1),b=Vye(()=>{if(typeof window>"u")return;let C=d.current?.getBoundingClientRect(),A=jqn(e)??{left:8,top:8,width:0,height:0},T=S9e(A,{width:i,minWidth:a,height:C?.height||Hqn},{width:window.innerWidth,height:window.innerHeight},p.current);g(D=>D&&D.left===T.left&&D.top===T.top&&D.width===T.width&&D.maxHeight===T.maxHeight&&D.side===T.side?D:T)},[a,e,i]),x=Vye(()=>{m.current===null&&(m.current=requestAnimationFrame(()=>{m.current=null,b()}))},[b]);HQo(()=>(b(),()=>{m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)}),[b]),w9e(()=>{let C=requestAnimationFrame(()=>{d.current?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(C)},[e]),w9e(()=>{if(!(typeof window>"u"))return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),window.addEventListener("pointerup",b,!0),window.addEventListener("keyup",x,!0),window.addEventListener("wheel",x,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b),window.removeEventListener("pointerup",b,!0),window.removeEventListener("keyup",x,!0),window.removeEventListener("wheel",x,!0)}},[x,b]),w9e(()=>{let C=d.current;if(!C||typeof ResizeObserver>"u")return;let A=new ResizeObserver(()=>b());A.observe(C);for(let T of Gqn(e)){A.observe(T);let D=T.closest(".overlay-canvas-editor");D&&A.observe(D)}return()=>A.disconnect()},[e,b]),w9e(()=>{let C=A=>{A.key!=="Escape"||A.defaultPrevented||A.target instanceof Element&&A.target.closest("[data-toolbar-popover]")||l()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[l]);let v=Vye(C=>{C.button!==0||C.target instanceof Element&&C.target.closest("button")||(C.preventDefault(),C.currentTarget.setPointerCapture(C.pointerId),f.current={pointerId:C.pointerId,startX:C.clientX,startY:C.clientY,originOffset:p.current??{dx:0,dy:0}})},[]),S=Vye(C=>{let A=f.current;!A||A.pointerId!==C.pointerId||(p.current=WQo(e,{dx:A.originOffset.dx+C.clientX-A.startX,dy:A.originOffset.dy+C.clientY-A.startY},i,a,d.current?.getBoundingClientRect().height),b())},[a,e,b,i]),F=Vye(C=>{let A=f.current;!A||A.pointerId!==C.pointerId||(f.current=null,C.currentTarget.hasPointerCapture(C.pointerId)&&C.currentTarget.releasePointerCapture(C.pointerId))},[]);if(!y)return null;let w=vAt("div",{ref:d,className:Bte.panel,role:"dialog","aria-label":n,"data-graph-settings-panel":"","data-non-modal-surface":"","data-side":h?.side??"right",tabIndex:-1,style:{left:h?.left??8,top:h?.top??8,width:h?.width??i,maxHeight:h?.maxHeight,visibility:h?void 0:"hidden"},children:[vAt("header",{className:Bte.header,onPointerDown:v,onPointerMove:S,onPointerUp:F,onPointerCancel:F,children:[Rte("h2",{className:Bte.title,children:t}),vAt("div",{className:Bte.headerActions,children:[s,Rte(Ur,{label:u,tone:"ghost",size:"sm",onClick:l,children:Rte(bo,{size:15,"aria-hidden":"true"})})]})]}),Rte("div",{className:Bte.body,children:o})]});return VQo(w,document.body)}var Hqn,_te=X(()=>{"use strict";"use client";er();sE();xAt();ga();Uqn();un();Hqn=520});function Xqn(e){window.dispatchEvent(new CustomEvent(A9e,{detail:e}))}function wAt(e){window.dispatchEvent(new CustomEvent(T9e,{detail:{shapeId:e}}))}var A9e,T9e,D9e=X(()=>{"use strict";A9e="sigma-studio:graph3d-animation-preview";T9e="sigma-studio:graph3d-settings-open"});function Wqn(e,t,n=Wye){let r=e.trim();if(!r)return{error:n("graph3dEditor.error.expressionRequired")};if(t==="equation"){let i=r.split("=");if(i.length!==2||!i[0].trim()||!i[1].trim())return{error:n("graph3dEditor.error.equationRequired")};let a=FP(i[0].trim()),s=FP(i[1].trim());return"error"in a||"error"in s?{error:n("graph3dEditor.error.equationUnreadable")}:{expression:`${a.expression}=${s.expression}`}}if(t==="inequality"){let i=YQo(r,n);return"error"in i?i:{expression:i.expressions.join(", ")}}let o=FP(r);return"error"in o?{error:n(`texError.${o.error}`)}:o}function Xh(e,t){if(t==="equation"){let n=e.split("=");return n.length!==2?e:`${dd(n[0].trim())}=${dd(n[1].trim())}`}return t==="inequality"?$Qo(e).map(n=>{let r=qQo(n);return r?dqn(r.left,r.operator,r.right):n}).join(",\\ "):dd(e)}function qqn(e=Wye){return[{title:e("graph3dEditor.group.solid"),choices:[{value:"box",label:e("graph3dEditor.name.box")},{value:"sphere",label:e("graph3dEditor.name.sphere")},{value:"cylinder",label:e("graph3dEditor.name.cylinder")},{value:"cone",label:e("graph3dEditor.name.cone")},{value:"revolution",label:e("graph3dEditor.name.revolution")},{value:"tetrahedron",label:e("graph3dEditor.name.boundedSolid")},{value:"polyhedron",label:e("graph3dEditor.name.polyhedronChoice")}]},{title:e("graph3dEditor.group.surfaceCurve"),choices:[{value:"parametricSurface",label:e("graph3dEditor.name.parametricSurface")},{value:"implicit",label:e("graph3dEditor.name.implicitSurfaceChoice")},{value:"parametricCurve",label:e("graph3dEditor.name.spaceCurve")}]},{title:e("graph3dEditor.group.pointLinePlane"),choices:[{value:"plane",label:e("graph3dEditor.name.plane")},{value:"segment",label:e("graph3dEditor.name.segment")},{value:"point",label:e("graph3dEditor.name.point")}]}]}function FAt(e,t=Wye){let n=rt("graph3d_object");switch(e){case"parametricSurface":return{id:n,name:t("graph3dEditor.name.parametricSurface"),kind:"parametricSurface",x:"(2 + cos(v))*cos(u)",y:"(2 + cos(v))*sin(u)",z:"sin(v)",u:{min:"0",max:"2*pi",samples:48},v:{min:"0",max:"2*pi",samples:24},style:Xye(.55)};case"parametricCurve":return{id:n,name:t("graph3dEditor.name.spaceCurve"),kind:"parametricCurve",x:"cos(t)",y:"sin(t)",z:"t/3",parameter:"t",range:{min:"-3*pi",max:"3*pi",samples:160},style:{color:"#2563eb",opacity:1}};case"revolution":return{id:n,name:t("graph3dEditor.name.revolution"),kind:"solidOfRevolution",axis:"z",radius:"sqrt(2*z^2 + 1)",axisRange:{min:"-3",max:"3",samples:28},angleRange:{min:"0",max:"2*pi",samples:48},capped:!0,style:Xye(.35)};case"box":case"sphere":case"cylinder":case"cone":return{id:n,name:{box:t("graph3dEditor.name.box"),sphere:t("graph3dEditor.name.sphere"),cylinder:t("graph3dEditor.name.cylinder"),cone:t("graph3dEditor.name.cone")}[e],kind:"primitive",primitive:e,center:jd("0","0","0"),size:jd("2","2","2"),style:Xye(.45)};case"polyhedron":return{id:n,name:t("graph3dEditor.name.squarePyramid"),kind:"polyhedron",vertices:[jd("-1","-1","0"),jd("1","-1","0"),jd("1","1","0"),jd("-1","1","0"),jd("0","0","2")],faces:[[0,3,2,1],[0,1,4],[1,2,4],[2,3,4],[3,0,4]],style:Xye(.45)};case"tetrahedron":return{id:n,name:t("graph3dEditor.name.boundedSolid"),kind:"boundedSolid",inequalities:["x >= 0","y >= 0","z >= 0","x+y+z <= 3"],bounds:{x:{min:"-1",max:"4"},y:{min:"-1",max:"4"},z:{min:"-1",max:"4"}},style:Xye(.4)};case"implicit":return{id:n,name:t("graph3dEditor.name.tanglecube"),kind:"implicitSurface",expression:"x^4 - 5*x^2 + y^4 - 5*y^2 + z^4 - 5*z^2 + 11.8 = 0",bounds:{x:{min:"-3.2",max:"3.2"},y:{min:"-3.2",max:"3.2"},z:{min:"-3.2",max:"3.2"}},resolution:44,style:{color:"#64748b",opacity:.55,wireframe:!1}};case"point":return{id:n,name:t("graph3dEditor.name.point"),kind:"point",position:jd("0","0","0")};case"segment":return{id:n,name:t("graph3dEditor.name.segment"),kind:"segment",from:jd("0","0","0"),to:jd("1","1","1")};case"plane":return{id:n,name:t("graph3dEditor.name.plane"),kind:"plane",plane:CAt("equation"),size:jd("6","6","0"),style:{color:"#94a3b8",opacity:.2}};default:return null}}function qQo(e){let t=/^([^<>=]*)(<=|>=|<|>)(.*)$/u.exec(e);if(!t)return null;let n=t[1].trim(),r=t[3].trim();return!n||!r?null:{left:n,operator:t[2],right:r}}function KQo(e){return`${e.left} ${e.operator} ${e.right}`}function YQo(e,t=Wye){let n=Kqn(e);if(n.length===0)return{error:t("graph3dEditor.error.expressionRequired")};let r=[];for(let o of n){let i=uqn(o);if(!i)return{error:t("graph3dEditor.error.inequalityRequired")};r.push(KQo(i))}return{expressions:r}}function $Qo(e){let t=Kqn(e);return t.length>0?t:[e.trim()].filter(Boolean)}function Kqn(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(a==="{"||a==="("||a==="[")r+=1;else if(a==="}"||a===")"||a==="]")r=Math.max(0,r-1);else if(r===0&&(a===","||a===";"||a==="\u3001")){let s=e.slice(n,i).trim();s&&t.push(s),n=i+1}}let o=e.slice(n).trim();return o&&t.push(o),t}function Yqn(e,t){let n=e.regions.find(o=>o.id===t);if(!n||n.kind!=="objectIntersection")return null;let r=e.objects.filter(o=>n.objectIds.includes(o.id));return r.length<2?null:{...e,objects:r.map(o=>({...o,visible:!1})),cuts:[],regions:[{...n,visible:!0}],annotations:[]}}function $qn(e,t=Wye){return{id:rt("graph3d_region"),kind:"objectIntersection",label:t("graph3dEditor.name.intersection"),objectIds:e,fill:{mode:"solid",color:"#d97706",opacity:.55},showEdges:!0}}function CAt(e){return e==="threePoints"?{kind:"threePoints",points:[jd("0","0","0"),jd("1","0","0"),jd("0","1","0")]}:e==="pointNormal"?{kind:"pointNormal",point:jd("0","0","0"),normal:jd("0","0","1")}:{kind:"equation",expression:"z = 0"}}function Zqn(e,t,n="diagonal"){return e==="none"?{mode:"none"}:e==="solid"?{mode:"solid",color:t,opacity:.3}:{mode:"pattern",color:t,opacity:.3,pattern:n}}function jd(e,t,n){return{x:e,y:t,z:n}}function Xye(e){return{color:"#64748b",opacity:e,wireframe:!0}}var Wye,Jqn=X(()=>{"use strict";u9e();ai();ho();Wye=Fr("shape")});import{Fragment as ZQo,memo as $ye,useCallback as uF,useEffect as pF,useId as JQo,useMemo as qye,useRef as Z2,useState as F_}from"react";import{flushSync as Qqn}from"react-dom";import{Fragment as $2,jsx as Bt,jsxs as br}from"react/jsx-runtime";function iKn({shapeId:e,onClose:t,onUndo:n,onRedo:r}){let[o,i]=F_(null);return pF(()=>{let a=s=>{i(s instanceof CustomEvent?s.detail:null)};return window.addEventListener(Ute,a),()=>window.removeEventListener(Ute,a)},[]),pF(()=>{e&&(!o||o.shapeId!==e)&&t()},[t,o,e]),!e||!o||o.shapeId!==e?null:Bt(eei,{selectedOverlayGraph3D:o,onClose:t,onUndo:n,onRedo:r})}function eei({selectedOverlayGraph3D:e,onClose:t,onUndo:n,onRedo:r}){let o=We("shape"),{spec:i,size:a,onSpecChange:s,onAnimationPreview:l,onInsertImage:c,onInsertSpec:u}=e,d=Z2(i),p=Z2(s),f=Z2(c),m=Z2(u),[h,g]=F_({status:"idle"}),[y,b]=F_(null),x=Z2(new Map),v=Z2(a);pF(()=>{d.current=i},[i]),pF(()=>{v.current=a},[a]),pF(()=>(wAt(e.shapeId),()=>wAt(null)),[e.shapeId]),pF(()=>{p.current=s},[s]),pF(()=>{f.current=c},[c]),pF(()=>{m.current=u},[u]);let S=uF((N,z)=>{let U=N(d.current);U!==d.current&&(d.current=U,p.current(U,z))},[]),F=N=>{!(N.metaKey||N.ctrlKey)||N.altKey||N.key.toLowerCase()!=="z"||N.target instanceof Element&&N.target.closest("math-field")||(N.preventDefault(),N.stopPropagation(),N.shiftKey?r():n())},w=Hv(i.view),C=qye(()=>Object.fromEntries(i.parameters.map(N=>[N.name,N.value])),[i.parameters]),A=qye(()=>i.regions.filter(N=>N.kind==="objectIntersection"),[i.regions]),T=uF((N,z)=>{S(U=>({...U,objects:U.objects.map(H=>H.id===N?z(H):H)}))},[S]),D=uF(N=>{let z=FAt(N,o);z&&S(U=>({...U,objects:[...U.objects,z]}))},[S,o]),k=uF(N=>{S(z=>({...z,objects:z.objects.filter(U=>U.id!==N),regions:z.regions.filter(U=>U.kind!=="objectIntersection"||U.objectIds.filter(H=>H!==N).length>=2).map(U=>U.kind==="objectIntersection"?{...U,objectIds:U.objectIds.filter(H=>H!==N)}:U)}))},[S]),P=uF((N,z)=>{S(U=>({...U,regions:U.regions.map(H=>H.id===N&&H.kind==="objectIntersection"?z(H):H)}))},[S]),I=uF(N=>{S(z=>({...z,regions:z.regions.filter(U=>U.id!==N)}))},[S]),B=uF(N=>{S(z=>({...z,annotations:z.annotations.map(U=>U.id===N.id?N:U)}))},[S]),M=uF(N=>{S(z=>({...z,annotations:z.annotations.filter(U=>U.id!==N)}))},[S]),L=uF(N=>{let z=d.current.regions.find(H=>H.id===N),U=Y2t(d.current,N,{width:320});U&&f.current({dataUrl:U.dataUrl,width:U.width,height:U.height,name:`${z&&"label"in z&&z.label||o("graph3d.intersectionFallback")}.svg`})},[o]),_=uF(N=>{let z=Yqn(d.current,N);z&&m.current(z)},[]),R=uF(async(N,z)=>{let U=new Map,H=fx(N),V=L5(N,H.annotations,Hv(N.view)).map(ne=>({id:ne.id,tex:ne.labelTex,color:ne.color}));if(V.length===0)return U;await document.fonts?.ready,Qqn(()=>b(V));try{for(let ne of V){let Z=x.current.get(ne.id),ee=Z?w3n(Z,z):null;ee&&U.set(ne.id,ee)}}finally{Qqn(()=>b(null))}return U},[]),O=uF(async()=>{let N=d.current;if(uce(N).length===0){g({status:"error",message:o("graph3d.noAnimatableParameters")});return}g({status:"preparing"});try{let{width:z,height:U}=v.current,H=await R(N,UH(z,U).scale);g({status:"recording",progress:0});let V=await pMn({spec:N,width:z,height:U,labels:H,onProgress:Z=>g({status:"recording",progress:Z})});g({status:"saving"});let ne=await m9e(V.blob,o("graph3d.animationExportName",{extension:V.extension}));g({status:"done",filePath:ne.filePath})}catch(z){g({status:"error",message:z instanceof Error?z.message:o("graph3dUi.videoExportFailed")})}},[R,o]);return br(AP,{shapeId:e.shapeId,title:o("graph3dUi.settingsTitle"),ariaLabel:o("graph3dUi.settingsTitle"),width:QQo,minWidth:300,onClose:t,children:[Bt(Kp,{className:Sn.inspector,space:"md",onKeyDownCapture:F,children:br(_n,{gap:"md",children:[br("div",{className:Sn.field,children:[Bt("span",{children:o("graph3dUi.templates")}),Bt(Aa,{"aria-label":o("graph3dUi.templates"),value:"",options:[{value:"",label:o("graph3dUi.templateKeepCurrent")},{value:"revolution",label:o("graph3dUi.templateRevolution")},{value:"tricylinder",label:o("graph3dUi.templateTricylinder")},{value:"sphereTetrahedron",label:o("graph3dUi.templateSphereTetrahedron")},{value:"surface",label:o("graph3dUi.templateSurface")},{value:"blank",label:o("graph3dUi.templateBlank")}],onChange:N=>{if(!N)return;let z=j9(N,mj(o));d.current=z,s(z)}})]}),br(K2,{title:o("graph3dUi.parametersSection"),count:i.parameters.length,children:[i.parameters.length===0&&Bt(Nte,{children:o("graph3dUi.parametersEmptyHint")}),Bt(p9e,{parameters:i.parameters,onChange:N=>S(z=>({...z,parameters:N(z.parameters)})),onPreview:l},e.shapeId),Bt(h9e,{parameters:uce(i),state:h,onExport:()=>{O()}})]}),Bt(K2,{title:o("graph3dUi.objectsSection"),count:i.objects.length,children:br(rE,{children:[i.objects.map(N=>Bt(oei,{object:N,variables:C,onChange:T,onDelete:k},N.id)),Bt(tei,{onAdd:D})]})}),br(K2,{title:o("graph3d.intersectionFallback"),count:A.length,children:[A.length===0&&Bt(Nte,{children:o("graph3dUi.intersectionExplainer")}),br(rE,{children:[A.map(N=>Bt(lei,{region:N,objects:i.objects,variables:C,onChange:P,onDelete:I,onInsertImage:L,onInsertSpec:_},N.id)),Bt(SP,{label:o("graph3dUi.addIntersection"),disabled:i.objects.length<2,onClick:()=>S(N=>({...N,regions:[...N.regions,$qn(N.objects.slice(0,2).map(z=>z.id),o)]}))})]}),i.objects.length<2&&Bt(Nte,{children:o("graph3dUi.intersectionNeedsTwoShapesHint")})]}),br(K2,{title:o("graph3dUi.annotationsSection"),count:i.annotations.length,children:[i.annotations.length===0&&Bt(Nte,{children:o("graph3dUi.annotationsEmptyHint")}),br(rE,{children:[i.annotations.map(N=>Bt(yei,{annotation:N,onChange:B,onDelete:M},N.id)),Bt(SP,{label:o("graph3dUi.addMathLabel"),onClick:()=>S(N=>({...N,annotations:[...N.annotations,rKn("label")]}))}),Bt(SP,{label:o("graph3dUi.addDimensionLine"),onClick:()=>S(N=>({...N,annotations:[...N.annotations,rKn("dimension")]}))})]})]}),br(K2,{title:o("graph3dUi.displaySection"),children:[br(fr,{gap:"md",wrap:!0,children:[Bt(zte,{label:o("graph3dUi.axes"),checked:i.view.showAxes,onChange:N=>S(z=>({...z,view:{...z.view,showAxes:N}}))}),Bt(zte,{label:o("graph3dUi.grid"),checked:i.view.showGrid,onChange:N=>S(z=>({...z,view:{...z.view,showGrid:N}}))}),Bt(zte,{label:o("graph3dUi.axisLabels"),checked:i.view.showAxisLabels!==!1,disabled:!i.view.showAxes,onChange:N=>S(z=>({...z,view:{...z.view,showAxisLabels:N}}))})]}),br("fieldset",{className:Sn.fieldset,disabled:!i.view.showAxes,children:[Bt("legend",{children:o("graph3dUi.axis")}),br(fr,{className:Sn.axisAppearance,gap:"sm",wrap:!0,children:[Bt(aKn,{lineStyle:i.view.axisLineStyle??"solid",endStyle:i.view.axisEndStyle??"arrow",disabled:!i.view.showAxes,onLineStyleChange:N=>S(z=>({...z,view:{...z.view,axisLineStyle:N}})),onEndStyleChange:N=>S(z=>({...z,view:{...z.view,axisEndStyle:N}}))}),Bt("div",{className:Sn.axisColorGrid,children:["x","y","z"].map(N=>Bt(Mj,{label:N,value:w[N],disabled:!i.view.showAxes,onChange:z=>S(U=>({...U,view:{...U.view,axisColors:{...Hv(U.view),[N]:z}}}))},N))})]})]}),br("div",{className:Sn.viewGroups,children:[br("div",{className:Sn.field,children:[Bt("span",{children:o("graph3dUi.projection")}),Bt(Aa,{"aria-label":o("graph3dUi.projectionMethod"),value:i.camera.projection,options:[{value:"perspective",label:o("graph3dUi.projectionPerspective")},{value:"orthographic",label:o("graph3dUi.projectionOrthographic")}],onChange:N=>S(z=>({...z,camera:{...z.camera,projection:N}}))})]}),Bt(Mj,{label:o("graph3dUi.background"),value:i.view.backgroundColor,onChange:N=>S(z=>({...z,view:{...z.view,backgroundColor:N}}))})]}),Bt(Cn,{size:"sm",onClick:()=>S(N=>({...N,camera:HB})),children:o("graph3dUi.resetView")})]})]})}),y&&Bt("div",{className:Sn.videoLabelStage,"aria-hidden":"true",children:y.map(N=>Bt("span",{className:"graph3d-annotation-label",ref:z=>{z?x.current.set(N.id,z):x.current.delete(N.id)},style:{color:N.color??"#1f2937"},children:Bt(hl,{tex:N.tex})},N.id))})]})}function aKn({lineStyle:e,endStyle:t,disabled:n=!1,onLineStyleChange:r,onEndStyleChange:o}){let i=Z2(null),[a,s]=F_(null);return br(fr,{className:Sn.axisStyleControls,gap:"xs",children:[Bt(aF,{buttonRef:i,currentValue:e,open:a==="line",disabled:n,onToggle:()=>s(l=>l==="line"?null:"line"),onSelect:l=>{r(l),s(null)},popoverZIndex:h1}),Bt(iE,{endpoint:"end",currentValue:t,open:a==="end",disabled:n,onToggle:()=>s(l=>l==="end"?null:"end"),onSelect:l=>{o(l),s(null)},popoverZIndex:h1})]})}function tei({onAdd:e}){let t=Z2(null),[n,r]=F_(!1);return br($2,{children:[br("button",{ref:t,type:"button",className:Sn.addCard,"aria-haspopup":"dialog","aria-expanded":n,onClick:()=>r(o=>!o),children:[Bt(zi,{size:17,"aria-hidden":"true"}),Bt("span",{children:qt("graph3dUi.addObject")})]}),Bt(Wo,{open:n,anchorRef:t,onClose:()=>r(!1),className:Sn.choicePopover,ariaLabel:qt("graph3dUi.addObjectKind"),zIndex:h1,children:Bt(_n,{gap:"sm",children:qqn(qt).map(o=>br("section",{children:[Bt("h4",{className:Sn.choiceGroupTitle,children:o.title}),Bt("div",{className:Sn.choiceGrid,children:o.choices.map(i=>br("button",{type:"button",className:Sn.choiceCard,onClick:()=>{r(!1),e(i.value)},children:[Bt(rei,{choice:i.value}),Bt("span",{children:i.label})]},i.value))})]},o.title))})})]})}function nei(e){let t=eKn.get(e);if(t!==void 0)return t;let n=null;try{let r=FAt(e,qt);r&&(n=hke(W5(Eot(r),{}),sKn,lKn,5))}catch{n=null}return eKn.set(e,n),n}function rei({choice:e}){let t=Z2(null);return pF(()=>{kAt(t.current,nei(e),"#64748b",sKn,lKn)},[e]),Bt("span",{className:Sn.choiceThumbnailFrame,"aria-hidden":"true",children:Bt("canvas",{ref:t,className:Sn.choiceThumbnail})})}function kAt(e,t,n,r=TAt,o=DAt){if(!e)return;let i=Math.min(3,Math.max(1,typeof window>"u"?1:window.devicePixelRatio||1));e.width=Math.round(r*i),e.height=Math.round(o*i);let a=e.getContext("2d");if(a&&(a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,r,o),!!t)){a.lineJoin="round",a.lineCap="round",a.strokeStyle="rgba(100, 116, 139, 0.28)",a.lineWidth=.6;for(let[s,l]of t.floor)a.beginPath(),a.moveTo(s.x,s.y),a.lineTo(l.x,l.y),a.stroke();for(let s of t.faces){let l=aei(n,s.shade);a.fillStyle=l,a.strokeStyle=l,a.lineWidth=.5,a.beginPath(),s.points.forEach((c,u)=>{u===0?a.moveTo(c.x,c.y):a.lineTo(c.x,c.y)}),a.closePath(),a.fill(),a.stroke()}a.strokeStyle=n,a.lineWidth=1.4;for(let s of t.polylines)a.beginPath(),s.forEach((l,c)=>{c===0?a.moveTo(l.x,l.y):a.lineTo(l.x,l.y)}),a.stroke();a.fillStyle=n;for(let s of t.points)a.beginPath(),a.arc(s.x,s.y,2.4,0,Math.PI*2),a.fill()}}function aei(e,t){let n=/^#([0-9a-f]{6})$/iu.exec(e.trim()),r=n?[0,2,4].map(a=>Number.parseInt(n[1].slice(a,a+2),16)):[100,116,139],o=.45+.95*Math.max(0,Math.min(1,t)),i=r.map(a=>Math.round(Math.min(255,a*o)));return`rgb(${i[0]}, ${i[1]}, ${i[2]})`}function sei(e){switch(e.kind){case"implicitSurface":return Xh(e.expression,"equation");case"parametricCurve":return`(${Xh(e.x,"expression")},${Xh(e.y,"expression")},${Xh(e.z,"expression")})`;case"parametricSurface":return`(${Xh(e.x,"expression")},${Xh(e.y,"expression")},${Xh(e.z,"expression")})`;case"solidOfRevolution":return`r=${Xh(e.radius,"expression")}`;case"point":return`(${Xh(e.position.x,"expression")},${Xh(e.position.y,"expression")},${Xh(e.position.z,"expression")})`;case"segment":return`${tKn(e.from)}\\mathbin{-}${tKn(e.to)}`;case"plane":return e.plane.kind==="equation"?Xh(e.plane.expression,"equation"):null;case"boundedSolid":return e.inequalities[0]?Xh(e.inequalities[0],"inequality"):null;default:return null}}function tKn(e){return`(${Xh(e.x,"expression")},${Xh(e.y,"expression")},${Xh(e.z,"expression")})`}function AAt(e){return e.fill.mode==="none"?{mode:"solid",color:"#d97706",opacity:.55}:e.fill}function cei(e){return qt({empty:"graph3dUi.sharedNone",solid:"graph3dUi.sharedVolume",section:"graph3dUi.sharedPlane",surface:"graph3dUi.sharedSurfaceArea",curve:"graph3dUi.sharedLine",points:"graph3dUi.sharedPoint"}[e])}function uei(e,t,n){let r=Om();return qye(()=>{if(e.length<2)return{kind:"error",status:qt("graph3dUi.selectTwoShapes"),drawing:null};try{let o=JK(e,t,{...n===void 0?{}:{resolution:n}});return{kind:o.kind,status:cei(o.kind),drawing:hke(Ptn(o),TAt,DAt)}}catch(o){return{kind:"error",status:dei(o)??qt("graph3dUi.intersectionFailed"),drawing:null}}},[e,n,t,r])}function dei(e){if(e instanceof Fa){let t=e.code==="commonPartObjectHasNoSurfaceOrInterior"&&!e.params?.name?{...e.params,name:qt("graph3dError.commonPartObjectFallbackName")}:e.params;return qt(`graph3dError.${e.code}`,t)}return e instanceof Error?e.message:null}function Kye({mode:e="expression",ariaLabel:t,className:n,placeholderTex:r,testId:o,value:i,onChange:a}){let s=We("shape"),l=JQo(),[c,u]=F_(null),[d,p]=F_(null),f=Z2(i);pF(()=>{f.current!==i&&(f.current=i,u(null),p(null))},[i]);let m=h=>{let g=Wqn(h,e,s);if("error"in g){u(h),p(g.error);return}u(null),p(null),a(g.expression)};return br($2,{children:[Bt(wP,{tex:c??Xh(i,e),ariaLabel:t,className:n,placeholderTex:r??fei[e],invalid:c!==null,ariaDescribedBy:d?l:void 0,"data-testid":o,onCommit:m}),d&&Bt("span",{id:l,className:Sn.expressionError,children:d})]})}function DA({mode:e="expression",label:t,value:n,onChange:r}){return br("label",{className:Sn.field,children:[Bt("span",{children:t}),Bt(Kye,{mode:e,ariaLabel:t,testId:`graph3d-expression-${cKn(t)}`,value:n,onChange:r})]})}function cKn(e){return e.replace(/[^a-zA-Z0-9\p{L}\p{N}]+/gu,"-").replace(/^-|-$/g,"")}function k9e(e){return br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:e.label}),Bt(uKn,{...e})]})}function uKn({label:e,variableTex:t,range:n,onChange:r}){return br("div",{className:Sn.relationRow,children:[Bt(Kye,{ariaLabel:qt("graph3dFormat.minimum",{label:e}),className:Sn.compactExpression,placeholderTex:"-2",value:n.min,onChange:o=>r({...n,min:o})}),Bt(hl,{className:Sn.relationSymbol,tex:`\\leqq ${t} \\leqq`}),Bt(Kye,{ariaLabel:qt("graph3dFormat.maximum",{label:e}),className:Sn.compactExpression,placeholderTex:"2",value:n.max,onChange:o=>r({...n,max:o})})]})}function mei({label:e,inequalities:t,onChange:n}){let r=(o,i)=>n(t.map((a,s)=>s===o?i:a));return br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:e}),br(_n,{gap:"xs",children:[br("div",{className:Sn.inequalitySystem,children:[Bt("span",{"aria-hidden":"true",className:Sn.inequalityBrace,"data-testid":"graph3d-inequality-brace",style:{fontSize:`${Math.max(44,t.length*34)}px`},children:"{"}),Bt(_n,{gap:"xs",children:t.map((o,i)=>Bt(hei,{index:i,value:o,onChange:a=>{let s=a.split(/[,;、]/u).map(l=>l.trim()).filter(Boolean);if(s.length>1){n([...t.slice(0,i),...s,...t.slice(i+1)]);return}r(i,a)},onDelete:t.length>1?()=>n(t.filter((a,s)=>s!==i)):void 0},i))})]}),br(Cn,{size:"sm",onClick:()=>n([...t,"x >= 0"]),children:[Bt(zi,{size:14})," ",qt("graph3dUi.addInequality")]})]})]})}function hei({index:e,value:t,onChange:n,onDelete:r}){let o=qt("graph3dFormat.inequality",{index:e+1});return br("div",{className:Sn.relationRow,children:[Bt(Kye,{mode:"inequality",ariaLabel:o,className:Sn.compactExpression,testId:`graph3d-inequality-${e+1}`,value:t,onChange:n}),r&&Bt(Ur,{label:qt("graph3dFormat.deleteNamed",{name:o}),size:"sm",tone:"ghost",onClick:r,children:Bt(Ro,{size:14})})]})}function TP({rows:e}){return br("div",{className:Sn.vectorGrid,children:[Bt("span",{"aria-hidden":"true"}),["x","y","z"].map(t=>Bt(hl,{className:Sn.vectorAxisHeading,tex:t},t)),e.map(t=>br(ZQo,{children:[Bt("span",{className:Sn.vectorRowLabel,children:t.label}),["x","y","z"].map(n=>Bt(Kye,{ariaLabel:qt("graph3dFormat.coordinate",{label:t.label,axis:n}),className:Sn.compactExpression,placeholderTex:"0",testId:`graph3d-vector-${cKn(t.label)}-${n}`,value:t.vector[n],onChange:r=>t.onChange({...t.vector,[n]:r})},n))]},t.label))]})}function gei({object:e,onChange:t}){let n=e.style?.wireframe===!0;return br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:qt("graph3dUi.appearance")}),br("div",{className:Sn.styleRow,children:[Bt(Mj,{label:qt("graph3dUi.color"),value:e.style?.color??"#64748b",onChange:r=>t(o=>({...o,style:{...o.style,color:r}}))}),Bt(dF,{label:qt("graph3dUi.opacity"),value:e.style?.opacity??.72,min:0,max:1,step:.05,onChange:r=>t(o=>({...o,style:{...o.style,opacity:r}}))}),Bt(zte,{label:qt("graph3dUi.wireframe"),checked:n,onChange:r=>t(o=>({...o,style:{...o.style,wireframe:r}}))}),Bt(Mj,{label:qt("graph3dUi.wireframeColor"),value:e.style?.wireframeColor??"#1f2933",disabled:!n,onChange:r=>t(o=>({...o,style:{...o.style,wireframeColor:r}}))})]})]})}function nKn({label:e,bounds:t,onChange:n}){return br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:e}),Bt(_n,{gap:"xs",children:["x","y","z"].map(r=>Bt(uKn,{label:qt("graph3dFormat.range",{name:r}),variableTex:r,range:t[r],onChange:o=>n({...t,[r]:o})},r))})]})}function dF({label:e,value:t,min:n,max:r,step:o="any",onChange:i}){return br("label",{className:Sn.field,children:[Bt("span",{children:e}),Bt("input",{type:"number",value:t,min:n,max:r,step:o,onChange:a=>{let s=a.target.valueAsNumber;Number.isFinite(s)&&i(s)}})]})}function Mj({label:e,value:t,disabled:n=!1,onChange:r}){let[o,i]=F_(!1),a=Z2(null),s=/^#[0-9a-f]{6}$/iu.test(t)?t:"#64748b";return br("div",{className:Sn.colorField,children:[Bt("span",{children:e}),br("button",{ref:a,type:"button",className:Sn.colorButton,"aria-label":qt("graph3dFormat.choose",{label:e}),"aria-haspopup":"dialog","aria-expanded":o,disabled:n,onClick:()=>i(l=>!l),children:[Bt("span",{className:Sn.colorSwatch,style:{backgroundColor:s},"aria-hidden":"true"}),Bt(ta,{size:12,"aria-hidden":"true"})]}),Bt(Wo,{open:o&&!n,anchorRef:a,onClose:()=>i(!1),className:"color-popover",ariaLabel:e,zIndex:h1,children:Bt(vd,{value:t,onChange:l=>{l&&r(l),i(!1)}})})]})}function zte({label:e,checked:t,disabled:n=!1,onChange:r}){return br("label",{className:Sn.checkbox,children:[Bt("input",{type:"checkbox",checked:t,disabled:n,onChange:o=>r(o.target.checked)}),Bt("span",{children:e})]})}function Nte({children:e}){return Bt("p",{className:Sn.empty,children:e})}function rKn(e){return e==="dimension"?{id:rt("graph3d_annotation"),kind:e,from:jd("0","0","0"),to:jd("0","0","1"),labelTex:"1",color:"#1f2937"}:{id:rt("graph3d_annotation"),kind:e,position:jd("0","0","0"),labelTex:"A",color:"#1f2937"}}function Yye(e){return{implicitSurface:qt("graph3dUi.kindImplicitSurface"),parametricCurve:qt("graph3dUi.kindSpaceCurve"),parametricSurface:qt("graph3dUi.kindParametricSurface"),primitive:qt("graph3dUi.kindPrimitive"),solidOfRevolution:qt("graph3dUi.kindRevolution"),polyhedron:qt("graph3dUi.kindPolyhedron"),boundedSolid:qt("graph3dUi.kindBoundedSolid"),point:qt("graph3dUi.kindPoint"),segment:qt("graph3dUi.kindSegment"),plane:qt("graph3dUi.kindPlane")}[e]}function bei(e,t){let n=a=>{try{return Math.abs(Ni(a,t))/2}catch{return 0}},r=n(e.size.x),o=n(e.size.y),i=n(e.size.z);return e.primitive==="sphere"?Math.max(r,o,i):Math.max(r,o)}function Ote(e){return typeof e=="string"?e:e.parameter?.trim()||"t"}function oKn(e,t,n){if(t===n)return e;let r=t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return e.replace(new RegExp(`\\b${r}\\b`,"gu"),n)}function xei(e,t){let n=e.split(`
8838
8838
  `).filter(r=>r.trim()).map(r=>r.split(",").map(o=>Number(o.trim())));return n.length>0&&n.every(r=>r.length>=3&&r.every(o=>Number.isInteger(o)&&o>=0))?n:t}var QQo,qt,Ute,lE,sKn,lKn,eKn,oei,iei,TAt,DAt,lei,pei,fei,yei,Bj=X(()=>{"use strict";"use client";er();YI();_te();Uye();xAt();Qb();Dj();ij();D9e();s9e();ga();Qc();Jw();Dt();Pn();Gc();Ys();Y0e();$1t();Dn();Gye();ai();DNe();ho();un();fAt();uAt();Hye();a9e();Jqn();QQo=620,qt=Fr("shape"),Ute="sigma-studio:select-overlay-graph3d",lE="sigma-studio:open-overlay-graph3d-settings";sKn=96,lKn=58,eKn=new Map;oei=$ye(function({object:t,variables:n,onChange:r,onDelete:o}){let i=l=>r(t.id,l),a=(l,c)=>i(u=>u.kind===l?c(u):u),s=(()=>{switch(t.kind){case"implicitSurface":return Bt(DA,{mode:"equation",label:qt("graph3dUi.surfaceEquation"),value:t.expression,onChange:l=>a("implicitSurface",c=>({...c,expression:l}))});case"parametricSurface":return br("div",{className:Sn.compactFormulaGrid,children:[Bt(DA,{label:"x(u,v)",value:t.x,onChange:l=>a("parametricSurface",c=>({...c,x:l}))}),Bt(DA,{label:"y(u,v)",value:t.y,onChange:l=>a("parametricSurface",c=>({...c,y:l}))}),Bt(DA,{label:"z(u,v)",value:t.z,onChange:l=>a("parametricSurface",c=>({...c,z:l}))})]});case"parametricCurve":return br("div",{className:Sn.compactFormulaGrid,children:[Bt(DA,{label:`x(${t.parameter})`,value:t.x,onChange:l=>a("parametricCurve",c=>({...c,x:l}))}),Bt(DA,{label:`y(${t.parameter})`,value:t.y,onChange:l=>a("parametricCurve",c=>({...c,y:l}))}),Bt(DA,{label:`z(${t.parameter})`,value:t.z,onChange:l=>a("parametricCurve",c=>({...c,z:l}))})]});case"solidOfRevolution":return Bt(DA,{label:qt("graph3dUi.crossSectionEquation"),value:t.radius,onChange:l=>a("solidOfRevolution",c=>({...c,radius:l}))});case"plane":return t.plane.kind==="equation"?Bt(DA,{mode:"equation",label:qt("graph3dUi.planeEquation"),value:t.plane.expression,onChange:l=>a("plane",c=>({...c,plane:{kind:"equation",expression:l}}))}):null;default:return null}})();return br(Cte,{label:qt("graph3dFormat.details",{name:t.name??Yye(t.kind)}),openDetailsOnCardHover:!0,visibility:{visible:t.visible!==!1,onChange:l=>i(c=>({...c,visible:l}))},title:Bt("input",{className:Sn.titleInput,"aria-label":qt("graph3dUi.objectName"),value:t.name??Yye(t.kind),onChange:l=>i(c=>({...c,name:l.target.value}))}),summary:Bt(iei,{object:t,variables:n,caption:sei(t)}),controls:s,children:[Bt(gei,{object:t,onChange:i}),t.kind==="implicitSurface"&&br($2,{children:[Bt(nKn,{label:qt("graph3dUi.calculationRange"),bounds:t.bounds,onChange:l=>a("implicitSurface",c=>({...c,bounds:l}))}),Bt(dF,{label:qt("graph3dUi.plotCount"),value:t.resolution??20,min:4,max:G9,step:1,onChange:l=>a("implicitSurface",c=>({...c,resolution:Math.round(l)}))})]}),t.kind==="parametricSurface"&&br($2,{children:[Bt(k9e,{label:qt("graph3dUi.uRange"),variableTex:"u",range:t.u,onChange:l=>a("parametricSurface",c=>({...c,u:l}))}),Bt(k9e,{label:qt("graph3dUi.vRange"),variableTex:"v",range:t.v,onChange:l=>a("parametricSurface",c=>({...c,v:l}))}),Bt(dF,{label:qt("graph3dUi.plotCount"),value:Math.max(t.u.samples??36,t.v.samples??36),min:2,max:256,step:1,onChange:l=>a("parametricSurface",c=>({...c,u:{...c.u,samples:Math.round(l)},v:{...c.v,samples:Math.round(l)}}))})]}),t.kind==="parametricCurve"&&br($2,{children:[br("label",{className:Sn.field,children:[Bt("span",{children:qt("graph3dUi.parameterLabel")}),Bt("input",{value:t.parameter,onChange:l=>a("parametricCurve",c=>({...c,parameter:l.target.value}))})]}),Bt(k9e,{label:qt("graph3dFormat.range",{name:t.parameter}),variableTex:t.parameter,range:t.range,onChange:l=>a("parametricCurve",c=>({...c,range:l}))}),Bt(dF,{label:qt("graph3dUi.plotCount"),value:t.range.samples??36,min:2,max:256,step:1,onChange:l=>a("parametricCurve",c=>({...c,range:{...c.range,samples:Math.round(l)}}))})]}),t.kind==="solidOfRevolution"&&br($2,{children:[Bt("p",{className:Sn.axisHint,children:qt("graph3dUi.revolutionRadiusHint",{parameter:Ote(t.axis)})}),br("div",{className:Sn.field,children:[Bt("span",{children:qt("graph3dUi.revolutionAxis")}),Bt(Aa,{"aria-label":qt("graph3dUi.revolutionAxis"),value:typeof t.axis=="string"?t.axis:"planeIntersection",options:[{value:"x",label:qt("graph3dUi.axisX")},{value:"y",label:qt("graph3dUi.axisY")},{value:"z",label:qt("graph3dUi.axisZ")},{value:"planeIntersection",label:qt("graph3dUi.axisTwoPlanes")}],onChange:l=>a("solidOfRevolution",c=>{let u=l==="planeIntersection"?{kind:"planeIntersection",equations:["x = y","z = 0"],parameter:"t"}:l;return{...c,axis:u,radius:oKn(c.radius,Ote(c.axis),Ote(u))}})})]}),typeof t.axis!="string"&&br($2,{children:[Bt(DA,{mode:"equation",label:qt("graph3dUi.axisFirstPlane"),value:t.axis.equations[0],onChange:l=>a("solidOfRevolution",c=>typeof c.axis=="string"?c:{...c,axis:{...c.axis,equations:[l,c.axis.equations[1]]}})}),Bt(DA,{mode:"equation",label:qt("graph3dUi.axisSecondPlane"),value:t.axis.equations[1],onChange:l=>a("solidOfRevolution",c=>typeof c.axis=="string"?c:{...c,axis:{...c.axis,equations:[c.axis.equations[0],l]}})}),br("label",{className:Sn.field,children:[Bt("span",{children:qt("graph3dUi.axisParameter")}),Bt("input",{value:t.axis.parameter??"t",onChange:l=>a("solidOfRevolution",c=>{if(typeof c.axis=="string")return c;let u=l.target.value.trim()||"t";return{...c,axis:{...c.axis,parameter:u},radius:oKn(c.radius,Ote(c.axis),u)}})})]}),Bt("p",{className:Sn.axisHint,children:qt("graph3dUi.axisTwoPlanesExample")})]}),Bt(k9e,{label:qt("graph3dFormat.range",{name:Ote(t.axis)}),variableTex:Ote(t.axis),range:t.axisRange,onChange:l=>a("solidOfRevolution",c=>({...c,axisRange:l}))}),br("div",{className:Sn.compactGrid,children:[Bt(dF,{label:qt("graph3dUi.axialPlotCount"),value:t.axisRange.samples??36,min:2,max:256,step:1,onChange:l=>a("solidOfRevolution",c=>({...c,axisRange:{...c.axisRange,samples:Math.round(l)}}))}),Bt(dF,{label:qt("graph3dUi.angularPlotCount"),value:t.angleRange?.samples??48,min:3,max:256,step:1,onChange:l=>a("solidOfRevolution",c=>({...c,angleRange:{...c.angleRange??{min:"0",max:"2*pi"},samples:Math.round(l)}}))})]})]}),t.kind==="primitive"&&br($2,{children:[br("div",{className:Sn.field,children:[Bt("span",{children:qt("graph3dUi.primitiveKind")}),Bt(Aa,{"aria-label":qt("graph3dUi.primitiveKind"),value:t.primitive,options:[{value:"box",label:qt("graph3dUi.primitiveBox")},{value:"sphere",label:qt("graph3dUi.primitiveSphere")},{value:"cylinder",label:qt("graph3dUi.primitiveCylinder")},{value:"cone",label:qt("graph3dUi.primitiveCone")}],onChange:l=>a("primitive",c=>({...c,primitive:l}))})]}),Bt(TP,{rows:[{label:qt("graph3dUi.center"),vector:t.center,onChange:l=>a("primitive",c=>({...c,center:l}))},{label:qt("graph3dUi.size"),vector:t.size,onChange:l=>a("primitive",c=>({...c,size:l}))}]}),t.primitive!=="box"&&br($2,{children:[Bt(dF,{label:qt("graph3dUi.plotCount"),value:gce(bei(t,n),t.resolution),min:$K,max:hce,step:1,onChange:l=>a("primitive",c=>({...c,resolution:Math.round(l)}))}),Bt("p",{className:Sn.axisHint,children:t.resolution===void 0?qt("graph3dUi.sizeAutoHint"):qt("graph3dUi.sizeAutoRestoreHint")}),t.resolution!==void 0&&Bt(Cn,{size:"sm",onClick:()=>a("primitive",l=>{let c={...l};return delete c.resolution,c}),children:qt("graph3dUi.matchRadius")})]})]}),t.kind==="boundedSolid"&&br($2,{children:[Bt(mei,{label:qt("graph3dUi.boundingInequalities"),inequalities:t.inequalities,onChange:l=>a("boundedSolid",c=>({...c,inequalities:l}))}),Bt(nKn,{label:qt("graph3dUi.searchBounds"),bounds:t.bounds,onChange:l=>a("boundedSolid",c=>({...c,bounds:l}))}),Bt(dF,{label:qt("graph3dUi.plotCount"),value:UB(t),min:8,max:G9,step:1,onChange:l=>a("boundedSolid",c=>({...c,resolution:Math.round(l)}))}),Bt("p",{className:Sn.axisHint,children:qt("graph3dUi.plotCountExplainer")})]}),t.kind==="polyhedron"&&br($2,{children:[Bt(TP,{rows:t.vertices.map((l,c)=>({label:qt("graph3dFormat.vertex",{index:c}),vector:l,onChange:u=>a("polyhedron",d=>({...d,vertices:d.vertices.map((p,f)=>f===c?u:p)}))}))}),br("label",{className:Sn.field,children:[Bt("span",{children:qt("graph3dUi.facesInput")}),Bt("textarea",{rows:4,value:t.faces.map(l=>l.join(",")).join(`
8839
- `),onChange:l=>a("polyhedron",c=>({...c,faces:xei(l.target.value,c.faces)}))})]})]}),t.kind==="point"&&br($2,{children:[Bt(TP,{rows:[{label:qt("graph3dUi.coordinates"),vector:t.position,onChange:l=>a("point",c=>({...c,position:l}))}]}),Bt(dF,{label:qt("graph3dUi.pointSize"),value:t.radius??.08,min:.01,max:1,step:.01,onChange:l=>a("point",c=>({...c,radius:l}))})]}),t.kind==="segment"&&Bt(TP,{rows:[{label:qt("graph3dUi.startPoint"),vector:t.from,onChange:l=>a("segment",c=>({...c,from:l}))},{label:qt("graph3dUi.endPoint"),vector:t.to,onChange:l=>a("segment",c=>({...c,to:l}))}]}),t.kind==="plane"&&br($2,{children:[br("div",{className:Sn.field,children:[Bt("span",{children:qt("graph3dUi.definitionMethod")}),Bt(Aa,{"aria-label":qt("graph3dUi.planeDefinitionMethod"),value:t.plane.kind,options:[{value:"equation",label:qt("graph3dUi.equation")},{value:"threePoints",label:qt("graph3dUi.threePoints")},{value:"pointNormal",label:qt("graph3dUi.pointAndNormal")}],onChange:l=>a("plane",c=>({...c,plane:CAt(l)}))})]}),t.plane.kind==="threePoints"&&Bt(TP,{rows:t.plane.points.map((l,c)=>({label:qt("graph3dFormat.point",{index:c+1}),vector:l,onChange:u=>a("plane",d=>{if(d.plane.kind!=="threePoints")return d;let p=[...d.plane.points];return p[c]=u,{...d,plane:{kind:"threePoints",points:p}}})}))}),t.plane.kind==="pointNormal"&&Bt(TP,{rows:[{label:qt("graph3dUi.pointOnPlane"),vector:t.plane.point,onChange:l=>a("plane",c=>c.plane.kind==="pointNormal"?{...c,plane:{...c.plane,point:l}}:c)},{label:qt("graph3dUi.normal"),vector:t.plane.normal,onChange:l=>a("plane",c=>c.plane.kind==="pointNormal"?{...c,plane:{...c.plane,normal:l}}:c)}]})]}),t.kind!=="point"&&t.kind!=="segment"&&br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:qt("graph3dUi.placementSection")}),Bt(TP,{rows:[{label:qt("graph3dUi.translation"),vector:t.translation??jd("0","0","0"),onChange:l=>i(c=>({...c,translation:l}))},{label:qt("graph3dUi.scale"),vector:t.scale??jd("1","1","1"),onChange:l=>i(c=>({...c,scale:l}))},{label:qt("graph3dUi.rotation"),vector:t.rotation??jd("0","0","0"),onChange:l=>i(c=>({...c,rotation:l}))}]}),Bt("p",{className:Sn.axisHint,children:qt("graph3dUi.rotationRadiansHint")})]}),br(Cn,{tone:"danger",size:"sm",onClick:()=>o(t.id),children:[Bt(Ro,{size:14})," ",qt("graph3dUi.deleteObject")]})]})}),iei=$ye(function({object:t,variables:n,caption:r}){let o=Z2(null),i=qye(()=>{try{let l=W5(Eot(t),n);return hke(l,TAt,DAt)}catch{return null}},[t,n]),a=t.style?.color??"#64748b";pF(()=>{kAt(o.current,i,a)},[a,i]);let s=!i||i.faces.length===0&&i.polylines.length===0&&i.points.length===0;return br("div",{className:Sn.objectOverview,children:[br("div",{className:Sn.objectThumbnailFrame,children:[Bt("canvas",{ref:o,className:Sn.objectThumbnail,role:"img","aria-label":qt("graph3dFormat.outline",{name:t.name||Yye(t.kind)})}),s&&Bt("span",{className:Sn.objectThumbnailFallback,children:"3D"})]}),br("div",{className:Sn.objectOverviewText,children:[Bt("span",{className:Sn.widgetSummary,children:Yye(t.kind)}),r&&Bt(hl,{className:Sn.objectFormula,tex:r})]})]})}),TAt=132,DAt=86;lei=$ye(function({region:t,objects:n,variables:r,onChange:o,onDelete:i,onInsertImage:a,onInsertSpec:s}){let l=g=>o(t.id,g),c=AAt(t),u=g=>l(y=>({...y,fill:{...AAt(y),...g}})),d=qye(()=>t.objectIds.map(g=>n.find(y=>y.id===g)).filter(g=>g!==void 0),[n,t.objectIds]),p=t.label||qt("graph3d.intersectionFallback"),f=uei(d,r,t.resolution),m=f.kind==="section",h=(g,y)=>l(b=>({...b,objectIds:y?[...b.objectIds.filter(x=>x!==g),g]:b.objectIds.filter(x=>x!==g)}));return br(Cte,{label:qt("graph3dFormat.details",{name:p}),openDetailsOnCardHover:!0,visibility:{visible:t.visible!==!1,onChange:g=>l(y=>({...y,visible:g}))},title:Bt("input",{className:Sn.titleInput,"aria-label":qt("graph3dUi.intersectionName"),value:p,onChange:g=>l(y=>({...y,label:g.target.value}))}),summary:Bt(pei,{result:f,color:c.color}),children:[br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:qt("graph3dUi.appearance")}),br("div",{className:Sn.styleRow,children:[Bt(Mj,{label:qt("graph3dUi.fillColor"),value:c.color,onChange:g=>u({color:g})}),Bt(dF,{label:qt("graph3dUi.opacity"),value:c.opacity??.55,min:0,max:1,step:.05,onChange:g=>u({opacity:g})}),Bt(zte,{label:qt("graph3dUi.outline"),checked:t.showEdges!==!1,onChange:g=>l(y=>({...y,showEdges:g}))}),Bt(Mj,{label:qt("graph3dUi.outlineColor"),value:t.edgeColor??c.color,disabled:t.showEdges===!1,onChange:g=>l(y=>({...y,edgeColor:g}))})]})]}),br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:qt("graph3dUi.intersectionShapes")}),br(_n,{className:Sn.memberList,gap:"xs",children:[n.length===0&&Bt(Nte,{children:qt("graph3dUi.intersectionShapesEmpty")}),n.map(g=>Bt(zte,{label:g.name||Yye(g.kind),checked:t.objectIds.includes(g.id),onChange:y=>h(g.id,y)},g.id))]})]}),br("div",{className:Sn.quickControlGrid,children:[br("div",{className:Sn.field,children:[Bt("span",{children:qt("graph3dUi.fillStyle")}),Bt(Aa,{"aria-label":qt("graph3dUi.intersectionFillStyle"),value:c.mode,options:[{value:"solid",label:qt("graph3dUi.fillSolid")},{value:"pattern",label:qt("graph3dUi.fillHatching")}],onChange:g=>l(y=>{let b=AAt(y),x=Zqn(g,b.color);return{...y,fill:x.mode==="none"?x:{...x,opacity:b.opacity}}})})]}),Bt(dF,{label:qt("graph3dUi.plotCount"),value:t.resolution??26,min:8,max:G9,step:1,onChange:g=>l(y=>({...y,resolution:Math.round(g)}))})]}),br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:qt("graph3dUi.insertIntoDocument")}),br(fr,{gap:"xs",wrap:!0,children:[br(Cn,{size:"sm",disabled:!m,onClick:()=>a(t.id),children:[Bt(lue,{size:14})," ",qt("graph3dUi.insertPlaneAsImage")]}),br(Cn,{size:"sm",disabled:f.kind==="empty"||f.kind==="error",onClick:()=>s(t.id),children:[Bt(Zce,{size:14})," ",qt("graph3dUi.insertIntersectionAs3d")]})]}),!m&&Bt(Nte,{children:qt("graph3dUi.insertImageOnlyPlanar")})]}),Bt("p",{className:Sn.axisHint,children:qt("graph3dUi.intersectionResultExplainer")}),br(Cn,{tone:"danger",size:"sm",onClick:()=>i(t.id),children:[Bt(Ro,{size:14})," ",qt("graph3dUi.deleteIntersection")]})]})});pei=$ye(function({result:t,color:n}){let r=Z2(null);return pF(()=>{kAt(r.current,t.drawing,n)},[n,t.drawing]),br("div",{className:Sn.objectOverview,children:[br("div",{className:Sn.objectThumbnailFrame,children:[Bt("canvas",{ref:r,className:Sn.objectThumbnail,role:"img","aria-label":qt("graph3dUi.intersectionPreview")}),!t.drawing&&Bt("span",{className:Sn.objectThumbnailFallback,children:"\u2014"})]}),Bt("div",{className:Sn.objectOverviewText,children:Bt("span",{className:Sn.widgetSummary,children:t.status})})]})});fei={expression:"x^2+y^2",equation:"x+y=1",inequality:"x+y+z \\leqq 3"};yei=$ye(function({annotation:t,onChange:n,onDelete:r}){return br(Cte,{label:qt("graph3dFormat.details",{name:t.kind==="dimension"?qt("graph3dUi.dimensionLine"):qt("graph3dUi.mathLabel")}),title:Bt("strong",{children:t.kind==="dimension"?qt("graph3dUi.dimensionLine"):qt("graph3dUi.mathLabel")}),summary:Bt(wP,{tex:t.labelTex,ariaLabel:qt("graph3dUi.labelFormula"),placeholderTex:"\\ell",onCommit:o=>n({...t,labelTex:o})}),controls:t.kind==="dimension"?br(fr,{className:Sn.dimensionStyle,gap:"sm",wrap:!0,align:"end",children:[Bt(aKn,{lineStyle:t.lineStyle??"solid",endStyle:aK(t.endStyle),onLineStyleChange:o=>n({...t,lineStyle:o}),onEndStyleChange:o=>n({...t,endStyle:o})}),Bt(dF,{label:qt("graph3dUi.lineWidth"),value:t.lineWidth??1.5,min:.5,max:12,step:.5,onChange:o=>n({...t,lineWidth:o})})]}):void 0,children:[Bt(Mj,{label:qt("graph3dUi.textAndLineColor"),value:t.color??"#1f2937",onChange:o=>n({...t,color:o})}),t.kind==="label"?Bt(TP,{rows:[{label:qt("graph3dUi.showCoordinates"),vector:t.position,onChange:o=>n({...t,position:o})}]}):Bt(TP,{rows:[{label:qt("graph3dUi.startPoint"),vector:t.from,onChange:o=>n({...t,from:o})},{label:qt("graph3dUi.endPoint"),vector:t.to,onChange:o=>n({...t,to:o})}]}),br(Cn,{tone:"danger",size:"sm",onClick:()=>r(t.id),children:[Bt(Ro,{size:14})," ",qt("graph3dUi.deleteAnnotation")]})]})})});function vei(e){return Bd(e)||e.type==="tableShape"}function dKn({shapes:e,point:t,isUnselectable:n,editPolicyLockedIds:r,margin:o=0}){let i=e;for(let a of RK(i))if(!(!Bd(a)||n(a.id)||Ac(i,a)||Js(i,a,r)||!qv(a,t,o)))return a}function E9e(e,t){return vei(e)?e:t()??e}var I9e=X(()=>{"use strict";Pn();Tc()});import{useCallback as Zye,useEffect as Sei}from"react";function pKn({shapesRef:e,selectedIdsRef:t,editPolicyLockedShapeIdsRef:n,notifyEditPolicyBlocked:r,setShapes:o,transitionMode:i,queueOverlaySave:a,extendedActionRunnerRef:s,applyQuickTransformToSelectedShapes:l,startImageCrop:c,requestImageReplacement:u,resetImageCrop:d,restoreImageNaturalSize:p,createChartFromTable:f,handleCurveDrawingDoubleClick:m,suppressNextShapeDoubleClickRef:h,graphFillPickShapeId:g,pagePointFromClient:y,focusedGroupIdRef:b,setFocusedGroupId:x,setSelectedShapeIds:v,selectShape:S,modeRef:F,getShapeAtPoint:w,getOpenStrokeShapeAtPoint:C,getEditableTextShapeAtPoint:A,setContextMenu:T,focusOverlayCanvas:D}){let k=Zye(L=>{let _=AA(e.current,t.current)[0];if(!_||t.current.length!==1||!yj(_))return;if(Ac(e.current,_)||Js(e.current,_,n.current)){Js(e.current,_,n.current)&&r();return}let R=DXn(_,L);R&&(o(O=>{let N=Qr(O.map(z=>z.id===_.id?R:z));return e.current=N,N}),i({type:"select"}),a())},[n,r,a,t,o,e,i]);Sei(()=>{s.current=L=>{if(L.type==="transform"){l(L.action);return}if(L.type==="changeShapeType"){k(L.command);return}if(L.type!=="shapeCommand")return;let[_]=AA(e.current,t.current);if(!(!_||t.current.length!==1))switch(L.command){case"imageCrop":_.type==="image"&&c(_.id);break;case"imageReplace":_.type==="image"&&u(_.id);break;case"imageResetCrop":_.type==="image"&&d(_.id);break;case"imageNaturalSize":_.type==="image"&&p(_.id);break;case"chartFromTable":_.type==="tableShape"&&f(_.id);break;case"chartSettings":_.type==="chartShape"&&window.dispatchEvent(new CustomEvent(w_,{detail:{shapeId:_.id}}));break;case"graph3dSettings":_.type==="graph3dShape"&&(i({type:"editGraph3D",shapeId:_.id}),window.dispatchEvent(new CustomEvent(lE,{detail:{shapeId:_.id}})));break;case"graphSettings":_.type==="graph2dShape"&&window.dispatchEvent(new CustomEvent(Pj,{detail:{shapeId:_.id}}));break;case"graphCrop":_.type==="graph2dShape"&&i({type:"editGraph",shapeId:_.id});break;case"graphOriginPick":_.type==="graph2dShape"&&i({type:"pickOrigin",shapeId:_.id});break;case"graphFillPick":_.type==="graph2dShape"&&_.props.spec.kind==="cartesian"&&i({type:"pickGraphFill",shapeId:_.id});break}}},[l,k,f,s,u,d,p,t,e,c,i]);let P=Zye((L,_)=>{if(m(L))return;if(window.performance.now()-h.current<500){L.preventDefault(),L.stopPropagation();return}if(g)return;let R=y(L.clientX,L.clientY),O=_.type==="graph2dShape"?0:FNe(_)?wei:8;if(!qv(_,R,O))return;let N=E9e(_,()=>A(R)),z=cF(e.current,N.id,b.current),U=z.length===1?e.current.find(H=>H.id===z[0]):null;if(U&&wh(U)&&b.current!==U.id){x(U.id),v(cF(e.current,N.id,U.id)),i({type:"select"});return}S(N.id),!Ac(e.current,N)&&(Bd(N)?i({type:"editText",shapeId:N.id}):N.type==="image"?i({type:"editImageCrop",shapeId:N.id}):N.type==="graph2dShape"?(L.preventDefault(),L.stopPropagation(),i({type:"editGraph",shapeId:N.id})):N.type==="graph3dShape"?(L.preventDefault(),L.stopPropagation(),i({type:"editGraph3D",shapeId:N.id}),window.dispatchEvent(new CustomEvent(lE,{detail:{shapeId:N.id}}))):N.type==="tableShape"?i({type:"editTable",shapeId:N.id}):N.type==="chartShape"&&(L.preventDefault(),L.stopPropagation(),window.dispatchEvent(new CustomEvent(w_,{detail:{shapeId:N.id}}))))},[b,A,g,m,y,S,x,v,e,h,i]),I=Zye(L=>{if(L.defaultPrevented)return;if(F.current.id==="overlay.curveDrawing"){m(L);return}let _=y(L.clientX,L.clientY),R=w(_,8)??C(_);R&&(L.preventDefault(),L.stopPropagation(),P(L,R))},[C,w,m,P,F,y]),B=Zye(L=>{let _=L.target instanceof Element?L.target:null;if(L.defaultPrevented&&!_?.closest(".overlay-graph3d-live-window")||_?.closest(".overlay-table-context-menu"))return;let R=y(L.clientX,L.clientY),O=w(R,8)??C(R);if(!O){T(null);return}L.preventDefault(),L.stopPropagation(),D();let N=b.current;N&&O.id!==N&&!hte(e.current,O.id,N)&&(b.current=null,x(null));let z=cF(e.current,O.id,b.current),U=new Set(t.current);z.some(H=>U.has(H))||v(z),i({type:"select"}),T({x:Yo(L.clientX,8,Math.max(8,window.innerWidth-232)),y:Yo(L.clientY,8,Math.max(8,window.innerHeight-360)),shapeId:z[0]??O.id})},[D,b,C,w,y,t,T,x,v,e,i]),M=Zye(L=>{L(),T(null),D()},[D,T]);return{handleCanvasContextMenu:B,handleCanvasDoubleClick:I,handleShapeDoubleClick:P,runContextMenuAction:M,changeSelectedShapeType:k}}var wei,fKn=X(()=>{"use strict";"use client";sE();Bj();Pn();Tc();jh();fte();dj();I9e();wei=14});function gs(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((a,s)=>gs(a,t[s]));let n=e,r=t,o=Object.keys(n).filter(a=>n[a]!==void 0),i=Object.keys(r).filter(a=>r[a]!==void 0);return o.length!==i.length?!1:o.every(a=>Object.prototype.hasOwnProperty.call(r,a)&&gs(n[a],r[a]))}var C_=X(()=>{"use strict"});import{useCallback as mKn,useEffect as Fei,useLayoutEffect as Cei}from"react";function hKn({setPreview:e,clearQueuedOverlaySave:t,imageCropDirtyRef:n,suppressNextSaveRef:r,modeRef:o,selectedIdsRef:i,shapesRef:a,assetsRef:s,extensionsRef:l,setShapes:c,setAssets:u,setSelectedIds:d,setAppliedSnapshotRevision:p,transitionMode:f,activeTextEditorRef:m,anchorMeasurementsRef:h,overlay:g,reconciledDocumentSnapshotRef:y,lastEmittedSnapshotRef:b,saveTimeoutRef:x,pendingOverlayHistoryRef:v,externalRevisionRef:S,externalRevision:F,seenDocumentSnapshotRef:w,mode:C}){let A=mKn(D=>{e(null),t(),n.current=!1,r.current=!0;let k=o.current,P=k.id==="overlay.textEditing"?k.shapeId:null,I=Qr(F0(D.shapes,h.current.rects,Qx(D.shapes))),B=new Set(I.map(R=>R.id)),M=P?I.find(R=>R.id===P&&Bd(R)):null,L=i.current.filter(R=>B.has(R)),_=k.id==="overlay.graph3dEditing"&&I.some(R=>R.id===k.shapeId&&R.type==="graph3dShape")?k.shapeId:null;if(a.current=I,s.current=D.assets,l.current=D.extensions,i.current=M?[M.id]:L,c(I),u(D.assets),d(i.current),p(R=>R+1),M)f({type:"editText",shapeId:M.id});else{let R=m.current;R&&!R.isDestroyed&&R.commands.blur(),m.current=null,f({type:"select"}),_&&f({type:"editGraph3D",shapeId:_})}},[m,h,s,t,l,n,o,i,p,u,e,d,c,a,r,f]),T=mKn(()=>{let D=g.overlaySnapshot;if(y.current===D||!D){y.current=D;return}let k=b.current;if(k&&D.shapes===k.shapes&&D.assets===k.assets){y.current=D;return}if(o.current.id!=="overlay.select"||x.current!==void 0||v.current)return;y.current=D;let P=ir(D);gs(Qr(P.shapes),a.current)&&gs(P.assets,s.current)||A(P)},[A,s,b,o,g.overlaySnapshot,v,y,x,a]);Cei(()=>{let D=g.overlaySnapshot,k=S.current!==F,P=w.current!==D;if(S.current=F,w.current=D,k){y.current=D,A(ir(D));return}P&&T()},[A,F,S,g.overlaySnapshot,T,y,w]),Fei(()=>{C.id==="overlay.select"&&T()},[C.id,T])}var gKn=X(()=>{"use strict";"use client";Dt();Pn();C_();v_();Tc()});var Lj,P9e=X(()=>{"use strict";Lj="sigma:open-tikz-editor"});function yKn(e,t,n){let r=new Set(t);if(r.size===0)return[];let o=new Set(e.filter(i=>i.anchor?.type==="block"&&r.has(i.anchor.blockId)).map(i=>i.id));for(let i of Tei(r,n))for(let a of e)!o.has(a.id)&&xke(a,i)&&o.add(a.id);return o.size===0?[]:xKn(e,Dei(e,o))}function bKn(e){return xKn(e,e.map(t=>t.id))}function xKn(e,t){let n=new Set([...t].map(r=>BCt(e,r,null)));return _5(e).filter(r=>n.has(r.id)).map(r=>r.id)}function Tei(e,t){if(!t)return[];let n=new Map;for(let o of e){let i=t.get(o);if(!i||i.left===void 0||!i.width||!i.height)continue;let a=`${Math.round(i.left)}:${Math.round(i.width)}`,s={x:i.left,y:i.top,w:i.width,h:i.height},l=n.get(a);l?l.push(s):n.set(a,[s])}let r=[];for(let o of n.values()){o.sort((i,a)=>i.y-a.y);for(let i of o){let a=r.at(-1);a&&a.x===i.x&&a.w===i.w&&i.y<=a.y+a.h+Aei?a.h=Math.max(a.h,i.y+i.h-a.y):r.push({...i})}}return r}function Dei(e,t){let n=[...new Set(t)];for(let r=0;r<4;r+=1){let o=kei(e,KDe(e,n));if(o.length===n.length)return o;n=o}return n}function kei(e,t){let n=new Set(t);for(let r=0;r<4;r+=1){let o=n.size;for(let i of e)i.anchor?.type==="shape"&&n.has(i.anchor.shapeId)&&n.add(i.id);if(n.size===o)break}return[...n]}var Aei,vKn=X(()=>{"use strict";Pn();Tc();Aei=4});function Eei(e){switch(e.type){case"startMove":case"startResize":case"startRotate":return e.shapes.map(t=>t.id);case"startAnchorDrag":case"startPoint":case"startImageCropResize":case"startImageCropPan":return[e.shape.id];case"editText":case"editImageCrop":case"editGraph":case"editGraph3D":case"editTable":case"pickOrigin":case"pickGraphFill":return[e.shapeId];default:return[]}}function SKn(e,t,n){if(n.size===0)return!1;let r=Eei(e);if(r.length===0)return!1;let o=new Map(t.map(i=>[i.id,i]));return r.some(i=>{let a=o.get(i);return a?Js(t,a,n):!1})}function Wh(e,t,n){if(n.size===0||t.length===0)return!1;let r=By(e,t,{includeGroups:!0}),o=new Map(e.map(i=>[i.id,i]));return r.some(i=>{let a=o.get(i);return a?Js(e,a,n):!1})}function Hte(e,t){return t?.has(e)??!1}function Rj(e,t,n=[]){return!t||t.size===0?e:e.filter(r=>!t.has(r)&&!By(n,[r],{includeGroups:!0}).some(o=>t.has(o)))}function wKn(e,t,n){let r=Rj(e,n,t);return r.length===e.length?null:r}var A_=X(()=>{"use strict";Tc()});function Gte(){if(typeof window>"u")return _j;try{let e=window.localStorage.getItem(FKn);e!==null&&(_j=Oke(JSON.parse(e)))}catch{}return _j}function CKn(e){if(_j=Oke(e),typeof window<"u")try{window.localStorage.setItem(FKn,JSON.stringify(_j))}catch{}for(let t of EAt)t(_j);return _j}function AKn(e){return EAt.add(e),()=>{EAt.delete(e)}}var FKn,_j,EAt,M9e=X(()=>{"use strict";Pn();FKn="sigma-studio:overlay-shape-style-defaults",_j=nrn;EAt=new Set});function B9e(e){let{shapes:t,marquee:n,focusedGroupId:r,currentIds:o,additive:i}=e,a=pDe(t).filter(s=>xke(s,n)).flatMap(s=>cF(t,s.id,r));return[...new Set(i?[...o,...a]:a)]}var IAt=X(()=>{"use strict";Pn();Tc()});function L9e(e){return e.isComposing||e.key==="Process"||e.keyCode===229}function PAt(e,t,n){let r=new Map(e.map(o=>[o.id,o]));for(let o=0;o<t.length;o+=1){let i=t[o],a=n[o];if(!i||!a)continue;let s=a.x-i.x,l=a.y-i.y;if(s===0&&l===0)continue;let c=wh(i)?By(e,[i.id],{includeGroups:!0}):[i.id];for(let u of c){let d=r.get(u);d&&!Ac(e,d)&&r.set(u,$5(d,s,l))}}return e.map(o=>r.get(o.id)??o)}function DKn(e){let t={...e};return delete t.locked,delete t.hidden,t}function kKn(e){if(e.anchor?.type!=="page")return e;let t={...e};return delete t.anchor,t}function g1(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return e instanceof HTMLInputElement&&(e.type==="file"||e.type==="hidden")?!1:t==="input"||t==="textarea"||e.closest("[contenteditable='true'], math-field")!==null}function jte(e,t,n){let r=new Set(By(e,t,{includeGroups:!1})),o=new Set;for(let i of e)r.has(i.id)&&!Ac(e,i)&&!Js(e,i,n)&&o.add(i.id);return o}var TKn,Vte=X(()=>{"use strict";Pn();Tc();TKn="[data-non-modal-surface], [data-toolbar-popover]"});import{useCallback as EKn,useEffect as IKn}from"react";function PKn({handledActionRequestIdRef:e,duplicateSelectedShapes:t,deleteSelectedShapes:n,arrangeSelectedShapes:r,alignSelectedShapes:o,distributeSelectedShapes:i,groupSelectedShapes:a,ungroupSelectedShapes:s,shapesRef:l,selectedIdsRef:c,setSelectedShapesLocked:u,setSelectedShapesHidden:d,setPreview:p,editPolicyLockedShapeIdsRef:f,editPolicyUnselectableShapeIdsRef:m,solidEdgeRef:h,learnShapeStyleDefaults:g,applyStyleToSelectedShapes:y,applyPastedOverlayShapes:b,setFocusedGroupId:x,setSelectedShapeIds:v,refreshAnchorMeasurements:S,transitionMode:F,extendedActionRunnerRef:w,activeTextEditorRef:C,createShapeFromInsertDrag:A,onActionHandled:T,actionRequest:D,handledSelectPointRequestIdRef:k,focusOverlayCanvas:P,onSelectPointHandled:I,getShapeAtPoint:B,getOpenStrokeShapeAtPoint:M,getEditableTextShapeAtPoint:L,focusedGroupIdRef:_,setShapes:R,queueOverlaySave:O,selectShape:N,documentId:z,selectPointRequest:U,openShapeContextMenu:H}){let V=EKn(Z=>{if(e.current!==Z.id){if(e.current=Z.id,Z.type==="duplicate")t();else if(Z.type==="delete")n();else if(Z.type==="arrange")r(Z.action);else if(Z.type==="align")o(Z.action);else if(Z.type==="distribute")i(Z.axis);else if(Z.type==="group")a();else if(Z.type==="ungroup")s();else if(Z.type==="toggleLock"){let ee=AA(l.current,c.current),J=ee.length>0&&ee.every(te=>Ac(l.current,te));u(!J)}else if(Z.type==="toggleHidden"){let ee=AA(l.current,c.current),J=ee.length>0&&ee.every(te=>mte(l.current,te));d(!J)}else if(Z.type==="style"){if(p(null),jte(l.current,c.current,f.current).size>0){let ee=h.current?{...Z.style,dash:void 0,size:void 0}:Z.style;g(orn(Gte(),ee))}y(Z.style)}else Z.type==="pasteShapes"?b(Z.payload,{anchorBlockIdMap:Z.anchorBlockIdMap,historyGroup:Z.historyGroup,centerAt:Z.centerAt,unbounded:Z.unbounded,pointerClient:Z.pointerClient}):Z.type==="selectShapesForBlocks"?(x(null),v(Z.allShapes?bKn(l.current):yKn(l.current,Z.blockIds,S().rects)),F({type:"select"})):Z.type==="transform"||Z.type==="changeShapeType"||Z.type==="shapeCommand"?w.current?.(Z):Z.type==="insertTextAtPoint"&&(C.current?.commands.blur(),A({kind:"insert",command:"text"},Z.point,Z.point));T(Z.id)}},[e,T,t,n,r,o,i,a,s,l,c,u,d,p,f,y,h,g,b,x,v,S,F,w,C,A]);IKn(()=>{if(D){let Z=window.setTimeout(()=>V(D),0);return()=>window.clearTimeout(Z)}},[D,V]);let ne=EKn(Z=>{if(k.current===Z.id)return;if(k.current=Z.id,Z.startMarquee){if(P(),Z.dragEndPoint){let K=Z.dragEndPoint;if(Math.hypot(K.x-Z.point.x,K.y-Z.point.y)>=3)v(Rj(B9e({shapes:l.current,marquee:{x:Math.min(Z.point.x,K.x),y:Math.min(Z.point.y,K.y),w:Math.abs(K.x-Z.point.x),h:Math.abs(K.y-Z.point.y)},focusedGroupId:_.current,currentIds:c.current,additive:!0}),m?.current));else{let G=B(K,8)??M(K);G?N(G.id):v([])}F({type:"select"}),I(Z.id,!0);return}F({type:"startMarquee",start:Z.point,additive:!0,selectOnClick:!0}),I(Z.id,!0);return}let ee=Z.targetShapeId?l.current.find(K=>K.id===Z.targetShapeId&&!wh(K)&&!mte(l.current,K)&&!Hte(K.id,m?.current)):void 0,J=ee??B(Z.point,8)??M(Z.point),te=J&&Z.startCrop&&!ee?E9e(J,()=>L(Z.point)):J;if(te){if(C.current?.commands.blur(),C.current=null,P(),Z.dragEndPoint){let K=Z.dragEndPoint.x-Z.point.x,G=Z.dragEndPoint.y-Z.point.y;if(Math.hypot(K,G)>=3){let ie=cF(l.current,te.id,_.current),fe=$x(l.current,ie,f.current);if(fe.length>0){let $=new Set(fe.map(re=>re.id)),j=Y9(fe,K,G),{ordered:pe}=S();v(ie),R(re=>{let le=Qr(Jx(Wv(re,j),$,pe));return l.current=le,le}),F({type:"select"}),I(Z.id,!0),O();return}}}F({type:"select"}),N(te.id),Z.openContextMenu&&Z.screenPoint&&H?.(Z.screenPoint,te.id),te.type==="image"&&te.props.tikz&&!te.locked&&!f.current.has(te.id)&&Z.dragEndPoint&&Math.hypot(Z.dragEndPoint.x-Z.point.x,Z.dragEndPoint.y-Z.point.y)<3&&window.dispatchEvent(new CustomEvent(Lj,{detail:{documentId:z,shapeId:te.id}})),Z.startCrop&&te.type==="graph2dShape"?F({type:"editGraph",shapeId:te.id}):Z.startCrop&&Bd(te)?F({type:"editText",shapeId:te.id}):Z.startCrop&&te.type==="tableShape"&&F({type:"editTable",shapeId:te.id}),I(Z.id,!0)}else v([]),F({type:"select"}),I(Z.id,!1)},[k,l,B,M,L,P,F,I,C,N,f,m,_,S,v,R,O,z,H,c]);IKn(()=>{if(U){let Z=window.setTimeout(()=>ne(U),0);return()=>window.clearTimeout(Z)}},[ne,U])}var MKn=X(()=>{"use strict";"use client";Pn();P9e();vKn();I9e();A_();Tc();Ly();M9e();IAt();Vte()});function BKn(e){let t=new Map,n;return(r,o)=>{let i=new Map(r.map(p=>[p.id,p])),a=r.filter(p=>p.type==="graph2dShape"),s=n?.width!==o.width||n?.height!==o.height,l=new Set(a.filter(p=>{let f=t.get(p.id);return s||!f||Array.from(f).some(([m,h])=>i.get(m)!==h)}).map(p=>p.id)),c=l.size>0?Pei(r,e,o,l):r,u=a.length>0?Md(c):c,d=new Map(u.map(p=>[p.id,p]));return t=new Map(u.filter(p=>p.type==="graph2dShape").map(p=>[p.id,Iei(p,d)])),n={...o},u}}function Iei(e,t){let n=new Map,r=e.props,o=[e.id,...Object.values(r.axisLabelTextShapeIds??{}),...Object.values(r.pointLabelTextShapeIdsByPointId??{}),...Object.values(r.annotationTextShapeIdsByAnnotationId??{}),...Object.values(r.labelTextShapeIdsByCurveId??{}),...r.labelTextShapeIds??[]];for(;o.length>0;){let i=o.pop();if(i===void 0||n.has(i))continue;let a=t.get(i);n.set(i,a),a?.parentId&&o.push(a.parentId),a?.anchor?.type==="shape"&&o.push(a.anchor.shapeId)}return n}function Pei(e,t,n={width:1600,height:1200},r){let o=e,i=new Map,a=[];for(let l of e){if(l.type!=="graph2dShape"||r&&!r.has(l.id))continue;let c=l,u=mD(c,e),d=Mei(c,u);if(d.length>0){let g=pte(c,t,{keys:d});if(g.length>0){let y={...u,...Object.fromEntries(g.map(b=>[b.key,b.shape.id]))};u=y,c=Xte(c,y),a.push(...g.map(b=>b.shape))}}Bei(c,u)&&(c=Wte(c));let p=Qye(c,e),f=(c.props.spec.points??[]).filter(g=>!!g.label?.trim()).map(g=>g.id).filter(g=>!p[g]);if(f.length>0){let g=p_(c,t,{pointIds:f});if(g.length>0){let y={...p,...Object.fromEntries(g.map(b=>[b.pointId,b.shape.id]))};c=tbe(c,y),a.push(...g.map(b=>b.shape))}}let m=ebe(c,e),h=(c.props.spec.annotations??[]).filter(g=>!!g.text.trim()).map(g=>g.id).filter(g=>!m[g]);if(h.length>0){let g=f_(c,t,{annotationIds:h});if(g.length>0){let y={...m,...Object.fromEntries(g.map(b=>[b.annotationId,b.shape.id]))};c=nbe(c,y),a.push(...g.map(b=>b.shape))}}if(c.props.spec.showFormulaLabels===!0){let g=Oj(c,e),y=c.props.spec.curves.map(b=>b.id).filter(b=>!g[b]);if(y.length>0){let b=dte(c,t,n,{curveIds:y});b.length>0&&(c=T_(c,{...g,...Object.fromEntries(b.map(x=>[x.curveId,x.shape.id]))}),a.push(...b.map(x=>x.shape)))}}c=xB(c),c!==l&&i.set(l.id,c)}(i.size>0||a.length>0)&&(o=Qr(e.map(l=>i.get(l.id)??l).concat(a)));let s=o;for(let l of s){if(l.type!=="graph2dShape"||r&&!r.has(l.id))continue;let c=i.get(l.id)??l;s=Nj(s,c)}return s}function Mei(e,t){let n=[];return e.props.spec.axes.xLabel?.trim()&&!t.x&&n.push("x"),e.props.spec.axes.yLabel?.trim()&&!t.y&&n.push("y"),e.props.spec.axes.originLabel?.trim()&&!t.origin&&n.push("origin"),n}function Bei(e,t){let n=[];return e.props.spec.axes.xLabel?.trim()&&n.push("x"),e.props.spec.axes.yLabel?.trim()&&n.push("y"),e.props.spec.axes.originLabel?.trim()&&n.push("origin"),n.length>0&&n.every(r=>!!t[r])}function Jye(e,t){return[...Object.values(mD(e,t)).filter(n=>typeof n=="string"),...Object.values(Qye(e,t)),...Object.values(ebe(e,t)),...R9e(e.props.spec,Oj(e,t))]}function LKn(e,t){if(t.length!==1)return null;let n=e.find(r=>r.id===t[0]);return n?.type===lF?n:!n||!ace(n,e)?null:e.find(r=>r.type===lF&&Jye(r,e).includes(n.id))??null}function Qye(e,t){let n=RKn(t),r=new Set((e.props.spec.points??[]).map(i=>i.id)),o={};for(let[i,a]of Object.entries(e.props.pointLabelTextShapeIdsByPointId??{}))!r.has(i)||!n.has(a)||(o[i]=a);return o}function ebe(e,t){let n=RKn(t),r=new Set((e.props.spec.annotations??[]).map(i=>i.id)),o={};for(let[i,a]of Object.entries(e.props.annotationTextShapeIdsByAnnotationId??{}))!r.has(i)||!n.has(a)||(o[i]=a);return o}function Oj(e,t){let n=new Set(t.filter(c=>c.type==="text").map(c=>c.id)),r=new Set(e.props.spec.curves.map(c=>c.id)),o=new Set,i={};for(let[c,u]of Object.entries(e.props.labelTextShapeIdsByCurveId??{}))!r.has(c)||!n.has(u)||(i[c]=u,o.add(u));let a=(e.props.labelTextShapeIds??[]).filter(c=>n.has(c)&&!o.has(c)),s=cXn(e.props.spec).map(c=>c.curveId),l=0;for(let c of s){if(i[c])continue;let u=a[l];if(!u)break;i[c]=u,l+=1}return i}function T_(e,t){return{...e,props:{...e.props,labelTextShapeIds:R9e(e.props.spec,t),labelTextShapeIdsByCurveId:t}}}function Xte(e,t){return{...e,props:{...e.props,axisLabelTextShapeIds:t}}}function tbe(e,t){return{...e,props:{...e.props,pointLabelTextShapeIdsByPointId:t}}}function nbe(e,t){return{...e,props:{...e.props,annotationTextShapeIdsByAnnotationId:t}}}function Wte(e){return{...e,props:{...e.props,spec:{...e.props.spec,axes:{...e.props.spec.axes,xLabel:"",yLabel:"",originLabel:""}}}}}function Nj(e,t,n={}){let r={...t,props:{...t.props,spec:h9(t,e)}},o=mD(t,e),i=pte(r,()=>"",{keys:Object.keys(o).filter(RTe)}),a=Qye(t,e),s=p_(r,()=>"",{pointIds:Object.keys(a)}),l=ebe(t,e),c=f_(r,()=>"",{annotationIds:Object.keys(l)}),u=[...i.map(m=>({key:`axis:${m.key}`,shape:m.shape})),...s.map(m=>({key:`point:${m.pointId}`,shape:m.shape})),...c.map(m=>({key:`annotation:${m.annotationId}`,shape:m.shape}))],d=new Map(u.map(m=>[m.key,m.shape])),p=!1,f=e.map(m=>{if(m.type!=="text")return m;let h=Lei(m.id,o,a,l);if(!h)return m;let g=d.get(h);if(!g)return m.hidden?m:(p=!0,{...m,hidden:!0});let y=g.anchor;if(!y||y.type!=="shape")return m;if(n.preserveExistingPositions){let w=lXn(t,m,g),C=w.anchor;if(!C||C.type!=="shape")return m;let A=Zx(C,m.anchor),T=w.hidden===m.hidden||w.hidden===void 0&&!m.hidden,D=w.x===void 0||w.x===m.x,k=w.y===void 0||w.y===m.y;return A&&T&&D&&k?m:(p=!0,{...m,...w})}let b=m.anchor?.type==="shape"&&m.anchor.shapeId===t.id?{...y,dx:m.anchor.dx,dy:m.anchor.dy}:{...y,dx:y.dx+m.x-g.x,dy:y.dy+m.y-g.y},x=Zx(b,m.anchor),v=!m.hidden;if(x&&v)return m;let S=g.x+b.dx-y.dx,F=g.y+b.dy-y.dy;return p=!0,{...m,x:S,y:F,hidden:void 0,anchor:b}});return Md(p?f:e)}function RKn(e){return new Set(e.filter(t=>t.type==="text").map(t=>t.id))}function Lei(e,t,n,r){let o=Rei(t,e);if(o)return`axis:${o}`;for(let[i,a]of Object.entries(n))if(a===e)return`point:${i}`;for(let[i,a]of Object.entries(r))if(a===e)return`annotation:${i}`;return null}function Rei(e,t){for(let[n,r]of Object.entries(e))if(r===t&&RTe(n))return n;return null}function R9e(e,t){return e.curves.map(n=>t[n.id]).filter(n=>typeof n=="string")}var D_=X(()=>{"use strict";Dt();My();Tc();Ly();Yx()});import{useEffect as _Kn}from"react";function OKn({shapes:e,selectedIds:t,shapesRef:n,setShapes:r,originPickShapeId:o,graphFillPickShapeId:i,setSelectedShapeIds:a,transitionMode:s,setGraphAxisLabelText:l,setGraphAxisLabelTextVisible:c,setGraphCurveFormulaLabelTextVisible:u}){_Kn(()=>{let d=LKn(e,t);if(!d){window.dispatchEvent(new CustomEvent(Ij,{detail:null}));return}let p=d.id,f=mD(d,e),m=LTe(d,e),h=Oj(d,e),g=h9(d,e),y={shapeId:p,spec:g,axisLabelShapeIdsByKey:f,axisLabelTextsByKey:m,formulaLabelShapeIds:R9e(d.props.spec,h),formulaLabelShapeIdsByCurveId:h,pickingOrigin:o===p,pickingFill:i===p,onSpecChange:b=>{r(x=>{let v=x.find(ie=>ie.id===p&&ie.type==="graph2dShape");if(!v)return x;let S=h9(v,x),F=new Set(b.curves.map(ie=>ie.id)),w=Oj(v,x),C={},A=[];for(let[ie,fe]of Object.entries(w))F.has(ie)?C[ie]=fe:A.push(fe);let T=new Map((S.points??[]).map(ie=>[ie.id,ie.label?.trim()??""])),D=new Map((b.points??[]).map(ie=>[ie.id,ie.label?.trim()??""])),k=new Set((b.points??[]).filter(ie=>!!ie.label?.trim()).map(ie=>ie.id)),P=Qye(v,x),I={},B=[];for(let ie of k){let fe=P[ie];fe?I[ie]=fe:B.push(ie)}for(let[ie,fe]of Object.entries(P))k.has(ie)||A.push(fe);let M=new Map((S.annotations??[]).map(ie=>[ie.id,ie.text.trim()])),L=new Map((b.annotations??[]).map(ie=>[ie.id,ie.text.trim()])),_=new Set((b.annotations??[]).filter(ie=>!!ie.text.trim()).map(ie=>ie.id)),R=ebe(v,x),O={},N=[];for(let ie of _){let fe=R[ie];fe?O[ie]=fe:N.push(ie)}for(let[ie,fe]of Object.entries(R))_.has(ie)||A.push(fe);let z=Ele(v,b),U=T_({...v,props:{...v.props,spec:b,boundsMode:"plot",w:z.w,h:z.h}},C),H=p_(U,ff,{pointIds:B});for(let ie of H)I[ie.pointId]=ie.shape.id;U=tbe(U,I);let V=f_(U,ff,{annotationIds:N});for(let ie of V)O[ie.annotationId]=ie.shape.id;U=nbe(U,O);let ne=[...k].filter(ie=>T.get(ie)!==D.get(ie)&&!!I[ie]),Z=new Map(p_(U,()=>"",{pointIds:ne}).map(ie=>[I[ie.pointId],ie.shape.props])),ee=[..._].filter(ie=>M.get(ie)!==L.get(ie)&&!!O[ie]),J=new Map(f_(U,()=>"",{annotationIds:ee}).map(ie=>[O[ie.annotationId],ie.shape.props]));U=xB(U);let te=new Set(A),K=x.filter(ie=>!te.has(ie.id)).map(ie=>{if(ie.id===p)return U;if(ie.type!=="text")return ie;let fe=Z.get(ie.id)??J.get(ie.id);return fe?{...ie,props:{...ie.props,...CNe(fe)}}:ie}).concat(H.map(ie=>ie.shape)).concat(V.map(ie=>ie.shape)),G=Nj(K,U);return n.current=G,G})},onStartOriginPick:()=>{a([p]),s({type:"pickOrigin",shapeId:p})},onStartFillPick:()=>{a([p]),s(i===p?{type:"select"}:{type:"pickGraphFill",shapeId:p})},onAxisLabelChange:(b,x)=>c(p,b,x),onAxisLabelTextChange:(b,x)=>l(p,b,x),onFormulaLabelChange:(b,x)=>u(p,b,x),onStartCrop:()=>{a([p]),s({type:"editGraph",shapeId:p})},onClose:()=>a([])};window.dispatchEvent(new CustomEvent(Ij,{detail:y}))},[i,o,t,l,c,u,a,e,r,n,s]),_Kn(()=>()=>{window.dispatchEvent(new CustomEvent(Ij,{detail:null}))},[])}var NKn=X(()=>{"use strict";"use client";sE();Yx();D_();tE()});import{useCallback as _9e,useEffect as _ei}from"react";function zKn({setShapes:e,canvasWidthRef:t,canvasHeightRef:n,shapesRef:r,queueOverlaySave:o,selectedIds:i,shapes:a,originPickShapeId:s,graphFillPickShapeId:l,setSelectedShapeIds:c,transitionMode:u}){let d=_9e((h,g,y)=>{e(b=>{let x=b.find(A=>A.id===h&&A.type==="graph2dShape");if(!x)return b;let v=Oj(x,b),S=v[g];if(y){if(S)return b;let A=x.props.spec.curves.map(B=>B.id).filter(B=>B===g||!!v[B]),D=dte(x,ff,{width:t.current,height:n.current},{curveIds:A}).find(B=>B.curveId===g);if(!D)return b;let k={...v,[g]:D.shape.id},P=T_(x,k),I=b.map(B=>B.id===h?P:B).concat(D.shape);return r.current=I,I}if(!S)return b;let F={...v};delete F[g];let w=new Set([S]),C=b.filter(A=>!w.has(A.id)).map(A=>A.id!==h||A.type!=="graph2dShape"?A:T_(A,F));return r.current=C,C}),o()},[n,t,o,e,r]),p=_9e((h,g,y)=>{e(b=>{let x=b.find(A=>A.id===h&&A.type==="graph2dShape");if(!x)return b;let v=mD(x,b),S=v[g];if(y){if(S)return b;let A=pte(x,ff,{keys:[g]})[0];if(!A)return b;let T={...v,[g]:A.shape.id},D=Xte(Wte(x),T),k=b.map(P=>P.id===h?D:P).concat(A.shape);return r.current=k,k}let F={...v};delete F[g];let w=new Set(S?[S]:[]),C=b.filter(A=>!w.has(A.id)).map(A=>A.id!==h||A.type!=="graph2dShape"?A:Xte(Wte(A),F));return r.current=C,C}),o()},[o,e,r]),f=_9e((h,g,y)=>{let b=y.trim();e(x=>{let v=x.find(k=>k.id===h&&k.type==="graph2dShape");if(!v)return x;let S=mD(v,x),F=S[g];if(!b){let k={...S};delete k[g];let P=new Set(F?[F]:[]),I=x.filter(B=>!P.has(B.id)).map(B=>B.id!==h||B.type!=="graph2dShape"?B:Xte(Wte(B),k));return r.current=I,I}let w=pte(v,()=>F??ff(),{keys:[g],labelsByKey:{[g]:b}})[0];if(!w)return x;let C={...S,[g]:w.shape.id},A=Xte(Wte(v),C),T=x.map(k=>k.id===h?A:k.id!==F||k.type!=="text"?k:{...k,props:{...k.props,...CNe(w.shape.props)}}).concat(F?[]:[w.shape]),D=Nj(T,A);return r.current=D,D}),o()},[o,e,r]),m=_9e((h,g)=>{e(y=>{let b=y.map(x=>x.id===h&&x.type==="chartShape"?{...x,props:{...x.props,spec:g}}:x);return r.current=b,b}),o()},[o,e,r]);_ei(()=>{let h=i.length===1?a.find(b=>b.id===i[0]):void 0;if(h?.type!=="chartShape"){window.dispatchEvent(new CustomEvent(Mte,{detail:null}));return}let g=h.props.sourceTableShapeId?a.find(b=>b.id===h.props.sourceTableShapeId):void 0,y=g?.type==="tableShape"?g.props.table:null;window.dispatchEvent(new CustomEvent(Mte,{detail:{shapeId:h.id,spec:h.props.spec,data:yK(h.props,y),linked:y!==null,onSpecChange:b=>m(h.id,b)}}))},[m,i,a]),OKn({shapes:a,selectedIds:i,shapesRef:r,setShapes:e,originPickShapeId:s,graphFillPickShapeId:l,setSelectedShapeIds:c,transitionMode:u,setGraphAxisLabelText:f,setGraphAxisLabelTextVisible:p,setGraphCurveFormulaLabelTextVisible:d})}var UKn=X(()=>{"use strict";"use client";sE();Dt();tE();Yx();D_();NKn()});var MAt=X(()=>{"use strict";wK()});function O9e(e){return e.id==="overlay.move"||e.id==="overlay.resize"||e.id==="overlay.point"||e.id==="overlay.marquee"||e.id==="overlay.insertDrag"||e.id==="overlay.anchor"}function N9e(e){return{x:e.origin.x+e.current.x-e.start.x,y:e.origin.y+e.current.y-e.start.y}}function HKn(e,t,n){let r=vNe(t,n.ordered,yi(e).y),o=r?n.rects.get(r.blockId):void 0;if(!r||!o)return null;let i=GVn(r,o,e.y,e.x);return e.anchor?.type==="block"&&e.anchor.reserveSpace!==void 0?{...i,reserveSpace:e.anchor.reserveSpace}:i}function BAt(e,t,n,r){let o=r(t,n),i=y9(o,dl(e),Oi(e),e.flipX,e.flipY),a={x:i.x-e.x,y:i.y-e.y};if(a.x<0||a.x>e.props.w||a.y<0||a.y>e.props.h)return null;let s=sx(e);return{x:s.plotBox.left+a.x/s.scaleX,y:s.plotBox.top+a.y/s.scaleY}}function GKn(e,t){return e===t?!0:!e||!t?!1:e.shapeId===t.shapeId&&e.point.x===t.point.x&&e.point.y===t.point.y&&Oei(e.spec.viewBox,t.spec.viewBox)}function Oei(e,t){return e.xMin===t.xMin&&e.xMax===t.xMax&&e.yMin===t.yMin&&e.yMax===t.yMax}function jKn(e,t){if(e.type==="geo"&&Nc(e)&&t.type==="solidVertex"){let n=TD(e)[t.index];return n?{x:e.x+n.x,y:e.y+n.y}:null}if(e.type==="line"&&t.type==="line"){let n=e.props.points[t.index];return n?{x:e.x+n.x,y:e.y+n.y}:null}if(e.type==="arrow"&&t.type==="arrow"){let n=e.props[t.endpoint];return{x:e.x+n.x,y:e.y+n.y}}return null}function VKn(e,t,n,r){let o=r.ctrlKey?TXn(e):null;return o!==null?vZt(t,n,o):r.shiftKey&&AXn(e)?I5(t,n):h_(e)?MQt(t,n,r.shiftKey):n}function LAt(e,t,n){if(e.x!==t.x||e.y!==t.y||e.props.w!==t.props.w||e.props.h!==t.props.h)return!1;let r=iw(e,n),o=iw(t,n);return r.topLeft.x===o.topLeft.x&&r.topLeft.y===o.topLeft.y&&r.bottomRight.x===o.bottomRight.x&&r.bottomRight.y===o.bottomRight.y}function RAt(e){return e.id==="overlay.imageCropping"?e.shapeId:e.id==="overlay.imageCropResize"||e.id==="overlay.imageCropPan"?e.shape.id:null}var qte=X(()=>{"use strict";Pn();My();MAt();NNe();jh();xP();Yx()});import{useCallback as z9e}from"react";function XKn({shapesRef:e,pagePointFromClient:t,originPickShapeId:n,setOriginPickPreview:r,updateGraphShapeSpec:o,queueOverlaySave:i,transitionMode:a,graphFillPickShapeId:s}){let l=z9e((p,f,m)=>{let h=e.current.find(S=>S.id===p&&S.type==="graph2dShape");if(!h)return null;let g=P5(h),y=qs(g),b=g.width-y.left-y.right,x=g.height-y.top-y.bottom,v=BAt(h,f,m,t);return!v||b<=0||x<=0||v.x<y.left||v.x>g.width-y.right||v.y<y.top||v.y>g.height-y.bottom?null:{shapeId:p,spec:_3n(g,(v.x-y.left)/b,(v.y-y.top)/x),point:v}},[t,e]),c=z9e(p=>{if(!n){r(null);return}let f=l(n,p.clientX,p.clientY);r(m=>GKn(m,f)?m:f)},[l,n,r]),u=z9e(p=>{if(!n)return;let m=(p.target instanceof Element?p.target:null)?.closest(".graph-shape");if(!(m instanceof HTMLElement)||m.id!==n)return;let h=l(n,p.clientX,p.clientY);if(!h){r(null);return}p.preventDefault(),p.stopPropagation(),o(n,h.spec),i(),r(null),a({type:"setTool",tool:{kind:"select"}})},[l,n,i,r,a,o]),d=z9e(p=>{if(!s||p.defaultPrevented)return;let m=(p.target instanceof Element?p.target:null)?.closest(".graph-shape");if(!(m instanceof HTMLElement)||m.id!==s){p.preventDefault(),p.stopPropagation(),a({type:"select"});return}let h=e.current.find(w=>w.id===s&&w.type==="graph2dShape");if(!h)return;let g=P5(h);if(g.kind!=="cartesian")return;let y=()=>{window.dispatchEvent(new CustomEvent(x9e,{detail:{shapeId:s}}))},b=BAt(h,p.clientX,p.clientY,t);if(!b){y();return}let x=qs(g),v;try{v=X0(g)}catch{y();return}p.preventDefault(),p.stopPropagation();let S=yJ(b.x,b.y,v,g,x),F=d4n(g,S,ebt());if(F===g){y();return}o(s,F)},[s,t,e,a,o]);return{updateOriginPickPreviewFromEvent:c,handleOriginPickPointerDown:u,handleGraphFillPickPointerDown:d}}var WKn=X(()=>{"use strict";"use client";sE();Bme();Ak();qte();Yx()});import{useCallback as k_,useEffect as qKn}from"react";function KKn({shapes:e,selectedIds:t,shapesRef:n,assetsRef:r,setShapes:o,setAssets:i,explicitlySavedShapeStatesRef:a,canvasWidthRef:s,canvasHeightRef:l,imageInsertGap:c,queueOverlaySave:u,setSelectedShapeIds:d,transitionMode:p,tShape:f}){let m=k_((F,w,C)=>{o(A=>{let T=A.map(D=>D.id===F&&D.type==="graph3dShape"?{...D,props:{...D.props,spec:w}}:D);return n.current=T,T}),C?.save!==!1&&u()},[u,o,n]),h=k_((F,w)=>{let C=n.current.find(A=>A.id===F&&A.type==="graph3dShape");C&&m(F,{...C.props.spec,camera:w})},[m,n]),g=k_((F,w,C)=>{let A=n.current.find(T=>T.id===F&&T.type==="graph3dShape");A&&m(F,{...A.props.spec,objects:A.props.spec.objects.map(T=>T.id===w?{...T,rotation:C}:T)})},[m,n]),y=k_((F,w,C)=>{let A=n.current.find(T=>T.id===F&&T.type==="graph3dShape");A&&m(F,{...A.props.spec,objects:A.props.spec.objects.map(T=>T.id===w?{...T,...C}:T)})},[m,n]),b=k_((F,w,C,A,T)=>{let D=n.current.find(L=>L.id===F&&L.type==="graph3dShape");if(!D)return;let k=AD(D.props.spec);if(A!==k)return;let P=D.props.previewAssetId??`asset_graph3d_preview_${F}`;if(r.current[P]?.props.src===w&&D.props.previewSourceHash===k)return;let B=Math.max(0,Math.floor((w.split(",")[1]?.length??0)*.75)),M={id:P,type:"image",props:{w:Math.max(1,Math.round(C.width)),h:Math.max(1,Math.round(C.height)),name:T.animated?f("graph3d.animationFileName"):f("graph3d.previewFileName"),isAnimated:T.animated,mimeType:"image/png",src:w,fileSize:B}};i(L=>{let _={...L,[P]:M};return r.current=_,_}),o(L=>{let _=L.map(R=>R.id===F&&R.type==="graph3dShape"?{...R,props:{...R.props,previewAssetId:P,previewSourceHash:k}}:R);return n.current=_,a.current.add(_),_}),u({history:"coalesce"})},[r,a,u,i,o,n,f]),x=k_((F,w)=>{let C=n.current.find(R=>R.id===F);if(!C||C.type!=="graph3dShape")return;let A=w(),T=yi(A.shape),D=C.x+C.props.w+c+T.w<=s.current,k=Math.max(0,Math.min(C.x+(D?C.props.w+c:0),Math.max(0,s.current-T.w))),P=k-C.x,I=D?0:C.props.h+c,B=C.anchor?.type==="block"?C.anchor:null,M=B?C.y+I:Math.max(0,Math.min(C.y+I,Math.max(0,l.current-T.h))),L=B?{...B,...typeof B.dx=="number"?{dx:B.dx+P}:{},dy:B.dy+I,...B.line?{line:{...B.line,dy:B.line.dy+I}}:{}}:void 0,_=Qr([{...A.shape,x:k,y:M,...L?{anchor:L}:{},...C.parentId?{parentId:C.parentId}:{}}]);if(A.asset){let R=A.asset;i(O=>{let N={...O,[R.id]:R};return r.current=N,N})}o(R=>{let O=Qr([...R,..._]);return n.current=O,O}),d(_.map(R=>R.id)),p({type:"select"}),u()},[c,r,l,s,u,i,d,o,n,p]),v=k_((F,w)=>{x(F,()=>{let C={id:ute(),type:"image",props:{w:w.width,h:w.height,name:w.name,isAnimated:!1,mimeType:"image/svg+xml",src:w.dataUrl,fileSize:w.dataUrl.length}};return{asset:C,shape:{id:ff(),type:"image",x:0,y:0,rotation:0,props:{assetId:C.id,w:w.width,h:w.height}}}})},[x]),S=k_((F,w)=>{x(F,()=>{let C=n.current.find(T=>T.id===F),A=C?.type==="graph3dShape"?{w:C.props.w,h:C.props.h}:{w:240,h:200};return{shape:{id:ff(),type:"graph3dShape",x:0,y:0,rotation:0,props:{...A,spec:w}}}})},[x,n]);return qKn(()=>{let F=t.length===1?e.find(A=>A.id===t[0]&&A.type==="graph3dShape"):void 0;if(!F){window.dispatchEvent(new CustomEvent(Ute,{detail:null}));return}let w=F.id,C={shapeId:w,spec:F.props.spec,size:{width:F.props.w,height:F.props.h},onSpecChange:(A,T)=>m(w,A,T),onAnimationPreview:(A,T)=>Xqn({shapeId:w,overrides:A,playing:T}),onInsertImage:A=>v(w,A),onInsertSpec:A=>S(w,A),onClose:()=>d([])};window.dispatchEvent(new CustomEvent(Ute,{detail:C}))},[v,S,m,t,d,e]),qKn(()=>()=>{window.dispatchEvent(new CustomEvent(Ute,{detail:null}))},[]),{handleGraph3DCameraChange:h,handleGraph3DObjectRotationChange:g,handleGraph3DObjectTransformChange:y,handleGraph3DPreviewReady:b}}var YKn=X(()=>{"use strict";"use client";Bj();D9e();Pn();Tc();tE()});var $Kn=X(()=>{"use strict";Pn()});function _At(e){if(!e.props.crop)return e;let t={...e.props};return delete t.crop,{...e,props:t}}function ZKn(e,t,n){if(!t)return e;let r=Dce({w:t.props.w,h:t.props.h},n);return e.props.w===r.w&&e.props.h===r.h?e:{...e,props:{...e.props,...r}}}function JKn(e,t,n,r){let o=e.find(u=>u.id===n&&u.type==="image");if(!o)return{shapes:[...e],assets:{...t}};let i=o.props.assetId,a=_At({...o,props:{...o.props,assetId:r.id}}),s=e.map(u=>u.id===n?a:u),l={...t,[r.id]:r},c=s.some(u=>u.type==="image"&&u.props.assetId===i);return i!==r.id&&!c&&delete l[i],{shapes:s,assets:l}}var QKn=X(()=>{"use strict";$Kn()});var DP=Fo(y1=>{"use strict";var Nei=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function zei(e,t){return Object.prototype.hasOwnProperty.call(e,t)}y1.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(var r in n)zei(n,r)&&(e[r]=n[r])}}return e};y1.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var Uei={arraySet:function(e,t,n,r,o){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),o);return}for(var i=0;i<r;i++)e[o+i]=t[n+i]},flattenChunks:function(e){var t,n,r,o,i,a;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(a=new Uint8Array(r),o=0,t=0,n=e.length;t<n;t++)i=e[t],a.set(i,o),o+=i.length;return a}},Hei={arraySet:function(e,t,n,r,o){for(var i=0;i<r;i++)e[o+i]=t[n+i]},flattenChunks:function(e){return[].concat.apply([],e)}};y1.setTyped=function(e){e?(y1.Buf8=Uint8Array,y1.Buf16=Uint16Array,y1.Buf32=Int32Array,y1.assign(y1,Uei)):(y1.Buf8=Array,y1.Buf16=Array,y1.Buf32=Array,y1.assign(y1,Hei))};y1.setTyped(Nei)});var wYn=Fo($te=>{"use strict";var Gei=DP(),jei=4,eYn=0,tYn=1,Vei=2;function Yte(e){for(var t=e.length;--t>=0;)e[t]=0}var Xei=0,sYn=1,Wei=2,qei=3,Kei=258,jAt=29,lbe=256,obe=lbe+1+jAt,Kte=30,VAt=19,lYn=2*obe+1,zj=15,OAt=16,Yei=7,XAt=256,cYn=16,uYn=17,dYn=18,HAt=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],U9e=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],$ei=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],pYn=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Zei=512,kP=new Array((obe+2)*2);Yte(kP);var rbe=new Array(Kte*2);Yte(rbe);var ibe=new Array(Zei);Yte(ibe);var abe=new Array(Kei-qei+1);Yte(abe);var WAt=new Array(jAt);Yte(WAt);var H9e=new Array(Kte);Yte(H9e);function NAt(e,t,n,r,o){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=o,this.has_stree=e&&e.length}var fYn,mYn,hYn;function zAt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function gYn(e){return e<256?ibe[e]:ibe[256+(e>>>7)]}function sbe(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function ev(e,t,n){e.bi_valid>OAt-n?(e.bi_buf|=t<<e.bi_valid&65535,sbe(e,e.bi_buf),e.bi_buf=t>>OAt-e.bi_valid,e.bi_valid+=n-OAt):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function cE(e,t,n){ev(e,n[t*2],n[t*2+1])}function yYn(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function Jei(e){e.bi_valid===16?(sbe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function Qei(e,t){var n=t.dyn_tree,r=t.max_code,o=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,l=t.stat_desc.max_length,c,u,d,p,f,m,h=0;for(p=0;p<=zj;p++)e.bl_count[p]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<lYn;c++)u=e.heap[c],p=n[n[u*2+1]*2+1]+1,p>l&&(p=l,h++),n[u*2+1]=p,!(u>r)&&(e.bl_count[p]++,f=0,u>=s&&(f=a[u-s]),m=n[u*2],e.opt_len+=m*(p+f),i&&(e.static_len+=m*(o[u*2+1]+f)));if(h!==0){do{for(p=l-1;e.bl_count[p]===0;)p--;e.bl_count[p]--,e.bl_count[p+1]+=2,e.bl_count[l]--,h-=2}while(h>0);for(p=l;p!==0;p--)for(u=e.bl_count[p];u!==0;)d=e.heap[--c],!(d>r)&&(n[d*2+1]!==p&&(e.opt_len+=(p-n[d*2+1])*n[d*2],n[d*2+1]=p),u--)}}function bYn(e,t,n){var r=new Array(zj+1),o=0,i,a;for(i=1;i<=zj;i++)r[i]=o=o+n[i-1]<<1;for(a=0;a<=t;a++){var s=e[a*2+1];s!==0&&(e[a*2]=yYn(r[s]++,s))}}function eti(){var e,t,n,r,o,i=new Array(zj+1);for(n=0,r=0;r<jAt-1;r++)for(WAt[r]=n,e=0;e<1<<HAt[r];e++)abe[n++]=r;for(abe[n-1]=r,o=0,r=0;r<16;r++)for(H9e[r]=o,e=0;e<1<<U9e[r];e++)ibe[o++]=r;for(o>>=7;r<Kte;r++)for(H9e[r]=o<<7,e=0;e<1<<U9e[r]-7;e++)ibe[256+o++]=r;for(t=0;t<=zj;t++)i[t]=0;for(e=0;e<=143;)kP[e*2+1]=8,e++,i[8]++;for(;e<=255;)kP[e*2+1]=9,e++,i[9]++;for(;e<=279;)kP[e*2+1]=7,e++,i[7]++;for(;e<=287;)kP[e*2+1]=8,e++,i[8]++;for(bYn(kP,obe+1,i),e=0;e<Kte;e++)rbe[e*2+1]=5,rbe[e*2]=yYn(e,5);fYn=new NAt(kP,HAt,lbe+1,obe,zj),mYn=new NAt(rbe,U9e,0,Kte,zj),hYn=new NAt(new Array(0),$ei,0,VAt,Yei)}function xYn(e){var t;for(t=0;t<obe;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Kte;t++)e.dyn_dtree[t*2]=0;for(t=0;t<VAt;t++)e.bl_tree[t*2]=0;e.dyn_ltree[XAt*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function vYn(e){e.bi_valid>8?sbe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function tti(e,t,n,r){vYn(e),r&&(sbe(e,n),sbe(e,~n)),Gei.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function nYn(e,t,n,r){var o=t*2,i=n*2;return e[o]<e[i]||e[o]===e[i]&&r[t]<=r[n]}function UAt(e,t,n){for(var r=e.heap[n],o=n<<1;o<=e.heap_len&&(o<e.heap_len&&nYn(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!nYn(t,r,e.heap[o],e.depth));)e.heap[n]=e.heap[o],n=o,o<<=1;e.heap[n]=r}function rYn(e,t,n){var r,o,i=0,a,s;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+i*2]<<8|e.pending_buf[e.d_buf+i*2+1],o=e.pending_buf[e.l_buf+i],i++,r===0?cE(e,o,t):(a=abe[o],cE(e,a+lbe+1,t),s=HAt[a],s!==0&&(o-=WAt[a],ev(e,o,s)),r--,a=gYn(r),cE(e,a,n),s=U9e[a],s!==0&&(r-=H9e[a],ev(e,r,s)));while(i<e.last_lit);cE(e,XAt,t)}function GAt(e,t){var n=t.dyn_tree,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,i=t.stat_desc.elems,a,s,l=-1,c;for(e.heap_len=0,e.heap_max=lYn,a=0;a<i;a++)n[a*2]!==0?(e.heap[++e.heap_len]=l=a,e.depth[a]=0):n[a*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,n[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=r[c*2+1]);for(t.max_code=l,a=e.heap_len>>1;a>=1;a--)UAt(e,n,a);c=i;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],UAt(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=s,n[c*2]=n[a*2]+n[s*2],e.depth[c]=(e.depth[a]>=e.depth[s]?e.depth[a]:e.depth[s])+1,n[a*2+1]=n[s*2+1]=c,e.heap[1]=c++,UAt(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Qei(e,t),bYn(n,l,e.bl_count)}function oYn(e,t,n){var r,o=-1,i,a=t[1],s=0,l=7,c=4;for(a===0&&(l=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)i=a,a=t[(r+1)*2+1],!(++s<l&&i===a)&&(s<c?e.bl_tree[i*2]+=s:i!==0?(i!==o&&e.bl_tree[i*2]++,e.bl_tree[cYn*2]++):s<=10?e.bl_tree[uYn*2]++:e.bl_tree[dYn*2]++,s=0,o=i,a===0?(l=138,c=3):i===a?(l=6,c=3):(l=7,c=4))}function iYn(e,t,n){var r,o=-1,i,a=t[1],s=0,l=7,c=4;for(a===0&&(l=138,c=3),r=0;r<=n;r++)if(i=a,a=t[(r+1)*2+1],!(++s<l&&i===a)){if(s<c)do cE(e,i,e.bl_tree);while(--s!==0);else i!==0?(i!==o&&(cE(e,i,e.bl_tree),s--),cE(e,cYn,e.bl_tree),ev(e,s-3,2)):s<=10?(cE(e,uYn,e.bl_tree),ev(e,s-3,3)):(cE(e,dYn,e.bl_tree),ev(e,s-11,7));s=0,o=i,a===0?(l=138,c=3):i===a?(l=6,c=3):(l=7,c=4)}}function nti(e){var t;for(oYn(e,e.dyn_ltree,e.l_desc.max_code),oYn(e,e.dyn_dtree,e.d_desc.max_code),GAt(e,e.bl_desc),t=VAt-1;t>=3&&e.bl_tree[pYn[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function rti(e,t,n,r){var o;for(ev(e,t-257,5),ev(e,n-1,5),ev(e,r-4,4),o=0;o<r;o++)ev(e,e.bl_tree[pYn[o]*2+1],3);iYn(e,e.dyn_ltree,t-1),iYn(e,e.dyn_dtree,n-1)}function oti(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return eYn;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return tYn;for(n=32;n<lbe;n++)if(e.dyn_ltree[n*2]!==0)return tYn;return eYn}var aYn=!1;function iti(e){aYn||(eti(),aYn=!0),e.l_desc=new zAt(e.dyn_ltree,fYn),e.d_desc=new zAt(e.dyn_dtree,mYn),e.bl_desc=new zAt(e.bl_tree,hYn),e.bi_buf=0,e.bi_valid=0,xYn(e)}function SYn(e,t,n,r){ev(e,(Xei<<1)+(r?1:0),3),tti(e,t,n,!0)}function ati(e){ev(e,sYn<<1,3),cE(e,XAt,kP),Jei(e)}function sti(e,t,n,r){var o,i,a=0;e.level>0?(e.strm.data_type===Vei&&(e.strm.data_type=oti(e)),GAt(e,e.l_desc),GAt(e,e.d_desc),a=nti(e),o=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=o&&(o=i)):o=i=n+5,n+4<=o&&t!==-1?SYn(e,t,n,r):e.strategy===jei||i===o?(ev(e,(sYn<<1)+(r?1:0),3),rYn(e,kP,rbe)):(ev(e,(Wei<<1)+(r?1:0),3),rti(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),rYn(e,e.dyn_ltree,e.dyn_dtree)),xYn(e),r&&vYn(e)}function lti(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(abe[n]+lbe+1)*2]++,e.dyn_dtree[gYn(t)*2]++),e.last_lit===e.lit_bufsize-1}$te._tr_init=iti;$te._tr_stored_block=SYn;$te._tr_flush_block=sti;$te._tr_tally=lti;$te._tr_align=ati});var qAt=Fo((ZZs,FYn)=>{"use strict";function cti(e,t,n,r){for(var o=e&65535|0,i=e>>>16&65535|0,a=0;n!==0;){a=n>2e3?2e3:n,n-=a;do o=o+t[r++]|0,i=i+o|0;while(--a);o%=65521,i%=65521}return o|i<<16|0}FYn.exports=cti});var KAt=Fo((JZs,CYn)=>{"use strict";function uti(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var dti=uti();function pti(e,t,n,r){var o=dti,i=r+n;e^=-1;for(var a=r;a<i;a++)e=e>>>8^o[(e^t[a])&255];return e^-1}CYn.exports=pti});var G9e=Fo((QZs,AYn)=>{"use strict";AYn.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var LYn=Fo(pE=>{"use strict";var b1=DP(),fF=wYn(),EYn=qAt(),E_=KAt(),fti=G9e(),jj=0,mti=1,hti=3,L_=4,TYn=5,dE=0,DYn=1,mF=-2,gti=-3,YAt=-5,yti=-1,bti=1,j9e=2,xti=3,vti=4,Sti=0,wti=2,q9e=8,Fti=9,Cti=15,Ati=8,Tti=29,Dti=256,ZAt=Dti+1+Tti,kti=30,Eti=19,Iti=2*ZAt+1,Pti=15,Bs=3,M_=258,kA=M_+Bs+1,Mti=32,K9e=42,JAt=69,V9e=73,X9e=91,W9e=103,Uj=113,ube=666,Wm=1,dbe=2,Hj=3,Qte=4,Bti=3;function B_(e,t){return e.msg=fti[t],t}function kYn(e){return(e<<1)-(e>4?9:0)}function P_(e){for(var t=e.length;--t>=0;)e[t]=0}function I_(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(b1.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function og(e,t){fF._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,I_(e.strm)}function Il(e,t){e.pending_buf[e.pending++]=t}function cbe(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function Lti(e,t,n,r){var o=e.avail_in;return o>r&&(o=r),o===0?0:(e.avail_in-=o,b1.arraySet(t,e.input,e.next_in,o,n),e.state.wrap===1?e.adler=EYn(e.adler,t,o,n):e.state.wrap===2&&(e.adler=E_(e.adler,t,o,n)),e.next_in+=o,e.total_in+=o,o)}function IYn(e,t){var n=e.max_chain_length,r=e.strstart,o,i,a=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-kA?e.strstart-(e.w_size-kA):0,c=e.window,u=e.w_mask,d=e.prev,p=e.strstart+M_,f=c[r+a-1],m=c[r+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(o=t,!(c[o+a]!==m||c[o+a-1]!==f||c[o]!==c[r]||c[++o]!==c[r+1])){r+=2,o++;do;while(c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&r<p);if(i=M_-(p-r),r=p-M_,i>a){if(e.match_start=t,a=i,i>=s)break;f=c[r+a-1],m=c[r+a]}}while((t=d[t&u])>l&&--n!==0);return a<=e.lookahead?a:e.lookahead}function Gj(e){var t=e.w_size,n,r,o,i,a;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-kA)){b1.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do o=e.head[--n],e.head[n]=o>=t?o-t:0;while(--r);r=t,n=r;do o=e.prev[--n],e.prev[n]=o>=t?o-t:0;while(--r);i+=t}if(e.strm.avail_in===0)break;if(r=Lti(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=Bs)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+Bs-1])&e.hash_mask,e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<Bs)););}while(e.lookahead<kA&&e.strm.avail_in!==0)}function Rti(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Gj(e),e.lookahead===0&&t===jj)return Wm;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,og(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-kA&&(og(e,!1),e.strm.avail_out===0))return Wm}return e.insert=0,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):(e.strstart>e.block_start&&(og(e,!1),e.strm.avail_out===0),Wm)}function $At(e,t){for(var n,r;;){if(e.lookahead<kA){if(Gj(e),e.lookahead<kA&&t===jj)return Wm;if(e.lookahead===0)break}if(n=0,e.lookahead>=Bs&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Bs-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-kA&&(e.match_length=IYn(e,n)),e.match_length>=Bs)if(r=fF._tr_tally(e,e.strstart-e.match_start,e.match_length-Bs),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Bs){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Bs-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=fF._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(og(e,!1),e.strm.avail_out===0))return Wm}return e.insert=e.strstart<Bs-1?e.strstart:Bs-1,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):e.last_lit&&(og(e,!1),e.strm.avail_out===0)?Wm:dbe}function Zte(e,t){for(var n,r,o;;){if(e.lookahead<kA){if(Gj(e),e.lookahead<kA&&t===jj)return Wm;if(e.lookahead===0)break}if(n=0,e.lookahead>=Bs&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Bs-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Bs-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-kA&&(e.match_length=IYn(e,n),e.match_length<=5&&(e.strategy===bti||e.match_length===Bs&&e.strstart-e.match_start>4096)&&(e.match_length=Bs-1)),e.prev_length>=Bs&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-Bs,r=fF._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Bs),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Bs-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Bs-1,e.strstart++,r&&(og(e,!1),e.strm.avail_out===0))return Wm}else if(e.match_available){if(r=fF._tr_tally(e,0,e.window[e.strstart-1]),r&&og(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Wm}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=fF._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Bs-1?e.strstart:Bs-1,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):e.last_lit&&(og(e,!1),e.strm.avail_out===0)?Wm:dbe}function _ti(e,t){for(var n,r,o,i,a=e.window;;){if(e.lookahead<=M_){if(Gj(e),e.lookahead<=M_&&t===jj)return Wm;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Bs&&e.strstart>0&&(o=e.strstart-1,r=a[o],r===a[++o]&&r===a[++o]&&r===a[++o])){i=e.strstart+M_;do;while(r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&o<i);e.match_length=M_-(i-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Bs?(n=fF._tr_tally(e,1,e.match_length-Bs),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=fF._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(og(e,!1),e.strm.avail_out===0))return Wm}return e.insert=0,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):e.last_lit&&(og(e,!1),e.strm.avail_out===0)?Wm:dbe}function Oti(e,t){for(var n;;){if(e.lookahead===0&&(Gj(e),e.lookahead===0)){if(t===jj)return Wm;break}if(e.match_length=0,n=fF._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(og(e,!1),e.strm.avail_out===0))return Wm}return e.insert=0,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):e.last_lit&&(og(e,!1),e.strm.avail_out===0)?Wm:dbe}function uE(e,t,n,r,o){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=o}var Jte;Jte=[new uE(0,0,0,0,Rti),new uE(4,4,8,4,$At),new uE(4,5,16,8,$At),new uE(4,6,32,32,$At),new uE(4,4,16,16,Zte),new uE(8,16,32,32,Zte),new uE(8,16,128,128,Zte),new uE(8,32,128,256,Zte),new uE(32,128,258,1024,Zte),new uE(32,258,258,4096,Zte)];function Nti(e){e.window_size=2*e.w_size,P_(e.head),e.max_lazy_match=Jte[e.level].max_lazy,e.good_match=Jte[e.level].good_length,e.nice_match=Jte[e.level].nice_length,e.max_chain_length=Jte[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Bs-1,e.match_available=0,e.ins_h=0}function zti(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=q9e,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new b1.Buf16(Iti*2),this.dyn_dtree=new b1.Buf16((2*kti+1)*2),this.bl_tree=new b1.Buf16((2*Eti+1)*2),P_(this.dyn_ltree),P_(this.dyn_dtree),P_(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new b1.Buf16(Pti+1),this.heap=new b1.Buf16(2*ZAt+1),P_(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new b1.Buf16(2*ZAt+1),P_(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function PYn(e){var t;return!e||!e.state?B_(e,mF):(e.total_in=e.total_out=0,e.data_type=wti,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?K9e:Uj,e.adler=t.wrap===2?0:1,t.last_flush=jj,fF._tr_init(t),dE)}function MYn(e){var t=PYn(e);return t===dE&&Nti(e.state),t}function Uti(e,t){return!e||!e.state||e.state.wrap!==2?mF:(e.state.gzhead=t,dE)}function BYn(e,t,n,r,o,i){if(!e)return mF;var a=1;if(t===yti&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),o<1||o>Fti||n!==q9e||r<8||r>15||t<0||t>9||i<0||i>vti)return B_(e,mF);r===8&&(r=9);var s=new zti;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=o+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+Bs-1)/Bs),s.window=new b1.Buf8(s.w_size*2),s.head=new b1.Buf16(s.hash_size),s.prev=new b1.Buf16(s.w_size),s.lit_bufsize=1<<o+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new b1.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=i,s.method=n,MYn(e)}function Hti(e,t){return BYn(e,t,q9e,Cti,Ati,Sti)}function Gti(e,t){var n,r,o,i;if(!e||!e.state||t>TYn||t<0)return e?B_(e,mF):mF;if(r=e.state,!e.output||!e.input&&e.avail_in!==0||r.status===ube&&t!==L_)return B_(e,e.avail_out===0?YAt:mF);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===K9e)if(r.wrap===2)e.adler=0,Il(r,31),Il(r,139),Il(r,8),r.gzhead?(Il(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Il(r,r.gzhead.time&255),Il(r,r.gzhead.time>>8&255),Il(r,r.gzhead.time>>16&255),Il(r,r.gzhead.time>>24&255),Il(r,r.level===9?2:r.strategy>=j9e||r.level<2?4:0),Il(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(Il(r,r.gzhead.extra.length&255),Il(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=E_(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=JAt):(Il(r,0),Il(r,0),Il(r,0),Il(r,0),Il(r,0),Il(r,r.level===9?2:r.strategy>=j9e||r.level<2?4:0),Il(r,Bti),r.status=Uj);else{var a=q9e+(r.w_bits-8<<4)<<8,s=-1;r.strategy>=j9e||r.level<2?s=0:r.level<6?s=1:r.level===6?s=2:s=3,a|=s<<6,r.strstart!==0&&(a|=Mti),a+=31-a%31,r.status=Uj,cbe(r,a),r.strstart!==0&&(cbe(r,e.adler>>>16),cbe(r,e.adler&65535)),e.adler=1}if(r.status===JAt)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),I_(e),o=r.pending,r.pending===r.pending_buf_size));)Il(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=V9e)}else r.status=V9e;if(r.status===V9e)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),I_(e),o=r.pending,r.pending===r.pending_buf_size)){i=1;break}r.gzindex<r.gzhead.name.length?i=r.gzhead.name.charCodeAt(r.gzindex++)&255:i=0,Il(r,i)}while(i!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),i===0&&(r.gzindex=0,r.status=X9e)}else r.status=X9e;if(r.status===X9e)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),I_(e),o=r.pending,r.pending===r.pending_buf_size)){i=1;break}r.gzindex<r.gzhead.comment.length?i=r.gzhead.comment.charCodeAt(r.gzindex++)&255:i=0,Il(r,i)}while(i!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),i===0&&(r.status=W9e)}else r.status=W9e;if(r.status===W9e&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&I_(e),r.pending+2<=r.pending_buf_size&&(Il(r,e.adler&255),Il(r,e.adler>>8&255),e.adler=0,r.status=Uj)):r.status=Uj),r.pending!==0){if(I_(e),e.avail_out===0)return r.last_flush=-1,dE}else if(e.avail_in===0&&kYn(t)<=kYn(n)&&t!==L_)return B_(e,YAt);if(r.status===ube&&e.avail_in!==0)return B_(e,YAt);if(e.avail_in!==0||r.lookahead!==0||t!==jj&&r.status!==ube){var l=r.strategy===j9e?Oti(r,t):r.strategy===xti?_ti(r,t):Jte[r.level].func(r,t);if((l===Hj||l===Qte)&&(r.status=ube),l===Wm||l===Hj)return e.avail_out===0&&(r.last_flush=-1),dE;if(l===dbe&&(t===mti?fF._tr_align(r):t!==TYn&&(fF._tr_stored_block(r,0,0,!1),t===hti&&(P_(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),I_(e),e.avail_out===0))return r.last_flush=-1,dE}return t!==L_?dE:r.wrap<=0?DYn:(r.wrap===2?(Il(r,e.adler&255),Il(r,e.adler>>8&255),Il(r,e.adler>>16&255),Il(r,e.adler>>24&255),Il(r,e.total_in&255),Il(r,e.total_in>>8&255),Il(r,e.total_in>>16&255),Il(r,e.total_in>>24&255)):(cbe(r,e.adler>>>16),cbe(r,e.adler&65535)),I_(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?dE:DYn)}function jti(e){var t;return!e||!e.state?mF:(t=e.state.status,t!==K9e&&t!==JAt&&t!==V9e&&t!==X9e&&t!==W9e&&t!==Uj&&t!==ube?B_(e,mF):(e.state=null,t===Uj?B_(e,gti):dE))}function Vti(e,t){var n=t.length,r,o,i,a,s,l,c,u;if(!e||!e.state||(r=e.state,a=r.wrap,a===2||a===1&&r.status!==K9e||r.lookahead))return mF;for(a===1&&(e.adler=EYn(e.adler,t,n,0)),r.wrap=0,n>=r.w_size&&(a===0&&(P_(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new b1.Buf8(r.w_size),b1.arraySet(u,t,n-r.w_size,r.w_size,0),t=u,n=r.w_size),s=e.avail_in,l=e.next_in,c=e.input,e.avail_in=n,e.next_in=0,e.input=t,Gj(r);r.lookahead>=Bs;){o=r.strstart,i=r.lookahead-(Bs-1);do r.ins_h=(r.ins_h<<r.hash_shift^r.window[o+Bs-1])&r.hash_mask,r.prev[o&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=o,o++;while(--i);r.strstart=o,r.lookahead=Bs-1,Gj(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Bs-1,r.match_available=0,e.next_in=l,e.input=c,e.avail_in=s,r.wrap=a,dE}pE.deflateInit=Hti;pE.deflateInit2=BYn;pE.deflateReset=MYn;pE.deflateResetKeep=PYn;pE.deflateSetHeader=Uti;pE.deflate=Gti;pE.deflateEnd=jti;pE.deflateSetDictionary=Vti;pE.deflateInfo="pako deflate (from Nodeca project)"});var QAt=Fo(ene=>{"use strict";var Y9e=DP(),RYn=!0,_Yn=!0;try{String.fromCharCode.apply(null,[0])}catch{RYn=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{_Yn=!1}var pbe=new Y9e.Buf8(256);for(EP=0;EP<256;EP++)pbe[EP]=EP>=252?6:EP>=248?5:EP>=240?4:EP>=224?3:EP>=192?2:1;var EP;pbe[254]=pbe[254]=1;ene.string2buf=function(e){var t,n,r,o,i,a=e.length,s=0;for(o=0;o<a;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<a&&(r=e.charCodeAt(o+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),o++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Y9e.Buf8(s),i=0,o=0;i<s;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<a&&(r=e.charCodeAt(o+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),o++)),n<128?t[i++]=n:n<2048?(t[i++]=192|n>>>6,t[i++]=128|n&63):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|n&63):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|n&63);return t};function OYn(e,t){if(t<65534&&(e.subarray&&_Yn||!e.subarray&&RYn))return String.fromCharCode.apply(null,Y9e.shrinkBuf(e,t));for(var n="",r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n}ene.buf2binstring=function(e){return OYn(e,e.length)};ene.binstring2buf=function(e){for(var t=new Y9e.Buf8(e.length),n=0,r=t.length;n<r;n++)t[n]=e.charCodeAt(n);return t};ene.buf2string=function(e,t){var n,r,o,i,a=t||e.length,s=new Array(a*2);for(r=0,n=0;n<a;){if(o=e[n++],o<128){s[r++]=o;continue}if(i=pbe[o],i>4){s[r++]=65533,n+=i-1;continue}for(o&=i===2?31:i===3?15:7;i>1&&n<a;)o=o<<6|e[n++]&63,i--;if(i>1){s[r++]=65533;continue}o<65536?s[r++]=o:(o-=65536,s[r++]=55296|o>>10&1023,s[r++]=56320|o&1023)}return OYn(s,r)};ene.utf8border=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+pbe[e[n]]>t?n:t}});var eTt=Fo((nJs,NYn)=>{"use strict";function Xti(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}NYn.exports=Xti});var GYn=Fo(hbe=>{"use strict";var fbe=LYn(),mbe=DP(),nTt=QAt(),rTt=G9e(),Wti=eTt(),HYn=Object.prototype.toString,qti=0,tTt=4,tne=0,zYn=1,UYn=2,Kti=-1,Yti=0,$ti=8;function Vj(e){if(!(this instanceof Vj))return new Vj(e);this.options=mbe.assign({level:Kti,method:$ti,chunkSize:16384,windowBits:15,memLevel:8,strategy:Yti,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Wti,this.strm.avail_out=0;var n=fbe.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==tne)throw new Error(rTt[n]);if(t.header&&fbe.deflateSetHeader(this.strm,t.header),t.dictionary){var r;if(typeof t.dictionary=="string"?r=nTt.string2buf(t.dictionary):HYn.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=fbe.deflateSetDictionary(this.strm,r),n!==tne)throw new Error(rTt[n]);this._dict_set=!0}}Vj.prototype.push=function(e,t){var n=this.strm,r=this.options.chunkSize,o,i;if(this.ended)return!1;i=t===~~t?t:t===!0?tTt:qti,typeof e=="string"?n.input=nTt.string2buf(e):HYn.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new mbe.Buf8(r),n.next_out=0,n.avail_out=r),o=fbe.deflate(n,i),o!==zYn&&o!==tne)return this.onEnd(o),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(i===tTt||i===UYn))&&(this.options.to==="string"?this.onData(nTt.buf2binstring(mbe.shrinkBuf(n.output,n.next_out))):this.onData(mbe.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&o!==zYn);return i===tTt?(o=fbe.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===tne):(i===UYn&&(this.onEnd(tne),n.avail_out=0),!0)};Vj.prototype.onData=function(e){this.chunks.push(e)};Vj.prototype.onEnd=function(e){e===tne&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=mbe.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function oTt(e,t){var n=new Vj(t);if(n.push(e,!0),n.err)throw n.msg||rTt[n.err];return n.result}function Zti(e,t){return t=t||{},t.raw=!0,oTt(e,t)}function Jti(e,t){return t=t||{},t.gzip=!0,oTt(e,t)}hbe.Deflate=Vj;hbe.deflate=oTt;hbe.deflateRaw=Zti;hbe.gzip=Jti});var VYn=Fo((oJs,jYn)=>{"use strict";var $9e=30,Qti=12;jYn.exports=function(t,n){var r,o,i,a,s,l,c,u,d,p,f,m,h,g,y,b,x,v,S,F,w,C,A,T,D;r=t.state,o=t.next_in,T=t.input,i=o+(t.avail_in-5),a=t.next_out,D=t.output,s=a-(n-t.avail_out),l=a+(t.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,p=r.wnext,f=r.window,m=r.hold,h=r.bits,g=r.lencode,y=r.distcode,b=(1<<r.lenbits)-1,x=(1<<r.distbits)-1;e:do{h<15&&(m+=T[o++]<<h,h+=8,m+=T[o++]<<h,h+=8),v=g[m&b];t:for(;;){if(S=v>>>24,m>>>=S,h-=S,S=v>>>16&255,S===0)D[a++]=v&65535;else if(S&16){F=v&65535,S&=15,S&&(h<S&&(m+=T[o++]<<h,h+=8),F+=m&(1<<S)-1,m>>>=S,h-=S),h<15&&(m+=T[o++]<<h,h+=8,m+=T[o++]<<h,h+=8),v=y[m&x];n:for(;;){if(S=v>>>24,m>>>=S,h-=S,S=v>>>16&255,S&16){if(w=v&65535,S&=15,h<S&&(m+=T[o++]<<h,h+=8,h<S&&(m+=T[o++]<<h,h+=8)),w+=m&(1<<S)-1,w>c){t.msg="invalid distance too far back",r.mode=$9e;break e}if(m>>>=S,h-=S,S=a-s,w>S){if(S=w-S,S>d&&r.sane){t.msg="invalid distance too far back",r.mode=$9e;break e}if(C=0,A=f,p===0){if(C+=u-S,S<F){F-=S;do D[a++]=f[C++];while(--S);C=a-w,A=D}}else if(p<S){if(C+=u+p-S,S-=p,S<F){F-=S;do D[a++]=f[C++];while(--S);if(C=0,p<F){S=p,F-=S;do D[a++]=f[C++];while(--S);C=a-w,A=D}}}else if(C+=p-S,S<F){F-=S;do D[a++]=f[C++];while(--S);C=a-w,A=D}for(;F>2;)D[a++]=A[C++],D[a++]=A[C++],D[a++]=A[C++],F-=3;F&&(D[a++]=A[C++],F>1&&(D[a++]=A[C++]))}else{C=a-w;do D[a++]=D[C++],D[a++]=D[C++],D[a++]=D[C++],F-=3;while(F>2);F&&(D[a++]=D[C++],F>1&&(D[a++]=D[C++]))}}else if((S&64)===0){v=y[(v&65535)+(m&(1<<S)-1)];continue n}else{t.msg="invalid distance code",r.mode=$9e;break e}break}}else if((S&64)===0){v=g[(v&65535)+(m&(1<<S)-1)];continue t}else if(S&32){r.mode=Qti;break e}else{t.msg="invalid literal/length code",r.mode=$9e;break e}break}}while(o<i&&a<l);F=h>>3,o-=F,h-=F<<3,m&=(1<<h)-1,t.next_in=o,t.next_out=a,t.avail_in=o<i?5+(i-o):5-(o-i),t.avail_out=a<l?257+(l-a):257-(a-l),r.hold=m,r.bits=h}});var ZYn=Fo((iJs,$Yn)=>{"use strict";var XYn=DP(),nne=15,WYn=852,qYn=592,KYn=0,iTt=1,YYn=2,eni=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],tni=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],nni=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],rni=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];$Yn.exports=function(t,n,r,o,i,a,s,l){var c=l.bits,u=0,d=0,p=0,f=0,m=0,h=0,g=0,y=0,b=0,x=0,v,S,F,w,C,A=null,T=0,D,k=new XYn.Buf16(nne+1),P=new XYn.Buf16(nne+1),I=null,B=0,M,L,_;for(u=0;u<=nne;u++)k[u]=0;for(d=0;d<o;d++)k[n[r+d]]++;for(m=c,f=nne;f>=1&&k[f]===0;f--);if(m>f&&(m=f),f===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,l.bits=1,0;for(p=1;p<f&&k[p]===0;p++);for(m<p&&(m=p),y=1,u=1;u<=nne;u++)if(y<<=1,y-=k[u],y<0)return-1;if(y>0&&(t===KYn||f!==1))return-1;for(P[1]=0,u=1;u<nne;u++)P[u+1]=P[u]+k[u];for(d=0;d<o;d++)n[r+d]!==0&&(s[P[n[r+d]]++]=d);if(t===KYn?(A=I=s,D=19):t===iTt?(A=eni,T-=257,I=tni,B-=257,D=256):(A=nni,I=rni,D=-1),x=0,d=0,u=p,C=a,h=m,g=0,F=-1,b=1<<m,w=b-1,t===iTt&&b>WYn||t===YYn&&b>qYn)return 1;for(;;){M=u-g,s[d]<D?(L=0,_=s[d]):s[d]>D?(L=I[B+s[d]],_=A[T+s[d]]):(L=96,_=0),v=1<<u-g,S=1<<h,p=S;do S-=v,i[C+(x>>g)+S]=M<<24|L<<16|_|0;while(S!==0);for(v=1<<u-1;x&v;)v>>=1;if(v!==0?(x&=v-1,x+=v):x=0,d++,--k[u]===0){if(u===f)break;u=n[r+s[d]]}if(u>m&&(x&w)!==F){for(g===0&&(g=m),C+=p,h=u-g,y=1<<h;h+g<f&&(y-=k[h+g],!(y<=0));)h++,y<<=1;if(b+=1<<h,t===iTt&&b>WYn||t===YYn&&b>qYn)return 1;F=x&w,i[F]=m<<24|h<<16|C-a|0}}return x!==0&&(i[C+x]=u-g<<24|64<<16|0),l.bits=m,0}});var M$n=Fo(EA=>{"use strict";var J2=DP(),dTt=qAt(),fE=KAt(),oni=VYn(),gbe=ZYn(),ini=0,F$n=1,C$n=2,JYn=4,ani=5,Z9e=6,Xj=0,sni=1,lni=2,hF=-2,A$n=-3,pTt=-4,cni=-5,QYn=8,T$n=1,e$n=2,t$n=3,n$n=4,r$n=5,o$n=6,i$n=7,a$n=8,s$n=9,l$n=10,eze=11,IP=12,aTt=13,c$n=14,sTt=15,u$n=16,d$n=17,p$n=18,f$n=19,J9e=20,Q9e=21,m$n=22,h$n=23,g$n=24,y$n=25,b$n=26,lTt=27,x$n=28,v$n=29,Sd=30,fTt=31,uni=32,dni=852,pni=592,fni=15,mni=fni;function S$n(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function hni(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new J2.Buf16(320),this.work=new J2.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function D$n(e){var t;return!e||!e.state?hF:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=T$n,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new J2.Buf32(dni),t.distcode=t.distdyn=new J2.Buf32(pni),t.sane=1,t.back=-1,Xj)}function k$n(e){var t;return!e||!e.state?hF:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,D$n(e))}function E$n(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?hF:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,k$n(e))}function I$n(e,t){var n,r;return e?(r=new hni,e.state=r,r.window=null,n=E$n(e,t),n!==Xj&&(e.state=null),n):hF}function gni(e){return I$n(e,mni)}var w$n=!0,cTt,uTt;function yni(e){if(w$n){var t;for(cTt=new J2.Buf32(512),uTt=new J2.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(gbe(F$n,e.lens,0,288,cTt,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;gbe(C$n,e.lens,0,32,uTt,0,e.work,{bits:5}),w$n=!1}e.lencode=cTt,e.lenbits=9,e.distcode=uTt,e.distbits=5}function P$n(e,t,n,r){var o,i=e.state;return i.window===null&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new J2.Buf8(i.wsize)),r>=i.wsize?(J2.arraySet(i.window,t,n-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):(o=i.wsize-i.wnext,o>r&&(o=r),J2.arraySet(i.window,t,n-r,o,i.wnext),r-=o,r?(J2.arraySet(i.window,t,n-r,r,0),i.wnext=r,i.whave=i.wsize):(i.wnext+=o,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=o))),0}function bni(e,t){var n,r,o,i,a,s,l,c,u,d,p,f,m,h,g=0,y,b,x,v,S,F,w,C,A=new J2.Buf8(4),T,D,k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return hF;n=e.state,n.mode===IP&&(n.mode=aTt),a=e.next_out,o=e.output,l=e.avail_out,i=e.next_in,r=e.input,s=e.avail_in,c=n.hold,u=n.bits,d=s,p=l,C=Xj;e:for(;;)switch(n.mode){case T$n:if(n.wrap===0){n.mode=aTt;break}for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(n.wrap&2&&c===35615){n.check=0,A[0]=c&255,A[1]=c>>>8&255,n.check=fE(n.check,A,2,0),c=0,u=0,n.mode=e$n;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=Sd;break}if((c&15)!==QYn){e.msg="unknown compression method",n.mode=Sd;break}if(c>>>=4,u-=4,w=(c&15)+8,n.wbits===0)n.wbits=w;else if(w>n.wbits){e.msg="invalid window size",n.mode=Sd;break}n.dmax=1<<w,e.adler=n.check=1,n.mode=c&512?l$n:IP,c=0,u=0;break;case e$n:for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(n.flags=c,(n.flags&255)!==QYn){e.msg="unknown compression method",n.mode=Sd;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=Sd;break}n.head&&(n.head.text=c>>8&1),n.flags&512&&(A[0]=c&255,A[1]=c>>>8&255,n.check=fE(n.check,A,2,0)),c=0,u=0,n.mode=t$n;case t$n:for(;u<32;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.head&&(n.head.time=c),n.flags&512&&(A[0]=c&255,A[1]=c>>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,n.check=fE(n.check,A,4,0)),c=0,u=0,n.mode=n$n;case n$n:for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.head&&(n.head.xflags=c&255,n.head.os=c>>8),n.flags&512&&(A[0]=c&255,A[1]=c>>>8&255,n.check=fE(n.check,A,2,0)),c=0,u=0,n.mode=r$n;case r$n:if(n.flags&1024){for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.length=c,n.head&&(n.head.extra_len=c),n.flags&512&&(A[0]=c&255,A[1]=c>>>8&255,n.check=fE(n.check,A,2,0)),c=0,u=0}else n.head&&(n.head.extra=null);n.mode=o$n;case o$n:if(n.flags&1024&&(f=n.length,f>s&&(f=s),f&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),J2.arraySet(n.head.extra,r,i,f,w)),n.flags&512&&(n.check=fE(n.check,r,f,i)),s-=f,i+=f,n.length-=f),n.length))break e;n.length=0,n.mode=i$n;case i$n:if(n.flags&2048){if(s===0)break e;f=0;do w=r[i+f++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w));while(w&&f<s);if(n.flags&512&&(n.check=fE(n.check,r,f,i)),s-=f,i+=f,w)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=a$n;case a$n:if(n.flags&4096){if(s===0)break e;f=0;do w=r[i+f++],n.head&&w&&n.length<65536&&(n.head.comment+=String.fromCharCode(w));while(w&&f<s);if(n.flags&512&&(n.check=fE(n.check,r,f,i)),s-=f,i+=f,w)break e}else n.head&&(n.head.comment=null);n.mode=s$n;case s$n:if(n.flags&512){for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(c!==(n.check&65535)){e.msg="header crc mismatch",n.mode=Sd;break}c=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=IP;break;case l$n:for(;u<32;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}e.adler=n.check=S$n(c),c=0,u=0,n.mode=eze;case eze:if(n.havedict===0)return e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=s,n.hold=c,n.bits=u,lni;e.adler=n.check=1,n.mode=IP;case IP:if(t===ani||t===Z9e)break e;case aTt:if(n.last){c>>>=u&7,u-=u&7,n.mode=lTt;break}for(;u<3;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}switch(n.last=c&1,c>>>=1,u-=1,c&3){case 0:n.mode=c$n;break;case 1:if(yni(n),n.mode=J9e,t===Z9e){c>>>=2,u-=2;break e}break;case 2:n.mode=d$n;break;case 3:e.msg="invalid block type",n.mode=Sd}c>>>=2,u-=2;break;case c$n:for(c>>>=u&7,u-=u&7;u<32;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",n.mode=Sd;break}if(n.length=c&65535,c=0,u=0,n.mode=sTt,t===Z9e)break e;case sTt:n.mode=u$n;case u$n:if(f=n.length,f){if(f>s&&(f=s),f>l&&(f=l),f===0)break e;J2.arraySet(o,r,i,f,a),s-=f,i+=f,l-=f,a+=f,n.length-=f;break}n.mode=IP;break;case d$n:for(;u<14;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(n.nlen=(c&31)+257,c>>>=5,u-=5,n.ndist=(c&31)+1,c>>>=5,u-=5,n.ncode=(c&15)+4,c>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Sd;break}n.have=0,n.mode=p$n;case p$n:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.lens[k[n.have++]]=c&7,c>>>=3,u-=3}for(;n.have<19;)n.lens[k[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},C=gbe(ini,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,C){e.msg="invalid code lengths set",n.mode=Sd;break}n.have=0,n.mode=f$n;case f$n:for(;n.have<n.nlen+n.ndist;){for(;g=n.lencode[c&(1<<n.lenbits)-1],y=g>>>24,b=g>>>16&255,x=g&65535,!(y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(x<16)c>>>=y,u-=y,n.lens[n.have++]=x;else{if(x===16){for(D=y+2;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(c>>>=y,u-=y,n.have===0){e.msg="invalid bit length repeat",n.mode=Sd;break}w=n.lens[n.have-1],f=3+(c&3),c>>>=2,u-=2}else if(x===17){for(D=y+3;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}c>>>=y,u-=y,w=0,f=3+(c&7),c>>>=3,u-=3}else{for(D=y+7;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}c>>>=y,u-=y,w=0,f=11+(c&127),c>>>=7,u-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Sd;break}for(;f--;)n.lens[n.have++]=w}}if(n.mode===Sd)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Sd;break}if(n.lenbits=9,T={bits:n.lenbits},C=gbe(F$n,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,C){e.msg="invalid literal/lengths set",n.mode=Sd;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},C=gbe(C$n,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,C){e.msg="invalid distances set",n.mode=Sd;break}if(n.mode=J9e,t===Z9e)break e;case J9e:n.mode=Q9e;case Q9e:if(s>=6&&l>=258){e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=s,n.hold=c,n.bits=u,oni(e,p),a=e.next_out,o=e.output,l=e.avail_out,i=e.next_in,r=e.input,s=e.avail_in,c=n.hold,u=n.bits,n.mode===IP&&(n.back=-1);break}for(n.back=0;g=n.lencode[c&(1<<n.lenbits)-1],y=g>>>24,b=g>>>16&255,x=g&65535,!(y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(b&&(b&240)===0){for(v=y,S=b,F=x;g=n.lencode[F+((c&(1<<v+S)-1)>>v)],y=g>>>24,b=g>>>16&255,x=g&65535,!(v+y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}c>>>=v,u-=v,n.back+=v}if(c>>>=y,u-=y,n.back+=y,n.length=x,b===0){n.mode=b$n;break}if(b&32){n.back=-1,n.mode=IP;break}if(b&64){e.msg="invalid literal/length code",n.mode=Sd;break}n.extra=b&15,n.mode=m$n;case m$n:if(n.extra){for(D=n.extra;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=h$n;case h$n:for(;g=n.distcode[c&(1<<n.distbits)-1],y=g>>>24,b=g>>>16&255,x=g&65535,!(y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if((b&240)===0){for(v=y,S=b,F=x;g=n.distcode[F+((c&(1<<v+S)-1)>>v)],y=g>>>24,b=g>>>16&255,x=g&65535,!(v+y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}c>>>=v,u-=v,n.back+=v}if(c>>>=y,u-=y,n.back+=y,b&64){e.msg="invalid distance code",n.mode=Sd;break}n.offset=x,n.extra=b&15,n.mode=g$n;case g$n:if(n.extra){for(D=n.extra;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Sd;break}n.mode=y$n;case y$n:if(l===0)break e;if(f=p-l,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Sd;break}f>n.wnext?(f-=n.wnext,m=n.wsize-f):m=n.wnext-f,f>n.length&&(f=n.length),h=n.window}else h=o,m=a-n.offset,f=n.length;f>l&&(f=l),l-=f,n.length-=f;do o[a++]=h[m++];while(--f);n.length===0&&(n.mode=Q9e);break;case b$n:if(l===0)break e;o[a++]=n.length,l--,n.mode=Q9e;break;case lTt:if(n.wrap){for(;u<32;){if(s===0)break e;s--,c|=r[i++]<<u,u+=8}if(p-=l,e.total_out+=p,n.total+=p,p&&(e.adler=n.check=n.flags?fE(n.check,o,p,a-p):dTt(n.check,o,p,a-p)),p=l,(n.flags?c:S$n(c))!==n.check){e.msg="incorrect data check",n.mode=Sd;break}c=0,u=0}n.mode=x$n;case x$n:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(c!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=Sd;break}c=0,u=0}n.mode=v$n;case v$n:C=sni;break e;case Sd:C=A$n;break e;case fTt:return pTt;case uni:default:return hF}return e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=s,n.hold=c,n.bits=u,(n.wsize||p!==e.avail_out&&n.mode<Sd&&(n.mode<lTt||t!==JYn))&&P$n(e,e.output,e.next_out,p-e.avail_out)?(n.mode=fTt,pTt):(d-=e.avail_in,p-=e.avail_out,e.total_in+=d,e.total_out+=p,n.total+=p,n.wrap&&p&&(e.adler=n.check=n.flags?fE(n.check,o,p,e.next_out-p):dTt(n.check,o,p,e.next_out-p)),e.data_type=n.bits+(n.last?64:0)+(n.mode===IP?128:0)+(n.mode===J9e||n.mode===sTt?256:0),(d===0&&p===0||t===JYn)&&C===Xj&&(C=cni),C)}function xni(e){if(!e||!e.state)return hF;var t=e.state;return t.window&&(t.window=null),e.state=null,Xj}function vni(e,t){var n;return!e||!e.state||(n=e.state,(n.wrap&2)===0)?hF:(n.head=t,t.done=!1,Xj)}function Sni(e,t){var n=t.length,r,o,i;return!e||!e.state||(r=e.state,r.wrap!==0&&r.mode!==eze)?hF:r.mode===eze&&(o=1,o=dTt(o,t,n,0),o!==r.check)?A$n:(i=P$n(e,t,n,n),i?(r.mode=fTt,pTt):(r.havedict=1,Xj))}EA.inflateReset=k$n;EA.inflateReset2=E$n;EA.inflateResetKeep=D$n;EA.inflateInit=gni;EA.inflateInit2=I$n;EA.inflate=bni;EA.inflateEnd=xni;EA.inflateGetHeader=vni;EA.inflateSetDictionary=Sni;EA.inflateInfo="pako inflate (from Nodeca project)"});var mTt=Fo((sJs,B$n)=>{"use strict";B$n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var R$n=Fo((lJs,L$n)=>{"use strict";function wni(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}L$n.exports=wni});var O$n=Fo(bbe=>{"use strict";var rne=M$n(),ybe=DP(),tze=QAt(),gf=mTt(),hTt=G9e(),Fni=eTt(),Cni=R$n(),_$n=Object.prototype.toString;function Wj(e){if(!(this instanceof Wj))return new Wj(e);this.options=ybe.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Fni,this.strm.avail_out=0;var n=rne.inflateInit2(this.strm,t.windowBits);if(n!==gf.Z_OK)throw new Error(hTt[n]);if(this.header=new Cni,rne.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=tze.string2buf(t.dictionary):_$n.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=rne.inflateSetDictionary(this.strm,t.dictionary),n!==gf.Z_OK)))throw new Error(hTt[n])}Wj.prototype.push=function(e,t){var n=this.strm,r=this.options.chunkSize,o=this.options.dictionary,i,a,s,l,c,u=!1;if(this.ended)return!1;a=t===~~t?t:t===!0?gf.Z_FINISH:gf.Z_NO_FLUSH,typeof e=="string"?n.input=tze.binstring2buf(e):_$n.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new ybe.Buf8(r),n.next_out=0,n.avail_out=r),i=rne.inflate(n,gf.Z_NO_FLUSH),i===gf.Z_NEED_DICT&&o&&(i=rne.inflateSetDictionary(this.strm,o)),i===gf.Z_BUF_ERROR&&u===!0&&(i=gf.Z_OK,u=!1),i!==gf.Z_STREAM_END&&i!==gf.Z_OK)return this.onEnd(i),this.ended=!0,!1;n.next_out&&(n.avail_out===0||i===gf.Z_STREAM_END||n.avail_in===0&&(a===gf.Z_FINISH||a===gf.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=tze.utf8border(n.output,n.next_out),l=n.next_out-s,c=tze.buf2string(n.output,s),n.next_out=l,n.avail_out=r-l,l&&ybe.arraySet(n.output,n.output,s,l,0),this.onData(c)):this.onData(ybe.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(u=!0)}while((n.avail_in>0||n.avail_out===0)&&i!==gf.Z_STREAM_END);return i===gf.Z_STREAM_END&&(a=gf.Z_FINISH),a===gf.Z_FINISH?(i=rne.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===gf.Z_OK):(a===gf.Z_SYNC_FLUSH&&(this.onEnd(gf.Z_OK),n.avail_out=0),!0)};Wj.prototype.onData=function(e){this.chunks.push(e)};Wj.prototype.onEnd=function(e){e===gf.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ybe.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function gTt(e,t){var n=new Wj(t);if(n.push(e,!0),n.err)throw n.msg||hTt[n.err];return n.result}function Ani(e,t){return t=t||{},t.raw=!0,gTt(e,t)}bbe.Inflate=Wj;bbe.inflate=gTt;bbe.inflateRaw=Ani;bbe.ungzip=gTt});var U$n=Fo((uJs,z$n)=>{"use strict";var Tni=DP().assign,Dni=GYn(),kni=O$n(),Eni=mTt(),N$n={};Tni(N$n,Dni,kni,Eni);z$n.exports=N$n});var nze=Fo((dJs,yTt)=>{(function(){var e={};typeof yTt=="object"?yTt.exports=e:self.UTIF=e;var t;typeof Ng=="function"?t=U$n():t=self.pako;function n(){typeof process>"u"&&console.log.apply(console,arguments)}(function(r,o){(function(){var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},a=(function(){function l(c){this.message="JPEG error: "+c}return l.prototype=Error(),l.prototype.name="JpegError",l.constructor=l})(),s=(function(){function l(c,u){this.message=c,this.g=u}return l.prototype=Error(),l.prototype.name="DNLMarkerError",l.constructor=l})();(function(){function l(){this.M=null,this.B=-1}function c(m,h){for(var g=0,y=[],b,x,v=16;0<v&&!m[v-1];)v--;y.push({children:[],index:0});var S=y[0],F;for(b=0;b<v;b++){for(x=0;x<m[b];x++){for(S=y.pop(),S.children[S.index]=h[g];0<S.index;)S=y.pop();for(S.index++,y.push(S);y.length<=b;)y.push(F={children:[],index:0}),S.children[S.index]=F.children,S=F;g++}b+1<v&&(y.push(F={children:[],index:0}),S.children[S.index]=F.children,S=F)}return y[0].children}function u(m,h,g,y,b,x,v,S,F){function w(){if(0<O)return O--,R>>O&1;if(R=m[h++],R===255){var j=m[h++];if(j){if(j===220&&M){h+=2;var pe=m[h++]<<8|m[h++];if(0<pe&&pe!==g.g)throw new s("Found DNL marker (0xFFDC) while parsing scan data",pe)}throw new a("unexpected marker "+(R<<8|j).toString(16))}}return O=7,R>>>7}function C(j){for(;;){if(j=j[w()],typeof j=="number")return j;if((typeof j>"u"?"undefined":i(j))!=="object")throw new a("invalid huffman sequence")}}function A(j){for(var pe=0;0<j;)pe=pe<<1|w(),j--;return pe}function T(j){if(j===1)return w()===1?1:-1;var pe=A(j);return pe>=1<<j-1?pe:pe+(-1<<j)+1}function D(j,pe){var re=C(j.D);for(re=re===0?0:T(re),j.a[pe]=j.m+=re,re=1;64>re;){var le=C(j.o),Q=le&15;if(le>>=4,Q===0){if(15>le)break;re+=16}else re+=le,j.a[pe+f[re]]=T(Q),re++}}function k(j,pe){var re=C(j.D);re=re===0?0:T(re)<<F,j.a[pe]=j.m+=re}function P(j,pe){j.a[pe]|=w()<<F}function I(j,pe){if(0<N)N--;else for(var re=x;re<=v;){var le=C(j.o),Q=le&15;if(le>>=4,Q===0){if(15>le){N=A(le)+(1<<le)-1;break}re+=16}else re+=le,j.a[pe+f[re]]=T(Q)*(1<<F),re++}}function B(j,pe){for(var re=x,le=0,Q;re<=v;){Q=pe+f[re];var se=0>j.a[Q]?-1:1;switch(z){case 0:if(le=C(j.o),Q=le&15,le>>=4,Q===0)15>le?(N=A(le)+(1<<le),z=4):(le=16,z=1);else{if(Q!==1)throw new a("invalid ACn encoding");U=T(Q),z=le?2:3}continue;case 1:case 2:j.a[Q]?j.a[Q]+=se*(w()<<F):(le--,le===0&&(z=z===2?3:0));break;case 3:j.a[Q]?j.a[Q]+=se*(w()<<F):(j.a[Q]=U<<F,z=0);break;case 4:j.a[Q]&&(j.a[Q]+=se*(w()<<F))}re++}z===4&&(N--,N===0&&(z=0))}for(var M=9<arguments.length&&arguments[9]!==void 0?arguments[9]:!1,L=g.P,_=h,R=0,O=0,N=0,z=0,U,H=y.length,V,ne,Z,ee,J=g.S?x===0?S===0?k:P:S===0?I:B:D,te=0,K=H===1?y[0].c*y[0].l:L*g.O,G,ie;te<K;){var fe=b?Math.min(K-te,b):K;for(V=0;V<H;V++)y[V].m=0;if(N=0,H===1){var $=y[0];for(ee=0;ee<fe;ee++)J($,64*(($.c+1)*(te/$.c|0)+te%$.c)),te++}else for(ee=0;ee<fe;ee++){for(V=0;V<H;V++)for($=y[V],G=$.h,ie=$.j,ne=0;ne<ie;ne++)for(Z=0;Z<G;Z++)J($,64*(($.c+1)*((te/L|0)*$.j+ne)+(te%L*$.h+Z)));te++}if(O=0,($=p(m,h))&&$.f&&((0,_util.warn)("decodeScan - unexpected MCU data, current marker is: "+$.f),h=$.offset),$=$&&$.F,!$||65280>=$)throw new a("marker was not found");if(65488<=$&&65495>=$)h+=2;else break}return($=p(m,h))&&$.f&&((0,_util.warn)("decodeScan - unexpected Scan data, current marker is: "+$.f),h=$.offset),h-_}function d(m,h){for(var g=h.c,y=h.l,b=new Int16Array(64),x=0;x<y;x++)for(var v=0;v<g;v++){var S=64*((h.c+1)*x+v),F=b,w=h.G,C=h.a;if(!w)throw new a("missing required Quantization Table.");for(var A=0;64>A;A+=8){var T=C[S+A],D=C[S+A+1],k=C[S+A+2],P=C[S+A+3],I=C[S+A+4],B=C[S+A+5],M=C[S+A+6],L=C[S+A+7];if(T*=w[A],(D|k|P|I|B|M|L)===0)T=5793*T+512>>10,F[A]=T,F[A+1]=T,F[A+2]=T,F[A+3]=T,F[A+4]=T,F[A+5]=T,F[A+6]=T,F[A+7]=T;else{D*=w[A+1],k*=w[A+2],P*=w[A+3],I*=w[A+4],B*=w[A+5],M*=w[A+6],L*=w[A+7];var _=5793*T+128>>8,R=5793*I+128>>8,O=k,N=M;I=2896*(D-L)+128>>8,L=2896*(D+L)+128>>8,P<<=4,B<<=4,_=_+R+1>>1,R=_-R,T=3784*O+1567*N+128>>8,O=1567*O-3784*N+128>>8,N=T,I=I+B+1>>1,B=I-B,L=L+P+1>>1,P=L-P,_=_+N+1>>1,N=_-N,R=R+O+1>>1,O=R-O,T=2276*I+3406*L+2048>>12,I=3406*I-2276*L+2048>>12,L=T,T=799*P+4017*B+2048>>12,P=4017*P-799*B+2048>>12,B=T,F[A]=_+L,F[A+7]=_-L,F[A+1]=R+B,F[A+6]=R-B,F[A+2]=O+P,F[A+5]=O-P,F[A+3]=N+I,F[A+4]=N-I}}for(w=0;8>w;++w)T=F[w],D=F[w+8],k=F[w+16],P=F[w+24],I=F[w+32],B=F[w+40],M=F[w+48],L=F[w+56],(D|k|P|I|B|M|L)===0?(T=5793*T+8192>>14,T=-2040>T?0:2024<=T?255:T+2056>>4,C[S+w]=T,C[S+w+8]=T,C[S+w+16]=T,C[S+w+24]=T,C[S+w+32]=T,C[S+w+40]=T,C[S+w+48]=T,C[S+w+56]=T):(_=5793*T+2048>>12,R=5793*I+2048>>12,O=k,N=M,I=2896*(D-L)+2048>>12,L=2896*(D+L)+2048>>12,_=(_+R+1>>1)+4112,R=_-R,T=3784*O+1567*N+2048>>12,O=1567*O-3784*N+2048>>12,N=T,I=I+B+1>>1,B=I-B,L=L+P+1>>1,P=L-P,_=_+N+1>>1,N=_-N,R=R+O+1>>1,O=R-O,T=2276*I+3406*L+2048>>12,I=3406*I-2276*L+2048>>12,L=T,T=799*P+4017*B+2048>>12,P=4017*P-799*B+2048>>12,B=T,T=_+L,L=_-L,D=R+B,M=R-B,k=O+P,B=O-P,P=N+I,I=N-I,T=16>T?0:4080<=T?255:T>>4,D=16>D?0:4080<=D?255:D>>4,k=16>k?0:4080<=k?255:k>>4,P=16>P?0:4080<=P?255:P>>4,I=16>I?0:4080<=I?255:I>>4,B=16>B?0:4080<=B?255:B>>4,M=16>M?0:4080<=M?255:M>>4,L=16>L?0:4080<=L?255:L>>4,C[S+w]=T,C[S+w+8]=D,C[S+w+16]=k,C[S+w+24]=P,C[S+w+32]=I,C[S+w+40]=B,C[S+w+48]=M,C[S+w+56]=L)}return h.a}function p(m,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:h,y=m.length-1;if(g=g<h?g:h,h>=y)return null;var b=m[h]<<8|m[h+1];if(65472<=b&&65534>=b)return{f:null,F:b,offset:h};for(var x=m[g]<<8|m[g+1];!(65472<=x&&65534>=x);){if(++g>=y)return null;x=m[g]<<8|m[g+1]}return{f:b.toString(16),F:x,offset:g}}var f=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);l.prototype={parse:function(m){function h(){var O=m[v]<<8|m[v+1];return v+=2,O}function g(){var O=h();O=v+O-2;var N=p(m,O,v);return N&&N.f&&((0,_util.warn)("readDataBlock - incorrect length, current marker is: "+N.f),O=N.offset),O=m.subarray(v,O),v+=O.length,O}function y(O){for(var N=Math.ceil(O.v/8/O.s),z=Math.ceil(O.g/8/O.u),U=0;U<O.b.length;U++){_=O.b[U];var H=Math.ceil(Math.ceil(O.v/8)*_.h/O.s),V=Math.ceil(Math.ceil(O.g/8)*_.j/O.u);_.a=new Int16Array(64*z*_.j*(N*_.h+1)),_.c=H,_.l=V}O.P=N,O.O=z}var b=(1<arguments.length&&arguments[1]!==void 0?arguments[1]:{}).N,x=b===void 0?null:b,v=0,S=null,F=0;b=[];var w=[],C=[],A=h();if(A!==65496)throw new a("SOI not found");for(A=h();A!==65497;){switch(A){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var T=g();A===65518&&T[0]===65&&T[1]===100&&T[2]===111&&T[3]===98&&T[4]===101&&(S={version:T[5]<<8|T[6],Y:T[7]<<8|T[8],Z:T[9]<<8|T[10],W:T[11]});break;case 65499:A=h()+v-2;for(var D;v<A;){var k=m[v++],P=new Uint16Array(64);if(k>>4===0)for(T=0;64>T;T++)D=f[T],P[D]=m[v++];else if(k>>4===1)for(T=0;64>T;T++)D=f[T],P[D]=h();else throw new a("DQT - invalid table spec");b[k&15]=P}break;case 65472:case 65473:case 65474:if(I)throw new a("Only single frame JPEGs supported");h();var I={};for(I.X=A===65473,I.S=A===65474,I.precision=m[v++],A=h(),I.g=x||A,I.v=h(),I.b=[],I.C={},T=m[v++],A=P=k=0;A<T;A++){D=m[v];var B=m[v+1]>>4,M=m[v+1]&15;k<B&&(k=B),P<M&&(P=M),B=I.b.push({h:B,j:M,T:m[v+2],G:null}),I.C[D]=B-1,v+=3}I.s=k,I.u=P,y(I);break;case 65476:for(D=h(),A=2;A<D;){for(k=m[v++],P=new Uint8Array(16),T=B=0;16>T;T++,v++)B+=P[T]=m[v];for(M=new Uint8Array(B),T=0;T<B;T++,v++)M[T]=m[v];A+=17+B,(k>>4===0?C:w)[k&15]=c(P,M)}break;case 65501:h();var L=h();break;case 65498:for(T=++F===1&&!x,h(),k=m[v++],D=[],A=0;A<k;A++){P=I.C[m[v++]];var _=I.b[P];P=m[v++],_.D=C[P>>4],_.o=w[P&15],D.push(_)}A=m[v++],k=m[v++],P=m[v++];try{var R=u(m,v,I,D,L,A,k,P>>4,P&15,T);v+=R}catch(O){if(O instanceof s)return(0,_util.warn)('Attempting to re-parse JPEG image using "scanLines" parameter found in DNL marker (0xFFDC) segment.'),this.parse(m,{N:O.g});throw O}break;case 65500:v+=4;break;case 65535:m[v]!==255&&v--;break;default:if(m[v-3]===255&&192<=m[v-2]&&254>=m[v-2])v-=3;else if((T=p(m,v-2))&&T.f)(0,_util.warn)("JpegImage.parse - unexpected data, current marker is: "+T.f),v=T.offset;else throw new a("unknown marker "+A.toString(16))}A=h()}for(this.width=I.v,this.height=I.g,this.A=S,this.b=[],A=0;A<I.b.length;A++)_=I.b[A],(L=b[_.T])&&(_.G=L),this.b.push({R:d(I,_),U:_.h/I.s,V:_.j/I.u,c:_.c,l:_.l});this.i=this.b.length},L:function(m,h){var g=this.width/m,y=this.height/h,b,x,v=this.b.length,S=m*h*v,F=new Uint8ClampedArray(S),w=new Uint32Array(m);for(x=0;x<v;x++){var C=this.b[x],A=C.U*g,T=C.V*y,D=x,k=C.R,P=C.c+1<<3;for(b=0;b<m;b++)C=0|b*A,w[b]=(C&4294967288)<<3|C&7;for(A=0;A<h;A++)for(C=0|A*T,C=P*(C&4294967288)|(C&7)<<3,b=0;b<m;b++)F[D]=k[C+w[b]],D+=v}if(y=this.M)for(x=0;x<S;)for(g=C=0;C<v;C++,x++,g+=2)F[x]=(F[x]*y[g]>>8)+y[g+1];return F},w:function(){return this.A?!!this.A.W:this.i===3?this.B!==0:this.B===1},I:function(m){for(var h,g,y,b=0,x=m.length;b<x;b+=3)h=m[b],g=m[b+1],y=m[b+2],m[b]=h-179.456+1.402*y,m[b+1]=h+135.459-.344*g-.714*y,m[b+2]=h-226.816+1.772*g;return m},K:function(m){for(var h,g,y,b,x=0,v=0,S=m.length;v<S;v+=4)h=m[v],g=m[v+1],y=m[v+2],b=m[v+3],m[x++]=-122.67195406894+g*(-660635669420364e-19*g+.000437130475926232*y-54080610064599e-18*h+.00048449797120281*b-.154362151871126)+y*(-.000957964378445773*y+.000817076911346625*h-.00477271405408747*b+1.53380253221734)+h*(.000961250184130688*h-.00266257332283933*b+.48357088451265)+b*(-.000336197177618394*b+.484791561490776),m[x++]=107.268039397724+g*(219927104525741e-19*g-.000640992018297945*y+.000659397001245577*h+.000426105652938837*b-.176491792462875)+y*(-.000778269941513683*y+.00130872261408275*h+.000770482631801132*b-.151051492775562)+h*(.00126935368114843*h-.00265090189010898*b+.25802910206845)+b*(-.000318913117588328*b-.213742400323665),m[x++]=-20.810012546947+g*(-.000570115196973677*g-263409051004589e-19*y+.0020741088115012*h-.00288260236853442*b+.814272968359295)+y*(-153496057440975e-19*y-.000132689043961446*h+.000560833691242812*b-.195152027534049)+h*(.00174418132927582*h-.00255243321439347*b+.116935020465145)+b*(-.000343531996510555*b+.24165260232407);return m.subarray(0,x)},J:function(m){for(var h,g,y,b=0,x=m.length;b<x;b+=4)h=m[b],g=m[b+1],y=m[b+2],m[b]=434.456-h-1.402*y,m[b+1]=119.541-h+.344*g+.714*y,m[b+2]=481.816-h-1.772*g;return m},H:function(m){for(var h,g,y,b,x=0,v=1/255,S=0,F=m.length;S<F;S+=4)h=m[S]*v,g=m[S+1]*v,y=m[S+2]*v,b=m[S+3]*v,m[x++]=255+h*(-4.387332384609988*h+54.48615194189176*g+18.82290502165302*y+212.25662451639585*b-285.2331026137004)+g*(1.7149763477362134*g-5.6096736904047315*y-17.873870861415444*b-5.497006427196366)+y*(-2.5217340131683033*y-21.248923337353073*b+17.5119270841813)-b*(21.86122147463605*b+189.48180835922747),m[x++]=255+h*(8.841041422036149*h+60.118027045597366*g+6.871425592049007*y+31.159100130055922*b-79.2970844816548)+g*(-15.310361306967817*g+17.575251261109482*y+131.35250912493976*b-190.9453302588951)+y*(4.444339102852739*y+9.8632861493405*b-24.86741582555878)-b*(20.737325471181034*b+187.80453709719578),m[x++]=255+h*(.8842522430003296*h+8.078677503112928*g+30.89978309703729*y-.23883238689178934*b-14.183576799673286)+g*(10.49593273432072*g+63.02378494754052*y+50.606957656360734*b-112.23884253719248)+y*(.03296041114873217*y+115.60384449646641*b-193.58209356861505)-b*(22.33816807309886*b+180.12613974708367);return m.subarray(0,x)},getData:function(m,h,g){if(4<this.i)throw new a("Unsupported color mode");if(m=this.L(m,h),this.i===1&&g){g=m.length,h=new Uint8ClampedArray(3*g);for(var y=0,b=0;b<g;b++){var x=m[b];h[y++]=x,h[y++]=x,h[y++]=x}return h}if(this.i===3&&this.w())return this.I(m);if(this.i===4){if(this.w())return g?this.K(m):this.J(m);if(g)return this.H(m)}return m}},r.JpegDecoder=l})()})(),r.encodeImage=function(i,a,s,l){var c={t256:[a],t257:[s],t258:[8,8,8,8],t259:[1],t262:[2],t273:[1e3],t277:[4],t278:[s],t279:[a*s*4],t282:[1],t283:[1],t284:[1],t286:[0],t287:[0],t296:[1],t305:["Photopea (UTIF.js)"],t338:[1]};if(l)for(var u in l)c[u]=l[u];for(var d=new Uint8Array(r.encode([c])),p=new Uint8Array(i),f=new Uint8Array(1e3+a*s*4),u=0;u<d.length;u++)f[u]=d[u];for(var u=0;u<p.length;u++)f[1e3+u]=p[u];return f.buffer},r.encode=function(i){var a=new Uint8Array(2e4),s=4,l=r._binBE;a[0]=77,a[1]=77,a[3]=42;var c=8;l.writeUint(a,s,c),s+=4;for(var u=0;u<i.length;u++){var d=r._writeIFD(l,a,c,i[u]);c=d[1],u<i.length-1&&l.writeUint(a,d[0],c)}return a.slice(0,c).buffer},r.decode=function(i){r.decode._decodeG3.allow2D=null;var a=new Uint8Array(i),s=0,l=r._binBE.readASCII(a,s,2);s+=2;var c=l=="II"?r._binLE:r._binBE,u=c.readUshort(a,s);s+=2;var d=c.readUint(a,s);s+=4;for(var p=[];;){var f=r._readIFD(c,a,d,p,0,!1);if(d=c.readUint(a,f),d==0)break}return p},r.decodeImage=function(i,a,s){var l=new Uint8Array(i),c=r._binBE.readASCII(l,0,2);if(a.t256!=null){a.isLE=c=="II",a.width=a.t256[0],a.height=a.t257[0];var u=a.t259?a.t259[0]:1,d=a.t266?a.t266[0]:1;a.t284&&a.t284[0]==2&&n("PlanarConfiguration 2 should not be used!");var p;a.t258?p=Math.min(32,a.t258[0])*a.t258.length:p=a.t277?a.t277[0]:1,u==1&&a.t279!=null&&a.t278&&a.t262[0]==32803&&(p=Math.round(a.t279[0]*8/(a.width*a.t278[0])));var f=Math.ceil(a.width*p/8)*8,m=a.t273;m==null&&(m=a.t324);var h=a.t279;u==1&&m.length==1&&(h=[a.height*(f>>>3)]),h==null&&(h=a.t325);var g=new Uint8Array(a.height*(f>>>3)),y=0;if(a.t322!=null){for(var b=a.t322[0],x=a.t323[0],v=Math.floor((a.width+b-1)/b),S=Math.floor((a.height+x-1)/x),F=new Uint8Array(Math.ceil(b*x*p/8)|0),w=0;w<S;w++)for(var C=0;C<v;C++){for(var A=w*v+C,T=0;T<F.length;T++)F[T]=0;r.decode._decompress(a,s,l,m[A],h[A],u,F,0,d),u==6?g=F:r._copyTile(F,Math.ceil(b*p/8)|0,x,g,Math.ceil(a.width*p/8)|0,a.height,Math.ceil(C*b*p/8)|0,w*x)}y=g.length*8}else{var D=a.t278?a.t278[0]:a.height;D=Math.min(D,a.height);for(var A=0;A<m.length;A++)r.decode._decompress(a,s,l,m[A],h[A],u,g,Math.ceil(y/8)|0,d),y+=f*D;y=Math.min(y,g.length*8)}a.data=new Uint8Array(g.buffer,0,Math.ceil(y/8)|0)}},r.decode._decompress=function(i,a,s,l,c,u,d,p,f){if(u==1||c==d.length&&u!=32767)for(var m=0;m<c;m++)d[p+m]=s[l+m];else if(u==3)r.decode._decodeG3(s,l,c,d,p,i.width,f);else if(u==4)r.decode._decodeG4(s,l,c,d,p,i.width,f);else if(u==5)r.decode._decodeLZW(s,l,d,p);else if(u==6)r.decode._decodeOldJPEG(i,s,l,c,d,p);else if(u==7)r.decode._decodeNewJPEG(i,s,l,c,d,p);else if(u==8)for(var h=new Uint8Array(s.buffer,l,c),g=o.inflate(h),y=0;y<g.length;y++)d[p+y]=g[y];else u==32767?r.decode._decodeARW(i,s,l,c,d,p):u==32773?r.decode._decodePackBits(s,l,c,d,p):u==32809?r.decode._decodeThunder(s,l,c,d,p):u==34713?r.decode._decodeNikon(i,a,s,l,c,d,p):n("Unknown compression",u);var b=i.t258?Math.min(32,i.t258[0]):1,x=i.t277?i.t277[0]:1,v=b*x>>>3,S=i.t278?i.t278[0]:i.height,F=Math.ceil(b*x*i.width/8);if(b==16&&!i.isLE&&i.t33422==null)for(var w=0;w<S;w++)for(var C=p+w*F,A=1;A<F;A+=2){var T=d[C+A];d[C+A]=d[C+A-1],d[C+A-1]=T}if(i.t317&&i.t317[0]==2)for(var w=0;w<S;w++){var D=p+w*F;if(b==16)for(var m=v;m<F;m+=2){var k=(d[D+m+1]<<8|d[D+m])+(d[D+m-v+1]<<8|d[D+m-v]);d[D+m]=k&255,d[D+m+1]=k>>>8&255}else if(x==3)for(var m=3;m<F;m+=3)d[D+m]=d[D+m]+d[D+m-3]&255,d[D+m+1]=d[D+m+1]+d[D+m-2]&255,d[D+m+2]=d[D+m+2]+d[D+m-1]&255;else for(var m=v;m<F;m++)d[D+m]=d[D+m]+d[D+m-v]&255}},r.decode._ljpeg_diff=function(i,a,s){var l=r.decode._getbithuff,c,u;return c=l(i,a,s[0],s),u=l(i,a,c,0),(u&1<<c-1)==0&&(u-=(1<<c)-1),u},r.decode._decodeARW=function(i,a,s,l,c,u){var d=i.t256[0],p=i.t257[0],f=i.t258[0],m=i.isLE?r._binLE:r._binBE,h=d*p==l||d*p*1.5==l;if(!h){p+=8;var g=[s,0,0,0],y=new Uint16Array(32770),b=[3857,3856,3599,3342,3085,2828,2571,2314,2057,1800,1543,1286,1029,772,771,768,514,513],z,x,v,I,P,S=0,F=r.decode._ljpeg_diff;for(y[0]=15,v=z=0;z<18;z++)for(var w=32768>>>(b[z]>>>8),x=0;x<w;x++)y[++v]=b[z];for(I=d;I--;)for(P=0;P<p+1;P+=2)if(P==p&&(P=1),S+=F(a,g,y),P<p){var C=S&4095;r.decode._putsF(c,(P*d+I)*f,C<<16-f)}return}if(d*p*1.5==l){for(var z=0;z<l;z+=3){var A=a[s+z+0],T=a[s+z+1],D=a[s+z+2];c[u+z]=T<<4|A>>>4,c[u+z+1]=A<<4|D>>>4,c[u+z+2]=D<<4|T>>>4}return}var k=new Uint16Array(16),P,I,B,M,L,_,R,O,N,z,U,H=new Uint8Array(d+1);for(P=0;P<p;P++){for(var V=0;V<d;V++)H[V]=a[s++];for(U=0,I=0;I<d-30;U+=16){for(M=2047&(B=m.readUint(H,U)),L=2047&B>>>11,_=15&B>>>22,R=15&B>>>26,O=0;O<4&&128<<O<=M-L;O++);for(N=30,z=0;z<16;z++)z==_?k[z]=M:z==R?k[z]=L:(k[z]=((m.readUshort(H,U+(N>>3))>>>(N&7)&127)<<O)+L,k[z]>2047&&(k[z]=2047),N+=7);for(z=0;z<16;z++,I+=2){var C=k[z]<<1;r.decode._putsF(c,(P*d+I)*f,C<<16-f)}I-=I&1?1:31}}},r.decode._decodeNikon=function(i,a,s,l,c,u,d){var p=[[0,0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,5,4,3,6,2,7,1,0,8,9,11,10,12],[0,0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,57,90,56,39,22,5,4,3,2,1,0,11,12,12],[0,0,1,4,2,3,1,2,0,0,0,0,0,0,0,0,0,5,4,6,3,7,2,8,1,9,0,10,11,12],[0,0,1,4,3,1,1,1,1,1,2,0,0,0,0,0,0,5,6,4,7,8,3,9,2,1,0,10,11,12,13,14],[0,0,1,5,1,1,1,1,1,1,1,2,0,0,0,0,0,8,92,75,58,41,7,6,5,4,3,2,1,0,13,14],[0,0,1,4,2,2,3,1,2,0,0,0,0,0,0,0,0,7,6,8,5,9,4,10,3,11,12,2,0,1,13,14]],f=i.t256[0],m=i.t257[0],h=i.t258[0],g=0,y=0,b=r.decode._make_decoder,x=r.decode._getbithuff,v=a[0].exifIFD.makerNote,S=v.t150?v.t150:v.t140,F=0,w=S[F++],C=S[F++];(w==73||C==88)&&(F+=2110),w==70&&(g=2),h==14&&(g+=3);for(var A=[[0,0],[0,0]],T=i.isLE?r._binLE:r._binBE,B=0;B<2;B++)for(var D=0;D<2;D++)A[B][D]=T.readShort(S,F),F+=2;var k=1<<h&32767,P=0,I=T.readShort(S,F);F+=2,I>1&&(P=Math.floor(k/(I-1))),w==68&&C==32&&P>0&&(y=T.readShort(S,562));var B,M,L,_,R,O,N=0,z=[0,0],U=b(p[g]),H=[l,0,0,0];for(N=M=0;M<m;M++)for(y&&M==y&&(U=b(p[g+1])),L=0;L<f;L++){B=x(s,H,U[0],U),_=B&15,R=B>>>4,O=(x(s,H,_-R,0)<<1)+1<<R>>>1,(O&1<<_-1)==0&&(O-=(1<<_)-(R==0?1:0)),L<2?z[L]=A[M&1][L]+=O:z[L&1]+=O;var V=Math.min(Math.max(z[L&1],0),(1<<h)-1),ne=(M*f+L)*h;r.decode._putsF(u,ne,V<<16-h)}},r.decode._putsF=function(i,a,s){s=s<<8-(a&7);var l=a>>>3;i[l]|=s>>>16,i[l+1]|=s>>>8,i[l+2]|=s},r.decode._getbithuff=function(i,a,s,l){var c=0,u=r.decode._get_byte,d,p=a[0],f=a[1],m=a[2],h=a[3];if(s==0||m<0)return 0;for(;!h&&m<s&&(d=i[p++])!=-1&&!(h=c&&d==255&&i[p++]);)f=(f<<8)+d,m+=8;if(d=f<<32-m>>>32-s,l?(m-=l[d+1]>>>8,d=l[d+1]&255):m-=s,m<0)throw"e";return a[0]=p,a[1]=f,a[2]=m,a[3]=h,d},r.decode._make_decoder=function(i){var a,s,l,c,u,d=[];for(a=16;a!=0&&!i[a];a--);var p=17;for(d[0]=a,l=s=1;s<=a;s++)for(c=0;c<i[s];c++,++p)for(u=0;u<1<<a-s;u++)l<=1<<a&&(d[l++]=s<<8|i[p]);return d},r.decode._decodeNewJPEG=function(i,a,s,l,c,u){var d=i.t347,p=d?d.length:0,f=new Uint8Array(p+l);if(d){for(var m=216,h=217,g=0,y=0;y<p-1&&!(d[y]==255&&d[y+1]==h);y++)f[g++]=d[y];var b=a[s],x=a[s+1];(b!=255||x!=m)&&(f[g++]=b,f[g++]=x);for(var y=2;y<l;y++)f[g++]=a[s+y]}else for(var y=0;y<l;y++)f[y]=a[s+y];if(i.t262[0]==32803||i.t262[0]==34892){var v=i.t258[0],S=r.LosslessJpegDecode(f),F=S.length;if(v==16)if(i.isLE)for(var y=0;y<F;y++)c[u+(y<<1)]=S[y]&255,c[u+(y<<1)+1]=S[y]>>>8;else for(var y=0;y<F;y++)c[u+(y<<1)]=S[y]>>>8,c[u+(y<<1)+1]=S[y]&255;else if(v==14||v==12)for(var w=16-v,y=0;y<F;y++)r.decode._putsF(c,y*v,S[y]<<w);else throw new Error("unsupported bit depth "+v)}else{var C=new r.JpegDecoder;C.parse(f);for(var A=C.getData(C.width,C.height),y=0;y<A.length;y++)c[u+y]=A[y]}i.t262[0]==6&&(i.t262[0]=2)},r.decode._decodeOldJPEGInit=function(i,a,s,l){var c=216,u=217,d=219,p=196,f=221,m=192,h=218,g=0,y=0,b,x,v=!1,S,F,w,C=i.t513,A=C?C[0]:0,T=i.t514,D=T?T[0]:0,k=i.t324||i.t273||C,P=i.t530,I=0,B=0,M=i.t277?i.t277[0]:1,L=i.t515;if(k&&(y=k[0],v=k.length>1),!v){if(a[s]==255&&a[s+1]==c)return{jpegOffset:s};if(C!=null&&(a[s+A]==255&&a[s+A+1]==c?g=s+A:n("JPEGInterchangeFormat does not point to SOI"),T==null?n("JPEGInterchangeFormatLength field is missing"):(A>=y||A+D<=y)&&n("JPEGInterchangeFormatLength field value is invalid"),g!=null))return{jpegOffset:g}}if(P!=null&&(I=P[0],B=P[1]),C!=null&&T!=null)if(D>=2&&A+D<=y){for(a[s+A+D-2]==255&&a[s+A+D-1]==c?b=new Uint8Array(D-2):b=new Uint8Array(D),S=0;S<b.length;S++)b[S]=a[s+A+S];n("Incorrect JPEG interchange format: using JPEGInterchangeFormat offset to derive tables")}else n("JPEGInterchangeFormat+JPEGInterchangeFormatLength > offset to first strip or tile");if(b==null){var _=0,R=[];R[_++]=255,R[_++]=c;var O=i.t519;if(O==null)throw new Error("JPEGQTables tag is missing");for(S=0;S<O.length;S++)for(R[_++]=255,R[_++]=d,R[_++]=0,R[_++]=67,R[_++]=S,F=0;F<64;F++)R[_++]=a[s+O[S]+F];for(w=0;w<2;w++){var N=i[w==0?"t520":"t521"];if(N==null)throw new Error((w==0?"JPEGDCTables":"JPEGACTables")+" tag is missing");for(S=0;S<N.length;S++){R[_++]=255,R[_++]=p;var z=19;for(F=0;F<16;F++)z+=a[s+N[S]+F];for(R[_++]=z>>>8,R[_++]=z&255,R[_++]=S|w<<4,F=0;F<16;F++)R[_++]=a[s+N[S]+F];for(F=0;F<z;F++)R[_++]=a[s+N[S]+16+F]}}if(R[_++]=255,R[_++]=m,R[_++]=0,R[_++]=8+3*M,R[_++]=8,R[_++]=i.height>>>8&255,R[_++]=i.height&255,R[_++]=i.width>>>8&255,R[_++]=i.width&255,R[_++]=M,M==1)R[_++]=1,R[_++]=17,R[_++]=0;else for(S=0;S<3;S++)R[_++]=S+1,R[_++]=S!=0?17:(I&15)<<4|B&15,R[_++]=S;L!=null&&L[0]!=0&&(R[_++]=255,R[_++]=f,R[_++]=0,R[_++]=4,R[_++]=L[0]>>>8&255,R[_++]=L[0]&255),b=new Uint8Array(R)}var U=-1;for(S=0;S<b.length-1;){if(b[S]==255&&b[S+1]==m){U=S;break}S++}if(U==-1){var H=new Uint8Array(b.length+10+3*M);H.set(b);var V=b.length;if(U=b.length,b=H,b[V++]=255,b[V++]=m,b[V++]=0,b[V++]=8+3*M,b[V++]=8,b[V++]=i.height>>>8&255,b[V++]=i.height&255,b[V++]=i.width>>>8&255,b[V++]=i.width&255,b[V++]=M,M==1)b[V++]=1,b[V++]=17,b[V++]=0;else for(S=0;S<3;S++)b[V++]=S+1,b[V++]=S!=0?17:(I&15)<<4|B&15,b[V++]=S}if(a[y]==255&&a[y+1]==h){var ne=a[y+2]<<8|a[y+3];for(x=new Uint8Array(ne+2),x[0]=a[y],x[1]=a[y+1],x[2]=a[y+2],x[3]=a[y+3],S=0;S<ne-2;S++)x[S+4]=a[y+S+4]}else{x=new Uint8Array(8+2*M);var Z=0;if(x[Z++]=255,x[Z++]=h,x[Z++]=0,x[Z++]=6+2*M,x[Z++]=M,M==1)x[Z++]=1,x[Z++]=0;else for(S=0;S<3;S++)x[Z++]=S+1,x[Z++]=S<<4|S;x[Z++]=0,x[Z++]=63,x[Z++]=0}return{jpegOffset:s,tables:b,sosMarker:x,sofPosition:U}},r.decode._decodeOldJPEG=function(i,a,s,l,c,u){var d,p,f,m,h,g=r.decode._decodeOldJPEGInit(i,a,s,l);if(g.jpegOffset!=null)for(p=s+l-g.jpegOffset,m=new Uint8Array(p),d=0;d<p;d++)m[d]=a[g.jpegOffset+d];else{for(f=g.tables.length,m=new Uint8Array(f+g.sosMarker.length+l+2),m.set(g.tables),h=f,m[g.sofPosition+5]=i.height>>>8&255,m[g.sofPosition+6]=i.height&255,m[g.sofPosition+7]=i.width>>>8&255,m[g.sofPosition+8]=i.width&255,(a[s]!=255||a[s+1]!=SOS)&&(m.set(g.sosMarker,h),h+=sosMarker.length),d=0;d<l;d++)m[h++]=a[s+d];m[h++]=255,m[h++]=EOI}var y=new r.JpegDecoder;y.parse(m);for(var b=y.getData(y.width,y.height),d=0;d<b.length;d++)c[u+d]=b[d];i.t262&&i.t262[0]==6&&(i.t262[0]=2)},r.decode._decodePackBits=function(i,a,s,l,c){for(var u=new Int8Array(i.buffer),d=new Int8Array(l.buffer),p=a+s;a<p;){var f=u[a];if(a++,f>=0&&f<128)for(var m=0;m<f+1;m++)d[c]=u[a],c++,a++;if(f>=-127&&f<0){for(var m=0;m<-f+1;m++)d[c]=u[a],c++;a++}}},r.decode._decodeThunder=function(i,a,s,l,c){for(var u=[0,1,0,-1],d=[0,1,2,3,0,-3,-2,-1],p=a+s,f=c*2,m=0;a<p;){var h=i[a],g=h>>>6,y=h&63;if(a++,g==3&&(m=y&15,l[f>>>1]|=m<<4*(1-f&1),f++),g==0)for(var b=0;b<y;b++)l[f>>>1]|=m<<4*(1-f&1),f++;if(g==2)for(var b=0;b<2;b++){var x=y>>>3*(1-b)&7;x!=4&&(m+=d[x],l[f>>>1]|=m<<4*(1-f&1),f++)}if(g==1)for(var b=0;b<3;b++){var x=y>>>2*(2-b)&3;x!=2&&(m+=u[x],l[f>>>1]|=m<<4*(1-f&1),f++)}}},r.decode._dmap={1:0,"011":1,"000011":2,"0000011":3,"010":-1,"000010":-2,"0000010":-3},r.decode._lens=(function(){var i=function(f,m,h,g){for(var y=0;y<m.length;y++)f[m[y]]=h+y*g},a="00110101,000111,0111,1000,1011,1100,1110,1111,10011,10100,00111,01000,001000,000011,110100,110101,101010,101011,0100111,0001100,0001000,0010111,0000011,0000100,0101000,0101011,0010011,0100100,0011000,00000010,00000011,00011010,00011011,00010010,00010011,00010100,00010101,00010110,00010111,00101000,00101001,00101010,00101011,00101100,00101101,00000100,00000101,00001010,00001011,01010010,01010011,01010100,01010101,00100100,00100101,01011000,01011001,01011010,01011011,01001010,01001011,00110010,00110011,00110100",s="0000110111,010,11,10,011,0011,0010,00011,000101,000100,0000100,0000101,0000111,00000100,00000111,000011000,0000010111,0000011000,0000001000,00001100111,00001101000,00001101100,00000110111,00000101000,00000010111,00000011000,000011001010,000011001011,000011001100,000011001101,000001101000,000001101001,000001101010,000001101011,000011010010,000011010011,000011010100,000011010101,000011010110,000011010111,000001101100,000001101101,000011011010,000011011011,000001010100,000001010101,000001010110,000001010111,000001100100,000001100101,000001010010,000001010011,000000100100,000000110111,000000111000,000000100111,000000101000,000001011000,000001011001,000000101011,000000101100,000001011010,000001100110,000001100111",l="11011,10010,010111,0110111,00110110,00110111,01100100,01100101,01101000,01100111,011001100,011001101,011010010,011010011,011010100,011010101,011010110,011010111,011011000,011011001,011011010,011011011,010011000,010011001,010011010,011000,010011011",c="0000001111,000011001000,000011001001,000001011011,000000110011,000000110100,000000110101,0000001101100,0000001101101,0000001001010,0000001001011,0000001001100,0000001001101,0000001110010,0000001110011,0000001110100,0000001110101,0000001110110,0000001110111,0000001010010,0000001010011,0000001010100,0000001010101,0000001011010,0000001011011,0000001100100,0000001100101",u="00000001000,00000001100,00000001101,000000010010,000000010011,000000010100,000000010101,000000010110,000000010111,000000011100,000000011101,000000011110,000000011111";a=a.split(","),s=s.split(","),l=l.split(","),c=c.split(","),u=u.split(",");var d={},p={};return i(d,a,0,1),i(d,l,64,64),i(d,u,1792,64),i(p,s,0,1),i(p,c,64,64),i(p,u,1792,64),[d,p]})(),r.decode._decodeG4=function(i,a,s,l,c,u,d){for(var p=r.decode,f=a<<3,m=0,h="",g=[],y=[],b=0;b<u;b++)y.push(0);y=p._makeDiff(y);for(var x=0,v=0,S=0,F=0,w=0,C=0,A=0,T="",D=0,k=Math.ceil(u/8)*8;f>>>3<a+s;){F=p._findDiff(y,x+(x==0?0:1),1-C),w=p._findDiff(y,F,C);var P=0;if(d==1&&(P=i[f>>>3]>>>7-(f&7)&1),d==2&&(P=i[f>>>3]>>>(f&7)&1),f++,h+=P,T=="H"){if(p._lens[C][h]!=null){var I=p._lens[C][h];h="",m+=I,I<64&&(p._addNtimes(g,m,C),x+=m,C=1-C,m=0,D--,D==0&&(T=""))}}else h=="0001"&&(h="",p._addNtimes(g,w-x,C),x=w),h=="001"&&(h="",T="H",D=2),p._dmap[h]!=null&&(v=F+p._dmap[h],p._addNtimes(g,v-x,C),x=v,h="",C=1-C);g.length==u&&T==""&&(p._writeBits(g,l,c*8+A*k),C=0,A++,x=0,y=p._makeDiff(g),g=[])}},r.decode._findDiff=function(i,a,s){for(var l=0;l<i.length;l+=2)if(i[l]>=a&&i[l+1]==s)return i[l]},r.decode._makeDiff=function(i){var a=[];i[0]==1&&a.push(0,1);for(var s=1;s<i.length;s++)i[s-1]!=i[s]&&a.push(s,i[s]);return a.push(i.length,0,i.length,1),a},r.decode._decodeG3=function(i,a,s,l,c,u,d){for(var p=r.decode,f=a<<3,m=0,h="",g=[],y=[],b=0;b<u;b++)g.push(0);for(var x=0,v=0,S=0,F=0,w=0,C=0,A=-1,T="",D=0,k=!1,P=Math.ceil(u/8)*8;f>>>3<a+s;){F=p._findDiff(y,x+(x==0?0:1),1-C),w=p._findDiff(y,F,C);var I=0;if(d==1&&(I=i[f>>>3]>>>7-(f&7)&1),d==2&&(I=i[f>>>3]>>>(f&7)&1),f++,h+=I,k){if(p._lens[C][h]!=null){var B=p._lens[C][h];h="",m+=B,B<64&&(p._addNtimes(g,m,C),C=1-C,m=0)}}else if(T=="H"){if(p._lens[C][h]!=null){var B=p._lens[C][h];h="",m+=B,B<64&&(p._addNtimes(g,m,C),x+=m,C=1-C,m=0,D--,D==0&&(T=""))}}else h=="0001"&&(h="",p._addNtimes(g,w-x,C),x=w),h=="001"&&(h="",T="H",D=2),p._dmap[h]!=null&&(v=F+p._dmap[h],p._addNtimes(g,v-x,C),x=v,h="",C=1-C);h.endsWith("000000000001")&&(A>=0&&p._writeBits(g,l,c*8+A*P),d==1&&(k=(i[f>>>3]>>>7-(f&7)&1)==1),d==2&&(k=(i[f>>>3]>>>(f&7)&1)==1),f++,p._decodeG3.allow2D==null&&(p._decodeG3.allow2D=k),p._decodeG3.allow2D||(k=!0,f--),h="",C=0,A++,x=0,y=p._makeDiff(g),g=[])}g.length==u&&p._writeBits(g,l,c*8+A*P)},r.decode._addNtimes=function(i,a,s){for(var l=0;l<a;l++)i.push(s)},r.decode._writeBits=function(i,a,s){for(var l=0;l<i.length;l++)a[s+l>>>3]|=i[l]<<7-(s+l&7)},r.decode._decodeLZW=function(i,a,s,l){if(r.decode._lzwTab==null){for(var c=new Uint32Array(65535),u=new Uint16Array(65535),h=new Uint8Array(2e6),d=0;d<256;d++)h[d<<2]=d,c[d]=d<<2,u[d]=1;r.decode._lzwTab=[c,u,h]}for(var p=r.decode._copyData,f=r.decode._lzwTab[0],m=r.decode._lzwTab[1],h=r.decode._lzwTab[2],g=258,y=1032,b=9,x=a<<3,v=256,S=257,F=0,w=0,C=0;F=i[x>>>3]<<16|i[x+8>>>3]<<8|i[x+16>>>3],w=F>>24-(x&7)-b&(1<<b)-1,x+=b,w!=S;){if(w==v){if(b=9,g=258,y=1032,F=i[x>>>3]<<16|i[x+8>>>3]<<8|i[x+16>>>3],w=F>>24-(x&7)-b&(1<<b)-1,x+=b,w==S)break;s[l]=w,l++}else if(w<g){var A=f[w],T=m[w];if(p(h,A,s,l,T),l+=T,C>=g)f[g]=y,h[f[g]]=A[0],m[g]=1,y=y+1+3&-4,g++;else{f[g]=y;var D=f[C],k=m[C];p(h,D,h,y,k),h[y+k]=h[A],k++,m[g]=k,g++,y=y+k+3&-4}g+1==1<<b&&b++}else{if(C>=g)f[g]=y,m[g]=0,g++;else{f[g]=y;var D=f[C],k=m[C];p(h,D,h,y,k),h[y+k]=h[y],k++,m[g]=k,g++,p(h,y,s,l,k),l+=k,y=y+k+3&-4}g+1==1<<b&&b++}C=w}},r.decode._copyData=function(i,a,s,l,c){for(var u=0;u<c;u+=4)s[l+u]=i[a+u],s[l+u+1]=i[a+u+1],s[l+u+2]=i[a+u+2],s[l+u+3]=i[a+u+3]},r.tags={},r.ttypes={256:3,257:3,258:3,259:3,262:3,273:4,274:3,277:3,278:4,279:4,282:5,283:5,284:3,286:5,287:5,296:3,305:2,306:2,338:3,513:4,514:4,34665:4},r._readIFD=function(i,a,s,l,c,u){var d=i.readUshort(a,s);s+=2;var p={};l.push(p),u&&n(" ".repeat(c),l.length-1,">>>----------------");for(var f=0;f<d;f++){var m=i.readUshort(a,s);s+=2;var h=i.readUshort(a,s);s+=2;var g=i.readUint(a,s);s+=4;var y=i.readUint(a,s);s+=4;var b=[];if((h==1||h==7)&&(b=new Uint8Array(a.buffer,g<5?s-4:y,g)),h==2){var x=g<5?s-4:y,v=a[x];v<128?b.push(i.readASCII(a,x,g-1)):b=new Uint8Array(a.buffer,x,g-1)}if(h==3)for(var S=0;S<g;S++)b.push(i.readUshort(a,(g<3?s-4:y)+2*S));if(h==4)for(var S=0;S<g;S++)b.push(i.readUint(a,(g<2?s-4:y)+4*S));if(h==5)for(var S=0;S<g;S++)b.push(i.readUint(a,y+S*8)/i.readUint(a,y+S*8+4));if(h==8)for(var S=0;S<g;S++)b.push(i.readShort(a,(g<3?s-4:y)+2*S));if(h==9)for(var S=0;S<g;S++)b.push(i.readInt(a,(g<2?s-4:y)+4*S));if(h==10)for(var S=0;S<g;S++)b.push(i.readInt(a,y+S*8)/i.readInt(a,y+S*8+4));if(h==11)for(var S=0;S<g;S++)b.push(i.readFloat(a,y+S*4));if(h==12)for(var S=0;S<g;S++)b.push(i.readDouble(a,y+S*8));if(p["t"+m]=b,g!=0&&b.length==0&&n("unknown TIFF tag type: ",h,"num:",g),u&&n(" ".repeat(c),m,h,r.tags[m],b),!(m==330&&p.t272&&p.t272[0]=="DSLR-A100")){if(m==330||m==34665||m==50740&&i.readUshort(a,i.readUint(b,0))<300){for(var F=m==50740?[i.readUint(b,0)]:b,w=[],S=0;S<F.length;S++)r._readIFD(i,a,F[S],w,c+1,u);m==330&&(p.subIFD=w),m==34665&&(p.exifIFD=w[0]),m==50740&&(p.dngPrvt=w[0])}}if(m==37500){var C=b;if(i.readASCII(C,0,5)=="Nikon")p.makerNote=r.decode(C.slice(10).buffer)[0];else if(i.readUshort(a,y)<300){var A=[];r._readIFD(i,a,y,A,c+1,u),p.makerNote=A[0]}}}return u&&n(" ".repeat(c),"<<<---------------"),s},r._writeIFD=function(i,a,s,l){var c=Object.keys(l);i.writeUshort(a,s,c.length),s+=2;for(var u=s+c.length*12+4,d=0;d<c.length;d++){var p=c[d],f=parseInt(p.slice(1)),m=r.ttypes[f];if(m==null)throw new Error("unknown type of tag: "+f);var h=l[p];m==2&&(h=h[0]+"\0");var g=h.length;i.writeUshort(a,s,f),s+=2,i.writeUshort(a,s,m),s+=2,i.writeUint(a,s,g),s+=4;var y=[-1,1,1,2,4,8,0,0,0,0,0,0,8][m]*g,b=s;if(y>4&&(i.writeUint(a,s,u),b=u),m==2&&i.writeASCII(a,b,h),m==3)for(var x=0;x<g;x++)i.writeUshort(a,b+2*x,h[x]);if(m==4)for(var x=0;x<g;x++)i.writeUint(a,b+4*x,h[x]);if(m==5)for(var x=0;x<g;x++)i.writeUint(a,b+8*x,Math.round(h[x]*1e4)),i.writeUint(a,b+8*x+4,1e4);if(m==12)for(var x=0;x<g;x++)i.writeDouble(a,b+8*x,h[x]);y>4&&(y+=y&1,u+=y),s+=4}return[s,u]},r.toRGBA8=function(i){var a=i.width,s=i.height,l=a*s,c=l*4,u=i.data,d=new Uint8Array(l*4),p=i.t262?i.t262[0]:2,f=i.t258?Math.min(32,i.t258[0]):1;if(p==0)for(var m=Math.ceil(f*a/8),h=0;h<s;h++){var g=h*m,y=h*a;if(f==1)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(b>>3)]>>7-(b&7)&1;d[x]=d[x+1]=d[x+2]=(1-v)*255,d[x+3]=255}if(f==4)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(b>>1)]>>4-4*(b&1)&15;d[x]=d[x+1]=d[x+2]=(15-v)*17,d[x+3]=255}if(f==8)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+b];d[x]=d[x+1]=d[x+2]=255-v,d[x+3]=255}}else if(p==1)for(var m=Math.ceil(f*a/8),h=0;h<s;h++){var g=h*m,y=h*a;if(f==1)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(b>>3)]>>7-(b&7)&1;d[x]=d[x+1]=d[x+2]=v*255,d[x+3]=255}if(f==2)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(b>>2)]>>6-2*(b&3)&3;d[x]=d[x+1]=d[x+2]=v*85,d[x+3]=255}if(f==8)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+b];d[x]=d[x+1]=d[x+2]=v,d[x+3]=255}if(f==16)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(2*b+1)];d[x]=d[x+1]=d[x+2]=Math.min(255,v),d[x+3]=255}}else if(p==2){var S=i.t258?i.t258.length:3;if(f==8){if(S==4)for(var b=0;b<c;b++)d[b]=u[b];if(S==3)for(var b=0;b<l;b++){var x=b<<2,F=b*3;d[x]=u[F],d[x+1]=u[F+1],d[x+2]=u[F+2],d[x+3]=255}}else{if(S==4)for(var b=0;b<l;b++){var x=b<<2,F=b*8+1;d[x]=u[F],d[x+1]=u[F+2],d[x+2]=u[F+4],d[x+3]=u[F+6]}if(S==3)for(var b=0;b<l;b++){var x=b<<2,F=b*6+1;d[x]=u[F],d[x+1]=u[F+2],d[x+2]=u[F+4],d[x+3]=255}}}else if(p==3)for(var w=i.t320,b=0;b<l;b++){var x=b<<2,C=u[b];d[x]=w[C]>>8,d[x+1]=w[256+C]>>8,d[x+2]=w[512+C]>>8,d[x+3]=255}else if(p==5)for(var S=i.t258?i.t258.length:4,A=S>4?1:0,b=0;b<l;b++){var x=b<<2,T=b*S,D=255-u[T],k=255-u[T+1],P=255-u[T+2],I=(255-u[T+3])*(1/255);d[x]=~~(D*I+.5),d[x+1]=~~(k*I+.5),d[x+2]=~~(P*I+.5),d[x+3]=255*(1-A)+u[T+4]*A}else n("Unknown Photometric interpretation: "+p);return d},r.replaceIMG=function(i){i==null&&(i=document.getElementsByTagName("img"));for(var a=["tif","tiff","dng","cr2","nef"],s=0;s<i.length;s++){var l=i[s],c=l.getAttribute("src");if(c!=null){var u=c.split(".").pop().toLowerCase();if(a.indexOf(u)!=-1){var d=new XMLHttpRequest;r._xhrs.push(d),r._imgs.push(l),d.open("GET",c),d.responseType="arraybuffer",d.onload=r._imgLoaded,d.send()}}}},r._xhrs=[],r._imgs=[],r._imgLoaded=function(i){var a=i.target.response,s=r.decode(a),l=s,c=0,u=l[0];s[0].subIFD&&(l=l.concat(s[0].subIFD));for(var d=0;d<l.length;d++){var y=l[d];if(!(y.t258==null||y.t258.length<3)){var p=y.t256*y.t257;p>c&&(c=p,u=y)}}r.decodeImage(a,u,s);var f=r.toRGBA8(u),m=u.width,h=u.height,g=r._xhrs.indexOf(i.target),y=r._imgs[g];r._xhrs.splice(g,1),r._imgs.splice(g,1);var b=document.createElement("canvas");b.width=m,b.height=h;for(var x=b.getContext("2d"),v=x.createImageData(m,h),d=0;d<f.length;d++)v.data[d]=f[d];x.putImageData(v,0,0),y.setAttribute("src",b.toDataURL())},r._binBE={nextZero:function(i,a){for(;i[a]!=0;)a++;return a},readUshort:function(i,a){return i[a]<<8|i[a+1]},readShort:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+1],s[1]=i[a+0],r._binBE.i16[0]},readInt:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+3],s[1]=i[a+2],s[2]=i[a+1],s[3]=i[a+0],r._binBE.i32[0]},readUint:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+3],s[1]=i[a+2],s[2]=i[a+1],s[3]=i[a+0],r._binBE.ui32[0]},readASCII:function(i,a,s){for(var l="",c=0;c<s;c++)l+=String.fromCharCode(i[a+c]);return l},readFloat:function(i,a){for(var s=r._binBE.ui8,l=0;l<4;l++)s[l]=i[a+3-l];return r._binBE.fl32[0]},readDouble:function(i,a){for(var s=r._binBE.ui8,l=0;l<8;l++)s[l]=i[a+7-l];return r._binBE.fl64[0]},writeUshort:function(i,a,s){i[a]=s>>8&255,i[a+1]=s&255},writeUint:function(i,a,s){i[a]=s>>24&255,i[a+1]=s>>16&255,i[a+2]=s>>8&255,i[a+3]=s>>0&255},writeASCII:function(i,a,s){for(var l=0;l<s.length;l++)i[a+l]=s.charCodeAt(l)},writeDouble:function(i,a,s){r._binBE.fl64[0]=s;for(var l=0;l<8;l++)i[a+l]=r._binBE.ui8[7-l]}},r._binBE.ui8=new Uint8Array(8),r._binBE.i16=new Int16Array(r._binBE.ui8.buffer),r._binBE.i32=new Int32Array(r._binBE.ui8.buffer),r._binBE.ui32=new Uint32Array(r._binBE.ui8.buffer),r._binBE.fl32=new Float32Array(r._binBE.ui8.buffer),r._binBE.fl64=new Float64Array(r._binBE.ui8.buffer),r._binLE={nextZero:r._binBE.nextZero,readUshort:function(i,a){return i[a+1]<<8|i[a]},readShort:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+0],s[1]=i[a+1],r._binBE.i16[0]},readInt:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+0],s[1]=i[a+1],s[2]=i[a+2],s[3]=i[a+3],r._binBE.i32[0]},readUint:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+0],s[1]=i[a+1],s[2]=i[a+2],s[3]=i[a+3],r._binBE.ui32[0]},readASCII:r._binBE.readASCII,readFloat:function(i,a){for(var s=r._binBE.ui8,l=0;l<4;l++)s[l]=i[a+l];return r._binBE.fl32[0]},readDouble:function(i,a){for(var s=r._binBE.ui8,l=0;l<8;l++)s[l]=i[a+l];return r._binBE.fl64[0]}},r._copyTile=function(i,a,s,l,c,u,d,p){for(var f=Math.min(a,c-d),m=Math.min(s,u-p),h=0;h<m;h++)for(var g=(p+h)*c+d,y=h*a,b=0;b<f;b++)l[g+b]=i[y+b]},r.LosslessJpegDecode=(function(){function i(c){this.w=c,this.N=0,this._=0,this.G=0}i.prototype={t:function(c){this.N=Math.max(0,Math.min(this.w.length,c))},i:function(){return this.w[this.N++]},l:function(){var c=this.N;return this.N+=2,this.w[c]<<8|this.w[c+1]},J:function(){return this._==0&&(this.G=this.w[this.N],this.N+=1+(this.G+1>>>8),this._=8),this.G>>>--this._&1},Z:function(c){var u=this._,d=this.G,p=Math.min(u,c);c-=p,u-=p;for(var f=d>>>u&(1<<p)-1;c>0;)d=this.w[this.N],this.N+=1+(d+1>>>8),p=Math.min(8,c),c-=p,u=8-p,f<<=p,f|=d>>>u&(1<<p)-1;return this._=u,this.G=d,f}};var a={};a.X=function(){return[0,0,-1]},a.s=function(c,u,d){c[a.Y(c,0,d)+2]=u},a.Y=function(c,u,d){if(c[u+2]!=-1)return 0;if(d==0)return u;for(var p=0;p<2;p++){c[u+p]==0&&(c[u+p]=c.length,c.push(0),c.push(0),c.push(-1));var f=a.Y(c,c[u+p],d-1);if(f!=0)return f}return 0},a.B=function(c,u){for(var d=0,p=0,f=0,m=u._,h=u.G,g=u.N;;)if(m==0&&(h=u.w[g],g+=1+(h+1>>>8),m=8),f=h>>>--m&1,d=c[d+f],p=c[d+2],p!=-1)return u._=m,u.G=h,u.N=g,p;return-1};function s(c){this.z=new i(c),this.D(this.z)}s.prototype={$:function(c,u){this.Q=c.i(),this.F=c.l(),this.o=c.l();var d=this.O=c.i();this.L=[];for(var p=0;p<d;p++){var f=c.i(),m=c.i();c.i(),this.L[f]=p}c.t(c.N+u-(6+d*3))},e:function(){var c=0,u=this.z.i();this.H==null&&(this.H={});for(var d=this.H[u]=a.X(),p=[],f=0;f<16;f++)p[f]=this.z.i(),c+=p[f];for(var f=0;f<16;f++)for(var m=0;m<p[f];m++)a.s(d,this.z.i(),f+1);return c+17},W:function(c){for(;c>0;)c-=this.e()},p:function(c,u){var d=c.i();this.U||(this.U=[]);for(var p=0;p<d;p++){var f=c.i(),m=c.i();this.U[this.L[f]]=this.H[m>>>4]}this.g=c.i(),c.t(c.N+u-(2+d*2))},D:function(c){var u=!1,d=c.l();if(d===s.q)do{var d=c.l(),p=c.l()-2;switch(d){case s.m:this.$(c,p);break;case s.K:this.W(p);break;case s.V:this.p(c,p),u=!0;break;default:c.t(c.N+p);break}}while(!u)},I:function(c,u){var d=a.B(u,c);if(d==16)return-32768;var p=c.Z(d);return(p&1<<d-1)==0&&(p-=(1<<d)-1),p},B:function(c,u){for(var d=this.z,p=this.O,f=this.F,m=this.I,h=this.g,g=this.o*p,y=this.U,b=0;b<p;b++)c[b]=m(d,y[b])+(1<<this.Q-1);for(var x=p;x<g;x+=p)for(var b=0;b<p;b++)c[x+b]=m(d,y[b])+c[x+b-p];for(var v=u,S=1;S<f;S++){for(var b=0;b<p;b++)c[v+b]=m(d,y[b])+c[v+b-u];for(var x=p;x<g;x+=p)for(var b=0;b<p;b++){var F=v+x+b,w=c[F-p];h==6&&(w=c[F-u]+(w-c[F-p-u]>>>1)),c[F]=w+m(d,y[b])}v+=u}}},s.m=65475,s.K=65476,s.q=65496,s.V=65498;function l(c){var u=new s(c),d=u.Q>8?Uint16Array:Uint8Array,p=new d(u.o*u.F*u.O),f=u.o*u.O;return u.B(p,f),p}return l})()})(e,t)})()});async function H$n(e,t){let n=await bTt(e),r={w:n.props.w,h:n.props.h},o=Dce(r,t);return{asset:n,shape:{id:ff(),type:"image",x:0,y:0,rotation:0,props:{assetId:n.id,w:o.w,h:o.h}}}}async function bTt(e){let t=dNe(e)?await Mni(e):e,n=await Ini(t),r=await Pni(n),o=r.width||240,i=r.height||Math.max(80,Math.round(o*.66));return{id:ute(),type:"image",props:{w:o,h:i,name:e.name,isAnimated:!1,mimeType:t.type||null,src:n,fileSize:t.size}}}function Ini(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function Pni(e){return e.startsWith("data:image/svg+xml")?Promise.resolve(Bon(e)??{}):new Promise(t=>{let n=new Image;n.onload=()=>t({width:n.naturalWidth,height:n.naturalHeight}),n.onerror=()=>t({}),n.src=e})}async function Mni(e){let{decode:t,decodeImage:n,toRGBA8:r}=await Promise.resolve().then(()=>yC(nze())),o=Bni(await e.arrayBuffer()),a=t(o)[0],s=Number(Array.isArray(a?.t256)?a.t256[0]:0),l=Number(Array.isArray(a?.t257)?a.t257[0]:0);if(!Number.isSafeInteger(s)||!Number.isSafeInteger(l)||s<=0||l<=0||s*l>4e7)throw new Error("Invalid or oversized TIFF image");n(o,a);let c=r(a);if(!a.data||c.length!==s*l*4)throw new Error("Invalid TIFF pixels");let u=document.createElement("canvas");u.width=s,u.height=l;let d=u.getContext("2d");if(!d)throw new Error("Image conversion unavailable");let p=d.createImageData(s,l);p.data.set(c),d.putImageData(p,0,0);let f=await new Promise((m,h)=>{u.toBlob(g=>g?m(g):h(new Error("TIFF conversion failed")),"image/png")});return new File([f],e.name,{type:"image/png"})}function Bni(e){let t=new DataView(e);if(e.byteLength<8||!(t.getUint32(0)===1229531648||t.getUint32(0)===1296891946))throw new Error("Invalid TIFF header");let n=t.getUint16(0)===18761,r=t.getUint32(4,n);if(r<8||r+2>e.byteLength)throw new Error("Invalid TIFF directory");let o=t.getUint16(r,n),i=r+2+o*12;if(i+4>e.byteLength)throw new Error("Invalid TIFF directory");let a=e.slice(0),s=new DataView(a);s.setUint32(i,0,n);let l=[0,1,1,2,4,8,1,1,2,4,8,4,8];for(let c=r+2;c<i;c+=12){let u=s.getUint16(c,n);if([330,34665,50740,37500].includes(u)){s.setUint16(c,0,n),s.setUint16(c+2,1,n),s.setUint32(c+4,0,n);continue}let d=s.getUint16(c+2,n),p=s.getUint32(c+4,n),f=p*(l[d]??0),m=f<=4?c+8:s.getUint32(c+8,n);if(!l[d]||p>1e6||m+f>a.byteLength)throw new Error("Invalid TIFF directory value")}return a}var xTt=X(()=>{"use strict";tj();Pn();tE();pY()});import{useCallback as qj,useLayoutEffect as Lni,useRef as vTt}from"react";function G$n({shapesRef:e,editPolicyLockedShapeIdsRef:t,notifyEditPolicyBlocked:n,setSelectedShapeIds:r,transitionMode:o,documentId:i,assetsRef:a,setShapes:s,setAssets:l,queueOverlaySave:c,replaceShape:u,imageInsertAreaRef:d,updateShape:p}){let f=vTt(null),m=vTt(null),h=vTt(0);Lni(()=>()=>{h.current++,m.current=null},[i]);let g=qj(w=>{let C=e.current.find(A=>A.id===w&&A.type==="image");return!C||Ac(e.current,C)?null:Js(e.current,C,t.current)?(n(),null):C},[t,n,e]),y=qj(w=>{let C=g(w);C&&(r([C.id]),o({type:"editImageCrop",shapeId:C.id}))},[g,r,o]),b=qj(w=>{let C=g(w);C&&(m.current=C.id,f.current&&(f.current.value="",f.current.click()))},[g,m]),x=qj(async w=>{let C=h.current,A=m.current,T=ate(w.currentTarget.files)[0];if(w.currentTarget.value="",m.current=null,!(!A||!T))try{let D=await bTt(T);if(C!==h.current)return;let k=g(A);if(!k)return;let P=JKn(e.current,a.current,k.id,D);e.current=Qr(P.shapes),a.current=P.assets,s(e.current),l(P.assets),r([k.id]),o({type:"select"}),c()}catch{return}},[a,g,c,l,r,s,e,o]),v=qj(w=>{let C=g(w);if(!C)return;let A=_At(C);A!==C&&(u(A),o({type:"select"}),c())},[g,c,u,o]),S=qj(w=>{let C=g(w);if(!C)return;let A=ZKn(C,a.current[C.props.assetId],d.current);A!==C&&(u(A),o({type:"select"}),c())},[a,g,d,c,u,o]),F=qj((w,C)=>{let A=g(w);A&&p({id:A.id,type:"image",opacity:Yo(C,0,1)})},[g,p]);return{imageReplacementInputRef:f,startImageCrop:y,requestImageReplacement:b,resetImageCrop:v,restoreImageNaturalSize:S,handleImageReplacementChange:x,setImageOpacity:F}}var j$n=X(()=>{"use strict";"use client";tj();Tc();QKn();xTt();jh()});function STt(){let e=null,t=0;return{cancel(){t++,e=null},async handle(n,r){if(e===n.id)return;e=n.id;let o=t;if(n.files.length===0){r.onHandled(n.id);return}try{let i=await Promise.all(n.files.map(l=>r.decodeFile(l,{w:r.areaSize.w,h:r.areaSize.h})));if(o!==t||i.length===0)return;let a=Qr(hnn(i,{areaWidth:r.areaSize.w,gap:r.gap,point:n.point,...r.getPlacement()})),s=Object.fromEntries(i.map(({asset:l})=>[l.id,l]));r.insert(a,s)}catch{return}finally{o===t&&r.onHandled(n.id)}}}}var V$n=X(()=>{"use strict";Dt();Pn()});import{useCallback as Rni,useEffect as _ni,useLayoutEffect as Oni,useRef as Nni}from"react";function X$n({documentId:e,imageInsertAreaWidth:t,imageInsertAreaHeight:n,canvasWidthRef:r,canvasHeightRef:o,focusedGroupIdRef:i,shapesRef:a,setAssets:s,assetsRef:l,setShapes:c,setSelectedShapeIds:u,transitionMode:d,queueOverlaySave:p,onImageHandled:f,imageRequest:m}){let h=Nni(null);Oni(()=>{let y=STt();return h.current=y,()=>{y.cancel(),h.current===y&&(h.current=null)}},[e]);let g=Rni(y=>(h.current??=STt(),h.current.handle(y,{areaSize:{w:t,h:n},gap:zni,decodeFile:H$n,getPlacement:()=>({canvasWidth:r.current,canvasHeight:o.current,parentId:i.current&&vP(a.current,i.current)?i.current:void 0}),insert:(b,x)=>{s(v=>{let S={...v,...x};return l.current=S,S}),c(v=>{let S=Qr([...v,...b]);return a.current=S,S}),u(b.map(v=>v.id)),d({type:"select"}),p()},onHandled:f})),[l,o,r,i,h,n,t,f,p,s,u,c,a,d]);_ni(()=>{m&&g(m)},[g,m])}var zni,W$n=X(()=>{"use strict";"use client";Tc();xTt();V$n();zni=16});import{useCallback as wTt}from"react";function q$n({lastCalloutCornerRadiusRef:e,focusedGroupIdRef:t,shapesRef:n,canvasWidthRef:r,canvasHeightRef:o,suppressNextSaveRef:i,insertedTableFocusRef:a,setShapes:s,selectKnownShape:l,commitOverlayChangeNow:c,queueOverlaySave:u,setSelectedShapeIds:d,transitionMode:p,clearSnapGuides:f}){let m=wTt((y,b,x,v,S=!1)=>{let F=y.command==="callout"&&y.calloutRadius===void 0?{...y,calloutRadius:e.current}:y,w=gj(F,b,x,ff(),v,S,J9(F.command,Gte()));if(!w)return null;w.type==="callout"&&(e.current=w.props.radius,qNe(w.props.radius));let C=t.current&&vP(n.current,t.current)?t.current:null,A=L=>C?{...L,parentId:C}:L,T=A(w),D=T.type==="graph2dShape"?dte(T,ff,{width:r.current,height:o.current}):[],k=T.type==="graph2dShape"?p_(T,ff):[],P=T.type==="graph2dShape"?f_(T,ff):[],I=[...D,...k,...P].map(L=>A(L.shape)),B=T;B.type==="graph2dShape"&&D.length>0&&(B=T_(B,Object.fromEntries(D.map(L=>[L.curveId,L.shape.id])))),B.type==="graph2dShape"&&k.length>0&&(B=tbe(B,Object.fromEntries(k.map(L=>[L.pointId,L.shape.id])))),B.type==="graph2dShape"&&P.length>0&&(B=nbe(B,Object.fromEntries(P.map(L=>[L.annotationId,L.shape.id])))),B.type==="graph2dShape"&&(B=xB(B));let M=aB(n.current,B);for(let L of I)M=aB(M,L);return M=Qr(M),n.current=M,Bd(B)&&(i.current=!0),B.type===nE&&(a.current=B.id),s(M),l(B,{editing:Bd(B)}),Bd(B)?c():u(),B.id},[o,r,c,t,a,e,u,l,s,n,i]),h=wTt(y=>{let b=n.current.find(C=>C.id===y);if(b?.type!=="tableShape")return;let x=SXn({x:b.x,y:b.y,w:b.props.w,h:b.props.h}),v=Yo(x.x,0,Math.max(0,r.current-x.w)),S=Yo(x.y,0,Math.max(0,o.current-x.h)),F=vXn(b.props.table,y,x.w,x.h),w=m({kind:"insert",command:"chart",chart:{sourceTableShapeId:y,spec:F.spec,dataSnapshot:F.dataSnapshot}},{x:v,y:S},{x:v+x.w,y:S+x.h});w&&d([w])},[o,r,m,d,n]),g=wTt((y,b,x=!1)=>{let v=aen(b,2);if(v.length<(y.command==="threePointArc"?3:2))return!1;let S=v[0],F=v[v.length-1];return m(y,S,F,v,x)?(p({type:"setTool",tool:{kind:"select"}}),f(),!0):!1},[f,m,p]);return{createShapeFromInsertDrag:m,finishCurveDrawing:g,createChartFromTable:h}}var K$n=X(()=>{"use strict";"use client";Dt();Pn();Tc();tE();jh();KNe();M9e();kCt();xP();Yx();D_();m_()});function Y$n(e){let t=e.metaKey||e.ctrlKey,n=e.key==="]"||e.key==="}"||e.code==="BracketRight",r=e.key==="["||e.key==="{"||e.code==="BracketLeft";if(t&&!e.altKey){if(e.key==="ArrowUp")return e.shiftKey?"front":"forward";if(e.key==="ArrowDown")return e.shiftKey?"back":"backward";if(n)return e.shiftKey?"front":"forward";if(r)return e.shiftKey?"back":"backward"}if(!t&&!e.shiftKey){if(n)return e.altKey?"forward":"front";if(r)return e.altKey?"backward":"back"}return null}function $$n(e){return e==="forward"||e==="backward"}var Z$n=X(()=>{"use strict"});import{useEffect as FTt}from"react";function J$n({textCompositionRef:e,modeRef:t,cancelTablePlacement:n,snapDisabledRef:r,clearSnapGuides:o,updateModifierDrivenInteraction:i,activeTextEditorRef:a,transitionMode:s,queueDirtyImageCropSave:l,finishCurveDrawing:c,restoreTransientInteraction:u,solidEdgeRef:d,setSolidEdge:p,focusedGroupIdRef:f,setFocusedGroupId:m,setSelectedShapeIds:h,shapesRef:g,ungroupSelectedShapes:y,groupSelectedShapes:b,selectedIdsRef:x,duplicateSelectedShapes:v,editPolicyLockedShapeIdsRef:S,notifyEditPolicyBlocked:F,arrangeSelectedShapes:w,refreshAnchorMeasurements:C,setShapes:A,deleteSelectedShapes:T,mode:D}){let k=$q();FTt(()=>{let P=I=>{if(!k()||document.querySelector("[data-modal-backdrop]")||(I.target instanceof Element?I.target:document.activeElement)?.closest(TKn)||e.current||L9e(I))return;let M=t.current;if(I.key==="Escape"&&M.tool.kind==="insert"&&M.tool.command==="table"&&!g1(I.target)){I.preventDefault(),n();return}if(ECt(I.key)&&(r.current=!0,sw(M))){I.preventDefault(),o(),i(M,I);return}if(a.current?.isFocused)return;if((I.key==="Enter"||I.key==="Escape")&&RAt(M)!==null&&!g1(I.target)){I.preventDefault(),s({type:"select"}),l();return}if(M.id==="overlay.curveDrawing"&&!g1(I.target)){if(I.key==="Escape"){I.preventDefault(),s({type:"setTool",tool:{kind:"select"}});return}if(I.key==="Enter"){I.preventDefault();let O=NDe(M.points,M.current);O&&c(M.tool,O);return}if(I.key==="Backspace"||I.key==="Delete"){I.preventDefault(),s({type:"removeLastCurvePoint"});return}}if(I.key==="Escape"&&M.id!=="overlay.select"){I.preventDefault();let O=a.current;O&&!O.isDestroyed&&O.commands.blur(),u(M),s({type:"select"});return}if(I.key==="Escape"&&d.current&&M.id==="overlay.select"){I.preventDefault(),p(null);return}if(I.key==="Escape"&&f.current&&M.id==="overlay.select"){I.preventDefault(),m(null),h([]);return}if(ICt(I.key)&&i(M,I)){I.preventDefault();return}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="a"&&!g1(I.target)){let O=LCt(g.current,f.current);if(O.length===0)return;I.preventDefault(),a.current?.commands.blur(),h(O),s({type:"select"});return}if((I.metaKey||I.ctrlKey)&&I.shiftKey&&I.key.toLowerCase()==="g"&&!g1(I.target)){I.preventDefault(),y();return}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="g"&&!g1(I.target)){I.preventDefault(),b();return}if(I.key==="Enter"&&M.id==="overlay.select"&&!g1(I.target)){let O=x.current.length===1?vP(g.current,x.current[0]):null;if(O){I.preventDefault(),m(O.id),h(LCt(g.current,O.id));return}}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="d"&&!g1(I.target)){if(x.current.length===0)return;I.preventDefault(),v();return}let L=Y$n(I),_=M.id==="overlay.textEditing"||M.id==="overlay.tableEditing";if(L&&!g1(I.target)&&!_){let O=x.current;if(O.length===0)return;if(Wh(g.current,O,S.current)){F();return}if(!($x(g.current,O,S.current).length>0)||I.repeat&&!$$n(L))return;I.preventDefault(),I.stopPropagation(),w(L);return}if(!I.metaKey&&!I.ctrlKey&&wXn(I.key)&&!g1(I.target)){let O=$x(g.current,x.current,S.current);if(O.length===0){Wh(g.current,x.current,S.current)&&F();return}I.preventDefault();let N=I.shiftKey?10:1,z=FXn(I.key,N),U=new Set(O.map(ne=>ne.id)),{ordered:H}=C(),V=Y9(O,z.x,z.y);A(ne=>{let Z=Qr(Jx(Wv(ne,V),U,H));return g.current=Z,Z});return}I.key!=="Backspace"&&I.key!=="Delete"||g1(I.target)||x.current.length===0||(I.preventDefault(),T())};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[k,w,n,T,v,c,b,o,F,l,C,u,h,p,s,y,i,e,t,a,d,f,x,r,m,g,S,A]),FTt(()=>{let P=RAt(D);if(!P)return;let I=B=>{let M=B.target instanceof Element?B.target:null,L=M?.closest("[data-overlay-shape-id]");M?.closest(".overlay-crop-handle")||L?.getAttribute("data-overlay-shape-id")===P||(s({type:"select"}),l())};return window.addEventListener("pointerdown",I,!0),()=>window.removeEventListener("pointerdown",I,!0)},[D,l,s]),FTt(()=>{let P=I=>{if(k()){if(ECt(I.key)){r.current=!1,!e.current&&!L9e(I)&&!a.current?.isFocused&&i(t.current,I)&&I.preventDefault();return}!ICt(I.key)||e.current||L9e(I)||a.current?.isFocused||i(t.current,I)&&I.preventDefault()}};return window.addEventListener("keyup",P),()=>window.removeEventListener("keyup",P)},[k,a,t,r,e,i])}var Q$n=X(()=>{"use strict";"use client";Hse();Pn();Z$n();A_();Tc();qte();yte();Ly();Vte();xP()});function tZn(e){return e.pageHeightPx>0&&e.canvasWidth>0&&e.canvasHeight>0}function Uni(e){if(!tZn(e))return 1;let t=e.pageHeightPx+Math.max(0,e.pageGapPx);return Math.max(1,Math.round((e.canvasHeight+Math.max(0,e.pageGapPx))/t))}function Hni(e,t,n){return t.width<=0||t.height<=0?null:{x:(e.x-t.left)/t.width*n.canvasWidth,y:(e.y-t.top)/t.height*n.canvasHeight}}function nZn(e,t,n){let r=Uni(n),o=n.pageHeightPx+Math.max(0,n.pageGapPx),a=Gni(e.y,n.pageHeightPx,o,r)*o;return{x:eZn(e.x,t.w,0,n.canvasWidth),y:eZn(e.y,t.h,a,a+n.pageHeightPx)}}function Gni(e,t,n,r){let o=Math.min(r-1,Math.max(0,Math.floor(e/n))),i=o+1;if(i>=r)return o;let a=Math.max(0,e-(o*n+t));return Math.max(0,i*n-e)<a?i:o}function eZn(e,t,n,r){let o=t/2;return r-n<=t?(n+r)/2:Math.min(r-o,Math.max(n+o,e))}function rZn(e){if(e)return(t,n)=>{let r=n.width/Eb(e,1).width;if(!(r>0))return null;let o=EB(e,{x:(t.x-n.left)/r,y:(t.y-n.top)/r});return{x:o.x,y:o.y}}}function oZn(e,t,n,r=(o,i)=>Hni(o,i,n)){if(!e||!t||!tZn(n))return null;let o=r(e,t);return o?{point:o,layout:n}:null}function Xni(e){let t=e?.closest(jni);return!!t&&!t.closest(Vni)}function Wni(){let e=r=>{r.isTrusted&&(oze=r.pointerType==="touch"?null:{x:r.clientX,y:r.clientY})},t=()=>{oze=null},n=document.documentElement;return window.addEventListener("pointermove",e,{capture:!0,passive:!0}),window.addEventListener("pointerdown",e,{capture:!0,passive:!0}),n.addEventListener("pointerleave",t),()=>{window.removeEventListener("pointermove",e,{capture:!0}),window.removeEventListener("pointerdown",e,{capture:!0}),n.removeEventListener("pointerleave",t),oze=null}}function iZn(){if(typeof window>"u"||typeof document>"u")return()=>{};rze+=1,rze===1&&(CTt=Wni());let e=!1;return()=>{e||(e=!0,rze-=1,rze===0&&(CTt?.(),CTt=null))}}function ize(){let e=oze;return!e||typeof document>"u"||typeof document.elementFromPoint!="function"?null:Xni(document.elementFromPoint(e.x,e.y))?{...e}:null}var jni,Vni,oze,rze,CTt,xbe=X(()=>{"use strict";Dn();jni=".page-mode",Vni=".workspace-passive-editor, [data-whiteboard='true']";oze=null,rze=0,CTt=null});import{useEffect as qni}from"react";function aZn({getBlockAnchorScope:e,activeTextEditorRef:t,shapesRef:n,selectedIdsRef:r,reanchorShapesToCopiedBlocks:o,assetsRef:i,documentIdRef:a,getRemovableSelectedShapeIds:s,pendingOverlaySaveHistoryGroupRef:l,deleteSelectedShapes:c,applyPastedOverlayShapes:u}){qni(()=>{let d=y=>{let b=y.target instanceof Element?y.target:null,x=e();if(!b||!b.closest(".text-flow-editor")||b.closest("math-field")||!(x instanceof Node)||!x.contains(b))return null;let v=y.clipboardData?OMe(y.clipboardData):null;if(!v||!y.clipboardData)return null;let S=y.clipboardData.getData("text/html");return{text:v,html:Kgt(S)}},p=y=>t.current?.isFocused||!y.clipboardData?!1:y_(n.current,r.current).length>0,f=(y,b)=>{if(!p(y)||!y.clipboardData)return!1;let x=y.clipboardData,v=y_(n.current,r.current);return!b&&g1(y.target)?!1:(y.preventDefault(),y.stopPropagation(),y.stopImmediatePropagation(),b?nA(x,gkn(b.text,o(v,b.text.slice),i.current,a.current),{html:b.html}):nA(x,Nw(v,i.current,a.current)),!0)},m=y=>{f(y,d(y))},h=y=>{if(!p(y))return;let b=xkn(y),x=b?{text:b,html:Kgt(y.clipboardData?.getData("text/html")??"")}:null;if(f(y,x)){let v=s().length>0;l.current=v?b?.historyGroup??null:null,c()}},g=y=>{if(y.defaultPrevented||g1(y.target)||t.current?.isFocused||!y.clipboardData)return;let b=Kf(y.clipboardData);if(b?.kind!=="overlayShapes"&&b?.kind!=="textAndShapes")return;let x=b.kind==="textAndShapes"?Fk(b):b,v=ize();u(x,v?{pointerClient:v}:void 0)&&(y.preventDefault(),y.stopPropagation(),y.stopImmediatePropagation())};return window.addEventListener("copy",m),window.addEventListener("cut",h),window.addEventListener("paste",g),()=>{window.removeEventListener("copy",m),window.removeEventListener("cut",h),window.removeEventListener("paste",g)}},[t,u,i,c,a,e,s,l,o,r,n])}var sZn=X(()=>{"use strict";"use client";Sp();Tc();xbe();Vte()});import{useCallback as Kj}from"react";function lZn({setRegionSelection:e,shapesRef:t,selectedIdsRef:n,setSelectedIds:r,onSelectedCountChange:o,unselectableShapeIdsRef:i,focusedGroupIdRef:a,transitionMode:s,modeRef:l,activeTextEditorRef:c,explicitlySavedShapeStatesRef:u,setShapes:d,commitOverlayChangeNow:p,queueOverlaySave:f,anchorMeasurementsRef:m}){let h=Kj(F=>{e(null);let w=Rj([...new Set(F)],i?.current,t.current),C=lrt(t.current,w);Knn(n.current,C)||(n.current=C,r(C),o?.(C.length))},[o,n,e,r,t,i]),g=Kj((F,w={})=>{let C=cF(t.current,F.id,a.current);h(C),w.editing&&Bd(F)&&C.length===1&&C[0]===F.id?s({type:"editText",shapeId:F.id}):(l.current.id!=="overlay.originPicking"&&l.current.id!=="overlay.graphFillPicking"||F.type!=="graph2dShape")&&s({type:"select"})},[a,l,h,t,s]),y=Kj(F=>{let w=t.current.find(C=>C.id===F);if(w){g(w);return}h([F]),s({type:"select"})},[g,h,t,s]),b=Kj(F=>{c.current?.commands.blur(),s({type:"select"}),h(Ynn(n.current,F))},[c,n,h,s]),x=Kj((F,w)=>{let C=t.current.find(D=>D.id===F.id&&D.type===F.type),A=Qr(XAe(t.current,F)),T=A.find(D=>D.id===F.id&&D.type===F.type);if(C&&T&&(C.type==="text"||C.type==="callout")&&T.type===C.type&&Oi(T)!==0&&F.x===void 0&&F.y===void 0){let D=yi(C),k=yi(T);(D.w!==k.w||D.h!==k.h)&&(A=Qr(aB(A,lnn(C,T))))}if(!_ke(t.current,A)){if(w?.commit){t.current=A,u.current.add(A),d(A),p({history:w.history});return}t.current=A,w?.history&&u.current.add(A),d(A),w?.history&&f({history:w.history})}},[p,u,f,d,t]),v=Kj((F,w,C={},A={})=>{let T=D=>{let k=D.find(L=>L.id===F&&L.type===lF);if(!k)return D;let P=Ele(k,w),I={...k,...C,props:{...k.props,spec:w,boundsMode:"plot",w:P.w,h:P.h}},B=C.x!==void 0||C.y!==void 0?vWn(I,k,D,m.current.rects):I,M=D.map(L=>L.id===F?B:L);return Nj(M,B,{preserveExistingPositions:A.preserveGraphOwnedLabelPositions===!0})};if(A.commit){let D=T(t.current);if(D===t.current)return;t.current=D,u.current.add(D),d(D),p();return}d(D=>{let k=T(D);return t.current=k,k})},[m,p,u,d,t]),S=Kj(F=>{d(w=>{let C=Qr(aB(w,F));return t.current=C,C})},[d,t]);return{setSelectedShapeIds:h,replaceShape:S,updateShape:x,selectKnownShape:g,selectShape:y,updateGraphShapeSpec:v,toggleShapeSelection:b}}var cZn=X(()=>{"use strict";"use client";Dt();Pn();Tc();Ly();Yx();D_();A_()});function ATt(e,t){let n=t.history??"record",r=t.historyGroup??null;return e?{history:e.history==="record"||n==="record"?"record":"coalesce",historyGroup:TTt(e.historyGroup,r)}:{history:n,historyGroup:r}}function TTt(e,t){return e===t?e:e===null?t:t===null?e:null}var DTt=X(()=>{"use strict"});import{useCallback as one}from"react";function uZn({syncBlockAnchors:e,shapesRef:t,canvasRef:n,canvasHeightRef:r,canvasWidthRef:o,getBlockAnchorScope:i,getLastDrawnBlockRects:a,getPreservedShapeIds:s,suppressNextSaveRef:l,setShapes:c,assetsRef:u,extensionsRef:d,lastEmittedSnapshotRef:p,onChangeRef:f,imageCropDirtyRef:m,saveTimeoutRef:h,pendingOverlayHistoryRef:g,pendingOverlaySaveHistoryGroupRef:y}){let b=one((C={})=>{let A=e?Qr(qWn(t.current,n.current,r.current,o.current,i(),a(),s())):Qr(t.current),T=x_(A,V$t(A),s());T!==t.current&&(t.current=T,l.current=!0,c(T));let D={version:1,shapes:t.current,assets:u.current,...d.current?{extensions:d.current}:{}};p.current=D,f.current({overlaySnapshot:D,updatedAt:new Date().toISOString()},{history:C.history??"record",...C.historyGroup?{historyGroup:C.historyGroup}:{}}),m.current=!1},[u,r,n,o,d,i,a,s,m,p,f,c,t,l,e]),x=one(()=>{h.current&&(window.clearTimeout(h.current),h.current=void 0),g.current=null,y.current=null},[g,y,h]),v=one(()=>{if(h.current===void 0&&!m.current)return;let C=g.current;x(),b({history:C?.history??"record",...C?.historyGroup?{historyGroup:C.historyGroup}:{}})},[x,b,m,g,h]),S=one((C={})=>{let A=ATt(g.current,C);x(),b({history:A.history,...A.historyGroup?{historyGroup:A.historyGroup}:{}})},[x,b,g]),F=one((C={})=>{g.current=ATt(g.current,C),h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{h.current=void 0;let A=g.current;g.current=null,b({history:A?.history??"record",...A?.historyGroup?{historyGroup:A.historyGroup}:{}})},250)},[b,g,h]),w=one(()=>{m.current&&F()},[m,F]);return{queueOverlaySave:F,clearQueuedOverlaySave:x,commitOverlayChangeNow:S,flushOverlayChange:v,queueDirtyImageCropSave:w}}var dZn=X(()=>{"use strict";"use client";Dt();Tc();DTt();Ly();aAt()});function ine(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(aze,{detail:{style:e}}))}var IA,aze,pZn,PP=X(()=>{"use strict";IA="sigma-studio:flush-overlay-changes",aze="sigma-studio:overlay-style-preview";pZn="selection"});import{useEffect as kTt}from"react";function fZn({assets:e,shapes:t,assetsRef:n,shapesRef:r,mountedRef:o,pendingOverlaySaveHistoryGroupRef:i,explicitlySavedShapeStatesRef:a,suppressNextSaveRef:s,commitOverlayChangeNow:l,queueOverlaySave:c,flushOverlayChange:u,saveTimeoutRef:d,imageCropDirtyRef:p}){kTt(()=>{if(!o.current){o.current=!0;return}let f=i.current;if(i.current=null,!(t!==r.current||e!==n.current)&&!a.current.delete(t)){if(s.current){s.current=!1;return}if(f){l({historyGroup:f});return}c()}},[e,l,a,o,i,c,t,s,n,r]),kTt(()=>(window.addEventListener(IA,u),()=>window.removeEventListener(IA,u)),[u]),kTt(()=>()=>{(d.current!==void 0||p.current)&&u()},[u,p,d])}var mZn=X(()=>{"use strict";"use client";PP()});import{useCallback as ane,useEffect as hZn,useLayoutEffect as ETt}from"react";function yZn({session:e,editing:t,selection:n,geometry:r,drawing:o,transforms:i,clearSnapGuides:a,setAdjustmentDragReadoutPointerPosition:s,canvasRef:l,autoScrollPanBy:c,autoScrollViewportElement:u,originPickShapeId:d,updateOriginPickPreviewFromEvent:p,setHoverSolidEdge:f,mode:m,cancelTablePlacement:h,restoreTransientInteraction:g,setRegionSelection:y,handledCommandRequestIdRef:b,queueOverlaySave:x,documentId:v,onRequestTextMode:S,retainEmptySelection:F,externalRevision:w,onRequestTextSelection:C,queueDirtyImageCropSave:A}){let{modeRef:T,transitionMode:D,bleedSurfaceRef:k,lastInteractionPointRef:P,dragPointerRef:I,dragCanvasRectRef:B,lastPointerModifiersRef:M,advanceInteractionFromClientRef:L,dragAutoScrollerRef:_}=e,{shapesRef:R,setShapes:O,editPolicyLockedShapeIdsRef:N,editPolicyUnselectableShapeIdsRef:z}=t,{selectedIdsRef:U,focusedGroupIdRef:H,setSelectedShapeIds:V,selectShape:ne}=n,{pagePointFromClient:Z,clientPointFromPage:ee,getOverlaySnapThreshold:J,getShapeAtPoint:te,getOpenStrokeShapeAtPoint:K,refreshAnchorMeasurements:G}=r,{getSnappedDrawingPoint:ie,getSnappedInsertDragPoint:fe,createShapeFromInsertDrag:$}=o,{applyMoveInteractionAtPoint:j,applyResizeInteractionAtPoint:pe,applyPointInteractionAtPoint:re,applyImageCropInteractionAtPoint:le}=i,Q=ane((Pe,Ne,we,Ie)=>{let Ce=T.current;if(!sw(Ce))return;let xe=Z(Pe,Ne,Ie);if(P.current=xe,Ce.id==="overlay.move"){j(Ce,xe);return}if(Ce.id==="overlay.resize"){pe(Ce,xe,we);return}if(Ce.id==="overlay.rotate"){a();let Y=Snn(Ce,xe,we.shiftKey);O(oe=>{let de=Qr(Wv(oe,$9(Ce.shapes,Ce.center,Y)));return R.current=de,de});return}if(Ce.id==="overlay.anchor"){a(),D({type:"updateAnchorDrag",current:xe});return}if(Ce.id==="overlay.marquee"){a(),D({type:"updateMarquee",current:xe});return}if(Ce.id==="overlay.point"){re(Ce,xe,we),xte(Ce.handle)&&s(xe);return}if(Ce.id==="overlay.imageCropResize"||Ce.id==="overlay.imageCropPan"){le(Ce,xe);return}if(Ce.id==="overlay.curveDrawing"){let Y=Ce.points[Ce.points.length-1];D({type:"updateCurveDrawing",current:ie(xe,{previousPoint:Y,shiftKey:we.shiftKey,enabled:hj(Ce.tool)})});return}if(Ce.id==="overlay.insertDrag"){if(Ce.tool.command==="table"&&_ye())return;let Y=fe(Ce.tool,Ce.start,xe,we);if(Ce.tool.command==="table"&&Ce.tool.tableCellSize){let oe=hD(Ce.start,Ce.current,Ce.tool.tableCellSize),de=hD(Ce.start,Y,Ce.tool.tableCellSize);if(oe.x===de.x&&oe.y===de.y&&oe.w===de.w&&oe.h===de.h)return}D({type:"updateInsertDrag",current:Y,point:Ce.tool.command==="freehand"?Y:void 0}),h_(Ce.tool)&&s(xe);return}},[T,Z,P,j,pe,a,O,R,D,re,s,le,ie,fe]);ETt(()=>{L.current=Q},[Q,L]);let se=ane(()=>{_.current?.stop(),_.current=null},[_]),De=ane((Pe,Ne)=>{if(!O9e(T.current)){se();return}if(!_.current){let we=l.current??k.current,Ie=we&&!c?PG(we):null,Ce=u??Ie;if(!Ce)return;let xe=Ce.ownerDocument.defaultView;if(!xe)return;let Y=c??(Ie?(oe,de)=>BG(Ie,oe,de):null);if(!Y)return;_.current=LG({ownerWindow:xe,getViewportBounds:()=>MG(Ce,xe),panBy:Y,onPan:(oe,de,Le)=>{if(!O9e(T.current)){se();return}L.current(oe,de,M.current,Le.rectSettled?null:B.current)},maxSpeedPxPerSec:Yni})}_.current.update(Pe,Ne)},[L,c,u,k,l,_,B,M,T,se]),Ae=ane(Pe=>{d&&p(Pe),M.current={ctrlKey:Pe.ctrlKey,shiftKey:Pe.shiftKey};let Ne=U.current.length===1?R.current.find(Ie=>Ie.id===U.current[0]):void 0;if(Ne&&Nc(Ne)&&!Ne.locked&&Pe.buttons===0&&T.current.id==="overlay.select"){let Ie=Cke(Ne,Z(Pe.clientX,Pe.clientY),J()*.75);f(Ce=>Ce?.shapeId===Ne.id&&Ce.index===Ie?Ce:Ie===null?null:{shapeId:Ne.id,index:Ie})}else f(Ie=>Ie===null?Ie:null);Q(Pe.clientX,Pe.clientY,M.current);let we=I.current;Pe.buttons!==0&&we?.pointerId===Pe.pointerId?(we.autoScrollArmed||(we.autoScrollArmed=Math.hypot(Pe.clientX-we.startClientX,Pe.clientY-we.startClientY)>Kni),we.autoScrollArmed?De(Pe.clientX,Pe.clientY):se()):se()},[Q,I,J,M,T,d,Z,U,f,R,se,De,p]);hZn(()=>{O9e(m)||se()},[m,se]),hZn(()=>se,[se]);let ye=ane(()=>{let Pe=T.current.tool;if(Pe.kind==="insert"&&Pe.command==="table"){h();return}let Ne=I.current?.pointerId;Ne!==void 0&&k.current?.hasPointerCapture(Ne)&&k.current.releasePointerCapture(Ne),I.current=null,se();let we=T.current;sw(we)&&(g(we),y(null),D({type:"select"}))},[k,h,I,T,g,y,se,D]);ETt(()=>{let Pe=m.tool;if(Pe.kind!=="insert"||Pe.command!=="table"||!Pe.tableCellSize)return;let Ne=we=>T.current.id==="overlay.insertDrag"?T.current.start:Z(we.x,we.y);return QWn(b.current,{bounds:(we,Ie)=>{let Ce=hD(Ne(we),Z(Ie.x,Ie.y),Pe.tableCellSize),xe=ee(Ce),Y=ee({x:Ce.x+Ce.w,y:Ce.y+Ce.h}),oe=Y.x-xe.x,de=Y.y-xe.y;return{...Ce,...xe,w:oe,h:de,cellW:oe/Ce.columns,cellH:de/Ce.rows}},freeze:()=>{let we=I.current?.pointerId;we!==void 0&&k.current?.hasPointerCapture(we)&&k.current.releasePointerCapture(we),I.current=null,se()},cancel:h,commit:(we,Ie)=>{let Ce=Ne(we),xe=Z(Ie.x,Ie.y);h();let Y=$(Pe,Ce,xe);Y?D({type:"editTable",shapeId:Y}):wte()}})},[m.tool,h,ee,$,Z,se,D,b,T,I,k]);let $e=ane(Pe=>{I.current=null,se();let Ne=T.current;if(!sw(Ne))return;let we=Ne.id==="overlay.resize"||Ne.id==="overlay.point"||Ne.id==="overlay.imageCropResize"||Ne.id==="overlay.imageCropPan",Ie=Ne.id==="overlay.move"?wnn({...Ne,start:ee(Ne.start)},{x:Pe.clientX,y:Pe.clientY}):null;if(Ie?.kind==="edit"){Ie.editor==="table"?D({type:"editTable",shapeId:Ie.shapeId}):D({type:"editText",shapeId:Ie.shapeId}),k.current?.hasPointerCapture(Pe.pointerId)&&k.current.releasePointerCapture(Pe.pointerId),a();return}if(Ne.id==="overlay.anchor"){let Ce=Z(Pe.clientX,Pe.clientY),xe=N9e({...Ne,current:Ce}),Y=Math.abs(Ce.x-Ne.start.x)>gZn||Math.abs(Ce.y-Ne.start.y)>gZn,oe=G(),de=R.current.find(Be=>Be.id===Ne.shape.id),Le=Y&&de&&!de.locked?HKn(de,xe,oe):null,be=!!(Le&&!Zx(de?.anchor,Le));Le&&be&&O(Be=>{let ce=Be.map(Qe=>Qe.id!==Ne.shape.id||Zx(Qe.anchor,Le)?Qe:{...Qe,anchor:Le}),Re=Sj(ce,oe.ordered);return R.current=Re,Re}),D({type:"select"}),a(),k.current?.hasPointerCapture(Pe.pointerId)&&k.current.releasePointerCapture(Pe.pointerId),be&&x();return}if(Ne.id==="overlay.move"){let Ce=Ne.shapes.length===1?Ne.shapes[0]:null,xe=Z(Pe.clientX,Pe.clientY);if(Ie?.kind==="noop"&&Ce?.type==="image"&&Ce.props.tikz&&!Ce.locked&&!N.current.has(Ce.id)&&!Pe.shiftKey&&!Pe.metaKey&&!Pe.ctrlKey&&Math.hypot(xe.x-Ne.start.x,xe.y-Ne.start.y)<3&&window.dispatchEvent(new CustomEvent(Lj,{detail:{documentId:v,shapeId:Ce.id}})),Ie?.kind==="commit"){let{offset:Y}=Ie;we=!0;let oe=new Set(Ne.shapes.map(be=>be.id)),de=Y9(Ne.shapes,Y.x,Y.y),{ordered:Le}=G();O(be=>{let Be=Qr(Jx(Wv(be,de),oe,Le));return R.current=Be,Be})}}if(Ne.id!=="overlay.curveDrawing"){if(Ne.id==="overlay.marquee"){let Ce=Wg([Ne.start,Ne.current]);if(Math.hypot(Ce.w,Ce.h)<3)if(Ne.selectOnClick){let xe=Z(Pe.clientX,Pe.clientY),Y=te(xe,8)??K(xe);Y?ne(Y.id):V([])}else Ne.additive||(V([]),S({x:Pe.clientX,y:Pe.clientY}));else{let xe=Rj(B9e({shapes:R.current,marquee:Ce,focusedGroupId:H.current,currentIds:U.current,additive:Ne.additive}),z?.current);V(xe),F&&xe.length===0&&!Ne.additive&&Ce.w>0&&Ce.h>0&&y({documentId:v,revision:w,bounds:Ce}),xe.length===0&&!Ne.additive&&!Ne.selectOnClick&&C?.(ee(Ne.start),{x:Pe.clientX,y:Pe.clientY})}}if(Ne.id==="overlay.insertDrag"){let Ce=Z(Pe.clientX,Pe.clientY),xe=fe(Ne.tool,Ne.start,Ce,Pe),Y=Math.hypot(xe.x-Ne.start.x,xe.y-Ne.start.y);if(k.current?.hasPointerCapture(Pe.pointerId)&&k.current.releasePointerCapture(Pe.pointerId),Y<4&&Ne.tool.command!=="table"){D({type:"setTool",tool:{kind:"select"}}),S({x:Pe.clientX,y:Pe.clientY}),a();return}let oe=$(Ne.tool,Ne.start,xe,Ne.tool.command==="freehand"?[...Ne.points??[Ne.start],xe]:Ne.points);Ne.tool.command==="graph"&&oe?D({type:"pickOrigin",shapeId:oe,initial:!0}):Ne.tool.command==="graph3d"&&oe?(D({type:"setTool",tool:{kind:"select"}}),D({type:"editGraph3D",shapeId:oe}),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent(lE,{detail:{shapeId:oe}}))},0)):Ne.tool.command==="table"&&oe?(D({type:"setTool",tool:{kind:"select"}}),D({type:"editTable",shapeId:oe})):Ne.tool.command==="text"&&oe?(D({type:"setTool",tool:{kind:"select"}}),D({type:"editText",shapeId:oe})):D({type:"setTool",tool:{kind:"select"}}),a();return}a(),Ne.id==="overlay.imageCropResize"||Ne.id==="overlay.imageCropPan"?D({type:"editImageCrop",shapeId:Ne.shape.id}):D({type:"select"}),k.current?.hasPointerCapture(Pe.pointerId)&&k.current.releasePointerCapture(Pe.pointerId),Ne.id==="overlay.imageCropResize"||Ne.id==="overlay.imageCropPan"?A():we&&x()}},[I,se,T,Z,a,k,D,G,R,O,x,N,z,v,te,K,ne,V,S,H,U,F,y,w,C,ee,fe,$,A]);return ETt(()=>{let Pe=k.current;return()=>{let Ne=I.current?.pointerId;Ne!==void 0&&Pe?.hasPointerCapture(Ne)&&Pe.releasePointerCapture(Ne),I.current=null,se();let we=T.current;sw(we)&&g(we)}},[v,k,I,T,g,se]),{handlePointerMove:Ae,handlePointerCancel:ye,handlePointerUp:$e}}var gZn,Kni,Yni,bZn=X(()=>{"use strict";"use client";Bj();Pn();P9e();Oge();Tc();A_();qte();yte();IAt();jh();Ly();_Ne();xP();Oye();gZn=2,Kni=8,Yni=1100});import{useCallback as xZn,useLayoutEffect as $ni,useMemo as Zni,useRef as R_}from"react";function vZn({documentId:e,modeRef:t,transitionMode:n,bleedSurfaceRef:r}){let o=R_(null),i=R_(null),a=R_(null),s=R_({ctrlKey:!1,shiftKey:!1}),l=R_(()=>{}),c=R_(Unn),u=R_(0),d=R_(null),p=xZn(m=>{i.current={pointerId:m.pointerId,startClientX:m.clientX,startClientY:m.clientY,autoScrollArmed:!1},r.current?.setPointerCapture(m.pointerId)},[r]),f=xZn(()=>{let m=i.current?.pointerId;m!==void 0&&r.current?.hasPointerCapture(m)&&r.current.releasePointerCapture(m),i.current=null,a.current=null,d.current?.stop(),d.current=null},[r]);return $ni(()=>f,[e,f]),Zni(()=>({modeRef:t,transitionMode:n,bleedSurfaceRef:r,lastInteractionPointRef:o,dragPointerRef:i,dragCanvasRectRef:a,lastPointerModifiersRef:s,advanceInteractionFromClientRef:l,resizePaddingRef:c,suppressNextShapeDoubleClickRef:u,dragAutoScrollerRef:d,capturePointer:p,releasePointer:f}),[t,n,r,p,f])}var SZn=X(()=>{"use strict";"use client";Pn()});import{useCallback as Q2}from"react";function wZn({session:e,editing:t,selection:n,geometry:r,drawing:o,focusOverlayCanvas:i,setAdjustmentDragReadoutPointerPosition:a,graphFillPickShapeId:s,selectedRegion:l}){let{modeRef:c,transitionMode:u,lastInteractionPointRef:d,resizePaddingRef:p,suppressNextShapeDoubleClickRef:f}=e,{shapesRef:m,updateShape:h,editPolicyLockedShapeIdsRef:g,notifyEditPolicyBlocked:y}=t,{selectedIdsRef:b,focusedGroupIdRef:x,setFocusedGroupId:v,setSelectedShapeIds:S,selectShape:F,toggleShapeSelection:w,setSolidEdge:C,duplicateSelectedShapes:A}=n,{pagePointFromClient:T,getOverlaySnapThreshold:D,getShapeAtPoint:k,getOpenStrokeShapeAtPoint:P}=r,{getSnappedDrawingPoint:I,finishCurveDrawing:B}=o,M=e.capturePointer,L=Q2((te,K)=>{te.preventDefault(),te.stopPropagation(),i(),S([]);let G=T(te.clientX,te.clientY);d.current=G,h_(K)&&a(G),u({type:"startInsertDrag",tool:K,start:G,points:K.command==="freehand"?[G]:void 0}),M(te)},[M,i,d,T,a,S,u]),_=Q2((te,K)=>{te.preventDefault(),te.stopPropagation(),i();let G=c.current,ie=T(te.clientX,te.clientY),fe=G.id==="overlay.curveDrawing"?G.points[G.points.length-1]:void 0,$=I(ie,{previousPoint:fe,shiftKey:te.shiftKey,enabled:hj(K)});if(G.id==="overlay.curveDrawing"){if(zDe(G.tool,G.points,ie)){B(G.tool,G.points,!0);return}let j=Xrt(G.points,$);if(G.tool.command==="threePointArc"){if(j.length>=3){B(G.tool,j.slice(0,3));return}u({type:"addCurvePoint",point:$});return}if(te.detail>=2){f.current=window.performance.now(),B(G.tool,j);return}u({type:"addCurvePoint",point:$});return}S([]),u({type:"startCurveDrawing",tool:K,point:$})},[B,i,I,c,T,S,f,u]),R=Q2(te=>{let K=c.current;if(K.id!=="overlay.curveDrawing"||K.tool.command==="threePointArc")return!1;te.preventDefault(),te.stopPropagation(),f.current=window.performance.now();let G=T(te.clientX,te.clientY),ie=K.points[K.points.length-1],fe=I(G,{previousPoint:ie,shiftKey:te.shiftKey,enabled:hj(K.tool)});return B(K.tool,Xrt(K.points,fe)),!0},[B,I,c,T,f]),O=Q2((te,K,G)=>{te.preventDefault(),te.stopPropagation(),i();let ie=x.current;ie&&K.id!==ie&&!hte(m.current,K.id,ie)&&(x.current=null,v(null));let fe=cF(m.current,K.id,x.current);if(te.shiftKey||te.metaKey||te.ctrlKey){w(fe);return}let j=b.current.length===1&&b.current[0]===K.id,pe=fe.every(Q=>b.current.includes(Q));if(pe||S(fe),Nc(K)){let Q=j&&!te.altKey?Cke(K,G,D()*.75):null;C(Q===null?null:{shapeId:K.id,index:Q})}if(te.altKey){let Q=A({x:0,y:0});if(Q.length===0)return;u({type:"startMove",shapes:Q,start:G}),M(te);return}let re=pe?b.current:fe,le=$x(m.current,re,g.current);if(le.length===0){Wh(m.current,re,g.current)&&y();return}u({type:"startMove",shapes:le,start:G,editOnPointerUp:Bd(K)&&j?"text":K.type==="tableShape"&&j?"table":void 0}),M(te)},[M,A,g,i,x,D,y,b,v,S,C,m,w,u]),N=Q2((te,K)=>{i(),x.current&&(x.current=null,v(null));let G=te.shiftKey||te.metaKey||te.ctrlKey;G||S([]),u({type:"startMarquee",start:K,additive:G}),M(te)},[M,i,x,v,S,u]),z=Q2(te=>{if(te.button!==0||te.defaultPrevented||s)return;let K=te.target instanceof Element?te.target:null;if(K?.closest(".overlay-text-shape-content, .graph2d-container.cropping")||K?.closest("[data-toolbar-popover]"))return;let G=kce(c.current);if(G.kind==="insert"){if(Iye(G)){_(te,G);return}L(te,G);return}let ie=T(te.clientX,te.clientY);if(!K?.closest("[data-overlay-shape-id]")){i();let fe=P(ie);if(fe){O(te,fe,ie);return}if(l&&!te.shiftKey&&!te.metaKey&&!te.ctrlKey&&ie.x>=l.x&&ie.x<=l.x+l.w&&ie.y>=l.y&&ie.y<=l.y+l.h){te.preventDefault();return}N(te,ie)}},[s,c,T,L,_,i,P,l,N,O]),U=Q2(te=>{if(te.button!==0||te.defaultPrevented||s||te.target instanceof Element&&te.target.closest(".overlay-text-shape-content, .overlay-table-shape-content, .graph2d-container.cropping"))return;let K=kce(c.current);if(K.kind==="insert"){if(Iye(K)){_(te,K);return}L(te,K);return}let G=T(te.clientX,te.clientY),ie=k(G,8)??P(G);if(!ie){if(te.target instanceof Element&&te.target.closest("button, a, input, textarea, [contenteditable='true'], [data-toolbar-popover]"))return;N(te,G);return}if(ie.type==="graph2dShape"&&!qv(ie,G,0))return;let fe=c.current;if(fe.id==="overlay.imageCropping"&&fe.shapeId===ie.id&&ie.type==="image"){te.preventDefault(),te.stopPropagation(),i(),F(ie.id),u({type:"startImageCropPan",shape:ie,start:G}),M(te);return}O(te,ie,G)},[N,M,i,P,k,s,_,c,T,F,L,O,u]),H=Q2((te,K)=>{te.preventDefault(),te.stopPropagation(),i();let G=$x(m.current,b.current,g.current),ie=Gnn(G,m.current);if(!ie){Wh(m.current,b.current,g.current)&&y();return}let fe=T(te.clientX,te.clientY);d.current=fe,p.current=ie.padding,u({type:"startResize",shapes:G,handle:K,start:fe,bounds:ie.visual}),M(te)},[M,g,i,d,y,T,p,b,m,u]),V=Q2((te,K,G)=>{if(K.locked)return;te.preventDefault(),te.stopPropagation(),i(),F(K.id);let ie=T(te.clientX,te.clientY);d.current=ie,u({type:"startImageCropResize",shape:K,handle:G,start:ie}),M(te)},[M,i,d,T,F,u]),ne=Q2(te=>{te.preventDefault(),te.stopPropagation(),i();let K=$x(m.current,b.current,g.current),G=Lke(K,m.current);if(!G){Wh(m.current,b.current,g.current)&&y();return}let ie=T(te.clientX,te.clientY);u({type:"startRotate",shapes:K,center:G,startAngle:vB(G,ie)}),M(te)},[M,g,i,y,T,b,m,u]),Z=Q2((te,K,G)=>{te.button!==0||K.locked||(te.preventDefault(),te.stopPropagation(),i(),F(K.id),u({type:"startAnchorDrag",shape:K,start:T(te.clientX,te.clientY),origin:G}),M(te))},[M,i,T,F,u]),ee=Q2((te,K,G)=>{if(!(K.locked||te.button!==0)){if(te.preventDefault(),te.stopPropagation(),i(),F(K.id),te.altKey&&K.type==="line"&&G.type==="line"&&UK(K.props.kind)){if(Ac(m.current,K))return;if(Js(m.current,K,g.current)){y();return}XQt(K.props.points,G.index,K.props.closed===!0)&&h({...K,props:{...K.props,points:WQt(K.props.points,G.index)}});return}xte(G)&&a(T(te.clientX,te.clientY)),u({type:"startPoint",shape:K,handle:G,pivot:dl(K),rotation:Oi(K)}),M(te)}},[M,g,i,y,T,F,a,m,u,h]),J=Q2((te,K,G,ie)=>{if(te.button!==0||Ac(m.current,K))return;if(Js(m.current,K,g.current)){y();return}te.preventDefault(),te.stopPropagation(),i(),F(K.id);let fe={...K,props:{...K.props,points:VQt(K.props.points,G,ie)}};h(fe,{history:"coalesce"}),u({type:"startPoint",shape:fe,handle:{type:"line",index:G},pivot:dl(fe),rotation:Oi(fe)}),M(te)},[M,g,i,y,F,m,u,h]);return{handleCurveDrawingDoubleClick:R,handleCanvasPointerDown:z,handleShapePointerDown:U,handleResizePointerDown:H,handleImageCropResizePointerDown:V,handleRotatePointerDown:ne,handlePointPointerDown:ee,handleLineInsertPointerDown:J,handleAnchorPointerDown:Z}}var FZn=X(()=>{"use strict";"use client";Pn();A_();Tc();yte();jh();_Ne();xP()});import{useCallback as Yj}from"react";function CZn({session:e,editing:t,geometry:n,snapDisabledRef:r,setSnapGuides:o,clearSnapGuides:i,lastCalloutCornerRadiusRef:a,imageCropDirtyRef:s}){let{transitionMode:l,lastInteractionPointRef:c,resizePaddingRef:u}=e,{shapesRef:d,setShapes:p,assetsRef:f,replaceShape:m}=t,{clientPointFromPage:h,getOverlaySnapThreshold:g,createSnapGeometry:y,anchorMeasurementsRef:b}=n,x=Yj((T,D)=>{if(Xot({start:h(T.start)},h(D))){i(),T.offset&&l({type:"updateMove",offset:{x:0,y:0}});return}let k=D.x-T.start.x,P=D.y-T.start.y,I=new Set(T.shapes.map(_=>_.id)),B=pd(T.shapes),M=k,L=P;if(B){let _=y(By(d.current,[...I],{includeGroups:!0})),R={threshold:g(),disabled:r.current},O=hrn(mrn(T.shapes),{x:k,y:P},_,R),N=O.guides.length>0?O:frn({...B,x:B.x+k,y:B.y+P},_,R);M+=N.nudge.x,L+=N.nudge.y,o(N.guides)}else i();l({type:"updateMove",offset:{x:M,y:L}})},[h,i,y,g,o,d,r,l]),v=Yj((T,D,k)=>{let{bounds:P,isRotated:I,preserveAspect:B,targetAspect:M}=Rnn(T,D,k),L=new Set(T.shapes.map(O=>O.id)),_=P;if(I)i();else{let O=grn(P,T.handle,y(By(d.current,[...L],{includeGroups:!0})),{threshold:g(),disabled:r.current,preserveAspect:B,targetAspect:M});_=O.bounds,o(O.guides)}let R={visual:T.bounds,padding:u.current};p(O=>{let N=I?[Vnn(T.shapes[0],R,_,T.handle)]:jnn(T.shapes,R,_,T.handle),z=new Set(N.map(H=>H.id)),U=Qr(Jx(Wv(O,N),z,b.current.ordered));return d.current=U,U})},[b,i,y,g,u,p,o,d,r]),S=Yj((T,D,k)=>{let P=qot(T.shape,T.handle,y9(D,T.pivot,T.rotation,T.shape.flipX,T.shape.flipY),k.shiftKey);P.type==="callout"&&T.handle.type==="calloutCornerRadius"&&(a.current=P.props.radius,qNe(P.props.radius));let I=jKn(P,T.handle);if(!I){i(),m(P);return}let B=oit(I,y(By(d.current,[T.shape.id],{includeGroups:!0})),{threshold:g(),disabled:r.current});o(B.guides);let M=B.snapped?qot(T.shape,T.handle,y9(B.point,T.pivot,T.rotation,T.shape.flipX,T.shape.flipY),k.shiftKey):P;m(M)},[i,y,g,a,m,o,d,r]),F=Yj((T,D)=>{i();let k=d.current.find(z=>z.id===T.shape.id&&z.type==="image");if(!k)return;let P=f.current[k.props.assetId],I=D.x-T.start.x,B=D.y-T.start.y,M=Yot(I,B,Oi(T.shape)),L={x:T.shape.flipX?-M.x:M.x,y:T.shape.flipY?-M.y:M.y};if(T.id==="overlay.imageCropPan"){let U={...eWn(T.shape,P,L.x,L.y),x:k.x,y:k.y,rotation:k.rotation,anchor:k.anchor};if(LAt(k,U,P))return;s.current=!0,m(U);return}let _=yi(T.shape),R=QXn(_,iw(T.shape,P),{w:P?.props.w||T.shape.props.w,h:P?.props.h||T.shape.props.h},T.handle,L),O=Dke(T.shape,_,R.bounds,T.handle),N={...k,x:O.x,y:O.y,props:{...k.props,w:O.props.w,h:O.props.h,crop:R.crop}};LAt(k,N,P)||(s.current=!0,p(z=>{let U=Qr(Jx(aB(z,N),new Set([N.id]),b.current.ordered));return d.current=U,U}))},[b,f,i,s,m,p,d]),w=Yj((T,D={})=>{let k=D.shiftKey&&D.previousPoint?I5(D.previousPoint,T):T;if(D.enabled===!1)return i(),k;let P=oit(k,y(),{threshold:g(),disabled:r.current});return o(P.guides),P.point},[i,y,g,o,r]),C=Yj((T,D,k,P)=>{let I=VKn(T,D,k,P);return CXn(T)?w(I,{enabled:!0}):(i(),I)},[i,w]);return{updateModifierDrivenInteraction:Yj((T,D)=>{let k=c.current;if(!k)return!1;if(T.id==="overlay.move")return x(T,k),!0;if(T.id==="overlay.resize")return v(T,k,D),!0;if(T.id==="overlay.point")return S(T,k,D),!0;if(T.id==="overlay.insertDrag")return l({type:"updateInsertDrag",current:C(T.tool,T.start,k,D)}),!0;if(T.id==="overlay.curveDrawing"){let P=T.points[T.points.length-1];return l({type:"updateCurveDrawing",current:w(k,{previousPoint:P,shiftKey:D.shiftKey,enabled:hj(T.tool)})}),!0}return!1},[x,S,v,w,C,c,l]),getSnappedDrawingPoint:w,applyMoveInteractionAtPoint:x,applyResizeInteractionAtPoint:v,applyPointInteractionAtPoint:S,applyImageCropInteractionAtPoint:F,getSnappedInsertDragPoint:C}}var AZn=X(()=>{"use strict";"use client";Dt();Pn();MAt();Tc();NNe();qte();jh();Ly();KNe();WCt();xP()});function TZn({payload:e,canvasWidth:t,canvasHeight:n,offset:r={x:20,y:20},targetDocId:o,anchorBlockIdMap:i,centerAt:a,unbounded:s=!1,pointerPlacement:l}){let c=!!o&&e.sourceDocId===o,u=a||l?pd(e.shapes):null,d=!a&&l&&u?nZn(l.point,u,l.layout):null,p=a??d,f=p&&u?{x:p.x-(u.x+u.w/2),y:p.y-(u.y+u.h/2)}:r,m=aJ(e,f,{dropBlockAnchors:!c||!!(p&&u),droppedBlockAnchor:d?"unanchored":"page",anchorBlockIdMap:i});if(m.shapes.length===0)return{shapes:[],assets:m.assets,selectedIds:[]};let h=m.shapes.map(Jni),g=Qr(s?h:rY(h,t,n)),y=new Set(g.map(x=>x.id)),b=g.filter(x=>!x.parentId||!y.has(x.parentId)).map(x=>x.id);return{shapes:g,assets:m.assets,selectedIds:b}}function Jni(e){let t={...e};return delete t.locked,delete t.hidden,t}var DZn=X(()=>{"use strict";Dt();Pn();Sp();xbe()});function kZn(e,t,n){let r=Qr(e),o=new Set(t),i=new Set(r.filter(l=>o.has(l.id)&&!ari(l,r,o)).map(l=>l.id));if(i.size===0)return r;let a=ori(r),s=new Map;for(let[l,c]of a){if(c.filter(d=>i.has(d.id)).length===0){s.set(l,c);continue}s.set(l,Qni(c,i,n))}return eri(Qr(iri(r,s)),i,n)}function Qni(e,t,n){if(n==="front"||n==="back"){let o=e.filter(a=>t.has(a.id)),i=e.filter(a=>!t.has(a.id));return n==="front"?[...i,...o]:[...o,...i]}let r=e.slice();if(n==="forward"){for(let o=r.length-2;o>=0;o-=1){let i=r[o];if(t.has(i.id)){let a=nri(r,o,t);a>o&&(r.splice(o,1),r.splice(a,0,i))}}return r}for(let o=1;o<r.length;o+=1){let i=r[o];if(t.has(i.id)){let a=rri(r,o,t);a<o&&(r.splice(o,1),r.splice(a,0,i))}}return r}function eri(e,t,n){let r=tri(e,t);if(r.size===0)return e;let o=n==="back"?"background":void 0,i=!1,a=e.map(s=>{if(!r.has(s.id))return s;if(o)return s.stackLayer===o?s:(i=!0,{...s,stackLayer:o});if(s.stackLayer===void 0)return s;let l={...s};return delete l.stackLayer,i=!0,l});return i?a:e}function tri(e,t){let n=new Set,r=o=>{if(!n.has(o.id)){n.add(o.id);for(let i of e.filter(a=>a.parentId===o.id))r(i)}};for(let o of e)t.has(o.id)&&r(o);return n}function nri(e,t,n){let r=e[t];for(let o=t+1;o<e.length;o+=1){let i=e[o];if(!n.has(i.id)&&EZn(r,i))return o}for(let o=t+1;o<e.length;o+=1)if(!n.has(e[o].id))return o;return t}function rri(e,t,n){let r=e[t];for(let o=t-1;o>=0;o-=1){let i=e[o];if(!n.has(i.id)&&EZn(r,i))return o}for(let o=t-1;o>=0;o-=1)if(!n.has(e[o].id))return o;return t}function EZn(e,t){let n=Zp(e),r=Zp(t);return n.x<=r.x+r.w&&n.x+n.w>=r.x&&n.y<=r.y+r.h&&n.y+n.h>=r.y}function ori(e){let t=new Map;for(let n of e){let r=n.parentId??"";t.set(r,[...t.get(r)??[],n])}return t}function iri(e,t){let n=[],r=new Set,o=i=>{if(!r.has(i.id)&&(r.add(i.id),n.push(i),i.type==="group"))for(let a of t.get(i.id)??[])o(a)};for(let i of t.get("")??[])o(i);for(let i of e)o(i);return n}function ari(e,t,n){let r=e.parentId,o=new Set([e.id]);for(;r;){if(n.has(r))return!0;if(o.has(r))return!1;o.add(r),r=t.find(i=>i.id===r)?.parentId}return!1}var IZn=X(()=>{"use strict";Dt();Pn()});import{useCallback as tv}from"react";function PZn({shapesRef:e,selectedIdsRef:t,editPolicyLockedShapeIdsRef:n,notifyEditPolicyBlocked:r,assetsRef:o,canvasWidthRef:i,canvasHeightRef:a,setAssets:s,setShapes:l,setSelectedShapeIds:c,transitionMode:u,queueOverlaySave:d,extensionsRef:p,explicitlySavedShapeStatesRef:f,pendingOverlaySaveHistoryGroupRef:m,commitOverlayChangeNow:h,refreshAnchorMeasurements:g,solidEdgeRef:y,documentIdRef:b,canvasRef:x,getBlockAnchorScope:v,pageHeightPx:S,pageGapPx:F}){let w=tv((N={x:20,y:20})=>{if(Wh(e.current,t.current,n.current))return r(),[];let z=y_(e.current,t.current);if(z.length===0)return[];let U=aJ(Nw(z,o.current),N),H=Qr(rY(U.shapes.map(DKn),i.current,a.current)),V=new Set(H.map(Z=>Z.id)),ne=H.filter(Z=>!Z.parentId||!V.has(Z.parentId)).map(Z=>Z.id);return s(Z=>{let ee={...Z,...U.assets};return o.current=ee,ee}),l(Z=>{let ee=Qr([...Z,...H]);return e.current=ee,ee}),c(ne),u({type:"select"}),d(),H},[o,a,i,n,r,d,t,s,c,l,e,u]),C=tv(()=>{let N=new Set(By(e.current,t.current,{includeGroups:!0})),z=new Set(e.current.filter(U=>N.has(U.id)&&!Ac(e.current,U)&&!Js(e.current,U,n.current)).map(U=>U.id));for(let U of e.current)if(!(U.type!=="graph2dShape"||!N.has(U.id)||U.locked||Js(e.current,U,n.current)))for(let H of Jye(U,e.current)){let V=e.current.find(ne=>ne.id===H);V&&!V.locked&&!Js(e.current,V,n.current)&&z.add(H)}return[...z]},[n,t,e]),A=tv(()=>{Wh(e.current,t.current,n.current)&&r();let N=C();if(N.length===0)return;let z=new Set(N),U=dB({version:1,shapes:Qr(WAe(e.current,N)),assets:o.current,...p.current?{extensions:p.current}:{}});e.current=U.shapes,o.current=U.assets,f.current.add(U.shapes),l(U.shapes),s(U.assets);let H=m.current;m.current=null,h(H?{historyGroup:H}:{}),c(t.current.filter(V=>!z.has(V))),u({type:"select"})},[o,h,n,f,p,C,r,m,t,s,c,l,e,u]),T=tv(()=>{if(Wh(e.current,t.current,n.current)){r();return}let N=PXn(e.current,t.current,iXn);e.current=N.shapes,l(N.shapes),c(N.selectedIds),u({type:"select"})},[n,r,t,c,l,e,u]),D=tv(()=>{if(Wh(e.current,t.current,n.current)){r();return}let N=MXn(e.current,t.current);e.current=N.shapes,l(N.shapes),c(N.selectedIds),u({type:"select"})},[n,r,t,c,l,e,u]),k=tv(N=>{if(Wh(e.current,t.current,n.current)){r();return}let z=new Set(t.current);l(U=>{let H=Qr(U.map(V=>z.has(V.id)?{...V,locked:N}:V));return e.current=H,H})},[n,r,t,l,e]),P=tv(N=>{let z=new Set(t.current);l(U=>{let H=Qr(U.map(V=>z.has(V.id)?{...V,hidden:N}:V));return e.current=H,H})},[t,l,e]),I=tv(N=>{let z=t.current;if(z.length===0)return;if(Wh(e.current,z,n.current)){r();return}let U=$x(e.current,z,n.current).map(V=>V.id);if(U.length===0)return;let H=kZn(e.current,U,N);_ke(e.current,H)||(e.current=H,l(H),c(z))},[n,r,t,c,l,e]),B=tv(N=>{Wh(e.current,t.current,n.current)&&r();let z=AA(e.current,t.current).filter(ne=>!Ac(e.current,ne)&&!Js(e.current,ne,n.current));if(z.length<2)return;let U=pnn(z,N),H=new Set(By(e.current,z.map(ne=>ne.id),{includeGroups:!0})),{ordered:V}=g();l(ne=>{let Z=Qr(Jx(PAt(ne,z,U),H,V));return e.current=Z,Z})},[n,r,g,t,l,e]),M=tv(N=>{Wh(e.current,t.current,n.current)&&r();let z=AA(e.current,t.current).filter(ne=>!Ac(e.current,ne)&&!Js(e.current,ne,n.current));if(z.length<3)return;let U=fnn(z,N),H=new Set(By(e.current,z.map(ne=>ne.id),{includeGroups:!0})),{ordered:V}=g();l(ne=>{let Z=Qr(Jx(PAt(ne,z,U),H,V));return e.current=Z,Z})},[n,r,g,t,l,e]),L=tv(N=>{if(Wh(e.current,t.current,n.current)){r();return}let z=$x(e.current,t.current,n.current),U=Lke(z,e.current);if(!U)return;let H=N==="rotateClockwise"?$9(z,U,Math.PI/2):N==="rotateCounterclockwise"?$9(z,U,-Math.PI/2):Tce(z,U,N),V=new Set(H.map(Z=>Z.id)),{ordered:ne}=g();l(Z=>{let ee=Qr(Jx(Wv(Z,H),V,ne));return e.current=ee,ee})},[n,r,g,t,l,e]),_=tv(N=>{Wh(e.current,t.current,n.current)&&r();let z=y.current,U=z&&N.dash!==void 0?N.dash:void 0,H=z&&N.size!==void 0?N.size:void 0,V=U===void 0&&H===void 0?N:{...N,...U===void 0?{}:{dash:void 0},...H===void 0?{}:{size:void 0}},ne=e.current,Z=jte(ne,t.current,n.current),ee=Qr(ne.map(J=>{if(!Z.has(J.id))return J;let te=cte(J,V);if(z?.shapeId!==J.id||!Nc(te))return te;let K=U===void 0?te:nnn(te,z.index,U);return H===void 0?K:onn(K,z.index,H)}));e.current=ee,l(ee)},[n,r,t,l,e,y]),R=tv((N,z={})=>{let U=z.pointerClient&&!z.centerAt&&Object.keys(z.anchorBlockIdMap??{}).length===0?oZn(z.pointerClient,x.current?.getBoundingClientRect(),{canvasWidth:i.current,canvasHeight:a.current,pageHeightPx:S,pageGapPx:F},rZn(W2(x.current))):null,H=TZn({payload:N,canvasWidth:i.current,canvasHeight:a.current,targetDocId:b.current,anchorBlockIdMap:z.anchorBlockIdMap,centerAt:z.centerAt,unbounded:z.unbounded,pointerPlacement:U??void 0});if(H.shapes.length===0)return!1;let V=new Set(Object.values(z.anchorBlockIdMap??{})),ne=H.shapes;if(V.size>0&&x.current){let J=v(),{rects:te}=J?yP(x.current,J,a.current,i.current):{rects:new Map},K=new Map([...te].filter(([G])=>V.has(G)));K.size>0&&(ne=Qr(F0(ne,K,Qx(ne))))}let Z={...o.current,...H.assets},ee=Qr([...e.current,...ne]);return o.current=Z,e.current=ee,f.current.add(ee),s(Z),l(ee),h(z.historyGroup?{historyGroup:z.historyGroup}:{}),c(H.selectedIds),u({type:"select"}),!0},[o,a,x,i,h,b,f,v,F,S,s,c,l,e,u]),O=tv((N,z)=>{let U=new Set(ykn(z));if(U.size===0)return N;let{ordered:H}=g(),V=H.filter(ee=>U.has(ee.id));if(V.length===0)return N;let ne=new Set(N.map(ee=>ee.id)),Z=e.current.map(ee=>ne.has(ee.id)?kKn(ee):ee);return y_(Jx(Z,ne,V),t.current)},[g,t,e]);return{duplicateSelectedShapes:w,deleteSelectedShapes:A,arrangeSelectedShapes:I,alignSelectedShapes:B,distributeSelectedShapes:M,groupSelectedShapes:T,ungroupSelectedShapes:D,setSelectedShapesLocked:k,setSelectedShapesHidden:P,applyStyleToSelectedShapes:_,applyPastedOverlayShapes:R,reanchorShapesToCopiedBlocks:O,getRemovableSelectedShapeIds:C,applyQuickTransformToSelectedShapes:L}}var MZn=X(()=>{"use strict";"use client";Dt();Pn();Sp();v_();My();A_();Tc();tE();DZn();sF();xbe();Ly();IZn();Vte();D_();dj()});import{useEffect as sri,useState as LZn}from"react";import{jsx as __,jsxs as BZn}from"react/jsx-runtime";function RZn(e){return e.id==="overlay.move"?"move":e.id==="overlay.resize"?"resize":e.id==="overlay.rotate"?"rotate":e.id==="overlay.imageCropResize"||e.id==="overlay.imageCropPan"?"crop":null}function lri(e){let[t,n]=LZn(null);return sri(()=>{if(!e?.remoteOverlayPresence||!e.subscribePresence)return;let r=()=>n({session:e,presence:e.remoteOverlayPresence?.()??[]});return e.subscribePresence(r)},[e]),e?.remoteOverlayPresence?t?.session===e?t.presence:e.remoteOverlayPresence():[]}function vbe({shapes:e,arrangement:t}){let n=HD(),o=lri(n).map(a=>({participant:a,frames:ITt(a,e)})).filter(a=>a.frames.length>0).sort((a,s)=>a.participant.clientId.localeCompare(s.participant.clientId)),i=new Map;return __("div",{className:"overlay-remote-presence-layer","aria-hidden":"true",children:o.map(({participant:a,frames:s})=>{let l=PTt(s),c=`${Math.round(l.x)}:${Math.round(l.y)}:${s.map(p=>p.id).sort().join("|")}`,u=i.get(c)??0;i.set(c,u+1);let d=uri(a.clientId);return BZn("div",{className:"overlay-remote-presence","data-remote-client-id":a.clientId,"data-remote-preview-kind":a.preview?.kind,style:{"--overlay-remote-color":d},children:[s.map(p=>__(Gd,{arrangement:t,y:p.y,children:__("div",{className:"overlay-remote-selection-box","data-remote-shape-id":p.id,style:MTt(p)})},p.id)),__(Gd,{arrangement:t,y:l.y,children:BZn("span",{className:"overlay-remote-presence-label","data-remote-label-slot":u,style:{left:l.x,top:l.y-u*30},children:[__(cri,{participant:a}),__("span",{children:a.displayName})]})})]},a.clientId)})})}function ITt(e,t){let n=new Map(t.map(o=>[o.id,o])),r=e.preview?.shapes.filter(o=>n.has(o.id))??[];return r.length>0?r:e.selectedShapeIds.flatMap(o=>{let i=n.get(o);if(!i)return[];let a=i.type==="group"?aw([i],t)??A0(i):A0(i),s=Oi(i);return[{id:o,...a,...s?{rotation:s,pivot:dl(i)}:{}}]})}function PTt(e){let t=e.map(n=>FK(n,n.rotation??0,n.pivot));return Wg(t.flatMap(n=>[{x:n.x,y:n.y},{x:n.x+n.w,y:n.y+n.h}]))}function cri({participant:e}){let[t,n]=LZn(!1),r=e.displayName.trim().charAt(0).toLocaleUpperCase()||"?";return __("span",{className:"overlay-remote-presence-avatar",children:e.avatarSource&&!t?__("img",{src:e.avatarSource,alt:"",onError:()=>n(!0)}):r})}function uri(e){let t=["#2563eb","#7c3aed","#db2777","#059669","#d97706","#0891b2"],n=0;for(let r=0;r<e.length;r+=1)n=(n<<5)-n+e.charCodeAt(r)|0;return t[Math.abs(n)%t.length]}function MTt(e){return{left:e.x,top:e.y,width:e.w,height:e.h,transform:e.rotation?`rotate(${e.rotation}rad)`:void 0,transformOrigin:e.rotation&&e.pivot?eAt(e.pivot,e):void 0}}var sze=X(()=>{"use strict";"use client";Pn();u4();jh();gte();tAt()});import{useEffect as lze,useLayoutEffect as dri,useMemo as mE}from"react";function _Zn({shapes:e,selectedIds:t,assets:n,editPolicyLockedShapeIds:r,mode:o,initialOriginPickShapeId:i,selectedRegion:a,dragOffset:s,publishesSessionPresence:l,documentSession:c,tShape:u,adjustmentDragReadoutPointerPosition:d,shapeStyleDefaults:p,showAnchorHandles:f,anchorMeasurements:m,canvasWidth:h,canvasHeight:g,bleedValues:y,onSelectionSummaryChange:b,solidEdge:x,acceptsStylePreview:v,setPreview:S,shapesRef:F,selectedIdsRef:w,editPolicyLockedShapeIdsRef:C}){let A=mE(()=>AA(e,t),[t,e]),T=mE(()=>$nn(A),[A]),D=mE(()=>y_(e,t),[t,e]),k=mE(()=>Znn(D,n),[n,D]),P=mE(()=>{let re=new Set(D.map(se=>se.id)),le=new Set(KDe(e,re)),Q=e.filter(se=>le.has(se.id)&&!re.has(se.id));return Q.length>0?[...D,...Q]:D},[D,e]),I=mE(()=>$x(e,t,r),[r,t,e]),B=mE(()=>Bke(A,e),[A,e]),M=A.length>0&&A.every(re=>Ac(e,re)),L=A.length>0&&A.every(re=>mte(e,re)),_=A.length===1?nY(A[0]):A.some(re=>!Ac(e,re)),R=!I.some(re=>re.type==="tableShape"),O=o.id==="overlay.graphEditing"&&A.length===1&&A[0]?.id===o.shapeId,N=o.id==="overlay.graph3dEditing"&&A.length===1&&A[0]?.id===o.shapeId,z=(o.id==="overlay.imageCropping"||o.id==="overlay.imageCropResize"||o.id==="overlay.imageCropPan")&&A.length===1&&A[0]?.id===(o.id==="overlay.imageCropping"?o.shapeId:o.shape.id)&&A[0]?.type==="image"?A[0]:null,U=i!==null,H=o.id==="overlay.marquee"?Wg([o.start,o.current]):a,V=o.tool,ne=o.id==="overlay.move"?o.shapes:null,Z=mE(()=>{if(!ne)return null;let re=new Set(ne.map(le=>le.id));for(let le of ne)if(le.type===lF)for(let Q of Jye(le,e))re.add(Q);return BXn(e,re)},[ne,e]),ee=mE(()=>{if(t.length===0)return null;let re=RZn(o),le=re?A.map(Q=>{let se=Q.type==="group"?aw([Q],e)??A0(Q):A0(Q),De=o.id==="overlay.move"&&Z?.has(Q.id)&&s?{...se,x:se.x+s.x,y:se.y+s.y}:se,Ae=Oi(Q),ye=Ae?dl(Q):null,$e=ye&&o.id==="overlay.move"&&Z?.has(Q.id)&&s?{x:ye.x+s.x,y:ye.y+s.y}:ye;return{id:Q.id,...De,...Ae&&$e?{rotation:Ae,pivot:$e}:{}}}):[];return{selectedShapeIds:t,...re?{preview:{kind:re,shapes:le}}:{}}},[s,o,Z,t,A,e]);lze(()=>{l&&c?.setOverlayPresence?.(ee)},[c,ee,l]),lze(()=>()=>{l&&c?.setOverlayPresence?.(null)},[c,l]);let J=o.id==="overlay.anchor"?o:null,te=o.id==="overlay.insertDrag"?o:null,K=o.id==="overlay.curveDrawing"?o:null,G=K?zDe(K.tool,K.points,K.current):!1,ie=K?NDe(K.points,K.current,G):null,fe=uWn(o,K,G,u),$=te?{tool:te.tool,start:te.start,current:te.current,points:te.points,closed:!1,bounds:Wg([te.start,te.current])}:K&&ie?{tool:K.tool,start:ie[0],current:ie[ie.length-1],points:ie,closed:G,bounds:Wg(ie)}:null,j=fWn(o,e,d,p,u),pe=mE(()=>{if(!f)return[];let re=J?N9e(J):null;return A.filter(le=>!LXn(e,le)&&!mte(e,le)&&!ace(le,e)).map(le=>TWn(le,e,m,h,g,J?.shape.id===le.id?re:null,Z?.has(le.id)??!1,y)).filter(le=>le!==null)},[J,m,y,g,h,Z,A,e,f]);return dri(()=>{let re=A.some(eXn),le=A.some(xCt),Q=A.some(tXn),se=A.some(nXn),De=vCt(A,"start"),Ae=vCt(A,"end"),ye=rXn(D);b?.({...o.id==="overlay.textEditing"||o.id==="overlay.tableEditing"?{textEditing:{shapeId:o.shapeId,kind:o.id==="overlay.tableEditing"?"table":"text"}}:{},...a?{region:a}:{},selectedCount:A.length,selectedShapeIds:t,selectedShapes:D,selectedAssets:k,...P!==D?{previewShapes:P}:{},locked:M,hidden:L,grouped:A.some($e=>wh($e)||!!$e.parentId),canAlign:A.length>=2,canDistribute:A.length>=3,canStyleStroke:re,canStyleFill:le,canStyleLine:Q,canStyleLineEndpoints:se,arrowheadStart:De,arrowheadEnd:Ae,fill:ye,...x&&A.length===1&&A[0].id===x.shapeId?{solidEdge:x}:{}})},[o,b,x,a,k,D,P,L,t,M,A]),lze(()=>()=>{b?.({selectedCount:0,selectedShapeIds:[],selectedShapes:[],selectedAssets:{},locked:!1,hidden:!1,grouped:!1,canAlign:!1,canDistribute:!1,canStyleStroke:!1,canStyleFill:!1,canStyleLine:!1,canStyleLineEndpoints:!1,arrowheadStart:null,arrowheadEnd:null,fill:{kind:"unavailable"}})},[b]),lze(()=>{if(!v)return;let re=le=>{let Q=le.detail?.style??null;S(Q===null?null:{style:Q,targetIds:jte(F.current,w.current,C.current)})};return window.addEventListener(aze,re),()=>window.removeEventListener(aze,re)},[v,C,w,S,F]),{movingShapeIds:Z,selectedShapes:A,currentTool:V,selectionChromeHidden:U,selectionImageCropShape:z,selectedDimensionShapes:T,selectionBounds:B,selectionCanResize:_,selectedLocked:M,selectionIsGraphCropping:O,selectionIsGraph3DEditing:N,selectionCanRotate:R,anchorIndicators:pe,marqueeBounds:H,insertPreview:$,curveDrawing:K,curveDrawingClosed:G,adjustmentDragReadout:j,drawingHint:fe}}var OZn=X(()=>{"use strict";"use client";Pn();PP();Tc();XNe();qte();jh();sze();Vte();QCt();Yx();D_();dj()});import{useCallback as hE}from"react";function NZn({activeTextEditorRef:e,selectShape:t,transitionMode:n,shapesRef:r,updateShape:o,updateGraphShapeSpec:i,insertedTableFocusRef:a}){let s=hE((y,b)=>{e.current=y,t(b),n({type:"editText",shapeId:b})},[e,t,n]),l=hE(y=>{e.current?.commands.blur(),e.current=null,t(y)},[e,t]),c=hE((y,b,x)=>{let v=r.current.find(F=>F.id===y);if(!v||!Bd(v))return;let S=v.type==="callout"?Math.max(v.props.h,b):b;Math.abs(v.props.h-S)<1||o({id:y,type:v.type,props:{h:S}},x?.preview?void 0:{history:"coalesce"})},[r,o]),u=hE((y,b)=>{let x=r.current.find(v=>v.id===y);!x||!Bd(x)||pri(x.props.blocks,b)||o({id:y,type:x.type,props:{blocks:b}},{commit:!0})},[r,o]),d=hE((y,b,x)=>{let v=x?.source==="crop"&&x.resizeToCrop?x.cropBox:void 0,S=v?r.current.find(w=>w.id===y&&w.type===lF):null,F=S&&v?sXn(S,v):{};i(y,b,F,{preserveGraphOwnedLabelPositions:x?.source==="crop",commit:x?.source==="crop"})},[r,i]),p=hE((y,b)=>{a.current===b&&(a.current=null,wte(),y.commands.focus("start",{scrollIntoView:!1}))},[a]),f=hE((y,b)=>{e.current=y,t(b),n({type:"editTable",shapeId:b})},[e,t,n]),m=hE((y,b)=>{o({id:y,type:nE,props:{table:b}})},[o]),h=hE((y,b)=>{o({id:y,type:nE,...b.x===void 0?{}:{x:b.x},...b.y===void 0?{}:{y:b.y},props:{w:b.w,h:b.h,table:b.table}})},[o]),g=hE(()=>{n({type:"select"})},[n]);return{handleTableChange:m,handleTableEditorFocus:f,handleTableFirstCellReady:p,handleTableResize:h,handleTextMeasuredHeight:c,handleTextChange:u,handleTextEditorCancel:l,handleTextEditorFocus:s,handleGraphSpecChange:d,handleGraphCropEnd:g}}function pri(e,t){return JSON.stringify(e)===JSON.stringify(t)}var zZn=X(()=>{"use strict";"use client";Pn();Yx();m_();Oye()});import{useEffect as $j,useMemo as fri,useRef as qm,useState as BTt}from"react";function UZn({overlay:e,canvasWidth:t,canvasHeight:n,documentId:r,externalRevision:o,onChange:i}){let a=fri(()=>ir(e.overlaySnapshot),[e.overlaySnapshot]),[s,l]=BTt(a.shapes),[c,u]=BTt(a.assets),[d]=BTt(()=>BKn(ff)),p=qm(t),f=qm(n),m=qm(r);$j(()=>{m.current=r},[r]),$j(()=>{p.current=t},[t]),$j(()=>{f.current=n},[n]);let h=qm(void 0),g=qm(null),y=qm(null),b=qm(!1),x=qm(!1),v=qm(!1),S=qm(new WeakSet),F=qm(o),w=qm(null),C=qm(e.overlaySnapshot),A=qm(e.overlaySnapshot),T=qm(i),D=qm(s),k=qm(c),P=qm(a.extensions);$j(()=>{T.current=i},[i]);let I=qm(s);return $j(()=>{s!==I.current&&(D.current=s)},[s]),$j(()=>{let B=d(D.current,{width:t,height:n});B!==D.current&&(D.current=B,l(B))},[t,n,d,s]),$j(()=>{k.current=c},[c]),{shapes:s,setShapes:l,assets:c,setAssets:u,canvasWidthRef:p,canvasHeightRef:f,documentIdRef:m,saveTimeoutRef:h,pendingOverlayHistoryRef:g,pendingOverlaySaveHistoryGroupRef:y,imageCropDirtyRef:b,mountedRef:x,suppressNextSaveRef:v,explicitlySavedShapeStatesRef:S,externalRevisionRef:F,lastEmittedSnapshotRef:w,seenDocumentSnapshotRef:C,reconciledDocumentSnapshotRef:A,onChangeRef:T,shapesRef:D,assetsRef:k,extensionsRef:P}}var HZn=X(()=>{"use strict";"use client";Dt();tE();D_()});import{useCallback as LTt,useEffect as VZn}from"react";function XZn({shapesRef:e,selectedIdsRef:t,editingShapeId:n,updateShape:r,activeTextEditorRef:o,modeRef:i}){let a=LTt(c=>{let u=Rke(e.current,t.current,n);u&&r({id:u.id,type:u.type,props:{blocks:sZt(u.props.blocks,c,()=>rt("p"))}},{commit:!0})},[n,t,e,r]),s=LTt((c,u)=>{let d=Rke(e.current,t.current,n);d&&r({id:d.id,type:d.type,props:{blocks:ett(d.props.blocks,c,u)}},{commit:!0})},[n,t,e,r]),l=LTt(c=>{let u=Rke(e.current,t.current,n);!u||!Number.isFinite(c)||r({id:u.id,type:u.type,props:{fontSize:c,size:rK(c),blocks:ett(u.props.blocks,"fontSize",String(c))}},{commit:!0})},[n,t,e,r]);VZn(()=>{let c=u=>{let d=u instanceof CustomEvent?u.detail:null,p=typeof d?.tex=="string"?d.tex:"",f=d?.edit===!0;if(d?.target!=="overlay"||!p&&!f)return;let m=o.current;if(m?.isFocused){let g=`overlay_math_${Date.now()}`;m.chain().focus().insertMathInline({id:g,tex:p}).run(),f&&J0(g);return}let h=`overlay_math_${Date.now()}`;a({type:"mathInline",id:h,tex:p,display:"inline",semanticRole:"expression"}),f&&J0(h)};return window.addEventListener(GZn,c),()=>window.removeEventListener(GZn,c)},[o,a]),VZn(()=>{let c=u=>{let d=u instanceof CustomEvent?u.detail:null;if(d?.target!=="overlay"||!d?.command)return;let p=d.command,f=typeof d.value=="string"?d.value:void 0,m=o.current,h=i.current.id==="overlay.textEditing"||i.current.id==="overlay.tableEditing";if(h&&m&&!m.isDestroyed)if(p==="fontSize"&&f)m.chain().focus().setFontSize(Number(f)).run();else if(p==="bold")m.chain().focus().toggleBold().run();else if(p==="italic")m.chain().focus().toggleItalic().run();else if(p==="underline")m.chain().focus().toggleUnderline().run();else if(p==="boxed")m.chain().focus().toggleBoxedText().run();else if(p==="boxedPaddingY"&&f){let g=Number.parseFloat(f);Number.isFinite(g)&&g>=0&&m.chain().focus().setBoxedTextPaddingY(g).run()}else if(p==="boxedVariant"&&f){let g=pWn(f);g&&m.chain().focus().setBoxedTextVariant(g).run()}else if(p==="boxedRoundness"&&f){let g=Number.parseFloat(f);Number.isFinite(g)&&g>=0&&m.chain().focus().setBoxedTextRoundness(g).run()}else if(p==="color"&&f)m.chain().focus().setTextColor(f).run();else if(p==="backgroundColor"){let g=m.chain().focus();f?g.setTextBackgroundColor(f).run():g.unsetTextBackgroundColor().run()}else if(p==="fontFamily"){let g=m.chain().focus();f?g.setFontFamily(f).run():g.unsetFontFamily().run()}else if(p==="lineHeight"&&f){let g=gi(f);g&&m.chain().focus().updateAttributes("paragraph",{lineHeight:g}).run()}else p==="textAlign"&&f?m.chain().focus().updateAttributes("paragraph",{textAlign:f}).run():p==="blockStyle"&&f&&NR(m,{command:p,value:f},{selection:null,blockNodeType:"paragraph",allowBlockStyle:!0});else p!=="fontSize"&&p!=="blockStyle"&&s(p,f);!h&&p==="fontSize"&&f&&l(Number(f))};return window.addEventListener(jZn,c),()=>window.removeEventListener(jZn,c)},[o,s,i,l])}var GZn,jZn,WZn=X(()=>{"use strict";"use client";hA();jk();Dt();Pn();ai();XNe();GZn="sigma-studio:insert-inline-math",jZn="sigma-studio:format-text"});import{useMemo as MP}from"react";function qZn({selectedIds:e,preview:t,shapes:n,visibleOriginPickPreview:r,movingShapeIds:o,editingShapeId:i,graphFillPickShapeId:a,initialOriginPickShapeId:s,visiblePageRange:l,pageHeightPx:c,pageGapPx:u}){let d=MP(()=>new Set(e),[e]),p=MP(()=>t===null?n:n.map(S=>t.targetIds.has(S.id)?cte(S,t.style):S),[t,n]),f=MP(()=>ux(p).map(S=>{let F=S9(p,S);return F===void 0?S:{...S,opacity:F}}),[p]),m=MP(()=>new Set(ux(DB(n,"background")).map(S=>S.id)),[n]),h=r?.shapeId??null,g=MP(()=>{let S=new Set;for(let F of By(n,[...e],{includeGroups:!0}))S.add(F);for(let F of o??[])S.add(F);for(let F of[i,a,s,h])F&&S.add(F);return S},[i,a,s,o,h,e,n]),y=MP(()=>!l||c<=0?f:f.filter(S=>{if(g.has(S.id))return!0;let F=rrt(Zp(S),c,u);return F.end>=l.start&&F.start<=l.end}),[u,c,g,l,f]),b=MP(()=>{let S=n.filter(C=>C.type==="chartShape");if(S.length===0)return new Map;let F=new Map;for(let C of n)C.type==="tableShape"&&F.set(C.id,C.props.table);let w=new Map;for(let C of S){let A=C.type==="chartShape"?C.props.sourceTableShapeId:void 0,T=A?F.get(A):void 0;T&&w.set(C.id,T)}return w},[n]),x=MP(()=>y.filter(S=>m.has(S.id)&&i!==S.id),[m,i,y]),v=MP(()=>y.filter(S=>!m.has(S.id)||i===S.id),[m,i,y]);return{backgroundVisibleShapes:x,chartSourceTables:b,foregroundVisibleShapes:v,selectedIdSet:d}}var KZn=X(()=>{"use strict";"use client";Pn();Dn();Tc();dj()});function mri(e,t,n=3){let r=[new DOMPoint(t.x,t.y)];for(let o=0;o<8&&n>0;o+=1){let i=o*Math.PI/4;r.push(new DOMPoint(t.x+n*Math.cos(i),t.y+n*Math.sin(i)))}for(let o of e.querySelectorAll("path, line, polyline, polygon, circle, ellipse, rect, text")){if(o.closest("defs, clipPath, mask, marker, pattern"))continue;let i=getComputedStyle(o);if(i.display==="none"||i.visibility!=="visible")continue;let a=!1;for(let d=o;d&&d!==e;d=d.parentElement){let p=getComputedStyle(d);if(p.display==="none"||Number(p.opacity)===0){a=!0;break}}if(a)continue;if(o instanceof SVGTextElement){let d=o.getBoundingClientRect();if(t.x>=d.left&&t.x<=d.right&&t.y>=d.top&&t.y<=d.bottom)return!0;continue}if(!(o instanceof SVGGeometryElement))continue;let s=o.getScreenCTM();if(!s||s.a*s.d===s.b*s.c)continue;let l=s.inverse(),c=i.fill!=="none"&&i.fill!=="rgba(0, 0, 0, 0)"&&Number(i.fillOpacity)>0,u=i.stroke!=="none"&&i.stroke!=="rgba(0, 0, 0, 0)"&&Number(i.strokeOpacity)>0&&parseFloat(i.strokeWidth)>0;for(let d of r){let p=d.matrixTransform(l);if(c&&o.isPointInFill(p)||u&&o.isPointInStroke(p))return!0}}return!1}function Sbe(e,t,n){let r=e?.querySelector(`[data-overlay-shape-id="${CSS.escape(t)}"]`);return!r||mri(r,n)}var RTt=X(()=>{"use strict"});function YZn(e,t,n,r){let o;for(let i of e)if(!(!qv(i,t,n)||!r(i))){if(n<=0||qv(i,t,0))return i;o??=i}return o}var $Zn=X(()=>{"use strict";Pn()});var ZZn,JZn=X(()=>{"use strict";ZZn={lockedShapeIds:new Set}});function cze(e){let t=e.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;let n=t.getRangeAt(0).commonAncestorContainer,r=n instanceof Element?n:n.parentElement;return!!(r?.closest(".text-flow-editor")&&!r.closest(".overlay-canvas-bleed-surface"))?t.getRangeAt(0).cloneRange():null}var _Tt=X(()=>{"use strict"});function QZn(e){if(!e)return;let t=e.ownerDocument,n=t.activeElement;n instanceof HTMLElement&&n.classList.contains("ProseMirror")&&!n.closest(".overlay-canvas-bleed-surface")&&n.blur(),cze(t)||t.getSelection()?.removeAllRanges(),t.activeElement!==e&&e.focus({preventScroll:!0})}var eJn=X(()=>{"use strict";_Tt()});import{useEffect as hri,useLayoutEffect as tJn,useRef as OTt,useState as gri}from"react";import{createPortal as yri}from"react-dom";import{jsx as xri}from"react/jsx-runtime";function nJn({anchorRef:e,position:t,className:n,children:r}){let o=OTt(null),[i,a]=gri(null);bri(()=>{let c=e.current;a(c?.closest("[data-modal-backdrop]")??c?.ownerDocument.body??null)},[e]);let s=OTt(null),l=OTt(null);return tJn(()=>{let c=o.current,u=e.current;if(!c||!u)return;let d=u.ownerDocument.defaultView;if(!d)return;let p=()=>{let m=u.getBoundingClientRect(),h=u.offsetWidth>0?m.width/u.offsetWidth:1,g=s.current??{x:m.left+t.x*h,y:m.top+t.y*h};c.style.left=`${Math.max(8,Math.min(g.x,d.innerWidth-c.offsetWidth-8))}px`,c.style.top=`${Math.max(8,Math.min(g.y,d.innerHeight-c.offsetHeight-8))}px`};p();let f=new ResizeObserver(p);return f.observe(c),f.observe(u),d.addEventListener("scroll",p,!0),d.addEventListener("resize",p),d.addEventListener(vR,p),()=>{f.disconnect(),d.removeEventListener("scroll",p,!0),d.removeEventListener("resize",p),d.removeEventListener(vR,p)}},[e,i,t.x,t.y]),i?yri(xri("div",{ref:o,className:n,style:{position:"fixed",zIndex:190},"data-overlay-editor-ui":"true","data-non-modal-surface":"true",onPointerDown:c=>{if(c.stopPropagation(),c.button!==0||!(c.target instanceof Element)||!c.target.closest(".overlay-table-toolbar-grip"))return;c.preventDefault();let u=c.currentTarget.getBoundingClientRect();l.current={pointerId:c.pointerId,x:c.clientX,y:c.clientY,left:u.left,top:u.top},c.currentTarget.setPointerCapture(c.pointerId)},onPointerMove:c=>{let u=l.current;if(!u||u.pointerId!==c.pointerId)return;let d=c.currentTarget,p=d.ownerDocument.defaultView,f=Math.max(8,Math.min(u.left+c.clientX-u.x,p.innerWidth-d.offsetWidth-8)),m=Math.max(8,Math.min(u.top+c.clientY-u.y,p.innerHeight-d.offsetHeight-8));s.current={x:f,y:m},d.style.left=`${f}px`,d.style.top=`${m}px`,c.stopPropagation()},onPointerUp:c=>{l.current?.pointerId===c.pointerId&&(l.current=null,c.currentTarget.releasePointerCapture(c.pointerId),c.stopPropagation())},onLostPointerCapture:()=>{l.current=null},onPointerCancel:()=>{l.current=null},onClick:c=>c.stopPropagation(),onDoubleClick:c=>c.stopPropagation(),onContextMenu:c=>{c.preventDefault(),c.stopPropagation()},children:r}),i):null}var bri,rJn=X(()=>{"use strict";"use client";s8e();bri=typeof window<"u"?tJn:hri});function aJn(e,t){return!wbe(e,t.anchor.rowIndex,t.anchor.columnIndex)||!wbe(e,t.focus.rowIndex,t.focus.columnIndex)?null:NTt(t)}function NTt(e){return{startRow:Math.min(e.anchor.rowIndex,e.focus.rowIndex),endRow:Math.max(e.anchor.rowIndex,e.focus.rowIndex),startColumn:Math.min(e.anchor.columnIndex,e.focus.columnIndex),endColumn:Math.max(e.anchor.columnIndex,e.focus.columnIndex)}}function sJn(e){return{anchor:{rowIndex:e.startRow,columnIndex:e.startColumn},focus:{rowIndex:e.endRow,columnIndex:e.endColumn}}}function lJn(e,t){return t.rowIndex>=e.startRow&&t.rowIndex<=e.endRow&&t.columnIndex>=e.startColumn&&t.columnIndex<=e.endColumn}function zTt(e,t,n,r=1,o=1){let i=t+Math.max(1,r)-1,a=n+Math.max(1,o)-1;return t<=e.endRow&&i>=e.startRow&&n<=e.endColumn&&a>=e.startColumn}function cJn(e,t,n,r,o=1,i=1){return t==="rows"?n<=e.endRow&&n+Math.max(1,o)-1>=e.startRow:r<=e.endColumn&&r+Math.max(1,i)-1>=e.startColumn}function UTt(e,t){let n=sne(t.startRow,e.rows.length),r=sne(t.endRow,e.rows.length);return e.rows.slice(n,r+1).map(o=>o.id)}function HTt(e,t){let n=sne(t.startColumn,e.columns.length),r=sne(t.endColumn,e.columns.length);return e.columns.slice(n,r+1).map(o=>o.id)}function GTt(e,t){if(e.rows.length===0||e.columns.length===0)return null;let n={rowIndex:sne(t.startRow,e.rows.length),columnIndex:sne(t.startColumn,e.columns.length)};return{anchor:n,focus:n}}function uJn(e,t,n){for(let r of e?.querySelectorAll("[data-table-content-id]")??[]){let o=r.getBoundingClientRect();if(t>=o.left&&t<=o.right&&n>=o.top&&n<=o.bottom)return r.dataset.tableContentId??null}return null}function dJn(e,t,n,r,o,i,a){let s=e?.getBoundingClientRect();if(!s||s.width<=0||s.height<=0||r.length<2||o.length<2)return null;let l=r[r.length-1]||t,c=o[o.length-1]||n,u=s.width/Math.max(1,t),d=s.height/Math.max(1,n),p=Yo((i-s.left)/Math.max(.01,u),0,Math.max(0,l-.001)),f=Yo((a-s.top)/Math.max(.01,d),0,Math.max(0,c-.001));return{rowIndex:oJn(o,f),columnIndex:oJn(r,p)}}function oJn(e,t){for(let n=0;n<e.length-1;n+=1)if(t<e[n+1]||n===e.length-2)return n;return 0}function sne(e,t){return t<=0?0:Math.trunc(Yo(e,0,t-1))}function uze(e,t){return`${e}:${t}`}function pJn(e){return e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.isComposing?null:e.key==="ArrowLeft"?"left":e.key==="ArrowRight"?"right":e.key==="ArrowUp"?"up":e.key==="ArrowDown"?"down":null}function fJn(e,t){let{selection:n}=e.state;if(!n.empty)return!1;if(t==="left"){let r=iJn(e,"left");return r!==null?r:n.$from.parentOffset<=0}if(t==="right"){let r=iJn(e,"right");return r!==null?r:n.$to.parentOffset>=n.$to.parent.content.size}return vri(e,t)}function iJn(e,t){let n=e.dom.ownerDocument.getSelection();if(!n||!n.isCollapsed||!n.anchorNode||!e.dom.contains(n.anchorNode))return null;let{anchorNode:r,anchorOffset:o}=n;if(e.posAtDOM)try{let i=e.posAtDOM(r,o),a=1,s=Math.max(a,e.state.doc.content.size-1);return t==="left"?i<=a:i>=s}catch{}if(r.nodeType===Node.TEXT_NODE){let i=r.textContent?.length??0;return t==="left"?o<=0:o>=i}return t==="left"?o<=0:o>=r.childNodes.length}function vri(e,t){let{selection:n}=e.state;try{let r=e.coordsAtPos(n.from),o=e.dom.getBoundingClientRect(),i=Math.max(1,r.bottom-r.top),a=Math.max(4,i*.45);return t==="up"?r.top<=o.top+a:r.bottom>=o.bottom-a}catch{let r=Math.max(1,e.state.doc.content.size-1);return t==="up"?n.from<=1:n.to>=r}}function jTt(e,t,n){return n==="left"?{rowIndex:e,columnIndex:t-1}:n==="right"?{rowIndex:e,columnIndex:t+1}:n==="up"?{rowIndex:e-1,columnIndex:t}:{rowIndex:e+1,columnIndex:t}}function VTt(e){return e==="left"||e==="up"?"end":"start"}function XTt(e,t){let n=t==="end"?Math.max(1,e.state.doc.content.size-1):1;e.chain().focus().setTextSelection(n).run()}function wbe(e,t,n){return t>=0&&t<e.rows.length&&n>=0&&n<e.columns.length}function dze(e,t,n){return wbe(e,t,n)?e.cells.find(r=>{let o=e.rows.findIndex(l=>l.id===r.rowId),i=e.columns.findIndex(l=>l.id===r.columnId);if(o<0||i<0)return!1;let a=r.rowSpan??1,s=r.colSpan??1;return t>=o&&t<o+a&&n>=i&&n<i+s})??null:null}function Fbe(e){return e.content.find(t=>t.type==="paragraph")??null}function WTt(e,t){return Kg(e)===Kg(t)}function qTt(e,t,n){if(t.axis==="vertical"){if("edge"in t)return t.edge==="left"?n("table.line.edgeLeft"):n("table.line.edgeRight");let o=e.columns.findIndex(i=>i.id===t.beforeColumnId);return o>0?n("table.line.betweenColumns",{first:o,second:o+1}):n("table.line.vertical")}if("edge"in t)return t.edge==="top"?n("table.line.edgeTop"):n("table.line.edgeBottom");let r=e.rows.findIndex(o=>o.id===t.beforeRowId);return r>0?n("table.line.betweenRows",{first:r,second:r+1}):n("table.line.horizontal")}function mJn(e){return[...Array.from({length:e.columns.length+1},(t,n)=>lx(e,n)).filter(t=>!!t),...Array.from({length:e.rows.length+1},(t,n)=>cx(e,n)).filter(t=>!!t)]}function hJn(e){return[lx(e,0),lx(e,e.columns.length),cx(e,0),cx(e,e.rows.length)].filter(t=>!!t)}function gJn(e){return[...Array.from({length:Math.max(0,e.columns.length-1)},(t,n)=>lx(e,n+1)).filter(t=>!!t),...Array.from({length:Math.max(0,e.rows.length-1)},(t,n)=>cx(e,n+1)).filter(t=>!!t)]}function pze(e,t,n){let r=e.rows.findIndex(i=>i.id===t.rowId),o=e.columns.findIndex(i=>i.id===t.columnId);return r<0||o<0?!1:zTt(n,r,o,t.rowSpan??1,t.colSpan??1)}function Cbe(e,t){return Array.from({length:Math.max(0,t-e+1)},(n,r)=>e+r)}function KTt(e){return{mode:"fixed",value:Math.max(1,e)}}function YTt(e,t){return e.mode==="fixed"?e.value:(e.mode==="auto",e.min??t)}function $Tt(e){return Math.max(0,e)*Id}function ZTt(e){return e/Id}function JTt(e){return Number.isFinite(e)?String(Math.round(e*10)/10):""}function QTt(e){return Math.max(1,e.reduce((t,n)=>t+Math.max(1,n),0))}function Abe(e){if(e.length===0)return null;let t=e[0];return e.every(n=>n===t)?t:null}function fze(e){let t=e.filter(n=>Number.isFinite(n)).map(n=>Math.round(n*10)/10);return Abe(t)}function eDt(e,t,n){return{...e,cells:e.cells.map(r=>pze(e,r,t)?{...r,style:{...r.style??{},...n},content:n.align===void 0?r.content:r.content.map(o=>o.type==="paragraph"?{...o,align:n.align}:o)}:r)}}function yJn({mode:e,cellRange:t,line:n,table:r,columnOffsets:o,rowOffsets:i,shapeWidth:a,shapeHeight:s}){if(e==="cell"&&t){let l=o[t.startColumn]??0,c=i[t.startRow]??0,u=(i[t.endRow+1]??c)+8;return{x:Yo(l,-8,Math.max(0,a-48)),y:Yo(c-44<-50?u:c-44,-50,Math.max(0,s-28))}}if(e==="line"&&n){let l=Sri(r,n,o,i);return{x:Yo(l.x,-8,Math.max(0,a-48)),y:Yo(l.y,-50,Math.max(0,s-28))}}return{x:0,y:-44}}function Sri(e,t,n,r){if(t.axis==="vertical"){let i="edge"in t?t.edge==="left"?0:e.columns.length:e.columns.findIndex(a=>a.id===t.beforeColumnId);return{x:n[i]??0,y:-44}}let o="edge"in t?t.edge==="top"?0:e.rows.length:e.rows.findIndex(i=>i.id===t.beforeRowId);return{x:8,y:(r[o]??0)-44}}var tDt=X(()=>{"use strict";Dt();jh();m_();Dn();Dn()});import{useEffect as mze,useMemo as wri,useRef as Fri}from"react";import{jsx as BP}from"react/jsx-runtime";function bJn({shapeId:e,cell:t,cellId:n,content:r,editing:o,showFormulaSource:i,table:a,rowIndex:s,columnIndex:l,colSpan:c,onFocus:u,onChange:d,onNavigate:p,onRegisterEditor:f}){return r.type==="trend"?BP(f8e,{colSpan:c,content:r}):!o||!i&&D5(a,t,r)!==null?BP(Cri,{cell:t,content:r,table:a}):BP(Ari,{shapeId:e,cellId:n,content:r,editing:o,rowIndex:s,columnIndex:l,onFocus:u,onChange:d,onNavigate:p,onRegisterEditor:f})}function Cri({cell:e,content:t,table:n}){return BP("div",{className:"overlay-table-paragraph","data-table-content-id":t.id,style:{pointerEvents:"none"},children:BP("div",{className:"overlay-table-shape-content ProseMirror",children:BP("p",{style:cDe(t),children:Tri(m9(n,e,t))})})})}function Ari({shapeId:e,cellId:t,content:n,editing:r,rowIndex:o,columnIndex:i,onFocus:a,onChange:s,onNavigate:l,onRegisterEditor:c}){let u=wri(()=>v2(n.children,n.align,n.lineHeight),[n.align,n.children,n.lineHeight]),d=Fri(u),p=ww({extensions:Vk({drawBoxedRunFrames:!1,enableMathDelimiters:!0,heading:!1,placeholder:"",textBlockStyle:!0}),content:u,editable:r,immediatelyRender:!1,editorProps:{attributes:{class:"overlay-table-shape-content"},handlePaste:(m,h,g)=>$8(m,h,g)},onFocus:({editor:m})=>{a(m,e,t),$w(m,"sigma-studio:text-format-state","overlay",void 0,{state:m.state,view:m.view,documentFontFamily:nx})},onTransaction:({editor:m})=>{m.isFocused&&$w(m,"sigma-studio:text-format-state","overlay",void 0,{state:m.state,view:m.view,documentFontFamily:nx})},onUpdate:({editor:m})=>{let h=m.getJSON();d.current=h,s(t,n.id,{...n,align:m.getAttributes("paragraph").textAlign??n.align,lineHeight:gi(m.getAttributes("paragraph").lineHeight)??n.lineHeight,children:V8(h)})}});mze(()=>{p?.setEditable(r)},[r,p]),mze(()=>{if(p)return c(t,n.id,p)},[t,n.id,p,c]),mze(()=>{if(!p||p.isDestroyed)return;let m=n.align??null,h=gi(n.lineHeight)??null,g=p.getAttributes("paragraph");if(g.textAlign===m&&g.lineHeight===h)return;let y=p.state.tr;p.state.doc.forEach((b,x)=>{b.type.name==="paragraph"&&y.setNodeMarkup(x,void 0,{...b.attrs,textAlign:m,lineHeight:h})}),p.view.dispatch(y.setMeta("preventUpdate",!0).setMeta("addToHistory",!1)),d.current=p.getJSON()},[n.align,n.lineHeight,p]),mze(()=>{if(!p||p.isFocused)return;let m=v2(n.children,n.align,n.lineHeight),h=JSON.stringify(d.current),g=JSON.stringify(m);if(h!==g){d.current=m;let y=window.setTimeout(()=>{!p.isDestroyed&&!p.isFocused&&p.commands.setContent(m,{emitUpdate:!1})},0);return()=>window.clearTimeout(y)}},[n.align,n.children,n.lineHeight,p]);let f=m=>{if(!p)return;let h=pJn(m.nativeEvent);!h||!fJn(p.view,h)||l(o,i,h)&&(m.preventDefault(),m.stopPropagation())};return BP("div",{className:"overlay-table-paragraph","data-table-content-id":n.id,style:{pointerEvents:r?"auto":"none"},onKeyDownCapture:f,onPointerDown:m=>{r&&m.stopPropagation()},children:BP(o2,{editor:p})})}function Tri(e){return BP(wJ,{nodes:e,keyPrefix:"sigma-inline-preview"})}var xJn=X(()=>{"use strict";"use client";rU();Ys();TH();ree();jk();Dt();Dn();H0();tDt()});import{jsx as vJn,jsxs as Dri}from"react/jsx-runtime";function SJn({table:e,columnOffsets:t,rowOffsets:n}){return Dri("div",{className:"overlay-table-rendered-lines","aria-hidden":"true",children:[Hle(e,t,n).map(r=>vJn("div",{className:`overlay-table-rendered-line ${r.axis}`,style:r.style},`rendered-${r.axis}-${r.domKey}`)),Gle(e,t,n).map(r=>vJn("div",{className:`overlay-table-line-connector ${r.axis}`,style:r.style},r.id))]})}var wJn=X(()=>{"use strict";Dn()});import{useCallback as lne,useEffect as Tbe,useMemo as Dbe,useRef as O_,useState as PA}from"react";import{createPortal as kri}from"react-dom";import{Fragment as hze,jsx as ba,jsxs as MA}from"react/jsx-runtime";function Iri(e,t){if(!t)return null;let n=Fbe(t);return n?D5(e,t,n)?.error??null:null}function Mri(e){return[{value:"none",label:e("format.lineDash.none"),hidden:!0},{value:"solid",label:e("format.lineDash.solid")},{value:"dashed",label:e("format.lineDash.dashed"),dasharray:"8 5"},{value:"dotted",label:e("format.lineDash.dotted"),dasharray:"1 5"},{value:"double",label:e("format.lineDash.double"),double:!0}]}function Bri(e){return[{value:"left",label:e("format.align.left"),icon:E0},{value:"center",label:e("format.align.center"),icon:wx},{value:"right",label:e("format.align.right"),icon:Fx}]}function Lri(e){if(e===null)return null;let t="m",n=Number.POSITIVE_INFINITY;for(let r of fNe){let o=Math.abs(FJn[r.value]-e);o<n&&(n=o,t=r.value)}return t}function kbe({shape:e,editing:t,onFocus:n,onChange:r,onResize:o,onCreateChart:i,onFirstCellReady:a}){let s=We("chrome"),l=We("settings"),c=We("shape"),u=e.props.table,d=O_(null),p=Math.max(1,e.props.w),f=Dbe(()=>aDe(u,p),[p,u]),m=Dbe(()=>sDe(u,e.props.h),[e.props.h,u]),h=Dbe(()=>MK(f),[f]),g=Dbe(()=>MK(m),[m]),[y,b]=PA(null),[x,v]=PA([]),[S,F]=PA(null),[w,C]=PA(null),[A,T]=PA(null),[D,k]=PA(null),[P,I]=PA(!1),[B,M]=PA(!1),[L,_]=PA(!1),R=O_(null),O=O_(null),N=O_(null),[z,U]=PA(()=>new Set),H=O_(new Map),V=O_(new Map),[ne,Z]=PA(null),ee=O_(null),J=Dbe(()=>t?x.filter(mt=>lDe(u,mt)):[],[t,x,u]),te=J[0]??null,K=t&&S?aJn(u,S):null,G=J.length>0?"line":K?"cell":null,ie=J.map(mt=>Vv(u,mt)),{origins:fe}=A5(u),$=O_(t);Tbe(()=>{let mt=t&&!$.current;$.current=t,!(!mt||u.rows.length===0||u.columns.length===0)&&(Z(null),ee.current=null,F({anchor:{rowIndex:0,columnIndex:0},focus:{rowIndex:u.rows.length-1,columnIndex:u.columns.length-1}}))},[t,u.columns.length,u.rows.length]);let j=dze(u,0,0),pe=j?Fbe(j):null,re=lne((mt,_t,Gt)=>{let cn=uze(mt,_t);V.current.set(cn,Gt),mt===j?.id&&_t===pe?.id&&a?.(Gt,e.id);let an=ee.current;if(an&&an.cellId===mt&&an.contentId===_t&&(ee.current=null,XTt(Gt,an.placement),an.clientPoint&&!Gt.isDestroyed)){let xr=Gt.view.posAtCoords(an.clientPoint);xr&&Gt.commands.setTextSelection(xr.pos)}return()=>{V.current.get(cn)===Gt&&V.current.delete(cn)}},[j?.id,pe?.id,a,e.id]),le=lne((mt,_t,Gt)=>{let cn=jTt(mt,_t,Gt);for(;wbe(u,cn.rowIndex,cn.columnIndex);){let an=dze(u,cn.rowIndex,cn.columnIndex),xr=an?Fbe(an):null,xt=an&&xr?V.current.get(uze(an.id,xr.id)):null;if(xt&&!xt.isDestroyed)return Z(an?.id??null),XTt(xt,VTt(Gt)),!0;if(an&&xr)return ee.current={cellId:an.id,contentId:xr.id,placement:VTt(Gt)},Z(an.id),!0;cn=jTt(cn.rowIndex,cn.columnIndex,Gt)}return!1},[u]),Q=(mt,_t,Gt)=>{r(e.id,{...u,cells:u.cells.map(cn=>cn.id!==mt?cn:{...cn,content:cn.content.map(an=>an.id===_t?Gt:an)})})},se=(mt,_t)=>{F(null),xe(),v(Gt=>{if(!_t)return[mt];let cn=Kg(mt);return Gt.some(an=>Kg(an)===cn)?Gt.filter(an=>Kg(an)!==cn):[...Gt,mt]})},De=mt=>{if(J.length===0)return;let _t=J.reduce((Gt,cn)=>dXn(Gt,cn,mt),u);r(e.id,_t)},Ae=mt=>{if(!K)return;let _t=$Tt(mt),Gt=new Set(Cbe(K.startColumn,K.endColumn)),cn=u.columns.map((xt,Kn)=>Gt.has(Kn)?{...xt,width:KTt(_t)}:xt),an={...u,columns:cn},xr=cn.map((xt,Kn)=>YTt(xt.width,f[Kn]??kye));o(e.id,{w:QTt(xr),h:e.props.h,table:an})},ye=mt=>{if(!K)return;let _t=$Tt(mt),Gt=new Set(Cbe(K.startRow,K.endRow)),cn=u.rows.map((xt,Kn)=>Gt.has(Kn)?{...xt,height:KTt(_t)}:xt),an={...u,rows:cn},xr=cn.map((xt,Kn)=>YTt(xt.height,m[Kn]??Eye));o(e.id,{w:e.props.w,h:QTt(xr),table:an})},$e=mt=>{K&&r(e.id,eDt(u,K,{align:mt}))},Pe=mt=>{!K||!Number.isFinite(mt)||mt<=0||r(e.id,eDt(u,K,{fontSize:mt}))},Ne=mt=>{if(!A)return;let _t=mt==="left"?A.range.startColumn:A.range.endColumn+1;r(e.id,TCt(u,_t)),xe()},we=mt=>{if(!A)return;let _t=mt==="above"?A.range.startRow:A.range.endRow+1;r(e.id,DCt(u,_t)),xe()},Ie=mt=>{let _t=mt==="all"?mJn(u):mt==="outer"?hJn(u):gJn(u);F(null),v(_t),xe()},Ce=(mt,_t,Gt)=>{v([]),Z(Gt),n(mt,_t)},xe=()=>{T(null),k(null)},Y=(mt,_t,Gt)=>{if(!t||mt.button!==0)return;let cn={rowIndex:_t,columnIndex:Gt},an=dze(u,_t,Gt),xr=uJn(mt.currentTarget,mt.clientX,mt.clientY),xt=an?.content.find(to=>to.id===xr),Kn=xt?.type==="paragraph"?xt:an?Fbe(an):null;Z(an?.id??null);let Zn=an&&Kn?V.current.get(uze(an.id,Kn.id)):null;an&&Kn&&(!Zn||Zn.isDestroyed)&&(ee.current={cellId:an.id,contentId:Kn.id,placement:"end",...D5(u,an,Kn)?{}:{clientPoint:{left:mt.clientX,top:mt.clientY}}}),v([]),xe(),F({anchor:cn,focus:cn}),C({anchor:cn,startClientX:mt.clientX,startClientY:mt.clientY,active:!1})},oe=(mt,_t,Gt)=>{if(!t)return;mt.preventDefault(),mt.stopPropagation();let cn={rowIndex:_t,columnIndex:Gt},an=K&&lJn(K,cn)?K:NTt({anchor:cn,focus:cn});v([]),F(sJn(an)),T({x:Yo(mt.clientX,8,Math.max(8,window.innerWidth-188)),y:Yo(mt.clientY,8,Math.max(8,window.innerHeight-104)),range:an}),k(null)},de=()=>{if(!A)return;let mt=UTt(u,A.range);if(mt.length===0||mt.length>=u.rows.length)return;let _t=yXn(u,mt);r(e.id,_t),F(GTt(_t,A.range)),xe()},Le=()=>{if(!A)return;let mt=HTt(u,A.range);if(mt.length===0||mt.length>=u.columns.length)return;let _t=gXn(u,mt);r(e.id,_t),F(GTt(_t,A.range)),xe()},be=lne(()=>{let mt=d.current?.getBoundingClientRect();return!mt||mt.width<=0?1:mt.width/p},[p]),Be=(mt,_t)=>{mt.preventDefault(),mt.stopPropagation(),b({type:"columnBoundary",boundaryIndex:_t,startClientX:mt.clientX,leftWidth:f[_t],rightWidth:f[_t+1]})},ce=(mt,_t)=>{let Gt=_t==="left"?0:u.columns.length-1;Gt<0||(mt.preventDefault(),mt.stopPropagation(),b({type:"columnEdge",edge:_t,startClientX:mt.clientX,startShapeX:e.x,startShapeW:e.props.w,edgeWidth:f[Gt]??pj}))},Re=(mt,_t)=>{mt.preventDefault(),mt.stopPropagation(),b({type:"rowBoundary",boundaryIndex:_t,startClientY:mt.clientY,topHeight:m[_t],bottomHeight:m[_t+1]})},Qe=(mt,_t)=>{let Gt=_t==="top"?0:u.rows.length-1;Gt<0||(mt.preventDefault(),mt.stopPropagation(),b({type:"rowEdge",edge:_t,startClientY:mt.clientY,startShapeY:e.y,startShapeH:e.props.h,edgeHeight:m[Gt]??fj}))},W=lne(mt=>{if(mt===void 0){for(let Gt of H.current.values())window.clearTimeout(Gt);H.current.clear();return}let _t=H.current.get(mt);_t!==void 0&&(window.clearTimeout(_t),H.current.delete(mt))},[]),ve=lne(mt=>{W(mt),U(_t=>{if(_t.has(mt))return _t;let Gt=new Set(_t);return Gt.add(mt),Gt})},[W]),_e=lne(mt=>{W(mt);let _t=window.setTimeout(()=>{H.current.delete(mt),U(Gt=>{if(!Gt.has(mt))return Gt;let cn=new Set(Gt);return cn.delete(mt),cn})},Pri);H.current.set(mt,_t)},[W]);Tbe(()=>W,[W]),Tbe(()=>{if(!w)return;let mt=Gt=>{let cn=dJn(d.current,p,e.props.h,h,g,Gt.clientX,Gt.clientY);!cn||!(w.active||Math.hypot(Gt.clientX-w.startClientX,Gt.clientY-w.startClientY)>=3)||(Gt.preventDefault(),d.current?.ownerDocument.getSelection()?.removeAllRanges(),w.active||(C({...w,active:!0}),Z(null),ee.current=null),F(xr=>xr&&xr.anchor.rowIndex===w.anchor.rowIndex&&xr.anchor.columnIndex===w.anchor.columnIndex&&xr.focus.rowIndex===cn.rowIndex&&xr.focus.columnIndex===cn.columnIndex?xr:{anchor:w.anchor,focus:cn}))},_t=()=>{C(null)};return window.addEventListener("pointermove",mt),window.addEventListener("pointerup",_t,{once:!0}),()=>{window.removeEventListener("pointermove",mt),window.removeEventListener("pointerup",_t)}},[w,h,g,e.props.h,p]),Tbe(()=>{if(!A)return;let mt=Gt=>{(Gt.target instanceof Element?Gt.target:null)?.closest(".overlay-table-context-menu")||(T(null),k(null))},_t=Gt=>{Gt.key==="Escape"&&(Gt.preventDefault(),T(null),k(null))};return window.addEventListener("pointerdown",mt,!0),window.addEventListener("keydown",_t),()=>{window.removeEventListener("pointerdown",mt,!0),window.removeEventListener("keydown",_t)}},[A]),Tbe(()=>{if(!y)return;let mt=Gt=>{let cn=Math.max(.01,be());if(y.type==="columnBoundary"){let Zn=(Gt.clientX-y.startClientX)/cn,to=Yo(Zn,pj-y.leftWidth,y.rightWidth-pj);r(e.id,pXn(u,y.boundaryIndex,y.leftWidth+to,y.rightWidth-to));return}if(y.type==="columnEdge"){let Zn=y.edge==="left"?(y.startClientX-Gt.clientX)/cn:(Gt.clientX-y.startClientX)/cn,to=Math.max(pj-y.edgeWidth,Zn),Qa=y.edgeWidth+to,ma=Math.max(pj,y.startShapeW+to);o(e.id,{x:y.edge==="left"?y.startShapeX-to:void 0,w:ma,h:e.props.h,table:fXn(u,y.edge,Qa)});return}if(y.type==="rowBoundary"){let Zn=(Gt.clientY-y.startClientY)/cn,to=Yo(Zn,fj-y.topHeight,y.bottomHeight-fj);r(e.id,mXn(u,y.boundaryIndex,y.topHeight+to,y.bottomHeight-to));return}let an=y.edge==="top"?(y.startClientY-Gt.clientY)/cn:(Gt.clientY-y.startClientY)/cn,xr=Math.max(fj-y.edgeHeight,an),xt=y.edgeHeight+xr,Kn=Math.max(fj,y.startShapeH+xr);o(e.id,{y:y.edge==="top"?y.startShapeY-xr:void 0,w:e.props.w,h:Kn,table:hXn(u,y.edge,xt)})},_t=()=>{b(null)};return window.addEventListener("pointermove",mt),window.addEventListener("pointerup",_t,{once:!0}),()=>{window.removeEventListener("pointermove",mt),window.removeEventListener("pointerup",_t)}},[be,r,o,y,e.id,e.props.h,e.props.w,u]);let he=t?A:null,Oe=t?D:null,qe=he?UTt(u,he.range):[],Ze=he?HTt(u,he.range):[],vt=qe.length>0&&qe.length<u.rows.length,Ft=Ze.length>0&&Ze.length<u.columns.length,gt=Abe(ie.map(mt=>mt.visible?mt.borderStyle:"none")),bt=Abe(ie.map(mt=>mt.borderWidth)),ct=Lri(bt),ft=K?Cbe(K.startColumn,K.endColumn):[],hn=K?Cbe(K.startRow,K.endRow):[],Kt=fze(ft.map(mt=>ZTt(f[mt]??0))),xo=fze(hn.map(mt=>ZTt(m[mt]??0))),Bo=K,fo=Bo?Abe(u.cells.filter(mt=>pze(u,mt,Bo)).flatMap(mt=>{let _t=mt.style?.align??u.defaultCellStyle.align??"center",Gt=mt.content.filter(cn=>cn.type==="paragraph");return Gt.length>0?Gt.map(cn=>cn.align??_t):[_t]})):null,Sr=Bo?fze(u.cells.filter(mt=>pze(u,mt,Bo)).map(mt=>mt.style?.fontSize??u.defaultCellStyle.fontSize??15)):null,oa=G?yJn({mode:G,cellRange:K,line:te,table:u,columnOffsets:h,rowOffsets:g,shapeWidth:e.props.w,shapeHeight:e.props.h}):null;return MA("div",{className:`overlay-table-shape ${t?"editing":""}`,style:{width:e.props.w,height:e.props.h},onContextMenu:mt=>{if(!t)return;let _t=mt.target instanceof Element?mt.target:null;if(_t?.closest(".overlay-table-context-menu, .overlay-table-floating-toolbar"))return;let Gt=!!(K&&K.startRow===0&&K.endRow===u.rows.length-1&&K.startColumn===0&&K.endColumn===u.columns.length-1);_t?.closest("td")&&!Gt||(mt.preventDefault(),mt.stopPropagation(),T({x:Yo(mt.clientX,8,Math.max(8,window.innerWidth-220)),y:Yo(mt.clientY,8,Math.max(8,window.innerHeight-220)),range:{startRow:0,endRow:Math.max(0,u.rows.length-1),startColumn:0,endColumn:Math.max(0,u.columns.length-1)}}))},children:[t&&MA(hze,{children:[oa&&MA(nJn,{className:`overlay-table-floating-toolbar ${G}`,anchorRef:d,position:oa,children:[ba("button",{type:"button",className:"overlay-table-toolbar-grip","aria-label":c("table.moveMenu"),title:c("table.moveMenu"),children:ba(n4,{size:14})}),G==="line"?MA(hze,{children:[ba(aF,{buttonRef:R,options:Mri(s),currentValue:gt,open:P,onToggle:()=>{M(!1),I(mt=>!mt)},onSelect:mt=>{if(mt==="none"){De({visible:!1}),I(!1);return}De({borderStyle:mt,visible:!0,...mt==="double"&&(bt??0)<3?{borderWidth:3}:{}}),I(!1)}}),ba(eE,{buttonRef:O,currentValue:ct,open:B,onToggle:()=>{I(!1),M(mt=>!mt)},onSelect:mt=>{De({borderWidth:FJn[mt],visible:!0}),M(!1)}})]}):MA(hze,{children:[MA("label",{className:"overlay-table-toolbar-number",children:[ba(gue,{size:14,"aria-label":c("table.columnWidth")}),ba("input",{type:"number",min:"0",step:"1",placeholder:c("table.mixed"),value:Kt===null?"":JTt(Kt),onChange:mt=>{let _t=Number.parseFloat(mt.target.value);Number.isFinite(_t)&&Ae(_t)}}),ba("span",{children:"mm"})]}),MA("label",{className:"overlay-table-toolbar-number",children:[ba(yue,{size:14,"aria-label":c("table.rowHeight")}),ba("input",{type:"number",min:"0",step:"1",placeholder:c("table.mixed"),value:xo===null?"":JTt(xo),onChange:mt=>{let _t=Number.parseFloat(mt.target.value);Number.isFinite(_t)&&ye(_t)}}),ba("span",{children:"mm"})]}),MA("label",{className:"overlay-table-toolbar-number",children:[ba(I0,{size:14,"aria-label":c("table.fontSize")}),ba("input",{type:"number",min:"1",step:"0.5","aria-label":c("table.fontSizeAria"),placeholder:c("table.mixed"),value:Sr===null?"":Sr,onChange:mt=>{let _t=Number.parseFloat(mt.target.value);Number.isFinite(_t)&&Pe(_t)}}),ba("span",{children:"pt"})]}),ba(AVn,{buttonRef:N,options:Bri(s),currentValue:fo,open:L,onToggle:()=>_(mt=>!mt),onSelect:mt=>{$e(mt),_(!1)}})]})]}),ba("div",{className:"overlay-table-column-controls","aria-hidden":!1,children:h.map((mt,_t)=>{let Gt=lx(u,_t);if(!Gt)return null;let cn=Kg(Gt),an=_t>0&&_t<u.columns.length,xr=_t===0?"left":_t===u.columns.length?"right":null,xt=J.some(Zn=>WTt(Zn,Gt)),Kn=z.has(cn);return ba("div",{role:"button",tabIndex:0,className:["overlay-table-boundary-hotspot","column","resizable",xt?"selected":"",Kn?"add-visible":""].filter(Boolean).join(" "),style:{left:mt},"aria-label":qTt(u,Gt,l),"data-testid":"overlay-table-column-boundary",onPointerEnter:()=>ve(cn),onPointerLeave:()=>_e(cn),onPointerDown:Zn=>{if(Zn.button===0){if(Zn.stopPropagation(),se(Gt,Zn.shiftKey),Zn.shiftKey){Zn.preventDefault();return}if(an){Be(Zn,_t-1);return}xr&&ce(Zn,xr)}},onKeyDown:Zn=>{(Zn.key==="Enter"||Zn.key===" ")&&(Zn.preventDefault(),se(Gt,Zn.shiftKey))},children:ba("button",{type:"button",className:"overlay-table-add-control column","aria-label":c("table.addColumnAt",{index:_t+1}),onPointerDown:Zn=>Zn.stopPropagation(),onClick:Zn=>{Zn.stopPropagation(),r(e.id,TCt(u,_t))},children:ba(zi,{size:11,strokeWidth:2.4})})},`column-boundary-${cn}`)})}),ba("div",{className:"overlay-table-row-controls","aria-hidden":!1,children:g.map((mt,_t)=>{let Gt=cx(u,_t);if(!Gt)return null;let cn=Kg(Gt),an=_t>0&&_t<u.rows.length,xr=_t===0?"top":_t===u.rows.length?"bottom":null,xt=J.some(Zn=>WTt(Zn,Gt)),Kn=z.has(cn);return ba("div",{role:"button",tabIndex:0,className:["overlay-table-boundary-hotspot","row","resizable",xt?"selected":"",Kn?"add-visible":""].filter(Boolean).join(" "),style:{top:mt},"aria-label":qTt(u,Gt,l),"data-testid":"overlay-table-row-boundary",onPointerEnter:()=>ve(cn),onPointerLeave:()=>_e(cn),onPointerDown:Zn=>{if(Zn.button===0){if(Zn.stopPropagation(),se(Gt,Zn.shiftKey),Zn.shiftKey){Zn.preventDefault();return}if(an){Re(Zn,_t-1);return}xr&&Qe(Zn,xr)}},onKeyDown:Zn=>{(Zn.key==="Enter"||Zn.key===" ")&&(Zn.preventDefault(),se(Gt,Zn.shiftKey))},children:ba("button",{type:"button",className:"overlay-table-add-control row","aria-label":c("table.addRowAt",{index:_t+1}),onPointerDown:Zn=>Zn.stopPropagation(),onClick:Zn=>{Zn.stopPropagation(),r(e.id,DCt(u,_t))},children:ba(zi,{size:11,strokeWidth:2.4})})},`row-boundary-${cn}`)})})]}),he&&typeof document<"u"&&kri(MA("div",{className:"overlay-table-context-menu",role:"menu",style:{left:he.x,top:he.y},onPointerDown:mt=>mt.stopPropagation(),onContextMenu:mt=>mt.preventDefault(),children:[ba("button",{type:"button",role:"menuitem",onClick:()=>Ne("left"),children:c("table.addColumnLeft")}),ba("button",{type:"button",role:"menuitem",onClick:()=>Ne("right"),children:c("table.addColumnRight")}),ba("button",{type:"button",role:"menuitem",onClick:()=>we("above"),children:c("table.addRowAbove")}),ba("button",{type:"button",role:"menuitem",onClick:()=>we("below"),children:c("table.addRowBelow")}),ba("button",{type:"button",role:"menuitem",className:"danger",disabled:!vt,onPointerEnter:()=>k("rows"),onPointerLeave:()=>k(null),onFocus:()=>k("rows"),onBlur:()=>k(null),onClick:de,children:c("table.deleteRows")}),ba("button",{type:"button",role:"menuitem",className:"danger",disabled:!Ft,onPointerEnter:()=>k("columns"),onPointerLeave:()=>k(null),onFocus:()=>k("columns"),onBlur:()=>k(null),onClick:Le,children:c("table.deleteColumns")}),i&&MA(hze,{children:[ba("div",{className:"overlay-table-context-menu-separator",role:"separator"}),ba("button",{type:"button",role:"menuitem",onClick:()=>{T(null),i(e.id)},children:c("table.createChart")})]}),ba("div",{className:"overlay-table-context-menu-separator",role:"separator"}),ba("button",{type:"button",role:"menuitem",onClick:()=>Ie("all"),children:c("table.selectAllLines")}),ba("button",{type:"button",role:"menuitem",onClick:()=>Ie("outer"),children:c("table.selectOuterLines")}),ba("button",{type:"button",role:"menuitem",onClick:()=>Ie("inner"),children:c("table.selectInnerLines")})]}),document.body),MA("table",{ref:d,className:"overlay-table-shape-table",style:{width:p,height:e.props.h,tableLayout:"fixed",border:0},children:[ba("colgroup",{children:u.columns.map((mt,_t)=>ba("col",{style:{width:f[_t]}},mt.id))}),ba("tbody",{children:u.rows.map((mt,_t)=>ba("tr",{style:{height:m[_t]},children:fe[_t].map(({cell:Gt,columnIndex:cn,rowSpan:an,colSpan:xr})=>{let xt=u.columns[cn],Kn=K?zTt(K,_t,cn,an,xr):!1,Zn=he&&Oe?cJn(he.range,Oe,_t,cn,an,xr):!1,to=zle(u,Gt,_t,cn,an,xr),Qa=Ule(u,Gt),ma=Iri(u,Gt),Jl=ma?c(Eri[ma]):null;return ba("td",{className:[Kn?"selected-cell":"",Zn?"delete-preview":""].filter(Boolean).join(" "),"data-table-row-index":_t,"data-table-column-index":cn,"data-table-cell-id":Gt?.id,"data-table-formula-error":ma??void 0,title:Jl??void 0,"aria-description":Jl?`${c("table.formula.errorAria")}: ${Jl}`:void 0,rowSpan:an,colSpan:xr,style:to,onPointerDownCapture:qi=>Y(qi,_t,cn),onPointerDown:qi=>{t&&qi.button===0&&qi.stopPropagation()},onContextMenuCapture:qi=>oe(qi,_t,cn),children:ba("div",{className:"overlay-table-cell-content-layer",style:Qa,children:Gt?Gt.content.map(qi=>ba(bJn,{shapeId:e.id,cell:Gt,cellId:Gt.id,content:qi,editing:t&&Gt.id===(ne??j?.id),showFormulaSource:t&&ne===Gt.id,table:u,rowIndex:_t,columnIndex:cn,colSpan:xr,onFocus:Ce,onChange:Q,onNavigate:le,onRegisterEditor:re},qi.id)):null})},Gt?.id??`${mt.id}:${xt.id}`)})},mt.id))})]}),ba(SJn,{table:u,columnOffsets:h,rowOffsets:g})]})}var Eri,Pri,FJn,CJn=X(()=>{"use strict";"use client";Dt();er();rJn();Dt();un();ij();jh();m_();tDt();xJn();wJn();Eri={"#DIV/0!":"table.formula.error.divideByZero","#NAME?":"table.formula.error.name","#REF!":"table.formula.error.ref","#VALUE!":"table.formula.error.value","#NUM!":"table.formula.error.num","#N/A":"table.formula.error.na","#CYCLE!":"table.formula.error.cycle"};Pri=500;FJn={xs:.5,s:1,m:2,l:3,xl:4}});function nDt(e){return JI([...e])}function gze(e,t=[]){return ky(e,[...t],{spaceAfter:"node"}).map(rDt)}function rDt(e){return e.type==="paragraph"||e.type==="heading"||e.type==="list"||e.type==="quote"||e.type==="codeBlock"||e.type==="divider"?e:{type:"paragraph",id:e.id||rt("p"),children:Bh(e)}}var oDt=X(()=>{"use strict";ai();xi();qk()});var AJn,TJn=X(()=>{"use strict";Xo();vwt();AJn=Vn.create({name:"overlayTextBlockAttrs",addGlobalAttributes(){return[{types:["paragraph","heading","bulletList","orderedList"],attributes:{sigmaDocId:{default:null,renderHTML:()=>({})},sigmaDocType:{default:null,renderHTML:()=>({})},spaceAfterPx:EOe}},{types:["listItem"],attributes:{spaceAfterPx:IOe}},{types:["paragraph","heading"],attributes:{listItemSpaceAfterPx:POe}},{types:["orderedList"],attributes:{markerStyle:BOe}},{types:["bulletList","orderedList"],attributes:{indentEm:MOe}}]}})});function kJn(e){return e.getMeta(iDt)===!0}function yze(e){let t=[],n=(r,o)=>{r.forEach((i,a)=>{if(i.type.name!=="listItem")return;let s=o+1+a;t.push({pos:s,kind:"listItem",node:i}),i.forEach((l,c)=>{DJn.has(l.type.name)&&n(l,s+1+c)})})};return e.forEach((r,o)=>{Rri.has(r.type.name)?t.push({pos:o,kind:"block",node:r}):DJn.has(r.type.name)&&n(r,o)}),t}function EJn(e,t){let n=-1;return e.forEach((r,o)=>{r.pos<=t&&t<r.pos+r.node.nodeSize&&(n=o)}),n}function IJn(e,t){for(let n=e;n&&n!==t;n=n.parentElement)if(n instanceof HTMLElement&&(n.tagName==="LI"||n.parentElement===t))return n;return null}function aDt(e){return e.kind==="block"?rc(e.node.attrs.spaceAfterPx)??0:rc(e.node.firstChild?.attrs.listItemSpaceAfterPx)??0}function PJn(e,t,n){let r=rc(n)??null;if(t.kind==="block")return e.setNodeMarkup(t.pos,void 0,{...t.node.attrs,spaceAfterPx:r});let o=t.node.firstChild;return o&&e.setNodeMarkup(t.pos+1,void 0,{...o.attrs,listItemSpaceAfterPx:r}),e.setNodeMarkup(t.pos,void 0,{...t.node.attrs,spaceAfterPx:r})}function MJn(e,t){let n=e.nodeDOM(t.pos);return n instanceof HTMLElement?t.kind==="block"?n:Array.from(n.children).filter(o=>o instanceof HTMLElement&&o.tagName!=="UL"&&o.tagName!=="OL").at(-1)??null:null}function BJn(e,t){let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent instanceof HTMLElement?r.offsetParent:null;return r===t?n+e.offsetHeight:null}function LJn(e,t,n,r){let o=Number.isFinite(r)&&r>0?r:1,i=Number.isFinite(n)?n:0;return(-e*Math.sin(i)+t*Math.cos(i))/o}var iDt,Rri,DJn,RJn=X(()=>{"use strict";Dt();iDt="overlayTextSpaceAfter";Rri=new Set(["paragraph","heading","divider"]),DJn=new Set(["bulletList","orderedList"])});import{useEffect as _Jn,useRef as bze}from"react";import{jsx as OJn}from"react/jsx-runtime";function NJn({editor:e,wrapperRef:t,rotation:n,draggingRef:r,onCommit:o}){let i=We("editor"),a=bze(null),s=bze(null),l=bze(n),c=bze(o);return _Jn(()=>{l.current=n,c.current=o},[o,n]),_Jn(()=>{let u=t.current,d=a.current;if(!u||!d)return;let p=null,f=null,m=null,h=null,g=()=>e.isInitialized&&!e.isDestroyed,y=()=>{if(!g()||!e.isEditable)return null;let L=yze(e.state.doc),_=f?.index??p??-1;if(_<0||_>=L.length){let{selection:z}=e.state;_=EJn(L,"node"in z?z.from:z.head)}let R=L[_];if(!R)return null;let O=MJn(e.view,R),N=O?BJn(O,u):null;return N===null?null:{index:_,px:aDt(R),bottom:N}},b=()=>{m=null;let L=y();if(h=L?{index:L.index,px:L.px}:null,!L){d.removeAttribute("data-visible");return}d.dataset.visible="true",d.dataset.index=String(L.index),d.style.top=`${L.bottom}px`},x=()=>{m===null&&(m=window.requestAnimationFrame(b))},v=(L,_,R)=>{if(!g())return!1;let O=yze(e.state.doc)[L];if(!O||aDt(O)===_)return!1;let N=PJn(e.state.tr,O,_).setMeta(iDt,!0).setMeta("addToHistory",!1);return R&&N.setMeta("preventUpdate",!0),e.view.dispatch(N),!0},S=(L,_)=>Wse(L.startPx+LJn(_.clientX-L.startPoint.clientX,_.clientY-L.startPoint.clientY,l.current,L.scale)),F=L=>{L.frame=null;let _=S(L,L.point);_!==L.px&&(L.px=_,v(L.index,_,!0),b())},w=L=>{L.frame!==null&&(window.cancelAnimationFrame(L.frame),L.frame=null),window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",D),window.removeEventListener("pointercancel",T),window.removeEventListener("keydown",k,!0),delete d.dataset.dragging,r.current=!1,f=null},C=()=>{let L=f;L&&(w(L),v(L.index,L.startPx,!0),x())};function A(L){let _=f;_&&(_.point={clientX:L.clientX,clientY:L.clientY},_.frame===null&&(_.frame=window.requestAnimationFrame(()=>F(_))))}function T(){C()}function D(L){let _=f;if(!_)return;let R=S(_,{clientX:L.clientX,clientY:L.clientY});w(_),v(_.index,R,!0),R!==_.startPx&&c.current(),x()}function k(L){L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),C())}s.current={startDrag(L){if(L.stopPropagation(),L.button!==0||!h||!g())return;f&&C();let _={clientX:L.clientX,clientY:L.clientY};f={index:h.index,startPx:h.px,px:h.px,startPoint:_,point:_,scale:G0(u,"y"),frame:null},r.current=!0,d.dataset.dragging="true";try{L.currentTarget.setPointerCapture(L.pointerId)}catch{}window.addEventListener("pointermove",A,{passive:!0}),window.addEventListener("pointerup",D),window.addEventListener("pointercancel",T),window.addEventListener("keydown",k,!0)},keyDown(L){let _=bAe(L);if(!_||!h)return;L.preventDefault(),L.stopPropagation();let R=_.kind==="reset"?0:Wse(h.px+_.deltaPx);v(h.index,R,!1)&&(h={index:h.index,px:R}),x()},reset(){h&&(v(h.index,0,!1),x())}};let P=L=>{if(f||!(L.target instanceof Element)||d.contains(L.target))return;let _=IJn(L.target,e.view.dom),R=yze(e.state.doc),O=_?R.findIndex(z=>e.view.nodeDOM(z.pos)===_):-1,N=O>=0?O:null;N!==p&&(p=N,x())},I=()=>{p=null,x()},B=({transaction:L})=>{L.docChanged&&!kJn(L)&&(p=null),x()};u.addEventListener("pointermove",P),e.on("selectionUpdate",I),e.on("transaction",B);let M=typeof ResizeObserver>"u"?null:new ResizeObserver(x);return M?.observe(u),x(),()=>{f&&C(),m!==null&&window.cancelAnimationFrame(m),u.removeEventListener("pointermove",P),e.off("selectionUpdate",I),e.off("transaction",B),M?.disconnect(),s.current=null}},[r,e,t]),OJn("div",{className:"overlay-text-space-layer","data-testid":"overlay-text-space-layer",children:OJn("button",{ref:a,type:"button",className:"page-block-space-handle overlay-text-space-handle","data-testid":"overlay-text-space-handle","aria-label":i("pageCanvas.spaceAfter"),title:i("pageCanvas.spaceAfterHint"),onMouseDown:u=>{u.preventDefault(),u.stopPropagation()},onPointerDown:u=>s.current?.startDrag(u),onClick:u=>u.stopPropagation(),onDoubleClick:u=>{u.stopPropagation(),s.current?.reset()},onKeyDown:u=>s.current?.keyDown(u)})})}var zJn=X(()=>{"use strict";"use client";Dt();Gc();un();RJn()});import{useEffect as UJn,useLayoutEffect as sDt,useRef as Ebe,useState as _ri}from"react";import{jsx as HJn,jsxs as Ori}from"react/jsx-runtime";function Ibe({shape:e,externalRevision:t,editing:n,onFocus:r,onCancel:o,onMeasuredHeight:i,onChange:a}){let{preferredFont:s,seedPreferredFont:l}=C_e(),c=Ebe(null),u=Ebe(e.props.blocks),d=Ebe(t),p=_m(),f=Ebe(!1),[m]=_ri(()=>new Nee),h=ww({extensions:Vk({blockExtensions:[AJn],drawBoxedRunFrames:e.type==="text"&&Oi(e)===0,enableMathDelimiters:!0,bodyBlocks:!0,listMarkerTypography:!0,orderedListMarkerStyles:!0,mathEnvironment:p,textBlockStyle:!0}),content:nDt(e.props.blocks),immediatelyRender:!1,editorProps:{attributes:{class:"overlay-text-shape-content"},handleKeyDown:(F,w)=>(jge(w)&&m.requestLiteralPaste(),w.key!=="Escape"?!1:(w.preventDefault(),o(e.id),!0)),handleDOMEvents:{copy:(F,w)=>eFt(F,w,u.current)},handlePaste:(F,w,C)=>EHn(m,F,w,C)},onTransaction:({editor:F})=>{F.isFocused&&(l(F),$w(F,lDt,"overlay",void 0,{state:F.state,view:F.view,documentFontFamily:nx}))},onFocus:({editor:F})=>{l(F),$w(F,lDt,"overlay",void 0,{state:F.state,view:F.view,documentFontFamily:nx}),r(F,e.id)},onUpdate:({editor:F})=>{$w(F,lDt,"overlay",void 0,{state:F.state,view:F.view,documentFontFamily:nx}),g(F)}});function g(F){let w=F.getJSON(),C=gze(w,u.current);u.current=C,a(e.id,C)}UJn(()=>{h?.isFocused&&l(h)},[h,s,l]),sDt(()=>{if(!h)return;let F=d.current!==t;if(d.current=t,h.isFocused&&!F)return;let w=JSON.stringify(u.current),C=JSON.stringify(e.props.blocks);if(w!==C){u.current=e.props.blocks;let A=nDt(e.props.blocks);h.isDestroyed||(h.commands.setContent(A,{emitUpdate:!1}),F&&n&&h.commands.focus("end"))}},[n,h,t,e.props.blocks]),UJn(()=>{n&&h&&!h.isFocused&&window.setTimeout(()=>h.commands.focus("end"),0)},[n,h]);let y=e.type==="callout",b=QS(e),x=Oi(e),v=n&&!e.flipX&&!e.flipY,S=Ebe(e);return sDt(()=>{S.current=e},[e]),sDt(()=>{let F=()=>{let k=c.current?.querySelector(".ProseMirror");if(!k)return;let P=Pye(k,{rotated:x!==0}),I=S.current,B=BNe(I,P);f.current?i(I.id,B,{preview:!0}):i(I.id,B)};F();let w=null,C=()=>{w!==null&&window.cancelAnimationFrame(w),w=window.requestAnimationFrame(()=>{w=null,F()})},A=c.current?.querySelector(".ProseMirror"),T=typeof ResizeObserver>"u"?null:new ResizeObserver(C),D=typeof MutationObserver>"u"?null:new MutationObserver(C);return A&&(T?.observe(A),D?.observe(A,{attributes:!0,attributeFilter:[..._Ct],childList:!0,subtree:!0})),C(),()=>{w!==null&&window.cancelAnimationFrame(w),T?.disconnect(),D?.disconnect()}},[n,h,b,i,x,e.id,e.type,e.props.blocks,e.props.w]),Ori("div",{ref:c,className:`overlay-text-shape ${y?"embedded-callout":""} ${e.type==="text"&&e.props.textWrap==="none"?"no-auto-wrap":""}`,style:{...v?{position:"relative"}:{},width:y?"100%":e.props.w,...e.type==="text"?LK(e):{},minWidth:y?0:wD,minHeight:y?b:Math.max(e.props.h,b),color:e.props.color,fontSize:`${xC(e)}pt`,pointerEvents:n?"auto":"none"},onPointerDown:F=>{n&&F.stopPropagation()},children:[HJn(o2,{editor:h}),v&&h?HJn(NJn,{editor:h,wrapperRef:c,rotation:x,draggingRef:f,onCommit:()=>g(h)}):null]})}var lDt,GJn=X(()=>{"use strict";"use client";rU();A_e();ree();jk();Dt();Ys();Dn();Pn();s7e();oDt();TJn();zJn();LNe();lDt="sigma-studio:text-format-state"});var cDt=X(()=>{"use strict";"use client";CJn();GJn()});import{useEffect as jJn,useMemo as Nri,useState as VJn}from"react";import{jsx as Pbe}from"react/jsx-runtime";function zri({shape:e,interactive:t,onCameraChange:n,onObjectRotationChange:r,onObjectTransformChange:o,onPreviewReady:i}){let[a,s]=VJn(null),[l,c]=VJn(!1);jJn(()=>{let p=f=>{if(!(f instanceof CustomEvent))return;let m=f.detail;m.shapeId===e.id&&s(m)};return window.addEventListener(A9e,p),()=>window.removeEventListener(A9e,p)},[e.id]),jJn(()=>{let p=f=>{if(!(f instanceof CustomEvent))return;let m=f.detail;c(m.shapeId===e.id)};return window.addEventListener(T9e,p),()=>window.removeEventListener(T9e,p)},[e.id]);let d=a?.playing===!1&&Object.entries(a.overrides).every(([p,f])=>e.props.spec.parameters.some(m=>m.name===p&&m.value===f))?null:a;return Pbe(Q1t,{spec:e.props.spec,interactive:t,parameterOverrides:d?.overrides,animationPlaying:d?.playing===!0,deferAnimationCapture:l,onCameraChange:p=>n(e.id,p),onObjectRotationChange:(p,f)=>r(e.id,p,f),onObjectTransformChange:(p,f)=>o(e.id,p,f),onPreviewReady:(p,f,m,h)=>i(e.id,p,f,m,h)})}function XJn(e){let{onGraph3DCameraChange:t,onGraph3DObjectRotationChange:n,onGraph3DObjectTransformChange:r,onGraph3DPreviewReady:o,onCreateChartFromTable:i,onTableChange:a,onTableEditorFocus:s,onTableFirstCellReady:l,onTableResize:c,onTextMeasuredHeight:u,onTextChange:d,onTextEditorCancel:p,onTextEditorFocus:f}=e;return Nri(()=>({renderGraph3DEditor:({interactive:m,shape:h})=>Pbe("div",{className:"overlay-graph3d-live-window","data-testid":"overlay-graph3d-live-window",onPointerDown:m?g=>g.stopPropagation():void 0,onDoubleClick:m?g=>g.stopPropagation():void 0,onWheel:m?g=>g.stopPropagation():void 0,children:Pbe(zri,{shape:h,interactive:m,onCameraChange:t,onObjectRotationChange:n,onObjectTransformChange:r,onPreviewReady:o})}),renderTableEditor:({editing:m,shape:h})=>Pbe(kbe,{shape:h,editing:m,onFocus:s,onFirstCellReady:l,onChange:a,onResize:c,onCreateChart:i}),renderTextEditor:({editing:m,externalRevision:h,shape:g})=>Pbe(Ibe,{shape:g,externalRevision:h,editing:m,onFocus:f,onCancel:p,onMeasuredHeight:u,onChange:d})}),[i,t,n,r,o,a,s,l,c,u,d,p,f])}var WJn=X(()=>{"use strict";Ys();D9e();cDt()});var dDt={};$S(dDt,{OverlayShapeReadOnlyView:()=>vj,OverlayTableShapeEditor:()=>kbe,OverlayTextShapeEditor:()=>Ibe,RemoteOverlayPresenceLayer:()=>vbe,default:()=>KJn,getRemoteOverlayPresenceFrameStyle:()=>MTt,getRemoteOverlayPresenceLabelBounds:()=>PTt,mergeOverlayHistoryGroup:()=>TTt,resolveRemoteOverlayPresenceFrames:()=>ITt});import{useMemo as Mbe}from"react";import{useCallback as kp,useEffect as Km,useLayoutEffect as cne,useReducer as Uri,useRef as wd,useState as nv}from"react";import{createPortal as xze}from"react-dom";import{jsx as gl,jsxs as Xri}from"react/jsx-runtime";function qJn(e,t){if(!(!t||!Bd(e)||!Tnt(Zp(e),t.bounds)))return t.revision}function KJn({externalRevision:e,documentId:t,overlay:n,canvasWidth:r,canvasHeight:o,insertionBounds:i,bleedValues:a,imageInsertAreaWidth:s,imageInsertAreaHeight:l,blockAnchorScopeElement:c,bodyBlockRects:u=null,bodyAnchorableBlocks:d=null,visiblePageRange:p=null,textRepaint:f=null,pageHeightPx:m=0,pageGapPx:h=0,pageArrangement:g=null,showAnchorHandles:y=!0,autoScrollPanBy:b,autoScrollViewportElement:x=null,verticalSnapGuides:v=[],backgroundLayerElement:S,commandRequest:F,imageRequest:w,actionRequest:C,arrangeShortcutLabels:A,acceptsStylePreview:T=!0,selectPointRequest:D,onCommandHandled:k,onImageHandled:P,onActionHandled:I,onSelectPointHandled:B,onRequestTextMode:M,onRequestTextSelection:L,retainEmptySelection:_=!1,onModeStatusChange:R,onSelectionSummaryChange:O,onSelectedCountChange:N,onActiveToolChange:z,onMaterialSaveRequest:U,syncBlockAnchors:H=!0,onChange:V,editPolicy:ne=ZZn,shapeDecorations:Z,diffShapeClassNames:ee,publishesSessionPresence:J=!1}){let te=We("shape"),K=HD(),{shapes:G,setShapes:ie,assets:fe,setAssets:$,canvasWidthRef:j,canvasHeightRef:pe,documentIdRef:re,saveTimeoutRef:le,pendingOverlayHistoryRef:Q,pendingOverlaySaveHistoryGroupRef:se,imageCropDirtyRef:De,mountedRef:Ae,suppressNextSaveRef:ye,explicitlySavedShapeStatesRef:$e,externalRevisionRef:Pe,lastEmittedSnapshotRef:Ne,seenDocumentSnapshotRef:we,reconciledDocumentSnapshotRef:Ie,onChangeRef:Ce,shapesRef:xe,assetsRef:Y,extensionsRef:oe}=UZn({overlay:n,canvasWidth:r,canvasHeight:o,documentId:t,externalRevision:e,onChange:V}),[de,Le]=nv([]),[be,Be]=nv(null),ce=wd(null),[Re,Qe]=nv(null),W=kp(Ot=>{ce.current=Ot,Be(Ot)},[]);Km(()=>{let Ot=ce.current;Ot&&!(de.length===1&&de[0]===Ot.shapeId)&&W(null)},[de,W]);let[ve,_e]=nv(null),[he,Oe]=nv(null),qe=wd(null),[Ze,vt]=nv(null),[Ft,gt]=nv(null),[bt,ct]=nv(jri),[ft,hn]=nv(null),[Kt,xo]=nv([]),[Bo,fo]=nv(0),[Sr,oa]=Uri(Vot,void 0,xnn),mt=_&&ve&&ve.documentId===t&&ve.revision===e&&de.length===0&&Sr.id==="overlay.select"?ve.bounds:null,_t=vnn(Sr),Gt=Fnn(Sr),cn=Cnn(Sr),an=Ann(Sr)?cn:null,xr=ft?.shapeId===cn?ft:null,xt=Tnn(Sr),Kn=wd(null),Zn=wd(null),to=g&&g.columns>1?g:null,Qa=wd(to);cne(()=>{Qa.current=to},[to]),Km(()=>{if(!mt)return;let Ot=mi=>{mi.key==="Escape"&&_e(null)},Jr=mi=>{let vo=mi.target;!(vo instanceof Element)||mi.button!==0||Kn.current?.contains(vo)||vo.closest(".selection-action-popover, [data-preserve-canvas-selection]")||_e(null)};return window.addEventListener("keydown",Ot,!0),window.addEventListener("pointerdown",Jr,!0),()=>{window.removeEventListener("keydown",Ot,!0),window.removeEventListener("pointerdown",Jr,!0)}},[mt]);let ma=wd(null),Jl=wd(!1),qi=wd(Sr),Go=wd(null),xs=wd(null),Fe=wd(null),dt=wd({w:s,h:l});cne(()=>{dt.current={w:s,h:l}},[l,s]);let Mt=wd(de),Ct=wd(Ft),Tt=wd(bt),dn=wd(""),Yn=wd(CD);Km(()=>{Yn.current=bWn()},[]);let[bn,Jt]=nv(Gte);Km(()=>AKn(Jt),[]);let dr=kp(Ot=>{CKn(Ot)},[]),$r=wd(!1),[ti,Qn]=nv(null),mo=ne.lockedShapeIds,Si=wd(mo);Km(()=>{Si.current=mo},[mo]);let rr=ne.unselectableShapeIds,Io=wd(rr);Km(()=>{Io.current=rr},[rr]);let ia=ne.preservedShapeIds,Wn=wd(ia);cne(()=>{Wn.current=ia},[ia]);let[es,Pi]=nv(null),ku=wd(null),ni=kp(()=>{ne.blockedMessage&&(Pi(ne.blockedMessage),ku.current&&clearTimeout(ku.current),ku.current=setTimeout(()=>Pi(null),6e3))},[ne.blockedMessage]);Km(()=>()=>{ku.current&&clearTimeout(ku.current)},[]);let Eu=kp(()=>{xo(Ot=>Ot.length===0?Ot:[])},[]),Iu=kp(()=>{let Ot=Zn.current?.getBoundingClientRect();if(!Ot||Ot.width<=0||Ot.height<=0)return uDt;let Jr=Qa.current;if(Jr)return uDt*(Eb(Jr,1).width/Ot.width);let mi=j.current/Ot.width,vo=pe.current/Ot.height;return uDt*Math.max(mi,vo)},[pe,j]),Pu=kp(()=>{let Ot=Zn.current;return Ot?c&&Ot.ownerDocument.contains(c)?c:Ot.closest(".page-canvas")??Ot.ownerDocument:c??null},[c]),Po=wd(null),xl=kp((Ot=[])=>{let Jr=[...Ot],mi=JSON.stringify(Jr),vo=xe.current,Rc=j.current,Gs=pe.current,js=Po.current,Z1=js&&js.guides.length===v.length&&js.guides.every((Q3,Bv)=>Q3===v[Bv]);if(js&&Z1&&js.shapes===vo&&js.excludedKey===mi&&js.canvasWidth===Rc&&js.canvasHeight===Gs)return js.geometry;let ud=prn(ux(vo),{excludedShapeIds:Jr,canvasWidth:Rc,canvasHeight:Gs,verticalGuideValues:v});return Po.current={canvasHeight:Gs,canvasWidth:Rc,excludedKey:mi,geometry:ud,guides:[...v],shapes:vo},ud},[pe,j,xe,v]);Km(()=>{let Ot=()=>{Jl.current=!0},Jr=()=>{Jl.current=!1};return window.addEventListener("compositionstart",Ot),window.addEventListener("compositionend",Jr),()=>{window.removeEventListener("compositionstart",Ot),window.removeEventListener("compositionend",Jr)}},[]),Km(()=>{Mt.current=de},[de]),Km(()=>{Ct.current=Ft},[Ft]),Km(()=>{if(!Ft||vP(G,Ft))return;let Ot=window.setTimeout(()=>gt(null),0);return()=>window.clearTimeout(Ot)},[Ft,G]);let Fi=kp(Ot=>{if(SKn(Ot,xe.current,Si.current)){ni();return}Ot.type==="select"&&qi.current.id==="overlay.marquee"||_e(null),qi.current=Vot(qi.current,Ot),oa(Ot)},[ni,xe]);Km(()=>{qi.current=Sr},[Sr]);let Ma=vZn({documentId:t,modeRef:qi,transitionMode:Fi,bleedSurfaceRef:Kn}),{dragPointerRef:vs,dragCanvasRectRef:Td,suppressNextShapeDoubleClickRef:dm,dragAutoScrollerRef:Pf}=Ma,{id:pb,labelId:Tg}=hWn(Sr,de.length);Km(()=>{R?.({id:pb,labelId:Tg})},[pb,Tg,R]),Km(()=>{z?.(Sr.tool)},[Sr.tool,z]);let LT=kp(()=>Tt.current.rects,[]),pm=kp(()=>Wn.current,[]),{queueOverlaySave:Zc,clearQueuedOverlaySave:d0,commitOverlayChangeNow:Lc,flushOverlayChange:Mf,queueDirtyImageCropSave:Ns}=uZn({syncBlockAnchors:H,shapesRef:xe,canvasRef:Zn,canvasHeightRef:pe,canvasWidthRef:j,getBlockAnchorScope:Pu,getLastDrawnBlockRects:LT,getPreservedShapeIds:pm,suppressNextSaveRef:ye,setShapes:ie,assetsRef:Y,extensionsRef:oe,lastEmittedSnapshotRef:Ne,onChangeRef:Ce,imageCropDirtyRef:De,saveTimeoutRef:le,pendingOverlayHistoryRef:Q,pendingOverlaySaveHistoryGroupRef:se}),Ql=kp((Ot,Jr=Array.from(Ot.values()))=>{if(Ot.size===0||sw(qi.current))return!1;let mi=xe.current,vo=Qr(ZNe(mi,Jr,void 0,Wn.current)),Rc=new Map(mi.map(ud=>[ud.id,ud])),Gs=vo.some(ud=>!Zx(Rc.get(ud.id)?.anchor,ud.anchor)),js=Qr(F0(vo,Ot,Qx(vo))),Z1=js.length!==mi.length;for(let ud=0;!Z1&&ud<js.length;ud+=1)js[ud]!==mi[ud]&&(Z1=!0);return Z1?(xe.current=js,Gs?($e.current.add(js),Zc({history:"coalesce"})):ye.current=!0,ie(js),!0):!1},[$e,Zc,ie,xe,ye]);hKn({setPreview:Oe,clearQueuedOverlaySave:d0,imageCropDirtyRef:De,suppressNextSaveRef:ye,modeRef:qi,selectedIdsRef:Mt,shapesRef:xe,assetsRef:Y,extensionsRef:oe,setShapes:ie,setAssets:$,setSelectedIds:Le,setAppliedSnapshotRevision:fo,transitionMode:Fi,activeTextEditorRef:ma,overlay:n,anchorMeasurementsRef:Tt,reconciledDocumentSnapshotRef:Ie,lastEmittedSnapshotRef:Ne,saveTimeoutRef:le,pendingOverlayHistoryRef:Q,externalRevisionRef:Pe,externalRevision:e,seenDocumentSnapshotRef:we,mode:Sr}),fZn({assets:fe,shapes:G,assetsRef:Y,shapesRef:xe,mountedRef:Ae,pendingOverlaySaveHistoryGroupRef:se,explicitlySavedShapeStatesRef:$e,suppressNextSaveRef:ye,commitOverlayChangeNow:Lc,queueOverlaySave:Zc,flushOverlayChange:Mf,saveTimeoutRef:le,imageCropDirtyRef:De}),cne(()=>{if(!H)return;let Ot=Zn.current;if(!Ot)return;let Jr=Pu();if(!Jr)return;let{rects:mi,ordered:vo}=yP(Ot,Jr,pe.current,j.current,Tt.current.rects);mi.size!==0&&Ql(mi,vo)},[pe,j,Pu,Ql,H]);let{setSelectedShapeIds:zs,replaceShape:fm,updateShape:Dd,selectKnownShape:ui,selectShape:vl,updateGraphShapeSpec:mm,toggleShapeSelection:ll}=lZn({setRegionSelection:_e,shapesRef:xe,selectedIdsRef:Mt,setSelectedIds:Le,onSelectedCountChange:N,unselectableShapeIdsRef:Io,focusedGroupIdRef:Ct,transitionMode:Fi,modeRef:qi,activeTextEditorRef:ma,explicitlySavedShapeStatesRef:$e,setShapes:ie,commitOverlayChangeNow:Lc,queueOverlaySave:Zc,anchorMeasurementsRef:Tt});Km(()=>{let Ot=wKn(Mt.current,xe.current,rr);Ot&&zs(Ot)},[rr,Mt,zs,xe]);let{imageReplacementInputRef:q1,startImageCrop:Mu,requestImageReplacement:pu,resetImageCrop:wo,restoreImageNaturalSize:Va,handleImageReplacementChange:ec,setImageOpacity:Us}=G$n({shapesRef:xe,editPolicyLockedShapeIdsRef:Si,notifyEditPolicyBlocked:ni,setSelectedShapeIds:zs,transitionMode:Fi,documentId:t,assetsRef:Y,setShapes:ie,setAssets:$,queueOverlaySave:Zc,replaceShape:fm,imageInsertAreaRef:dt,updateShape:Dd}),{createShapeFromInsertDrag:Dv,finishCurveDrawing:fb,createChartFromTable:dh}=q$n({lastCalloutCornerRadiusRef:Yn,focusedGroupIdRef:Ct,shapesRef:xe,canvasWidthRef:j,canvasHeightRef:pe,suppressNextSaveRef:ye,insertedTableFocusRef:qe,setShapes:ie,selectKnownShape:ui,commitOverlayChangeNow:Lc,queueOverlaySave:Zc,setSelectedShapeIds:zs,transitionMode:Fi,clearSnapGuides:Eu}),Bu=kp(()=>{qe.current=null;let Ot=vs.current?.pointerId;Ot!==void 0&&Kn.current?.hasPointerCapture(Ot)&&Kn.current.releasePointerCapture(Ot),vs.current=null,Pf.current?.stop(),Pf.current=null,Eu(),Fi({type:"setTool",tool:{kind:"select"}})},[Eu,Pf,vs,Fi]),Bf=kp(Ot=>{let Jr=Ot.id==="overlay.resize"||Ot.id==="overlay.rotate"?Ot.shapes:Ot.id==="overlay.point"||Ot.id==="overlay.imageCropResize"||Ot.id==="overlay.imageCropPan"?[Ot.shape]:[];Jr.length>0&&ie(mi=>{let vo=Qr(Wv(mi,Jr));return xe.current=vo,vo}),(Ot.id==="overlay.imageCropResize"||Ot.id==="overlay.imageCropPan")&&(De.current=!1),Qn(null),Eu()},[Eu,De,ie,xe]),Jc=kp(Ot=>{if(Go.current!==Ot.id){if(Ot.command==="select")Fi({type:"setTool",tool:{kind:"select"}});else if(Ot.command==="table"){let Jr=ma.current;Jr&&!Jr.isDestroyed&&Jr.commands.blur(),ma.current=null,Fi({type:"setTool",tool:{kind:"insert",command:"table",tableCellSize:{w:kye,h:Math.max(36,Eye)}}})}else Fi({type:"setTool",tool:{kind:"insert",command:Ot.command,graphPreset:Ot.graphPreset,graph3dPreset:Ot.graph3dPreset,...Ot.command==="callout"?{calloutRadius:Yn.current}:{}}});Go.current=Ot.id,k(Ot.id)}},[k,Fi]);Km(()=>{if(F){let Ot=window.setTimeout(()=>Jc(F),0);return()=>window.clearTimeout(Ot)}},[F,Jc]),X$n({documentId:t,imageInsertAreaWidth:s,imageInsertAreaHeight:l,canvasWidthRef:j,canvasHeightRef:pe,focusedGroupIdRef:Ct,shapesRef:xe,setAssets:$,assetsRef:Y,setShapes:ie,setSelectedShapeIds:zs,transitionMode:Fi,queueOverlaySave:Zc,onImageHandled:P,imageRequest:w});let Jn=kp((Ot,Jr,mi)=>{let vo=mi??Zn.current?.getBoundingClientRect();if(!vo||vo.width<=0||vo.height<=0)return{x:Ot,y:Jr};mi||(Td.current={left:vo.left,top:vo.top,width:vo.width,height:vo.height});let Rc=Qa.current;if(Rc){let Gs=vo.width/Eb(Rc,1).width,js=EB(Rc,{x:(Ot-vo.left)/Gs,y:(Jr-vo.top)/Gs});return{x:js.x,y:js.y}}return{x:(Ot-vo.left)/vo.width*j.current,y:(Jr-vo.top)/vo.height*pe.current}},[pe,j,Td]),kd=kp(Ot=>{let Jr=Zn.current?.getBoundingClientRect();if(!Jr||j.current<=0||pe.current<=0)return{x:Ot.x,y:Ot.y};let mi=Qa.current;if(mi){let vo=Jr.width/Eb(mi,1).width,Rc=yDe(mi,Ot);return{x:Jr.left+Rc.x*vo,y:Jr.top+Rc.y*vo}}return{x:Jr.left+Ot.x/j.current*Jr.width,y:Jr.top+Ot.y/pe.current*Jr.height}},[pe,j]),Ke=kp(()=>{QZn(Kn.current)},[]),Lu=kp(()=>{let Ot=Zn.current;if(!Ot)return Tt.current;let Jr=Pu();if(!Jr||sw(qi.current))return Tt.current;let mi=u&&d?{rects:u,ordered:[...d]}:yP(Ot,Jr,pe.current,j.current,Tt.current.rects),{rects:vo,ordered:Rc}=mi,Gs=KWn(Rc);if(Gs===dn.current)return Tt.current;let js={rects:vo,ordered:Rc};return dn.current=Gs,Tt.current=js,ct(js),Ql(vo,Rc),js},[d,u,pe,j,Pu,Ql]),gc=sw(Sr);cne(()=>{gc||Lu()},[gc,u,o,r,c,Lu]),cne(()=>{u||sw(qi.current)||Lu()}),Km(()=>(window.addEventListener("resize",Lu),()=>window.removeEventListener("resize",Lu)),[Lu]);let fu=kp((Ot,Jr=8)=>{let mi,vo=kd(Ot);return YZn(RK(xe.current),Ot,Jr,Gs=>Hte(Gs.id,Io.current)?!1:Gs.type==="graph2dShape"&&!Sbe(Zn.current,Gs.id,vo)?(mi??=Gs,!1):!0)??mi},[kd,xe]),Ru=kp(Ot=>{for(let Jr of RK(xe.current))if(!(!FNe(Jr)||Hte(Jr.id,Io.current))&&qv(Jr,Ot,Hri))return Jr},[xe]),rp=kp(Ot=>dKn({shapes:xe.current,point:Ot,isUnselectable:Jr=>Hte(Jr,Io.current),editPolicyLockedIds:Si.current}),[xe]),{duplicateSelectedShapes:Ss,deleteSelectedShapes:od,arrangeSelectedShapes:Nl,alignSelectedShapes:Dg,distributeSelectedShapes:id,groupSelectedShapes:op,ungroupSelectedShapes:mu,setSelectedShapesLocked:sC,setSelectedShapesHidden:kg,applyStyleToSelectedShapes:mb,applyPastedOverlayShapes:hm,reanchorShapesToCopiedBlocks:lC,getRemovableSelectedShapeIds:Eg,applyQuickTransformToSelectedShapes:NS}=PZn({shapesRef:xe,selectedIdsRef:Mt,editPolicyLockedShapeIdsRef:Si,notifyEditPolicyBlocked:ni,assetsRef:Y,canvasWidthRef:j,canvasHeightRef:pe,setAssets:$,setShapes:ie,setSelectedShapeIds:zs,transitionMode:Fi,queueOverlaySave:Zc,extensionsRef:oe,explicitlySavedShapeStatesRef:$e,pendingOverlaySaveHistoryGroupRef:se,commitOverlayChangeNow:Lc,refreshAnchorMeasurements:Lu,solidEdgeRef:ce,documentIdRef:re,canvasRef:Zn,getBlockAnchorScope:Pu,pageHeightPx:m,pageGapPx:h}),p0=wd(null),RT=kp((Ot,Jr)=>vt({x:Yo(Ot.x,8,Math.max(8,window.innerWidth-232)),y:Yo(Ot.y,8,Math.max(8,window.innerHeight-360)),shapeId:Jr}),[vt]);PKn({handledActionRequestIdRef:xs,duplicateSelectedShapes:Ss,deleteSelectedShapes:od,arrangeSelectedShapes:Nl,alignSelectedShapes:Dg,distributeSelectedShapes:id,groupSelectedShapes:op,ungroupSelectedShapes:mu,shapesRef:xe,selectedIdsRef:Mt,setSelectedShapesLocked:sC,setSelectedShapesHidden:kg,setPreview:Oe,editPolicyLockedShapeIdsRef:Si,editPolicyUnselectableShapeIdsRef:Io,solidEdgeRef:ce,learnShapeStyleDefaults:dr,applyStyleToSelectedShapes:mb,applyPastedOverlayShapes:hm,setFocusedGroupId:gt,setSelectedShapeIds:zs,refreshAnchorMeasurements:Lu,transitionMode:Fi,extendedActionRunnerRef:p0,activeTextEditorRef:ma,createShapeFromInsertDrag:Dv,onActionHandled:I,actionRequest:C,handledSelectPointRequestIdRef:Fe,focusOverlayCanvas:Ke,onSelectPointHandled:B,getShapeAtPoint:fu,getOpenStrokeShapeAtPoint:Ru,getEditableTextShapeAtPoint:rp,focusedGroupIdRef:Ct,setShapes:ie,queueOverlaySave:Zc,selectShape:vl,documentId:t,selectPointRequest:D,openShapeContextMenu:RT}),zKn({setShapes:ie,canvasWidthRef:j,canvasHeightRef:pe,shapesRef:xe,queueOverlaySave:Zc,selectedIds:de,shapes:G,originPickShapeId:cn,graphFillPickShapeId:xt,setSelectedShapeIds:zs,transitionMode:Fi});let{handleGraph3DCameraChange:Vp,handleGraph3DObjectRotationChange:zl,handleGraph3DObjectTransformChange:hb,handleGraph3DPreviewReady:ph}=KKn({shapes:G,selectedIds:de,shapesRef:xe,assetsRef:Y,setShapes:ie,setAssets:$,explicitlySavedShapeStatesRef:$e,canvasWidthRef:j,canvasHeightRef:pe,imageInsertGap:Gri,queueOverlaySave:Zc,setSelectedShapeIds:zs,transitionMode:Fi,tShape:te});Km(()=>{let Ot=Jr=>{let mi=Jr instanceof CustomEvent?Jr.detail:void 0;mi?.shapeId&&vl(mi.shapeId)};return window.addEventListener(wCt,Ot),()=>window.removeEventListener(wCt,Ot)},[vl]),XZn({shapesRef:xe,selectedIdsRef:Mt,editingShapeId:Gt,updateShape:Dd,activeTextEditorRef:ma,modeRef:qi});let gb=Mbe(()=>({shapesRef:xe,updateShape:Dd,editPolicyLockedShapeIdsRef:Si,editPolicyUnselectableShapeIdsRef:Io,notifyEditPolicyBlocked:ni,setShapes:ie,assetsRef:Y,replaceShape:fm}),[xe,Dd,Si,ni,ie,Y,fm]),_T=Mbe(()=>({selectedIdsRef:Mt,focusedGroupIdRef:Ct,setFocusedGroupId:gt,setSelectedShapeIds:zs,selectShape:vl,toggleShapeSelection:ll,setSolidEdge:W,duplicateSelectedShapes:Ss}),[Mt,Ct,gt,zs,vl,ll,W,Ss]),yb=Mbe(()=>({pagePointFromClient:Jn,getOverlaySnapThreshold:Iu,getShapeAtPoint:fu,getOpenStrokeShapeAtPoint:Ru,clientPointFromPage:kd,refreshAnchorMeasurements:Lu,createSnapGeometry:xl,anchorMeasurementsRef:Tt}),[Jn,Iu,fu,Ru,kd,Lu,xl,Tt]),{updateModifierDrivenInteraction:kv,getSnappedDrawingPoint:zS,applyMoveInteractionAtPoint:Sl,applyResizeInteractionAtPoint:gm,applyPointInteractionAtPoint:He,applyImageCropInteractionAtPoint:it,getSnappedInsertDragPoint:Pt}=CZn({session:Ma,editing:gb,geometry:yb,snapDisabledRef:$r,setSnapGuides:xo,clearSnapGuides:Eu,lastCalloutCornerRadiusRef:Yn,imageCropDirtyRef:De});J$n({textCompositionRef:Jl,modeRef:qi,cancelTablePlacement:Bu,snapDisabledRef:$r,clearSnapGuides:Eu,updateModifierDrivenInteraction:kv,activeTextEditorRef:ma,transitionMode:Fi,queueDirtyImageCropSave:Ns,finishCurveDrawing:fb,restoreTransientInteraction:Bf,solidEdgeRef:ce,setSolidEdge:W,focusedGroupIdRef:Ct,setFocusedGroupId:gt,setSelectedShapeIds:zs,shapesRef:xe,ungroupSelectedShapes:mu,groupSelectedShapes:op,selectedIdsRef:Mt,duplicateSelectedShapes:Ss,editPolicyLockedShapeIdsRef:Si,notifyEditPolicyBlocked:ni,arrangeSelectedShapes:Nl,refreshAnchorMeasurements:Lu,setShapes:ie,deleteSelectedShapes:od,mode:Sr}),Km(()=>{if(!Ze)return;let Ot=mi=>{(mi.target instanceof Element?mi.target:null)?.closest(".overlay-shape-context-menu, .overlay-shape-context-submenu-panel")||vt(null)},Jr=mi=>{mi.key==="Escape"&&vt(null)};return window.addEventListener("pointerdown",Ot,!0),window.addEventListener("keydown",Jr),()=>{window.removeEventListener("pointerdown",Ot,!0),window.removeEventListener("keydown",Jr)}},[Ze]),aZn({getBlockAnchorScope:Pu,activeTextEditorRef:ma,shapesRef:xe,selectedIdsRef:Mt,reanchorShapesToCopiedBlocks:lC,assetsRef:Y,documentIdRef:re,getRemovableSelectedShapeIds:Eg,pendingOverlaySaveHistoryGroupRef:se,deleteSelectedShapes:od,applyPastedOverlayShapes:hm});let{updateOriginPickPreviewFromEvent:Fn,handleOriginPickPointerDown:nn,handleGraphFillPickPointerDown:rn}=XKn({shapesRef:xe,pagePointFromClient:Jn,originPickShapeId:cn,setOriginPickPreview:hn,updateGraphShapeSpec:mm,queueOverlaySave:Zc,transitionMode:Fi,graphFillPickShapeId:xt}),tn=Mbe(()=>({getSnappedDrawingPoint:zS,finishCurveDrawing:fb,getSnappedInsertDragPoint:Pt,createShapeFromInsertDrag:Dv}),[zS,fb,Pt,Dv]),or=Mbe(()=>({applyMoveInteractionAtPoint:Sl,applyResizeInteractionAtPoint:gm,applyPointInteractionAtPoint:He,applyImageCropInteractionAtPoint:it}),[Sl,gm,He,it]),{handleCurveDrawingDoubleClick:Zr,handleCanvasPointerDown:pi,handleShapePointerDown:Ba,handleResizePointerDown:ts,handleImageCropResizePointerDown:ke,handleRotatePointerDown:fi,handlePointPointerDown:Ig,handleLineInsertPointerDown:aa,handleAnchorPointerDown:ip}=wZn({session:Ma,editing:gb,selection:_T,geometry:yb,drawing:tn,focusOverlayCanvas:Ke,setAdjustmentDragReadoutPointerPosition:Qn,graphFillPickShapeId:xt,selectedRegion:mt}),{handlePointerMove:Ul,handlePointerCancel:ym,handlePointerUp:K1}=yZn({session:Ma,editing:gb,selection:_T,geometry:yb,drawing:tn,transforms:or,clearSnapGuides:Eu,setAdjustmentDragReadoutPointerPosition:Qn,canvasRef:Zn,autoScrollPanBy:b,autoScrollViewportElement:x,originPickShapeId:cn,updateOriginPickPreviewFromEvent:Fn,setHoverSolidEdge:Qe,mode:Sr,cancelTablePlacement:Bu,restoreTransientInteraction:Bf,setRegionSelection:_e,handledCommandRequestIdRef:Go,queueOverlaySave:Zc,documentId:t,onRequestTextMode:M,retainEmptySelection:_,externalRevision:e,onRequestTextSelection:L,queueDirtyImageCropSave:Ns}),{movingShapeIds:tc,selectedShapes:ro,currentTool:cl,selectionChromeHidden:Hs,selectionImageCropShape:bm,selectedDimensionShapes:ad,selectionBounds:sd,selectionCanResize:C6,selectedLocked:OT,selectionIsGraphCropping:Pg,selectionIsGraph3DEditing:NT,selectionCanRotate:xm,anchorIndicators:cC,marqueeBounds:ul,insertPreview:vm,curveDrawing:ld,curveDrawingClosed:uC,adjustmentDragReadout:Y1,drawingHint:Ev}=_Zn({shapes:G,selectedIds:de,assets:fe,editPolicyLockedShapeIds:mo,mode:Sr,initialOriginPickShapeId:an,selectedRegion:mt,dragOffset:_t,publishesSessionPresence:J,documentSession:K,tShape:te,adjustmentDragReadoutPointerPosition:ti,shapeStyleDefaults:bn,showAnchorHandles:y,anchorMeasurements:bt,canvasWidth:r,canvasHeight:o,bleedValues:a,onSelectionSummaryChange:O,solidEdge:be,acceptsStylePreview:T,setPreview:Oe,shapesRef:xe,selectedIdsRef:Mt,editPolicyLockedShapeIdsRef:Si}),{backgroundVisibleShapes:Lf,chartSourceTables:$1,foregroundVisibleShapes:Mg,selectedIdSet:dC}=qZn({selectedIds:de,preview:he,shapes:G,visibleOriginPickPreview:xr,movingShapeIds:tc,editingShapeId:Gt,graphFillPickShapeId:xt,initialOriginPickShapeId:an,visiblePageRange:p,pageHeightPx:m,pageGapPx:h}),cd=Ze?ro.length:0,{convertSvg:f0,svgConversionMessage:zT}=WXn({documentId:t,shapesRef:xe,assetsRef:Y,extensionsRef:oe,editPolicyLockedShapeIdsRef:Si,explicitlySavedShapeStatesRef:$e,notifyEditPolicyBlocked:ni,setShapes:ie,setAssets:$,setSelectedShapeIds:zs,commitOverlayChangeNow:Lc,readAssetSource:async Ot=>await K?.readAssetSource?.(Ot)??K?.resolveAssetSource?.(Ot)??Ot,tShape:te}),sa=cd>=2,Iv=cd>0&&ro.some(wh),Bg=cd>=2,A6=cd>=3,US=cd===1&&yj(ro[0]),nc=cd===1&&ro[0]?.type==="image"?ro[0]:null,_u=cd===1&&ro[0]?.type==="graph2dShape"?ro[0]:null,bb=cd===1&&ro[0]?.type==="graph3dShape"?ro[0]:null,pC=cd===1&&ro[0]?.type==="tableShape"?ro[0]:null,HS=cd===1&&ro[0]?.type==="chartShape"?ro[0]:null,Pv=!!(nc&&!Ac(G,nc)&&!Js(G,nc,mo)),Lg=!!(_u&&!Ac(G,_u)&&!Js(G,_u,mo)),Z3=!!(bb&&!Ac(G,bb)&&!Js(G,bb,mo)),{handleCanvasContextMenu:m0,handleCanvasDoubleClick:Xp,handleShapeDoubleClick:h0,runContextMenuAction:yc,changeSelectedShapeType:J3}=pKn({shapesRef:xe,selectedIdsRef:Mt,editPolicyLockedShapeIdsRef:Si,notifyEditPolicyBlocked:ni,setShapes:ie,transitionMode:Fi,queueOverlaySave:Zc,extendedActionRunnerRef:p0,applyQuickTransformToSelectedShapes:NS,startImageCrop:Mu,requestImageReplacement:pu,resetImageCrop:wo,restoreImageNaturalSize:Va,createChartFromTable:dh,handleCurveDrawingDoubleClick:Zr,suppressNextShapeDoubleClickRef:dm,graphFillPickShapeId:xt,pagePointFromClient:Jn,focusedGroupIdRef:Ct,setFocusedGroupId:gt,setSelectedShapeIds:zs,selectShape:vl,modeRef:qi,getShapeAtPoint:fu,getOpenStrokeShapeAtPoint:Ru,getEditableTextShapeAtPoint:rp,setContextMenu:vt,focusOverlayCanvas:Ke}),{handleTableChange:T6,handleTableEditorFocus:fh,handleTableFirstCellReady:xb,handleTableResize:GS,handleTextMeasuredHeight:Mv,handleTextChange:vb,handleTextEditorCancel:Sb,handleTextEditorFocus:IN,handleGraphSpecChange:PN,handleGraphCropEnd:D6}=NZn({activeTextEditorRef:ma,selectShape:vl,transitionMode:Fi,shapesRef:xe,updateShape:Dd,updateGraphShapeSpec:mm,insertedTableFocusRef:qe}),fC=Ot=>yi(Ot).y+(tc?.has(Ot.id)?_t?.y??0:0),Rg=(sd?.y??0)+(tc?_t?.y??0:0),UT=XJn({onCreateChartFromTable:dh,onGraph3DCameraChange:Vp,onGraph3DObjectRotationChange:zl,onGraph3DObjectTransformChange:hb,onGraph3DPreviewReady:ph,onTableChange:T6,onTableEditorFocus:fh,onTableFirstCellReady:xb,onTableResize:GS,onTextMeasuredHeight:Mv,onTextChange:vb,onTextEditorCancel:Sb,onTextEditorFocus:IN});return gl("div",{ref:Kn,className:"overlay-canvas-bleed-surface",onPointerDownCapture:Ot=>{nn(Ot),rn(Ot)},onPointerDown:pi,onPointerMove:Ul,onPointerCancel:ym,onPointerLeave:()=>{Qe(null),cn&&hn(null)},onPointerUp:K1,onContextMenu:m0,onDoubleClick:Xp,tabIndex:-1,children:Xri("div",{ref:Zn,className:["overlay-canvas-editor",cn?"origin-picking":"",an?"initial-origin-picking":"",xt?"graph-fill-picking":"",cl.kind==="insert"?"inserting":""].filter(Boolean).join(" "),"data-overlay-insert-command":cl.kind==="insert"?cl.command:void 0,children:[cl.kind==="insert"&&i&&gl("div",{className:"overlay-insertion-surface","aria-hidden":"true",style:{left:i.x,top:i.y,width:i.w,height:i.h}}),gl("input",{ref:q1,type:"file",accept:uNe,hidden:!0,"data-testid":"overlay-image-replacement-input",onChange:Ot=>{ec(Ot)}}),S&&Lf.length>0&&xze(gl("div",{className:"overlay-canvas-bleed-surface background","aria-hidden":"true",children:gl("div",{className:"overlay-canvas-editor background",children:Lf.map(Ot=>gl(Gd,{arrangement:to,y:fC(Ot),children:gl(GNe,{shape:Ot,assets:fe,chartSourceTable:$1.get(Ot.id)??null,externalRevision:Bo,selected:!1,editing:!1,disableGraphCrop:!0,hideGraphAxes:!1,originPickPreview:null,dragTranslate:tc?.has(Ot.id)?_t:null,onPointerDown:GCt,onDoubleClick:jCt,onGraphSpecChange:Mye,onGraphCropEnd:Bye,diffClassName:ee?.get(Ot.id),decoration:Z?.get(Ot.id)??null,textPaintRevision:qJn(Ot,f)})},Ot.id))})}),S),Mg.map(Ot=>gl(Gd,{arrangement:to,y:fC(Ot),children:gl(GNe,{shape:Ot,assets:fe,chartSourceTable:$1.get(Ot.id)??null,externalRevision:Bo,selected:dC.has(Ot.id),editing:Gt===Ot.id,disableGraphCrop:!!xt,hideGraphAxes:an===Ot.id,originPickPreview:xr?.shapeId===Ot.id?xr:null,dragTranslate:tc?.has(Ot.id)?_t:null,onPointerDown:Ba,onDoubleClick:h0,onGraphSpecChange:PN,onGraphCropEnd:D6,diffClassName:ee?.get(Ot.id),decoration:Z?.get(Ot.id)??null,editorRenderers:UT,onTextMeasuredHeight:Mv,textPaintRevision:qJn(Ot,f)})},Ot.id)),gl(Gd,{arrangement:to,y:Rg,children:gl(aWn,{shapes:Hs||bm?[]:ad,dragTranslate:_t,movingShapeIds:tc})}),Lf.map(Ot=>gl(Gd,{arrangement:to,y:fC(Ot),children:gl(sWn,{shape:Ot,selected:dC.has(Ot.id),dragTranslate:tc?.has(Ot.id)?_t:null,onPointerDown:Ba,onDoubleClick:h0})},`${Ot.id}-hit-target`)),sd&&ro.length>0&&!Hs&&gl(Gd,{arrangement:to,y:Rg,children:gl(MWn,{shapes:ro,allShapes:G,bounds:sd,resizable:C6&&!OT&&!Pg&&!NT,rotatable:xm&&!OT&&!Pg&&!NT,cropShape:bm,dragTranslate:_t,movingShapeIds:tc,onResizePointerDown:ts,onImageCropResizePointerDown:ke,onRotatePointerDown:fi,onPointPointerDown:Ig,onLineInsertPointerDown:aa,solidEdge:be&&ro.length===1&&ro[0].id===be.shapeId?be.index:null,solidHoverEdge:Re&&ro.length===1&&ro[0].id===Re.shapeId?Re.index:null})}),cC.length>0&&!Hs&&!bm&&gl(PWn,{indicators:cC,onAnchorPointerDown:ip,arrangement:to}),ul&&gl(Gd,{arrangement:to,y:ul.y,children:gl("div",{className:"overlay-marquee-box","data-retained-region":mt?"true":void 0,style:{left:ul.x,top:ul.y,width:ul.w,height:ul.h}})}),Sr.id==="overlay.select"&&cl.kind==="insert"&&cl.command==="table"&&!_ye()&&gl(cWn,{tool:cl,surfaceRef:Kn,pointFromClient:Jn,assets:fe,styleDefaults:J9("table",bn),arrangement:to}),vm&&!(vm.tool.command==="table"&&_ye())&&gl(Gd,{arrangement:to,y:vm.start.y,children:gl(XCt,{tool:vm.tool,start:vm.start,current:vm.current,points:vm.points,closed:vm.closed,bounds:vm.bounds,assets:fe,styleDefaults:J9(vm.tool.command,bn)})}),ld&&gl(Gd,{arrangement:to,y:ld.points[0]?.y??ld.current?.y??0,children:gl(dWn,{points:ld.points,current:ld.current,closeArmed:uC})}),Y1&&gl(Gd,{arrangement:to,y:Y1.position.y,children:gl(mWn,{...Y1})}),Kt.length>0&&gl(Gd,{arrangement:to,y:Rg,children:gl(Vri,{guides:Kt})}),es&&gl("p",{className:ne.blockedNoticeClassName,role:"status","aria-live":"polite",children:es}),Ev!==null&&typeof document<"u"&&xze(gl("div",{className:"overlay-drawing-hint",role:"status","data-testid":"overlay-drawing-hint",children:Ev}),document.body),zT&&typeof document<"u"&&xze(gl("div",{className:"overlay-drawing-hint",role:"status","aria-live":"polite","data-testid":"svg-conversion-message",children:zT}),document.body),Ze&&cd>0&&typeof document<"u"&&xze(gl(EXn,{x:Ze.x,y:Ze.y,canGroup:sa,canUngroup:Iv,canAlign:Bg,canDistribute:A6,canChangeShapeType:US,imageHasCrop:!!nc?.props.crop,imageEditable:Pv,imageOpacity:Yo(nc?.opacity??1,0,1),graphEditable:Lg,graphCanFill:_u?.props.spec.kind==="cartesian",graph3dEditable:Z3,onCreateChartFromTable:pC?()=>yc(()=>{dh(pC.id)}):void 0,onChartSettings:HS?()=>yc(()=>{zs([HS.id]),window.dispatchEvent(new CustomEvent(w_,{detail:{shapeId:HS.id}}))}):void 0,onGraph3DSettings:bb?()=>yc(()=>{zs([bb.id]),Fi({type:"editGraph3D",shapeId:bb.id}),window.dispatchEvent(new CustomEvent(lE,{detail:{shapeId:bb.id}}))}):void 0,onGraphSettings:_u?()=>yc(()=>{window.dispatchEvent(new CustomEvent(Pj,{detail:{shapeId:_u.id}}))}):void 0,onGraphCrop:_u?()=>yc(()=>{zs([_u.id]),Fi({type:"editGraph",shapeId:_u.id})}):void 0,onGraphOriginPick:_u?()=>yc(()=>{zs([_u.id]),Fi({type:"pickOrigin",shapeId:_u.id})}):void 0,onGraphFillPick:_u?()=>yc(()=>{zs([_u.id]),Fi({type:"pickGraphFill",shapeId:_u.id})}):void 0,onImageCrop:nc?()=>yc(()=>Mu(nc.id)):void 0,onImageReplace:nc?()=>yc(()=>pu(nc.id)):void 0,onImageResetCrop:nc?()=>yc(()=>wo(nc.id)):void 0,onImageNaturalSize:nc?()=>yc(()=>Va(nc.id)):void 0,onSvgConvert:nc&&sz(fe[nc.props.assetId])?()=>yc(()=>{f0(nc.id)}):void 0,onImageOpacityChange:nc?Ot=>Us(nc.id,Ot):void 0,onDuplicate:()=>yc(()=>Ss()),onDelete:()=>yc(od),onGroup:()=>yc(op),onUngroup:()=>yc(mu),arrangeShortcutLabels:A,onArrange:Ot=>yc(()=>Nl(Ot)),onTransform:Ot=>yc(()=>NS(Ot)),onAlign:Ot=>yc(()=>Dg(Ot)),onDistribute:Ot=>yc(()=>id(Ot)),onChangeShapeType:Ot=>yc(()=>J3(Ot)),onSaveAsMaterial:U?()=>yc(U):void 0}),document.body)]})})}function Vri({guides:e}){let t=e.filter(n=>n.type==="line");return t.length===0?null:gl("svg",{className:"overlay-snap-guides","aria-hidden":"true",children:t.map((n,r)=>gl("line",{className:"overlay-snap-guide-line",x1:n.axis==="x"?n.value:n.start,y1:n.axis==="x"?n.start:n.value,x2:n.axis==="x"?n.value:n.end,y2:n.axis==="x"?n.end:n.value},`line-${n.axis}-${n.value}-${r}`))})}var Hri,uDt,Gri,jri,Bbe=X(()=>{"use strict";"use client";IXn();qXn();Wce();XNe();gWn();KNe();gte();tAt();aAt();Oye();fKn();gKn();MKn();UKn();WKn();YKn();j$n();W$n();K$n();Q$n();sZn();cZn();dZn();mZn();bZn();SZn();FZn();AZn();MZn();OZn();zZn();HZn();WZn();KZn();u4();sE();Bj();Pn();Dn();un();tj();My();A_();RTt();$Zn();I9e();JZn();eJn();Tc();yte();jh();Ly();M9e();WJn();vte();fte();bte();Yx();m_();dj();v_();cDt();vte();DTt();sze();sze();Hri=14,uDt=8,Gri=16,jri={rects:new Map,ordered:[]}});var gHe=Fo((Ssr,WEt)=>{(function(e){typeof Ssr=="object"&&typeof WEt<"u"?WEt.exports=e():typeof define=="function"&&define.amd?define([],e):(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).JSZip=e()})(function(){return(function e(t,n,r){function o(s,l){if(!n[s]){if(!t[s]){var c=typeof Ng=="function"&&Ng;if(!l&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(p){var f=t[s][1][p];return o(f||p)},d,d.exports,e,t,n,r)}return n[s].exports}for(var i=typeof Ng=="function"&&Ng,a=0;a<r.length;a++)o(r[a]);return o})({1:[function(e,t,n){"use strict";var r=e("./utils"),o=e("./support"),i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(a){for(var s,l,c,u,d,p,f,m=[],h=0,g=a.length,y=g,b=r.getTypeOf(a)!=="string";h<a.length;)y=g-h,c=b?(s=a[h++],l=h<g?a[h++]:0,h<g?a[h++]:0):(s=a.charCodeAt(h++),l=h<g?a.charCodeAt(h++):0,h<g?a.charCodeAt(h++):0),u=s>>2,d=(3&s)<<4|l>>4,p=1<y?(15&l)<<2|c>>6:64,f=2<y?63&c:64,m.push(i.charAt(u)+i.charAt(d)+i.charAt(p)+i.charAt(f));return m.join("")},n.decode=function(a){var s,l,c,u,d,p,f=0,m=0,h="data:";if(a.substr(0,h.length)===h)throw new Error("Invalid base64 input, it looks like a data url.");var g,y=3*(a=a.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(a.charAt(a.length-1)===i.charAt(64)&&y--,a.charAt(a.length-2)===i.charAt(64)&&y--,y%1!=0)throw new Error("Invalid base64 input, bad content length.");for(g=o.uint8array?new Uint8Array(0|y):new Array(0|y);f<a.length;)s=i.indexOf(a.charAt(f++))<<2|(u=i.indexOf(a.charAt(f++)))>>4,l=(15&u)<<4|(d=i.indexOf(a.charAt(f++)))>>2,c=(3&d)<<6|(p=i.indexOf(a.charAt(f++))),g[m++]=s,d!==64&&(g[m++]=l),p!==64&&(g[m++]=c);return g}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var r=e("./external"),o=e("./stream/DataWorker"),i=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function s(l,c,u,d,p){this.compressedSize=l,this.uncompressedSize=c,this.crc32=u,this.compression=d,this.compressedContent=p}s.prototype={getContentWorker:function(){var l=new o(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),c=this;return l.on("end",function(){if(this.streamInfo.data_length!==c.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),l},getCompressedWorker:function(){return new o(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},s.createWorkerFrom=function(l,c,u){return l.pipe(new i).pipe(new a("uncompressedSize")).pipe(c.compressWorker(u)).pipe(new a("compressedSize")).withStreamInfo("compression",c)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var r=e("./utils"),o=(function(){for(var i,a=[],s=0;s<256;s++){i=s;for(var l=0;l<8;l++)i=1&i?3988292384^i>>>1:i>>>1;a[s]=i}return a})();t.exports=function(i,a){return i!==void 0&&i.length?r.getTypeOf(i)!=="string"?(function(s,l,c,u){var d=o,p=u+c;s^=-1;for(var f=u;f<p;f++)s=s>>>8^d[255&(s^l[f])];return-1^s})(0|a,i,i.length,0):(function(s,l,c,u){var d=o,p=u+c;s^=-1;for(var f=u;f<p;f++)s=s>>>8^d[255&(s^l.charCodeAt(f))];return-1^s})(0|a,i,i.length,0):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var r=null;r=typeof Promise<"u"?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){"use strict";var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=e("pako"),i=e("./utils"),a=e("./stream/GenericWorker"),s=r?"uint8array":"array";function l(c,u){a.call(this,"FlateWorker/"+c),this._pako=null,this._pakoAction=c,this._pakoOptions=u,this.meta={}}n.magic="\b\0",i.inherits(l,a),l.prototype.processChunk=function(c){this.meta=c.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(s,c.data),!1)},l.prototype.flush=function(){a.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var c=this;this._pako.onData=function(u){c.push({data:u,meta:c.meta})}},n.compressWorker=function(c){return new l("Deflate",c)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function r(d,p){var f,m="";for(f=0;f<p;f++)m+=String.fromCharCode(255&d),d>>>=8;return m}function o(d,p,f,m,h,g){var y,b,x=d.file,v=d.compression,S=g!==s.utf8encode,F=i.transformTo("string",g(x.name)),w=i.transformTo("string",s.utf8encode(x.name)),C=x.comment,A=i.transformTo("string",g(C)),T=i.transformTo("string",s.utf8encode(C)),D=w.length!==x.name.length,k=T.length!==C.length,P="",I="",B="",M=x.dir,L=x.date,_={crc32:0,compressedSize:0,uncompressedSize:0};p&&!f||(_.crc32=d.crc32,_.compressedSize=d.compressedSize,_.uncompressedSize=d.uncompressedSize);var R=0;p&&(R|=8),S||!D&&!k||(R|=2048);var O=0,N=0;M&&(O|=16),h==="UNIX"?(N=798,O|=(function(U,H){var V=U;return U||(V=H?16893:33204),(65535&V)<<16})(x.unixPermissions,M)):(N=20,O|=(function(U){return 63&(U||0)})(x.dosPermissions)),y=L.getUTCHours(),y<<=6,y|=L.getUTCMinutes(),y<<=5,y|=L.getUTCSeconds()/2,b=L.getUTCFullYear()-1980,b<<=4,b|=L.getUTCMonth()+1,b<<=5,b|=L.getUTCDate(),D&&(I=r(1,1)+r(l(F),4)+w,P+="up"+r(I.length,2)+I),k&&(B=r(1,1)+r(l(A),4)+T,P+="uc"+r(B.length,2)+B);var z="";return z+=`
8839
+ `),onChange:l=>a("polyhedron",c=>({...c,faces:xei(l.target.value,c.faces)}))})]})]}),t.kind==="point"&&br($2,{children:[Bt(TP,{rows:[{label:qt("graph3dUi.coordinates"),vector:t.position,onChange:l=>a("point",c=>({...c,position:l}))}]}),Bt(dF,{label:qt("graph3dUi.pointSize"),value:t.radius??.08,min:.01,max:1,step:.01,onChange:l=>a("point",c=>({...c,radius:l}))})]}),t.kind==="segment"&&Bt(TP,{rows:[{label:qt("graph3dUi.startPoint"),vector:t.from,onChange:l=>a("segment",c=>({...c,from:l}))},{label:qt("graph3dUi.endPoint"),vector:t.to,onChange:l=>a("segment",c=>({...c,to:l}))}]}),t.kind==="plane"&&br($2,{children:[br("div",{className:Sn.field,children:[Bt("span",{children:qt("graph3dUi.definitionMethod")}),Bt(Aa,{"aria-label":qt("graph3dUi.planeDefinitionMethod"),value:t.plane.kind,options:[{value:"equation",label:qt("graph3dUi.equation")},{value:"threePoints",label:qt("graph3dUi.threePoints")},{value:"pointNormal",label:qt("graph3dUi.pointAndNormal")}],onChange:l=>a("plane",c=>({...c,plane:CAt(l)}))})]}),t.plane.kind==="threePoints"&&Bt(TP,{rows:t.plane.points.map((l,c)=>({label:qt("graph3dFormat.point",{index:c+1}),vector:l,onChange:u=>a("plane",d=>{if(d.plane.kind!=="threePoints")return d;let p=[...d.plane.points];return p[c]=u,{...d,plane:{kind:"threePoints",points:p}}})}))}),t.plane.kind==="pointNormal"&&Bt(TP,{rows:[{label:qt("graph3dUi.pointOnPlane"),vector:t.plane.point,onChange:l=>a("plane",c=>c.plane.kind==="pointNormal"?{...c,plane:{...c.plane,point:l}}:c)},{label:qt("graph3dUi.normal"),vector:t.plane.normal,onChange:l=>a("plane",c=>c.plane.kind==="pointNormal"?{...c,plane:{...c.plane,normal:l}}:c)}]})]}),t.kind!=="point"&&t.kind!=="segment"&&br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:qt("graph3dUi.placementSection")}),Bt(TP,{rows:[{label:qt("graph3dUi.translation"),vector:t.translation??jd("0","0","0"),onChange:l=>i(c=>({...c,translation:l}))},{label:qt("graph3dUi.scale"),vector:t.scale??jd("1","1","1"),onChange:l=>i(c=>({...c,scale:l}))},{label:qt("graph3dUi.rotation"),vector:t.rotation??jd("0","0","0"),onChange:l=>i(c=>({...c,rotation:l}))}]}),Bt("p",{className:Sn.axisHint,children:qt("graph3dUi.rotationRadiansHint")})]}),br(Cn,{tone:"danger",size:"sm",onClick:()=>o(t.id),children:[Bt(Ro,{size:14})," ",qt("graph3dUi.deleteObject")]})]})}),iei=$ye(function({object:t,variables:n,caption:r}){let o=Z2(null),i=qye(()=>{try{let l=W5(Eot(t),n);return hke(l,TAt,DAt)}catch{return null}},[t,n]),a=t.style?.color??"#64748b";pF(()=>{kAt(o.current,i,a)},[a,i]);let s=!i||i.faces.length===0&&i.polylines.length===0&&i.points.length===0;return br("div",{className:Sn.objectOverview,children:[br("div",{className:Sn.objectThumbnailFrame,children:[Bt("canvas",{ref:o,className:Sn.objectThumbnail,role:"img","aria-label":qt("graph3dFormat.outline",{name:t.name||Yye(t.kind)})}),s&&Bt("span",{className:Sn.objectThumbnailFallback,children:"3D"})]}),br("div",{className:Sn.objectOverviewText,children:[Bt("span",{className:Sn.widgetSummary,children:Yye(t.kind)}),r&&Bt(hl,{className:Sn.objectFormula,tex:r})]})]})}),TAt=132,DAt=86;lei=$ye(function({region:t,objects:n,variables:r,onChange:o,onDelete:i,onInsertImage:a,onInsertSpec:s}){let l=g=>o(t.id,g),c=AAt(t),u=g=>l(y=>({...y,fill:{...AAt(y),...g}})),d=qye(()=>t.objectIds.map(g=>n.find(y=>y.id===g)).filter(g=>g!==void 0),[n,t.objectIds]),p=t.label||qt("graph3d.intersectionFallback"),f=uei(d,r,t.resolution),m=f.kind==="section",h=(g,y)=>l(b=>({...b,objectIds:y?[...b.objectIds.filter(x=>x!==g),g]:b.objectIds.filter(x=>x!==g)}));return br(Cte,{label:qt("graph3dFormat.details",{name:p}),openDetailsOnCardHover:!0,visibility:{visible:t.visible!==!1,onChange:g=>l(y=>({...y,visible:g}))},title:Bt("input",{className:Sn.titleInput,"aria-label":qt("graph3dUi.intersectionName"),value:p,onChange:g=>l(y=>({...y,label:g.target.value}))}),summary:Bt(pei,{result:f,color:c.color}),children:[br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:qt("graph3dUi.appearance")}),br("div",{className:Sn.styleRow,children:[Bt(Mj,{label:qt("graph3dUi.fillColor"),value:c.color,onChange:g=>u({color:g})}),Bt(dF,{label:qt("graph3dUi.opacity"),value:c.opacity??.55,min:0,max:1,step:.05,onChange:g=>u({opacity:g})}),Bt(zte,{label:qt("graph3dUi.outline"),checked:t.showEdges!==!1,onChange:g=>l(y=>({...y,showEdges:g}))}),Bt(Mj,{label:qt("graph3dUi.outlineColor"),value:t.edgeColor??c.color,disabled:t.showEdges===!1,onChange:g=>l(y=>({...y,edgeColor:g}))})]})]}),br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:qt("graph3dUi.intersectionShapes")}),br(_n,{className:Sn.memberList,gap:"xs",children:[n.length===0&&Bt(Nte,{children:qt("graph3dUi.intersectionShapesEmpty")}),n.map(g=>Bt(zte,{label:g.name||Yye(g.kind),checked:t.objectIds.includes(g.id),onChange:y=>h(g.id,y)},g.id))]})]}),br("div",{className:Sn.quickControlGrid,children:[br("div",{className:Sn.field,children:[Bt("span",{children:qt("graph3dUi.fillStyle")}),Bt(Aa,{"aria-label":qt("graph3dUi.intersectionFillStyle"),value:c.mode,options:[{value:"solid",label:qt("graph3dUi.fillSolid")},{value:"pattern",label:qt("graph3dUi.fillHatching")}],onChange:g=>l(y=>{let b=AAt(y),x=Zqn(g,b.color);return{...y,fill:x.mode==="none"?x:{...x,opacity:b.opacity}}})})]}),Bt(dF,{label:qt("graph3dUi.plotCount"),value:t.resolution??26,min:8,max:G9,step:1,onChange:g=>l(y=>({...y,resolution:Math.round(g)}))})]}),br("fieldset",{className:Sn.fieldset,children:[Bt("legend",{children:qt("graph3dUi.insertIntoDocument")}),br(fr,{gap:"xs",wrap:!0,children:[br(Cn,{size:"sm",disabled:!m,onClick:()=>a(t.id),children:[Bt(lue,{size:14})," ",qt("graph3dUi.insertPlaneAsImage")]}),br(Cn,{size:"sm",disabled:f.kind==="empty"||f.kind==="error",onClick:()=>s(t.id),children:[Bt(Zce,{size:14})," ",qt("graph3dUi.insertIntersectionAs3d")]})]}),!m&&Bt(Nte,{children:qt("graph3dUi.insertImageOnlyPlanar")})]}),Bt("p",{className:Sn.axisHint,children:qt("graph3dUi.intersectionResultExplainer")}),br(Cn,{tone:"danger",size:"sm",onClick:()=>i(t.id),children:[Bt(Ro,{size:14})," ",qt("graph3dUi.deleteIntersection")]})]})});pei=$ye(function({result:t,color:n}){let r=Z2(null);return pF(()=>{kAt(r.current,t.drawing,n)},[n,t.drawing]),br("div",{className:Sn.objectOverview,children:[br("div",{className:Sn.objectThumbnailFrame,children:[Bt("canvas",{ref:r,className:Sn.objectThumbnail,role:"img","aria-label":qt("graph3dUi.intersectionPreview")}),!t.drawing&&Bt("span",{className:Sn.objectThumbnailFallback,children:"\u2014"})]}),Bt("div",{className:Sn.objectOverviewText,children:Bt("span",{className:Sn.widgetSummary,children:t.status})})]})});fei={expression:"x^2+y^2",equation:"x+y=1",inequality:"x+y+z \\leqq 3"};yei=$ye(function({annotation:t,onChange:n,onDelete:r}){return br(Cte,{label:qt("graph3dFormat.details",{name:t.kind==="dimension"?qt("graph3dUi.dimensionLine"):qt("graph3dUi.mathLabel")}),title:Bt("strong",{children:t.kind==="dimension"?qt("graph3dUi.dimensionLine"):qt("graph3dUi.mathLabel")}),summary:Bt(wP,{tex:t.labelTex,ariaLabel:qt("graph3dUi.labelFormula"),placeholderTex:"\\ell",onCommit:o=>n({...t,labelTex:o})}),controls:t.kind==="dimension"?br(fr,{className:Sn.dimensionStyle,gap:"sm",wrap:!0,align:"end",children:[Bt(aKn,{lineStyle:t.lineStyle??"solid",endStyle:aK(t.endStyle),onLineStyleChange:o=>n({...t,lineStyle:o}),onEndStyleChange:o=>n({...t,endStyle:o})}),Bt(dF,{label:qt("graph3dUi.lineWidth"),value:t.lineWidth??1.5,min:.5,max:12,step:.5,onChange:o=>n({...t,lineWidth:o})})]}):void 0,children:[Bt(Mj,{label:qt("graph3dUi.textAndLineColor"),value:t.color??"#1f2937",onChange:o=>n({...t,color:o})}),t.kind==="label"?Bt(TP,{rows:[{label:qt("graph3dUi.showCoordinates"),vector:t.position,onChange:o=>n({...t,position:o})}]}):Bt(TP,{rows:[{label:qt("graph3dUi.startPoint"),vector:t.from,onChange:o=>n({...t,from:o})},{label:qt("graph3dUi.endPoint"),vector:t.to,onChange:o=>n({...t,to:o})}]}),br(Cn,{tone:"danger",size:"sm",onClick:()=>r(t.id),children:[Bt(Ro,{size:14})," ",qt("graph3dUi.deleteAnnotation")]})]})})});function vei(e){return Bd(e)||e.type==="tableShape"}function dKn({shapes:e,point:t,isUnselectable:n,editPolicyLockedIds:r,margin:o=0}){let i=e;for(let a of RK(i))if(!(!Bd(a)||n(a.id)||Ac(i,a)||Js(i,a,r)||!qv(a,t,o)))return a}function E9e(e,t){return vei(e)?e:t()??e}var I9e=X(()=>{"use strict";Pn();Tc()});import{useCallback as Zye,useEffect as Sei}from"react";function pKn({shapesRef:e,selectedIdsRef:t,editPolicyLockedShapeIdsRef:n,notifyEditPolicyBlocked:r,setShapes:o,transitionMode:i,queueOverlaySave:a,extendedActionRunnerRef:s,applyQuickTransformToSelectedShapes:l,startImageCrop:c,requestImageReplacement:u,resetImageCrop:d,restoreImageNaturalSize:p,createChartFromTable:f,handleCurveDrawingDoubleClick:m,suppressNextShapeDoubleClickRef:h,graphFillPickShapeId:g,pagePointFromClient:y,focusedGroupIdRef:b,setFocusedGroupId:x,setSelectedShapeIds:v,selectShape:S,modeRef:F,getShapeAtPoint:w,getOpenStrokeShapeAtPoint:C,getEditableTextShapeAtPoint:A,setContextMenu:T,focusOverlayCanvas:D}){let k=Zye(L=>{let _=AA(e.current,t.current)[0];if(!_||t.current.length!==1||!yj(_))return;if(Ac(e.current,_)||Js(e.current,_,n.current)){Js(e.current,_,n.current)&&r();return}let R=DXn(_,L);R&&(o(O=>{let N=Qr(O.map(z=>z.id===_.id?R:z));return e.current=N,N}),i({type:"select"}),a())},[n,r,a,t,o,e,i]);Sei(()=>{s.current=L=>{if(L.type==="transform"){l(L.action);return}if(L.type==="changeShapeType"){k(L.command);return}if(L.type!=="shapeCommand")return;let[_]=AA(e.current,t.current);if(!(!_||t.current.length!==1))switch(L.command){case"imageCrop":_.type==="image"&&c(_.id);break;case"imageReplace":_.type==="image"&&u(_.id);break;case"imageResetCrop":_.type==="image"&&d(_.id);break;case"imageNaturalSize":_.type==="image"&&p(_.id);break;case"chartFromTable":_.type==="tableShape"&&f(_.id);break;case"chartSettings":_.type==="chartShape"&&window.dispatchEvent(new CustomEvent(w_,{detail:{shapeId:_.id}}));break;case"graph3dSettings":_.type==="graph3dShape"&&(i({type:"editGraph3D",shapeId:_.id}),window.dispatchEvent(new CustomEvent(lE,{detail:{shapeId:_.id}})));break;case"graphSettings":_.type==="graph2dShape"&&window.dispatchEvent(new CustomEvent(Pj,{detail:{shapeId:_.id}}));break;case"graphCrop":_.type==="graph2dShape"&&i({type:"editGraph",shapeId:_.id});break;case"graphOriginPick":_.type==="graph2dShape"&&i({type:"pickOrigin",shapeId:_.id});break;case"graphFillPick":_.type==="graph2dShape"&&_.props.spec.kind==="cartesian"&&i({type:"pickGraphFill",shapeId:_.id});break}}},[l,k,f,s,u,d,p,t,e,c,i]);let P=Zye((L,_)=>{if(m(L))return;if(window.performance.now()-h.current<500){L.preventDefault(),L.stopPropagation();return}if(g)return;let R=y(L.clientX,L.clientY),O=_.type==="graph2dShape"?0:FNe(_)?wei:8;if(!qv(_,R,O))return;let N=E9e(_,()=>A(R)),z=cF(e.current,N.id,b.current),U=z.length===1?e.current.find(H=>H.id===z[0]):null;if(U&&wh(U)&&b.current!==U.id){x(U.id),v(cF(e.current,N.id,U.id)),i({type:"select"});return}S(N.id),!Ac(e.current,N)&&(Bd(N)?i({type:"editText",shapeId:N.id}):N.type==="image"?i({type:"editImageCrop",shapeId:N.id}):N.type==="graph2dShape"?(L.preventDefault(),L.stopPropagation(),i({type:"editGraph",shapeId:N.id})):N.type==="graph3dShape"?(L.preventDefault(),L.stopPropagation(),i({type:"editGraph3D",shapeId:N.id}),window.dispatchEvent(new CustomEvent(lE,{detail:{shapeId:N.id}}))):N.type==="tableShape"?i({type:"editTable",shapeId:N.id}):N.type==="chartShape"&&(L.preventDefault(),L.stopPropagation(),window.dispatchEvent(new CustomEvent(w_,{detail:{shapeId:N.id}}))))},[b,A,g,m,y,S,x,v,e,h,i]),I=Zye(L=>{if(L.defaultPrevented)return;if(F.current.id==="overlay.curveDrawing"){m(L);return}let _=y(L.clientX,L.clientY),R=w(_,8)??C(_);R&&(L.preventDefault(),L.stopPropagation(),P(L,R))},[C,w,m,P,F,y]),B=Zye(L=>{let _=L.target instanceof Element?L.target:null;if(L.defaultPrevented&&!_?.closest(".overlay-graph3d-live-window")||_?.closest(".overlay-table-context-menu"))return;let R=y(L.clientX,L.clientY),O=w(R,8)??C(R);if(!O){T(null);return}L.preventDefault(),L.stopPropagation(),D();let N=b.current;N&&O.id!==N&&!hte(e.current,O.id,N)&&(b.current=null,x(null));let z=cF(e.current,O.id,b.current),U=new Set(t.current);z.some(H=>U.has(H))||v(z),i({type:"select"}),T({x:Yo(L.clientX,8,Math.max(8,window.innerWidth-232)),y:Yo(L.clientY,8,Math.max(8,window.innerHeight-360)),shapeId:z[0]??O.id})},[D,b,C,w,y,t,T,x,v,e,i]),M=Zye(L=>{L(),T(null),D()},[D,T]);return{handleCanvasContextMenu:B,handleCanvasDoubleClick:I,handleShapeDoubleClick:P,runContextMenuAction:M,changeSelectedShapeType:k}}var wei,fKn=X(()=>{"use strict";"use client";sE();Bj();Pn();Tc();jh();fte();dj();I9e();wei=14});function gs(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((a,s)=>gs(a,t[s]));let n=e,r=t,o=Object.keys(n).filter(a=>n[a]!==void 0),i=Object.keys(r).filter(a=>r[a]!==void 0);return o.length!==i.length?!1:o.every(a=>Object.prototype.hasOwnProperty.call(r,a)&&gs(n[a],r[a]))}var C_=X(()=>{"use strict"});import{useCallback as mKn,useEffect as Fei,useLayoutEffect as Cei}from"react";function hKn({setPreview:e,clearQueuedOverlaySave:t,imageCropDirtyRef:n,suppressNextSaveRef:r,modeRef:o,selectedIdsRef:i,shapesRef:a,assetsRef:s,extensionsRef:l,setShapes:c,setAssets:u,setSelectedIds:d,setAppliedSnapshotRevision:p,transitionMode:f,activeTextEditorRef:m,anchorMeasurementsRef:h,overlay:g,reconciledDocumentSnapshotRef:y,lastEmittedSnapshotRef:b,saveTimeoutRef:x,pendingOverlayHistoryRef:v,externalRevisionRef:S,externalRevision:F,seenDocumentSnapshotRef:w,mode:C}){let A=mKn(D=>{e(null),t(),n.current=!1,r.current=!0;let k=o.current,P=k.id==="overlay.textEditing"?k.shapeId:null,I=Qr(F0(D.shapes,h.current.rects,Qx(D.shapes))),B=new Set(I.map(R=>R.id)),M=P?I.find(R=>R.id===P&&Bd(R)):null,L=i.current.filter(R=>B.has(R)),_=k.id==="overlay.graph3dEditing"&&I.some(R=>R.id===k.shapeId&&R.type==="graph3dShape")?k.shapeId:null;if(a.current=I,s.current=D.assets,l.current=D.extensions,i.current=M?[M.id]:L,c(I),u(D.assets),d(i.current),p(R=>R+1),M)f({type:"editText",shapeId:M.id});else{let R=m.current;R&&!R.isDestroyed&&R.commands.blur(),m.current=null,f({type:"select"}),_&&f({type:"editGraph3D",shapeId:_})}},[m,h,s,t,l,n,o,i,p,u,e,d,c,a,r,f]),T=mKn(()=>{let D=g.overlaySnapshot;if(y.current===D||!D){y.current=D;return}let k=b.current;if(k&&D.shapes===k.shapes&&D.assets===k.assets){y.current=D;return}if(o.current.id!=="overlay.select"||x.current!==void 0||v.current)return;y.current=D;let P=ir(D);gs(Qr(P.shapes),a.current)&&gs(P.assets,s.current)||A(P)},[A,s,b,o,g.overlaySnapshot,v,y,x,a]);Cei(()=>{let D=g.overlaySnapshot,k=S.current!==F,P=w.current!==D;if(S.current=F,w.current=D,k){y.current=D,A(ir(D));return}P&&T()},[A,F,S,g.overlaySnapshot,T,y,w]),Fei(()=>{C.id==="overlay.select"&&T()},[C.id,T])}var gKn=X(()=>{"use strict";"use client";Dt();Pn();C_();v_();Tc()});var Lj,P9e=X(()=>{"use strict";Lj="sigma:open-tikz-editor"});function yKn(e,t,n){let r=new Set(t);if(r.size===0)return[];let o=new Set(e.filter(i=>i.anchor?.type==="block"&&r.has(i.anchor.blockId)).map(i=>i.id));for(let i of Tei(r,n))for(let a of e)!o.has(a.id)&&xke(a,i)&&o.add(a.id);return o.size===0?[]:xKn(e,Dei(e,o))}function bKn(e){return xKn(e,e.map(t=>t.id))}function xKn(e,t){let n=new Set([...t].map(r=>BCt(e,r,null)));return _5(e).filter(r=>n.has(r.id)).map(r=>r.id)}function Tei(e,t){if(!t)return[];let n=new Map;for(let o of e){let i=t.get(o);if(!i||i.left===void 0||!i.width||!i.height)continue;let a=`${Math.round(i.left)}:${Math.round(i.width)}`,s={x:i.left,y:i.top,w:i.width,h:i.height},l=n.get(a);l?l.push(s):n.set(a,[s])}let r=[];for(let o of n.values()){o.sort((i,a)=>i.y-a.y);for(let i of o){let a=r.at(-1);a&&a.x===i.x&&a.w===i.w&&i.y<=a.y+a.h+Aei?a.h=Math.max(a.h,i.y+i.h-a.y):r.push({...i})}}return r}function Dei(e,t){let n=[...new Set(t)];for(let r=0;r<4;r+=1){let o=kei(e,KDe(e,n));if(o.length===n.length)return o;n=o}return n}function kei(e,t){let n=new Set(t);for(let r=0;r<4;r+=1){let o=n.size;for(let i of e)i.anchor?.type==="shape"&&n.has(i.anchor.shapeId)&&n.add(i.id);if(n.size===o)break}return[...n]}var Aei,vKn=X(()=>{"use strict";Pn();Tc();Aei=4});function Eei(e){switch(e.type){case"startMove":case"startResize":case"startRotate":return e.shapes.map(t=>t.id);case"startAnchorDrag":case"startPoint":case"startImageCropResize":case"startImageCropPan":return[e.shape.id];case"editText":case"editImageCrop":case"editGraph":case"editGraph3D":case"editTable":case"pickOrigin":case"pickGraphFill":return[e.shapeId];default:return[]}}function SKn(e,t,n){if(n.size===0)return!1;let r=Eei(e);if(r.length===0)return!1;let o=new Map(t.map(i=>[i.id,i]));return r.some(i=>{let a=o.get(i);return a?Js(t,a,n):!1})}function Wh(e,t,n){if(n.size===0||t.length===0)return!1;let r=By(e,t,{includeGroups:!0}),o=new Map(e.map(i=>[i.id,i]));return r.some(i=>{let a=o.get(i);return a?Js(e,a,n):!1})}function Hte(e,t){return t?.has(e)??!1}function Rj(e,t,n=[]){return!t||t.size===0?e:e.filter(r=>!t.has(r)&&!By(n,[r],{includeGroups:!0}).some(o=>t.has(o)))}function wKn(e,t,n){let r=Rj(e,n,t);return r.length===e.length?null:r}var A_=X(()=>{"use strict";Tc()});function Gte(){if(typeof window>"u")return _j;try{let e=window.localStorage.getItem(FKn);e!==null&&(_j=Oke(JSON.parse(e)))}catch{}return _j}function CKn(e){if(_j=Oke(e),typeof window<"u")try{window.localStorage.setItem(FKn,JSON.stringify(_j))}catch{}for(let t of EAt)t(_j);return _j}function AKn(e){return EAt.add(e),()=>{EAt.delete(e)}}var FKn,_j,EAt,M9e=X(()=>{"use strict";Pn();FKn="sigma-studio:overlay-shape-style-defaults",_j=nrn;EAt=new Set});function B9e(e){let{shapes:t,marquee:n,focusedGroupId:r,currentIds:o,additive:i}=e,a=pDe(t).filter(s=>xke(s,n)).flatMap(s=>cF(t,s.id,r));return[...new Set(i?[...o,...a]:a)]}var IAt=X(()=>{"use strict";Pn();Tc()});function L9e(e){return e.isComposing||e.key==="Process"||e.keyCode===229}function PAt(e,t,n){let r=new Map(e.map(o=>[o.id,o]));for(let o=0;o<t.length;o+=1){let i=t[o],a=n[o];if(!i||!a)continue;let s=a.x-i.x,l=a.y-i.y;if(s===0&&l===0)continue;let c=wh(i)?By(e,[i.id],{includeGroups:!0}):[i.id];for(let u of c){let d=r.get(u);d&&!Ac(e,d)&&r.set(u,$5(d,s,l))}}return e.map(o=>r.get(o.id)??o)}function DKn(e){let t={...e};return delete t.locked,delete t.hidden,t}function kKn(e){if(e.anchor?.type!=="page")return e;let t={...e};return delete t.anchor,t}function g1(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return e instanceof HTMLInputElement&&(e.type==="file"||e.type==="hidden")?!1:t==="input"||t==="textarea"||e.closest("[contenteditable='true'], math-field")!==null}function jte(e,t,n){let r=new Set(By(e,t,{includeGroups:!1})),o=new Set;for(let i of e)r.has(i.id)&&!Ac(e,i)&&!Js(e,i,n)&&o.add(i.id);return o}var TKn,Vte=X(()=>{"use strict";Pn();Tc();TKn="[data-non-modal-surface], [data-toolbar-popover]"});import{useCallback as EKn,useEffect as IKn}from"react";function PKn({handledActionRequestIdRef:e,duplicateSelectedShapes:t,deleteSelectedShapes:n,arrangeSelectedShapes:r,alignSelectedShapes:o,distributeSelectedShapes:i,groupSelectedShapes:a,ungroupSelectedShapes:s,shapesRef:l,selectedIdsRef:c,setSelectedShapesLocked:u,setSelectedShapesHidden:d,setPreview:p,editPolicyLockedShapeIdsRef:f,editPolicyUnselectableShapeIdsRef:m,solidEdgeRef:h,learnShapeStyleDefaults:g,applyStyleToSelectedShapes:y,applyPastedOverlayShapes:b,setFocusedGroupId:x,setSelectedShapeIds:v,refreshAnchorMeasurements:S,transitionMode:F,extendedActionRunnerRef:w,activeTextEditorRef:C,createShapeFromInsertDrag:A,onActionHandled:T,actionRequest:D,handledSelectPointRequestIdRef:k,focusOverlayCanvas:P,onSelectPointHandled:I,getShapeAtPoint:B,getOpenStrokeShapeAtPoint:M,getEditableTextShapeAtPoint:L,focusedGroupIdRef:_,setShapes:R,queueOverlaySave:O,selectShape:N,documentId:z,selectPointRequest:U,openShapeContextMenu:H}){let V=EKn(Z=>{if(e.current!==Z.id){if(e.current=Z.id,Z.type==="duplicate")t();else if(Z.type==="delete")n();else if(Z.type==="arrange")r(Z.action);else if(Z.type==="align")o(Z.action);else if(Z.type==="distribute")i(Z.axis);else if(Z.type==="group")a();else if(Z.type==="ungroup")s();else if(Z.type==="toggleLock"){let ee=AA(l.current,c.current),J=ee.length>0&&ee.every(te=>Ac(l.current,te));u(!J)}else if(Z.type==="toggleHidden"){let ee=AA(l.current,c.current),J=ee.length>0&&ee.every(te=>mte(l.current,te));d(!J)}else if(Z.type==="style"){if(p(null),jte(l.current,c.current,f.current).size>0){let ee=h.current?{...Z.style,dash:void 0,size:void 0}:Z.style;g(orn(Gte(),ee))}y(Z.style)}else Z.type==="pasteShapes"?b(Z.payload,{anchorBlockIdMap:Z.anchorBlockIdMap,historyGroup:Z.historyGroup,centerAt:Z.centerAt,unbounded:Z.unbounded,pointerClient:Z.pointerClient}):Z.type==="selectShapesForBlocks"?(x(null),v(Z.allShapes?bKn(l.current):yKn(l.current,Z.blockIds,S().rects)),F({type:"select"})):Z.type==="transform"||Z.type==="changeShapeType"||Z.type==="shapeCommand"?w.current?.(Z):Z.type==="insertTextAtPoint"&&(C.current?.commands.blur(),A({kind:"insert",command:"text"},Z.point,Z.point));T(Z.id)}},[e,T,t,n,r,o,i,a,s,l,c,u,d,p,f,y,h,g,b,x,v,S,F,w,C,A]);IKn(()=>{if(D){let Z=window.setTimeout(()=>V(D),0);return()=>window.clearTimeout(Z)}},[D,V]);let ne=EKn(Z=>{if(k.current===Z.id)return;if(k.current=Z.id,Z.startMarquee){if(P(),Z.dragEndPoint){let K=Z.dragEndPoint;if(Math.hypot(K.x-Z.point.x,K.y-Z.point.y)>=3)v(Rj(B9e({shapes:l.current,marquee:{x:Math.min(Z.point.x,K.x),y:Math.min(Z.point.y,K.y),w:Math.abs(K.x-Z.point.x),h:Math.abs(K.y-Z.point.y)},focusedGroupId:_.current,currentIds:c.current,additive:!0}),m?.current));else{let G=B(K,8)??M(K);G?N(G.id):v([])}F({type:"select"}),I(Z.id,!0);return}F({type:"startMarquee",start:Z.point,additive:!0,selectOnClick:!0}),I(Z.id,!0);return}let ee=Z.targetShapeId?l.current.find(K=>K.id===Z.targetShapeId&&!wh(K)&&!mte(l.current,K)&&!Hte(K.id,m?.current)):void 0,J=ee??B(Z.point,8)??M(Z.point),te=J&&Z.startCrop&&!ee?E9e(J,()=>L(Z.point)):J;if(te){if(C.current?.commands.blur(),C.current=null,P(),Z.dragEndPoint){let K=Z.dragEndPoint.x-Z.point.x,G=Z.dragEndPoint.y-Z.point.y;if(Math.hypot(K,G)>=3){let ie=cF(l.current,te.id,_.current),fe=$x(l.current,ie,f.current);if(fe.length>0){let $=new Set(fe.map(re=>re.id)),j=Y9(fe,K,G),{ordered:pe}=S();v(ie),R(re=>{let le=Qr(Jx(Wv(re,j),$,pe));return l.current=le,le}),F({type:"select"}),I(Z.id,!0),O();return}}}F({type:"select"}),N(te.id),Z.openContextMenu&&Z.screenPoint&&H?.(Z.screenPoint,te.id),te.type==="image"&&te.props.tikz&&!te.locked&&!f.current.has(te.id)&&Z.dragEndPoint&&Math.hypot(Z.dragEndPoint.x-Z.point.x,Z.dragEndPoint.y-Z.point.y)<3&&window.dispatchEvent(new CustomEvent(Lj,{detail:{documentId:z,shapeId:te.id}})),Z.startCrop&&te.type==="graph2dShape"?F({type:"editGraph",shapeId:te.id}):Z.startCrop&&Bd(te)?F({type:"editText",shapeId:te.id}):Z.startCrop&&te.type==="tableShape"&&F({type:"editTable",shapeId:te.id}),I(Z.id,!0)}else v([]),F({type:"select"}),I(Z.id,!1)},[k,l,B,M,L,P,F,I,C,N,f,m,_,S,v,R,O,z,H,c]);IKn(()=>{if(U){let Z=window.setTimeout(()=>ne(U),0);return()=>window.clearTimeout(Z)}},[ne,U])}var MKn=X(()=>{"use strict";"use client";Pn();P9e();vKn();I9e();A_();Tc();Ly();M9e();IAt();Vte()});function BKn(e){let t=new Map,n;return(r,o)=>{let i=new Map(r.map(p=>[p.id,p])),a=r.filter(p=>p.type==="graph2dShape"),s=n?.width!==o.width||n?.height!==o.height,l=new Set(a.filter(p=>{let f=t.get(p.id);return s||!f||Array.from(f).some(([m,h])=>i.get(m)!==h)}).map(p=>p.id)),c=l.size>0?Pei(r,e,o,l):r,u=a.length>0?Md(c):c,d=new Map(u.map(p=>[p.id,p]));return t=new Map(u.filter(p=>p.type==="graph2dShape").map(p=>[p.id,Iei(p,d)])),n={...o},u}}function Iei(e,t){let n=new Map,r=e.props,o=[e.id,...Object.values(r.axisLabelTextShapeIds??{}),...Object.values(r.pointLabelTextShapeIdsByPointId??{}),...Object.values(r.annotationTextShapeIdsByAnnotationId??{}),...Object.values(r.labelTextShapeIdsByCurveId??{}),...r.labelTextShapeIds??[]];for(;o.length>0;){let i=o.pop();if(i===void 0||n.has(i))continue;let a=t.get(i);n.set(i,a),a?.parentId&&o.push(a.parentId),a?.anchor?.type==="shape"&&o.push(a.anchor.shapeId)}return n}function Pei(e,t,n={width:1600,height:1200},r){let o=e,i=new Map,a=[];for(let l of e){if(l.type!=="graph2dShape"||r&&!r.has(l.id))continue;let c=l,u=mD(c,e),d=Mei(c,u);if(d.length>0){let g=pte(c,t,{keys:d});if(g.length>0){let y={...u,...Object.fromEntries(g.map(b=>[b.key,b.shape.id]))};u=y,c=Xte(c,y),a.push(...g.map(b=>b.shape))}}Bei(c,u)&&(c=Wte(c));let p=Qye(c,e),f=(c.props.spec.points??[]).filter(g=>!!g.label?.trim()).map(g=>g.id).filter(g=>!p[g]);if(f.length>0){let g=p_(c,t,{pointIds:f});if(g.length>0){let y={...p,...Object.fromEntries(g.map(b=>[b.pointId,b.shape.id]))};c=tbe(c,y),a.push(...g.map(b=>b.shape))}}let m=ebe(c,e),h=(c.props.spec.annotations??[]).filter(g=>!!g.text.trim()).map(g=>g.id).filter(g=>!m[g]);if(h.length>0){let g=f_(c,t,{annotationIds:h});if(g.length>0){let y={...m,...Object.fromEntries(g.map(b=>[b.annotationId,b.shape.id]))};c=nbe(c,y),a.push(...g.map(b=>b.shape))}}if(c.props.spec.showFormulaLabels===!0){let g=Oj(c,e),y=c.props.spec.curves.map(b=>b.id).filter(b=>!g[b]);if(y.length>0){let b=dte(c,t,n,{curveIds:y});b.length>0&&(c=T_(c,{...g,...Object.fromEntries(b.map(x=>[x.curveId,x.shape.id]))}),a.push(...b.map(x=>x.shape)))}}c=xB(c),c!==l&&i.set(l.id,c)}(i.size>0||a.length>0)&&(o=Qr(e.map(l=>i.get(l.id)??l).concat(a)));let s=o;for(let l of s){if(l.type!=="graph2dShape"||r&&!r.has(l.id))continue;let c=i.get(l.id)??l;s=Nj(s,c)}return s}function Mei(e,t){let n=[];return e.props.spec.axes.xLabel?.trim()&&!t.x&&n.push("x"),e.props.spec.axes.yLabel?.trim()&&!t.y&&n.push("y"),e.props.spec.axes.originLabel?.trim()&&!t.origin&&n.push("origin"),n}function Bei(e,t){let n=[];return e.props.spec.axes.xLabel?.trim()&&n.push("x"),e.props.spec.axes.yLabel?.trim()&&n.push("y"),e.props.spec.axes.originLabel?.trim()&&n.push("origin"),n.length>0&&n.every(r=>!!t[r])}function Jye(e,t){return[...Object.values(mD(e,t)).filter(n=>typeof n=="string"),...Object.values(Qye(e,t)),...Object.values(ebe(e,t)),...R9e(e.props.spec,Oj(e,t))]}function LKn(e,t){if(t.length!==1)return null;let n=e.find(r=>r.id===t[0]);return n?.type===lF?n:!n||!ace(n,e)?null:e.find(r=>r.type===lF&&Jye(r,e).includes(n.id))??null}function Qye(e,t){let n=RKn(t),r=new Set((e.props.spec.points??[]).map(i=>i.id)),o={};for(let[i,a]of Object.entries(e.props.pointLabelTextShapeIdsByPointId??{}))!r.has(i)||!n.has(a)||(o[i]=a);return o}function ebe(e,t){let n=RKn(t),r=new Set((e.props.spec.annotations??[]).map(i=>i.id)),o={};for(let[i,a]of Object.entries(e.props.annotationTextShapeIdsByAnnotationId??{}))!r.has(i)||!n.has(a)||(o[i]=a);return o}function Oj(e,t){let n=new Set(t.filter(c=>c.type==="text").map(c=>c.id)),r=new Set(e.props.spec.curves.map(c=>c.id)),o=new Set,i={};for(let[c,u]of Object.entries(e.props.labelTextShapeIdsByCurveId??{}))!r.has(c)||!n.has(u)||(i[c]=u,o.add(u));let a=(e.props.labelTextShapeIds??[]).filter(c=>n.has(c)&&!o.has(c)),s=cXn(e.props.spec).map(c=>c.curveId),l=0;for(let c of s){if(i[c])continue;let u=a[l];if(!u)break;i[c]=u,l+=1}return i}function T_(e,t){return{...e,props:{...e.props,labelTextShapeIds:R9e(e.props.spec,t),labelTextShapeIdsByCurveId:t}}}function Xte(e,t){return{...e,props:{...e.props,axisLabelTextShapeIds:t}}}function tbe(e,t){return{...e,props:{...e.props,pointLabelTextShapeIdsByPointId:t}}}function nbe(e,t){return{...e,props:{...e.props,annotationTextShapeIdsByAnnotationId:t}}}function Wte(e){return{...e,props:{...e.props,spec:{...e.props.spec,axes:{...e.props.spec.axes,xLabel:"",yLabel:"",originLabel:""}}}}}function Nj(e,t,n={}){let r={...t,props:{...t.props,spec:h9(t,e)}},o=mD(t,e),i=pte(r,()=>"",{keys:Object.keys(o).filter(RTe)}),a=Qye(t,e),s=p_(r,()=>"",{pointIds:Object.keys(a)}),l=ebe(t,e),c=f_(r,()=>"",{annotationIds:Object.keys(l)}),u=[...i.map(m=>({key:`axis:${m.key}`,shape:m.shape})),...s.map(m=>({key:`point:${m.pointId}`,shape:m.shape})),...c.map(m=>({key:`annotation:${m.annotationId}`,shape:m.shape}))],d=new Map(u.map(m=>[m.key,m.shape])),p=!1,f=e.map(m=>{if(m.type!=="text")return m;let h=Lei(m.id,o,a,l);if(!h)return m;let g=d.get(h);if(!g)return m.hidden?m:(p=!0,{...m,hidden:!0});let y=g.anchor;if(!y||y.type!=="shape")return m;if(n.preserveExistingPositions){let w=lXn(t,m,g),C=w.anchor;if(!C||C.type!=="shape")return m;let A=Zx(C,m.anchor),T=w.hidden===m.hidden||w.hidden===void 0&&!m.hidden,D=w.x===void 0||w.x===m.x,k=w.y===void 0||w.y===m.y;return A&&T&&D&&k?m:(p=!0,{...m,...w})}let b=m.anchor?.type==="shape"&&m.anchor.shapeId===t.id?{...y,dx:m.anchor.dx,dy:m.anchor.dy}:{...y,dx:y.dx+m.x-g.x,dy:y.dy+m.y-g.y},x=Zx(b,m.anchor),v=!m.hidden;if(x&&v)return m;let S=g.x+b.dx-y.dx,F=g.y+b.dy-y.dy;return p=!0,{...m,x:S,y:F,hidden:void 0,anchor:b}});return Md(p?f:e)}function RKn(e){return new Set(e.filter(t=>t.type==="text").map(t=>t.id))}function Lei(e,t,n,r){let o=Rei(t,e);if(o)return`axis:${o}`;for(let[i,a]of Object.entries(n))if(a===e)return`point:${i}`;for(let[i,a]of Object.entries(r))if(a===e)return`annotation:${i}`;return null}function Rei(e,t){for(let[n,r]of Object.entries(e))if(r===t&&RTe(n))return n;return null}function R9e(e,t){return e.curves.map(n=>t[n.id]).filter(n=>typeof n=="string")}var D_=X(()=>{"use strict";Dt();My();Tc();Ly();Yx()});import{useEffect as _Kn}from"react";function OKn({shapes:e,selectedIds:t,shapesRef:n,setShapes:r,originPickShapeId:o,graphFillPickShapeId:i,setSelectedShapeIds:a,transitionMode:s,setGraphAxisLabelText:l,setGraphAxisLabelTextVisible:c,setGraphCurveFormulaLabelTextVisible:u}){_Kn(()=>{let d=LKn(e,t);if(!d){window.dispatchEvent(new CustomEvent(Ij,{detail:null}));return}let p=d.id,f=mD(d,e),m=LTe(d,e),h=Oj(d,e),g=h9(d,e),y={shapeId:p,spec:g,axisLabelShapeIdsByKey:f,axisLabelTextsByKey:m,formulaLabelShapeIds:R9e(d.props.spec,h),formulaLabelShapeIdsByCurveId:h,pickingOrigin:o===p,pickingFill:i===p,onSpecChange:b=>{r(x=>{let v=x.find(ie=>ie.id===p&&ie.type==="graph2dShape");if(!v)return x;let S=h9(v,x),F=new Set(b.curves.map(ie=>ie.id)),w=Oj(v,x),C={},A=[];for(let[ie,fe]of Object.entries(w))F.has(ie)?C[ie]=fe:A.push(fe);let T=new Map((S.points??[]).map(ie=>[ie.id,ie.label?.trim()??""])),D=new Map((b.points??[]).map(ie=>[ie.id,ie.label?.trim()??""])),k=new Set((b.points??[]).filter(ie=>!!ie.label?.trim()).map(ie=>ie.id)),P=Qye(v,x),I={},B=[];for(let ie of k){let fe=P[ie];fe?I[ie]=fe:B.push(ie)}for(let[ie,fe]of Object.entries(P))k.has(ie)||A.push(fe);let M=new Map((S.annotations??[]).map(ie=>[ie.id,ie.text.trim()])),L=new Map((b.annotations??[]).map(ie=>[ie.id,ie.text.trim()])),_=new Set((b.annotations??[]).filter(ie=>!!ie.text.trim()).map(ie=>ie.id)),R=ebe(v,x),O={},N=[];for(let ie of _){let fe=R[ie];fe?O[ie]=fe:N.push(ie)}for(let[ie,fe]of Object.entries(R))_.has(ie)||A.push(fe);let z=Ele(v,b),U=T_({...v,props:{...v.props,spec:b,boundsMode:"plot",w:z.w,h:z.h}},C),H=p_(U,ff,{pointIds:B});for(let ie of H)I[ie.pointId]=ie.shape.id;U=tbe(U,I);let V=f_(U,ff,{annotationIds:N});for(let ie of V)O[ie.annotationId]=ie.shape.id;U=nbe(U,O);let ne=[...k].filter(ie=>T.get(ie)!==D.get(ie)&&!!I[ie]),Z=new Map(p_(U,()=>"",{pointIds:ne}).map(ie=>[I[ie.pointId],ie.shape.props])),ee=[..._].filter(ie=>M.get(ie)!==L.get(ie)&&!!O[ie]),J=new Map(f_(U,()=>"",{annotationIds:ee}).map(ie=>[O[ie.annotationId],ie.shape.props]));U=xB(U);let te=new Set(A),K=x.filter(ie=>!te.has(ie.id)).map(ie=>{if(ie.id===p)return U;if(ie.type!=="text")return ie;let fe=Z.get(ie.id)??J.get(ie.id);return fe?{...ie,props:{...ie.props,...CNe(fe)}}:ie}).concat(H.map(ie=>ie.shape)).concat(V.map(ie=>ie.shape)),G=Nj(K,U);return n.current=G,G})},onStartOriginPick:()=>{a([p]),s({type:"pickOrigin",shapeId:p})},onStartFillPick:()=>{a([p]),s(i===p?{type:"select"}:{type:"pickGraphFill",shapeId:p})},onAxisLabelChange:(b,x)=>c(p,b,x),onAxisLabelTextChange:(b,x)=>l(p,b,x),onFormulaLabelChange:(b,x)=>u(p,b,x),onStartCrop:()=>{a([p]),s({type:"editGraph",shapeId:p})},onClose:()=>a([])};window.dispatchEvent(new CustomEvent(Ij,{detail:y}))},[i,o,t,l,c,u,a,e,r,n,s]),_Kn(()=>()=>{window.dispatchEvent(new CustomEvent(Ij,{detail:null}))},[])}var NKn=X(()=>{"use strict";"use client";sE();Yx();D_();tE()});import{useCallback as _9e,useEffect as _ei}from"react";function zKn({setShapes:e,canvasWidthRef:t,canvasHeightRef:n,shapesRef:r,queueOverlaySave:o,selectedIds:i,shapes:a,originPickShapeId:s,graphFillPickShapeId:l,setSelectedShapeIds:c,transitionMode:u}){let d=_9e((h,g,y)=>{e(b=>{let x=b.find(A=>A.id===h&&A.type==="graph2dShape");if(!x)return b;let v=Oj(x,b),S=v[g];if(y){if(S)return b;let A=x.props.spec.curves.map(B=>B.id).filter(B=>B===g||!!v[B]),D=dte(x,ff,{width:t.current,height:n.current},{curveIds:A}).find(B=>B.curveId===g);if(!D)return b;let k={...v,[g]:D.shape.id},P=T_(x,k),I=b.map(B=>B.id===h?P:B).concat(D.shape);return r.current=I,I}if(!S)return b;let F={...v};delete F[g];let w=new Set([S]),C=b.filter(A=>!w.has(A.id)).map(A=>A.id!==h||A.type!=="graph2dShape"?A:T_(A,F));return r.current=C,C}),o()},[n,t,o,e,r]),p=_9e((h,g,y)=>{e(b=>{let x=b.find(A=>A.id===h&&A.type==="graph2dShape");if(!x)return b;let v=mD(x,b),S=v[g];if(y){if(S)return b;let A=pte(x,ff,{keys:[g]})[0];if(!A)return b;let T={...v,[g]:A.shape.id},D=Xte(Wte(x),T),k=b.map(P=>P.id===h?D:P).concat(A.shape);return r.current=k,k}let F={...v};delete F[g];let w=new Set(S?[S]:[]),C=b.filter(A=>!w.has(A.id)).map(A=>A.id!==h||A.type!=="graph2dShape"?A:Xte(Wte(A),F));return r.current=C,C}),o()},[o,e,r]),f=_9e((h,g,y)=>{let b=y.trim();e(x=>{let v=x.find(k=>k.id===h&&k.type==="graph2dShape");if(!v)return x;let S=mD(v,x),F=S[g];if(!b){let k={...S};delete k[g];let P=new Set(F?[F]:[]),I=x.filter(B=>!P.has(B.id)).map(B=>B.id!==h||B.type!=="graph2dShape"?B:Xte(Wte(B),k));return r.current=I,I}let w=pte(v,()=>F??ff(),{keys:[g],labelsByKey:{[g]:b}})[0];if(!w)return x;let C={...S,[g]:w.shape.id},A=Xte(Wte(v),C),T=x.map(k=>k.id===h?A:k.id!==F||k.type!=="text"?k:{...k,props:{...k.props,...CNe(w.shape.props)}}).concat(F?[]:[w.shape]),D=Nj(T,A);return r.current=D,D}),o()},[o,e,r]),m=_9e((h,g)=>{e(y=>{let b=y.map(x=>x.id===h&&x.type==="chartShape"?{...x,props:{...x.props,spec:g}}:x);return r.current=b,b}),o()},[o,e,r]);_ei(()=>{let h=i.length===1?a.find(b=>b.id===i[0]):void 0;if(h?.type!=="chartShape"){window.dispatchEvent(new CustomEvent(Mte,{detail:null}));return}let g=h.props.sourceTableShapeId?a.find(b=>b.id===h.props.sourceTableShapeId):void 0,y=g?.type==="tableShape"?g.props.table:null;window.dispatchEvent(new CustomEvent(Mte,{detail:{shapeId:h.id,spec:h.props.spec,data:yK(h.props,y),linked:y!==null,onSpecChange:b=>m(h.id,b)}}))},[m,i,a]),OKn({shapes:a,selectedIds:i,shapesRef:r,setShapes:e,originPickShapeId:s,graphFillPickShapeId:l,setSelectedShapeIds:c,transitionMode:u,setGraphAxisLabelText:f,setGraphAxisLabelTextVisible:p,setGraphCurveFormulaLabelTextVisible:d})}var UKn=X(()=>{"use strict";"use client";sE();Dt();tE();Yx();D_();NKn()});var MAt=X(()=>{"use strict";wK()});function O9e(e){return e.id==="overlay.move"||e.id==="overlay.resize"||e.id==="overlay.point"||e.id==="overlay.marquee"||e.id==="overlay.insertDrag"||e.id==="overlay.anchor"}function N9e(e){return{x:e.origin.x+e.current.x-e.start.x,y:e.origin.y+e.current.y-e.start.y}}function HKn(e,t,n){let r=vNe(t,n.ordered,yi(e).y),o=r?n.rects.get(r.blockId):void 0;if(!r||!o)return null;let i=GVn(r,o,e.y,e.x);return e.anchor?.type==="block"&&e.anchor.reserveSpace!==void 0?{...i,reserveSpace:e.anchor.reserveSpace}:i}function BAt(e,t,n,r){let o=r(t,n),i=y9(o,dl(e),Oi(e),e.flipX,e.flipY),a={x:i.x-e.x,y:i.y-e.y};if(a.x<0||a.x>e.props.w||a.y<0||a.y>e.props.h)return null;let s=sx(e);return{x:s.plotBox.left+a.x/s.scaleX,y:s.plotBox.top+a.y/s.scaleY}}function GKn(e,t){return e===t?!0:!e||!t?!1:e.shapeId===t.shapeId&&e.point.x===t.point.x&&e.point.y===t.point.y&&Oei(e.spec.viewBox,t.spec.viewBox)}function Oei(e,t){return e.xMin===t.xMin&&e.xMax===t.xMax&&e.yMin===t.yMin&&e.yMax===t.yMax}function jKn(e,t){if(e.type==="geo"&&Nc(e)&&t.type==="solidVertex"){let n=TD(e)[t.index];return n?{x:e.x+n.x,y:e.y+n.y}:null}if(e.type==="line"&&t.type==="line"){let n=e.props.points[t.index];return n?{x:e.x+n.x,y:e.y+n.y}:null}if(e.type==="arrow"&&t.type==="arrow"){let n=e.props[t.endpoint];return{x:e.x+n.x,y:e.y+n.y}}return null}function VKn(e,t,n,r){let o=r.ctrlKey?TXn(e):null;return o!==null?vZt(t,n,o):r.shiftKey&&AXn(e)?I5(t,n):h_(e)?MQt(t,n,r.shiftKey):n}function LAt(e,t,n){if(e.x!==t.x||e.y!==t.y||e.props.w!==t.props.w||e.props.h!==t.props.h)return!1;let r=iw(e,n),o=iw(t,n);return r.topLeft.x===o.topLeft.x&&r.topLeft.y===o.topLeft.y&&r.bottomRight.x===o.bottomRight.x&&r.bottomRight.y===o.bottomRight.y}function RAt(e){return e.id==="overlay.imageCropping"?e.shapeId:e.id==="overlay.imageCropResize"||e.id==="overlay.imageCropPan"?e.shape.id:null}var qte=X(()=>{"use strict";Pn();My();MAt();NNe();jh();xP();Yx()});import{useCallback as z9e}from"react";function XKn({shapesRef:e,pagePointFromClient:t,originPickShapeId:n,setOriginPickPreview:r,updateGraphShapeSpec:o,queueOverlaySave:i,transitionMode:a,graphFillPickShapeId:s}){let l=z9e((p,f,m)=>{let h=e.current.find(S=>S.id===p&&S.type==="graph2dShape");if(!h)return null;let g=P5(h),y=qs(g),b=g.width-y.left-y.right,x=g.height-y.top-y.bottom,v=BAt(h,f,m,t);return!v||b<=0||x<=0||v.x<y.left||v.x>g.width-y.right||v.y<y.top||v.y>g.height-y.bottom?null:{shapeId:p,spec:_3n(g,(v.x-y.left)/b,(v.y-y.top)/x),point:v}},[t,e]),c=z9e(p=>{if(!n){r(null);return}let f=l(n,p.clientX,p.clientY);r(m=>GKn(m,f)?m:f)},[l,n,r]),u=z9e(p=>{if(!n)return;let m=(p.target instanceof Element?p.target:null)?.closest(".graph-shape");if(!(m instanceof HTMLElement)||m.id!==n)return;let h=l(n,p.clientX,p.clientY);if(!h){r(null);return}p.preventDefault(),p.stopPropagation(),o(n,h.spec),i(),r(null),a({type:"setTool",tool:{kind:"select"}})},[l,n,i,r,a,o]),d=z9e(p=>{if(!s||p.defaultPrevented)return;let m=(p.target instanceof Element?p.target:null)?.closest(".graph-shape");if(!(m instanceof HTMLElement)||m.id!==s){p.preventDefault(),p.stopPropagation(),a({type:"select"});return}let h=e.current.find(w=>w.id===s&&w.type==="graph2dShape");if(!h)return;let g=P5(h);if(g.kind!=="cartesian")return;let y=()=>{window.dispatchEvent(new CustomEvent(x9e,{detail:{shapeId:s}}))},b=BAt(h,p.clientX,p.clientY,t);if(!b){y();return}let x=qs(g),v;try{v=X0(g)}catch{y();return}p.preventDefault(),p.stopPropagation();let S=yJ(b.x,b.y,v,g,x),F=d4n(g,S,ebt());if(F===g){y();return}o(s,F)},[s,t,e,a,o]);return{updateOriginPickPreviewFromEvent:c,handleOriginPickPointerDown:u,handleGraphFillPickPointerDown:d}}var WKn=X(()=>{"use strict";"use client";sE();Bme();Ak();qte();Yx()});import{useCallback as k_,useEffect as qKn}from"react";function KKn({shapes:e,selectedIds:t,shapesRef:n,assetsRef:r,setShapes:o,setAssets:i,explicitlySavedShapeStatesRef:a,canvasWidthRef:s,canvasHeightRef:l,imageInsertGap:c,queueOverlaySave:u,setSelectedShapeIds:d,transitionMode:p,tShape:f}){let m=k_((F,w,C)=>{o(A=>{let T=A.map(D=>D.id===F&&D.type==="graph3dShape"?{...D,props:{...D.props,spec:w}}:D);return n.current=T,T}),C?.save!==!1&&u()},[u,o,n]),h=k_((F,w)=>{let C=n.current.find(A=>A.id===F&&A.type==="graph3dShape");C&&m(F,{...C.props.spec,camera:w})},[m,n]),g=k_((F,w,C)=>{let A=n.current.find(T=>T.id===F&&T.type==="graph3dShape");A&&m(F,{...A.props.spec,objects:A.props.spec.objects.map(T=>T.id===w?{...T,rotation:C}:T)})},[m,n]),y=k_((F,w,C)=>{let A=n.current.find(T=>T.id===F&&T.type==="graph3dShape");A&&m(F,{...A.props.spec,objects:A.props.spec.objects.map(T=>T.id===w?{...T,...C}:T)})},[m,n]),b=k_((F,w,C,A,T)=>{let D=n.current.find(L=>L.id===F&&L.type==="graph3dShape");if(!D)return;let k=AD(D.props.spec);if(A!==k)return;let P=D.props.previewAssetId??`asset_graph3d_preview_${F}`;if(r.current[P]?.props.src===w&&D.props.previewSourceHash===k)return;let B=Math.max(0,Math.floor((w.split(",")[1]?.length??0)*.75)),M={id:P,type:"image",props:{w:Math.max(1,Math.round(C.width)),h:Math.max(1,Math.round(C.height)),name:T.animated?f("graph3d.animationFileName"):f("graph3d.previewFileName"),isAnimated:T.animated,mimeType:"image/png",src:w,fileSize:B}};i(L=>{let _={...L,[P]:M};return r.current=_,_}),o(L=>{let _=L.map(R=>R.id===F&&R.type==="graph3dShape"?{...R,props:{...R.props,previewAssetId:P,previewSourceHash:k}}:R);return n.current=_,a.current.add(_),_}),u({history:"coalesce"})},[r,a,u,i,o,n,f]),x=k_((F,w)=>{let C=n.current.find(R=>R.id===F);if(!C||C.type!=="graph3dShape")return;let A=w(),T=yi(A.shape),D=C.x+C.props.w+c+T.w<=s.current,k=Math.max(0,Math.min(C.x+(D?C.props.w+c:0),Math.max(0,s.current-T.w))),P=k-C.x,I=D?0:C.props.h+c,B=C.anchor?.type==="block"?C.anchor:null,M=B?C.y+I:Math.max(0,Math.min(C.y+I,Math.max(0,l.current-T.h))),L=B?{...B,...typeof B.dx=="number"?{dx:B.dx+P}:{},dy:B.dy+I,...B.line?{line:{...B.line,dy:B.line.dy+I}}:{}}:void 0,_=Qr([{...A.shape,x:k,y:M,...L?{anchor:L}:{},...C.parentId?{parentId:C.parentId}:{}}]);if(A.asset){let R=A.asset;i(O=>{let N={...O,[R.id]:R};return r.current=N,N})}o(R=>{let O=Qr([...R,..._]);return n.current=O,O}),d(_.map(R=>R.id)),p({type:"select"}),u()},[c,r,l,s,u,i,d,o,n,p]),v=k_((F,w)=>{x(F,()=>{let C={id:ute(),type:"image",props:{w:w.width,h:w.height,name:w.name,isAnimated:!1,mimeType:"image/svg+xml",src:w.dataUrl,fileSize:w.dataUrl.length}};return{asset:C,shape:{id:ff(),type:"image",x:0,y:0,rotation:0,props:{assetId:C.id,w:w.width,h:w.height}}}})},[x]),S=k_((F,w)=>{x(F,()=>{let C=n.current.find(T=>T.id===F),A=C?.type==="graph3dShape"?{w:C.props.w,h:C.props.h}:{w:240,h:200};return{shape:{id:ff(),type:"graph3dShape",x:0,y:0,rotation:0,props:{...A,spec:w}}}})},[x,n]);return qKn(()=>{let F=t.length===1?e.find(A=>A.id===t[0]&&A.type==="graph3dShape"):void 0;if(!F){window.dispatchEvent(new CustomEvent(Ute,{detail:null}));return}let w=F.id,C={shapeId:w,spec:F.props.spec,size:{width:F.props.w,height:F.props.h},onSpecChange:(A,T)=>m(w,A,T),onAnimationPreview:(A,T)=>Xqn({shapeId:w,overrides:A,playing:T}),onInsertImage:A=>v(w,A),onInsertSpec:A=>S(w,A),onClose:()=>d([])};window.dispatchEvent(new CustomEvent(Ute,{detail:C}))},[v,S,m,t,d,e]),qKn(()=>()=>{window.dispatchEvent(new CustomEvent(Ute,{detail:null}))},[]),{handleGraph3DCameraChange:h,handleGraph3DObjectRotationChange:g,handleGraph3DObjectTransformChange:y,handleGraph3DPreviewReady:b}}var YKn=X(()=>{"use strict";"use client";Bj();D9e();Pn();Tc();tE()});var $Kn=X(()=>{"use strict";Pn()});function _At(e){if(!e.props.crop)return e;let t={...e.props};return delete t.crop,{...e,props:t}}function ZKn(e,t,n){if(!t)return e;let r=Dce({w:t.props.w,h:t.props.h},n);return e.props.w===r.w&&e.props.h===r.h?e:{...e,props:{...e.props,...r}}}function JKn(e,t,n,r){let o=e.find(u=>u.id===n&&u.type==="image");if(!o)return{shapes:[...e],assets:{...t}};let i=o.props.assetId,a=_At({...o,props:{...o.props,assetId:r.id}}),s=e.map(u=>u.id===n?a:u),l={...t,[r.id]:r},c=s.some(u=>u.type==="image"&&u.props.assetId===i);return i!==r.id&&!c&&delete l[i],{shapes:s,assets:l}}var QKn=X(()=>{"use strict";$Kn()});var DP=Fo(y1=>{"use strict";var Nei=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function zei(e,t){return Object.prototype.hasOwnProperty.call(e,t)}y1.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(var r in n)zei(n,r)&&(e[r]=n[r])}}return e};y1.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var Uei={arraySet:function(e,t,n,r,o){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),o);return}for(var i=0;i<r;i++)e[o+i]=t[n+i]},flattenChunks:function(e){var t,n,r,o,i,a;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(a=new Uint8Array(r),o=0,t=0,n=e.length;t<n;t++)i=e[t],a.set(i,o),o+=i.length;return a}},Hei={arraySet:function(e,t,n,r,o){for(var i=0;i<r;i++)e[o+i]=t[n+i]},flattenChunks:function(e){return[].concat.apply([],e)}};y1.setTyped=function(e){e?(y1.Buf8=Uint8Array,y1.Buf16=Uint16Array,y1.Buf32=Int32Array,y1.assign(y1,Uei)):(y1.Buf8=Array,y1.Buf16=Array,y1.Buf32=Array,y1.assign(y1,Hei))};y1.setTyped(Nei)});var wYn=Fo($te=>{"use strict";var Gei=DP(),jei=4,eYn=0,tYn=1,Vei=2;function Yte(e){for(var t=e.length;--t>=0;)e[t]=0}var Xei=0,sYn=1,Wei=2,qei=3,Kei=258,jAt=29,lbe=256,obe=lbe+1+jAt,Kte=30,VAt=19,lYn=2*obe+1,zj=15,OAt=16,Yei=7,XAt=256,cYn=16,uYn=17,dYn=18,HAt=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],U9e=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],$ei=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],pYn=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Zei=512,kP=new Array((obe+2)*2);Yte(kP);var rbe=new Array(Kte*2);Yte(rbe);var ibe=new Array(Zei);Yte(ibe);var abe=new Array(Kei-qei+1);Yte(abe);var WAt=new Array(jAt);Yte(WAt);var H9e=new Array(Kte);Yte(H9e);function NAt(e,t,n,r,o){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=o,this.has_stree=e&&e.length}var fYn,mYn,hYn;function zAt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function gYn(e){return e<256?ibe[e]:ibe[256+(e>>>7)]}function sbe(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function ev(e,t,n){e.bi_valid>OAt-n?(e.bi_buf|=t<<e.bi_valid&65535,sbe(e,e.bi_buf),e.bi_buf=t>>OAt-e.bi_valid,e.bi_valid+=n-OAt):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function cE(e,t,n){ev(e,n[t*2],n[t*2+1])}function yYn(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function Jei(e){e.bi_valid===16?(sbe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function Qei(e,t){var n=t.dyn_tree,r=t.max_code,o=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,l=t.stat_desc.max_length,c,u,d,p,f,m,h=0;for(p=0;p<=zj;p++)e.bl_count[p]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<lYn;c++)u=e.heap[c],p=n[n[u*2+1]*2+1]+1,p>l&&(p=l,h++),n[u*2+1]=p,!(u>r)&&(e.bl_count[p]++,f=0,u>=s&&(f=a[u-s]),m=n[u*2],e.opt_len+=m*(p+f),i&&(e.static_len+=m*(o[u*2+1]+f)));if(h!==0){do{for(p=l-1;e.bl_count[p]===0;)p--;e.bl_count[p]--,e.bl_count[p+1]+=2,e.bl_count[l]--,h-=2}while(h>0);for(p=l;p!==0;p--)for(u=e.bl_count[p];u!==0;)d=e.heap[--c],!(d>r)&&(n[d*2+1]!==p&&(e.opt_len+=(p-n[d*2+1])*n[d*2],n[d*2+1]=p),u--)}}function bYn(e,t,n){var r=new Array(zj+1),o=0,i,a;for(i=1;i<=zj;i++)r[i]=o=o+n[i-1]<<1;for(a=0;a<=t;a++){var s=e[a*2+1];s!==0&&(e[a*2]=yYn(r[s]++,s))}}function eti(){var e,t,n,r,o,i=new Array(zj+1);for(n=0,r=0;r<jAt-1;r++)for(WAt[r]=n,e=0;e<1<<HAt[r];e++)abe[n++]=r;for(abe[n-1]=r,o=0,r=0;r<16;r++)for(H9e[r]=o,e=0;e<1<<U9e[r];e++)ibe[o++]=r;for(o>>=7;r<Kte;r++)for(H9e[r]=o<<7,e=0;e<1<<U9e[r]-7;e++)ibe[256+o++]=r;for(t=0;t<=zj;t++)i[t]=0;for(e=0;e<=143;)kP[e*2+1]=8,e++,i[8]++;for(;e<=255;)kP[e*2+1]=9,e++,i[9]++;for(;e<=279;)kP[e*2+1]=7,e++,i[7]++;for(;e<=287;)kP[e*2+1]=8,e++,i[8]++;for(bYn(kP,obe+1,i),e=0;e<Kte;e++)rbe[e*2+1]=5,rbe[e*2]=yYn(e,5);fYn=new NAt(kP,HAt,lbe+1,obe,zj),mYn=new NAt(rbe,U9e,0,Kte,zj),hYn=new NAt(new Array(0),$ei,0,VAt,Yei)}function xYn(e){var t;for(t=0;t<obe;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Kte;t++)e.dyn_dtree[t*2]=0;for(t=0;t<VAt;t++)e.bl_tree[t*2]=0;e.dyn_ltree[XAt*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function vYn(e){e.bi_valid>8?sbe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function tti(e,t,n,r){vYn(e),r&&(sbe(e,n),sbe(e,~n)),Gei.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function nYn(e,t,n,r){var o=t*2,i=n*2;return e[o]<e[i]||e[o]===e[i]&&r[t]<=r[n]}function UAt(e,t,n){for(var r=e.heap[n],o=n<<1;o<=e.heap_len&&(o<e.heap_len&&nYn(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!nYn(t,r,e.heap[o],e.depth));)e.heap[n]=e.heap[o],n=o,o<<=1;e.heap[n]=r}function rYn(e,t,n){var r,o,i=0,a,s;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+i*2]<<8|e.pending_buf[e.d_buf+i*2+1],o=e.pending_buf[e.l_buf+i],i++,r===0?cE(e,o,t):(a=abe[o],cE(e,a+lbe+1,t),s=HAt[a],s!==0&&(o-=WAt[a],ev(e,o,s)),r--,a=gYn(r),cE(e,a,n),s=U9e[a],s!==0&&(r-=H9e[a],ev(e,r,s)));while(i<e.last_lit);cE(e,XAt,t)}function GAt(e,t){var n=t.dyn_tree,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,i=t.stat_desc.elems,a,s,l=-1,c;for(e.heap_len=0,e.heap_max=lYn,a=0;a<i;a++)n[a*2]!==0?(e.heap[++e.heap_len]=l=a,e.depth[a]=0):n[a*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,n[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=r[c*2+1]);for(t.max_code=l,a=e.heap_len>>1;a>=1;a--)UAt(e,n,a);c=i;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],UAt(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=s,n[c*2]=n[a*2]+n[s*2],e.depth[c]=(e.depth[a]>=e.depth[s]?e.depth[a]:e.depth[s])+1,n[a*2+1]=n[s*2+1]=c,e.heap[1]=c++,UAt(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Qei(e,t),bYn(n,l,e.bl_count)}function oYn(e,t,n){var r,o=-1,i,a=t[1],s=0,l=7,c=4;for(a===0&&(l=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)i=a,a=t[(r+1)*2+1],!(++s<l&&i===a)&&(s<c?e.bl_tree[i*2]+=s:i!==0?(i!==o&&e.bl_tree[i*2]++,e.bl_tree[cYn*2]++):s<=10?e.bl_tree[uYn*2]++:e.bl_tree[dYn*2]++,s=0,o=i,a===0?(l=138,c=3):i===a?(l=6,c=3):(l=7,c=4))}function iYn(e,t,n){var r,o=-1,i,a=t[1],s=0,l=7,c=4;for(a===0&&(l=138,c=3),r=0;r<=n;r++)if(i=a,a=t[(r+1)*2+1],!(++s<l&&i===a)){if(s<c)do cE(e,i,e.bl_tree);while(--s!==0);else i!==0?(i!==o&&(cE(e,i,e.bl_tree),s--),cE(e,cYn,e.bl_tree),ev(e,s-3,2)):s<=10?(cE(e,uYn,e.bl_tree),ev(e,s-3,3)):(cE(e,dYn,e.bl_tree),ev(e,s-11,7));s=0,o=i,a===0?(l=138,c=3):i===a?(l=6,c=3):(l=7,c=4)}}function nti(e){var t;for(oYn(e,e.dyn_ltree,e.l_desc.max_code),oYn(e,e.dyn_dtree,e.d_desc.max_code),GAt(e,e.bl_desc),t=VAt-1;t>=3&&e.bl_tree[pYn[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function rti(e,t,n,r){var o;for(ev(e,t-257,5),ev(e,n-1,5),ev(e,r-4,4),o=0;o<r;o++)ev(e,e.bl_tree[pYn[o]*2+1],3);iYn(e,e.dyn_ltree,t-1),iYn(e,e.dyn_dtree,n-1)}function oti(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return eYn;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return tYn;for(n=32;n<lbe;n++)if(e.dyn_ltree[n*2]!==0)return tYn;return eYn}var aYn=!1;function iti(e){aYn||(eti(),aYn=!0),e.l_desc=new zAt(e.dyn_ltree,fYn),e.d_desc=new zAt(e.dyn_dtree,mYn),e.bl_desc=new zAt(e.bl_tree,hYn),e.bi_buf=0,e.bi_valid=0,xYn(e)}function SYn(e,t,n,r){ev(e,(Xei<<1)+(r?1:0),3),tti(e,t,n,!0)}function ati(e){ev(e,sYn<<1,3),cE(e,XAt,kP),Jei(e)}function sti(e,t,n,r){var o,i,a=0;e.level>0?(e.strm.data_type===Vei&&(e.strm.data_type=oti(e)),GAt(e,e.l_desc),GAt(e,e.d_desc),a=nti(e),o=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=o&&(o=i)):o=i=n+5,n+4<=o&&t!==-1?SYn(e,t,n,r):e.strategy===jei||i===o?(ev(e,(sYn<<1)+(r?1:0),3),rYn(e,kP,rbe)):(ev(e,(Wei<<1)+(r?1:0),3),rti(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),rYn(e,e.dyn_ltree,e.dyn_dtree)),xYn(e),r&&vYn(e)}function lti(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(abe[n]+lbe+1)*2]++,e.dyn_dtree[gYn(t)*2]++),e.last_lit===e.lit_bufsize-1}$te._tr_init=iti;$te._tr_stored_block=SYn;$te._tr_flush_block=sti;$te._tr_tally=lti;$te._tr_align=ati});var qAt=Fo((ZZs,FYn)=>{"use strict";function cti(e,t,n,r){for(var o=e&65535|0,i=e>>>16&65535|0,a=0;n!==0;){a=n>2e3?2e3:n,n-=a;do o=o+t[r++]|0,i=i+o|0;while(--a);o%=65521,i%=65521}return o|i<<16|0}FYn.exports=cti});var KAt=Fo((JZs,CYn)=>{"use strict";function uti(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var dti=uti();function pti(e,t,n,r){var o=dti,i=r+n;e^=-1;for(var a=r;a<i;a++)e=e>>>8^o[(e^t[a])&255];return e^-1}CYn.exports=pti});var G9e=Fo((QZs,AYn)=>{"use strict";AYn.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var LYn=Fo(pE=>{"use strict";var b1=DP(),fF=wYn(),EYn=qAt(),E_=KAt(),fti=G9e(),jj=0,mti=1,hti=3,L_=4,TYn=5,dE=0,DYn=1,mF=-2,gti=-3,YAt=-5,yti=-1,bti=1,j9e=2,xti=3,vti=4,Sti=0,wti=2,q9e=8,Fti=9,Cti=15,Ati=8,Tti=29,Dti=256,ZAt=Dti+1+Tti,kti=30,Eti=19,Iti=2*ZAt+1,Pti=15,Bs=3,M_=258,kA=M_+Bs+1,Mti=32,K9e=42,JAt=69,V9e=73,X9e=91,W9e=103,Uj=113,ube=666,Wm=1,dbe=2,Hj=3,Qte=4,Bti=3;function B_(e,t){return e.msg=fti[t],t}function kYn(e){return(e<<1)-(e>4?9:0)}function P_(e){for(var t=e.length;--t>=0;)e[t]=0}function I_(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(b1.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function og(e,t){fF._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,I_(e.strm)}function Il(e,t){e.pending_buf[e.pending++]=t}function cbe(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function Lti(e,t,n,r){var o=e.avail_in;return o>r&&(o=r),o===0?0:(e.avail_in-=o,b1.arraySet(t,e.input,e.next_in,o,n),e.state.wrap===1?e.adler=EYn(e.adler,t,o,n):e.state.wrap===2&&(e.adler=E_(e.adler,t,o,n)),e.next_in+=o,e.total_in+=o,o)}function IYn(e,t){var n=e.max_chain_length,r=e.strstart,o,i,a=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-kA?e.strstart-(e.w_size-kA):0,c=e.window,u=e.w_mask,d=e.prev,p=e.strstart+M_,f=c[r+a-1],m=c[r+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(o=t,!(c[o+a]!==m||c[o+a-1]!==f||c[o]!==c[r]||c[++o]!==c[r+1])){r+=2,o++;do;while(c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&r<p);if(i=M_-(p-r),r=p-M_,i>a){if(e.match_start=t,a=i,i>=s)break;f=c[r+a-1],m=c[r+a]}}while((t=d[t&u])>l&&--n!==0);return a<=e.lookahead?a:e.lookahead}function Gj(e){var t=e.w_size,n,r,o,i,a;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-kA)){b1.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do o=e.head[--n],e.head[n]=o>=t?o-t:0;while(--r);r=t,n=r;do o=e.prev[--n],e.prev[n]=o>=t?o-t:0;while(--r);i+=t}if(e.strm.avail_in===0)break;if(r=Lti(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=Bs)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+Bs-1])&e.hash_mask,e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<Bs)););}while(e.lookahead<kA&&e.strm.avail_in!==0)}function Rti(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Gj(e),e.lookahead===0&&t===jj)return Wm;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,og(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-kA&&(og(e,!1),e.strm.avail_out===0))return Wm}return e.insert=0,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):(e.strstart>e.block_start&&(og(e,!1),e.strm.avail_out===0),Wm)}function $At(e,t){for(var n,r;;){if(e.lookahead<kA){if(Gj(e),e.lookahead<kA&&t===jj)return Wm;if(e.lookahead===0)break}if(n=0,e.lookahead>=Bs&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Bs-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-kA&&(e.match_length=IYn(e,n)),e.match_length>=Bs)if(r=fF._tr_tally(e,e.strstart-e.match_start,e.match_length-Bs),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Bs){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Bs-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=fF._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(og(e,!1),e.strm.avail_out===0))return Wm}return e.insert=e.strstart<Bs-1?e.strstart:Bs-1,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):e.last_lit&&(og(e,!1),e.strm.avail_out===0)?Wm:dbe}function Zte(e,t){for(var n,r,o;;){if(e.lookahead<kA){if(Gj(e),e.lookahead<kA&&t===jj)return Wm;if(e.lookahead===0)break}if(n=0,e.lookahead>=Bs&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Bs-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Bs-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-kA&&(e.match_length=IYn(e,n),e.match_length<=5&&(e.strategy===bti||e.match_length===Bs&&e.strstart-e.match_start>4096)&&(e.match_length=Bs-1)),e.prev_length>=Bs&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-Bs,r=fF._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Bs),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Bs-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Bs-1,e.strstart++,r&&(og(e,!1),e.strm.avail_out===0))return Wm}else if(e.match_available){if(r=fF._tr_tally(e,0,e.window[e.strstart-1]),r&&og(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Wm}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=fF._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Bs-1?e.strstart:Bs-1,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):e.last_lit&&(og(e,!1),e.strm.avail_out===0)?Wm:dbe}function _ti(e,t){for(var n,r,o,i,a=e.window;;){if(e.lookahead<=M_){if(Gj(e),e.lookahead<=M_&&t===jj)return Wm;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Bs&&e.strstart>0&&(o=e.strstart-1,r=a[o],r===a[++o]&&r===a[++o]&&r===a[++o])){i=e.strstart+M_;do;while(r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&o<i);e.match_length=M_-(i-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Bs?(n=fF._tr_tally(e,1,e.match_length-Bs),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=fF._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(og(e,!1),e.strm.avail_out===0))return Wm}return e.insert=0,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):e.last_lit&&(og(e,!1),e.strm.avail_out===0)?Wm:dbe}function Oti(e,t){for(var n;;){if(e.lookahead===0&&(Gj(e),e.lookahead===0)){if(t===jj)return Wm;break}if(e.match_length=0,n=fF._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(og(e,!1),e.strm.avail_out===0))return Wm}return e.insert=0,t===L_?(og(e,!0),e.strm.avail_out===0?Hj:Qte):e.last_lit&&(og(e,!1),e.strm.avail_out===0)?Wm:dbe}function uE(e,t,n,r,o){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=o}var Jte;Jte=[new uE(0,0,0,0,Rti),new uE(4,4,8,4,$At),new uE(4,5,16,8,$At),new uE(4,6,32,32,$At),new uE(4,4,16,16,Zte),new uE(8,16,32,32,Zte),new uE(8,16,128,128,Zte),new uE(8,32,128,256,Zte),new uE(32,128,258,1024,Zte),new uE(32,258,258,4096,Zte)];function Nti(e){e.window_size=2*e.w_size,P_(e.head),e.max_lazy_match=Jte[e.level].max_lazy,e.good_match=Jte[e.level].good_length,e.nice_match=Jte[e.level].nice_length,e.max_chain_length=Jte[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Bs-1,e.match_available=0,e.ins_h=0}function zti(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=q9e,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new b1.Buf16(Iti*2),this.dyn_dtree=new b1.Buf16((2*kti+1)*2),this.bl_tree=new b1.Buf16((2*Eti+1)*2),P_(this.dyn_ltree),P_(this.dyn_dtree),P_(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new b1.Buf16(Pti+1),this.heap=new b1.Buf16(2*ZAt+1),P_(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new b1.Buf16(2*ZAt+1),P_(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function PYn(e){var t;return!e||!e.state?B_(e,mF):(e.total_in=e.total_out=0,e.data_type=wti,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?K9e:Uj,e.adler=t.wrap===2?0:1,t.last_flush=jj,fF._tr_init(t),dE)}function MYn(e){var t=PYn(e);return t===dE&&Nti(e.state),t}function Uti(e,t){return!e||!e.state||e.state.wrap!==2?mF:(e.state.gzhead=t,dE)}function BYn(e,t,n,r,o,i){if(!e)return mF;var a=1;if(t===yti&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),o<1||o>Fti||n!==q9e||r<8||r>15||t<0||t>9||i<0||i>vti)return B_(e,mF);r===8&&(r=9);var s=new zti;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=o+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+Bs-1)/Bs),s.window=new b1.Buf8(s.w_size*2),s.head=new b1.Buf16(s.hash_size),s.prev=new b1.Buf16(s.w_size),s.lit_bufsize=1<<o+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new b1.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=i,s.method=n,MYn(e)}function Hti(e,t){return BYn(e,t,q9e,Cti,Ati,Sti)}function Gti(e,t){var n,r,o,i;if(!e||!e.state||t>TYn||t<0)return e?B_(e,mF):mF;if(r=e.state,!e.output||!e.input&&e.avail_in!==0||r.status===ube&&t!==L_)return B_(e,e.avail_out===0?YAt:mF);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===K9e)if(r.wrap===2)e.adler=0,Il(r,31),Il(r,139),Il(r,8),r.gzhead?(Il(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Il(r,r.gzhead.time&255),Il(r,r.gzhead.time>>8&255),Il(r,r.gzhead.time>>16&255),Il(r,r.gzhead.time>>24&255),Il(r,r.level===9?2:r.strategy>=j9e||r.level<2?4:0),Il(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(Il(r,r.gzhead.extra.length&255),Il(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=E_(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=JAt):(Il(r,0),Il(r,0),Il(r,0),Il(r,0),Il(r,0),Il(r,r.level===9?2:r.strategy>=j9e||r.level<2?4:0),Il(r,Bti),r.status=Uj);else{var a=q9e+(r.w_bits-8<<4)<<8,s=-1;r.strategy>=j9e||r.level<2?s=0:r.level<6?s=1:r.level===6?s=2:s=3,a|=s<<6,r.strstart!==0&&(a|=Mti),a+=31-a%31,r.status=Uj,cbe(r,a),r.strstart!==0&&(cbe(r,e.adler>>>16),cbe(r,e.adler&65535)),e.adler=1}if(r.status===JAt)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),I_(e),o=r.pending,r.pending===r.pending_buf_size));)Il(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=V9e)}else r.status=V9e;if(r.status===V9e)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),I_(e),o=r.pending,r.pending===r.pending_buf_size)){i=1;break}r.gzindex<r.gzhead.name.length?i=r.gzhead.name.charCodeAt(r.gzindex++)&255:i=0,Il(r,i)}while(i!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),i===0&&(r.gzindex=0,r.status=X9e)}else r.status=X9e;if(r.status===X9e)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),I_(e),o=r.pending,r.pending===r.pending_buf_size)){i=1;break}r.gzindex<r.gzhead.comment.length?i=r.gzhead.comment.charCodeAt(r.gzindex++)&255:i=0,Il(r,i)}while(i!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=E_(e.adler,r.pending_buf,r.pending-o,o)),i===0&&(r.status=W9e)}else r.status=W9e;if(r.status===W9e&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&I_(e),r.pending+2<=r.pending_buf_size&&(Il(r,e.adler&255),Il(r,e.adler>>8&255),e.adler=0,r.status=Uj)):r.status=Uj),r.pending!==0){if(I_(e),e.avail_out===0)return r.last_flush=-1,dE}else if(e.avail_in===0&&kYn(t)<=kYn(n)&&t!==L_)return B_(e,YAt);if(r.status===ube&&e.avail_in!==0)return B_(e,YAt);if(e.avail_in!==0||r.lookahead!==0||t!==jj&&r.status!==ube){var l=r.strategy===j9e?Oti(r,t):r.strategy===xti?_ti(r,t):Jte[r.level].func(r,t);if((l===Hj||l===Qte)&&(r.status=ube),l===Wm||l===Hj)return e.avail_out===0&&(r.last_flush=-1),dE;if(l===dbe&&(t===mti?fF._tr_align(r):t!==TYn&&(fF._tr_stored_block(r,0,0,!1),t===hti&&(P_(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),I_(e),e.avail_out===0))return r.last_flush=-1,dE}return t!==L_?dE:r.wrap<=0?DYn:(r.wrap===2?(Il(r,e.adler&255),Il(r,e.adler>>8&255),Il(r,e.adler>>16&255),Il(r,e.adler>>24&255),Il(r,e.total_in&255),Il(r,e.total_in>>8&255),Il(r,e.total_in>>16&255),Il(r,e.total_in>>24&255)):(cbe(r,e.adler>>>16),cbe(r,e.adler&65535)),I_(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?dE:DYn)}function jti(e){var t;return!e||!e.state?mF:(t=e.state.status,t!==K9e&&t!==JAt&&t!==V9e&&t!==X9e&&t!==W9e&&t!==Uj&&t!==ube?B_(e,mF):(e.state=null,t===Uj?B_(e,gti):dE))}function Vti(e,t){var n=t.length,r,o,i,a,s,l,c,u;if(!e||!e.state||(r=e.state,a=r.wrap,a===2||a===1&&r.status!==K9e||r.lookahead))return mF;for(a===1&&(e.adler=EYn(e.adler,t,n,0)),r.wrap=0,n>=r.w_size&&(a===0&&(P_(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new b1.Buf8(r.w_size),b1.arraySet(u,t,n-r.w_size,r.w_size,0),t=u,n=r.w_size),s=e.avail_in,l=e.next_in,c=e.input,e.avail_in=n,e.next_in=0,e.input=t,Gj(r);r.lookahead>=Bs;){o=r.strstart,i=r.lookahead-(Bs-1);do r.ins_h=(r.ins_h<<r.hash_shift^r.window[o+Bs-1])&r.hash_mask,r.prev[o&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=o,o++;while(--i);r.strstart=o,r.lookahead=Bs-1,Gj(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Bs-1,r.match_available=0,e.next_in=l,e.input=c,e.avail_in=s,r.wrap=a,dE}pE.deflateInit=Hti;pE.deflateInit2=BYn;pE.deflateReset=MYn;pE.deflateResetKeep=PYn;pE.deflateSetHeader=Uti;pE.deflate=Gti;pE.deflateEnd=jti;pE.deflateSetDictionary=Vti;pE.deflateInfo="pako deflate (from Nodeca project)"});var QAt=Fo(ene=>{"use strict";var Y9e=DP(),RYn=!0,_Yn=!0;try{String.fromCharCode.apply(null,[0])}catch{RYn=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{_Yn=!1}var pbe=new Y9e.Buf8(256);for(EP=0;EP<256;EP++)pbe[EP]=EP>=252?6:EP>=248?5:EP>=240?4:EP>=224?3:EP>=192?2:1;var EP;pbe[254]=pbe[254]=1;ene.string2buf=function(e){var t,n,r,o,i,a=e.length,s=0;for(o=0;o<a;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<a&&(r=e.charCodeAt(o+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),o++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Y9e.Buf8(s),i=0,o=0;i<s;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<a&&(r=e.charCodeAt(o+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),o++)),n<128?t[i++]=n:n<2048?(t[i++]=192|n>>>6,t[i++]=128|n&63):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|n&63):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|n&63);return t};function OYn(e,t){if(t<65534&&(e.subarray&&_Yn||!e.subarray&&RYn))return String.fromCharCode.apply(null,Y9e.shrinkBuf(e,t));for(var n="",r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n}ene.buf2binstring=function(e){return OYn(e,e.length)};ene.binstring2buf=function(e){for(var t=new Y9e.Buf8(e.length),n=0,r=t.length;n<r;n++)t[n]=e.charCodeAt(n);return t};ene.buf2string=function(e,t){var n,r,o,i,a=t||e.length,s=new Array(a*2);for(r=0,n=0;n<a;){if(o=e[n++],o<128){s[r++]=o;continue}if(i=pbe[o],i>4){s[r++]=65533,n+=i-1;continue}for(o&=i===2?31:i===3?15:7;i>1&&n<a;)o=o<<6|e[n++]&63,i--;if(i>1){s[r++]=65533;continue}o<65536?s[r++]=o:(o-=65536,s[r++]=55296|o>>10&1023,s[r++]=56320|o&1023)}return OYn(s,r)};ene.utf8border=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+pbe[e[n]]>t?n:t}});var eTt=Fo((nJs,NYn)=>{"use strict";function Xti(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}NYn.exports=Xti});var GYn=Fo(hbe=>{"use strict";var fbe=LYn(),mbe=DP(),nTt=QAt(),rTt=G9e(),Wti=eTt(),HYn=Object.prototype.toString,qti=0,tTt=4,tne=0,zYn=1,UYn=2,Kti=-1,Yti=0,$ti=8;function Vj(e){if(!(this instanceof Vj))return new Vj(e);this.options=mbe.assign({level:Kti,method:$ti,chunkSize:16384,windowBits:15,memLevel:8,strategy:Yti,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Wti,this.strm.avail_out=0;var n=fbe.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==tne)throw new Error(rTt[n]);if(t.header&&fbe.deflateSetHeader(this.strm,t.header),t.dictionary){var r;if(typeof t.dictionary=="string"?r=nTt.string2buf(t.dictionary):HYn.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=fbe.deflateSetDictionary(this.strm,r),n!==tne)throw new Error(rTt[n]);this._dict_set=!0}}Vj.prototype.push=function(e,t){var n=this.strm,r=this.options.chunkSize,o,i;if(this.ended)return!1;i=t===~~t?t:t===!0?tTt:qti,typeof e=="string"?n.input=nTt.string2buf(e):HYn.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new mbe.Buf8(r),n.next_out=0,n.avail_out=r),o=fbe.deflate(n,i),o!==zYn&&o!==tne)return this.onEnd(o),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(i===tTt||i===UYn))&&(this.options.to==="string"?this.onData(nTt.buf2binstring(mbe.shrinkBuf(n.output,n.next_out))):this.onData(mbe.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&o!==zYn);return i===tTt?(o=fbe.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===tne):(i===UYn&&(this.onEnd(tne),n.avail_out=0),!0)};Vj.prototype.onData=function(e){this.chunks.push(e)};Vj.prototype.onEnd=function(e){e===tne&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=mbe.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function oTt(e,t){var n=new Vj(t);if(n.push(e,!0),n.err)throw n.msg||rTt[n.err];return n.result}function Zti(e,t){return t=t||{},t.raw=!0,oTt(e,t)}function Jti(e,t){return t=t||{},t.gzip=!0,oTt(e,t)}hbe.Deflate=Vj;hbe.deflate=oTt;hbe.deflateRaw=Zti;hbe.gzip=Jti});var VYn=Fo((oJs,jYn)=>{"use strict";var $9e=30,Qti=12;jYn.exports=function(t,n){var r,o,i,a,s,l,c,u,d,p,f,m,h,g,y,b,x,v,S,F,w,C,A,T,D;r=t.state,o=t.next_in,T=t.input,i=o+(t.avail_in-5),a=t.next_out,D=t.output,s=a-(n-t.avail_out),l=a+(t.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,p=r.wnext,f=r.window,m=r.hold,h=r.bits,g=r.lencode,y=r.distcode,b=(1<<r.lenbits)-1,x=(1<<r.distbits)-1;e:do{h<15&&(m+=T[o++]<<h,h+=8,m+=T[o++]<<h,h+=8),v=g[m&b];t:for(;;){if(S=v>>>24,m>>>=S,h-=S,S=v>>>16&255,S===0)D[a++]=v&65535;else if(S&16){F=v&65535,S&=15,S&&(h<S&&(m+=T[o++]<<h,h+=8),F+=m&(1<<S)-1,m>>>=S,h-=S),h<15&&(m+=T[o++]<<h,h+=8,m+=T[o++]<<h,h+=8),v=y[m&x];n:for(;;){if(S=v>>>24,m>>>=S,h-=S,S=v>>>16&255,S&16){if(w=v&65535,S&=15,h<S&&(m+=T[o++]<<h,h+=8,h<S&&(m+=T[o++]<<h,h+=8)),w+=m&(1<<S)-1,w>c){t.msg="invalid distance too far back",r.mode=$9e;break e}if(m>>>=S,h-=S,S=a-s,w>S){if(S=w-S,S>d&&r.sane){t.msg="invalid distance too far back",r.mode=$9e;break e}if(C=0,A=f,p===0){if(C+=u-S,S<F){F-=S;do D[a++]=f[C++];while(--S);C=a-w,A=D}}else if(p<S){if(C+=u+p-S,S-=p,S<F){F-=S;do D[a++]=f[C++];while(--S);if(C=0,p<F){S=p,F-=S;do D[a++]=f[C++];while(--S);C=a-w,A=D}}}else if(C+=p-S,S<F){F-=S;do D[a++]=f[C++];while(--S);C=a-w,A=D}for(;F>2;)D[a++]=A[C++],D[a++]=A[C++],D[a++]=A[C++],F-=3;F&&(D[a++]=A[C++],F>1&&(D[a++]=A[C++]))}else{C=a-w;do D[a++]=D[C++],D[a++]=D[C++],D[a++]=D[C++],F-=3;while(F>2);F&&(D[a++]=D[C++],F>1&&(D[a++]=D[C++]))}}else if((S&64)===0){v=y[(v&65535)+(m&(1<<S)-1)];continue n}else{t.msg="invalid distance code",r.mode=$9e;break e}break}}else if((S&64)===0){v=g[(v&65535)+(m&(1<<S)-1)];continue t}else if(S&32){r.mode=Qti;break e}else{t.msg="invalid literal/length code",r.mode=$9e;break e}break}}while(o<i&&a<l);F=h>>3,o-=F,h-=F<<3,m&=(1<<h)-1,t.next_in=o,t.next_out=a,t.avail_in=o<i?5+(i-o):5-(o-i),t.avail_out=a<l?257+(l-a):257-(a-l),r.hold=m,r.bits=h}});var ZYn=Fo((iJs,$Yn)=>{"use strict";var XYn=DP(),nne=15,WYn=852,qYn=592,KYn=0,iTt=1,YYn=2,eni=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],tni=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],nni=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],rni=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];$Yn.exports=function(t,n,r,o,i,a,s,l){var c=l.bits,u=0,d=0,p=0,f=0,m=0,h=0,g=0,y=0,b=0,x=0,v,S,F,w,C,A=null,T=0,D,k=new XYn.Buf16(nne+1),P=new XYn.Buf16(nne+1),I=null,B=0,M,L,_;for(u=0;u<=nne;u++)k[u]=0;for(d=0;d<o;d++)k[n[r+d]]++;for(m=c,f=nne;f>=1&&k[f]===0;f--);if(m>f&&(m=f),f===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,l.bits=1,0;for(p=1;p<f&&k[p]===0;p++);for(m<p&&(m=p),y=1,u=1;u<=nne;u++)if(y<<=1,y-=k[u],y<0)return-1;if(y>0&&(t===KYn||f!==1))return-1;for(P[1]=0,u=1;u<nne;u++)P[u+1]=P[u]+k[u];for(d=0;d<o;d++)n[r+d]!==0&&(s[P[n[r+d]]++]=d);if(t===KYn?(A=I=s,D=19):t===iTt?(A=eni,T-=257,I=tni,B-=257,D=256):(A=nni,I=rni,D=-1),x=0,d=0,u=p,C=a,h=m,g=0,F=-1,b=1<<m,w=b-1,t===iTt&&b>WYn||t===YYn&&b>qYn)return 1;for(;;){M=u-g,s[d]<D?(L=0,_=s[d]):s[d]>D?(L=I[B+s[d]],_=A[T+s[d]]):(L=96,_=0),v=1<<u-g,S=1<<h,p=S;do S-=v,i[C+(x>>g)+S]=M<<24|L<<16|_|0;while(S!==0);for(v=1<<u-1;x&v;)v>>=1;if(v!==0?(x&=v-1,x+=v):x=0,d++,--k[u]===0){if(u===f)break;u=n[r+s[d]]}if(u>m&&(x&w)!==F){for(g===0&&(g=m),C+=p,h=u-g,y=1<<h;h+g<f&&(y-=k[h+g],!(y<=0));)h++,y<<=1;if(b+=1<<h,t===iTt&&b>WYn||t===YYn&&b>qYn)return 1;F=x&w,i[F]=m<<24|h<<16|C-a|0}}return x!==0&&(i[C+x]=u-g<<24|64<<16|0),l.bits=m,0}});var M$n=Fo(EA=>{"use strict";var J2=DP(),dTt=qAt(),fE=KAt(),oni=VYn(),gbe=ZYn(),ini=0,F$n=1,C$n=2,JYn=4,ani=5,Z9e=6,Xj=0,sni=1,lni=2,hF=-2,A$n=-3,pTt=-4,cni=-5,QYn=8,T$n=1,e$n=2,t$n=3,n$n=4,r$n=5,o$n=6,i$n=7,a$n=8,s$n=9,l$n=10,eze=11,IP=12,aTt=13,c$n=14,sTt=15,u$n=16,d$n=17,p$n=18,f$n=19,J9e=20,Q9e=21,m$n=22,h$n=23,g$n=24,y$n=25,b$n=26,lTt=27,x$n=28,v$n=29,Sd=30,fTt=31,uni=32,dni=852,pni=592,fni=15,mni=fni;function S$n(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function hni(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new J2.Buf16(320),this.work=new J2.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function D$n(e){var t;return!e||!e.state?hF:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=T$n,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new J2.Buf32(dni),t.distcode=t.distdyn=new J2.Buf32(pni),t.sane=1,t.back=-1,Xj)}function k$n(e){var t;return!e||!e.state?hF:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,D$n(e))}function E$n(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?hF:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,k$n(e))}function I$n(e,t){var n,r;return e?(r=new hni,e.state=r,r.window=null,n=E$n(e,t),n!==Xj&&(e.state=null),n):hF}function gni(e){return I$n(e,mni)}var w$n=!0,cTt,uTt;function yni(e){if(w$n){var t;for(cTt=new J2.Buf32(512),uTt=new J2.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(gbe(F$n,e.lens,0,288,cTt,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;gbe(C$n,e.lens,0,32,uTt,0,e.work,{bits:5}),w$n=!1}e.lencode=cTt,e.lenbits=9,e.distcode=uTt,e.distbits=5}function P$n(e,t,n,r){var o,i=e.state;return i.window===null&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new J2.Buf8(i.wsize)),r>=i.wsize?(J2.arraySet(i.window,t,n-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):(o=i.wsize-i.wnext,o>r&&(o=r),J2.arraySet(i.window,t,n-r,o,i.wnext),r-=o,r?(J2.arraySet(i.window,t,n-r,r,0),i.wnext=r,i.whave=i.wsize):(i.wnext+=o,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=o))),0}function bni(e,t){var n,r,o,i,a,s,l,c,u,d,p,f,m,h,g=0,y,b,x,v,S,F,w,C,A=new J2.Buf8(4),T,D,k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return hF;n=e.state,n.mode===IP&&(n.mode=aTt),a=e.next_out,o=e.output,l=e.avail_out,i=e.next_in,r=e.input,s=e.avail_in,c=n.hold,u=n.bits,d=s,p=l,C=Xj;e:for(;;)switch(n.mode){case T$n:if(n.wrap===0){n.mode=aTt;break}for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(n.wrap&2&&c===35615){n.check=0,A[0]=c&255,A[1]=c>>>8&255,n.check=fE(n.check,A,2,0),c=0,u=0,n.mode=e$n;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=Sd;break}if((c&15)!==QYn){e.msg="unknown compression method",n.mode=Sd;break}if(c>>>=4,u-=4,w=(c&15)+8,n.wbits===0)n.wbits=w;else if(w>n.wbits){e.msg="invalid window size",n.mode=Sd;break}n.dmax=1<<w,e.adler=n.check=1,n.mode=c&512?l$n:IP,c=0,u=0;break;case e$n:for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(n.flags=c,(n.flags&255)!==QYn){e.msg="unknown compression method",n.mode=Sd;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=Sd;break}n.head&&(n.head.text=c>>8&1),n.flags&512&&(A[0]=c&255,A[1]=c>>>8&255,n.check=fE(n.check,A,2,0)),c=0,u=0,n.mode=t$n;case t$n:for(;u<32;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.head&&(n.head.time=c),n.flags&512&&(A[0]=c&255,A[1]=c>>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,n.check=fE(n.check,A,4,0)),c=0,u=0,n.mode=n$n;case n$n:for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.head&&(n.head.xflags=c&255,n.head.os=c>>8),n.flags&512&&(A[0]=c&255,A[1]=c>>>8&255,n.check=fE(n.check,A,2,0)),c=0,u=0,n.mode=r$n;case r$n:if(n.flags&1024){for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.length=c,n.head&&(n.head.extra_len=c),n.flags&512&&(A[0]=c&255,A[1]=c>>>8&255,n.check=fE(n.check,A,2,0)),c=0,u=0}else n.head&&(n.head.extra=null);n.mode=o$n;case o$n:if(n.flags&1024&&(f=n.length,f>s&&(f=s),f&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),J2.arraySet(n.head.extra,r,i,f,w)),n.flags&512&&(n.check=fE(n.check,r,f,i)),s-=f,i+=f,n.length-=f),n.length))break e;n.length=0,n.mode=i$n;case i$n:if(n.flags&2048){if(s===0)break e;f=0;do w=r[i+f++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w));while(w&&f<s);if(n.flags&512&&(n.check=fE(n.check,r,f,i)),s-=f,i+=f,w)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=a$n;case a$n:if(n.flags&4096){if(s===0)break e;f=0;do w=r[i+f++],n.head&&w&&n.length<65536&&(n.head.comment+=String.fromCharCode(w));while(w&&f<s);if(n.flags&512&&(n.check=fE(n.check,r,f,i)),s-=f,i+=f,w)break e}else n.head&&(n.head.comment=null);n.mode=s$n;case s$n:if(n.flags&512){for(;u<16;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(c!==(n.check&65535)){e.msg="header crc mismatch",n.mode=Sd;break}c=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=IP;break;case l$n:for(;u<32;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}e.adler=n.check=S$n(c),c=0,u=0,n.mode=eze;case eze:if(n.havedict===0)return e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=s,n.hold=c,n.bits=u,lni;e.adler=n.check=1,n.mode=IP;case IP:if(t===ani||t===Z9e)break e;case aTt:if(n.last){c>>>=u&7,u-=u&7,n.mode=lTt;break}for(;u<3;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}switch(n.last=c&1,c>>>=1,u-=1,c&3){case 0:n.mode=c$n;break;case 1:if(yni(n),n.mode=J9e,t===Z9e){c>>>=2,u-=2;break e}break;case 2:n.mode=d$n;break;case 3:e.msg="invalid block type",n.mode=Sd}c>>>=2,u-=2;break;case c$n:for(c>>>=u&7,u-=u&7;u<32;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",n.mode=Sd;break}if(n.length=c&65535,c=0,u=0,n.mode=sTt,t===Z9e)break e;case sTt:n.mode=u$n;case u$n:if(f=n.length,f){if(f>s&&(f=s),f>l&&(f=l),f===0)break e;J2.arraySet(o,r,i,f,a),s-=f,i+=f,l-=f,a+=f,n.length-=f;break}n.mode=IP;break;case d$n:for(;u<14;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(n.nlen=(c&31)+257,c>>>=5,u-=5,n.ndist=(c&31)+1,c>>>=5,u-=5,n.ncode=(c&15)+4,c>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Sd;break}n.have=0,n.mode=p$n;case p$n:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.lens[k[n.have++]]=c&7,c>>>=3,u-=3}for(;n.have<19;)n.lens[k[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},C=gbe(ini,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,C){e.msg="invalid code lengths set",n.mode=Sd;break}n.have=0,n.mode=f$n;case f$n:for(;n.have<n.nlen+n.ndist;){for(;g=n.lencode[c&(1<<n.lenbits)-1],y=g>>>24,b=g>>>16&255,x=g&65535,!(y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(x<16)c>>>=y,u-=y,n.lens[n.have++]=x;else{if(x===16){for(D=y+2;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(c>>>=y,u-=y,n.have===0){e.msg="invalid bit length repeat",n.mode=Sd;break}w=n.lens[n.have-1],f=3+(c&3),c>>>=2,u-=2}else if(x===17){for(D=y+3;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}c>>>=y,u-=y,w=0,f=3+(c&7),c>>>=3,u-=3}else{for(D=y+7;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}c>>>=y,u-=y,w=0,f=11+(c&127),c>>>=7,u-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Sd;break}for(;f--;)n.lens[n.have++]=w}}if(n.mode===Sd)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Sd;break}if(n.lenbits=9,T={bits:n.lenbits},C=gbe(F$n,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,C){e.msg="invalid literal/lengths set",n.mode=Sd;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},C=gbe(C$n,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,C){e.msg="invalid distances set",n.mode=Sd;break}if(n.mode=J9e,t===Z9e)break e;case J9e:n.mode=Q9e;case Q9e:if(s>=6&&l>=258){e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=s,n.hold=c,n.bits=u,oni(e,p),a=e.next_out,o=e.output,l=e.avail_out,i=e.next_in,r=e.input,s=e.avail_in,c=n.hold,u=n.bits,n.mode===IP&&(n.back=-1);break}for(n.back=0;g=n.lencode[c&(1<<n.lenbits)-1],y=g>>>24,b=g>>>16&255,x=g&65535,!(y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(b&&(b&240)===0){for(v=y,S=b,F=x;g=n.lencode[F+((c&(1<<v+S)-1)>>v)],y=g>>>24,b=g>>>16&255,x=g&65535,!(v+y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}c>>>=v,u-=v,n.back+=v}if(c>>>=y,u-=y,n.back+=y,n.length=x,b===0){n.mode=b$n;break}if(b&32){n.back=-1,n.mode=IP;break}if(b&64){e.msg="invalid literal/length code",n.mode=Sd;break}n.extra=b&15,n.mode=m$n;case m$n:if(n.extra){for(D=n.extra;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=h$n;case h$n:for(;g=n.distcode[c&(1<<n.distbits)-1],y=g>>>24,b=g>>>16&255,x=g&65535,!(y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if((b&240)===0){for(v=y,S=b,F=x;g=n.distcode[F+((c&(1<<v+S)-1)>>v)],y=g>>>24,b=g>>>16&255,x=g&65535,!(v+y<=u);){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}c>>>=v,u-=v,n.back+=v}if(c>>>=y,u-=y,n.back+=y,b&64){e.msg="invalid distance code",n.mode=Sd;break}n.offset=x,n.extra=b&15,n.mode=g$n;case g$n:if(n.extra){for(D=n.extra;u<D;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Sd;break}n.mode=y$n;case y$n:if(l===0)break e;if(f=p-l,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Sd;break}f>n.wnext?(f-=n.wnext,m=n.wsize-f):m=n.wnext-f,f>n.length&&(f=n.length),h=n.window}else h=o,m=a-n.offset,f=n.length;f>l&&(f=l),l-=f,n.length-=f;do o[a++]=h[m++];while(--f);n.length===0&&(n.mode=Q9e);break;case b$n:if(l===0)break e;o[a++]=n.length,l--,n.mode=Q9e;break;case lTt:if(n.wrap){for(;u<32;){if(s===0)break e;s--,c|=r[i++]<<u,u+=8}if(p-=l,e.total_out+=p,n.total+=p,p&&(e.adler=n.check=n.flags?fE(n.check,o,p,a-p):dTt(n.check,o,p,a-p)),p=l,(n.flags?c:S$n(c))!==n.check){e.msg="incorrect data check",n.mode=Sd;break}c=0,u=0}n.mode=x$n;case x$n:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break e;s--,c+=r[i++]<<u,u+=8}if(c!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=Sd;break}c=0,u=0}n.mode=v$n;case v$n:C=sni;break e;case Sd:C=A$n;break e;case fTt:return pTt;case uni:default:return hF}return e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=s,n.hold=c,n.bits=u,(n.wsize||p!==e.avail_out&&n.mode<Sd&&(n.mode<lTt||t!==JYn))&&P$n(e,e.output,e.next_out,p-e.avail_out)?(n.mode=fTt,pTt):(d-=e.avail_in,p-=e.avail_out,e.total_in+=d,e.total_out+=p,n.total+=p,n.wrap&&p&&(e.adler=n.check=n.flags?fE(n.check,o,p,e.next_out-p):dTt(n.check,o,p,e.next_out-p)),e.data_type=n.bits+(n.last?64:0)+(n.mode===IP?128:0)+(n.mode===J9e||n.mode===sTt?256:0),(d===0&&p===0||t===JYn)&&C===Xj&&(C=cni),C)}function xni(e){if(!e||!e.state)return hF;var t=e.state;return t.window&&(t.window=null),e.state=null,Xj}function vni(e,t){var n;return!e||!e.state||(n=e.state,(n.wrap&2)===0)?hF:(n.head=t,t.done=!1,Xj)}function Sni(e,t){var n=t.length,r,o,i;return!e||!e.state||(r=e.state,r.wrap!==0&&r.mode!==eze)?hF:r.mode===eze&&(o=1,o=dTt(o,t,n,0),o!==r.check)?A$n:(i=P$n(e,t,n,n),i?(r.mode=fTt,pTt):(r.havedict=1,Xj))}EA.inflateReset=k$n;EA.inflateReset2=E$n;EA.inflateResetKeep=D$n;EA.inflateInit=gni;EA.inflateInit2=I$n;EA.inflate=bni;EA.inflateEnd=xni;EA.inflateGetHeader=vni;EA.inflateSetDictionary=Sni;EA.inflateInfo="pako inflate (from Nodeca project)"});var mTt=Fo((sJs,B$n)=>{"use strict";B$n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var R$n=Fo((lJs,L$n)=>{"use strict";function wni(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}L$n.exports=wni});var O$n=Fo(bbe=>{"use strict";var rne=M$n(),ybe=DP(),tze=QAt(),gf=mTt(),hTt=G9e(),Fni=eTt(),Cni=R$n(),_$n=Object.prototype.toString;function Wj(e){if(!(this instanceof Wj))return new Wj(e);this.options=ybe.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Fni,this.strm.avail_out=0;var n=rne.inflateInit2(this.strm,t.windowBits);if(n!==gf.Z_OK)throw new Error(hTt[n]);if(this.header=new Cni,rne.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=tze.string2buf(t.dictionary):_$n.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=rne.inflateSetDictionary(this.strm,t.dictionary),n!==gf.Z_OK)))throw new Error(hTt[n])}Wj.prototype.push=function(e,t){var n=this.strm,r=this.options.chunkSize,o=this.options.dictionary,i,a,s,l,c,u=!1;if(this.ended)return!1;a=t===~~t?t:t===!0?gf.Z_FINISH:gf.Z_NO_FLUSH,typeof e=="string"?n.input=tze.binstring2buf(e):_$n.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new ybe.Buf8(r),n.next_out=0,n.avail_out=r),i=rne.inflate(n,gf.Z_NO_FLUSH),i===gf.Z_NEED_DICT&&o&&(i=rne.inflateSetDictionary(this.strm,o)),i===gf.Z_BUF_ERROR&&u===!0&&(i=gf.Z_OK,u=!1),i!==gf.Z_STREAM_END&&i!==gf.Z_OK)return this.onEnd(i),this.ended=!0,!1;n.next_out&&(n.avail_out===0||i===gf.Z_STREAM_END||n.avail_in===0&&(a===gf.Z_FINISH||a===gf.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=tze.utf8border(n.output,n.next_out),l=n.next_out-s,c=tze.buf2string(n.output,s),n.next_out=l,n.avail_out=r-l,l&&ybe.arraySet(n.output,n.output,s,l,0),this.onData(c)):this.onData(ybe.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(u=!0)}while((n.avail_in>0||n.avail_out===0)&&i!==gf.Z_STREAM_END);return i===gf.Z_STREAM_END&&(a=gf.Z_FINISH),a===gf.Z_FINISH?(i=rne.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===gf.Z_OK):(a===gf.Z_SYNC_FLUSH&&(this.onEnd(gf.Z_OK),n.avail_out=0),!0)};Wj.prototype.onData=function(e){this.chunks.push(e)};Wj.prototype.onEnd=function(e){e===gf.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ybe.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function gTt(e,t){var n=new Wj(t);if(n.push(e,!0),n.err)throw n.msg||hTt[n.err];return n.result}function Ani(e,t){return t=t||{},t.raw=!0,gTt(e,t)}bbe.Inflate=Wj;bbe.inflate=gTt;bbe.inflateRaw=Ani;bbe.ungzip=gTt});var U$n=Fo((uJs,z$n)=>{"use strict";var Tni=DP().assign,Dni=GYn(),kni=O$n(),Eni=mTt(),N$n={};Tni(N$n,Dni,kni,Eni);z$n.exports=N$n});var nze=Fo((dJs,yTt)=>{(function(){var e={};typeof yTt=="object"?yTt.exports=e:self.UTIF=e;var t;typeof Ng=="function"?t=U$n():t=self.pako;function n(){typeof process>"u"&&console.log.apply(console,arguments)}(function(r,o){(function(){var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},a=(function(){function l(c){this.message="JPEG error: "+c}return l.prototype=Error(),l.prototype.name="JpegError",l.constructor=l})(),s=(function(){function l(c,u){this.message=c,this.g=u}return l.prototype=Error(),l.prototype.name="DNLMarkerError",l.constructor=l})();(function(){function l(){this.M=null,this.B=-1}function c(m,h){for(var g=0,y=[],b,x,v=16;0<v&&!m[v-1];)v--;y.push({children:[],index:0});var S=y[0],F;for(b=0;b<v;b++){for(x=0;x<m[b];x++){for(S=y.pop(),S.children[S.index]=h[g];0<S.index;)S=y.pop();for(S.index++,y.push(S);y.length<=b;)y.push(F={children:[],index:0}),S.children[S.index]=F.children,S=F;g++}b+1<v&&(y.push(F={children:[],index:0}),S.children[S.index]=F.children,S=F)}return y[0].children}function u(m,h,g,y,b,x,v,S,F){function w(){if(0<O)return O--,R>>O&1;if(R=m[h++],R===255){var j=m[h++];if(j){if(j===220&&M){h+=2;var pe=m[h++]<<8|m[h++];if(0<pe&&pe!==g.g)throw new s("Found DNL marker (0xFFDC) while parsing scan data",pe)}throw new a("unexpected marker "+(R<<8|j).toString(16))}}return O=7,R>>>7}function C(j){for(;;){if(j=j[w()],typeof j=="number")return j;if((typeof j>"u"?"undefined":i(j))!=="object")throw new a("invalid huffman sequence")}}function A(j){for(var pe=0;0<j;)pe=pe<<1|w(),j--;return pe}function T(j){if(j===1)return w()===1?1:-1;var pe=A(j);return pe>=1<<j-1?pe:pe+(-1<<j)+1}function D(j,pe){var re=C(j.D);for(re=re===0?0:T(re),j.a[pe]=j.m+=re,re=1;64>re;){var le=C(j.o),Q=le&15;if(le>>=4,Q===0){if(15>le)break;re+=16}else re+=le,j.a[pe+f[re]]=T(Q),re++}}function k(j,pe){var re=C(j.D);re=re===0?0:T(re)<<F,j.a[pe]=j.m+=re}function P(j,pe){j.a[pe]|=w()<<F}function I(j,pe){if(0<N)N--;else for(var re=x;re<=v;){var le=C(j.o),Q=le&15;if(le>>=4,Q===0){if(15>le){N=A(le)+(1<<le)-1;break}re+=16}else re+=le,j.a[pe+f[re]]=T(Q)*(1<<F),re++}}function B(j,pe){for(var re=x,le=0,Q;re<=v;){Q=pe+f[re];var se=0>j.a[Q]?-1:1;switch(z){case 0:if(le=C(j.o),Q=le&15,le>>=4,Q===0)15>le?(N=A(le)+(1<<le),z=4):(le=16,z=1);else{if(Q!==1)throw new a("invalid ACn encoding");U=T(Q),z=le?2:3}continue;case 1:case 2:j.a[Q]?j.a[Q]+=se*(w()<<F):(le--,le===0&&(z=z===2?3:0));break;case 3:j.a[Q]?j.a[Q]+=se*(w()<<F):(j.a[Q]=U<<F,z=0);break;case 4:j.a[Q]&&(j.a[Q]+=se*(w()<<F))}re++}z===4&&(N--,N===0&&(z=0))}for(var M=9<arguments.length&&arguments[9]!==void 0?arguments[9]:!1,L=g.P,_=h,R=0,O=0,N=0,z=0,U,H=y.length,V,ne,Z,ee,J=g.S?x===0?S===0?k:P:S===0?I:B:D,te=0,K=H===1?y[0].c*y[0].l:L*g.O,G,ie;te<K;){var fe=b?Math.min(K-te,b):K;for(V=0;V<H;V++)y[V].m=0;if(N=0,H===1){var $=y[0];for(ee=0;ee<fe;ee++)J($,64*(($.c+1)*(te/$.c|0)+te%$.c)),te++}else for(ee=0;ee<fe;ee++){for(V=0;V<H;V++)for($=y[V],G=$.h,ie=$.j,ne=0;ne<ie;ne++)for(Z=0;Z<G;Z++)J($,64*(($.c+1)*((te/L|0)*$.j+ne)+(te%L*$.h+Z)));te++}if(O=0,($=p(m,h))&&$.f&&((0,_util.warn)("decodeScan - unexpected MCU data, current marker is: "+$.f),h=$.offset),$=$&&$.F,!$||65280>=$)throw new a("marker was not found");if(65488<=$&&65495>=$)h+=2;else break}return($=p(m,h))&&$.f&&((0,_util.warn)("decodeScan - unexpected Scan data, current marker is: "+$.f),h=$.offset),h-_}function d(m,h){for(var g=h.c,y=h.l,b=new Int16Array(64),x=0;x<y;x++)for(var v=0;v<g;v++){var S=64*((h.c+1)*x+v),F=b,w=h.G,C=h.a;if(!w)throw new a("missing required Quantization Table.");for(var A=0;64>A;A+=8){var T=C[S+A],D=C[S+A+1],k=C[S+A+2],P=C[S+A+3],I=C[S+A+4],B=C[S+A+5],M=C[S+A+6],L=C[S+A+7];if(T*=w[A],(D|k|P|I|B|M|L)===0)T=5793*T+512>>10,F[A]=T,F[A+1]=T,F[A+2]=T,F[A+3]=T,F[A+4]=T,F[A+5]=T,F[A+6]=T,F[A+7]=T;else{D*=w[A+1],k*=w[A+2],P*=w[A+3],I*=w[A+4],B*=w[A+5],M*=w[A+6],L*=w[A+7];var _=5793*T+128>>8,R=5793*I+128>>8,O=k,N=M;I=2896*(D-L)+128>>8,L=2896*(D+L)+128>>8,P<<=4,B<<=4,_=_+R+1>>1,R=_-R,T=3784*O+1567*N+128>>8,O=1567*O-3784*N+128>>8,N=T,I=I+B+1>>1,B=I-B,L=L+P+1>>1,P=L-P,_=_+N+1>>1,N=_-N,R=R+O+1>>1,O=R-O,T=2276*I+3406*L+2048>>12,I=3406*I-2276*L+2048>>12,L=T,T=799*P+4017*B+2048>>12,P=4017*P-799*B+2048>>12,B=T,F[A]=_+L,F[A+7]=_-L,F[A+1]=R+B,F[A+6]=R-B,F[A+2]=O+P,F[A+5]=O-P,F[A+3]=N+I,F[A+4]=N-I}}for(w=0;8>w;++w)T=F[w],D=F[w+8],k=F[w+16],P=F[w+24],I=F[w+32],B=F[w+40],M=F[w+48],L=F[w+56],(D|k|P|I|B|M|L)===0?(T=5793*T+8192>>14,T=-2040>T?0:2024<=T?255:T+2056>>4,C[S+w]=T,C[S+w+8]=T,C[S+w+16]=T,C[S+w+24]=T,C[S+w+32]=T,C[S+w+40]=T,C[S+w+48]=T,C[S+w+56]=T):(_=5793*T+2048>>12,R=5793*I+2048>>12,O=k,N=M,I=2896*(D-L)+2048>>12,L=2896*(D+L)+2048>>12,_=(_+R+1>>1)+4112,R=_-R,T=3784*O+1567*N+2048>>12,O=1567*O-3784*N+2048>>12,N=T,I=I+B+1>>1,B=I-B,L=L+P+1>>1,P=L-P,_=_+N+1>>1,N=_-N,R=R+O+1>>1,O=R-O,T=2276*I+3406*L+2048>>12,I=3406*I-2276*L+2048>>12,L=T,T=799*P+4017*B+2048>>12,P=4017*P-799*B+2048>>12,B=T,T=_+L,L=_-L,D=R+B,M=R-B,k=O+P,B=O-P,P=N+I,I=N-I,T=16>T?0:4080<=T?255:T>>4,D=16>D?0:4080<=D?255:D>>4,k=16>k?0:4080<=k?255:k>>4,P=16>P?0:4080<=P?255:P>>4,I=16>I?0:4080<=I?255:I>>4,B=16>B?0:4080<=B?255:B>>4,M=16>M?0:4080<=M?255:M>>4,L=16>L?0:4080<=L?255:L>>4,C[S+w]=T,C[S+w+8]=D,C[S+w+16]=k,C[S+w+24]=P,C[S+w+32]=I,C[S+w+40]=B,C[S+w+48]=M,C[S+w+56]=L)}return h.a}function p(m,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:h,y=m.length-1;if(g=g<h?g:h,h>=y)return null;var b=m[h]<<8|m[h+1];if(65472<=b&&65534>=b)return{f:null,F:b,offset:h};for(var x=m[g]<<8|m[g+1];!(65472<=x&&65534>=x);){if(++g>=y)return null;x=m[g]<<8|m[g+1]}return{f:b.toString(16),F:x,offset:g}}var f=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);l.prototype={parse:function(m){function h(){var O=m[v]<<8|m[v+1];return v+=2,O}function g(){var O=h();O=v+O-2;var N=p(m,O,v);return N&&N.f&&((0,_util.warn)("readDataBlock - incorrect length, current marker is: "+N.f),O=N.offset),O=m.subarray(v,O),v+=O.length,O}function y(O){for(var N=Math.ceil(O.v/8/O.s),z=Math.ceil(O.g/8/O.u),U=0;U<O.b.length;U++){_=O.b[U];var H=Math.ceil(Math.ceil(O.v/8)*_.h/O.s),V=Math.ceil(Math.ceil(O.g/8)*_.j/O.u);_.a=new Int16Array(64*z*_.j*(N*_.h+1)),_.c=H,_.l=V}O.P=N,O.O=z}var b=(1<arguments.length&&arguments[1]!==void 0?arguments[1]:{}).N,x=b===void 0?null:b,v=0,S=null,F=0;b=[];var w=[],C=[],A=h();if(A!==65496)throw new a("SOI not found");for(A=h();A!==65497;){switch(A){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var T=g();A===65518&&T[0]===65&&T[1]===100&&T[2]===111&&T[3]===98&&T[4]===101&&(S={version:T[5]<<8|T[6],Y:T[7]<<8|T[8],Z:T[9]<<8|T[10],W:T[11]});break;case 65499:A=h()+v-2;for(var D;v<A;){var k=m[v++],P=new Uint16Array(64);if(k>>4===0)for(T=0;64>T;T++)D=f[T],P[D]=m[v++];else if(k>>4===1)for(T=0;64>T;T++)D=f[T],P[D]=h();else throw new a("DQT - invalid table spec");b[k&15]=P}break;case 65472:case 65473:case 65474:if(I)throw new a("Only single frame JPEGs supported");h();var I={};for(I.X=A===65473,I.S=A===65474,I.precision=m[v++],A=h(),I.g=x||A,I.v=h(),I.b=[],I.C={},T=m[v++],A=P=k=0;A<T;A++){D=m[v];var B=m[v+1]>>4,M=m[v+1]&15;k<B&&(k=B),P<M&&(P=M),B=I.b.push({h:B,j:M,T:m[v+2],G:null}),I.C[D]=B-1,v+=3}I.s=k,I.u=P,y(I);break;case 65476:for(D=h(),A=2;A<D;){for(k=m[v++],P=new Uint8Array(16),T=B=0;16>T;T++,v++)B+=P[T]=m[v];for(M=new Uint8Array(B),T=0;T<B;T++,v++)M[T]=m[v];A+=17+B,(k>>4===0?C:w)[k&15]=c(P,M)}break;case 65501:h();var L=h();break;case 65498:for(T=++F===1&&!x,h(),k=m[v++],D=[],A=0;A<k;A++){P=I.C[m[v++]];var _=I.b[P];P=m[v++],_.D=C[P>>4],_.o=w[P&15],D.push(_)}A=m[v++],k=m[v++],P=m[v++];try{var R=u(m,v,I,D,L,A,k,P>>4,P&15,T);v+=R}catch(O){if(O instanceof s)return(0,_util.warn)('Attempting to re-parse JPEG image using "scanLines" parameter found in DNL marker (0xFFDC) segment.'),this.parse(m,{N:O.g});throw O}break;case 65500:v+=4;break;case 65535:m[v]!==255&&v--;break;default:if(m[v-3]===255&&192<=m[v-2]&&254>=m[v-2])v-=3;else if((T=p(m,v-2))&&T.f)(0,_util.warn)("JpegImage.parse - unexpected data, current marker is: "+T.f),v=T.offset;else throw new a("unknown marker "+A.toString(16))}A=h()}for(this.width=I.v,this.height=I.g,this.A=S,this.b=[],A=0;A<I.b.length;A++)_=I.b[A],(L=b[_.T])&&(_.G=L),this.b.push({R:d(I,_),U:_.h/I.s,V:_.j/I.u,c:_.c,l:_.l});this.i=this.b.length},L:function(m,h){var g=this.width/m,y=this.height/h,b,x,v=this.b.length,S=m*h*v,F=new Uint8ClampedArray(S),w=new Uint32Array(m);for(x=0;x<v;x++){var C=this.b[x],A=C.U*g,T=C.V*y,D=x,k=C.R,P=C.c+1<<3;for(b=0;b<m;b++)C=0|b*A,w[b]=(C&4294967288)<<3|C&7;for(A=0;A<h;A++)for(C=0|A*T,C=P*(C&4294967288)|(C&7)<<3,b=0;b<m;b++)F[D]=k[C+w[b]],D+=v}if(y=this.M)for(x=0;x<S;)for(g=C=0;C<v;C++,x++,g+=2)F[x]=(F[x]*y[g]>>8)+y[g+1];return F},w:function(){return this.A?!!this.A.W:this.i===3?this.B!==0:this.B===1},I:function(m){for(var h,g,y,b=0,x=m.length;b<x;b+=3)h=m[b],g=m[b+1],y=m[b+2],m[b]=h-179.456+1.402*y,m[b+1]=h+135.459-.344*g-.714*y,m[b+2]=h-226.816+1.772*g;return m},K:function(m){for(var h,g,y,b,x=0,v=0,S=m.length;v<S;v+=4)h=m[v],g=m[v+1],y=m[v+2],b=m[v+3],m[x++]=-122.67195406894+g*(-660635669420364e-19*g+.000437130475926232*y-54080610064599e-18*h+.00048449797120281*b-.154362151871126)+y*(-.000957964378445773*y+.000817076911346625*h-.00477271405408747*b+1.53380253221734)+h*(.000961250184130688*h-.00266257332283933*b+.48357088451265)+b*(-.000336197177618394*b+.484791561490776),m[x++]=107.268039397724+g*(219927104525741e-19*g-.000640992018297945*y+.000659397001245577*h+.000426105652938837*b-.176491792462875)+y*(-.000778269941513683*y+.00130872261408275*h+.000770482631801132*b-.151051492775562)+h*(.00126935368114843*h-.00265090189010898*b+.25802910206845)+b*(-.000318913117588328*b-.213742400323665),m[x++]=-20.810012546947+g*(-.000570115196973677*g-263409051004589e-19*y+.0020741088115012*h-.00288260236853442*b+.814272968359295)+y*(-153496057440975e-19*y-.000132689043961446*h+.000560833691242812*b-.195152027534049)+h*(.00174418132927582*h-.00255243321439347*b+.116935020465145)+b*(-.000343531996510555*b+.24165260232407);return m.subarray(0,x)},J:function(m){for(var h,g,y,b=0,x=m.length;b<x;b+=4)h=m[b],g=m[b+1],y=m[b+2],m[b]=434.456-h-1.402*y,m[b+1]=119.541-h+.344*g+.714*y,m[b+2]=481.816-h-1.772*g;return m},H:function(m){for(var h,g,y,b,x=0,v=1/255,S=0,F=m.length;S<F;S+=4)h=m[S]*v,g=m[S+1]*v,y=m[S+2]*v,b=m[S+3]*v,m[x++]=255+h*(-4.387332384609988*h+54.48615194189176*g+18.82290502165302*y+212.25662451639585*b-285.2331026137004)+g*(1.7149763477362134*g-5.6096736904047315*y-17.873870861415444*b-5.497006427196366)+y*(-2.5217340131683033*y-21.248923337353073*b+17.5119270841813)-b*(21.86122147463605*b+189.48180835922747),m[x++]=255+h*(8.841041422036149*h+60.118027045597366*g+6.871425592049007*y+31.159100130055922*b-79.2970844816548)+g*(-15.310361306967817*g+17.575251261109482*y+131.35250912493976*b-190.9453302588951)+y*(4.444339102852739*y+9.8632861493405*b-24.86741582555878)-b*(20.737325471181034*b+187.80453709719578),m[x++]=255+h*(.8842522430003296*h+8.078677503112928*g+30.89978309703729*y-.23883238689178934*b-14.183576799673286)+g*(10.49593273432072*g+63.02378494754052*y+50.606957656360734*b-112.23884253719248)+y*(.03296041114873217*y+115.60384449646641*b-193.58209356861505)-b*(22.33816807309886*b+180.12613974708367);return m.subarray(0,x)},getData:function(m,h,g){if(4<this.i)throw new a("Unsupported color mode");if(m=this.L(m,h),this.i===1&&g){g=m.length,h=new Uint8ClampedArray(3*g);for(var y=0,b=0;b<g;b++){var x=m[b];h[y++]=x,h[y++]=x,h[y++]=x}return h}if(this.i===3&&this.w())return this.I(m);if(this.i===4){if(this.w())return g?this.K(m):this.J(m);if(g)return this.H(m)}return m}},r.JpegDecoder=l})()})(),r.encodeImage=function(i,a,s,l){var c={t256:[a],t257:[s],t258:[8,8,8,8],t259:[1],t262:[2],t273:[1e3],t277:[4],t278:[s],t279:[a*s*4],t282:[1],t283:[1],t284:[1],t286:[0],t287:[0],t296:[1],t305:["Photopea (UTIF.js)"],t338:[1]};if(l)for(var u in l)c[u]=l[u];for(var d=new Uint8Array(r.encode([c])),p=new Uint8Array(i),f=new Uint8Array(1e3+a*s*4),u=0;u<d.length;u++)f[u]=d[u];for(var u=0;u<p.length;u++)f[1e3+u]=p[u];return f.buffer},r.encode=function(i){var a=new Uint8Array(2e4),s=4,l=r._binBE;a[0]=77,a[1]=77,a[3]=42;var c=8;l.writeUint(a,s,c),s+=4;for(var u=0;u<i.length;u++){var d=r._writeIFD(l,a,c,i[u]);c=d[1],u<i.length-1&&l.writeUint(a,d[0],c)}return a.slice(0,c).buffer},r.decode=function(i){r.decode._decodeG3.allow2D=null;var a=new Uint8Array(i),s=0,l=r._binBE.readASCII(a,s,2);s+=2;var c=l=="II"?r._binLE:r._binBE,u=c.readUshort(a,s);s+=2;var d=c.readUint(a,s);s+=4;for(var p=[];;){var f=r._readIFD(c,a,d,p,0,!1);if(d=c.readUint(a,f),d==0)break}return p},r.decodeImage=function(i,a,s){var l=new Uint8Array(i),c=r._binBE.readASCII(l,0,2);if(a.t256!=null){a.isLE=c=="II",a.width=a.t256[0],a.height=a.t257[0];var u=a.t259?a.t259[0]:1,d=a.t266?a.t266[0]:1;a.t284&&a.t284[0]==2&&n("PlanarConfiguration 2 should not be used!");var p;a.t258?p=Math.min(32,a.t258[0])*a.t258.length:p=a.t277?a.t277[0]:1,u==1&&a.t279!=null&&a.t278&&a.t262[0]==32803&&(p=Math.round(a.t279[0]*8/(a.width*a.t278[0])));var f=Math.ceil(a.width*p/8)*8,m=a.t273;m==null&&(m=a.t324);var h=a.t279;u==1&&m.length==1&&(h=[a.height*(f>>>3)]),h==null&&(h=a.t325);var g=new Uint8Array(a.height*(f>>>3)),y=0;if(a.t322!=null){for(var b=a.t322[0],x=a.t323[0],v=Math.floor((a.width+b-1)/b),S=Math.floor((a.height+x-1)/x),F=new Uint8Array(Math.ceil(b*x*p/8)|0),w=0;w<S;w++)for(var C=0;C<v;C++){for(var A=w*v+C,T=0;T<F.length;T++)F[T]=0;r.decode._decompress(a,s,l,m[A],h[A],u,F,0,d),u==6?g=F:r._copyTile(F,Math.ceil(b*p/8)|0,x,g,Math.ceil(a.width*p/8)|0,a.height,Math.ceil(C*b*p/8)|0,w*x)}y=g.length*8}else{var D=a.t278?a.t278[0]:a.height;D=Math.min(D,a.height);for(var A=0;A<m.length;A++)r.decode._decompress(a,s,l,m[A],h[A],u,g,Math.ceil(y/8)|0,d),y+=f*D;y=Math.min(y,g.length*8)}a.data=new Uint8Array(g.buffer,0,Math.ceil(y/8)|0)}},r.decode._decompress=function(i,a,s,l,c,u,d,p,f){if(u==1||c==d.length&&u!=32767)for(var m=0;m<c;m++)d[p+m]=s[l+m];else if(u==3)r.decode._decodeG3(s,l,c,d,p,i.width,f);else if(u==4)r.decode._decodeG4(s,l,c,d,p,i.width,f);else if(u==5)r.decode._decodeLZW(s,l,d,p);else if(u==6)r.decode._decodeOldJPEG(i,s,l,c,d,p);else if(u==7)r.decode._decodeNewJPEG(i,s,l,c,d,p);else if(u==8)for(var h=new Uint8Array(s.buffer,l,c),g=o.inflate(h),y=0;y<g.length;y++)d[p+y]=g[y];else u==32767?r.decode._decodeARW(i,s,l,c,d,p):u==32773?r.decode._decodePackBits(s,l,c,d,p):u==32809?r.decode._decodeThunder(s,l,c,d,p):u==34713?r.decode._decodeNikon(i,a,s,l,c,d,p):n("Unknown compression",u);var b=i.t258?Math.min(32,i.t258[0]):1,x=i.t277?i.t277[0]:1,v=b*x>>>3,S=i.t278?i.t278[0]:i.height,F=Math.ceil(b*x*i.width/8);if(b==16&&!i.isLE&&i.t33422==null)for(var w=0;w<S;w++)for(var C=p+w*F,A=1;A<F;A+=2){var T=d[C+A];d[C+A]=d[C+A-1],d[C+A-1]=T}if(i.t317&&i.t317[0]==2)for(var w=0;w<S;w++){var D=p+w*F;if(b==16)for(var m=v;m<F;m+=2){var k=(d[D+m+1]<<8|d[D+m])+(d[D+m-v+1]<<8|d[D+m-v]);d[D+m]=k&255,d[D+m+1]=k>>>8&255}else if(x==3)for(var m=3;m<F;m+=3)d[D+m]=d[D+m]+d[D+m-3]&255,d[D+m+1]=d[D+m+1]+d[D+m-2]&255,d[D+m+2]=d[D+m+2]+d[D+m-1]&255;else for(var m=v;m<F;m++)d[D+m]=d[D+m]+d[D+m-v]&255}},r.decode._ljpeg_diff=function(i,a,s){var l=r.decode._getbithuff,c,u;return c=l(i,a,s[0],s),u=l(i,a,c,0),(u&1<<c-1)==0&&(u-=(1<<c)-1),u},r.decode._decodeARW=function(i,a,s,l,c,u){var d=i.t256[0],p=i.t257[0],f=i.t258[0],m=i.isLE?r._binLE:r._binBE,h=d*p==l||d*p*1.5==l;if(!h){p+=8;var g=[s,0,0,0],y=new Uint16Array(32770),b=[3857,3856,3599,3342,3085,2828,2571,2314,2057,1800,1543,1286,1029,772,771,768,514,513],z,x,v,I,P,S=0,F=r.decode._ljpeg_diff;for(y[0]=15,v=z=0;z<18;z++)for(var w=32768>>>(b[z]>>>8),x=0;x<w;x++)y[++v]=b[z];for(I=d;I--;)for(P=0;P<p+1;P+=2)if(P==p&&(P=1),S+=F(a,g,y),P<p){var C=S&4095;r.decode._putsF(c,(P*d+I)*f,C<<16-f)}return}if(d*p*1.5==l){for(var z=0;z<l;z+=3){var A=a[s+z+0],T=a[s+z+1],D=a[s+z+2];c[u+z]=T<<4|A>>>4,c[u+z+1]=A<<4|D>>>4,c[u+z+2]=D<<4|T>>>4}return}var k=new Uint16Array(16),P,I,B,M,L,_,R,O,N,z,U,H=new Uint8Array(d+1);for(P=0;P<p;P++){for(var V=0;V<d;V++)H[V]=a[s++];for(U=0,I=0;I<d-30;U+=16){for(M=2047&(B=m.readUint(H,U)),L=2047&B>>>11,_=15&B>>>22,R=15&B>>>26,O=0;O<4&&128<<O<=M-L;O++);for(N=30,z=0;z<16;z++)z==_?k[z]=M:z==R?k[z]=L:(k[z]=((m.readUshort(H,U+(N>>3))>>>(N&7)&127)<<O)+L,k[z]>2047&&(k[z]=2047),N+=7);for(z=0;z<16;z++,I+=2){var C=k[z]<<1;r.decode._putsF(c,(P*d+I)*f,C<<16-f)}I-=I&1?1:31}}},r.decode._decodeNikon=function(i,a,s,l,c,u,d){var p=[[0,0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,5,4,3,6,2,7,1,0,8,9,11,10,12],[0,0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,57,90,56,39,22,5,4,3,2,1,0,11,12,12],[0,0,1,4,2,3,1,2,0,0,0,0,0,0,0,0,0,5,4,6,3,7,2,8,1,9,0,10,11,12],[0,0,1,4,3,1,1,1,1,1,2,0,0,0,0,0,0,5,6,4,7,8,3,9,2,1,0,10,11,12,13,14],[0,0,1,5,1,1,1,1,1,1,1,2,0,0,0,0,0,8,92,75,58,41,7,6,5,4,3,2,1,0,13,14],[0,0,1,4,2,2,3,1,2,0,0,0,0,0,0,0,0,7,6,8,5,9,4,10,3,11,12,2,0,1,13,14]],f=i.t256[0],m=i.t257[0],h=i.t258[0],g=0,y=0,b=r.decode._make_decoder,x=r.decode._getbithuff,v=a[0].exifIFD.makerNote,S=v.t150?v.t150:v.t140,F=0,w=S[F++],C=S[F++];(w==73||C==88)&&(F+=2110),w==70&&(g=2),h==14&&(g+=3);for(var A=[[0,0],[0,0]],T=i.isLE?r._binLE:r._binBE,B=0;B<2;B++)for(var D=0;D<2;D++)A[B][D]=T.readShort(S,F),F+=2;var k=1<<h&32767,P=0,I=T.readShort(S,F);F+=2,I>1&&(P=Math.floor(k/(I-1))),w==68&&C==32&&P>0&&(y=T.readShort(S,562));var B,M,L,_,R,O,N=0,z=[0,0],U=b(p[g]),H=[l,0,0,0];for(N=M=0;M<m;M++)for(y&&M==y&&(U=b(p[g+1])),L=0;L<f;L++){B=x(s,H,U[0],U),_=B&15,R=B>>>4,O=(x(s,H,_-R,0)<<1)+1<<R>>>1,(O&1<<_-1)==0&&(O-=(1<<_)-(R==0?1:0)),L<2?z[L]=A[M&1][L]+=O:z[L&1]+=O;var V=Math.min(Math.max(z[L&1],0),(1<<h)-1),ne=(M*f+L)*h;r.decode._putsF(u,ne,V<<16-h)}},r.decode._putsF=function(i,a,s){s=s<<8-(a&7);var l=a>>>3;i[l]|=s>>>16,i[l+1]|=s>>>8,i[l+2]|=s},r.decode._getbithuff=function(i,a,s,l){var c=0,u=r.decode._get_byte,d,p=a[0],f=a[1],m=a[2],h=a[3];if(s==0||m<0)return 0;for(;!h&&m<s&&(d=i[p++])!=-1&&!(h=c&&d==255&&i[p++]);)f=(f<<8)+d,m+=8;if(d=f<<32-m>>>32-s,l?(m-=l[d+1]>>>8,d=l[d+1]&255):m-=s,m<0)throw"e";return a[0]=p,a[1]=f,a[2]=m,a[3]=h,d},r.decode._make_decoder=function(i){var a,s,l,c,u,d=[];for(a=16;a!=0&&!i[a];a--);var p=17;for(d[0]=a,l=s=1;s<=a;s++)for(c=0;c<i[s];c++,++p)for(u=0;u<1<<a-s;u++)l<=1<<a&&(d[l++]=s<<8|i[p]);return d},r.decode._decodeNewJPEG=function(i,a,s,l,c,u){var d=i.t347,p=d?d.length:0,f=new Uint8Array(p+l);if(d){for(var m=216,h=217,g=0,y=0;y<p-1&&!(d[y]==255&&d[y+1]==h);y++)f[g++]=d[y];var b=a[s],x=a[s+1];(b!=255||x!=m)&&(f[g++]=b,f[g++]=x);for(var y=2;y<l;y++)f[g++]=a[s+y]}else for(var y=0;y<l;y++)f[y]=a[s+y];if(i.t262[0]==32803||i.t262[0]==34892){var v=i.t258[0],S=r.LosslessJpegDecode(f),F=S.length;if(v==16)if(i.isLE)for(var y=0;y<F;y++)c[u+(y<<1)]=S[y]&255,c[u+(y<<1)+1]=S[y]>>>8;else for(var y=0;y<F;y++)c[u+(y<<1)]=S[y]>>>8,c[u+(y<<1)+1]=S[y]&255;else if(v==14||v==12)for(var w=16-v,y=0;y<F;y++)r.decode._putsF(c,y*v,S[y]<<w);else throw new Error("unsupported bit depth "+v)}else{var C=new r.JpegDecoder;C.parse(f);for(var A=C.getData(C.width,C.height),y=0;y<A.length;y++)c[u+y]=A[y]}i.t262[0]==6&&(i.t262[0]=2)},r.decode._decodeOldJPEGInit=function(i,a,s,l){var c=216,u=217,d=219,p=196,f=221,m=192,h=218,g=0,y=0,b,x,v=!1,S,F,w,C=i.t513,A=C?C[0]:0,T=i.t514,D=T?T[0]:0,k=i.t324||i.t273||C,P=i.t530,I=0,B=0,M=i.t277?i.t277[0]:1,L=i.t515;if(k&&(y=k[0],v=k.length>1),!v){if(a[s]==255&&a[s+1]==c)return{jpegOffset:s};if(C!=null&&(a[s+A]==255&&a[s+A+1]==c?g=s+A:n("JPEGInterchangeFormat does not point to SOI"),T==null?n("JPEGInterchangeFormatLength field is missing"):(A>=y||A+D<=y)&&n("JPEGInterchangeFormatLength field value is invalid"),g!=null))return{jpegOffset:g}}if(P!=null&&(I=P[0],B=P[1]),C!=null&&T!=null)if(D>=2&&A+D<=y){for(a[s+A+D-2]==255&&a[s+A+D-1]==c?b=new Uint8Array(D-2):b=new Uint8Array(D),S=0;S<b.length;S++)b[S]=a[s+A+S];n("Incorrect JPEG interchange format: using JPEGInterchangeFormat offset to derive tables")}else n("JPEGInterchangeFormat+JPEGInterchangeFormatLength > offset to first strip or tile");if(b==null){var _=0,R=[];R[_++]=255,R[_++]=c;var O=i.t519;if(O==null)throw new Error("JPEGQTables tag is missing");for(S=0;S<O.length;S++)for(R[_++]=255,R[_++]=d,R[_++]=0,R[_++]=67,R[_++]=S,F=0;F<64;F++)R[_++]=a[s+O[S]+F];for(w=0;w<2;w++){var N=i[w==0?"t520":"t521"];if(N==null)throw new Error((w==0?"JPEGDCTables":"JPEGACTables")+" tag is missing");for(S=0;S<N.length;S++){R[_++]=255,R[_++]=p;var z=19;for(F=0;F<16;F++)z+=a[s+N[S]+F];for(R[_++]=z>>>8,R[_++]=z&255,R[_++]=S|w<<4,F=0;F<16;F++)R[_++]=a[s+N[S]+F];for(F=0;F<z;F++)R[_++]=a[s+N[S]+16+F]}}if(R[_++]=255,R[_++]=m,R[_++]=0,R[_++]=8+3*M,R[_++]=8,R[_++]=i.height>>>8&255,R[_++]=i.height&255,R[_++]=i.width>>>8&255,R[_++]=i.width&255,R[_++]=M,M==1)R[_++]=1,R[_++]=17,R[_++]=0;else for(S=0;S<3;S++)R[_++]=S+1,R[_++]=S!=0?17:(I&15)<<4|B&15,R[_++]=S;L!=null&&L[0]!=0&&(R[_++]=255,R[_++]=f,R[_++]=0,R[_++]=4,R[_++]=L[0]>>>8&255,R[_++]=L[0]&255),b=new Uint8Array(R)}var U=-1;for(S=0;S<b.length-1;){if(b[S]==255&&b[S+1]==m){U=S;break}S++}if(U==-1){var H=new Uint8Array(b.length+10+3*M);H.set(b);var V=b.length;if(U=b.length,b=H,b[V++]=255,b[V++]=m,b[V++]=0,b[V++]=8+3*M,b[V++]=8,b[V++]=i.height>>>8&255,b[V++]=i.height&255,b[V++]=i.width>>>8&255,b[V++]=i.width&255,b[V++]=M,M==1)b[V++]=1,b[V++]=17,b[V++]=0;else for(S=0;S<3;S++)b[V++]=S+1,b[V++]=S!=0?17:(I&15)<<4|B&15,b[V++]=S}if(a[y]==255&&a[y+1]==h){var ne=a[y+2]<<8|a[y+3];for(x=new Uint8Array(ne+2),x[0]=a[y],x[1]=a[y+1],x[2]=a[y+2],x[3]=a[y+3],S=0;S<ne-2;S++)x[S+4]=a[y+S+4]}else{x=new Uint8Array(8+2*M);var Z=0;if(x[Z++]=255,x[Z++]=h,x[Z++]=0,x[Z++]=6+2*M,x[Z++]=M,M==1)x[Z++]=1,x[Z++]=0;else for(S=0;S<3;S++)x[Z++]=S+1,x[Z++]=S<<4|S;x[Z++]=0,x[Z++]=63,x[Z++]=0}return{jpegOffset:s,tables:b,sosMarker:x,sofPosition:U}},r.decode._decodeOldJPEG=function(i,a,s,l,c,u){var d,p,f,m,h,g=r.decode._decodeOldJPEGInit(i,a,s,l);if(g.jpegOffset!=null)for(p=s+l-g.jpegOffset,m=new Uint8Array(p),d=0;d<p;d++)m[d]=a[g.jpegOffset+d];else{for(f=g.tables.length,m=new Uint8Array(f+g.sosMarker.length+l+2),m.set(g.tables),h=f,m[g.sofPosition+5]=i.height>>>8&255,m[g.sofPosition+6]=i.height&255,m[g.sofPosition+7]=i.width>>>8&255,m[g.sofPosition+8]=i.width&255,(a[s]!=255||a[s+1]!=SOS)&&(m.set(g.sosMarker,h),h+=sosMarker.length),d=0;d<l;d++)m[h++]=a[s+d];m[h++]=255,m[h++]=EOI}var y=new r.JpegDecoder;y.parse(m);for(var b=y.getData(y.width,y.height),d=0;d<b.length;d++)c[u+d]=b[d];i.t262&&i.t262[0]==6&&(i.t262[0]=2)},r.decode._decodePackBits=function(i,a,s,l,c){for(var u=new Int8Array(i.buffer),d=new Int8Array(l.buffer),p=a+s;a<p;){var f=u[a];if(a++,f>=0&&f<128)for(var m=0;m<f+1;m++)d[c]=u[a],c++,a++;if(f>=-127&&f<0){for(var m=0;m<-f+1;m++)d[c]=u[a],c++;a++}}},r.decode._decodeThunder=function(i,a,s,l,c){for(var u=[0,1,0,-1],d=[0,1,2,3,0,-3,-2,-1],p=a+s,f=c*2,m=0;a<p;){var h=i[a],g=h>>>6,y=h&63;if(a++,g==3&&(m=y&15,l[f>>>1]|=m<<4*(1-f&1),f++),g==0)for(var b=0;b<y;b++)l[f>>>1]|=m<<4*(1-f&1),f++;if(g==2)for(var b=0;b<2;b++){var x=y>>>3*(1-b)&7;x!=4&&(m+=d[x],l[f>>>1]|=m<<4*(1-f&1),f++)}if(g==1)for(var b=0;b<3;b++){var x=y>>>2*(2-b)&3;x!=2&&(m+=u[x],l[f>>>1]|=m<<4*(1-f&1),f++)}}},r.decode._dmap={1:0,"011":1,"000011":2,"0000011":3,"010":-1,"000010":-2,"0000010":-3},r.decode._lens=(function(){var i=function(f,m,h,g){for(var y=0;y<m.length;y++)f[m[y]]=h+y*g},a="00110101,000111,0111,1000,1011,1100,1110,1111,10011,10100,00111,01000,001000,000011,110100,110101,101010,101011,0100111,0001100,0001000,0010111,0000011,0000100,0101000,0101011,0010011,0100100,0011000,00000010,00000011,00011010,00011011,00010010,00010011,00010100,00010101,00010110,00010111,00101000,00101001,00101010,00101011,00101100,00101101,00000100,00000101,00001010,00001011,01010010,01010011,01010100,01010101,00100100,00100101,01011000,01011001,01011010,01011011,01001010,01001011,00110010,00110011,00110100",s="0000110111,010,11,10,011,0011,0010,00011,000101,000100,0000100,0000101,0000111,00000100,00000111,000011000,0000010111,0000011000,0000001000,00001100111,00001101000,00001101100,00000110111,00000101000,00000010111,00000011000,000011001010,000011001011,000011001100,000011001101,000001101000,000001101001,000001101010,000001101011,000011010010,000011010011,000011010100,000011010101,000011010110,000011010111,000001101100,000001101101,000011011010,000011011011,000001010100,000001010101,000001010110,000001010111,000001100100,000001100101,000001010010,000001010011,000000100100,000000110111,000000111000,000000100111,000000101000,000001011000,000001011001,000000101011,000000101100,000001011010,000001100110,000001100111",l="11011,10010,010111,0110111,00110110,00110111,01100100,01100101,01101000,01100111,011001100,011001101,011010010,011010011,011010100,011010101,011010110,011010111,011011000,011011001,011011010,011011011,010011000,010011001,010011010,011000,010011011",c="0000001111,000011001000,000011001001,000001011011,000000110011,000000110100,000000110101,0000001101100,0000001101101,0000001001010,0000001001011,0000001001100,0000001001101,0000001110010,0000001110011,0000001110100,0000001110101,0000001110110,0000001110111,0000001010010,0000001010011,0000001010100,0000001010101,0000001011010,0000001011011,0000001100100,0000001100101",u="00000001000,00000001100,00000001101,000000010010,000000010011,000000010100,000000010101,000000010110,000000010111,000000011100,000000011101,000000011110,000000011111";a=a.split(","),s=s.split(","),l=l.split(","),c=c.split(","),u=u.split(",");var d={},p={};return i(d,a,0,1),i(d,l,64,64),i(d,u,1792,64),i(p,s,0,1),i(p,c,64,64),i(p,u,1792,64),[d,p]})(),r.decode._decodeG4=function(i,a,s,l,c,u,d){for(var p=r.decode,f=a<<3,m=0,h="",g=[],y=[],b=0;b<u;b++)y.push(0);y=p._makeDiff(y);for(var x=0,v=0,S=0,F=0,w=0,C=0,A=0,T="",D=0,k=Math.ceil(u/8)*8;f>>>3<a+s;){F=p._findDiff(y,x+(x==0?0:1),1-C),w=p._findDiff(y,F,C);var P=0;if(d==1&&(P=i[f>>>3]>>>7-(f&7)&1),d==2&&(P=i[f>>>3]>>>(f&7)&1),f++,h+=P,T=="H"){if(p._lens[C][h]!=null){var I=p._lens[C][h];h="",m+=I,I<64&&(p._addNtimes(g,m,C),x+=m,C=1-C,m=0,D--,D==0&&(T=""))}}else h=="0001"&&(h="",p._addNtimes(g,w-x,C),x=w),h=="001"&&(h="",T="H",D=2),p._dmap[h]!=null&&(v=F+p._dmap[h],p._addNtimes(g,v-x,C),x=v,h="",C=1-C);g.length==u&&T==""&&(p._writeBits(g,l,c*8+A*k),C=0,A++,x=0,y=p._makeDiff(g),g=[])}},r.decode._findDiff=function(i,a,s){for(var l=0;l<i.length;l+=2)if(i[l]>=a&&i[l+1]==s)return i[l]},r.decode._makeDiff=function(i){var a=[];i[0]==1&&a.push(0,1);for(var s=1;s<i.length;s++)i[s-1]!=i[s]&&a.push(s,i[s]);return a.push(i.length,0,i.length,1),a},r.decode._decodeG3=function(i,a,s,l,c,u,d){for(var p=r.decode,f=a<<3,m=0,h="",g=[],y=[],b=0;b<u;b++)g.push(0);for(var x=0,v=0,S=0,F=0,w=0,C=0,A=-1,T="",D=0,k=!1,P=Math.ceil(u/8)*8;f>>>3<a+s;){F=p._findDiff(y,x+(x==0?0:1),1-C),w=p._findDiff(y,F,C);var I=0;if(d==1&&(I=i[f>>>3]>>>7-(f&7)&1),d==2&&(I=i[f>>>3]>>>(f&7)&1),f++,h+=I,k){if(p._lens[C][h]!=null){var B=p._lens[C][h];h="",m+=B,B<64&&(p._addNtimes(g,m,C),C=1-C,m=0)}}else if(T=="H"){if(p._lens[C][h]!=null){var B=p._lens[C][h];h="",m+=B,B<64&&(p._addNtimes(g,m,C),x+=m,C=1-C,m=0,D--,D==0&&(T=""))}}else h=="0001"&&(h="",p._addNtimes(g,w-x,C),x=w),h=="001"&&(h="",T="H",D=2),p._dmap[h]!=null&&(v=F+p._dmap[h],p._addNtimes(g,v-x,C),x=v,h="",C=1-C);h.endsWith("000000000001")&&(A>=0&&p._writeBits(g,l,c*8+A*P),d==1&&(k=(i[f>>>3]>>>7-(f&7)&1)==1),d==2&&(k=(i[f>>>3]>>>(f&7)&1)==1),f++,p._decodeG3.allow2D==null&&(p._decodeG3.allow2D=k),p._decodeG3.allow2D||(k=!0,f--),h="",C=0,A++,x=0,y=p._makeDiff(g),g=[])}g.length==u&&p._writeBits(g,l,c*8+A*P)},r.decode._addNtimes=function(i,a,s){for(var l=0;l<a;l++)i.push(s)},r.decode._writeBits=function(i,a,s){for(var l=0;l<i.length;l++)a[s+l>>>3]|=i[l]<<7-(s+l&7)},r.decode._decodeLZW=function(i,a,s,l){if(r.decode._lzwTab==null){for(var c=new Uint32Array(65535),u=new Uint16Array(65535),h=new Uint8Array(2e6),d=0;d<256;d++)h[d<<2]=d,c[d]=d<<2,u[d]=1;r.decode._lzwTab=[c,u,h]}for(var p=r.decode._copyData,f=r.decode._lzwTab[0],m=r.decode._lzwTab[1],h=r.decode._lzwTab[2],g=258,y=1032,b=9,x=a<<3,v=256,S=257,F=0,w=0,C=0;F=i[x>>>3]<<16|i[x+8>>>3]<<8|i[x+16>>>3],w=F>>24-(x&7)-b&(1<<b)-1,x+=b,w!=S;){if(w==v){if(b=9,g=258,y=1032,F=i[x>>>3]<<16|i[x+8>>>3]<<8|i[x+16>>>3],w=F>>24-(x&7)-b&(1<<b)-1,x+=b,w==S)break;s[l]=w,l++}else if(w<g){var A=f[w],T=m[w];if(p(h,A,s,l,T),l+=T,C>=g)f[g]=y,h[f[g]]=A[0],m[g]=1,y=y+1+3&-4,g++;else{f[g]=y;var D=f[C],k=m[C];p(h,D,h,y,k),h[y+k]=h[A],k++,m[g]=k,g++,y=y+k+3&-4}g+1==1<<b&&b++}else{if(C>=g)f[g]=y,m[g]=0,g++;else{f[g]=y;var D=f[C],k=m[C];p(h,D,h,y,k),h[y+k]=h[y],k++,m[g]=k,g++,p(h,y,s,l,k),l+=k,y=y+k+3&-4}g+1==1<<b&&b++}C=w}},r.decode._copyData=function(i,a,s,l,c){for(var u=0;u<c;u+=4)s[l+u]=i[a+u],s[l+u+1]=i[a+u+1],s[l+u+2]=i[a+u+2],s[l+u+3]=i[a+u+3]},r.tags={},r.ttypes={256:3,257:3,258:3,259:3,262:3,273:4,274:3,277:3,278:4,279:4,282:5,283:5,284:3,286:5,287:5,296:3,305:2,306:2,338:3,513:4,514:4,34665:4},r._readIFD=function(i,a,s,l,c,u){var d=i.readUshort(a,s);s+=2;var p={};l.push(p),u&&n(" ".repeat(c),l.length-1,">>>----------------");for(var f=0;f<d;f++){var m=i.readUshort(a,s);s+=2;var h=i.readUshort(a,s);s+=2;var g=i.readUint(a,s);s+=4;var y=i.readUint(a,s);s+=4;var b=[];if((h==1||h==7)&&(b=new Uint8Array(a.buffer,g<5?s-4:y,g)),h==2){var x=g<5?s-4:y,v=a[x];v<128?b.push(i.readASCII(a,x,g-1)):b=new Uint8Array(a.buffer,x,g-1)}if(h==3)for(var S=0;S<g;S++)b.push(i.readUshort(a,(g<3?s-4:y)+2*S));if(h==4)for(var S=0;S<g;S++)b.push(i.readUint(a,(g<2?s-4:y)+4*S));if(h==5)for(var S=0;S<g;S++)b.push(i.readUint(a,y+S*8)/i.readUint(a,y+S*8+4));if(h==8)for(var S=0;S<g;S++)b.push(i.readShort(a,(g<3?s-4:y)+2*S));if(h==9)for(var S=0;S<g;S++)b.push(i.readInt(a,(g<2?s-4:y)+4*S));if(h==10)for(var S=0;S<g;S++)b.push(i.readInt(a,y+S*8)/i.readInt(a,y+S*8+4));if(h==11)for(var S=0;S<g;S++)b.push(i.readFloat(a,y+S*4));if(h==12)for(var S=0;S<g;S++)b.push(i.readDouble(a,y+S*8));if(p["t"+m]=b,g!=0&&b.length==0&&n("unknown TIFF tag type: ",h,"num:",g),u&&n(" ".repeat(c),m,h,r.tags[m],b),!(m==330&&p.t272&&p.t272[0]=="DSLR-A100")){if(m==330||m==34665||m==50740&&i.readUshort(a,i.readUint(b,0))<300){for(var F=m==50740?[i.readUint(b,0)]:b,w=[],S=0;S<F.length;S++)r._readIFD(i,a,F[S],w,c+1,u);m==330&&(p.subIFD=w),m==34665&&(p.exifIFD=w[0]),m==50740&&(p.dngPrvt=w[0])}}if(m==37500){var C=b;if(i.readASCII(C,0,5)=="Nikon")p.makerNote=r.decode(C.slice(10).buffer)[0];else if(i.readUshort(a,y)<300){var A=[];r._readIFD(i,a,y,A,c+1,u),p.makerNote=A[0]}}}return u&&n(" ".repeat(c),"<<<---------------"),s},r._writeIFD=function(i,a,s,l){var c=Object.keys(l);i.writeUshort(a,s,c.length),s+=2;for(var u=s+c.length*12+4,d=0;d<c.length;d++){var p=c[d],f=parseInt(p.slice(1)),m=r.ttypes[f];if(m==null)throw new Error("unknown type of tag: "+f);var h=l[p];m==2&&(h=h[0]+"\0");var g=h.length;i.writeUshort(a,s,f),s+=2,i.writeUshort(a,s,m),s+=2,i.writeUint(a,s,g),s+=4;var y=[-1,1,1,2,4,8,0,0,0,0,0,0,8][m]*g,b=s;if(y>4&&(i.writeUint(a,s,u),b=u),m==2&&i.writeASCII(a,b,h),m==3)for(var x=0;x<g;x++)i.writeUshort(a,b+2*x,h[x]);if(m==4)for(var x=0;x<g;x++)i.writeUint(a,b+4*x,h[x]);if(m==5)for(var x=0;x<g;x++)i.writeUint(a,b+8*x,Math.round(h[x]*1e4)),i.writeUint(a,b+8*x+4,1e4);if(m==12)for(var x=0;x<g;x++)i.writeDouble(a,b+8*x,h[x]);y>4&&(y+=y&1,u+=y),s+=4}return[s,u]},r.toRGBA8=function(i){var a=i.width,s=i.height,l=a*s,c=l*4,u=i.data,d=new Uint8Array(l*4),p=i.t262?i.t262[0]:2,f=i.t258?Math.min(32,i.t258[0]):1;if(p==0)for(var m=Math.ceil(f*a/8),h=0;h<s;h++){var g=h*m,y=h*a;if(f==1)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(b>>3)]>>7-(b&7)&1;d[x]=d[x+1]=d[x+2]=(1-v)*255,d[x+3]=255}if(f==4)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(b>>1)]>>4-4*(b&1)&15;d[x]=d[x+1]=d[x+2]=(15-v)*17,d[x+3]=255}if(f==8)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+b];d[x]=d[x+1]=d[x+2]=255-v,d[x+3]=255}}else if(p==1)for(var m=Math.ceil(f*a/8),h=0;h<s;h++){var g=h*m,y=h*a;if(f==1)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(b>>3)]>>7-(b&7)&1;d[x]=d[x+1]=d[x+2]=v*255,d[x+3]=255}if(f==2)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(b>>2)]>>6-2*(b&3)&3;d[x]=d[x+1]=d[x+2]=v*85,d[x+3]=255}if(f==8)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+b];d[x]=d[x+1]=d[x+2]=v,d[x+3]=255}if(f==16)for(var b=0;b<a;b++){var x=y+b<<2,v=u[g+(2*b+1)];d[x]=d[x+1]=d[x+2]=Math.min(255,v),d[x+3]=255}}else if(p==2){var S=i.t258?i.t258.length:3;if(f==8){if(S==4)for(var b=0;b<c;b++)d[b]=u[b];if(S==3)for(var b=0;b<l;b++){var x=b<<2,F=b*3;d[x]=u[F],d[x+1]=u[F+1],d[x+2]=u[F+2],d[x+3]=255}}else{if(S==4)for(var b=0;b<l;b++){var x=b<<2,F=b*8+1;d[x]=u[F],d[x+1]=u[F+2],d[x+2]=u[F+4],d[x+3]=u[F+6]}if(S==3)for(var b=0;b<l;b++){var x=b<<2,F=b*6+1;d[x]=u[F],d[x+1]=u[F+2],d[x+2]=u[F+4],d[x+3]=255}}}else if(p==3)for(var w=i.t320,b=0;b<l;b++){var x=b<<2,C=u[b];d[x]=w[C]>>8,d[x+1]=w[256+C]>>8,d[x+2]=w[512+C]>>8,d[x+3]=255}else if(p==5)for(var S=i.t258?i.t258.length:4,A=S>4?1:0,b=0;b<l;b++){var x=b<<2,T=b*S,D=255-u[T],k=255-u[T+1],P=255-u[T+2],I=(255-u[T+3])*(1/255);d[x]=~~(D*I+.5),d[x+1]=~~(k*I+.5),d[x+2]=~~(P*I+.5),d[x+3]=255*(1-A)+u[T+4]*A}else n("Unknown Photometric interpretation: "+p);return d},r.replaceIMG=function(i){i==null&&(i=document.getElementsByTagName("img"));for(var a=["tif","tiff","dng","cr2","nef"],s=0;s<i.length;s++){var l=i[s],c=l.getAttribute("src");if(c!=null){var u=c.split(".").pop().toLowerCase();if(a.indexOf(u)!=-1){var d=new XMLHttpRequest;r._xhrs.push(d),r._imgs.push(l),d.open("GET",c),d.responseType="arraybuffer",d.onload=r._imgLoaded,d.send()}}}},r._xhrs=[],r._imgs=[],r._imgLoaded=function(i){var a=i.target.response,s=r.decode(a),l=s,c=0,u=l[0];s[0].subIFD&&(l=l.concat(s[0].subIFD));for(var d=0;d<l.length;d++){var y=l[d];if(!(y.t258==null||y.t258.length<3)){var p=y.t256*y.t257;p>c&&(c=p,u=y)}}r.decodeImage(a,u,s);var f=r.toRGBA8(u),m=u.width,h=u.height,g=r._xhrs.indexOf(i.target),y=r._imgs[g];r._xhrs.splice(g,1),r._imgs.splice(g,1);var b=document.createElement("canvas");b.width=m,b.height=h;for(var x=b.getContext("2d"),v=x.createImageData(m,h),d=0;d<f.length;d++)v.data[d]=f[d];x.putImageData(v,0,0),y.setAttribute("src",b.toDataURL())},r._binBE={nextZero:function(i,a){for(;i[a]!=0;)a++;return a},readUshort:function(i,a){return i[a]<<8|i[a+1]},readShort:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+1],s[1]=i[a+0],r._binBE.i16[0]},readInt:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+3],s[1]=i[a+2],s[2]=i[a+1],s[3]=i[a+0],r._binBE.i32[0]},readUint:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+3],s[1]=i[a+2],s[2]=i[a+1],s[3]=i[a+0],r._binBE.ui32[0]},readASCII:function(i,a,s){for(var l="",c=0;c<s;c++)l+=String.fromCharCode(i[a+c]);return l},readFloat:function(i,a){for(var s=r._binBE.ui8,l=0;l<4;l++)s[l]=i[a+3-l];return r._binBE.fl32[0]},readDouble:function(i,a){for(var s=r._binBE.ui8,l=0;l<8;l++)s[l]=i[a+7-l];return r._binBE.fl64[0]},writeUshort:function(i,a,s){i[a]=s>>8&255,i[a+1]=s&255},writeUint:function(i,a,s){i[a]=s>>24&255,i[a+1]=s>>16&255,i[a+2]=s>>8&255,i[a+3]=s>>0&255},writeASCII:function(i,a,s){for(var l=0;l<s.length;l++)i[a+l]=s.charCodeAt(l)},writeDouble:function(i,a,s){r._binBE.fl64[0]=s;for(var l=0;l<8;l++)i[a+l]=r._binBE.ui8[7-l]}},r._binBE.ui8=new Uint8Array(8),r._binBE.i16=new Int16Array(r._binBE.ui8.buffer),r._binBE.i32=new Int32Array(r._binBE.ui8.buffer),r._binBE.ui32=new Uint32Array(r._binBE.ui8.buffer),r._binBE.fl32=new Float32Array(r._binBE.ui8.buffer),r._binBE.fl64=new Float64Array(r._binBE.ui8.buffer),r._binLE={nextZero:r._binBE.nextZero,readUshort:function(i,a){return i[a+1]<<8|i[a]},readShort:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+0],s[1]=i[a+1],r._binBE.i16[0]},readInt:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+0],s[1]=i[a+1],s[2]=i[a+2],s[3]=i[a+3],r._binBE.i32[0]},readUint:function(i,a){var s=r._binBE.ui8;return s[0]=i[a+0],s[1]=i[a+1],s[2]=i[a+2],s[3]=i[a+3],r._binBE.ui32[0]},readASCII:r._binBE.readASCII,readFloat:function(i,a){for(var s=r._binBE.ui8,l=0;l<4;l++)s[l]=i[a+l];return r._binBE.fl32[0]},readDouble:function(i,a){for(var s=r._binBE.ui8,l=0;l<8;l++)s[l]=i[a+l];return r._binBE.fl64[0]}},r._copyTile=function(i,a,s,l,c,u,d,p){for(var f=Math.min(a,c-d),m=Math.min(s,u-p),h=0;h<m;h++)for(var g=(p+h)*c+d,y=h*a,b=0;b<f;b++)l[g+b]=i[y+b]},r.LosslessJpegDecode=(function(){function i(c){this.w=c,this.N=0,this._=0,this.G=0}i.prototype={t:function(c){this.N=Math.max(0,Math.min(this.w.length,c))},i:function(){return this.w[this.N++]},l:function(){var c=this.N;return this.N+=2,this.w[c]<<8|this.w[c+1]},J:function(){return this._==0&&(this.G=this.w[this.N],this.N+=1+(this.G+1>>>8),this._=8),this.G>>>--this._&1},Z:function(c){var u=this._,d=this.G,p=Math.min(u,c);c-=p,u-=p;for(var f=d>>>u&(1<<p)-1;c>0;)d=this.w[this.N],this.N+=1+(d+1>>>8),p=Math.min(8,c),c-=p,u=8-p,f<<=p,f|=d>>>u&(1<<p)-1;return this._=u,this.G=d,f}};var a={};a.X=function(){return[0,0,-1]},a.s=function(c,u,d){c[a.Y(c,0,d)+2]=u},a.Y=function(c,u,d){if(c[u+2]!=-1)return 0;if(d==0)return u;for(var p=0;p<2;p++){c[u+p]==0&&(c[u+p]=c.length,c.push(0),c.push(0),c.push(-1));var f=a.Y(c,c[u+p],d-1);if(f!=0)return f}return 0},a.B=function(c,u){for(var d=0,p=0,f=0,m=u._,h=u.G,g=u.N;;)if(m==0&&(h=u.w[g],g+=1+(h+1>>>8),m=8),f=h>>>--m&1,d=c[d+f],p=c[d+2],p!=-1)return u._=m,u.G=h,u.N=g,p;return-1};function s(c){this.z=new i(c),this.D(this.z)}s.prototype={$:function(c,u){this.Q=c.i(),this.F=c.l(),this.o=c.l();var d=this.O=c.i();this.L=[];for(var p=0;p<d;p++){var f=c.i(),m=c.i();c.i(),this.L[f]=p}c.t(c.N+u-(6+d*3))},e:function(){var c=0,u=this.z.i();this.H==null&&(this.H={});for(var d=this.H[u]=a.X(),p=[],f=0;f<16;f++)p[f]=this.z.i(),c+=p[f];for(var f=0;f<16;f++)for(var m=0;m<p[f];m++)a.s(d,this.z.i(),f+1);return c+17},W:function(c){for(;c>0;)c-=this.e()},p:function(c,u){var d=c.i();this.U||(this.U=[]);for(var p=0;p<d;p++){var f=c.i(),m=c.i();this.U[this.L[f]]=this.H[m>>>4]}this.g=c.i(),c.t(c.N+u-(2+d*2))},D:function(c){var u=!1,d=c.l();if(d===s.q)do{var d=c.l(),p=c.l()-2;switch(d){case s.m:this.$(c,p);break;case s.K:this.W(p);break;case s.V:this.p(c,p),u=!0;break;default:c.t(c.N+p);break}}while(!u)},I:function(c,u){var d=a.B(u,c);if(d==16)return-32768;var p=c.Z(d);return(p&1<<d-1)==0&&(p-=(1<<d)-1),p},B:function(c,u){for(var d=this.z,p=this.O,f=this.F,m=this.I,h=this.g,g=this.o*p,y=this.U,b=0;b<p;b++)c[b]=m(d,y[b])+(1<<this.Q-1);for(var x=p;x<g;x+=p)for(var b=0;b<p;b++)c[x+b]=m(d,y[b])+c[x+b-p];for(var v=u,S=1;S<f;S++){for(var b=0;b<p;b++)c[v+b]=m(d,y[b])+c[v+b-u];for(var x=p;x<g;x+=p)for(var b=0;b<p;b++){var F=v+x+b,w=c[F-p];h==6&&(w=c[F-u]+(w-c[F-p-u]>>>1)),c[F]=w+m(d,y[b])}v+=u}}},s.m=65475,s.K=65476,s.q=65496,s.V=65498;function l(c){var u=new s(c),d=u.Q>8?Uint16Array:Uint8Array,p=new d(u.o*u.F*u.O),f=u.o*u.O;return u.B(p,f),p}return l})()})(e,t)})()});async function H$n(e,t){let n=await bTt(e),r={w:n.props.w,h:n.props.h},o=Dce(r,t);return{asset:n,shape:{id:ff(),type:"image",x:0,y:0,rotation:0,props:{assetId:n.id,w:o.w,h:o.h}}}}async function bTt(e){let t=dNe(e)?await Mni(e):e,n=await Ini(t),r=await Pni(n),o=r.width||240,i=r.height||Math.max(80,Math.round(o*.66));return{id:ute(),type:"image",props:{w:o,h:i,name:e.name,isAnimated:!1,mimeType:t.type||null,src:n,fileSize:t.size}}}function Ini(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function Pni(e){return e.startsWith("data:image/svg+xml")?Promise.resolve(Bon(e)??{}):new Promise(t=>{let n=new Image;n.onload=()=>t({width:n.naturalWidth,height:n.naturalHeight}),n.onerror=()=>t({}),n.src=e})}async function Mni(e){let{decode:t,decodeImage:n,toRGBA8:r}=await Promise.resolve().then(()=>yC(nze())),o=Bni(await e.arrayBuffer()),a=t(o)[0],s=Number(Array.isArray(a?.t256)?a.t256[0]:0),l=Number(Array.isArray(a?.t257)?a.t257[0]:0);if(!Number.isSafeInteger(s)||!Number.isSafeInteger(l)||s<=0||l<=0||s*l>4e7)throw new Error("Invalid or oversized TIFF image");if(a.t322||a.t323){let m=Number(Array.isArray(a.t322)?a.t322[0]:0),h=Number(Array.isArray(a.t323)?a.t323[0]:0);if(!Number.isSafeInteger(m)||!Number.isSafeInteger(h)||m<=0||h<=0||m*h>4e7)throw new Error("Invalid or oversized TIFF tile")}n(o,a);let c=r(a);if(!a.data||c.length!==s*l*4)throw new Error("Invalid TIFF pixels");let u=document.createElement("canvas");u.width=s,u.height=l;let d=u.getContext("2d");if(!d)throw new Error("Image conversion unavailable");let p=d.createImageData(s,l);p.data.set(c),d.putImageData(p,0,0);let f=await new Promise((m,h)=>{u.toBlob(g=>g?m(g):h(new Error("TIFF conversion failed")),"image/png")});return new File([f],e.name,{type:"image/png"})}function Bni(e){let t=new DataView(e);if(e.byteLength<8||!(t.getUint32(0)===1229531648||t.getUint32(0)===1296891946))throw new Error("Invalid TIFF header");let n=t.getUint16(0)===18761,r=t.getUint32(4,n);if(r<8||r+2>e.byteLength)throw new Error("Invalid TIFF directory");let o=t.getUint16(r,n),i=r+2+o*12;if(i+4>e.byteLength)throw new Error("Invalid TIFF directory");let a=e.slice(0),s=new DataView(a);s.setUint32(i,0,n);let l=[0,1,1,2,4,8,1,1,2,4,8,4,8];for(let c=r+2;c<i;c+=12){let u=s.getUint16(c,n);if([330,34665,50740,37500].includes(u)){s.setUint16(c,0,n),s.setUint16(c+2,1,n),s.setUint32(c+4,0,n);continue}let d=s.getUint16(c+2,n),p=s.getUint32(c+4,n),f=p*(l[d]??0),m=f<=4?c+8:s.getUint32(c+8,n);if(!l[d]||p>1e6||m+f>a.byteLength)throw new Error("Invalid TIFF directory value")}return a}var xTt=X(()=>{"use strict";tj();Pn();tE();pY()});import{useCallback as qj,useLayoutEffect as Lni,useRef as vTt}from"react";function G$n({shapesRef:e,editPolicyLockedShapeIdsRef:t,notifyEditPolicyBlocked:n,setSelectedShapeIds:r,transitionMode:o,documentId:i,assetsRef:a,setShapes:s,setAssets:l,queueOverlaySave:c,replaceShape:u,imageInsertAreaRef:d,updateShape:p}){let f=vTt(null),m=vTt(null),h=vTt(0);Lni(()=>()=>{h.current++,m.current=null},[i]);let g=qj(w=>{let C=e.current.find(A=>A.id===w&&A.type==="image");return!C||Ac(e.current,C)?null:Js(e.current,C,t.current)?(n(),null):C},[t,n,e]),y=qj(w=>{let C=g(w);C&&(r([C.id]),o({type:"editImageCrop",shapeId:C.id}))},[g,r,o]),b=qj(w=>{let C=g(w);C&&(m.current=C.id,f.current&&(f.current.value="",f.current.click()))},[g,m]),x=qj(async w=>{let C=h.current,A=m.current,T=ate(w.currentTarget.files)[0];if(w.currentTarget.value="",m.current=null,!(!A||!T))try{let D=await bTt(T);if(C!==h.current)return;let k=g(A);if(!k)return;let P=JKn(e.current,a.current,k.id,D);e.current=Qr(P.shapes),a.current=P.assets,s(e.current),l(P.assets),r([k.id]),o({type:"select"}),c()}catch{return}},[a,g,c,l,r,s,e,o]),v=qj(w=>{let C=g(w);if(!C)return;let A=_At(C);A!==C&&(u(A),o({type:"select"}),c())},[g,c,u,o]),S=qj(w=>{let C=g(w);if(!C)return;let A=ZKn(C,a.current[C.props.assetId],d.current);A!==C&&(u(A),o({type:"select"}),c())},[a,g,d,c,u,o]),F=qj((w,C)=>{let A=g(w);A&&p({id:A.id,type:"image",opacity:Yo(C,0,1)})},[g,p]);return{imageReplacementInputRef:f,startImageCrop:y,requestImageReplacement:b,resetImageCrop:v,restoreImageNaturalSize:S,handleImageReplacementChange:x,setImageOpacity:F}}var j$n=X(()=>{"use strict";"use client";tj();Tc();QKn();xTt();jh()});function STt(){let e=null,t=0;return{cancel(){t++,e=null},async handle(n,r){if(e===n.id)return;e=n.id;let o=t;if(n.files.length===0){r.onHandled(n.id);return}try{let i=await Promise.all(n.files.map(l=>r.decodeFile(l,{w:r.areaSize.w,h:r.areaSize.h})));if(o!==t||i.length===0)return;let a=Qr(hnn(i,{areaWidth:r.areaSize.w,gap:r.gap,point:n.point,...r.getPlacement()})),s=Object.fromEntries(i.map(({asset:l})=>[l.id,l]));r.insert(a,s)}catch{return}finally{o===t&&r.onHandled(n.id)}}}}var V$n=X(()=>{"use strict";Dt();Pn()});import{useCallback as Rni,useEffect as _ni,useLayoutEffect as Oni,useRef as Nni}from"react";function X$n({documentId:e,imageInsertAreaWidth:t,imageInsertAreaHeight:n,canvasWidthRef:r,canvasHeightRef:o,focusedGroupIdRef:i,shapesRef:a,setAssets:s,assetsRef:l,setShapes:c,setSelectedShapeIds:u,transitionMode:d,queueOverlaySave:p,onImageHandled:f,imageRequest:m}){let h=Nni(null);Oni(()=>{let y=STt();return h.current=y,()=>{y.cancel(),h.current===y&&(h.current=null)}},[e]);let g=Rni(y=>(h.current??=STt(),h.current.handle(y,{areaSize:{w:t,h:n},gap:zni,decodeFile:H$n,getPlacement:()=>({canvasWidth:r.current,canvasHeight:o.current,parentId:i.current&&vP(a.current,i.current)?i.current:void 0}),insert:(b,x)=>{s(v=>{let S={...v,...x};return l.current=S,S}),c(v=>{let S=Qr([...v,...b]);return a.current=S,S}),u(b.map(v=>v.id)),d({type:"select"}),p()},onHandled:f})),[l,o,r,i,h,n,t,f,p,s,u,c,a,d]);_ni(()=>{m&&g(m)},[g,m])}var zni,W$n=X(()=>{"use strict";"use client";Tc();xTt();V$n();zni=16});import{useCallback as wTt}from"react";function q$n({lastCalloutCornerRadiusRef:e,focusedGroupIdRef:t,shapesRef:n,canvasWidthRef:r,canvasHeightRef:o,suppressNextSaveRef:i,insertedTableFocusRef:a,setShapes:s,selectKnownShape:l,commitOverlayChangeNow:c,queueOverlaySave:u,setSelectedShapeIds:d,transitionMode:p,clearSnapGuides:f}){let m=wTt((y,b,x,v,S=!1)=>{let F=y.command==="callout"&&y.calloutRadius===void 0?{...y,calloutRadius:e.current}:y,w=gj(F,b,x,ff(),v,S,J9(F.command,Gte()));if(!w)return null;w.type==="callout"&&(e.current=w.props.radius,qNe(w.props.radius));let C=t.current&&vP(n.current,t.current)?t.current:null,A=L=>C?{...L,parentId:C}:L,T=A(w),D=T.type==="graph2dShape"?dte(T,ff,{width:r.current,height:o.current}):[],k=T.type==="graph2dShape"?p_(T,ff):[],P=T.type==="graph2dShape"?f_(T,ff):[],I=[...D,...k,...P].map(L=>A(L.shape)),B=T;B.type==="graph2dShape"&&D.length>0&&(B=T_(B,Object.fromEntries(D.map(L=>[L.curveId,L.shape.id])))),B.type==="graph2dShape"&&k.length>0&&(B=tbe(B,Object.fromEntries(k.map(L=>[L.pointId,L.shape.id])))),B.type==="graph2dShape"&&P.length>0&&(B=nbe(B,Object.fromEntries(P.map(L=>[L.annotationId,L.shape.id])))),B.type==="graph2dShape"&&(B=xB(B));let M=aB(n.current,B);for(let L of I)M=aB(M,L);return M=Qr(M),n.current=M,Bd(B)&&(i.current=!0),B.type===nE&&(a.current=B.id),s(M),l(B,{editing:Bd(B)}),Bd(B)?c():u(),B.id},[o,r,c,t,a,e,u,l,s,n,i]),h=wTt(y=>{let b=n.current.find(C=>C.id===y);if(b?.type!=="tableShape")return;let x=SXn({x:b.x,y:b.y,w:b.props.w,h:b.props.h}),v=Yo(x.x,0,Math.max(0,r.current-x.w)),S=Yo(x.y,0,Math.max(0,o.current-x.h)),F=vXn(b.props.table,y,x.w,x.h),w=m({kind:"insert",command:"chart",chart:{sourceTableShapeId:y,spec:F.spec,dataSnapshot:F.dataSnapshot}},{x:v,y:S},{x:v+x.w,y:S+x.h});w&&d([w])},[o,r,m,d,n]),g=wTt((y,b,x=!1)=>{let v=aen(b,2);if(v.length<(y.command==="threePointArc"?3:2))return!1;let S=v[0],F=v[v.length-1];return m(y,S,F,v,x)?(p({type:"setTool",tool:{kind:"select"}}),f(),!0):!1},[f,m,p]);return{createShapeFromInsertDrag:m,finishCurveDrawing:g,createChartFromTable:h}}var K$n=X(()=>{"use strict";"use client";Dt();Pn();Tc();tE();jh();KNe();M9e();kCt();xP();Yx();D_();m_()});function Y$n(e){let t=e.metaKey||e.ctrlKey,n=e.key==="]"||e.key==="}"||e.code==="BracketRight",r=e.key==="["||e.key==="{"||e.code==="BracketLeft";if(t&&!e.altKey){if(e.key==="ArrowUp")return e.shiftKey?"front":"forward";if(e.key==="ArrowDown")return e.shiftKey?"back":"backward";if(n)return e.shiftKey?"front":"forward";if(r)return e.shiftKey?"back":"backward"}if(!t&&!e.shiftKey){if(n)return e.altKey?"forward":"front";if(r)return e.altKey?"backward":"back"}return null}function $$n(e){return e==="forward"||e==="backward"}var Z$n=X(()=>{"use strict"});import{useEffect as FTt}from"react";function J$n({textCompositionRef:e,modeRef:t,cancelTablePlacement:n,snapDisabledRef:r,clearSnapGuides:o,updateModifierDrivenInteraction:i,activeTextEditorRef:a,transitionMode:s,queueDirtyImageCropSave:l,finishCurveDrawing:c,restoreTransientInteraction:u,solidEdgeRef:d,setSolidEdge:p,focusedGroupIdRef:f,setFocusedGroupId:m,setSelectedShapeIds:h,shapesRef:g,ungroupSelectedShapes:y,groupSelectedShapes:b,selectedIdsRef:x,duplicateSelectedShapes:v,editPolicyLockedShapeIdsRef:S,notifyEditPolicyBlocked:F,arrangeSelectedShapes:w,refreshAnchorMeasurements:C,setShapes:A,deleteSelectedShapes:T,mode:D}){let k=$q();FTt(()=>{let P=I=>{if(!k()||document.querySelector("[data-modal-backdrop]")||(I.target instanceof Element?I.target:document.activeElement)?.closest(TKn)||e.current||L9e(I))return;let M=t.current;if(I.key==="Escape"&&M.tool.kind==="insert"&&M.tool.command==="table"&&!g1(I.target)){I.preventDefault(),n();return}if(ECt(I.key)&&(r.current=!0,sw(M))){I.preventDefault(),o(),i(M,I);return}if(a.current?.isFocused)return;if((I.key==="Enter"||I.key==="Escape")&&RAt(M)!==null&&!g1(I.target)){I.preventDefault(),s({type:"select"}),l();return}if(M.id==="overlay.curveDrawing"&&!g1(I.target)){if(I.key==="Escape"){I.preventDefault(),s({type:"setTool",tool:{kind:"select"}});return}if(I.key==="Enter"){I.preventDefault();let O=NDe(M.points,M.current);O&&c(M.tool,O);return}if(I.key==="Backspace"||I.key==="Delete"){I.preventDefault(),s({type:"removeLastCurvePoint"});return}}if(I.key==="Escape"&&M.id!=="overlay.select"){I.preventDefault();let O=a.current;O&&!O.isDestroyed&&O.commands.blur(),u(M),s({type:"select"});return}if(I.key==="Escape"&&d.current&&M.id==="overlay.select"){I.preventDefault(),p(null);return}if(I.key==="Escape"&&f.current&&M.id==="overlay.select"){I.preventDefault(),m(null),h([]);return}if(ICt(I.key)&&i(M,I)){I.preventDefault();return}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="a"&&!g1(I.target)){let O=LCt(g.current,f.current);if(O.length===0)return;I.preventDefault(),a.current?.commands.blur(),h(O),s({type:"select"});return}if((I.metaKey||I.ctrlKey)&&I.shiftKey&&I.key.toLowerCase()==="g"&&!g1(I.target)){I.preventDefault(),y();return}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="g"&&!g1(I.target)){I.preventDefault(),b();return}if(I.key==="Enter"&&M.id==="overlay.select"&&!g1(I.target)){let O=x.current.length===1?vP(g.current,x.current[0]):null;if(O){I.preventDefault(),m(O.id),h(LCt(g.current,O.id));return}}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="d"&&!g1(I.target)){if(x.current.length===0)return;I.preventDefault(),v();return}let L=Y$n(I),_=M.id==="overlay.textEditing"||M.id==="overlay.tableEditing";if(L&&!g1(I.target)&&!_){let O=x.current;if(O.length===0)return;if(Wh(g.current,O,S.current)){F();return}if(!($x(g.current,O,S.current).length>0)||I.repeat&&!$$n(L))return;I.preventDefault(),I.stopPropagation(),w(L);return}if(!I.metaKey&&!I.ctrlKey&&wXn(I.key)&&!g1(I.target)){let O=$x(g.current,x.current,S.current);if(O.length===0){Wh(g.current,x.current,S.current)&&F();return}I.preventDefault();let N=I.shiftKey?10:1,z=FXn(I.key,N),U=new Set(O.map(ne=>ne.id)),{ordered:H}=C(),V=Y9(O,z.x,z.y);A(ne=>{let Z=Qr(Jx(Wv(ne,V),U,H));return g.current=Z,Z});return}I.key!=="Backspace"&&I.key!=="Delete"||g1(I.target)||x.current.length===0||(I.preventDefault(),T())};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[k,w,n,T,v,c,b,o,F,l,C,u,h,p,s,y,i,e,t,a,d,f,x,r,m,g,S,A]),FTt(()=>{let P=RAt(D);if(!P)return;let I=B=>{let M=B.target instanceof Element?B.target:null,L=M?.closest("[data-overlay-shape-id]");M?.closest(".overlay-crop-handle")||L?.getAttribute("data-overlay-shape-id")===P||(s({type:"select"}),l())};return window.addEventListener("pointerdown",I,!0),()=>window.removeEventListener("pointerdown",I,!0)},[D,l,s]),FTt(()=>{let P=I=>{if(k()){if(ECt(I.key)){r.current=!1,!e.current&&!L9e(I)&&!a.current?.isFocused&&i(t.current,I)&&I.preventDefault();return}!ICt(I.key)||e.current||L9e(I)||a.current?.isFocused||i(t.current,I)&&I.preventDefault()}};return window.addEventListener("keyup",P),()=>window.removeEventListener("keyup",P)},[k,a,t,r,e,i])}var Q$n=X(()=>{"use strict";"use client";Hse();Pn();Z$n();A_();Tc();qte();yte();Ly();Vte();xP()});function tZn(e){return e.pageHeightPx>0&&e.canvasWidth>0&&e.canvasHeight>0}function Uni(e){if(!tZn(e))return 1;let t=e.pageHeightPx+Math.max(0,e.pageGapPx);return Math.max(1,Math.round((e.canvasHeight+Math.max(0,e.pageGapPx))/t))}function Hni(e,t,n){return t.width<=0||t.height<=0?null:{x:(e.x-t.left)/t.width*n.canvasWidth,y:(e.y-t.top)/t.height*n.canvasHeight}}function nZn(e,t,n){let r=Uni(n),o=n.pageHeightPx+Math.max(0,n.pageGapPx),a=Gni(e.y,n.pageHeightPx,o,r)*o;return{x:eZn(e.x,t.w,0,n.canvasWidth),y:eZn(e.y,t.h,a,a+n.pageHeightPx)}}function Gni(e,t,n,r){let o=Math.min(r-1,Math.max(0,Math.floor(e/n))),i=o+1;if(i>=r)return o;let a=Math.max(0,e-(o*n+t));return Math.max(0,i*n-e)<a?i:o}function eZn(e,t,n,r){let o=t/2;return r-n<=t?(n+r)/2:Math.min(r-o,Math.max(n+o,e))}function rZn(e){if(e)return(t,n)=>{let r=n.width/Eb(e,1).width;if(!(r>0))return null;let o=EB(e,{x:(t.x-n.left)/r,y:(t.y-n.top)/r});return{x:o.x,y:o.y}}}function oZn(e,t,n,r=(o,i)=>Hni(o,i,n)){if(!e||!t||!tZn(n))return null;let o=r(e,t);return o?{point:o,layout:n}:null}function Xni(e){let t=e?.closest(jni);return!!t&&!t.closest(Vni)}function Wni(){let e=r=>{r.isTrusted&&(oze=r.pointerType==="touch"?null:{x:r.clientX,y:r.clientY})},t=()=>{oze=null},n=document.documentElement;return window.addEventListener("pointermove",e,{capture:!0,passive:!0}),window.addEventListener("pointerdown",e,{capture:!0,passive:!0}),n.addEventListener("pointerleave",t),()=>{window.removeEventListener("pointermove",e,{capture:!0}),window.removeEventListener("pointerdown",e,{capture:!0}),n.removeEventListener("pointerleave",t),oze=null}}function iZn(){if(typeof window>"u"||typeof document>"u")return()=>{};rze+=1,rze===1&&(CTt=Wni());let e=!1;return()=>{e||(e=!0,rze-=1,rze===0&&(CTt?.(),CTt=null))}}function ize(){let e=oze;return!e||typeof document>"u"||typeof document.elementFromPoint!="function"?null:Xni(document.elementFromPoint(e.x,e.y))?{...e}:null}var jni,Vni,oze,rze,CTt,xbe=X(()=>{"use strict";Dn();jni=".page-mode",Vni=".workspace-passive-editor, [data-whiteboard='true']";oze=null,rze=0,CTt=null});import{useEffect as qni}from"react";function aZn({getBlockAnchorScope:e,activeTextEditorRef:t,shapesRef:n,selectedIdsRef:r,reanchorShapesToCopiedBlocks:o,assetsRef:i,documentIdRef:a,getRemovableSelectedShapeIds:s,pendingOverlaySaveHistoryGroupRef:l,deleteSelectedShapes:c,applyPastedOverlayShapes:u}){qni(()=>{let d=y=>{let b=y.target instanceof Element?y.target:null,x=e();if(!b||!b.closest(".text-flow-editor")||b.closest("math-field")||!(x instanceof Node)||!x.contains(b))return null;let v=y.clipboardData?OMe(y.clipboardData):null;if(!v||!y.clipboardData)return null;let S=y.clipboardData.getData("text/html");return{text:v,html:Kgt(S)}},p=y=>t.current?.isFocused||!y.clipboardData?!1:y_(n.current,r.current).length>0,f=(y,b)=>{if(!p(y)||!y.clipboardData)return!1;let x=y.clipboardData,v=y_(n.current,r.current);return!b&&g1(y.target)?!1:(y.preventDefault(),y.stopPropagation(),y.stopImmediatePropagation(),b?nA(x,gkn(b.text,o(v,b.text.slice),i.current,a.current),{html:b.html}):nA(x,Nw(v,i.current,a.current)),!0)},m=y=>{f(y,d(y))},h=y=>{if(!p(y))return;let b=xkn(y),x=b?{text:b,html:Kgt(y.clipboardData?.getData("text/html")??"")}:null;if(f(y,x)){let v=s().length>0;l.current=v?b?.historyGroup??null:null,c()}},g=y=>{if(y.defaultPrevented||g1(y.target)||t.current?.isFocused||!y.clipboardData)return;let b=Kf(y.clipboardData);if(b?.kind!=="overlayShapes"&&b?.kind!=="textAndShapes")return;let x=b.kind==="textAndShapes"?Fk(b):b,v=ize();u(x,v?{pointerClient:v}:void 0)&&(y.preventDefault(),y.stopPropagation(),y.stopImmediatePropagation())};return window.addEventListener("copy",m),window.addEventListener("cut",h),window.addEventListener("paste",g),()=>{window.removeEventListener("copy",m),window.removeEventListener("cut",h),window.removeEventListener("paste",g)}},[t,u,i,c,a,e,s,l,o,r,n])}var sZn=X(()=>{"use strict";"use client";Sp();Tc();xbe();Vte()});import{useCallback as Kj}from"react";function lZn({setRegionSelection:e,shapesRef:t,selectedIdsRef:n,setSelectedIds:r,onSelectedCountChange:o,unselectableShapeIdsRef:i,focusedGroupIdRef:a,transitionMode:s,modeRef:l,activeTextEditorRef:c,explicitlySavedShapeStatesRef:u,setShapes:d,commitOverlayChangeNow:p,queueOverlaySave:f,anchorMeasurementsRef:m}){let h=Kj(F=>{e(null);let w=Rj([...new Set(F)],i?.current,t.current),C=lrt(t.current,w);Knn(n.current,C)||(n.current=C,r(C),o?.(C.length))},[o,n,e,r,t,i]),g=Kj((F,w={})=>{let C=cF(t.current,F.id,a.current);h(C),w.editing&&Bd(F)&&C.length===1&&C[0]===F.id?s({type:"editText",shapeId:F.id}):(l.current.id!=="overlay.originPicking"&&l.current.id!=="overlay.graphFillPicking"||F.type!=="graph2dShape")&&s({type:"select"})},[a,l,h,t,s]),y=Kj(F=>{let w=t.current.find(C=>C.id===F);if(w){g(w);return}h([F]),s({type:"select"})},[g,h,t,s]),b=Kj(F=>{c.current?.commands.blur(),s({type:"select"}),h(Ynn(n.current,F))},[c,n,h,s]),x=Kj((F,w)=>{let C=t.current.find(D=>D.id===F.id&&D.type===F.type),A=Qr(XAe(t.current,F)),T=A.find(D=>D.id===F.id&&D.type===F.type);if(C&&T&&(C.type==="text"||C.type==="callout")&&T.type===C.type&&Oi(T)!==0&&F.x===void 0&&F.y===void 0){let D=yi(C),k=yi(T);(D.w!==k.w||D.h!==k.h)&&(A=Qr(aB(A,lnn(C,T))))}if(!_ke(t.current,A)){if(w?.commit){t.current=A,u.current.add(A),d(A),p({history:w.history});return}t.current=A,w?.history&&u.current.add(A),d(A),w?.history&&f({history:w.history})}},[p,u,f,d,t]),v=Kj((F,w,C={},A={})=>{let T=D=>{let k=D.find(L=>L.id===F&&L.type===lF);if(!k)return D;let P=Ele(k,w),I={...k,...C,props:{...k.props,spec:w,boundsMode:"plot",w:P.w,h:P.h}},B=C.x!==void 0||C.y!==void 0?vWn(I,k,D,m.current.rects):I,M=D.map(L=>L.id===F?B:L);return Nj(M,B,{preserveExistingPositions:A.preserveGraphOwnedLabelPositions===!0})};if(A.commit){let D=T(t.current);if(D===t.current)return;t.current=D,u.current.add(D),d(D),p();return}d(D=>{let k=T(D);return t.current=k,k})},[m,p,u,d,t]),S=Kj(F=>{d(w=>{let C=Qr(aB(w,F));return t.current=C,C})},[d,t]);return{setSelectedShapeIds:h,replaceShape:S,updateShape:x,selectKnownShape:g,selectShape:y,updateGraphShapeSpec:v,toggleShapeSelection:b}}var cZn=X(()=>{"use strict";"use client";Dt();Pn();Tc();Ly();Yx();D_();A_()});function ATt(e,t){let n=t.history??"record",r=t.historyGroup??null;return e?{history:e.history==="record"||n==="record"?"record":"coalesce",historyGroup:TTt(e.historyGroup,r)}:{history:n,historyGroup:r}}function TTt(e,t){return e===t?e:e===null?t:t===null?e:null}var DTt=X(()=>{"use strict"});import{useCallback as one}from"react";function uZn({syncBlockAnchors:e,shapesRef:t,canvasRef:n,canvasHeightRef:r,canvasWidthRef:o,getBlockAnchorScope:i,getLastDrawnBlockRects:a,getPreservedShapeIds:s,suppressNextSaveRef:l,setShapes:c,assetsRef:u,extensionsRef:d,lastEmittedSnapshotRef:p,onChangeRef:f,imageCropDirtyRef:m,saveTimeoutRef:h,pendingOverlayHistoryRef:g,pendingOverlaySaveHistoryGroupRef:y}){let b=one((C={})=>{let A=e?Qr(qWn(t.current,n.current,r.current,o.current,i(),a(),s())):Qr(t.current),T=x_(A,V$t(A),s());T!==t.current&&(t.current=T,l.current=!0,c(T));let D={version:1,shapes:t.current,assets:u.current,...d.current?{extensions:d.current}:{}};p.current=D,f.current({overlaySnapshot:D,updatedAt:new Date().toISOString()},{history:C.history??"record",...C.historyGroup?{historyGroup:C.historyGroup}:{}}),m.current=!1},[u,r,n,o,d,i,a,s,m,p,f,c,t,l,e]),x=one(()=>{h.current&&(window.clearTimeout(h.current),h.current=void 0),g.current=null,y.current=null},[g,y,h]),v=one(()=>{if(h.current===void 0&&!m.current)return;let C=g.current;x(),b({history:C?.history??"record",...C?.historyGroup?{historyGroup:C.historyGroup}:{}})},[x,b,m,g,h]),S=one((C={})=>{let A=ATt(g.current,C);x(),b({history:A.history,...A.historyGroup?{historyGroup:A.historyGroup}:{}})},[x,b,g]),F=one((C={})=>{g.current=ATt(g.current,C),h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{h.current=void 0;let A=g.current;g.current=null,b({history:A?.history??"record",...A?.historyGroup?{historyGroup:A.historyGroup}:{}})},250)},[b,g,h]),w=one(()=>{m.current&&F()},[m,F]);return{queueOverlaySave:F,clearQueuedOverlaySave:x,commitOverlayChangeNow:S,flushOverlayChange:v,queueDirtyImageCropSave:w}}var dZn=X(()=>{"use strict";"use client";Dt();Tc();DTt();Ly();aAt()});function ine(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(aze,{detail:{style:e}}))}var IA,aze,pZn,PP=X(()=>{"use strict";IA="sigma-studio:flush-overlay-changes",aze="sigma-studio:overlay-style-preview";pZn="selection"});import{useEffect as kTt}from"react";function fZn({assets:e,shapes:t,assetsRef:n,shapesRef:r,mountedRef:o,pendingOverlaySaveHistoryGroupRef:i,explicitlySavedShapeStatesRef:a,suppressNextSaveRef:s,commitOverlayChangeNow:l,queueOverlaySave:c,flushOverlayChange:u,saveTimeoutRef:d,imageCropDirtyRef:p}){kTt(()=>{if(!o.current){o.current=!0;return}let f=i.current;if(i.current=null,!(t!==r.current||e!==n.current)&&!a.current.delete(t)){if(s.current){s.current=!1;return}if(f){l({historyGroup:f});return}c()}},[e,l,a,o,i,c,t,s,n,r]),kTt(()=>(window.addEventListener(IA,u),()=>window.removeEventListener(IA,u)),[u]),kTt(()=>()=>{(d.current!==void 0||p.current)&&u()},[u,p,d])}var mZn=X(()=>{"use strict";"use client";PP()});import{useCallback as ane,useEffect as hZn,useLayoutEffect as ETt}from"react";function yZn({session:e,editing:t,selection:n,geometry:r,drawing:o,transforms:i,clearSnapGuides:a,setAdjustmentDragReadoutPointerPosition:s,canvasRef:l,autoScrollPanBy:c,autoScrollViewportElement:u,originPickShapeId:d,updateOriginPickPreviewFromEvent:p,setHoverSolidEdge:f,mode:m,cancelTablePlacement:h,restoreTransientInteraction:g,setRegionSelection:y,handledCommandRequestIdRef:b,queueOverlaySave:x,documentId:v,onRequestTextMode:S,retainEmptySelection:F,externalRevision:w,onRequestTextSelection:C,queueDirtyImageCropSave:A}){let{modeRef:T,transitionMode:D,bleedSurfaceRef:k,lastInteractionPointRef:P,dragPointerRef:I,dragCanvasRectRef:B,lastPointerModifiersRef:M,advanceInteractionFromClientRef:L,dragAutoScrollerRef:_}=e,{shapesRef:R,setShapes:O,editPolicyLockedShapeIdsRef:N,editPolicyUnselectableShapeIdsRef:z}=t,{selectedIdsRef:U,focusedGroupIdRef:H,setSelectedShapeIds:V,selectShape:ne}=n,{pagePointFromClient:Z,clientPointFromPage:ee,getOverlaySnapThreshold:J,getShapeAtPoint:te,getOpenStrokeShapeAtPoint:K,refreshAnchorMeasurements:G}=r,{getSnappedDrawingPoint:ie,getSnappedInsertDragPoint:fe,createShapeFromInsertDrag:$}=o,{applyMoveInteractionAtPoint:j,applyResizeInteractionAtPoint:pe,applyPointInteractionAtPoint:re,applyImageCropInteractionAtPoint:le}=i,Q=ane((Pe,Ne,we,Ie)=>{let Ce=T.current;if(!sw(Ce))return;let xe=Z(Pe,Ne,Ie);if(P.current=xe,Ce.id==="overlay.move"){j(Ce,xe);return}if(Ce.id==="overlay.resize"){pe(Ce,xe,we);return}if(Ce.id==="overlay.rotate"){a();let Y=Snn(Ce,xe,we.shiftKey);O(oe=>{let de=Qr(Wv(oe,$9(Ce.shapes,Ce.center,Y)));return R.current=de,de});return}if(Ce.id==="overlay.anchor"){a(),D({type:"updateAnchorDrag",current:xe});return}if(Ce.id==="overlay.marquee"){a(),D({type:"updateMarquee",current:xe});return}if(Ce.id==="overlay.point"){re(Ce,xe,we),xte(Ce.handle)&&s(xe);return}if(Ce.id==="overlay.imageCropResize"||Ce.id==="overlay.imageCropPan"){le(Ce,xe);return}if(Ce.id==="overlay.curveDrawing"){let Y=Ce.points[Ce.points.length-1];D({type:"updateCurveDrawing",current:ie(xe,{previousPoint:Y,shiftKey:we.shiftKey,enabled:hj(Ce.tool)})});return}if(Ce.id==="overlay.insertDrag"){if(Ce.tool.command==="table"&&_ye())return;let Y=fe(Ce.tool,Ce.start,xe,we);if(Ce.tool.command==="table"&&Ce.tool.tableCellSize){let oe=hD(Ce.start,Ce.current,Ce.tool.tableCellSize),de=hD(Ce.start,Y,Ce.tool.tableCellSize);if(oe.x===de.x&&oe.y===de.y&&oe.w===de.w&&oe.h===de.h)return}D({type:"updateInsertDrag",current:Y,point:Ce.tool.command==="freehand"?Y:void 0}),h_(Ce.tool)&&s(xe);return}},[T,Z,P,j,pe,a,O,R,D,re,s,le,ie,fe]);ETt(()=>{L.current=Q},[Q,L]);let se=ane(()=>{_.current?.stop(),_.current=null},[_]),De=ane((Pe,Ne)=>{if(!O9e(T.current)){se();return}if(!_.current){let we=l.current??k.current,Ie=we&&!c?PG(we):null,Ce=u??Ie;if(!Ce)return;let xe=Ce.ownerDocument.defaultView;if(!xe)return;let Y=c??(Ie?(oe,de)=>BG(Ie,oe,de):null);if(!Y)return;_.current=LG({ownerWindow:xe,getViewportBounds:()=>MG(Ce,xe),panBy:Y,onPan:(oe,de,Le)=>{if(!O9e(T.current)){se();return}L.current(oe,de,M.current,Le.rectSettled?null:B.current)},maxSpeedPxPerSec:Yni})}_.current.update(Pe,Ne)},[L,c,u,k,l,_,B,M,T,se]),Ae=ane(Pe=>{d&&p(Pe),M.current={ctrlKey:Pe.ctrlKey,shiftKey:Pe.shiftKey};let Ne=U.current.length===1?R.current.find(Ie=>Ie.id===U.current[0]):void 0;if(Ne&&Nc(Ne)&&!Ne.locked&&Pe.buttons===0&&T.current.id==="overlay.select"){let Ie=Cke(Ne,Z(Pe.clientX,Pe.clientY),J()*.75);f(Ce=>Ce?.shapeId===Ne.id&&Ce.index===Ie?Ce:Ie===null?null:{shapeId:Ne.id,index:Ie})}else f(Ie=>Ie===null?Ie:null);Q(Pe.clientX,Pe.clientY,M.current);let we=I.current;Pe.buttons!==0&&we?.pointerId===Pe.pointerId?(we.autoScrollArmed||(we.autoScrollArmed=Math.hypot(Pe.clientX-we.startClientX,Pe.clientY-we.startClientY)>Kni),we.autoScrollArmed?De(Pe.clientX,Pe.clientY):se()):se()},[Q,I,J,M,T,d,Z,U,f,R,se,De,p]);hZn(()=>{O9e(m)||se()},[m,se]),hZn(()=>se,[se]);let ye=ane(()=>{let Pe=T.current.tool;if(Pe.kind==="insert"&&Pe.command==="table"){h();return}let Ne=I.current?.pointerId;Ne!==void 0&&k.current?.hasPointerCapture(Ne)&&k.current.releasePointerCapture(Ne),I.current=null,se();let we=T.current;sw(we)&&(g(we),y(null),D({type:"select"}))},[k,h,I,T,g,y,se,D]);ETt(()=>{let Pe=m.tool;if(Pe.kind!=="insert"||Pe.command!=="table"||!Pe.tableCellSize)return;let Ne=we=>T.current.id==="overlay.insertDrag"?T.current.start:Z(we.x,we.y);return QWn(b.current,{bounds:(we,Ie)=>{let Ce=hD(Ne(we),Z(Ie.x,Ie.y),Pe.tableCellSize),xe=ee(Ce),Y=ee({x:Ce.x+Ce.w,y:Ce.y+Ce.h}),oe=Y.x-xe.x,de=Y.y-xe.y;return{...Ce,...xe,w:oe,h:de,cellW:oe/Ce.columns,cellH:de/Ce.rows}},freeze:()=>{let we=I.current?.pointerId;we!==void 0&&k.current?.hasPointerCapture(we)&&k.current.releasePointerCapture(we),I.current=null,se()},cancel:h,commit:(we,Ie)=>{let Ce=Ne(we),xe=Z(Ie.x,Ie.y);h();let Y=$(Pe,Ce,xe);Y?D({type:"editTable",shapeId:Y}):wte()}})},[m.tool,h,ee,$,Z,se,D,b,T,I,k]);let $e=ane(Pe=>{I.current=null,se();let Ne=T.current;if(!sw(Ne))return;let we=Ne.id==="overlay.resize"||Ne.id==="overlay.point"||Ne.id==="overlay.imageCropResize"||Ne.id==="overlay.imageCropPan",Ie=Ne.id==="overlay.move"?wnn({...Ne,start:ee(Ne.start)},{x:Pe.clientX,y:Pe.clientY}):null;if(Ie?.kind==="edit"){Ie.editor==="table"?D({type:"editTable",shapeId:Ie.shapeId}):D({type:"editText",shapeId:Ie.shapeId}),k.current?.hasPointerCapture(Pe.pointerId)&&k.current.releasePointerCapture(Pe.pointerId),a();return}if(Ne.id==="overlay.anchor"){let Ce=Z(Pe.clientX,Pe.clientY),xe=N9e({...Ne,current:Ce}),Y=Math.abs(Ce.x-Ne.start.x)>gZn||Math.abs(Ce.y-Ne.start.y)>gZn,oe=G(),de=R.current.find(Be=>Be.id===Ne.shape.id),Le=Y&&de&&!de.locked?HKn(de,xe,oe):null,be=!!(Le&&!Zx(de?.anchor,Le));Le&&be&&O(Be=>{let ce=Be.map(Qe=>Qe.id!==Ne.shape.id||Zx(Qe.anchor,Le)?Qe:{...Qe,anchor:Le}),Re=Sj(ce,oe.ordered);return R.current=Re,Re}),D({type:"select"}),a(),k.current?.hasPointerCapture(Pe.pointerId)&&k.current.releasePointerCapture(Pe.pointerId),be&&x();return}if(Ne.id==="overlay.move"){let Ce=Ne.shapes.length===1?Ne.shapes[0]:null,xe=Z(Pe.clientX,Pe.clientY);if(Ie?.kind==="noop"&&Ce?.type==="image"&&Ce.props.tikz&&!Ce.locked&&!N.current.has(Ce.id)&&!Pe.shiftKey&&!Pe.metaKey&&!Pe.ctrlKey&&Math.hypot(xe.x-Ne.start.x,xe.y-Ne.start.y)<3&&window.dispatchEvent(new CustomEvent(Lj,{detail:{documentId:v,shapeId:Ce.id}})),Ie?.kind==="commit"){let{offset:Y}=Ie;we=!0;let oe=new Set(Ne.shapes.map(be=>be.id)),de=Y9(Ne.shapes,Y.x,Y.y),{ordered:Le}=G();O(be=>{let Be=Qr(Jx(Wv(be,de),oe,Le));return R.current=Be,Be})}}if(Ne.id!=="overlay.curveDrawing"){if(Ne.id==="overlay.marquee"){let Ce=Wg([Ne.start,Ne.current]);if(Math.hypot(Ce.w,Ce.h)<3)if(Ne.selectOnClick){let xe=Z(Pe.clientX,Pe.clientY),Y=te(xe,8)??K(xe);Y?ne(Y.id):V([])}else Ne.additive||(V([]),S({x:Pe.clientX,y:Pe.clientY}));else{let xe=Rj(B9e({shapes:R.current,marquee:Ce,focusedGroupId:H.current,currentIds:U.current,additive:Ne.additive}),z?.current);V(xe),F&&xe.length===0&&!Ne.additive&&Ce.w>0&&Ce.h>0&&y({documentId:v,revision:w,bounds:Ce}),xe.length===0&&!Ne.additive&&!Ne.selectOnClick&&C?.(ee(Ne.start),{x:Pe.clientX,y:Pe.clientY})}}if(Ne.id==="overlay.insertDrag"){let Ce=Z(Pe.clientX,Pe.clientY),xe=fe(Ne.tool,Ne.start,Ce,Pe),Y=Math.hypot(xe.x-Ne.start.x,xe.y-Ne.start.y);if(k.current?.hasPointerCapture(Pe.pointerId)&&k.current.releasePointerCapture(Pe.pointerId),Y<4&&Ne.tool.command!=="table"){D({type:"setTool",tool:{kind:"select"}}),S({x:Pe.clientX,y:Pe.clientY}),a();return}let oe=$(Ne.tool,Ne.start,xe,Ne.tool.command==="freehand"?[...Ne.points??[Ne.start],xe]:Ne.points);Ne.tool.command==="graph"&&oe?D({type:"pickOrigin",shapeId:oe,initial:!0}):Ne.tool.command==="graph3d"&&oe?(D({type:"setTool",tool:{kind:"select"}}),D({type:"editGraph3D",shapeId:oe}),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent(lE,{detail:{shapeId:oe}}))},0)):Ne.tool.command==="table"&&oe?(D({type:"setTool",tool:{kind:"select"}}),D({type:"editTable",shapeId:oe})):Ne.tool.command==="text"&&oe?(D({type:"setTool",tool:{kind:"select"}}),D({type:"editText",shapeId:oe})):D({type:"setTool",tool:{kind:"select"}}),a();return}a(),Ne.id==="overlay.imageCropResize"||Ne.id==="overlay.imageCropPan"?D({type:"editImageCrop",shapeId:Ne.shape.id}):D({type:"select"}),k.current?.hasPointerCapture(Pe.pointerId)&&k.current.releasePointerCapture(Pe.pointerId),Ne.id==="overlay.imageCropResize"||Ne.id==="overlay.imageCropPan"?A():we&&x()}},[I,se,T,Z,a,k,D,G,R,O,x,N,z,v,te,K,ne,V,S,H,U,F,y,w,C,ee,fe,$,A]);return ETt(()=>{let Pe=k.current;return()=>{let Ne=I.current?.pointerId;Ne!==void 0&&Pe?.hasPointerCapture(Ne)&&Pe.releasePointerCapture(Ne),I.current=null,se();let we=T.current;sw(we)&&g(we)}},[v,k,I,T,g,se]),{handlePointerMove:Ae,handlePointerCancel:ye,handlePointerUp:$e}}var gZn,Kni,Yni,bZn=X(()=>{"use strict";"use client";Bj();Pn();P9e();Oge();Tc();A_();qte();yte();IAt();jh();Ly();_Ne();xP();Oye();gZn=2,Kni=8,Yni=1100});import{useCallback as xZn,useLayoutEffect as $ni,useMemo as Zni,useRef as R_}from"react";function vZn({documentId:e,modeRef:t,transitionMode:n,bleedSurfaceRef:r}){let o=R_(null),i=R_(null),a=R_(null),s=R_({ctrlKey:!1,shiftKey:!1}),l=R_(()=>{}),c=R_(Unn),u=R_(0),d=R_(null),p=xZn(m=>{i.current={pointerId:m.pointerId,startClientX:m.clientX,startClientY:m.clientY,autoScrollArmed:!1},r.current?.setPointerCapture(m.pointerId)},[r]),f=xZn(()=>{let m=i.current?.pointerId;m!==void 0&&r.current?.hasPointerCapture(m)&&r.current.releasePointerCapture(m),i.current=null,a.current=null,d.current?.stop(),d.current=null},[r]);return $ni(()=>f,[e,f]),Zni(()=>({modeRef:t,transitionMode:n,bleedSurfaceRef:r,lastInteractionPointRef:o,dragPointerRef:i,dragCanvasRectRef:a,lastPointerModifiersRef:s,advanceInteractionFromClientRef:l,resizePaddingRef:c,suppressNextShapeDoubleClickRef:u,dragAutoScrollerRef:d,capturePointer:p,releasePointer:f}),[t,n,r,p,f])}var SZn=X(()=>{"use strict";"use client";Pn()});import{useCallback as Q2}from"react";function wZn({session:e,editing:t,selection:n,geometry:r,drawing:o,focusOverlayCanvas:i,setAdjustmentDragReadoutPointerPosition:a,graphFillPickShapeId:s,selectedRegion:l}){let{modeRef:c,transitionMode:u,lastInteractionPointRef:d,resizePaddingRef:p,suppressNextShapeDoubleClickRef:f}=e,{shapesRef:m,updateShape:h,editPolicyLockedShapeIdsRef:g,notifyEditPolicyBlocked:y}=t,{selectedIdsRef:b,focusedGroupIdRef:x,setFocusedGroupId:v,setSelectedShapeIds:S,selectShape:F,toggleShapeSelection:w,setSolidEdge:C,duplicateSelectedShapes:A}=n,{pagePointFromClient:T,getOverlaySnapThreshold:D,getShapeAtPoint:k,getOpenStrokeShapeAtPoint:P}=r,{getSnappedDrawingPoint:I,finishCurveDrawing:B}=o,M=e.capturePointer,L=Q2((te,K)=>{te.preventDefault(),te.stopPropagation(),i(),S([]);let G=T(te.clientX,te.clientY);d.current=G,h_(K)&&a(G),u({type:"startInsertDrag",tool:K,start:G,points:K.command==="freehand"?[G]:void 0}),M(te)},[M,i,d,T,a,S,u]),_=Q2((te,K)=>{te.preventDefault(),te.stopPropagation(),i();let G=c.current,ie=T(te.clientX,te.clientY),fe=G.id==="overlay.curveDrawing"?G.points[G.points.length-1]:void 0,$=I(ie,{previousPoint:fe,shiftKey:te.shiftKey,enabled:hj(K)});if(G.id==="overlay.curveDrawing"){if(zDe(G.tool,G.points,ie)){B(G.tool,G.points,!0);return}let j=Xrt(G.points,$);if(G.tool.command==="threePointArc"){if(j.length>=3){B(G.tool,j.slice(0,3));return}u({type:"addCurvePoint",point:$});return}if(te.detail>=2){f.current=window.performance.now(),B(G.tool,j);return}u({type:"addCurvePoint",point:$});return}S([]),u({type:"startCurveDrawing",tool:K,point:$})},[B,i,I,c,T,S,f,u]),R=Q2(te=>{let K=c.current;if(K.id!=="overlay.curveDrawing"||K.tool.command==="threePointArc")return!1;te.preventDefault(),te.stopPropagation(),f.current=window.performance.now();let G=T(te.clientX,te.clientY),ie=K.points[K.points.length-1],fe=I(G,{previousPoint:ie,shiftKey:te.shiftKey,enabled:hj(K.tool)});return B(K.tool,Xrt(K.points,fe)),!0},[B,I,c,T,f]),O=Q2((te,K,G)=>{te.preventDefault(),te.stopPropagation(),i();let ie=x.current;ie&&K.id!==ie&&!hte(m.current,K.id,ie)&&(x.current=null,v(null));let fe=cF(m.current,K.id,x.current);if(te.shiftKey||te.metaKey||te.ctrlKey){w(fe);return}let j=b.current.length===1&&b.current[0]===K.id,pe=fe.every(Q=>b.current.includes(Q));if(pe||S(fe),Nc(K)){let Q=j&&!te.altKey?Cke(K,G,D()*.75):null;C(Q===null?null:{shapeId:K.id,index:Q})}if(te.altKey){let Q=A({x:0,y:0});if(Q.length===0)return;u({type:"startMove",shapes:Q,start:G}),M(te);return}let re=pe?b.current:fe,le=$x(m.current,re,g.current);if(le.length===0){Wh(m.current,re,g.current)&&y();return}u({type:"startMove",shapes:le,start:G,editOnPointerUp:Bd(K)&&j?"text":K.type==="tableShape"&&j?"table":void 0}),M(te)},[M,A,g,i,x,D,y,b,v,S,C,m,w,u]),N=Q2((te,K)=>{i(),x.current&&(x.current=null,v(null));let G=te.shiftKey||te.metaKey||te.ctrlKey;G||S([]),u({type:"startMarquee",start:K,additive:G}),M(te)},[M,i,x,v,S,u]),z=Q2(te=>{if(te.button!==0||te.defaultPrevented||s)return;let K=te.target instanceof Element?te.target:null;if(K?.closest(".overlay-text-shape-content, .graph2d-container.cropping")||K?.closest("[data-toolbar-popover]"))return;let G=kce(c.current);if(G.kind==="insert"){if(Iye(G)){_(te,G);return}L(te,G);return}let ie=T(te.clientX,te.clientY);if(!K?.closest("[data-overlay-shape-id]")){i();let fe=P(ie);if(fe){O(te,fe,ie);return}if(l&&!te.shiftKey&&!te.metaKey&&!te.ctrlKey&&ie.x>=l.x&&ie.x<=l.x+l.w&&ie.y>=l.y&&ie.y<=l.y+l.h){te.preventDefault();return}N(te,ie)}},[s,c,T,L,_,i,P,l,N,O]),U=Q2(te=>{if(te.button!==0||te.defaultPrevented||s||te.target instanceof Element&&te.target.closest(".overlay-text-shape-content, .overlay-table-shape-content, .graph2d-container.cropping"))return;let K=kce(c.current);if(K.kind==="insert"){if(Iye(K)){_(te,K);return}L(te,K);return}let G=T(te.clientX,te.clientY),ie=k(G,8)??P(G);if(!ie){if(te.target instanceof Element&&te.target.closest("button, a, input, textarea, [contenteditable='true'], [data-toolbar-popover]"))return;N(te,G);return}if(ie.type==="graph2dShape"&&!qv(ie,G,0))return;let fe=c.current;if(fe.id==="overlay.imageCropping"&&fe.shapeId===ie.id&&ie.type==="image"){te.preventDefault(),te.stopPropagation(),i(),F(ie.id),u({type:"startImageCropPan",shape:ie,start:G}),M(te);return}O(te,ie,G)},[N,M,i,P,k,s,_,c,T,F,L,O,u]),H=Q2((te,K)=>{te.preventDefault(),te.stopPropagation(),i();let G=$x(m.current,b.current,g.current),ie=Gnn(G,m.current);if(!ie){Wh(m.current,b.current,g.current)&&y();return}let fe=T(te.clientX,te.clientY);d.current=fe,p.current=ie.padding,u({type:"startResize",shapes:G,handle:K,start:fe,bounds:ie.visual}),M(te)},[M,g,i,d,y,T,p,b,m,u]),V=Q2((te,K,G)=>{if(K.locked)return;te.preventDefault(),te.stopPropagation(),i(),F(K.id);let ie=T(te.clientX,te.clientY);d.current=ie,u({type:"startImageCropResize",shape:K,handle:G,start:ie}),M(te)},[M,i,d,T,F,u]),ne=Q2(te=>{te.preventDefault(),te.stopPropagation(),i();let K=$x(m.current,b.current,g.current),G=Lke(K,m.current);if(!G){Wh(m.current,b.current,g.current)&&y();return}let ie=T(te.clientX,te.clientY);u({type:"startRotate",shapes:K,center:G,startAngle:vB(G,ie)}),M(te)},[M,g,i,y,T,b,m,u]),Z=Q2((te,K,G)=>{te.button!==0||K.locked||(te.preventDefault(),te.stopPropagation(),i(),F(K.id),u({type:"startAnchorDrag",shape:K,start:T(te.clientX,te.clientY),origin:G}),M(te))},[M,i,T,F,u]),ee=Q2((te,K,G)=>{if(!(K.locked||te.button!==0)){if(te.preventDefault(),te.stopPropagation(),i(),F(K.id),te.altKey&&K.type==="line"&&G.type==="line"&&UK(K.props.kind)){if(Ac(m.current,K))return;if(Js(m.current,K,g.current)){y();return}XQt(K.props.points,G.index,K.props.closed===!0)&&h({...K,props:{...K.props,points:WQt(K.props.points,G.index)}});return}xte(G)&&a(T(te.clientX,te.clientY)),u({type:"startPoint",shape:K,handle:G,pivot:dl(K),rotation:Oi(K)}),M(te)}},[M,g,i,y,T,F,a,m,u,h]),J=Q2((te,K,G,ie)=>{if(te.button!==0||Ac(m.current,K))return;if(Js(m.current,K,g.current)){y();return}te.preventDefault(),te.stopPropagation(),i(),F(K.id);let fe={...K,props:{...K.props,points:VQt(K.props.points,G,ie)}};h(fe,{history:"coalesce"}),u({type:"startPoint",shape:fe,handle:{type:"line",index:G},pivot:dl(fe),rotation:Oi(fe)}),M(te)},[M,g,i,y,F,m,u,h]);return{handleCurveDrawingDoubleClick:R,handleCanvasPointerDown:z,handleShapePointerDown:U,handleResizePointerDown:H,handleImageCropResizePointerDown:V,handleRotatePointerDown:ne,handlePointPointerDown:ee,handleLineInsertPointerDown:J,handleAnchorPointerDown:Z}}var FZn=X(()=>{"use strict";"use client";Pn();A_();Tc();yte();jh();_Ne();xP()});import{useCallback as Yj}from"react";function CZn({session:e,editing:t,geometry:n,snapDisabledRef:r,setSnapGuides:o,clearSnapGuides:i,lastCalloutCornerRadiusRef:a,imageCropDirtyRef:s}){let{transitionMode:l,lastInteractionPointRef:c,resizePaddingRef:u}=e,{shapesRef:d,setShapes:p,assetsRef:f,replaceShape:m}=t,{clientPointFromPage:h,getOverlaySnapThreshold:g,createSnapGeometry:y,anchorMeasurementsRef:b}=n,x=Yj((T,D)=>{if(Xot({start:h(T.start)},h(D))){i(),T.offset&&l({type:"updateMove",offset:{x:0,y:0}});return}let k=D.x-T.start.x,P=D.y-T.start.y,I=new Set(T.shapes.map(_=>_.id)),B=pd(T.shapes),M=k,L=P;if(B){let _=y(By(d.current,[...I],{includeGroups:!0})),R={threshold:g(),disabled:r.current},O=hrn(mrn(T.shapes),{x:k,y:P},_,R),N=O.guides.length>0?O:frn({...B,x:B.x+k,y:B.y+P},_,R);M+=N.nudge.x,L+=N.nudge.y,o(N.guides)}else i();l({type:"updateMove",offset:{x:M,y:L}})},[h,i,y,g,o,d,r,l]),v=Yj((T,D,k)=>{let{bounds:P,isRotated:I,preserveAspect:B,targetAspect:M}=Rnn(T,D,k),L=new Set(T.shapes.map(O=>O.id)),_=P;if(I)i();else{let O=grn(P,T.handle,y(By(d.current,[...L],{includeGroups:!0})),{threshold:g(),disabled:r.current,preserveAspect:B,targetAspect:M});_=O.bounds,o(O.guides)}let R={visual:T.bounds,padding:u.current};p(O=>{let N=I?[Vnn(T.shapes[0],R,_,T.handle)]:jnn(T.shapes,R,_,T.handle),z=new Set(N.map(H=>H.id)),U=Qr(Jx(Wv(O,N),z,b.current.ordered));return d.current=U,U})},[b,i,y,g,u,p,o,d,r]),S=Yj((T,D,k)=>{let P=qot(T.shape,T.handle,y9(D,T.pivot,T.rotation,T.shape.flipX,T.shape.flipY),k.shiftKey);P.type==="callout"&&T.handle.type==="calloutCornerRadius"&&(a.current=P.props.radius,qNe(P.props.radius));let I=jKn(P,T.handle);if(!I){i(),m(P);return}let B=oit(I,y(By(d.current,[T.shape.id],{includeGroups:!0})),{threshold:g(),disabled:r.current});o(B.guides);let M=B.snapped?qot(T.shape,T.handle,y9(B.point,T.pivot,T.rotation,T.shape.flipX,T.shape.flipY),k.shiftKey):P;m(M)},[i,y,g,a,m,o,d,r]),F=Yj((T,D)=>{i();let k=d.current.find(z=>z.id===T.shape.id&&z.type==="image");if(!k)return;let P=f.current[k.props.assetId],I=D.x-T.start.x,B=D.y-T.start.y,M=Yot(I,B,Oi(T.shape)),L={x:T.shape.flipX?-M.x:M.x,y:T.shape.flipY?-M.y:M.y};if(T.id==="overlay.imageCropPan"){let U={...eWn(T.shape,P,L.x,L.y),x:k.x,y:k.y,rotation:k.rotation,anchor:k.anchor};if(LAt(k,U,P))return;s.current=!0,m(U);return}let _=yi(T.shape),R=QXn(_,iw(T.shape,P),{w:P?.props.w||T.shape.props.w,h:P?.props.h||T.shape.props.h},T.handle,L),O=Dke(T.shape,_,R.bounds,T.handle),N={...k,x:O.x,y:O.y,props:{...k.props,w:O.props.w,h:O.props.h,crop:R.crop}};LAt(k,N,P)||(s.current=!0,p(z=>{let U=Qr(Jx(aB(z,N),new Set([N.id]),b.current.ordered));return d.current=U,U}))},[b,f,i,s,m,p,d]),w=Yj((T,D={})=>{let k=D.shiftKey&&D.previousPoint?I5(D.previousPoint,T):T;if(D.enabled===!1)return i(),k;let P=oit(k,y(),{threshold:g(),disabled:r.current});return o(P.guides),P.point},[i,y,g,o,r]),C=Yj((T,D,k,P)=>{let I=VKn(T,D,k,P);return CXn(T)?w(I,{enabled:!0}):(i(),I)},[i,w]);return{updateModifierDrivenInteraction:Yj((T,D)=>{let k=c.current;if(!k)return!1;if(T.id==="overlay.move")return x(T,k),!0;if(T.id==="overlay.resize")return v(T,k,D),!0;if(T.id==="overlay.point")return S(T,k,D),!0;if(T.id==="overlay.insertDrag")return l({type:"updateInsertDrag",current:C(T.tool,T.start,k,D)}),!0;if(T.id==="overlay.curveDrawing"){let P=T.points[T.points.length-1];return l({type:"updateCurveDrawing",current:w(k,{previousPoint:P,shiftKey:D.shiftKey,enabled:hj(T.tool)})}),!0}return!1},[x,S,v,w,C,c,l]),getSnappedDrawingPoint:w,applyMoveInteractionAtPoint:x,applyResizeInteractionAtPoint:v,applyPointInteractionAtPoint:S,applyImageCropInteractionAtPoint:F,getSnappedInsertDragPoint:C}}var AZn=X(()=>{"use strict";"use client";Dt();Pn();MAt();Tc();NNe();qte();jh();Ly();KNe();WCt();xP()});function TZn({payload:e,canvasWidth:t,canvasHeight:n,offset:r={x:20,y:20},targetDocId:o,anchorBlockIdMap:i,centerAt:a,unbounded:s=!1,pointerPlacement:l}){let c=!!o&&e.sourceDocId===o,u=a||l?pd(e.shapes):null,d=!a&&l&&u?nZn(l.point,u,l.layout):null,p=a??d,f=p&&u?{x:p.x-(u.x+u.w/2),y:p.y-(u.y+u.h/2)}:r,m=aJ(e,f,{dropBlockAnchors:!c||!!(p&&u),droppedBlockAnchor:d?"unanchored":"page",anchorBlockIdMap:i});if(m.shapes.length===0)return{shapes:[],assets:m.assets,selectedIds:[]};let h=m.shapes.map(Jni),g=Qr(s?h:rY(h,t,n)),y=new Set(g.map(x=>x.id)),b=g.filter(x=>!x.parentId||!y.has(x.parentId)).map(x=>x.id);return{shapes:g,assets:m.assets,selectedIds:b}}function Jni(e){let t={...e};return delete t.locked,delete t.hidden,t}var DZn=X(()=>{"use strict";Dt();Pn();Sp();xbe()});function kZn(e,t,n){let r=Qr(e),o=new Set(t),i=new Set(r.filter(l=>o.has(l.id)&&!ari(l,r,o)).map(l=>l.id));if(i.size===0)return r;let a=ori(r),s=new Map;for(let[l,c]of a){if(c.filter(d=>i.has(d.id)).length===0){s.set(l,c);continue}s.set(l,Qni(c,i,n))}return eri(Qr(iri(r,s)),i,n)}function Qni(e,t,n){if(n==="front"||n==="back"){let o=e.filter(a=>t.has(a.id)),i=e.filter(a=>!t.has(a.id));return n==="front"?[...i,...o]:[...o,...i]}let r=e.slice();if(n==="forward"){for(let o=r.length-2;o>=0;o-=1){let i=r[o];if(t.has(i.id)){let a=nri(r,o,t);a>o&&(r.splice(o,1),r.splice(a,0,i))}}return r}for(let o=1;o<r.length;o+=1){let i=r[o];if(t.has(i.id)){let a=rri(r,o,t);a<o&&(r.splice(o,1),r.splice(a,0,i))}}return r}function eri(e,t,n){let r=tri(e,t);if(r.size===0)return e;let o=n==="back"?"background":void 0,i=!1,a=e.map(s=>{if(!r.has(s.id))return s;if(o)return s.stackLayer===o?s:(i=!0,{...s,stackLayer:o});if(s.stackLayer===void 0)return s;let l={...s};return delete l.stackLayer,i=!0,l});return i?a:e}function tri(e,t){let n=new Set,r=o=>{if(!n.has(o.id)){n.add(o.id);for(let i of e.filter(a=>a.parentId===o.id))r(i)}};for(let o of e)t.has(o.id)&&r(o);return n}function nri(e,t,n){let r=e[t];for(let o=t+1;o<e.length;o+=1){let i=e[o];if(!n.has(i.id)&&EZn(r,i))return o}for(let o=t+1;o<e.length;o+=1)if(!n.has(e[o].id))return o;return t}function rri(e,t,n){let r=e[t];for(let o=t-1;o>=0;o-=1){let i=e[o];if(!n.has(i.id)&&EZn(r,i))return o}for(let o=t-1;o>=0;o-=1)if(!n.has(e[o].id))return o;return t}function EZn(e,t){let n=Zp(e),r=Zp(t);return n.x<=r.x+r.w&&n.x+n.w>=r.x&&n.y<=r.y+r.h&&n.y+n.h>=r.y}function ori(e){let t=new Map;for(let n of e){let r=n.parentId??"";t.set(r,[...t.get(r)??[],n])}return t}function iri(e,t){let n=[],r=new Set,o=i=>{if(!r.has(i.id)&&(r.add(i.id),n.push(i),i.type==="group"))for(let a of t.get(i.id)??[])o(a)};for(let i of t.get("")??[])o(i);for(let i of e)o(i);return n}function ari(e,t,n){let r=e.parentId,o=new Set([e.id]);for(;r;){if(n.has(r))return!0;if(o.has(r))return!1;o.add(r),r=t.find(i=>i.id===r)?.parentId}return!1}var IZn=X(()=>{"use strict";Dt();Pn()});import{useCallback as tv}from"react";function PZn({shapesRef:e,selectedIdsRef:t,editPolicyLockedShapeIdsRef:n,notifyEditPolicyBlocked:r,assetsRef:o,canvasWidthRef:i,canvasHeightRef:a,setAssets:s,setShapes:l,setSelectedShapeIds:c,transitionMode:u,queueOverlaySave:d,extensionsRef:p,explicitlySavedShapeStatesRef:f,pendingOverlaySaveHistoryGroupRef:m,commitOverlayChangeNow:h,refreshAnchorMeasurements:g,solidEdgeRef:y,documentIdRef:b,canvasRef:x,getBlockAnchorScope:v,pageHeightPx:S,pageGapPx:F}){let w=tv((N={x:20,y:20})=>{if(Wh(e.current,t.current,n.current))return r(),[];let z=y_(e.current,t.current);if(z.length===0)return[];let U=aJ(Nw(z,o.current),N),H=Qr(rY(U.shapes.map(DKn),i.current,a.current)),V=new Set(H.map(Z=>Z.id)),ne=H.filter(Z=>!Z.parentId||!V.has(Z.parentId)).map(Z=>Z.id);return s(Z=>{let ee={...Z,...U.assets};return o.current=ee,ee}),l(Z=>{let ee=Qr([...Z,...H]);return e.current=ee,ee}),c(ne),u({type:"select"}),d(),H},[o,a,i,n,r,d,t,s,c,l,e,u]),C=tv(()=>{let N=new Set(By(e.current,t.current,{includeGroups:!0})),z=new Set(e.current.filter(U=>N.has(U.id)&&!Ac(e.current,U)&&!Js(e.current,U,n.current)).map(U=>U.id));for(let U of e.current)if(!(U.type!=="graph2dShape"||!N.has(U.id)||U.locked||Js(e.current,U,n.current)))for(let H of Jye(U,e.current)){let V=e.current.find(ne=>ne.id===H);V&&!V.locked&&!Js(e.current,V,n.current)&&z.add(H)}return[...z]},[n,t,e]),A=tv(()=>{Wh(e.current,t.current,n.current)&&r();let N=C();if(N.length===0)return;let z=new Set(N),U=dB({version:1,shapes:Qr(WAe(e.current,N)),assets:o.current,...p.current?{extensions:p.current}:{}});e.current=U.shapes,o.current=U.assets,f.current.add(U.shapes),l(U.shapes),s(U.assets);let H=m.current;m.current=null,h(H?{historyGroup:H}:{}),c(t.current.filter(V=>!z.has(V))),u({type:"select"})},[o,h,n,f,p,C,r,m,t,s,c,l,e,u]),T=tv(()=>{if(Wh(e.current,t.current,n.current)){r();return}let N=PXn(e.current,t.current,iXn);e.current=N.shapes,l(N.shapes),c(N.selectedIds),u({type:"select"})},[n,r,t,c,l,e,u]),D=tv(()=>{if(Wh(e.current,t.current,n.current)){r();return}let N=MXn(e.current,t.current);e.current=N.shapes,l(N.shapes),c(N.selectedIds),u({type:"select"})},[n,r,t,c,l,e,u]),k=tv(N=>{if(Wh(e.current,t.current,n.current)){r();return}let z=new Set(t.current);l(U=>{let H=Qr(U.map(V=>z.has(V.id)?{...V,locked:N}:V));return e.current=H,H})},[n,r,t,l,e]),P=tv(N=>{let z=new Set(t.current);l(U=>{let H=Qr(U.map(V=>z.has(V.id)?{...V,hidden:N}:V));return e.current=H,H})},[t,l,e]),I=tv(N=>{let z=t.current;if(z.length===0)return;if(Wh(e.current,z,n.current)){r();return}let U=$x(e.current,z,n.current).map(V=>V.id);if(U.length===0)return;let H=kZn(e.current,U,N);_ke(e.current,H)||(e.current=H,l(H),c(z))},[n,r,t,c,l,e]),B=tv(N=>{Wh(e.current,t.current,n.current)&&r();let z=AA(e.current,t.current).filter(ne=>!Ac(e.current,ne)&&!Js(e.current,ne,n.current));if(z.length<2)return;let U=pnn(z,N),H=new Set(By(e.current,z.map(ne=>ne.id),{includeGroups:!0})),{ordered:V}=g();l(ne=>{let Z=Qr(Jx(PAt(ne,z,U),H,V));return e.current=Z,Z})},[n,r,g,t,l,e]),M=tv(N=>{Wh(e.current,t.current,n.current)&&r();let z=AA(e.current,t.current).filter(ne=>!Ac(e.current,ne)&&!Js(e.current,ne,n.current));if(z.length<3)return;let U=fnn(z,N),H=new Set(By(e.current,z.map(ne=>ne.id),{includeGroups:!0})),{ordered:V}=g();l(ne=>{let Z=Qr(Jx(PAt(ne,z,U),H,V));return e.current=Z,Z})},[n,r,g,t,l,e]),L=tv(N=>{if(Wh(e.current,t.current,n.current)){r();return}let z=$x(e.current,t.current,n.current),U=Lke(z,e.current);if(!U)return;let H=N==="rotateClockwise"?$9(z,U,Math.PI/2):N==="rotateCounterclockwise"?$9(z,U,-Math.PI/2):Tce(z,U,N),V=new Set(H.map(Z=>Z.id)),{ordered:ne}=g();l(Z=>{let ee=Qr(Jx(Wv(Z,H),V,ne));return e.current=ee,ee})},[n,r,g,t,l,e]),_=tv(N=>{Wh(e.current,t.current,n.current)&&r();let z=y.current,U=z&&N.dash!==void 0?N.dash:void 0,H=z&&N.size!==void 0?N.size:void 0,V=U===void 0&&H===void 0?N:{...N,...U===void 0?{}:{dash:void 0},...H===void 0?{}:{size:void 0}},ne=e.current,Z=jte(ne,t.current,n.current),ee=Qr(ne.map(J=>{if(!Z.has(J.id))return J;let te=cte(J,V);if(z?.shapeId!==J.id||!Nc(te))return te;let K=U===void 0?te:nnn(te,z.index,U);return H===void 0?K:onn(K,z.index,H)}));e.current=ee,l(ee)},[n,r,t,l,e,y]),R=tv((N,z={})=>{let U=z.pointerClient&&!z.centerAt&&Object.keys(z.anchorBlockIdMap??{}).length===0?oZn(z.pointerClient,x.current?.getBoundingClientRect(),{canvasWidth:i.current,canvasHeight:a.current,pageHeightPx:S,pageGapPx:F},rZn(W2(x.current))):null,H=TZn({payload:N,canvasWidth:i.current,canvasHeight:a.current,targetDocId:b.current,anchorBlockIdMap:z.anchorBlockIdMap,centerAt:z.centerAt,unbounded:z.unbounded,pointerPlacement:U??void 0});if(H.shapes.length===0)return!1;let V=new Set(Object.values(z.anchorBlockIdMap??{})),ne=H.shapes;if(V.size>0&&x.current){let J=v(),{rects:te}=J?yP(x.current,J,a.current,i.current):{rects:new Map},K=new Map([...te].filter(([G])=>V.has(G)));K.size>0&&(ne=Qr(F0(ne,K,Qx(ne))))}let Z={...o.current,...H.assets},ee=Qr([...e.current,...ne]);return o.current=Z,e.current=ee,f.current.add(ee),s(Z),l(ee),h(z.historyGroup?{historyGroup:z.historyGroup}:{}),c(H.selectedIds),u({type:"select"}),!0},[o,a,x,i,h,b,f,v,F,S,s,c,l,e,u]),O=tv((N,z)=>{let U=new Set(ykn(z));if(U.size===0)return N;let{ordered:H}=g(),V=H.filter(ee=>U.has(ee.id));if(V.length===0)return N;let ne=new Set(N.map(ee=>ee.id)),Z=e.current.map(ee=>ne.has(ee.id)?kKn(ee):ee);return y_(Jx(Z,ne,V),t.current)},[g,t,e]);return{duplicateSelectedShapes:w,deleteSelectedShapes:A,arrangeSelectedShapes:I,alignSelectedShapes:B,distributeSelectedShapes:M,groupSelectedShapes:T,ungroupSelectedShapes:D,setSelectedShapesLocked:k,setSelectedShapesHidden:P,applyStyleToSelectedShapes:_,applyPastedOverlayShapes:R,reanchorShapesToCopiedBlocks:O,getRemovableSelectedShapeIds:C,applyQuickTransformToSelectedShapes:L}}var MZn=X(()=>{"use strict";"use client";Dt();Pn();Sp();v_();My();A_();Tc();tE();DZn();sF();xbe();Ly();IZn();Vte();D_();dj()});import{useEffect as sri,useState as LZn}from"react";import{jsx as __,jsxs as BZn}from"react/jsx-runtime";function RZn(e){return e.id==="overlay.move"?"move":e.id==="overlay.resize"?"resize":e.id==="overlay.rotate"?"rotate":e.id==="overlay.imageCropResize"||e.id==="overlay.imageCropPan"?"crop":null}function lri(e){let[t,n]=LZn(null);return sri(()=>{if(!e?.remoteOverlayPresence||!e.subscribePresence)return;let r=()=>n({session:e,presence:e.remoteOverlayPresence?.()??[]});return e.subscribePresence(r)},[e]),e?.remoteOverlayPresence?t?.session===e?t.presence:e.remoteOverlayPresence():[]}function vbe({shapes:e,arrangement:t}){let n=HD(),o=lri(n).map(a=>({participant:a,frames:ITt(a,e)})).filter(a=>a.frames.length>0).sort((a,s)=>a.participant.clientId.localeCompare(s.participant.clientId)),i=new Map;return __("div",{className:"overlay-remote-presence-layer","aria-hidden":"true",children:o.map(({participant:a,frames:s})=>{let l=PTt(s),c=`${Math.round(l.x)}:${Math.round(l.y)}:${s.map(p=>p.id).sort().join("|")}`,u=i.get(c)??0;i.set(c,u+1);let d=uri(a.clientId);return BZn("div",{className:"overlay-remote-presence","data-remote-client-id":a.clientId,"data-remote-preview-kind":a.preview?.kind,style:{"--overlay-remote-color":d},children:[s.map(p=>__(Gd,{arrangement:t,y:p.y,children:__("div",{className:"overlay-remote-selection-box","data-remote-shape-id":p.id,style:MTt(p)})},p.id)),__(Gd,{arrangement:t,y:l.y,children:BZn("span",{className:"overlay-remote-presence-label","data-remote-label-slot":u,style:{left:l.x,top:l.y-u*30},children:[__(cri,{participant:a}),__("span",{children:a.displayName})]})})]},a.clientId)})})}function ITt(e,t){let n=new Map(t.map(o=>[o.id,o])),r=e.preview?.shapes.filter(o=>n.has(o.id))??[];return r.length>0?r:e.selectedShapeIds.flatMap(o=>{let i=n.get(o);if(!i)return[];let a=i.type==="group"?aw([i],t)??A0(i):A0(i),s=Oi(i);return[{id:o,...a,...s?{rotation:s,pivot:dl(i)}:{}}]})}function PTt(e){let t=e.map(n=>FK(n,n.rotation??0,n.pivot));return Wg(t.flatMap(n=>[{x:n.x,y:n.y},{x:n.x+n.w,y:n.y+n.h}]))}function cri({participant:e}){let[t,n]=LZn(!1),r=e.displayName.trim().charAt(0).toLocaleUpperCase()||"?";return __("span",{className:"overlay-remote-presence-avatar",children:e.avatarSource&&!t?__("img",{src:e.avatarSource,alt:"",onError:()=>n(!0)}):r})}function uri(e){let t=["#2563eb","#7c3aed","#db2777","#059669","#d97706","#0891b2"],n=0;for(let r=0;r<e.length;r+=1)n=(n<<5)-n+e.charCodeAt(r)|0;return t[Math.abs(n)%t.length]}function MTt(e){return{left:e.x,top:e.y,width:e.w,height:e.h,transform:e.rotation?`rotate(${e.rotation}rad)`:void 0,transformOrigin:e.rotation&&e.pivot?eAt(e.pivot,e):void 0}}var sze=X(()=>{"use strict";"use client";Pn();u4();jh();gte();tAt()});import{useEffect as lze,useLayoutEffect as dri,useMemo as mE}from"react";function _Zn({shapes:e,selectedIds:t,assets:n,editPolicyLockedShapeIds:r,mode:o,initialOriginPickShapeId:i,selectedRegion:a,dragOffset:s,publishesSessionPresence:l,documentSession:c,tShape:u,adjustmentDragReadoutPointerPosition:d,shapeStyleDefaults:p,showAnchorHandles:f,anchorMeasurements:m,canvasWidth:h,canvasHeight:g,bleedValues:y,onSelectionSummaryChange:b,solidEdge:x,acceptsStylePreview:v,setPreview:S,shapesRef:F,selectedIdsRef:w,editPolicyLockedShapeIdsRef:C}){let A=mE(()=>AA(e,t),[t,e]),T=mE(()=>$nn(A),[A]),D=mE(()=>y_(e,t),[t,e]),k=mE(()=>Znn(D,n),[n,D]),P=mE(()=>{let re=new Set(D.map(se=>se.id)),le=new Set(KDe(e,re)),Q=e.filter(se=>le.has(se.id)&&!re.has(se.id));return Q.length>0?[...D,...Q]:D},[D,e]),I=mE(()=>$x(e,t,r),[r,t,e]),B=mE(()=>Bke(A,e),[A,e]),M=A.length>0&&A.every(re=>Ac(e,re)),L=A.length>0&&A.every(re=>mte(e,re)),_=A.length===1?nY(A[0]):A.some(re=>!Ac(e,re)),R=!I.some(re=>re.type==="tableShape"),O=o.id==="overlay.graphEditing"&&A.length===1&&A[0]?.id===o.shapeId,N=o.id==="overlay.graph3dEditing"&&A.length===1&&A[0]?.id===o.shapeId,z=(o.id==="overlay.imageCropping"||o.id==="overlay.imageCropResize"||o.id==="overlay.imageCropPan")&&A.length===1&&A[0]?.id===(o.id==="overlay.imageCropping"?o.shapeId:o.shape.id)&&A[0]?.type==="image"?A[0]:null,U=i!==null,H=o.id==="overlay.marquee"?Wg([o.start,o.current]):a,V=o.tool,ne=o.id==="overlay.move"?o.shapes:null,Z=mE(()=>{if(!ne)return null;let re=new Set(ne.map(le=>le.id));for(let le of ne)if(le.type===lF)for(let Q of Jye(le,e))re.add(Q);return BXn(e,re)},[ne,e]),ee=mE(()=>{if(t.length===0)return null;let re=RZn(o),le=re?A.map(Q=>{let se=Q.type==="group"?aw([Q],e)??A0(Q):A0(Q),De=o.id==="overlay.move"&&Z?.has(Q.id)&&s?{...se,x:se.x+s.x,y:se.y+s.y}:se,Ae=Oi(Q),ye=Ae?dl(Q):null,$e=ye&&o.id==="overlay.move"&&Z?.has(Q.id)&&s?{x:ye.x+s.x,y:ye.y+s.y}:ye;return{id:Q.id,...De,...Ae&&$e?{rotation:Ae,pivot:$e}:{}}}):[];return{selectedShapeIds:t,...re?{preview:{kind:re,shapes:le}}:{}}},[s,o,Z,t,A,e]);lze(()=>{l&&c?.setOverlayPresence?.(ee)},[c,ee,l]),lze(()=>()=>{l&&c?.setOverlayPresence?.(null)},[c,l]);let J=o.id==="overlay.anchor"?o:null,te=o.id==="overlay.insertDrag"?o:null,K=o.id==="overlay.curveDrawing"?o:null,G=K?zDe(K.tool,K.points,K.current):!1,ie=K?NDe(K.points,K.current,G):null,fe=uWn(o,K,G,u),$=te?{tool:te.tool,start:te.start,current:te.current,points:te.points,closed:!1,bounds:Wg([te.start,te.current])}:K&&ie?{tool:K.tool,start:ie[0],current:ie[ie.length-1],points:ie,closed:G,bounds:Wg(ie)}:null,j=fWn(o,e,d,p,u),pe=mE(()=>{if(!f)return[];let re=J?N9e(J):null;return A.filter(le=>!LXn(e,le)&&!mte(e,le)&&!ace(le,e)).map(le=>TWn(le,e,m,h,g,J?.shape.id===le.id?re:null,Z?.has(le.id)??!1,y)).filter(le=>le!==null)},[J,m,y,g,h,Z,A,e,f]);return dri(()=>{let re=A.some(eXn),le=A.some(xCt),Q=A.some(tXn),se=A.some(nXn),De=vCt(A,"start"),Ae=vCt(A,"end"),ye=rXn(D);b?.({...o.id==="overlay.textEditing"||o.id==="overlay.tableEditing"?{textEditing:{shapeId:o.shapeId,kind:o.id==="overlay.tableEditing"?"table":"text"}}:{},...a?{region:a}:{},selectedCount:A.length,selectedShapeIds:t,selectedShapes:D,selectedAssets:k,...P!==D?{previewShapes:P}:{},locked:M,hidden:L,grouped:A.some($e=>wh($e)||!!$e.parentId),canAlign:A.length>=2,canDistribute:A.length>=3,canStyleStroke:re,canStyleFill:le,canStyleLine:Q,canStyleLineEndpoints:se,arrowheadStart:De,arrowheadEnd:Ae,fill:ye,...x&&A.length===1&&A[0].id===x.shapeId?{solidEdge:x}:{}})},[o,b,x,a,k,D,P,L,t,M,A]),lze(()=>()=>{b?.({selectedCount:0,selectedShapeIds:[],selectedShapes:[],selectedAssets:{},locked:!1,hidden:!1,grouped:!1,canAlign:!1,canDistribute:!1,canStyleStroke:!1,canStyleFill:!1,canStyleLine:!1,canStyleLineEndpoints:!1,arrowheadStart:null,arrowheadEnd:null,fill:{kind:"unavailable"}})},[b]),lze(()=>{if(!v)return;let re=le=>{let Q=le.detail?.style??null;S(Q===null?null:{style:Q,targetIds:jte(F.current,w.current,C.current)})};return window.addEventListener(aze,re),()=>window.removeEventListener(aze,re)},[v,C,w,S,F]),{movingShapeIds:Z,selectedShapes:A,currentTool:V,selectionChromeHidden:U,selectionImageCropShape:z,selectedDimensionShapes:T,selectionBounds:B,selectionCanResize:_,selectedLocked:M,selectionIsGraphCropping:O,selectionIsGraph3DEditing:N,selectionCanRotate:R,anchorIndicators:pe,marqueeBounds:H,insertPreview:$,curveDrawing:K,curveDrawingClosed:G,adjustmentDragReadout:j,drawingHint:fe}}var OZn=X(()=>{"use strict";"use client";Pn();PP();Tc();XNe();qte();jh();sze();Vte();QCt();Yx();D_();dj()});import{useCallback as hE}from"react";function NZn({activeTextEditorRef:e,selectShape:t,transitionMode:n,shapesRef:r,updateShape:o,updateGraphShapeSpec:i,insertedTableFocusRef:a}){let s=hE((y,b)=>{e.current=y,t(b),n({type:"editText",shapeId:b})},[e,t,n]),l=hE(y=>{e.current?.commands.blur(),e.current=null,t(y)},[e,t]),c=hE((y,b,x)=>{let v=r.current.find(F=>F.id===y);if(!v||!Bd(v))return;let S=v.type==="callout"?Math.max(v.props.h,b):b;Math.abs(v.props.h-S)<1||o({id:y,type:v.type,props:{h:S}},x?.preview?void 0:{history:"coalesce"})},[r,o]),u=hE((y,b)=>{let x=r.current.find(v=>v.id===y);!x||!Bd(x)||pri(x.props.blocks,b)||o({id:y,type:x.type,props:{blocks:b}},{commit:!0})},[r,o]),d=hE((y,b,x)=>{let v=x?.source==="crop"&&x.resizeToCrop?x.cropBox:void 0,S=v?r.current.find(w=>w.id===y&&w.type===lF):null,F=S&&v?sXn(S,v):{};i(y,b,F,{preserveGraphOwnedLabelPositions:x?.source==="crop",commit:x?.source==="crop"})},[r,i]),p=hE((y,b)=>{a.current===b&&(a.current=null,wte(),y.commands.focus("start",{scrollIntoView:!1}))},[a]),f=hE((y,b)=>{e.current=y,t(b),n({type:"editTable",shapeId:b})},[e,t,n]),m=hE((y,b)=>{o({id:y,type:nE,props:{table:b}})},[o]),h=hE((y,b)=>{o({id:y,type:nE,...b.x===void 0?{}:{x:b.x},...b.y===void 0?{}:{y:b.y},props:{w:b.w,h:b.h,table:b.table}})},[o]),g=hE(()=>{n({type:"select"})},[n]);return{handleTableChange:m,handleTableEditorFocus:f,handleTableFirstCellReady:p,handleTableResize:h,handleTextMeasuredHeight:c,handleTextChange:u,handleTextEditorCancel:l,handleTextEditorFocus:s,handleGraphSpecChange:d,handleGraphCropEnd:g}}function pri(e,t){return JSON.stringify(e)===JSON.stringify(t)}var zZn=X(()=>{"use strict";"use client";Pn();Yx();m_();Oye()});import{useEffect as $j,useMemo as fri,useRef as qm,useState as BTt}from"react";function UZn({overlay:e,canvasWidth:t,canvasHeight:n,documentId:r,externalRevision:o,onChange:i}){let a=fri(()=>ir(e.overlaySnapshot),[e.overlaySnapshot]),[s,l]=BTt(a.shapes),[c,u]=BTt(a.assets),[d]=BTt(()=>BKn(ff)),p=qm(t),f=qm(n),m=qm(r);$j(()=>{m.current=r},[r]),$j(()=>{p.current=t},[t]),$j(()=>{f.current=n},[n]);let h=qm(void 0),g=qm(null),y=qm(null),b=qm(!1),x=qm(!1),v=qm(!1),S=qm(new WeakSet),F=qm(o),w=qm(null),C=qm(e.overlaySnapshot),A=qm(e.overlaySnapshot),T=qm(i),D=qm(s),k=qm(c),P=qm(a.extensions);$j(()=>{T.current=i},[i]);let I=qm(s);return $j(()=>{s!==I.current&&(D.current=s)},[s]),$j(()=>{let B=d(D.current,{width:t,height:n});B!==D.current&&(D.current=B,l(B))},[t,n,d,s]),$j(()=>{k.current=c},[c]),{shapes:s,setShapes:l,assets:c,setAssets:u,canvasWidthRef:p,canvasHeightRef:f,documentIdRef:m,saveTimeoutRef:h,pendingOverlayHistoryRef:g,pendingOverlaySaveHistoryGroupRef:y,imageCropDirtyRef:b,mountedRef:x,suppressNextSaveRef:v,explicitlySavedShapeStatesRef:S,externalRevisionRef:F,lastEmittedSnapshotRef:w,seenDocumentSnapshotRef:C,reconciledDocumentSnapshotRef:A,onChangeRef:T,shapesRef:D,assetsRef:k,extensionsRef:P}}var HZn=X(()=>{"use strict";"use client";Dt();tE();D_()});import{useCallback as LTt,useEffect as VZn}from"react";function XZn({shapesRef:e,selectedIdsRef:t,editingShapeId:n,updateShape:r,activeTextEditorRef:o,modeRef:i}){let a=LTt(c=>{let u=Rke(e.current,t.current,n);u&&r({id:u.id,type:u.type,props:{blocks:sZt(u.props.blocks,c,()=>rt("p"))}},{commit:!0})},[n,t,e,r]),s=LTt((c,u)=>{let d=Rke(e.current,t.current,n);d&&r({id:d.id,type:d.type,props:{blocks:ett(d.props.blocks,c,u)}},{commit:!0})},[n,t,e,r]),l=LTt(c=>{let u=Rke(e.current,t.current,n);!u||!Number.isFinite(c)||r({id:u.id,type:u.type,props:{fontSize:c,size:rK(c),blocks:ett(u.props.blocks,"fontSize",String(c))}},{commit:!0})},[n,t,e,r]);VZn(()=>{let c=u=>{let d=u instanceof CustomEvent?u.detail:null,p=typeof d?.tex=="string"?d.tex:"",f=d?.edit===!0;if(d?.target!=="overlay"||!p&&!f)return;let m=o.current;if(m?.isFocused){let g=`overlay_math_${Date.now()}`;m.chain().focus().insertMathInline({id:g,tex:p}).run(),f&&J0(g);return}let h=`overlay_math_${Date.now()}`;a({type:"mathInline",id:h,tex:p,display:"inline",semanticRole:"expression"}),f&&J0(h)};return window.addEventListener(GZn,c),()=>window.removeEventListener(GZn,c)},[o,a]),VZn(()=>{let c=u=>{let d=u instanceof CustomEvent?u.detail:null;if(d?.target!=="overlay"||!d?.command)return;let p=d.command,f=typeof d.value=="string"?d.value:void 0,m=o.current,h=i.current.id==="overlay.textEditing"||i.current.id==="overlay.tableEditing";if(h&&m&&!m.isDestroyed)if(p==="fontSize"&&f)m.chain().focus().setFontSize(Number(f)).run();else if(p==="bold")m.chain().focus().toggleBold().run();else if(p==="italic")m.chain().focus().toggleItalic().run();else if(p==="underline")m.chain().focus().toggleUnderline().run();else if(p==="boxed")m.chain().focus().toggleBoxedText().run();else if(p==="boxedPaddingY"&&f){let g=Number.parseFloat(f);Number.isFinite(g)&&g>=0&&m.chain().focus().setBoxedTextPaddingY(g).run()}else if(p==="boxedVariant"&&f){let g=pWn(f);g&&m.chain().focus().setBoxedTextVariant(g).run()}else if(p==="boxedRoundness"&&f){let g=Number.parseFloat(f);Number.isFinite(g)&&g>=0&&m.chain().focus().setBoxedTextRoundness(g).run()}else if(p==="color"&&f)m.chain().focus().setTextColor(f).run();else if(p==="backgroundColor"){let g=m.chain().focus();f?g.setTextBackgroundColor(f).run():g.unsetTextBackgroundColor().run()}else if(p==="fontFamily"){let g=m.chain().focus();f?g.setFontFamily(f).run():g.unsetFontFamily().run()}else if(p==="lineHeight"&&f){let g=gi(f);g&&m.chain().focus().updateAttributes("paragraph",{lineHeight:g}).run()}else p==="textAlign"&&f?m.chain().focus().updateAttributes("paragraph",{textAlign:f}).run():p==="blockStyle"&&f&&NR(m,{command:p,value:f},{selection:null,blockNodeType:"paragraph",allowBlockStyle:!0});else p!=="fontSize"&&p!=="blockStyle"&&s(p,f);!h&&p==="fontSize"&&f&&l(Number(f))};return window.addEventListener(jZn,c),()=>window.removeEventListener(jZn,c)},[o,s,i,l])}var GZn,jZn,WZn=X(()=>{"use strict";"use client";hA();jk();Dt();Pn();ai();XNe();GZn="sigma-studio:insert-inline-math",jZn="sigma-studio:format-text"});import{useMemo as MP}from"react";function qZn({selectedIds:e,preview:t,shapes:n,visibleOriginPickPreview:r,movingShapeIds:o,editingShapeId:i,graphFillPickShapeId:a,initialOriginPickShapeId:s,visiblePageRange:l,pageHeightPx:c,pageGapPx:u}){let d=MP(()=>new Set(e),[e]),p=MP(()=>t===null?n:n.map(S=>t.targetIds.has(S.id)?cte(S,t.style):S),[t,n]),f=MP(()=>ux(p).map(S=>{let F=S9(p,S);return F===void 0?S:{...S,opacity:F}}),[p]),m=MP(()=>new Set(ux(DB(n,"background")).map(S=>S.id)),[n]),h=r?.shapeId??null,g=MP(()=>{let S=new Set;for(let F of By(n,[...e],{includeGroups:!0}))S.add(F);for(let F of o??[])S.add(F);for(let F of[i,a,s,h])F&&S.add(F);return S},[i,a,s,o,h,e,n]),y=MP(()=>!l||c<=0?f:f.filter(S=>{if(g.has(S.id))return!0;let F=rrt(Zp(S),c,u);return F.end>=l.start&&F.start<=l.end}),[u,c,g,l,f]),b=MP(()=>{let S=n.filter(C=>C.type==="chartShape");if(S.length===0)return new Map;let F=new Map;for(let C of n)C.type==="tableShape"&&F.set(C.id,C.props.table);let w=new Map;for(let C of S){let A=C.type==="chartShape"?C.props.sourceTableShapeId:void 0,T=A?F.get(A):void 0;T&&w.set(C.id,T)}return w},[n]),x=MP(()=>y.filter(S=>m.has(S.id)&&i!==S.id),[m,i,y]),v=MP(()=>y.filter(S=>!m.has(S.id)||i===S.id),[m,i,y]);return{backgroundVisibleShapes:x,chartSourceTables:b,foregroundVisibleShapes:v,selectedIdSet:d}}var KZn=X(()=>{"use strict";"use client";Pn();Dn();Tc();dj()});function mri(e,t,n=3){let r=[new DOMPoint(t.x,t.y)];for(let o=0;o<8&&n>0;o+=1){let i=o*Math.PI/4;r.push(new DOMPoint(t.x+n*Math.cos(i),t.y+n*Math.sin(i)))}for(let o of e.querySelectorAll("path, line, polyline, polygon, circle, ellipse, rect, text")){if(o.closest("defs, clipPath, mask, marker, pattern"))continue;let i=getComputedStyle(o);if(i.display==="none"||i.visibility!=="visible")continue;let a=!1;for(let d=o;d&&d!==e;d=d.parentElement){let p=getComputedStyle(d);if(p.display==="none"||Number(p.opacity)===0){a=!0;break}}if(a)continue;if(o instanceof SVGTextElement){let d=o.getBoundingClientRect();if(t.x>=d.left&&t.x<=d.right&&t.y>=d.top&&t.y<=d.bottom)return!0;continue}if(!(o instanceof SVGGeometryElement))continue;let s=o.getScreenCTM();if(!s||s.a*s.d===s.b*s.c)continue;let l=s.inverse(),c=i.fill!=="none"&&i.fill!=="rgba(0, 0, 0, 0)"&&Number(i.fillOpacity)>0,u=i.stroke!=="none"&&i.stroke!=="rgba(0, 0, 0, 0)"&&Number(i.strokeOpacity)>0&&parseFloat(i.strokeWidth)>0;for(let d of r){let p=d.matrixTransform(l);if(c&&o.isPointInFill(p)||u&&o.isPointInStroke(p))return!0}}return!1}function Sbe(e,t,n){let r=e?.querySelector(`[data-overlay-shape-id="${CSS.escape(t)}"]`);return!r||mri(r,n)}var RTt=X(()=>{"use strict"});function YZn(e,t,n,r){let o;for(let i of e)if(!(!qv(i,t,n)||!r(i))){if(n<=0||qv(i,t,0))return i;o??=i}return o}var $Zn=X(()=>{"use strict";Pn()});var ZZn,JZn=X(()=>{"use strict";ZZn={lockedShapeIds:new Set}});function cze(e){let t=e.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;let n=t.getRangeAt(0).commonAncestorContainer,r=n instanceof Element?n:n.parentElement;return!!(r?.closest(".text-flow-editor")&&!r.closest(".overlay-canvas-bleed-surface"))?t.getRangeAt(0).cloneRange():null}var _Tt=X(()=>{"use strict"});function QZn(e){if(!e)return;let t=e.ownerDocument,n=t.activeElement;n instanceof HTMLElement&&n.classList.contains("ProseMirror")&&!n.closest(".overlay-canvas-bleed-surface")&&n.blur(),cze(t)||t.getSelection()?.removeAllRanges(),t.activeElement!==e&&e.focus({preventScroll:!0})}var eJn=X(()=>{"use strict";_Tt()});import{useEffect as hri,useLayoutEffect as tJn,useRef as OTt,useState as gri}from"react";import{createPortal as yri}from"react-dom";import{jsx as xri}from"react/jsx-runtime";function nJn({anchorRef:e,position:t,className:n,children:r}){let o=OTt(null),[i,a]=gri(null);bri(()=>{let c=e.current;a(c?.closest("[data-modal-backdrop]")??c?.ownerDocument.body??null)},[e]);let s=OTt(null),l=OTt(null);return tJn(()=>{let c=o.current,u=e.current;if(!c||!u)return;let d=u.ownerDocument.defaultView;if(!d)return;let p=()=>{let m=u.getBoundingClientRect(),h=u.offsetWidth>0?m.width/u.offsetWidth:1,g=s.current??{x:m.left+t.x*h,y:m.top+t.y*h};c.style.left=`${Math.max(8,Math.min(g.x,d.innerWidth-c.offsetWidth-8))}px`,c.style.top=`${Math.max(8,Math.min(g.y,d.innerHeight-c.offsetHeight-8))}px`};p();let f=new ResizeObserver(p);return f.observe(c),f.observe(u),d.addEventListener("scroll",p,!0),d.addEventListener("resize",p),d.addEventListener(vR,p),()=>{f.disconnect(),d.removeEventListener("scroll",p,!0),d.removeEventListener("resize",p),d.removeEventListener(vR,p)}},[e,i,t.x,t.y]),i?yri(xri("div",{ref:o,className:n,style:{position:"fixed",zIndex:190},"data-overlay-editor-ui":"true","data-non-modal-surface":"true",onPointerDown:c=>{if(c.stopPropagation(),c.button!==0||!(c.target instanceof Element)||!c.target.closest(".overlay-table-toolbar-grip"))return;c.preventDefault();let u=c.currentTarget.getBoundingClientRect();l.current={pointerId:c.pointerId,x:c.clientX,y:c.clientY,left:u.left,top:u.top},c.currentTarget.setPointerCapture(c.pointerId)},onPointerMove:c=>{let u=l.current;if(!u||u.pointerId!==c.pointerId)return;let d=c.currentTarget,p=d.ownerDocument.defaultView,f=Math.max(8,Math.min(u.left+c.clientX-u.x,p.innerWidth-d.offsetWidth-8)),m=Math.max(8,Math.min(u.top+c.clientY-u.y,p.innerHeight-d.offsetHeight-8));s.current={x:f,y:m},d.style.left=`${f}px`,d.style.top=`${m}px`,c.stopPropagation()},onPointerUp:c=>{l.current?.pointerId===c.pointerId&&(l.current=null,c.currentTarget.releasePointerCapture(c.pointerId),c.stopPropagation())},onLostPointerCapture:()=>{l.current=null},onPointerCancel:()=>{l.current=null},onClick:c=>c.stopPropagation(),onDoubleClick:c=>c.stopPropagation(),onContextMenu:c=>{c.preventDefault(),c.stopPropagation()},children:r}),i):null}var bri,rJn=X(()=>{"use strict";"use client";s8e();bri=typeof window<"u"?tJn:hri});function aJn(e,t){return!wbe(e,t.anchor.rowIndex,t.anchor.columnIndex)||!wbe(e,t.focus.rowIndex,t.focus.columnIndex)?null:NTt(t)}function NTt(e){return{startRow:Math.min(e.anchor.rowIndex,e.focus.rowIndex),endRow:Math.max(e.anchor.rowIndex,e.focus.rowIndex),startColumn:Math.min(e.anchor.columnIndex,e.focus.columnIndex),endColumn:Math.max(e.anchor.columnIndex,e.focus.columnIndex)}}function sJn(e){return{anchor:{rowIndex:e.startRow,columnIndex:e.startColumn},focus:{rowIndex:e.endRow,columnIndex:e.endColumn}}}function lJn(e,t){return t.rowIndex>=e.startRow&&t.rowIndex<=e.endRow&&t.columnIndex>=e.startColumn&&t.columnIndex<=e.endColumn}function zTt(e,t,n,r=1,o=1){let i=t+Math.max(1,r)-1,a=n+Math.max(1,o)-1;return t<=e.endRow&&i>=e.startRow&&n<=e.endColumn&&a>=e.startColumn}function cJn(e,t,n,r,o=1,i=1){return t==="rows"?n<=e.endRow&&n+Math.max(1,o)-1>=e.startRow:r<=e.endColumn&&r+Math.max(1,i)-1>=e.startColumn}function UTt(e,t){let n=sne(t.startRow,e.rows.length),r=sne(t.endRow,e.rows.length);return e.rows.slice(n,r+1).map(o=>o.id)}function HTt(e,t){let n=sne(t.startColumn,e.columns.length),r=sne(t.endColumn,e.columns.length);return e.columns.slice(n,r+1).map(o=>o.id)}function GTt(e,t){if(e.rows.length===0||e.columns.length===0)return null;let n={rowIndex:sne(t.startRow,e.rows.length),columnIndex:sne(t.startColumn,e.columns.length)};return{anchor:n,focus:n}}function uJn(e,t,n){for(let r of e?.querySelectorAll("[data-table-content-id]")??[]){let o=r.getBoundingClientRect();if(t>=o.left&&t<=o.right&&n>=o.top&&n<=o.bottom)return r.dataset.tableContentId??null}return null}function dJn(e,t,n,r,o,i,a){let s=e?.getBoundingClientRect();if(!s||s.width<=0||s.height<=0||r.length<2||o.length<2)return null;let l=r[r.length-1]||t,c=o[o.length-1]||n,u=s.width/Math.max(1,t),d=s.height/Math.max(1,n),p=Yo((i-s.left)/Math.max(.01,u),0,Math.max(0,l-.001)),f=Yo((a-s.top)/Math.max(.01,d),0,Math.max(0,c-.001));return{rowIndex:oJn(o,f),columnIndex:oJn(r,p)}}function oJn(e,t){for(let n=0;n<e.length-1;n+=1)if(t<e[n+1]||n===e.length-2)return n;return 0}function sne(e,t){return t<=0?0:Math.trunc(Yo(e,0,t-1))}function uze(e,t){return`${e}:${t}`}function pJn(e){return e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.isComposing?null:e.key==="ArrowLeft"?"left":e.key==="ArrowRight"?"right":e.key==="ArrowUp"?"up":e.key==="ArrowDown"?"down":null}function fJn(e,t){let{selection:n}=e.state;if(!n.empty)return!1;if(t==="left"){let r=iJn(e,"left");return r!==null?r:n.$from.parentOffset<=0}if(t==="right"){let r=iJn(e,"right");return r!==null?r:n.$to.parentOffset>=n.$to.parent.content.size}return vri(e,t)}function iJn(e,t){let n=e.dom.ownerDocument.getSelection();if(!n||!n.isCollapsed||!n.anchorNode||!e.dom.contains(n.anchorNode))return null;let{anchorNode:r,anchorOffset:o}=n;if(e.posAtDOM)try{let i=e.posAtDOM(r,o),a=1,s=Math.max(a,e.state.doc.content.size-1);return t==="left"?i<=a:i>=s}catch{}if(r.nodeType===Node.TEXT_NODE){let i=r.textContent?.length??0;return t==="left"?o<=0:o>=i}return t==="left"?o<=0:o>=r.childNodes.length}function vri(e,t){let{selection:n}=e.state;try{let r=e.coordsAtPos(n.from),o=e.dom.getBoundingClientRect(),i=Math.max(1,r.bottom-r.top),a=Math.max(4,i*.45);return t==="up"?r.top<=o.top+a:r.bottom>=o.bottom-a}catch{let r=Math.max(1,e.state.doc.content.size-1);return t==="up"?n.from<=1:n.to>=r}}function jTt(e,t,n){return n==="left"?{rowIndex:e,columnIndex:t-1}:n==="right"?{rowIndex:e,columnIndex:t+1}:n==="up"?{rowIndex:e-1,columnIndex:t}:{rowIndex:e+1,columnIndex:t}}function VTt(e){return e==="left"||e==="up"?"end":"start"}function XTt(e,t){let n=t==="end"?Math.max(1,e.state.doc.content.size-1):1;e.chain().focus().setTextSelection(n).run()}function wbe(e,t,n){return t>=0&&t<e.rows.length&&n>=0&&n<e.columns.length}function dze(e,t,n){return wbe(e,t,n)?e.cells.find(r=>{let o=e.rows.findIndex(l=>l.id===r.rowId),i=e.columns.findIndex(l=>l.id===r.columnId);if(o<0||i<0)return!1;let a=r.rowSpan??1,s=r.colSpan??1;return t>=o&&t<o+a&&n>=i&&n<i+s})??null:null}function Fbe(e){return e.content.find(t=>t.type==="paragraph")??null}function WTt(e,t){return Kg(e)===Kg(t)}function qTt(e,t,n){if(t.axis==="vertical"){if("edge"in t)return t.edge==="left"?n("table.line.edgeLeft"):n("table.line.edgeRight");let o=e.columns.findIndex(i=>i.id===t.beforeColumnId);return o>0?n("table.line.betweenColumns",{first:o,second:o+1}):n("table.line.vertical")}if("edge"in t)return t.edge==="top"?n("table.line.edgeTop"):n("table.line.edgeBottom");let r=e.rows.findIndex(o=>o.id===t.beforeRowId);return r>0?n("table.line.betweenRows",{first:r,second:r+1}):n("table.line.horizontal")}function mJn(e){return[...Array.from({length:e.columns.length+1},(t,n)=>lx(e,n)).filter(t=>!!t),...Array.from({length:e.rows.length+1},(t,n)=>cx(e,n)).filter(t=>!!t)]}function hJn(e){return[lx(e,0),lx(e,e.columns.length),cx(e,0),cx(e,e.rows.length)].filter(t=>!!t)}function gJn(e){return[...Array.from({length:Math.max(0,e.columns.length-1)},(t,n)=>lx(e,n+1)).filter(t=>!!t),...Array.from({length:Math.max(0,e.rows.length-1)},(t,n)=>cx(e,n+1)).filter(t=>!!t)]}function pze(e,t,n){let r=e.rows.findIndex(i=>i.id===t.rowId),o=e.columns.findIndex(i=>i.id===t.columnId);return r<0||o<0?!1:zTt(n,r,o,t.rowSpan??1,t.colSpan??1)}function Cbe(e,t){return Array.from({length:Math.max(0,t-e+1)},(n,r)=>e+r)}function KTt(e){return{mode:"fixed",value:Math.max(1,e)}}function YTt(e,t){return e.mode==="fixed"?e.value:(e.mode==="auto",e.min??t)}function $Tt(e){return Math.max(0,e)*Id}function ZTt(e){return e/Id}function JTt(e){return Number.isFinite(e)?String(Math.round(e*10)/10):""}function QTt(e){return Math.max(1,e.reduce((t,n)=>t+Math.max(1,n),0))}function Abe(e){if(e.length===0)return null;let t=e[0];return e.every(n=>n===t)?t:null}function fze(e){let t=e.filter(n=>Number.isFinite(n)).map(n=>Math.round(n*10)/10);return Abe(t)}function eDt(e,t,n){return{...e,cells:e.cells.map(r=>pze(e,r,t)?{...r,style:{...r.style??{},...n},content:n.align===void 0?r.content:r.content.map(o=>o.type==="paragraph"?{...o,align:n.align}:o)}:r)}}function yJn({mode:e,cellRange:t,line:n,table:r,columnOffsets:o,rowOffsets:i,shapeWidth:a,shapeHeight:s}){if(e==="cell"&&t){let l=o[t.startColumn]??0,c=i[t.startRow]??0,u=(i[t.endRow+1]??c)+8;return{x:Yo(l,-8,Math.max(0,a-48)),y:Yo(c-44<-50?u:c-44,-50,Math.max(0,s-28))}}if(e==="line"&&n){let l=Sri(r,n,o,i);return{x:Yo(l.x,-8,Math.max(0,a-48)),y:Yo(l.y,-50,Math.max(0,s-28))}}return{x:0,y:-44}}function Sri(e,t,n,r){if(t.axis==="vertical"){let i="edge"in t?t.edge==="left"?0:e.columns.length:e.columns.findIndex(a=>a.id===t.beforeColumnId);return{x:n[i]??0,y:-44}}let o="edge"in t?t.edge==="top"?0:e.rows.length:e.rows.findIndex(i=>i.id===t.beforeRowId);return{x:8,y:(r[o]??0)-44}}var tDt=X(()=>{"use strict";Dt();jh();m_();Dn();Dn()});import{useEffect as mze,useMemo as wri,useRef as Fri}from"react";import{jsx as BP}from"react/jsx-runtime";function bJn({shapeId:e,cell:t,cellId:n,content:r,editing:o,showFormulaSource:i,table:a,rowIndex:s,columnIndex:l,colSpan:c,onFocus:u,onChange:d,onNavigate:p,onRegisterEditor:f}){return r.type==="trend"?BP(f8e,{colSpan:c,content:r}):!o||!i&&D5(a,t,r)!==null?BP(Cri,{cell:t,content:r,table:a}):BP(Ari,{shapeId:e,cellId:n,content:r,editing:o,rowIndex:s,columnIndex:l,onFocus:u,onChange:d,onNavigate:p,onRegisterEditor:f})}function Cri({cell:e,content:t,table:n}){return BP("div",{className:"overlay-table-paragraph","data-table-content-id":t.id,style:{pointerEvents:"none"},children:BP("div",{className:"overlay-table-shape-content ProseMirror",children:BP("p",{style:cDe(t),children:Tri(m9(n,e,t))})})})}function Ari({shapeId:e,cellId:t,content:n,editing:r,rowIndex:o,columnIndex:i,onFocus:a,onChange:s,onNavigate:l,onRegisterEditor:c}){let u=wri(()=>v2(n.children,n.align,n.lineHeight),[n.align,n.children,n.lineHeight]),d=Fri(u),p=ww({extensions:Vk({drawBoxedRunFrames:!1,enableMathDelimiters:!0,heading:!1,placeholder:"",textBlockStyle:!0}),content:u,editable:r,immediatelyRender:!1,editorProps:{attributes:{class:"overlay-table-shape-content"},handlePaste:(m,h,g)=>$8(m,h,g)},onFocus:({editor:m})=>{a(m,e,t),$w(m,"sigma-studio:text-format-state","overlay",void 0,{state:m.state,view:m.view,documentFontFamily:nx})},onTransaction:({editor:m})=>{m.isFocused&&$w(m,"sigma-studio:text-format-state","overlay",void 0,{state:m.state,view:m.view,documentFontFamily:nx})},onUpdate:({editor:m})=>{let h=m.getJSON();d.current=h,s(t,n.id,{...n,align:m.getAttributes("paragraph").textAlign??n.align,lineHeight:gi(m.getAttributes("paragraph").lineHeight)??n.lineHeight,children:V8(h)})}});mze(()=>{p?.setEditable(r)},[r,p]),mze(()=>{if(p)return c(t,n.id,p)},[t,n.id,p,c]),mze(()=>{if(!p||p.isDestroyed)return;let m=n.align??null,h=gi(n.lineHeight)??null,g=p.getAttributes("paragraph");if(g.textAlign===m&&g.lineHeight===h)return;let y=p.state.tr;p.state.doc.forEach((b,x)=>{b.type.name==="paragraph"&&y.setNodeMarkup(x,void 0,{...b.attrs,textAlign:m,lineHeight:h})}),p.view.dispatch(y.setMeta("preventUpdate",!0).setMeta("addToHistory",!1)),d.current=p.getJSON()},[n.align,n.lineHeight,p]),mze(()=>{if(!p||p.isFocused)return;let m=v2(n.children,n.align,n.lineHeight),h=JSON.stringify(d.current),g=JSON.stringify(m);if(h!==g){d.current=m;let y=window.setTimeout(()=>{!p.isDestroyed&&!p.isFocused&&p.commands.setContent(m,{emitUpdate:!1})},0);return()=>window.clearTimeout(y)}},[n.align,n.children,n.lineHeight,p]);let f=m=>{if(!p)return;let h=pJn(m.nativeEvent);!h||!fJn(p.view,h)||l(o,i,h)&&(m.preventDefault(),m.stopPropagation())};return BP("div",{className:"overlay-table-paragraph","data-table-content-id":n.id,style:{pointerEvents:r?"auto":"none"},onKeyDownCapture:f,onPointerDown:m=>{r&&m.stopPropagation()},children:BP(o2,{editor:p})})}function Tri(e){return BP(wJ,{nodes:e,keyPrefix:"sigma-inline-preview"})}var xJn=X(()=>{"use strict";"use client";rU();Ys();TH();ree();jk();Dt();Dn();H0();tDt()});import{jsx as vJn,jsxs as Dri}from"react/jsx-runtime";function SJn({table:e,columnOffsets:t,rowOffsets:n}){return Dri("div",{className:"overlay-table-rendered-lines","aria-hidden":"true",children:[Hle(e,t,n).map(r=>vJn("div",{className:`overlay-table-rendered-line ${r.axis}`,style:r.style},`rendered-${r.axis}-${r.domKey}`)),Gle(e,t,n).map(r=>vJn("div",{className:`overlay-table-line-connector ${r.axis}`,style:r.style},r.id))]})}var wJn=X(()=>{"use strict";Dn()});import{useCallback as lne,useEffect as Tbe,useMemo as Dbe,useRef as O_,useState as PA}from"react";import{createPortal as kri}from"react-dom";import{Fragment as hze,jsx as ba,jsxs as MA}from"react/jsx-runtime";function Iri(e,t){if(!t)return null;let n=Fbe(t);return n?D5(e,t,n)?.error??null:null}function Mri(e){return[{value:"none",label:e("format.lineDash.none"),hidden:!0},{value:"solid",label:e("format.lineDash.solid")},{value:"dashed",label:e("format.lineDash.dashed"),dasharray:"8 5"},{value:"dotted",label:e("format.lineDash.dotted"),dasharray:"1 5"},{value:"double",label:e("format.lineDash.double"),double:!0}]}function Bri(e){return[{value:"left",label:e("format.align.left"),icon:E0},{value:"center",label:e("format.align.center"),icon:wx},{value:"right",label:e("format.align.right"),icon:Fx}]}function Lri(e){if(e===null)return null;let t="m",n=Number.POSITIVE_INFINITY;for(let r of fNe){let o=Math.abs(FJn[r.value]-e);o<n&&(n=o,t=r.value)}return t}function kbe({shape:e,editing:t,onFocus:n,onChange:r,onResize:o,onCreateChart:i,onFirstCellReady:a}){let s=We("chrome"),l=We("settings"),c=We("shape"),u=e.props.table,d=O_(null),p=Math.max(1,e.props.w),f=Dbe(()=>aDe(u,p),[p,u]),m=Dbe(()=>sDe(u,e.props.h),[e.props.h,u]),h=Dbe(()=>MK(f),[f]),g=Dbe(()=>MK(m),[m]),[y,b]=PA(null),[x,v]=PA([]),[S,F]=PA(null),[w,C]=PA(null),[A,T]=PA(null),[D,k]=PA(null),[P,I]=PA(!1),[B,M]=PA(!1),[L,_]=PA(!1),R=O_(null),O=O_(null),N=O_(null),[z,U]=PA(()=>new Set),H=O_(new Map),V=O_(new Map),[ne,Z]=PA(null),ee=O_(null),J=Dbe(()=>t?x.filter(mt=>lDe(u,mt)):[],[t,x,u]),te=J[0]??null,K=t&&S?aJn(u,S):null,G=J.length>0?"line":K?"cell":null,ie=J.map(mt=>Vv(u,mt)),{origins:fe}=A5(u),$=O_(t);Tbe(()=>{let mt=t&&!$.current;$.current=t,!(!mt||u.rows.length===0||u.columns.length===0)&&(Z(null),ee.current=null,F({anchor:{rowIndex:0,columnIndex:0},focus:{rowIndex:u.rows.length-1,columnIndex:u.columns.length-1}}))},[t,u.columns.length,u.rows.length]);let j=dze(u,0,0),pe=j?Fbe(j):null,re=lne((mt,_t,Gt)=>{let cn=uze(mt,_t);V.current.set(cn,Gt),mt===j?.id&&_t===pe?.id&&a?.(Gt,e.id);let an=ee.current;if(an&&an.cellId===mt&&an.contentId===_t&&(ee.current=null,XTt(Gt,an.placement),an.clientPoint&&!Gt.isDestroyed)){let xr=Gt.view.posAtCoords(an.clientPoint);xr&&Gt.commands.setTextSelection(xr.pos)}return()=>{V.current.get(cn)===Gt&&V.current.delete(cn)}},[j?.id,pe?.id,a,e.id]),le=lne((mt,_t,Gt)=>{let cn=jTt(mt,_t,Gt);for(;wbe(u,cn.rowIndex,cn.columnIndex);){let an=dze(u,cn.rowIndex,cn.columnIndex),xr=an?Fbe(an):null,xt=an&&xr?V.current.get(uze(an.id,xr.id)):null;if(xt&&!xt.isDestroyed)return Z(an?.id??null),XTt(xt,VTt(Gt)),!0;if(an&&xr)return ee.current={cellId:an.id,contentId:xr.id,placement:VTt(Gt)},Z(an.id),!0;cn=jTt(cn.rowIndex,cn.columnIndex,Gt)}return!1},[u]),Q=(mt,_t,Gt)=>{r(e.id,{...u,cells:u.cells.map(cn=>cn.id!==mt?cn:{...cn,content:cn.content.map(an=>an.id===_t?Gt:an)})})},se=(mt,_t)=>{F(null),xe(),v(Gt=>{if(!_t)return[mt];let cn=Kg(mt);return Gt.some(an=>Kg(an)===cn)?Gt.filter(an=>Kg(an)!==cn):[...Gt,mt]})},De=mt=>{if(J.length===0)return;let _t=J.reduce((Gt,cn)=>dXn(Gt,cn,mt),u);r(e.id,_t)},Ae=mt=>{if(!K)return;let _t=$Tt(mt),Gt=new Set(Cbe(K.startColumn,K.endColumn)),cn=u.columns.map((xt,Kn)=>Gt.has(Kn)?{...xt,width:KTt(_t)}:xt),an={...u,columns:cn},xr=cn.map((xt,Kn)=>YTt(xt.width,f[Kn]??kye));o(e.id,{w:QTt(xr),h:e.props.h,table:an})},ye=mt=>{if(!K)return;let _t=$Tt(mt),Gt=new Set(Cbe(K.startRow,K.endRow)),cn=u.rows.map((xt,Kn)=>Gt.has(Kn)?{...xt,height:KTt(_t)}:xt),an={...u,rows:cn},xr=cn.map((xt,Kn)=>YTt(xt.height,m[Kn]??Eye));o(e.id,{w:e.props.w,h:QTt(xr),table:an})},$e=mt=>{K&&r(e.id,eDt(u,K,{align:mt}))},Pe=mt=>{!K||!Number.isFinite(mt)||mt<=0||r(e.id,eDt(u,K,{fontSize:mt}))},Ne=mt=>{if(!A)return;let _t=mt==="left"?A.range.startColumn:A.range.endColumn+1;r(e.id,TCt(u,_t)),xe()},we=mt=>{if(!A)return;let _t=mt==="above"?A.range.startRow:A.range.endRow+1;r(e.id,DCt(u,_t)),xe()},Ie=mt=>{let _t=mt==="all"?mJn(u):mt==="outer"?hJn(u):gJn(u);F(null),v(_t),xe()},Ce=(mt,_t,Gt)=>{v([]),Z(Gt),n(mt,_t)},xe=()=>{T(null),k(null)},Y=(mt,_t,Gt)=>{if(!t||mt.button!==0)return;let cn={rowIndex:_t,columnIndex:Gt},an=dze(u,_t,Gt),xr=uJn(mt.currentTarget,mt.clientX,mt.clientY),xt=an?.content.find(to=>to.id===xr),Kn=xt?.type==="paragraph"?xt:an?Fbe(an):null;Z(an?.id??null);let Zn=an&&Kn?V.current.get(uze(an.id,Kn.id)):null;an&&Kn&&(!Zn||Zn.isDestroyed)&&(ee.current={cellId:an.id,contentId:Kn.id,placement:"end",...D5(u,an,Kn)?{}:{clientPoint:{left:mt.clientX,top:mt.clientY}}}),v([]),xe(),F({anchor:cn,focus:cn}),C({anchor:cn,startClientX:mt.clientX,startClientY:mt.clientY,active:!1})},oe=(mt,_t,Gt)=>{if(!t)return;mt.preventDefault(),mt.stopPropagation();let cn={rowIndex:_t,columnIndex:Gt},an=K&&lJn(K,cn)?K:NTt({anchor:cn,focus:cn});v([]),F(sJn(an)),T({x:Yo(mt.clientX,8,Math.max(8,window.innerWidth-188)),y:Yo(mt.clientY,8,Math.max(8,window.innerHeight-104)),range:an}),k(null)},de=()=>{if(!A)return;let mt=UTt(u,A.range);if(mt.length===0||mt.length>=u.rows.length)return;let _t=yXn(u,mt);r(e.id,_t),F(GTt(_t,A.range)),xe()},Le=()=>{if(!A)return;let mt=HTt(u,A.range);if(mt.length===0||mt.length>=u.columns.length)return;let _t=gXn(u,mt);r(e.id,_t),F(GTt(_t,A.range)),xe()},be=lne(()=>{let mt=d.current?.getBoundingClientRect();return!mt||mt.width<=0?1:mt.width/p},[p]),Be=(mt,_t)=>{mt.preventDefault(),mt.stopPropagation(),b({type:"columnBoundary",boundaryIndex:_t,startClientX:mt.clientX,leftWidth:f[_t],rightWidth:f[_t+1]})},ce=(mt,_t)=>{let Gt=_t==="left"?0:u.columns.length-1;Gt<0||(mt.preventDefault(),mt.stopPropagation(),b({type:"columnEdge",edge:_t,startClientX:mt.clientX,startShapeX:e.x,startShapeW:e.props.w,edgeWidth:f[Gt]??pj}))},Re=(mt,_t)=>{mt.preventDefault(),mt.stopPropagation(),b({type:"rowBoundary",boundaryIndex:_t,startClientY:mt.clientY,topHeight:m[_t],bottomHeight:m[_t+1]})},Qe=(mt,_t)=>{let Gt=_t==="top"?0:u.rows.length-1;Gt<0||(mt.preventDefault(),mt.stopPropagation(),b({type:"rowEdge",edge:_t,startClientY:mt.clientY,startShapeY:e.y,startShapeH:e.props.h,edgeHeight:m[Gt]??fj}))},W=lne(mt=>{if(mt===void 0){for(let Gt of H.current.values())window.clearTimeout(Gt);H.current.clear();return}let _t=H.current.get(mt);_t!==void 0&&(window.clearTimeout(_t),H.current.delete(mt))},[]),ve=lne(mt=>{W(mt),U(_t=>{if(_t.has(mt))return _t;let Gt=new Set(_t);return Gt.add(mt),Gt})},[W]),_e=lne(mt=>{W(mt);let _t=window.setTimeout(()=>{H.current.delete(mt),U(Gt=>{if(!Gt.has(mt))return Gt;let cn=new Set(Gt);return cn.delete(mt),cn})},Pri);H.current.set(mt,_t)},[W]);Tbe(()=>W,[W]),Tbe(()=>{if(!w)return;let mt=Gt=>{let cn=dJn(d.current,p,e.props.h,h,g,Gt.clientX,Gt.clientY);!cn||!(w.active||Math.hypot(Gt.clientX-w.startClientX,Gt.clientY-w.startClientY)>=3)||(Gt.preventDefault(),d.current?.ownerDocument.getSelection()?.removeAllRanges(),w.active||(C({...w,active:!0}),Z(null),ee.current=null),F(xr=>xr&&xr.anchor.rowIndex===w.anchor.rowIndex&&xr.anchor.columnIndex===w.anchor.columnIndex&&xr.focus.rowIndex===cn.rowIndex&&xr.focus.columnIndex===cn.columnIndex?xr:{anchor:w.anchor,focus:cn}))},_t=()=>{C(null)};return window.addEventListener("pointermove",mt),window.addEventListener("pointerup",_t,{once:!0}),()=>{window.removeEventListener("pointermove",mt),window.removeEventListener("pointerup",_t)}},[w,h,g,e.props.h,p]),Tbe(()=>{if(!A)return;let mt=Gt=>{(Gt.target instanceof Element?Gt.target:null)?.closest(".overlay-table-context-menu")||(T(null),k(null))},_t=Gt=>{Gt.key==="Escape"&&(Gt.preventDefault(),T(null),k(null))};return window.addEventListener("pointerdown",mt,!0),window.addEventListener("keydown",_t),()=>{window.removeEventListener("pointerdown",mt,!0),window.removeEventListener("keydown",_t)}},[A]),Tbe(()=>{if(!y)return;let mt=Gt=>{let cn=Math.max(.01,be());if(y.type==="columnBoundary"){let Zn=(Gt.clientX-y.startClientX)/cn,to=Yo(Zn,pj-y.leftWidth,y.rightWidth-pj);r(e.id,pXn(u,y.boundaryIndex,y.leftWidth+to,y.rightWidth-to));return}if(y.type==="columnEdge"){let Zn=y.edge==="left"?(y.startClientX-Gt.clientX)/cn:(Gt.clientX-y.startClientX)/cn,to=Math.max(pj-y.edgeWidth,Zn),Qa=y.edgeWidth+to,ma=Math.max(pj,y.startShapeW+to);o(e.id,{x:y.edge==="left"?y.startShapeX-to:void 0,w:ma,h:e.props.h,table:fXn(u,y.edge,Qa)});return}if(y.type==="rowBoundary"){let Zn=(Gt.clientY-y.startClientY)/cn,to=Yo(Zn,fj-y.topHeight,y.bottomHeight-fj);r(e.id,mXn(u,y.boundaryIndex,y.topHeight+to,y.bottomHeight-to));return}let an=y.edge==="top"?(y.startClientY-Gt.clientY)/cn:(Gt.clientY-y.startClientY)/cn,xr=Math.max(fj-y.edgeHeight,an),xt=y.edgeHeight+xr,Kn=Math.max(fj,y.startShapeH+xr);o(e.id,{y:y.edge==="top"?y.startShapeY-xr:void 0,w:e.props.w,h:Kn,table:hXn(u,y.edge,xt)})},_t=()=>{b(null)};return window.addEventListener("pointermove",mt),window.addEventListener("pointerup",_t,{once:!0}),()=>{window.removeEventListener("pointermove",mt),window.removeEventListener("pointerup",_t)}},[be,r,o,y,e.id,e.props.h,e.props.w,u]);let he=t?A:null,Oe=t?D:null,qe=he?UTt(u,he.range):[],Ze=he?HTt(u,he.range):[],vt=qe.length>0&&qe.length<u.rows.length,Ft=Ze.length>0&&Ze.length<u.columns.length,gt=Abe(ie.map(mt=>mt.visible?mt.borderStyle:"none")),bt=Abe(ie.map(mt=>mt.borderWidth)),ct=Lri(bt),ft=K?Cbe(K.startColumn,K.endColumn):[],hn=K?Cbe(K.startRow,K.endRow):[],Kt=fze(ft.map(mt=>ZTt(f[mt]??0))),xo=fze(hn.map(mt=>ZTt(m[mt]??0))),Bo=K,fo=Bo?Abe(u.cells.filter(mt=>pze(u,mt,Bo)).flatMap(mt=>{let _t=mt.style?.align??u.defaultCellStyle.align??"center",Gt=mt.content.filter(cn=>cn.type==="paragraph");return Gt.length>0?Gt.map(cn=>cn.align??_t):[_t]})):null,Sr=Bo?fze(u.cells.filter(mt=>pze(u,mt,Bo)).map(mt=>mt.style?.fontSize??u.defaultCellStyle.fontSize??15)):null,oa=G?yJn({mode:G,cellRange:K,line:te,table:u,columnOffsets:h,rowOffsets:g,shapeWidth:e.props.w,shapeHeight:e.props.h}):null;return MA("div",{className:`overlay-table-shape ${t?"editing":""}`,style:{width:e.props.w,height:e.props.h},onContextMenu:mt=>{if(!t)return;let _t=mt.target instanceof Element?mt.target:null;if(_t?.closest(".overlay-table-context-menu, .overlay-table-floating-toolbar"))return;let Gt=!!(K&&K.startRow===0&&K.endRow===u.rows.length-1&&K.startColumn===0&&K.endColumn===u.columns.length-1);_t?.closest("td")&&!Gt||(mt.preventDefault(),mt.stopPropagation(),T({x:Yo(mt.clientX,8,Math.max(8,window.innerWidth-220)),y:Yo(mt.clientY,8,Math.max(8,window.innerHeight-220)),range:{startRow:0,endRow:Math.max(0,u.rows.length-1),startColumn:0,endColumn:Math.max(0,u.columns.length-1)}}))},children:[t&&MA(hze,{children:[oa&&MA(nJn,{className:`overlay-table-floating-toolbar ${G}`,anchorRef:d,position:oa,children:[ba("button",{type:"button",className:"overlay-table-toolbar-grip","aria-label":c("table.moveMenu"),title:c("table.moveMenu"),children:ba(n4,{size:14})}),G==="line"?MA(hze,{children:[ba(aF,{buttonRef:R,options:Mri(s),currentValue:gt,open:P,onToggle:()=>{M(!1),I(mt=>!mt)},onSelect:mt=>{if(mt==="none"){De({visible:!1}),I(!1);return}De({borderStyle:mt,visible:!0,...mt==="double"&&(bt??0)<3?{borderWidth:3}:{}}),I(!1)}}),ba(eE,{buttonRef:O,currentValue:ct,open:B,onToggle:()=>{I(!1),M(mt=>!mt)},onSelect:mt=>{De({borderWidth:FJn[mt],visible:!0}),M(!1)}})]}):MA(hze,{children:[MA("label",{className:"overlay-table-toolbar-number",children:[ba(gue,{size:14,"aria-label":c("table.columnWidth")}),ba("input",{type:"number",min:"0",step:"1",placeholder:c("table.mixed"),value:Kt===null?"":JTt(Kt),onChange:mt=>{let _t=Number.parseFloat(mt.target.value);Number.isFinite(_t)&&Ae(_t)}}),ba("span",{children:"mm"})]}),MA("label",{className:"overlay-table-toolbar-number",children:[ba(yue,{size:14,"aria-label":c("table.rowHeight")}),ba("input",{type:"number",min:"0",step:"1",placeholder:c("table.mixed"),value:xo===null?"":JTt(xo),onChange:mt=>{let _t=Number.parseFloat(mt.target.value);Number.isFinite(_t)&&ye(_t)}}),ba("span",{children:"mm"})]}),MA("label",{className:"overlay-table-toolbar-number",children:[ba(I0,{size:14,"aria-label":c("table.fontSize")}),ba("input",{type:"number",min:"1",step:"0.5","aria-label":c("table.fontSizeAria"),placeholder:c("table.mixed"),value:Sr===null?"":Sr,onChange:mt=>{let _t=Number.parseFloat(mt.target.value);Number.isFinite(_t)&&Pe(_t)}}),ba("span",{children:"pt"})]}),ba(AVn,{buttonRef:N,options:Bri(s),currentValue:fo,open:L,onToggle:()=>_(mt=>!mt),onSelect:mt=>{$e(mt),_(!1)}})]})]}),ba("div",{className:"overlay-table-column-controls","aria-hidden":!1,children:h.map((mt,_t)=>{let Gt=lx(u,_t);if(!Gt)return null;let cn=Kg(Gt),an=_t>0&&_t<u.columns.length,xr=_t===0?"left":_t===u.columns.length?"right":null,xt=J.some(Zn=>WTt(Zn,Gt)),Kn=z.has(cn);return ba("div",{role:"button",tabIndex:0,className:["overlay-table-boundary-hotspot","column","resizable",xt?"selected":"",Kn?"add-visible":""].filter(Boolean).join(" "),style:{left:mt},"aria-label":qTt(u,Gt,l),"data-testid":"overlay-table-column-boundary",onPointerEnter:()=>ve(cn),onPointerLeave:()=>_e(cn),onPointerDown:Zn=>{if(Zn.button===0){if(Zn.stopPropagation(),se(Gt,Zn.shiftKey),Zn.shiftKey){Zn.preventDefault();return}if(an){Be(Zn,_t-1);return}xr&&ce(Zn,xr)}},onKeyDown:Zn=>{(Zn.key==="Enter"||Zn.key===" ")&&(Zn.preventDefault(),se(Gt,Zn.shiftKey))},children:ba("button",{type:"button",className:"overlay-table-add-control column","aria-label":c("table.addColumnAt",{index:_t+1}),onPointerDown:Zn=>Zn.stopPropagation(),onClick:Zn=>{Zn.stopPropagation(),r(e.id,TCt(u,_t))},children:ba(zi,{size:11,strokeWidth:2.4})})},`column-boundary-${cn}`)})}),ba("div",{className:"overlay-table-row-controls","aria-hidden":!1,children:g.map((mt,_t)=>{let Gt=cx(u,_t);if(!Gt)return null;let cn=Kg(Gt),an=_t>0&&_t<u.rows.length,xr=_t===0?"top":_t===u.rows.length?"bottom":null,xt=J.some(Zn=>WTt(Zn,Gt)),Kn=z.has(cn);return ba("div",{role:"button",tabIndex:0,className:["overlay-table-boundary-hotspot","row","resizable",xt?"selected":"",Kn?"add-visible":""].filter(Boolean).join(" "),style:{top:mt},"aria-label":qTt(u,Gt,l),"data-testid":"overlay-table-row-boundary",onPointerEnter:()=>ve(cn),onPointerLeave:()=>_e(cn),onPointerDown:Zn=>{if(Zn.button===0){if(Zn.stopPropagation(),se(Gt,Zn.shiftKey),Zn.shiftKey){Zn.preventDefault();return}if(an){Re(Zn,_t-1);return}xr&&Qe(Zn,xr)}},onKeyDown:Zn=>{(Zn.key==="Enter"||Zn.key===" ")&&(Zn.preventDefault(),se(Gt,Zn.shiftKey))},children:ba("button",{type:"button",className:"overlay-table-add-control row","aria-label":c("table.addRowAt",{index:_t+1}),onPointerDown:Zn=>Zn.stopPropagation(),onClick:Zn=>{Zn.stopPropagation(),r(e.id,DCt(u,_t))},children:ba(zi,{size:11,strokeWidth:2.4})})},`row-boundary-${cn}`)})})]}),he&&typeof document<"u"&&kri(MA("div",{className:"overlay-table-context-menu",role:"menu",style:{left:he.x,top:he.y},onPointerDown:mt=>mt.stopPropagation(),onContextMenu:mt=>mt.preventDefault(),children:[ba("button",{type:"button",role:"menuitem",onClick:()=>Ne("left"),children:c("table.addColumnLeft")}),ba("button",{type:"button",role:"menuitem",onClick:()=>Ne("right"),children:c("table.addColumnRight")}),ba("button",{type:"button",role:"menuitem",onClick:()=>we("above"),children:c("table.addRowAbove")}),ba("button",{type:"button",role:"menuitem",onClick:()=>we("below"),children:c("table.addRowBelow")}),ba("button",{type:"button",role:"menuitem",className:"danger",disabled:!vt,onPointerEnter:()=>k("rows"),onPointerLeave:()=>k(null),onFocus:()=>k("rows"),onBlur:()=>k(null),onClick:de,children:c("table.deleteRows")}),ba("button",{type:"button",role:"menuitem",className:"danger",disabled:!Ft,onPointerEnter:()=>k("columns"),onPointerLeave:()=>k(null),onFocus:()=>k("columns"),onBlur:()=>k(null),onClick:Le,children:c("table.deleteColumns")}),i&&MA(hze,{children:[ba("div",{className:"overlay-table-context-menu-separator",role:"separator"}),ba("button",{type:"button",role:"menuitem",onClick:()=>{T(null),i(e.id)},children:c("table.createChart")})]}),ba("div",{className:"overlay-table-context-menu-separator",role:"separator"}),ba("button",{type:"button",role:"menuitem",onClick:()=>Ie("all"),children:c("table.selectAllLines")}),ba("button",{type:"button",role:"menuitem",onClick:()=>Ie("outer"),children:c("table.selectOuterLines")}),ba("button",{type:"button",role:"menuitem",onClick:()=>Ie("inner"),children:c("table.selectInnerLines")})]}),document.body),MA("table",{ref:d,className:"overlay-table-shape-table",style:{width:p,height:e.props.h,tableLayout:"fixed",border:0},children:[ba("colgroup",{children:u.columns.map((mt,_t)=>ba("col",{style:{width:f[_t]}},mt.id))}),ba("tbody",{children:u.rows.map((mt,_t)=>ba("tr",{style:{height:m[_t]},children:fe[_t].map(({cell:Gt,columnIndex:cn,rowSpan:an,colSpan:xr})=>{let xt=u.columns[cn],Kn=K?zTt(K,_t,cn,an,xr):!1,Zn=he&&Oe?cJn(he.range,Oe,_t,cn,an,xr):!1,to=zle(u,Gt,_t,cn,an,xr),Qa=Ule(u,Gt),ma=Iri(u,Gt),Jl=ma?c(Eri[ma]):null;return ba("td",{className:[Kn?"selected-cell":"",Zn?"delete-preview":""].filter(Boolean).join(" "),"data-table-row-index":_t,"data-table-column-index":cn,"data-table-cell-id":Gt?.id,"data-table-formula-error":ma??void 0,title:Jl??void 0,"aria-description":Jl?`${c("table.formula.errorAria")}: ${Jl}`:void 0,rowSpan:an,colSpan:xr,style:to,onPointerDownCapture:qi=>Y(qi,_t,cn),onPointerDown:qi=>{t&&qi.button===0&&qi.stopPropagation()},onContextMenuCapture:qi=>oe(qi,_t,cn),children:ba("div",{className:"overlay-table-cell-content-layer",style:Qa,children:Gt?Gt.content.map(qi=>ba(bJn,{shapeId:e.id,cell:Gt,cellId:Gt.id,content:qi,editing:t&&Gt.id===(ne??j?.id),showFormulaSource:t&&ne===Gt.id,table:u,rowIndex:_t,columnIndex:cn,colSpan:xr,onFocus:Ce,onChange:Q,onNavigate:le,onRegisterEditor:re},qi.id)):null})},Gt?.id??`${mt.id}:${xt.id}`)})},mt.id))})]}),ba(SJn,{table:u,columnOffsets:h,rowOffsets:g})]})}var Eri,Pri,FJn,CJn=X(()=>{"use strict";"use client";Dt();er();rJn();Dt();un();ij();jh();m_();tDt();xJn();wJn();Eri={"#DIV/0!":"table.formula.error.divideByZero","#NAME?":"table.formula.error.name","#REF!":"table.formula.error.ref","#VALUE!":"table.formula.error.value","#NUM!":"table.formula.error.num","#N/A":"table.formula.error.na","#CYCLE!":"table.formula.error.cycle"};Pri=500;FJn={xs:.5,s:1,m:2,l:3,xl:4}});function nDt(e){return JI([...e])}function gze(e,t=[]){return ky(e,[...t],{spaceAfter:"node"}).map(rDt)}function rDt(e){return e.type==="paragraph"||e.type==="heading"||e.type==="list"||e.type==="quote"||e.type==="codeBlock"||e.type==="divider"?e:{type:"paragraph",id:e.id||rt("p"),children:Bh(e)}}var oDt=X(()=>{"use strict";ai();xi();qk()});var AJn,TJn=X(()=>{"use strict";Xo();vwt();AJn=Vn.create({name:"overlayTextBlockAttrs",addGlobalAttributes(){return[{types:["paragraph","heading","bulletList","orderedList"],attributes:{sigmaDocId:{default:null,renderHTML:()=>({})},sigmaDocType:{default:null,renderHTML:()=>({})},spaceAfterPx:EOe}},{types:["listItem"],attributes:{spaceAfterPx:IOe}},{types:["paragraph","heading"],attributes:{listItemSpaceAfterPx:POe}},{types:["orderedList"],attributes:{markerStyle:BOe}},{types:["bulletList","orderedList"],attributes:{indentEm:MOe}}]}})});function kJn(e){return e.getMeta(iDt)===!0}function yze(e){let t=[],n=(r,o)=>{r.forEach((i,a)=>{if(i.type.name!=="listItem")return;let s=o+1+a;t.push({pos:s,kind:"listItem",node:i}),i.forEach((l,c)=>{DJn.has(l.type.name)&&n(l,s+1+c)})})};return e.forEach((r,o)=>{Rri.has(r.type.name)?t.push({pos:o,kind:"block",node:r}):DJn.has(r.type.name)&&n(r,o)}),t}function EJn(e,t){let n=-1;return e.forEach((r,o)=>{r.pos<=t&&t<r.pos+r.node.nodeSize&&(n=o)}),n}function IJn(e,t){for(let n=e;n&&n!==t;n=n.parentElement)if(n instanceof HTMLElement&&(n.tagName==="LI"||n.parentElement===t))return n;return null}function aDt(e){return e.kind==="block"?rc(e.node.attrs.spaceAfterPx)??0:rc(e.node.firstChild?.attrs.listItemSpaceAfterPx)??0}function PJn(e,t,n){let r=rc(n)??null;if(t.kind==="block")return e.setNodeMarkup(t.pos,void 0,{...t.node.attrs,spaceAfterPx:r});let o=t.node.firstChild;return o&&e.setNodeMarkup(t.pos+1,void 0,{...o.attrs,listItemSpaceAfterPx:r}),e.setNodeMarkup(t.pos,void 0,{...t.node.attrs,spaceAfterPx:r})}function MJn(e,t){let n=e.nodeDOM(t.pos);return n instanceof HTMLElement?t.kind==="block"?n:Array.from(n.children).filter(o=>o instanceof HTMLElement&&o.tagName!=="UL"&&o.tagName!=="OL").at(-1)??null:null}function BJn(e,t){let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent instanceof HTMLElement?r.offsetParent:null;return r===t?n+e.offsetHeight:null}function LJn(e,t,n,r){let o=Number.isFinite(r)&&r>0?r:1,i=Number.isFinite(n)?n:0;return(-e*Math.sin(i)+t*Math.cos(i))/o}var iDt,Rri,DJn,RJn=X(()=>{"use strict";Dt();iDt="overlayTextSpaceAfter";Rri=new Set(["paragraph","heading","divider"]),DJn=new Set(["bulletList","orderedList"])});import{useEffect as _Jn,useRef as bze}from"react";import{jsx as OJn}from"react/jsx-runtime";function NJn({editor:e,wrapperRef:t,rotation:n,draggingRef:r,onCommit:o}){let i=We("editor"),a=bze(null),s=bze(null),l=bze(n),c=bze(o);return _Jn(()=>{l.current=n,c.current=o},[o,n]),_Jn(()=>{let u=t.current,d=a.current;if(!u||!d)return;let p=null,f=null,m=null,h=null,g=()=>e.isInitialized&&!e.isDestroyed,y=()=>{if(!g()||!e.isEditable)return null;let L=yze(e.state.doc),_=f?.index??p??-1;if(_<0||_>=L.length){let{selection:z}=e.state;_=EJn(L,"node"in z?z.from:z.head)}let R=L[_];if(!R)return null;let O=MJn(e.view,R),N=O?BJn(O,u):null;return N===null?null:{index:_,px:aDt(R),bottom:N}},b=()=>{m=null;let L=y();if(h=L?{index:L.index,px:L.px}:null,!L){d.removeAttribute("data-visible");return}d.dataset.visible="true",d.dataset.index=String(L.index),d.style.top=`${L.bottom}px`},x=()=>{m===null&&(m=window.requestAnimationFrame(b))},v=(L,_,R)=>{if(!g())return!1;let O=yze(e.state.doc)[L];if(!O||aDt(O)===_)return!1;let N=PJn(e.state.tr,O,_).setMeta(iDt,!0).setMeta("addToHistory",!1);return R&&N.setMeta("preventUpdate",!0),e.view.dispatch(N),!0},S=(L,_)=>Wse(L.startPx+LJn(_.clientX-L.startPoint.clientX,_.clientY-L.startPoint.clientY,l.current,L.scale)),F=L=>{L.frame=null;let _=S(L,L.point);_!==L.px&&(L.px=_,v(L.index,_,!0),b())},w=L=>{L.frame!==null&&(window.cancelAnimationFrame(L.frame),L.frame=null),window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",D),window.removeEventListener("pointercancel",T),window.removeEventListener("keydown",k,!0),delete d.dataset.dragging,r.current=!1,f=null},C=()=>{let L=f;L&&(w(L),v(L.index,L.startPx,!0),x())};function A(L){let _=f;_&&(_.point={clientX:L.clientX,clientY:L.clientY},_.frame===null&&(_.frame=window.requestAnimationFrame(()=>F(_))))}function T(){C()}function D(L){let _=f;if(!_)return;let R=S(_,{clientX:L.clientX,clientY:L.clientY});w(_),v(_.index,R,!0),R!==_.startPx&&c.current(),x()}function k(L){L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),C())}s.current={startDrag(L){if(L.stopPropagation(),L.button!==0||!h||!g())return;f&&C();let _={clientX:L.clientX,clientY:L.clientY};f={index:h.index,startPx:h.px,px:h.px,startPoint:_,point:_,scale:G0(u,"y"),frame:null},r.current=!0,d.dataset.dragging="true";try{L.currentTarget.setPointerCapture(L.pointerId)}catch{}window.addEventListener("pointermove",A,{passive:!0}),window.addEventListener("pointerup",D),window.addEventListener("pointercancel",T),window.addEventListener("keydown",k,!0)},keyDown(L){let _=bAe(L);if(!_||!h)return;L.preventDefault(),L.stopPropagation();let R=_.kind==="reset"?0:Wse(h.px+_.deltaPx);v(h.index,R,!1)&&(h={index:h.index,px:R}),x()},reset(){h&&(v(h.index,0,!1),x())}};let P=L=>{if(f||!(L.target instanceof Element)||d.contains(L.target))return;let _=IJn(L.target,e.view.dom),R=yze(e.state.doc),O=_?R.findIndex(z=>e.view.nodeDOM(z.pos)===_):-1,N=O>=0?O:null;N!==p&&(p=N,x())},I=()=>{p=null,x()},B=({transaction:L})=>{L.docChanged&&!kJn(L)&&(p=null),x()};u.addEventListener("pointermove",P),e.on("selectionUpdate",I),e.on("transaction",B);let M=typeof ResizeObserver>"u"?null:new ResizeObserver(x);return M?.observe(u),x(),()=>{f&&C(),m!==null&&window.cancelAnimationFrame(m),u.removeEventListener("pointermove",P),e.off("selectionUpdate",I),e.off("transaction",B),M?.disconnect(),s.current=null}},[r,e,t]),OJn("div",{className:"overlay-text-space-layer","data-testid":"overlay-text-space-layer",children:OJn("button",{ref:a,type:"button",className:"page-block-space-handle overlay-text-space-handle","data-testid":"overlay-text-space-handle","aria-label":i("pageCanvas.spaceAfter"),title:i("pageCanvas.spaceAfterHint"),onMouseDown:u=>{u.preventDefault(),u.stopPropagation()},onPointerDown:u=>s.current?.startDrag(u),onClick:u=>u.stopPropagation(),onDoubleClick:u=>{u.stopPropagation(),s.current?.reset()},onKeyDown:u=>s.current?.keyDown(u)})})}var zJn=X(()=>{"use strict";"use client";Dt();Gc();un();RJn()});import{useEffect as UJn,useLayoutEffect as sDt,useRef as Ebe,useState as _ri}from"react";import{jsx as HJn,jsxs as Ori}from"react/jsx-runtime";function Ibe({shape:e,externalRevision:t,editing:n,onFocus:r,onCancel:o,onMeasuredHeight:i,onChange:a}){let{preferredFont:s,seedPreferredFont:l}=C_e(),c=Ebe(null),u=Ebe(e.props.blocks),d=Ebe(t),p=_m(),f=Ebe(!1),[m]=_ri(()=>new Nee),h=ww({extensions:Vk({blockExtensions:[AJn],drawBoxedRunFrames:e.type==="text"&&Oi(e)===0,enableMathDelimiters:!0,bodyBlocks:!0,listMarkerTypography:!0,orderedListMarkerStyles:!0,mathEnvironment:p,textBlockStyle:!0}),content:nDt(e.props.blocks),immediatelyRender:!1,editorProps:{attributes:{class:"overlay-text-shape-content"},handleKeyDown:(F,w)=>(jge(w)&&m.requestLiteralPaste(),w.key!=="Escape"?!1:(w.preventDefault(),o(e.id),!0)),handleDOMEvents:{copy:(F,w)=>eFt(F,w,u.current)},handlePaste:(F,w,C)=>EHn(m,F,w,C)},onTransaction:({editor:F})=>{F.isFocused&&(l(F),$w(F,lDt,"overlay",void 0,{state:F.state,view:F.view,documentFontFamily:nx}))},onFocus:({editor:F})=>{l(F),$w(F,lDt,"overlay",void 0,{state:F.state,view:F.view,documentFontFamily:nx}),r(F,e.id)},onUpdate:({editor:F})=>{$w(F,lDt,"overlay",void 0,{state:F.state,view:F.view,documentFontFamily:nx}),g(F)}});function g(F){let w=F.getJSON(),C=gze(w,u.current);u.current=C,a(e.id,C)}UJn(()=>{h?.isFocused&&l(h)},[h,s,l]),sDt(()=>{if(!h)return;let F=d.current!==t;if(d.current=t,h.isFocused&&!F)return;let w=JSON.stringify(u.current),C=JSON.stringify(e.props.blocks);if(w!==C){u.current=e.props.blocks;let A=nDt(e.props.blocks);h.isDestroyed||(h.commands.setContent(A,{emitUpdate:!1}),F&&n&&h.commands.focus("end"))}},[n,h,t,e.props.blocks]),UJn(()=>{n&&h&&!h.isFocused&&window.setTimeout(()=>h.commands.focus("end"),0)},[n,h]);let y=e.type==="callout",b=QS(e),x=Oi(e),v=n&&!e.flipX&&!e.flipY,S=Ebe(e);return sDt(()=>{S.current=e},[e]),sDt(()=>{let F=()=>{let k=c.current?.querySelector(".ProseMirror");if(!k)return;let P=Pye(k,{rotated:x!==0}),I=S.current,B=BNe(I,P);f.current?i(I.id,B,{preview:!0}):i(I.id,B)};F();let w=null,C=()=>{w!==null&&window.cancelAnimationFrame(w),w=window.requestAnimationFrame(()=>{w=null,F()})},A=c.current?.querySelector(".ProseMirror"),T=typeof ResizeObserver>"u"?null:new ResizeObserver(C),D=typeof MutationObserver>"u"?null:new MutationObserver(C);return A&&(T?.observe(A),D?.observe(A,{attributes:!0,attributeFilter:[..._Ct],childList:!0,subtree:!0})),C(),()=>{w!==null&&window.cancelAnimationFrame(w),T?.disconnect(),D?.disconnect()}},[n,h,b,i,x,e.id,e.type,e.props.blocks,e.props.w]),Ori("div",{ref:c,className:`overlay-text-shape ${y?"embedded-callout":""} ${e.type==="text"&&e.props.textWrap==="none"?"no-auto-wrap":""}`,style:{...v?{position:"relative"}:{},width:y?"100%":e.props.w,...e.type==="text"?LK(e):{},minWidth:y?0:wD,minHeight:y?b:Math.max(e.props.h,b),color:e.props.color,fontSize:`${xC(e)}pt`,pointerEvents:n?"auto":"none"},onPointerDown:F=>{n&&F.stopPropagation()},children:[HJn(o2,{editor:h}),v&&h?HJn(NJn,{editor:h,wrapperRef:c,rotation:x,draggingRef:f,onCommit:()=>g(h)}):null]})}var lDt,GJn=X(()=>{"use strict";"use client";rU();A_e();ree();jk();Dt();Ys();Dn();Pn();s7e();oDt();TJn();zJn();LNe();lDt="sigma-studio:text-format-state"});var cDt=X(()=>{"use strict";"use client";CJn();GJn()});import{useEffect as jJn,useMemo as Nri,useState as VJn}from"react";import{jsx as Pbe}from"react/jsx-runtime";function zri({shape:e,interactive:t,onCameraChange:n,onObjectRotationChange:r,onObjectTransformChange:o,onPreviewReady:i}){let[a,s]=VJn(null),[l,c]=VJn(!1);jJn(()=>{let p=f=>{if(!(f instanceof CustomEvent))return;let m=f.detail;m.shapeId===e.id&&s(m)};return window.addEventListener(A9e,p),()=>window.removeEventListener(A9e,p)},[e.id]),jJn(()=>{let p=f=>{if(!(f instanceof CustomEvent))return;let m=f.detail;c(m.shapeId===e.id)};return window.addEventListener(T9e,p),()=>window.removeEventListener(T9e,p)},[e.id]);let d=a?.playing===!1&&Object.entries(a.overrides).every(([p,f])=>e.props.spec.parameters.some(m=>m.name===p&&m.value===f))?null:a;return Pbe(Q1t,{spec:e.props.spec,interactive:t,parameterOverrides:d?.overrides,animationPlaying:d?.playing===!0,deferAnimationCapture:l,onCameraChange:p=>n(e.id,p),onObjectRotationChange:(p,f)=>r(e.id,p,f),onObjectTransformChange:(p,f)=>o(e.id,p,f),onPreviewReady:(p,f,m,h)=>i(e.id,p,f,m,h)})}function XJn(e){let{onGraph3DCameraChange:t,onGraph3DObjectRotationChange:n,onGraph3DObjectTransformChange:r,onGraph3DPreviewReady:o,onCreateChartFromTable:i,onTableChange:a,onTableEditorFocus:s,onTableFirstCellReady:l,onTableResize:c,onTextMeasuredHeight:u,onTextChange:d,onTextEditorCancel:p,onTextEditorFocus:f}=e;return Nri(()=>({renderGraph3DEditor:({interactive:m,shape:h})=>Pbe("div",{className:"overlay-graph3d-live-window","data-testid":"overlay-graph3d-live-window",onPointerDown:m?g=>g.stopPropagation():void 0,onDoubleClick:m?g=>g.stopPropagation():void 0,onWheel:m?g=>g.stopPropagation():void 0,children:Pbe(zri,{shape:h,interactive:m,onCameraChange:t,onObjectRotationChange:n,onObjectTransformChange:r,onPreviewReady:o})}),renderTableEditor:({editing:m,shape:h})=>Pbe(kbe,{shape:h,editing:m,onFocus:s,onFirstCellReady:l,onChange:a,onResize:c,onCreateChart:i}),renderTextEditor:({editing:m,externalRevision:h,shape:g})=>Pbe(Ibe,{shape:g,externalRevision:h,editing:m,onFocus:f,onCancel:p,onMeasuredHeight:u,onChange:d})}),[i,t,n,r,o,a,s,l,c,u,d,p,f])}var WJn=X(()=>{"use strict";Ys();D9e();cDt()});var dDt={};$S(dDt,{OverlayShapeReadOnlyView:()=>vj,OverlayTableShapeEditor:()=>kbe,OverlayTextShapeEditor:()=>Ibe,RemoteOverlayPresenceLayer:()=>vbe,default:()=>KJn,getRemoteOverlayPresenceFrameStyle:()=>MTt,getRemoteOverlayPresenceLabelBounds:()=>PTt,mergeOverlayHistoryGroup:()=>TTt,resolveRemoteOverlayPresenceFrames:()=>ITt});import{useMemo as Mbe}from"react";import{useCallback as kp,useEffect as Km,useLayoutEffect as cne,useReducer as Uri,useRef as wd,useState as nv}from"react";import{createPortal as xze}from"react-dom";import{jsx as gl,jsxs as Xri}from"react/jsx-runtime";function qJn(e,t){if(!(!t||!Bd(e)||!Tnt(Zp(e),t.bounds)))return t.revision}function KJn({externalRevision:e,documentId:t,overlay:n,canvasWidth:r,canvasHeight:o,insertionBounds:i,bleedValues:a,imageInsertAreaWidth:s,imageInsertAreaHeight:l,blockAnchorScopeElement:c,bodyBlockRects:u=null,bodyAnchorableBlocks:d=null,visiblePageRange:p=null,textRepaint:f=null,pageHeightPx:m=0,pageGapPx:h=0,pageArrangement:g=null,showAnchorHandles:y=!0,autoScrollPanBy:b,autoScrollViewportElement:x=null,verticalSnapGuides:v=[],backgroundLayerElement:S,commandRequest:F,imageRequest:w,actionRequest:C,arrangeShortcutLabels:A,acceptsStylePreview:T=!0,selectPointRequest:D,onCommandHandled:k,onImageHandled:P,onActionHandled:I,onSelectPointHandled:B,onRequestTextMode:M,onRequestTextSelection:L,retainEmptySelection:_=!1,onModeStatusChange:R,onSelectionSummaryChange:O,onSelectedCountChange:N,onActiveToolChange:z,onMaterialSaveRequest:U,syncBlockAnchors:H=!0,onChange:V,editPolicy:ne=ZZn,shapeDecorations:Z,diffShapeClassNames:ee,publishesSessionPresence:J=!1}){let te=We("shape"),K=HD(),{shapes:G,setShapes:ie,assets:fe,setAssets:$,canvasWidthRef:j,canvasHeightRef:pe,documentIdRef:re,saveTimeoutRef:le,pendingOverlayHistoryRef:Q,pendingOverlaySaveHistoryGroupRef:se,imageCropDirtyRef:De,mountedRef:Ae,suppressNextSaveRef:ye,explicitlySavedShapeStatesRef:$e,externalRevisionRef:Pe,lastEmittedSnapshotRef:Ne,seenDocumentSnapshotRef:we,reconciledDocumentSnapshotRef:Ie,onChangeRef:Ce,shapesRef:xe,assetsRef:Y,extensionsRef:oe}=UZn({overlay:n,canvasWidth:r,canvasHeight:o,documentId:t,externalRevision:e,onChange:V}),[de,Le]=nv([]),[be,Be]=nv(null),ce=wd(null),[Re,Qe]=nv(null),W=kp(Ot=>{ce.current=Ot,Be(Ot)},[]);Km(()=>{let Ot=ce.current;Ot&&!(de.length===1&&de[0]===Ot.shapeId)&&W(null)},[de,W]);let[ve,_e]=nv(null),[he,Oe]=nv(null),qe=wd(null),[Ze,vt]=nv(null),[Ft,gt]=nv(null),[bt,ct]=nv(jri),[ft,hn]=nv(null),[Kt,xo]=nv([]),[Bo,fo]=nv(0),[Sr,oa]=Uri(Vot,void 0,xnn),mt=_&&ve&&ve.documentId===t&&ve.revision===e&&de.length===0&&Sr.id==="overlay.select"?ve.bounds:null,_t=vnn(Sr),Gt=Fnn(Sr),cn=Cnn(Sr),an=Ann(Sr)?cn:null,xr=ft?.shapeId===cn?ft:null,xt=Tnn(Sr),Kn=wd(null),Zn=wd(null),to=g&&g.columns>1?g:null,Qa=wd(to);cne(()=>{Qa.current=to},[to]),Km(()=>{if(!mt)return;let Ot=mi=>{mi.key==="Escape"&&_e(null)},Jr=mi=>{let vo=mi.target;!(vo instanceof Element)||mi.button!==0||Kn.current?.contains(vo)||vo.closest(".selection-action-popover, [data-preserve-canvas-selection]")||_e(null)};return window.addEventListener("keydown",Ot,!0),window.addEventListener("pointerdown",Jr,!0),()=>{window.removeEventListener("keydown",Ot,!0),window.removeEventListener("pointerdown",Jr,!0)}},[mt]);let ma=wd(null),Jl=wd(!1),qi=wd(Sr),Go=wd(null),xs=wd(null),Fe=wd(null),dt=wd({w:s,h:l});cne(()=>{dt.current={w:s,h:l}},[l,s]);let Mt=wd(de),Ct=wd(Ft),Tt=wd(bt),dn=wd(""),Yn=wd(CD);Km(()=>{Yn.current=bWn()},[]);let[bn,Jt]=nv(Gte);Km(()=>AKn(Jt),[]);let dr=kp(Ot=>{CKn(Ot)},[]),$r=wd(!1),[ti,Qn]=nv(null),mo=ne.lockedShapeIds,Si=wd(mo);Km(()=>{Si.current=mo},[mo]);let rr=ne.unselectableShapeIds,Io=wd(rr);Km(()=>{Io.current=rr},[rr]);let ia=ne.preservedShapeIds,Wn=wd(ia);cne(()=>{Wn.current=ia},[ia]);let[es,Pi]=nv(null),ku=wd(null),ni=kp(()=>{ne.blockedMessage&&(Pi(ne.blockedMessage),ku.current&&clearTimeout(ku.current),ku.current=setTimeout(()=>Pi(null),6e3))},[ne.blockedMessage]);Km(()=>()=>{ku.current&&clearTimeout(ku.current)},[]);let Eu=kp(()=>{xo(Ot=>Ot.length===0?Ot:[])},[]),Iu=kp(()=>{let Ot=Zn.current?.getBoundingClientRect();if(!Ot||Ot.width<=0||Ot.height<=0)return uDt;let Jr=Qa.current;if(Jr)return uDt*(Eb(Jr,1).width/Ot.width);let mi=j.current/Ot.width,vo=pe.current/Ot.height;return uDt*Math.max(mi,vo)},[pe,j]),Pu=kp(()=>{let Ot=Zn.current;return Ot?c&&Ot.ownerDocument.contains(c)?c:Ot.closest(".page-canvas")??Ot.ownerDocument:c??null},[c]),Po=wd(null),xl=kp((Ot=[])=>{let Jr=[...Ot],mi=JSON.stringify(Jr),vo=xe.current,Rc=j.current,Gs=pe.current,js=Po.current,Z1=js&&js.guides.length===v.length&&js.guides.every((Q3,Bv)=>Q3===v[Bv]);if(js&&Z1&&js.shapes===vo&&js.excludedKey===mi&&js.canvasWidth===Rc&&js.canvasHeight===Gs)return js.geometry;let ud=prn(ux(vo),{excludedShapeIds:Jr,canvasWidth:Rc,canvasHeight:Gs,verticalGuideValues:v});return Po.current={canvasHeight:Gs,canvasWidth:Rc,excludedKey:mi,geometry:ud,guides:[...v],shapes:vo},ud},[pe,j,xe,v]);Km(()=>{let Ot=()=>{Jl.current=!0},Jr=()=>{Jl.current=!1};return window.addEventListener("compositionstart",Ot),window.addEventListener("compositionend",Jr),()=>{window.removeEventListener("compositionstart",Ot),window.removeEventListener("compositionend",Jr)}},[]),Km(()=>{Mt.current=de},[de]),Km(()=>{Ct.current=Ft},[Ft]),Km(()=>{if(!Ft||vP(G,Ft))return;let Ot=window.setTimeout(()=>gt(null),0);return()=>window.clearTimeout(Ot)},[Ft,G]);let Fi=kp(Ot=>{if(SKn(Ot,xe.current,Si.current)){ni();return}Ot.type==="select"&&qi.current.id==="overlay.marquee"||_e(null),qi.current=Vot(qi.current,Ot),oa(Ot)},[ni,xe]);Km(()=>{qi.current=Sr},[Sr]);let Ma=vZn({documentId:t,modeRef:qi,transitionMode:Fi,bleedSurfaceRef:Kn}),{dragPointerRef:vs,dragCanvasRectRef:Td,suppressNextShapeDoubleClickRef:dm,dragAutoScrollerRef:Pf}=Ma,{id:pb,labelId:Tg}=hWn(Sr,de.length);Km(()=>{R?.({id:pb,labelId:Tg})},[pb,Tg,R]),Km(()=>{z?.(Sr.tool)},[Sr.tool,z]);let LT=kp(()=>Tt.current.rects,[]),pm=kp(()=>Wn.current,[]),{queueOverlaySave:Zc,clearQueuedOverlaySave:d0,commitOverlayChangeNow:Lc,flushOverlayChange:Mf,queueDirtyImageCropSave:Ns}=uZn({syncBlockAnchors:H,shapesRef:xe,canvasRef:Zn,canvasHeightRef:pe,canvasWidthRef:j,getBlockAnchorScope:Pu,getLastDrawnBlockRects:LT,getPreservedShapeIds:pm,suppressNextSaveRef:ye,setShapes:ie,assetsRef:Y,extensionsRef:oe,lastEmittedSnapshotRef:Ne,onChangeRef:Ce,imageCropDirtyRef:De,saveTimeoutRef:le,pendingOverlayHistoryRef:Q,pendingOverlaySaveHistoryGroupRef:se}),Ql=kp((Ot,Jr=Array.from(Ot.values()))=>{if(Ot.size===0||sw(qi.current))return!1;let mi=xe.current,vo=Qr(ZNe(mi,Jr,void 0,Wn.current)),Rc=new Map(mi.map(ud=>[ud.id,ud])),Gs=vo.some(ud=>!Zx(Rc.get(ud.id)?.anchor,ud.anchor)),js=Qr(F0(vo,Ot,Qx(vo))),Z1=js.length!==mi.length;for(let ud=0;!Z1&&ud<js.length;ud+=1)js[ud]!==mi[ud]&&(Z1=!0);return Z1?(xe.current=js,Gs?($e.current.add(js),Zc({history:"coalesce"})):ye.current=!0,ie(js),!0):!1},[$e,Zc,ie,xe,ye]);hKn({setPreview:Oe,clearQueuedOverlaySave:d0,imageCropDirtyRef:De,suppressNextSaveRef:ye,modeRef:qi,selectedIdsRef:Mt,shapesRef:xe,assetsRef:Y,extensionsRef:oe,setShapes:ie,setAssets:$,setSelectedIds:Le,setAppliedSnapshotRevision:fo,transitionMode:Fi,activeTextEditorRef:ma,overlay:n,anchorMeasurementsRef:Tt,reconciledDocumentSnapshotRef:Ie,lastEmittedSnapshotRef:Ne,saveTimeoutRef:le,pendingOverlayHistoryRef:Q,externalRevisionRef:Pe,externalRevision:e,seenDocumentSnapshotRef:we,mode:Sr}),fZn({assets:fe,shapes:G,assetsRef:Y,shapesRef:xe,mountedRef:Ae,pendingOverlaySaveHistoryGroupRef:se,explicitlySavedShapeStatesRef:$e,suppressNextSaveRef:ye,commitOverlayChangeNow:Lc,queueOverlaySave:Zc,flushOverlayChange:Mf,saveTimeoutRef:le,imageCropDirtyRef:De}),cne(()=>{if(!H)return;let Ot=Zn.current;if(!Ot)return;let Jr=Pu();if(!Jr)return;let{rects:mi,ordered:vo}=yP(Ot,Jr,pe.current,j.current,Tt.current.rects);mi.size!==0&&Ql(mi,vo)},[pe,j,Pu,Ql,H]);let{setSelectedShapeIds:zs,replaceShape:fm,updateShape:Dd,selectKnownShape:ui,selectShape:vl,updateGraphShapeSpec:mm,toggleShapeSelection:ll}=lZn({setRegionSelection:_e,shapesRef:xe,selectedIdsRef:Mt,setSelectedIds:Le,onSelectedCountChange:N,unselectableShapeIdsRef:Io,focusedGroupIdRef:Ct,transitionMode:Fi,modeRef:qi,activeTextEditorRef:ma,explicitlySavedShapeStatesRef:$e,setShapes:ie,commitOverlayChangeNow:Lc,queueOverlaySave:Zc,anchorMeasurementsRef:Tt});Km(()=>{let Ot=wKn(Mt.current,xe.current,rr);Ot&&zs(Ot)},[rr,Mt,zs,xe]);let{imageReplacementInputRef:q1,startImageCrop:Mu,requestImageReplacement:pu,resetImageCrop:wo,restoreImageNaturalSize:Va,handleImageReplacementChange:ec,setImageOpacity:Us}=G$n({shapesRef:xe,editPolicyLockedShapeIdsRef:Si,notifyEditPolicyBlocked:ni,setSelectedShapeIds:zs,transitionMode:Fi,documentId:t,assetsRef:Y,setShapes:ie,setAssets:$,queueOverlaySave:Zc,replaceShape:fm,imageInsertAreaRef:dt,updateShape:Dd}),{createShapeFromInsertDrag:Dv,finishCurveDrawing:fb,createChartFromTable:dh}=q$n({lastCalloutCornerRadiusRef:Yn,focusedGroupIdRef:Ct,shapesRef:xe,canvasWidthRef:j,canvasHeightRef:pe,suppressNextSaveRef:ye,insertedTableFocusRef:qe,setShapes:ie,selectKnownShape:ui,commitOverlayChangeNow:Lc,queueOverlaySave:Zc,setSelectedShapeIds:zs,transitionMode:Fi,clearSnapGuides:Eu}),Bu=kp(()=>{qe.current=null;let Ot=vs.current?.pointerId;Ot!==void 0&&Kn.current?.hasPointerCapture(Ot)&&Kn.current.releasePointerCapture(Ot),vs.current=null,Pf.current?.stop(),Pf.current=null,Eu(),Fi({type:"setTool",tool:{kind:"select"}})},[Eu,Pf,vs,Fi]),Bf=kp(Ot=>{let Jr=Ot.id==="overlay.resize"||Ot.id==="overlay.rotate"?Ot.shapes:Ot.id==="overlay.point"||Ot.id==="overlay.imageCropResize"||Ot.id==="overlay.imageCropPan"?[Ot.shape]:[];Jr.length>0&&ie(mi=>{let vo=Qr(Wv(mi,Jr));return xe.current=vo,vo}),(Ot.id==="overlay.imageCropResize"||Ot.id==="overlay.imageCropPan")&&(De.current=!1),Qn(null),Eu()},[Eu,De,ie,xe]),Jc=kp(Ot=>{if(Go.current!==Ot.id){if(Ot.command==="select")Fi({type:"setTool",tool:{kind:"select"}});else if(Ot.command==="table"){let Jr=ma.current;Jr&&!Jr.isDestroyed&&Jr.commands.blur(),ma.current=null,Fi({type:"setTool",tool:{kind:"insert",command:"table",tableCellSize:{w:kye,h:Math.max(36,Eye)}}})}else Fi({type:"setTool",tool:{kind:"insert",command:Ot.command,graphPreset:Ot.graphPreset,graph3dPreset:Ot.graph3dPreset,...Ot.command==="callout"?{calloutRadius:Yn.current}:{}}});Go.current=Ot.id,k(Ot.id)}},[k,Fi]);Km(()=>{if(F){let Ot=window.setTimeout(()=>Jc(F),0);return()=>window.clearTimeout(Ot)}},[F,Jc]),X$n({documentId:t,imageInsertAreaWidth:s,imageInsertAreaHeight:l,canvasWidthRef:j,canvasHeightRef:pe,focusedGroupIdRef:Ct,shapesRef:xe,setAssets:$,assetsRef:Y,setShapes:ie,setSelectedShapeIds:zs,transitionMode:Fi,queueOverlaySave:Zc,onImageHandled:P,imageRequest:w});let Jn=kp((Ot,Jr,mi)=>{let vo=mi??Zn.current?.getBoundingClientRect();if(!vo||vo.width<=0||vo.height<=0)return{x:Ot,y:Jr};mi||(Td.current={left:vo.left,top:vo.top,width:vo.width,height:vo.height});let Rc=Qa.current;if(Rc){let Gs=vo.width/Eb(Rc,1).width,js=EB(Rc,{x:(Ot-vo.left)/Gs,y:(Jr-vo.top)/Gs});return{x:js.x,y:js.y}}return{x:(Ot-vo.left)/vo.width*j.current,y:(Jr-vo.top)/vo.height*pe.current}},[pe,j,Td]),kd=kp(Ot=>{let Jr=Zn.current?.getBoundingClientRect();if(!Jr||j.current<=0||pe.current<=0)return{x:Ot.x,y:Ot.y};let mi=Qa.current;if(mi){let vo=Jr.width/Eb(mi,1).width,Rc=yDe(mi,Ot);return{x:Jr.left+Rc.x*vo,y:Jr.top+Rc.y*vo}}return{x:Jr.left+Ot.x/j.current*Jr.width,y:Jr.top+Ot.y/pe.current*Jr.height}},[pe,j]),Ke=kp(()=>{QZn(Kn.current)},[]),Lu=kp(()=>{let Ot=Zn.current;if(!Ot)return Tt.current;let Jr=Pu();if(!Jr||sw(qi.current))return Tt.current;let mi=u&&d?{rects:u,ordered:[...d]}:yP(Ot,Jr,pe.current,j.current,Tt.current.rects),{rects:vo,ordered:Rc}=mi,Gs=KWn(Rc);if(Gs===dn.current)return Tt.current;let js={rects:vo,ordered:Rc};return dn.current=Gs,Tt.current=js,ct(js),Ql(vo,Rc),js},[d,u,pe,j,Pu,Ql]),gc=sw(Sr);cne(()=>{gc||Lu()},[gc,u,o,r,c,Lu]),cne(()=>{u||sw(qi.current)||Lu()}),Km(()=>(window.addEventListener("resize",Lu),()=>window.removeEventListener("resize",Lu)),[Lu]);let fu=kp((Ot,Jr=8)=>{let mi,vo=kd(Ot);return YZn(RK(xe.current),Ot,Jr,Gs=>Hte(Gs.id,Io.current)?!1:Gs.type==="graph2dShape"&&!Sbe(Zn.current,Gs.id,vo)?(mi??=Gs,!1):!0)??mi},[kd,xe]),Ru=kp(Ot=>{for(let Jr of RK(xe.current))if(!(!FNe(Jr)||Hte(Jr.id,Io.current))&&qv(Jr,Ot,Hri))return Jr},[xe]),rp=kp(Ot=>dKn({shapes:xe.current,point:Ot,isUnselectable:Jr=>Hte(Jr,Io.current),editPolicyLockedIds:Si.current}),[xe]),{duplicateSelectedShapes:Ss,deleteSelectedShapes:od,arrangeSelectedShapes:Nl,alignSelectedShapes:Dg,distributeSelectedShapes:id,groupSelectedShapes:op,ungroupSelectedShapes:mu,setSelectedShapesLocked:sC,setSelectedShapesHidden:kg,applyStyleToSelectedShapes:mb,applyPastedOverlayShapes:hm,reanchorShapesToCopiedBlocks:lC,getRemovableSelectedShapeIds:Eg,applyQuickTransformToSelectedShapes:NS}=PZn({shapesRef:xe,selectedIdsRef:Mt,editPolicyLockedShapeIdsRef:Si,notifyEditPolicyBlocked:ni,assetsRef:Y,canvasWidthRef:j,canvasHeightRef:pe,setAssets:$,setShapes:ie,setSelectedShapeIds:zs,transitionMode:Fi,queueOverlaySave:Zc,extensionsRef:oe,explicitlySavedShapeStatesRef:$e,pendingOverlaySaveHistoryGroupRef:se,commitOverlayChangeNow:Lc,refreshAnchorMeasurements:Lu,solidEdgeRef:ce,documentIdRef:re,canvasRef:Zn,getBlockAnchorScope:Pu,pageHeightPx:m,pageGapPx:h}),p0=wd(null),RT=kp((Ot,Jr)=>vt({x:Yo(Ot.x,8,Math.max(8,window.innerWidth-232)),y:Yo(Ot.y,8,Math.max(8,window.innerHeight-360)),shapeId:Jr}),[vt]);PKn({handledActionRequestIdRef:xs,duplicateSelectedShapes:Ss,deleteSelectedShapes:od,arrangeSelectedShapes:Nl,alignSelectedShapes:Dg,distributeSelectedShapes:id,groupSelectedShapes:op,ungroupSelectedShapes:mu,shapesRef:xe,selectedIdsRef:Mt,setSelectedShapesLocked:sC,setSelectedShapesHidden:kg,setPreview:Oe,editPolicyLockedShapeIdsRef:Si,editPolicyUnselectableShapeIdsRef:Io,solidEdgeRef:ce,learnShapeStyleDefaults:dr,applyStyleToSelectedShapes:mb,applyPastedOverlayShapes:hm,setFocusedGroupId:gt,setSelectedShapeIds:zs,refreshAnchorMeasurements:Lu,transitionMode:Fi,extendedActionRunnerRef:p0,activeTextEditorRef:ma,createShapeFromInsertDrag:Dv,onActionHandled:I,actionRequest:C,handledSelectPointRequestIdRef:Fe,focusOverlayCanvas:Ke,onSelectPointHandled:B,getShapeAtPoint:fu,getOpenStrokeShapeAtPoint:Ru,getEditableTextShapeAtPoint:rp,focusedGroupIdRef:Ct,setShapes:ie,queueOverlaySave:Zc,selectShape:vl,documentId:t,selectPointRequest:D,openShapeContextMenu:RT}),zKn({setShapes:ie,canvasWidthRef:j,canvasHeightRef:pe,shapesRef:xe,queueOverlaySave:Zc,selectedIds:de,shapes:G,originPickShapeId:cn,graphFillPickShapeId:xt,setSelectedShapeIds:zs,transitionMode:Fi});let{handleGraph3DCameraChange:Vp,handleGraph3DObjectRotationChange:zl,handleGraph3DObjectTransformChange:hb,handleGraph3DPreviewReady:ph}=KKn({shapes:G,selectedIds:de,shapesRef:xe,assetsRef:Y,setShapes:ie,setAssets:$,explicitlySavedShapeStatesRef:$e,canvasWidthRef:j,canvasHeightRef:pe,imageInsertGap:Gri,queueOverlaySave:Zc,setSelectedShapeIds:zs,transitionMode:Fi,tShape:te});Km(()=>{let Ot=Jr=>{let mi=Jr instanceof CustomEvent?Jr.detail:void 0;mi?.shapeId&&vl(mi.shapeId)};return window.addEventListener(wCt,Ot),()=>window.removeEventListener(wCt,Ot)},[vl]),XZn({shapesRef:xe,selectedIdsRef:Mt,editingShapeId:Gt,updateShape:Dd,activeTextEditorRef:ma,modeRef:qi});let gb=Mbe(()=>({shapesRef:xe,updateShape:Dd,editPolicyLockedShapeIdsRef:Si,editPolicyUnselectableShapeIdsRef:Io,notifyEditPolicyBlocked:ni,setShapes:ie,assetsRef:Y,replaceShape:fm}),[xe,Dd,Si,ni,ie,Y,fm]),_T=Mbe(()=>({selectedIdsRef:Mt,focusedGroupIdRef:Ct,setFocusedGroupId:gt,setSelectedShapeIds:zs,selectShape:vl,toggleShapeSelection:ll,setSolidEdge:W,duplicateSelectedShapes:Ss}),[Mt,Ct,gt,zs,vl,ll,W,Ss]),yb=Mbe(()=>({pagePointFromClient:Jn,getOverlaySnapThreshold:Iu,getShapeAtPoint:fu,getOpenStrokeShapeAtPoint:Ru,clientPointFromPage:kd,refreshAnchorMeasurements:Lu,createSnapGeometry:xl,anchorMeasurementsRef:Tt}),[Jn,Iu,fu,Ru,kd,Lu,xl,Tt]),{updateModifierDrivenInteraction:kv,getSnappedDrawingPoint:zS,applyMoveInteractionAtPoint:Sl,applyResizeInteractionAtPoint:gm,applyPointInteractionAtPoint:He,applyImageCropInteractionAtPoint:it,getSnappedInsertDragPoint:Pt}=CZn({session:Ma,editing:gb,geometry:yb,snapDisabledRef:$r,setSnapGuides:xo,clearSnapGuides:Eu,lastCalloutCornerRadiusRef:Yn,imageCropDirtyRef:De});J$n({textCompositionRef:Jl,modeRef:qi,cancelTablePlacement:Bu,snapDisabledRef:$r,clearSnapGuides:Eu,updateModifierDrivenInteraction:kv,activeTextEditorRef:ma,transitionMode:Fi,queueDirtyImageCropSave:Ns,finishCurveDrawing:fb,restoreTransientInteraction:Bf,solidEdgeRef:ce,setSolidEdge:W,focusedGroupIdRef:Ct,setFocusedGroupId:gt,setSelectedShapeIds:zs,shapesRef:xe,ungroupSelectedShapes:mu,groupSelectedShapes:op,selectedIdsRef:Mt,duplicateSelectedShapes:Ss,editPolicyLockedShapeIdsRef:Si,notifyEditPolicyBlocked:ni,arrangeSelectedShapes:Nl,refreshAnchorMeasurements:Lu,setShapes:ie,deleteSelectedShapes:od,mode:Sr}),Km(()=>{if(!Ze)return;let Ot=mi=>{(mi.target instanceof Element?mi.target:null)?.closest(".overlay-shape-context-menu, .overlay-shape-context-submenu-panel")||vt(null)},Jr=mi=>{mi.key==="Escape"&&vt(null)};return window.addEventListener("pointerdown",Ot,!0),window.addEventListener("keydown",Jr),()=>{window.removeEventListener("pointerdown",Ot,!0),window.removeEventListener("keydown",Jr)}},[Ze]),aZn({getBlockAnchorScope:Pu,activeTextEditorRef:ma,shapesRef:xe,selectedIdsRef:Mt,reanchorShapesToCopiedBlocks:lC,assetsRef:Y,documentIdRef:re,getRemovableSelectedShapeIds:Eg,pendingOverlaySaveHistoryGroupRef:se,deleteSelectedShapes:od,applyPastedOverlayShapes:hm});let{updateOriginPickPreviewFromEvent:Fn,handleOriginPickPointerDown:nn,handleGraphFillPickPointerDown:rn}=XKn({shapesRef:xe,pagePointFromClient:Jn,originPickShapeId:cn,setOriginPickPreview:hn,updateGraphShapeSpec:mm,queueOverlaySave:Zc,transitionMode:Fi,graphFillPickShapeId:xt}),tn=Mbe(()=>({getSnappedDrawingPoint:zS,finishCurveDrawing:fb,getSnappedInsertDragPoint:Pt,createShapeFromInsertDrag:Dv}),[zS,fb,Pt,Dv]),or=Mbe(()=>({applyMoveInteractionAtPoint:Sl,applyResizeInteractionAtPoint:gm,applyPointInteractionAtPoint:He,applyImageCropInteractionAtPoint:it}),[Sl,gm,He,it]),{handleCurveDrawingDoubleClick:Zr,handleCanvasPointerDown:pi,handleShapePointerDown:Ba,handleResizePointerDown:ts,handleImageCropResizePointerDown:ke,handleRotatePointerDown:fi,handlePointPointerDown:Ig,handleLineInsertPointerDown:aa,handleAnchorPointerDown:ip}=wZn({session:Ma,editing:gb,selection:_T,geometry:yb,drawing:tn,focusOverlayCanvas:Ke,setAdjustmentDragReadoutPointerPosition:Qn,graphFillPickShapeId:xt,selectedRegion:mt}),{handlePointerMove:Ul,handlePointerCancel:ym,handlePointerUp:K1}=yZn({session:Ma,editing:gb,selection:_T,geometry:yb,drawing:tn,transforms:or,clearSnapGuides:Eu,setAdjustmentDragReadoutPointerPosition:Qn,canvasRef:Zn,autoScrollPanBy:b,autoScrollViewportElement:x,originPickShapeId:cn,updateOriginPickPreviewFromEvent:Fn,setHoverSolidEdge:Qe,mode:Sr,cancelTablePlacement:Bu,restoreTransientInteraction:Bf,setRegionSelection:_e,handledCommandRequestIdRef:Go,queueOverlaySave:Zc,documentId:t,onRequestTextMode:M,retainEmptySelection:_,externalRevision:e,onRequestTextSelection:L,queueDirtyImageCropSave:Ns}),{movingShapeIds:tc,selectedShapes:ro,currentTool:cl,selectionChromeHidden:Hs,selectionImageCropShape:bm,selectedDimensionShapes:ad,selectionBounds:sd,selectionCanResize:C6,selectedLocked:OT,selectionIsGraphCropping:Pg,selectionIsGraph3DEditing:NT,selectionCanRotate:xm,anchorIndicators:cC,marqueeBounds:ul,insertPreview:vm,curveDrawing:ld,curveDrawingClosed:uC,adjustmentDragReadout:Y1,drawingHint:Ev}=_Zn({shapes:G,selectedIds:de,assets:fe,editPolicyLockedShapeIds:mo,mode:Sr,initialOriginPickShapeId:an,selectedRegion:mt,dragOffset:_t,publishesSessionPresence:J,documentSession:K,tShape:te,adjustmentDragReadoutPointerPosition:ti,shapeStyleDefaults:bn,showAnchorHandles:y,anchorMeasurements:bt,canvasWidth:r,canvasHeight:o,bleedValues:a,onSelectionSummaryChange:O,solidEdge:be,acceptsStylePreview:T,setPreview:Oe,shapesRef:xe,selectedIdsRef:Mt,editPolicyLockedShapeIdsRef:Si}),{backgroundVisibleShapes:Lf,chartSourceTables:$1,foregroundVisibleShapes:Mg,selectedIdSet:dC}=qZn({selectedIds:de,preview:he,shapes:G,visibleOriginPickPreview:xr,movingShapeIds:tc,editingShapeId:Gt,graphFillPickShapeId:xt,initialOriginPickShapeId:an,visiblePageRange:p,pageHeightPx:m,pageGapPx:h}),cd=Ze?ro.length:0,{convertSvg:f0,svgConversionMessage:zT}=WXn({documentId:t,shapesRef:xe,assetsRef:Y,extensionsRef:oe,editPolicyLockedShapeIdsRef:Si,explicitlySavedShapeStatesRef:$e,notifyEditPolicyBlocked:ni,setShapes:ie,setAssets:$,setSelectedShapeIds:zs,commitOverlayChangeNow:Lc,readAssetSource:async Ot=>await K?.readAssetSource?.(Ot)??K?.resolveAssetSource?.(Ot)??Ot,tShape:te}),sa=cd>=2,Iv=cd>0&&ro.some(wh),Bg=cd>=2,A6=cd>=3,US=cd===1&&yj(ro[0]),nc=cd===1&&ro[0]?.type==="image"?ro[0]:null,_u=cd===1&&ro[0]?.type==="graph2dShape"?ro[0]:null,bb=cd===1&&ro[0]?.type==="graph3dShape"?ro[0]:null,pC=cd===1&&ro[0]?.type==="tableShape"?ro[0]:null,HS=cd===1&&ro[0]?.type==="chartShape"?ro[0]:null,Pv=!!(nc&&!Ac(G,nc)&&!Js(G,nc,mo)),Lg=!!(_u&&!Ac(G,_u)&&!Js(G,_u,mo)),Z3=!!(bb&&!Ac(G,bb)&&!Js(G,bb,mo)),{handleCanvasContextMenu:m0,handleCanvasDoubleClick:Xp,handleShapeDoubleClick:h0,runContextMenuAction:yc,changeSelectedShapeType:J3}=pKn({shapesRef:xe,selectedIdsRef:Mt,editPolicyLockedShapeIdsRef:Si,notifyEditPolicyBlocked:ni,setShapes:ie,transitionMode:Fi,queueOverlaySave:Zc,extendedActionRunnerRef:p0,applyQuickTransformToSelectedShapes:NS,startImageCrop:Mu,requestImageReplacement:pu,resetImageCrop:wo,restoreImageNaturalSize:Va,createChartFromTable:dh,handleCurveDrawingDoubleClick:Zr,suppressNextShapeDoubleClickRef:dm,graphFillPickShapeId:xt,pagePointFromClient:Jn,focusedGroupIdRef:Ct,setFocusedGroupId:gt,setSelectedShapeIds:zs,selectShape:vl,modeRef:qi,getShapeAtPoint:fu,getOpenStrokeShapeAtPoint:Ru,getEditableTextShapeAtPoint:rp,setContextMenu:vt,focusOverlayCanvas:Ke}),{handleTableChange:T6,handleTableEditorFocus:fh,handleTableFirstCellReady:xb,handleTableResize:GS,handleTextMeasuredHeight:Mv,handleTextChange:vb,handleTextEditorCancel:Sb,handleTextEditorFocus:IN,handleGraphSpecChange:PN,handleGraphCropEnd:D6}=NZn({activeTextEditorRef:ma,selectShape:vl,transitionMode:Fi,shapesRef:xe,updateShape:Dd,updateGraphShapeSpec:mm,insertedTableFocusRef:qe}),fC=Ot=>yi(Ot).y+(tc?.has(Ot.id)?_t?.y??0:0),Rg=(sd?.y??0)+(tc?_t?.y??0:0),UT=XJn({onCreateChartFromTable:dh,onGraph3DCameraChange:Vp,onGraph3DObjectRotationChange:zl,onGraph3DObjectTransformChange:hb,onGraph3DPreviewReady:ph,onTableChange:T6,onTableEditorFocus:fh,onTableFirstCellReady:xb,onTableResize:GS,onTextMeasuredHeight:Mv,onTextChange:vb,onTextEditorCancel:Sb,onTextEditorFocus:IN});return gl("div",{ref:Kn,className:"overlay-canvas-bleed-surface",onPointerDownCapture:Ot=>{nn(Ot),rn(Ot)},onPointerDown:pi,onPointerMove:Ul,onPointerCancel:ym,onPointerLeave:()=>{Qe(null),cn&&hn(null)},onPointerUp:K1,onContextMenu:m0,onDoubleClick:Xp,tabIndex:-1,children:Xri("div",{ref:Zn,className:["overlay-canvas-editor",cn?"origin-picking":"",an?"initial-origin-picking":"",xt?"graph-fill-picking":"",cl.kind==="insert"?"inserting":""].filter(Boolean).join(" "),"data-overlay-insert-command":cl.kind==="insert"?cl.command:void 0,children:[cl.kind==="insert"&&i&&gl("div",{className:"overlay-insertion-surface","aria-hidden":"true",style:{left:i.x,top:i.y,width:i.w,height:i.h}}),gl("input",{ref:q1,type:"file",accept:uNe,hidden:!0,"data-testid":"overlay-image-replacement-input",onChange:Ot=>{ec(Ot)}}),S&&Lf.length>0&&xze(gl("div",{className:"overlay-canvas-bleed-surface background","aria-hidden":"true",children:gl("div",{className:"overlay-canvas-editor background",children:Lf.map(Ot=>gl(Gd,{arrangement:to,y:fC(Ot),children:gl(GNe,{shape:Ot,assets:fe,chartSourceTable:$1.get(Ot.id)??null,externalRevision:Bo,selected:!1,editing:!1,disableGraphCrop:!0,hideGraphAxes:!1,originPickPreview:null,dragTranslate:tc?.has(Ot.id)?_t:null,onPointerDown:GCt,onDoubleClick:jCt,onGraphSpecChange:Mye,onGraphCropEnd:Bye,diffClassName:ee?.get(Ot.id),decoration:Z?.get(Ot.id)??null,textPaintRevision:qJn(Ot,f)})},Ot.id))})}),S),Mg.map(Ot=>gl(Gd,{arrangement:to,y:fC(Ot),children:gl(GNe,{shape:Ot,assets:fe,chartSourceTable:$1.get(Ot.id)??null,externalRevision:Bo,selected:dC.has(Ot.id),editing:Gt===Ot.id,disableGraphCrop:!!xt,hideGraphAxes:an===Ot.id,originPickPreview:xr?.shapeId===Ot.id?xr:null,dragTranslate:tc?.has(Ot.id)?_t:null,onPointerDown:Ba,onDoubleClick:h0,onGraphSpecChange:PN,onGraphCropEnd:D6,diffClassName:ee?.get(Ot.id),decoration:Z?.get(Ot.id)??null,editorRenderers:UT,onTextMeasuredHeight:Mv,textPaintRevision:qJn(Ot,f)})},Ot.id)),gl(Gd,{arrangement:to,y:Rg,children:gl(aWn,{shapes:Hs||bm?[]:ad,dragTranslate:_t,movingShapeIds:tc})}),Lf.map(Ot=>gl(Gd,{arrangement:to,y:fC(Ot),children:gl(sWn,{shape:Ot,selected:dC.has(Ot.id),dragTranslate:tc?.has(Ot.id)?_t:null,onPointerDown:Ba,onDoubleClick:h0})},`${Ot.id}-hit-target`)),sd&&ro.length>0&&!Hs&&gl(Gd,{arrangement:to,y:Rg,children:gl(MWn,{shapes:ro,allShapes:G,bounds:sd,resizable:C6&&!OT&&!Pg&&!NT,rotatable:xm&&!OT&&!Pg&&!NT,cropShape:bm,dragTranslate:_t,movingShapeIds:tc,onResizePointerDown:ts,onImageCropResizePointerDown:ke,onRotatePointerDown:fi,onPointPointerDown:Ig,onLineInsertPointerDown:aa,solidEdge:be&&ro.length===1&&ro[0].id===be.shapeId?be.index:null,solidHoverEdge:Re&&ro.length===1&&ro[0].id===Re.shapeId?Re.index:null})}),cC.length>0&&!Hs&&!bm&&gl(PWn,{indicators:cC,onAnchorPointerDown:ip,arrangement:to}),ul&&gl(Gd,{arrangement:to,y:ul.y,children:gl("div",{className:"overlay-marquee-box","data-retained-region":mt?"true":void 0,style:{left:ul.x,top:ul.y,width:ul.w,height:ul.h}})}),Sr.id==="overlay.select"&&cl.kind==="insert"&&cl.command==="table"&&!_ye()&&gl(cWn,{tool:cl,surfaceRef:Kn,pointFromClient:Jn,assets:fe,styleDefaults:J9("table",bn),arrangement:to}),vm&&!(vm.tool.command==="table"&&_ye())&&gl(Gd,{arrangement:to,y:vm.start.y,children:gl(XCt,{tool:vm.tool,start:vm.start,current:vm.current,points:vm.points,closed:vm.closed,bounds:vm.bounds,assets:fe,styleDefaults:J9(vm.tool.command,bn)})}),ld&&gl(Gd,{arrangement:to,y:ld.points[0]?.y??ld.current?.y??0,children:gl(dWn,{points:ld.points,current:ld.current,closeArmed:uC})}),Y1&&gl(Gd,{arrangement:to,y:Y1.position.y,children:gl(mWn,{...Y1})}),Kt.length>0&&gl(Gd,{arrangement:to,y:Rg,children:gl(Vri,{guides:Kt})}),es&&gl("p",{className:ne.blockedNoticeClassName,role:"status","aria-live":"polite",children:es}),Ev!==null&&typeof document<"u"&&xze(gl("div",{className:"overlay-drawing-hint",role:"status","data-testid":"overlay-drawing-hint",children:Ev}),document.body),zT&&typeof document<"u"&&xze(gl("div",{className:"overlay-drawing-hint",role:"status","aria-live":"polite","data-testid":"svg-conversion-message",children:zT}),document.body),Ze&&cd>0&&typeof document<"u"&&xze(gl(EXn,{x:Ze.x,y:Ze.y,canGroup:sa,canUngroup:Iv,canAlign:Bg,canDistribute:A6,canChangeShapeType:US,imageHasCrop:!!nc?.props.crop,imageEditable:Pv,imageOpacity:Yo(nc?.opacity??1,0,1),graphEditable:Lg,graphCanFill:_u?.props.spec.kind==="cartesian",graph3dEditable:Z3,onCreateChartFromTable:pC?()=>yc(()=>{dh(pC.id)}):void 0,onChartSettings:HS?()=>yc(()=>{zs([HS.id]),window.dispatchEvent(new CustomEvent(w_,{detail:{shapeId:HS.id}}))}):void 0,onGraph3DSettings:bb?()=>yc(()=>{zs([bb.id]),Fi({type:"editGraph3D",shapeId:bb.id}),window.dispatchEvent(new CustomEvent(lE,{detail:{shapeId:bb.id}}))}):void 0,onGraphSettings:_u?()=>yc(()=>{window.dispatchEvent(new CustomEvent(Pj,{detail:{shapeId:_u.id}}))}):void 0,onGraphCrop:_u?()=>yc(()=>{zs([_u.id]),Fi({type:"editGraph",shapeId:_u.id})}):void 0,onGraphOriginPick:_u?()=>yc(()=>{zs([_u.id]),Fi({type:"pickOrigin",shapeId:_u.id})}):void 0,onGraphFillPick:_u?()=>yc(()=>{zs([_u.id]),Fi({type:"pickGraphFill",shapeId:_u.id})}):void 0,onImageCrop:nc?()=>yc(()=>Mu(nc.id)):void 0,onImageReplace:nc?()=>yc(()=>pu(nc.id)):void 0,onImageResetCrop:nc?()=>yc(()=>wo(nc.id)):void 0,onImageNaturalSize:nc?()=>yc(()=>Va(nc.id)):void 0,onSvgConvert:nc&&sz(fe[nc.props.assetId])?()=>yc(()=>{f0(nc.id)}):void 0,onImageOpacityChange:nc?Ot=>Us(nc.id,Ot):void 0,onDuplicate:()=>yc(()=>Ss()),onDelete:()=>yc(od),onGroup:()=>yc(op),onUngroup:()=>yc(mu),arrangeShortcutLabels:A,onArrange:Ot=>yc(()=>Nl(Ot)),onTransform:Ot=>yc(()=>NS(Ot)),onAlign:Ot=>yc(()=>Dg(Ot)),onDistribute:Ot=>yc(()=>id(Ot)),onChangeShapeType:Ot=>yc(()=>J3(Ot)),onSaveAsMaterial:U?()=>yc(U):void 0}),document.body)]})})}function Vri({guides:e}){let t=e.filter(n=>n.type==="line");return t.length===0?null:gl("svg",{className:"overlay-snap-guides","aria-hidden":"true",children:t.map((n,r)=>gl("line",{className:"overlay-snap-guide-line",x1:n.axis==="x"?n.value:n.start,y1:n.axis==="x"?n.start:n.value,x2:n.axis==="x"?n.value:n.end,y2:n.axis==="x"?n.end:n.value},`line-${n.axis}-${n.value}-${r}`))})}var Hri,uDt,Gri,jri,Bbe=X(()=>{"use strict";"use client";IXn();qXn();Wce();XNe();gWn();KNe();gte();tAt();aAt();Oye();fKn();gKn();MKn();UKn();WKn();YKn();j$n();W$n();K$n();Q$n();sZn();cZn();dZn();mZn();bZn();SZn();FZn();AZn();MZn();OZn();zZn();HZn();WZn();KZn();u4();sE();Bj();Pn();Dn();un();tj();My();A_();RTt();$Zn();I9e();JZn();eJn();Tc();yte();jh();Ly();M9e();WJn();vte();fte();bte();Yx();m_();dj();v_();cDt();vte();DTt();sze();sze();Hri=14,uDt=8,Gri=16,jri={rects:new Map,ordered:[]}});var gHe=Fo((Ssr,WEt)=>{(function(e){typeof Ssr=="object"&&typeof WEt<"u"?WEt.exports=e():typeof define=="function"&&define.amd?define([],e):(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).JSZip=e()})(function(){return(function e(t,n,r){function o(s,l){if(!n[s]){if(!t[s]){var c=typeof Ng=="function"&&Ng;if(!l&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(p){var f=t[s][1][p];return o(f||p)},d,d.exports,e,t,n,r)}return n[s].exports}for(var i=typeof Ng=="function"&&Ng,a=0;a<r.length;a++)o(r[a]);return o})({1:[function(e,t,n){"use strict";var r=e("./utils"),o=e("./support"),i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(a){for(var s,l,c,u,d,p,f,m=[],h=0,g=a.length,y=g,b=r.getTypeOf(a)!=="string";h<a.length;)y=g-h,c=b?(s=a[h++],l=h<g?a[h++]:0,h<g?a[h++]:0):(s=a.charCodeAt(h++),l=h<g?a.charCodeAt(h++):0,h<g?a.charCodeAt(h++):0),u=s>>2,d=(3&s)<<4|l>>4,p=1<y?(15&l)<<2|c>>6:64,f=2<y?63&c:64,m.push(i.charAt(u)+i.charAt(d)+i.charAt(p)+i.charAt(f));return m.join("")},n.decode=function(a){var s,l,c,u,d,p,f=0,m=0,h="data:";if(a.substr(0,h.length)===h)throw new Error("Invalid base64 input, it looks like a data url.");var g,y=3*(a=a.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(a.charAt(a.length-1)===i.charAt(64)&&y--,a.charAt(a.length-2)===i.charAt(64)&&y--,y%1!=0)throw new Error("Invalid base64 input, bad content length.");for(g=o.uint8array?new Uint8Array(0|y):new Array(0|y);f<a.length;)s=i.indexOf(a.charAt(f++))<<2|(u=i.indexOf(a.charAt(f++)))>>4,l=(15&u)<<4|(d=i.indexOf(a.charAt(f++)))>>2,c=(3&d)<<6|(p=i.indexOf(a.charAt(f++))),g[m++]=s,d!==64&&(g[m++]=l),p!==64&&(g[m++]=c);return g}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var r=e("./external"),o=e("./stream/DataWorker"),i=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function s(l,c,u,d,p){this.compressedSize=l,this.uncompressedSize=c,this.crc32=u,this.compression=d,this.compressedContent=p}s.prototype={getContentWorker:function(){var l=new o(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),c=this;return l.on("end",function(){if(this.streamInfo.data_length!==c.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),l},getCompressedWorker:function(){return new o(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},s.createWorkerFrom=function(l,c,u){return l.pipe(new i).pipe(new a("uncompressedSize")).pipe(c.compressWorker(u)).pipe(new a("compressedSize")).withStreamInfo("compression",c)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var r=e("./utils"),o=(function(){for(var i,a=[],s=0;s<256;s++){i=s;for(var l=0;l<8;l++)i=1&i?3988292384^i>>>1:i>>>1;a[s]=i}return a})();t.exports=function(i,a){return i!==void 0&&i.length?r.getTypeOf(i)!=="string"?(function(s,l,c,u){var d=o,p=u+c;s^=-1;for(var f=u;f<p;f++)s=s>>>8^d[255&(s^l[f])];return-1^s})(0|a,i,i.length,0):(function(s,l,c,u){var d=o,p=u+c;s^=-1;for(var f=u;f<p;f++)s=s>>>8^d[255&(s^l.charCodeAt(f))];return-1^s})(0|a,i,i.length,0):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var r=null;r=typeof Promise<"u"?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){"use strict";var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=e("pako"),i=e("./utils"),a=e("./stream/GenericWorker"),s=r?"uint8array":"array";function l(c,u){a.call(this,"FlateWorker/"+c),this._pako=null,this._pakoAction=c,this._pakoOptions=u,this.meta={}}n.magic="\b\0",i.inherits(l,a),l.prototype.processChunk=function(c){this.meta=c.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(s,c.data),!1)},l.prototype.flush=function(){a.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var c=this;this._pako.onData=function(u){c.push({data:u,meta:c.meta})}},n.compressWorker=function(c){return new l("Deflate",c)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function r(d,p){var f,m="";for(f=0;f<p;f++)m+=String.fromCharCode(255&d),d>>>=8;return m}function o(d,p,f,m,h,g){var y,b,x=d.file,v=d.compression,S=g!==s.utf8encode,F=i.transformTo("string",g(x.name)),w=i.transformTo("string",s.utf8encode(x.name)),C=x.comment,A=i.transformTo("string",g(C)),T=i.transformTo("string",s.utf8encode(C)),D=w.length!==x.name.length,k=T.length!==C.length,P="",I="",B="",M=x.dir,L=x.date,_={crc32:0,compressedSize:0,uncompressedSize:0};p&&!f||(_.crc32=d.crc32,_.compressedSize=d.compressedSize,_.uncompressedSize=d.uncompressedSize);var R=0;p&&(R|=8),S||!D&&!k||(R|=2048);var O=0,N=0;M&&(O|=16),h==="UNIX"?(N=798,O|=(function(U,H){var V=U;return U||(V=H?16893:33204),(65535&V)<<16})(x.unixPermissions,M)):(N=20,O|=(function(U){return 63&(U||0)})(x.dosPermissions)),y=L.getUTCHours(),y<<=6,y|=L.getUTCMinutes(),y<<=5,y|=L.getUTCSeconds()/2,b=L.getUTCFullYear()-1980,b<<=4,b|=L.getUTCMonth()+1,b<<=5,b|=L.getUTCDate(),D&&(I=r(1,1)+r(l(F),4)+w,P+="up"+r(I.length,2)+I),k&&(B=r(1,1)+r(l(A),4)+T,P+="uc"+r(B.length,2)+B);var z="";return z+=`
8840
8840
  \0`,z+=r(R,2),z+=v.magic,z+=r(y,2),z+=r(b,2),z+=r(_.crc32,4),z+=r(_.compressedSize,4),z+=r(_.uncompressedSize,4),z+=r(F.length,2),z+=r(P.length,2),{fileRecord:c.LOCAL_FILE_HEADER+z+F+P,dirRecord:c.CENTRAL_FILE_HEADER+r(N,2)+z+r(A.length,2)+"\0\0\0\0"+r(O,4)+r(m,4)+F+P+A}}var i=e("../utils"),a=e("../stream/GenericWorker"),s=e("../utf8"),l=e("../crc32"),c=e("../signature");function u(d,p,f,m){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=f,this.encodeFileName=m,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(u,a),u.prototype.push=function(d){var p=d.meta.percent||0,f=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,a.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:f?(p+100*(f-m-1))/f:100}}))},u.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var p=this.streamFiles&&!d.file.dir;if(p){var f=o(d,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(d){this.accumulate=!1;var p=this.streamFiles&&!d.file.dir,f=o(d,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),p)this.push({data:(function(m){return c.DATA_DESCRIPTOR+r(m.crc32,4)+r(m.compressedSize,4)+r(m.uncompressedSize,4)})(d),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var d=this.bytesWritten,p=0;p<this.dirRecords.length;p++)this.push({data:this.dirRecords[p],meta:{percent:100}});var f=this.bytesWritten-d,m=(function(h,g,y,b,x){var v=i.transformTo("string",x(b));return c.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(h,2)+r(h,2)+r(g,4)+r(y,4)+r(v.length,2)+v})(this.dirRecords.length,f,d,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},u.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},u.prototype.registerPrevious=function(d){this._sources.push(d);var p=this;return d.on("data",function(f){p.processChunk(f)}),d.on("end",function(){p.closedSource(p.previous.streamInfo),p._sources.length?p.prepareNextSource():p.end()}),d.on("error",function(f){p.error(f)}),this},u.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},u.prototype.error=function(d){var p=this._sources;if(!a.prototype.error.call(this,d))return!1;for(var f=0;f<p.length;f++)try{p[f].error(d)}catch{}return!0},u.prototype.lock=function(){a.prototype.lock.call(this);for(var d=this._sources,p=0;p<d.length;p++)d[p].lock()},t.exports=u},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,n){"use strict";var r=e("../compressions"),o=e("./ZipFileWorker");n.generateWorker=function(i,a,s){var l=new o(a.streamFiles,s,a.platform,a.encodeFileName),c=0;try{i.forEach(function(u,d){c++;var p=(function(g,y){var b=g||y,x=r[b];if(!x)throw new Error(b+" is not a valid compression method !");return x})(d.options.compression,a.compression),f=d.options.compressionOptions||a.compressionOptions||{},m=d.dir,h=d.date;d._compressWorker(p,f).withStreamInfo("file",{name:u,dir:m,date:h,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(l)}),l.entriesCount=c}catch(u){l.error(u)}return l}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,n){"use strict";function r(){if(!(this instanceof r))return new r;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new r;for(var i in this)typeof this[i]!="function"&&(o[i]=this[i]);return o}}(r.prototype=e("./object")).loadAsync=e("./load"),r.support=e("./support"),r.defaults=e("./defaults"),r.version="3.10.2",r.loadAsync=function(o,i){return new r().loadAsync(o,i)},r.external=e("./external"),t.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,n){"use strict";var r=e("./utils"),o=e("./external"),i=e("./utf8"),a=e("./zipEntries"),s=e("./stream/Crc32Probe"),l=e("./nodejsUtils");function c(u){return new o.Promise(function(d,p){var f=u.decompressed.getContentWorker().pipe(new s);f.on("error",function(m){p(m)}).on("end",function(){f.streamInfo.crc32!==u.decompressed.crc32?p(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}t.exports=function(u,d){var p=this;return d=r.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:i.utf8decode}),l.isNode&&l.isStream(u)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",u,!0,d.optimizedBinaryString,d.base64).then(function(f){var m=new a(d);return m.load(f),m}).then(function(f){var m=[o.Promise.resolve(f)],h=f.files;if(d.checkCRC32)for(var g=0;g<h.length;g++)m.push(c(h[g]));return o.Promise.all(m)}).then(function(f){for(var m=f.shift(),h=m.files,g=0;g<h.length;g++){var y=h[g],b=y.fileNameStr,x=r.resolve(y.fileNameStr);p.file(x,y.decompressed,{binary:!0,optimizedBinaryString:!0,date:y.date,dir:y.dir,comment:y.fileCommentStr.length?y.fileCommentStr:null,unixPermissions:y.unixPermissions,dosPermissions:y.dosPermissions,createFolders:d.createFolders}),y.dir||(p.file(x).unsafeOriginalName=b)}return m.zipComment.length&&(p.comment=m.zipComment),p})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,n){"use strict";var r=e("../utils"),o=e("../stream/GenericWorker");function i(a,s){o.call(this,"Nodejs stream input adapter for "+a),this._upstreamEnded=!1,this._bindStream(s)}r.inherits(i,o),i.prototype._bindStream=function(a){var s=this;(this._stream=a).pause(),a.on("data",function(l){s.push({data:l,meta:{percent:0}})}).on("error",function(l){s.isPaused?this.generatedError=l:s.error(l)}).on("end",function(){s.isPaused?s._upstreamEnded=!0:s.end()})},i.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},i.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=i},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,n){"use strict";var r=e("readable-stream").Readable;function o(i,a,s){r.call(this,a),this._helper=i;var l=this;i.on("data",function(c,u){l.push(c)||l._helper.pause(),s&&s(u)}).on("error",function(c){l.emit("error",c)}).on("end",function(){l.push(null)})}e("../utils").inherits(o,r),o.prototype._read=function(){this._helper.resume()},t.exports=o},{"../utils":32,"readable-stream":16}],14:[function(e,t,n){"use strict";t.exports={isNode:typeof Buffer<"u",newBufferFrom:function(r,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(r,o);if(typeof r=="number")throw new Error('The "data" argument must not be a number');return new Buffer(r,o)},allocBuffer:function(r){if(Buffer.alloc)return Buffer.alloc(r);var o=new Buffer(r);return o.fill(0),o},isBuffer:function(r){return Buffer.isBuffer(r)},isStream:function(r){return r&&typeof r.on=="function"&&typeof r.pause=="function"&&typeof r.resume=="function"}}},{}],15:[function(e,t,n){"use strict";function r(x,v,S){var F,w=i.getTypeOf(v),C=i.extend(S||{},l);C.date=C.date||new Date,C.compression!==null&&(C.compression=C.compression.toUpperCase()),typeof C.unixPermissions=="string"&&(C.unixPermissions=parseInt(C.unixPermissions,8)),C.unixPermissions&&16384&C.unixPermissions&&(C.dir=!0),C.dosPermissions&&16&C.dosPermissions&&(C.dir=!0),C.dir&&(x=h(x)),C.createFolders&&(F=m(x))&&g.call(this,F,!0);var A=w==="string"&&C.binary===!1&&C.base64===!1;S&&S.binary!==void 0||(C.binary=!A),(v instanceof c&&v.uncompressedSize===0||C.dir||!v||v.length===0)&&(C.base64=!1,C.binary=!0,v="",C.compression="STORE",w="string");var T=null;T=v instanceof c||v instanceof a?v:p.isNode&&p.isStream(v)?new f(x,v):i.prepareContent(x,v,C.binary,C.optimizedBinaryString,C.base64);var D=new u(x,T,C);this.files[x]=D}var o=e("./utf8"),i=e("./utils"),a=e("./stream/GenericWorker"),s=e("./stream/StreamHelper"),l=e("./defaults"),c=e("./compressedObject"),u=e("./zipObject"),d=e("./generate"),p=e("./nodejsUtils"),f=e("./nodejs/NodejsStreamInputAdapter"),m=function(x){x.slice(-1)==="/"&&(x=x.substring(0,x.length-1));var v=x.lastIndexOf("/");return 0<v?x.substring(0,v):""},h=function(x){return x.slice(-1)!=="/"&&(x+="/"),x},g=function(x,v){return v=v!==void 0?v:l.createFolders,x=h(x),this.files[x]||r.call(this,x,null,{dir:!0,createFolders:v}),this.files[x]};function y(x){return Object.prototype.toString.call(x)==="[object RegExp]"}var b={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(x){var v,S,F;for(v in this.files)F=this.files[v],(S=v.slice(this.root.length,v.length))&&v.slice(0,this.root.length)===this.root&&x(S,F)},filter:function(x){var v=[];return this.forEach(function(S,F){x(S,F)&&v.push(F)}),v},file:function(x,v,S){if(arguments.length!==1)return x=this.root+x,r.call(this,x,v,S),this;if(y(x)){var F=x;return this.filter(function(C,A){return!A.dir&&F.test(C)})}var w=this.files[this.root+x];return w&&!w.dir?w:null},folder:function(x){if(!x)return this;if(y(x))return this.filter(function(w,C){return C.dir&&x.test(w)});var v=this.root+x,S=g.call(this,v),F=this.clone();return F.root=S.name,F},remove:function(x){x=this.root+x;var v=this.files[x];if(v||(x.slice(-1)!=="/"&&(x+="/"),v=this.files[x]),v&&!v.dir)delete this.files[x];else for(var S=this.filter(function(w,C){return C.name.slice(0,x.length)===x}),F=0;F<S.length;F++)delete this.files[S[F].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(x){var v,S={};try{if((S=i.extend(x||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),S.type==="binarystring"&&(S.type="string"),!S.type)throw new Error("No output type specified.");i.checkSupport(S.type),S.platform!=="darwin"&&S.platform!=="freebsd"&&S.platform!=="linux"&&S.platform!=="sunos"||(S.platform="UNIX"),S.platform==="win32"&&(S.platform="DOS");var F=S.comment||this.comment||"";v=d.generateWorker(this,S,F)}catch(w){(v=new a("error")).error(w)}return new s(v,S.type||"string",S.mimeType)},generateAsync:function(x,v){return this.generateInternalStream(x).accumulate(v)},generateNodeStream:function(x,v){return(x=x||{}).type||(x.type="nodebuffer"),this.generateInternalStream(x).toNodejsStream(v)}};t.exports=b},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,n){"use strict";t.exports=e("stream")},{stream:void 0}],17:[function(e,t,n){"use strict";var r=e("./DataReader");function o(i){r.call(this,i);for(var a=0;a<this.data.length;a++)i[a]=255&i[a]}e("../utils").inherits(o,r),o.prototype.byteAt=function(i){return this.data[this.zero+i]},o.prototype.lastIndexOfSignature=function(i){for(var a=i.charCodeAt(0),s=i.charCodeAt(1),l=i.charCodeAt(2),c=i.charCodeAt(3),u=this.length-4;0<=u;--u)if(this.data[u]===a&&this.data[u+1]===s&&this.data[u+2]===l&&this.data[u+3]===c)return u-this.zero;return-1},o.prototype.readAndCheckSignature=function(i){var a=i.charCodeAt(0),s=i.charCodeAt(1),l=i.charCodeAt(2),c=i.charCodeAt(3),u=this.readData(4);return a===u[0]&&s===u[1]&&l===u[2]&&c===u[3]},o.prototype.readData=function(i){if(this.checkOffset(i),i===0)return[];var a=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},t.exports=o},{"../utils":32,"./DataReader":18}],18:[function(e,t,n){"use strict";var r=e("../utils");function o(i){this.data=i,this.length=i.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(i){this.checkIndex(this.index+i)},checkIndex:function(i){if(this.length<this.zero+i||i<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+i+"). Corrupted zip ?")},setIndex:function(i){this.checkIndex(i),this.index=i},skip:function(i){this.setIndex(this.index+i)},byteAt:function(){},readInt:function(i){var a,s=0;for(this.checkOffset(i),a=this.index+i-1;a>=this.index;a--)s=(s<<8)+this.byteAt(a);return this.index+=i,s},readString:function(i){return r.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},t.exports=o},{"../utils":32}],19:[function(e,t,n){"use strict";var r=e("./Uint8ArrayReader");function o(i){r.call(this,i)}e("../utils").inherits(o,r),o.prototype.readData=function(i){this.checkOffset(i);var a=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},t.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var r=e("./DataReader");function o(i){r.call(this,i)}e("../utils").inherits(o,r),o.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},o.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},o.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},o.prototype.readData=function(i){this.checkOffset(i);var a=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},t.exports=o},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var r=e("./ArrayReader");function o(i){r.call(this,i)}e("../utils").inherits(o,r),o.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var a=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},t.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var r=e("../utils"),o=e("../support"),i=e("./ArrayReader"),a=e("./StringReader"),s=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(c){var u=r.getTypeOf(c);return r.checkSupport(u),u!=="string"||o.uint8array?u==="nodebuffer"?new s(c):o.uint8array?new l(r.transformTo("uint8array",c)):new i(r.transformTo("array",c)):new a(c)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,t,n){"use strict";var r=e("./GenericWorker"),o=e("../utils");function i(a){r.call(this,"ConvertWorker to "+a),this.destType=a}o.inherits(i,r),i.prototype.processChunk=function(a){this.push({data:o.transformTo(this.destType,a.data),meta:a.meta})},t.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var r=e("./GenericWorker"),o=e("../crc32");function i(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(i,r),i.prototype.processChunk=function(a){this.streamInfo.crc32=o(a.data,this.streamInfo.crc32||0),this.push(a)},t.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var r=e("../utils"),o=e("./GenericWorker");function i(a){o.call(this,"DataLengthProbe for "+a),this.propName=a,this.withStreamInfo(a,0)}r.inherits(i,o),i.prototype.processChunk=function(a){if(a){var s=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=s+a.data.length}o.prototype.processChunk.call(this,a)},t.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var r=e("../utils"),o=e("./GenericWorker");function i(a){o.call(this,"DataWorker");var s=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,a.then(function(l){s.dataIsReady=!0,s.data=l,s.max=l&&l.length||0,s.type=r.getTypeOf(l),s.isPaused||s._tickAndRepeat()},function(l){s.error(l)})}r.inherits(i,o),i.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var a=null,s=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":a=this.data.substring(this.index,s);break;case"uint8array":a=this.data.subarray(this.index,s);break;case"array":case"nodebuffer":a=this.data.slice(this.index,s)}return this.index=s,this.push({data:a,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function r(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,i){return this._listeners[o].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,i){if(this._listeners[o])for(var a=0;a<this._listeners[o].length;a++)this._listeners[o][a].call(this,i)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var i=this;return o.on("data",function(a){i.processChunk(a)}),o.on("end",function(){i.end()}),o.on("error",function(a){i.error(a)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,i){return this.extraStreamInfo[o]=i,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},t.exports=r},{}],29:[function(e,t,n){"use strict";var r=e("../utils"),o=e("./ConvertWorker"),i=e("./GenericWorker"),a=e("../base64"),s=e("../support"),l=e("../external"),c=null;if(s.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function u(p,f){return new l.Promise(function(m,h){var g=[],y=p._internalType,b=p._outputType,x=p._mimeType;p.on("data",function(v,S){g.push(v),f&&f(S)}).on("error",function(v){g=[],h(v)}).on("end",function(){try{var v=(function(S,F,w){switch(S){case"blob":return r.newBlob(r.transformTo("arraybuffer",F),w);case"base64":return a.encode(F);default:return r.transformTo(S,F)}})(b,(function(S,F){var w,C=0,A=null,T=0;for(w=0;w<F.length;w++)T+=F[w].length;switch(S){case"string":return F.join("");case"array":return Array.prototype.concat.apply([],F);case"uint8array":for(A=new Uint8Array(T),w=0;w<F.length;w++)A.set(F[w],C),C+=F[w].length;return A;case"nodebuffer":return Buffer.concat(F);default:throw new Error("concat : unsupported type '"+S+"'")}})(y,g),x);m(v)}catch(S){h(S)}g=[]}).resume()})}function d(p,f,m){var h=f;switch(f){case"blob":case"arraybuffer":h="uint8array";break;case"base64":h="string"}try{this._internalType=h,this._outputType=f,this._mimeType=m,r.checkSupport(h),this._worker=p.pipe(new o(h)),p.lock()}catch(g){this._worker=new i("error"),this._worker.error(g)}}d.prototype={accumulate:function(p){return u(this,p)},on:function(p,f){var m=this;return p==="data"?this._worker.on(p,function(h){f.call(m,h.data,h.meta)}):this._worker.on(p,function(){r.delay(f,arguments,m)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(p){if(r.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new c(this,{objectMode:this._outputType!=="nodebuffer"},p)}},t.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,n){"use strict";if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",n.nodebuffer=typeof Buffer<"u",n.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")n.blob=!1;else{var r=new ArrayBuffer(0);try{n.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(r),n.blob=o.getBlob("application/zip").size===0}catch{n.blob=!1}}}try{n.nodestream=!!e("readable-stream").Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,n){"use strict";for(var r=e("./utils"),o=e("./support"),i=e("./nodejsUtils"),a=e("./stream/GenericWorker"),s=new Array(256),l=0;l<256;l++)s[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;s[254]=s[254]=1;function c(){a.call(this,"utf-8 decode"),this.leftOver=null}function u(){a.call(this,"utf-8 encode")}n.utf8encode=function(d){return o.nodebuffer?i.newBufferFrom(d,"utf-8"):(function(p){var f,m,h,g,y,b=p.length,x=0;for(g=0;g<b;g++)(64512&(m=p.charCodeAt(g)))==55296&&g+1<b&&(64512&(h=p.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(h-56320),g++),x+=m<128?1:m<2048?2:m<65536?3:4;for(f=o.uint8array?new Uint8Array(x):new Array(x),g=y=0;y<x;g++)(64512&(m=p.charCodeAt(g)))==55296&&g+1<b&&(64512&(h=p.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(h-56320),g++),m<128?f[y++]=m:(m<2048?f[y++]=192|m>>>6:(m<65536?f[y++]=224|m>>>12:(f[y++]=240|m>>>18,f[y++]=128|m>>>12&63),f[y++]=128|m>>>6&63),f[y++]=128|63&m);return f})(d)},n.utf8decode=function(d){return o.nodebuffer?r.transformTo("nodebuffer",d).toString("utf-8"):(function(p){var f,m,h,g,y=p.length,b=new Array(2*y);for(f=m=0;f<y;)if((h=p[f++])<128)b[m++]=h;else if(4<(g=s[h]))b[m++]=65533,f+=g-1;else{for(h&=g===2?31:g===3?15:7;1<g&&f<y;)h=h<<6|63&p[f++],g--;1<g?b[m++]=65533:h<65536?b[m++]=h:(h-=65536,b[m++]=55296|h>>10&1023,b[m++]=56320|1023&h)}return b.length!==m&&(b.subarray?b=b.subarray(0,m):b.length=m),r.applyFromCharCode(b)})(d=r.transformTo(o.uint8array?"uint8array":"array",d))},r.inherits(c,a),c.prototype.processChunk=function(d){var p=r.transformTo(o.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var f=p;(p=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),p.set(f,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var m=(function(g,y){var b;for((y=y||g.length)>g.length&&(y=g.length),b=y-1;0<=b&&(192&g[b])==128;)b--;return b<0||b===0?y:b+s[g[b]]>y?b:y})(p),h=p;m!==p.length&&(o.uint8array?(h=p.subarray(0,m),this.leftOver=p.subarray(m,p.length)):(h=p.slice(0,m),this.leftOver=p.slice(m,p.length))),this.push({data:n.utf8decode(h),meta:d.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=c,r.inherits(u,a),u.prototype.processChunk=function(d){this.push({data:n.utf8encode(d.data),meta:d.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var r=e("./support"),o=e("./base64"),i=e("./nodejsUtils"),a=e("./external");function s(f){return f}function l(f,m){for(var h=0;h<f.length;++h)m[h]=255&f.charCodeAt(h);return m}e("setimmediate"),n.newBlob=function(f,m){n.checkSupport("blob");try{return new Blob([f],{type:m})}catch{try{var h=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return h.append(f),h.getBlob(m)}catch{throw new Error("Bug : can't construct the Blob.")}}};var c={stringifyByChunk:function(f,m,h){var g=[],y=0,b=f.length;if(b<=h)return String.fromCharCode.apply(null,f);for(;y<b;)m==="array"||m==="nodebuffer"?g.push(String.fromCharCode.apply(null,f.slice(y,Math.min(y+h,b)))):g.push(String.fromCharCode.apply(null,f.subarray(y,Math.min(y+h,b)))),y+=h;return g.join("")},stringifyByChar:function(f){for(var m="",h=0;h<f.length;h++)m+=String.fromCharCode(f[h]);return m},applyCanBeUsed:{uint8array:(function(){try{return r.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return r.nodebuffer&&String.fromCharCode.apply(null,i.allocBuffer(1)).length===1}catch{return!1}})()}};function u(f){var m=65536,h=n.getTypeOf(f),g=!0;if(h==="uint8array"?g=c.applyCanBeUsed.uint8array:h==="nodebuffer"&&(g=c.applyCanBeUsed.nodebuffer),g)for(;1<m;)try{return c.stringifyByChunk(f,h,m)}catch{m=Math.floor(m/2)}return c.stringifyByChar(f)}function d(f,m){for(var h=0;h<f.length;h++)m[h]=f[h];return m}n.applyFromCharCode=u;var p={};p.string={string:s,array:function(f){return l(f,new Array(f.length))},arraybuffer:function(f){return p.string.uint8array(f).buffer},uint8array:function(f){return l(f,new Uint8Array(f.length))},nodebuffer:function(f){return l(f,i.allocBuffer(f.length))}},p.array={string:u,array:s,arraybuffer:function(f){return new Uint8Array(f).buffer},uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return i.newBufferFrom(f)}},p.arraybuffer={string:function(f){return u(new Uint8Array(f))},array:function(f){return d(new Uint8Array(f),new Array(f.byteLength))},arraybuffer:s,uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return i.newBufferFrom(new Uint8Array(f))}},p.uint8array={string:u,array:function(f){return d(f,new Array(f.length))},arraybuffer:function(f){return f.buffer},uint8array:s,nodebuffer:function(f){return i.newBufferFrom(f)}},p.nodebuffer={string:u,array:function(f){return d(f,new Array(f.length))},arraybuffer:function(f){return p.nodebuffer.uint8array(f).buffer},uint8array:function(f){return d(f,new Uint8Array(f.length))},nodebuffer:s},n.transformTo=function(f,m){if(m=m||"",!f)return m;n.checkSupport(f);var h=n.getTypeOf(m);return p[h][f](m)},n.resolve=function(f){for(var m=f.split("/"),h=[],g=0;g<m.length;g++){var y=m[g];y==="."||y===""&&g!==0&&g!==m.length-1||(y===".."?h.pop():h.push(y))}return h.join("/")},n.getTypeOf=function(f){if(typeof f=="string")return"string";var m=Object.prototype.toString.call(f);return m==="[object Array]"?"array":r.nodebuffer&&i.isBuffer(f)?"nodebuffer":r.uint8array&&m==="[object Uint8Array]"?"uint8array":r.arraybuffer&&m==="[object ArrayBuffer]"?"arraybuffer":void 0},n.checkSupport=function(f){if(!r[f.toLowerCase()])throw new Error(f+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(f){var m,h,g="";for(h=0;h<(f||"").length;h++)g+="\\x"+((m=f.charCodeAt(h))<16?"0":"")+m.toString(16).toUpperCase();return g},n.delay=function(f,m,h){setImmediate(function(){f.apply(h||null,m||[])})},n.inherits=function(f,m){function h(){}h.prototype=m.prototype,f.prototype=new h},n.extend=function(){var f,m,h={};for(f=0;f<arguments.length;f++)for(m in arguments[f])Object.prototype.hasOwnProperty.call(arguments[f],m)&&h[m]===void 0&&(h[m]=arguments[f][m]);return h},n.prepareContent=function(f,m,h,g,y){return a.Promise.resolve(m).then(function(b){return r.blob&&(b instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(b))!==-1)?Blob.prototype.arrayBuffer!==void 0?b.arrayBuffer():typeof FileReader<"u"?new a.Promise(function(x,v){var S=new FileReader;S.onload=function(F){x(F.target.result)},S.onerror=function(F){v(F.target.error)},S.readAsArrayBuffer(b)}):a.Promise.reject(new Error(f+" is a Blob, but we have no way of reading it.")):b}).then(function(b){var x=n.getTypeOf(b);return x?(x==="arraybuffer"?b=n.transformTo("uint8array",b):x==="string"&&(y?b=o.decode(b):h&&g!==!0&&(b=(function(v){return l(v,r.uint8array?new Uint8Array(v.length):new Array(v.length))})(b))),b):a.Promise.reject(new Error("Can't read the data of '"+f+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,n){"use strict";var r=e("./reader/readerFor"),o=e("./utils"),i=e("./signature"),a=e("./zipEntry"),s=e("./support");function l(c){this.files=[],this.loadOptions=c}l.prototype={checkSignature:function(c){if(!this.reader.readAndCheckSignature(c)){this.reader.index-=4;var u=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(u)+", expected "+o.pretty(c)+")")}},isSignature:function(c,u){var d=this.reader.index;this.reader.setIndex(c);var p=this.reader.readString(4)===u;return this.reader.setIndex(d),p},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var c=this.reader.readData(this.zipCommentLength),u=s.uint8array?"uint8array":"array",d=o.transformTo(u,c);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var c,u,d,p=this.zip64EndOfCentralSize-44;0<p;)c=this.reader.readInt(2),u=this.reader.readInt(4),d=this.reader.readData(u),this.zip64ExtensibleData[c]={id:c,length:u,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var c,u;for(c=0;c<this.files.length;c++)u=this.files[c],this.reader.setIndex(u.localHeaderOffset),this.checkSignature(i.LOCAL_FILE_HEADER),u.readLocalPart(this.reader),u.handleUTF8(),u.processAttributes()},readCentralDir:function(){var c;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(i.CENTRAL_FILE_HEADER);)(c=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(c);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var c=this.reader.lastIndexOfSignature(i.CENTRAL_DIRECTORY_END);if(c<0)throw this.isSignature(0,i.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(c);var u=c;if(this.checkSignature(i.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(c=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(c),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,i.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var p=u-d;if(0<p)this.isSignature(u,i.CENTRAL_FILE_HEADER)||(this.reader.zero=p);else if(p<0)throw new Error("Corrupted zip: missing "+Math.abs(p)+" bytes.")},prepareReader:function(c){this.reader=r(c)},load:function(c){this.prepareReader(c),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=l},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,n){"use strict";var r=e("./reader/readerFor"),o=e("./utils"),i=e("./compressedObject"),a=e("./crc32"),s=e("./utf8"),l=e("./compressions"),c=e("./support");function u(d,p){this.options=d,this.loadOptions=p}u.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var p,f;if(d.skip(22),this.fileNameLength=d.readInt(2),f=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(f),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((p=(function(m){for(var h in l)if(Object.prototype.hasOwnProperty.call(l,h)&&l[h].magic===m)return l[h];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,p,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var p=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(p),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=r(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var p,f,m,h=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<h;)p=d.readInt(2),f=d.readInt(2),m=d.readData(f),this.extraFields[p]={id:p,length:f,value:m};d.setIndex(h)},handleUTF8:function(){var d=c.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=s.utf8decode(this.fileName),this.fileCommentStr=s.utf8decode(this.fileComment);else{var p=this.findExtraFieldUnicodePath();if(p!==null)this.fileNameStr=p;else{var f=o.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(f)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var h=o.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(h)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var p=r(d.value);return p.readInt(1)!==1||a(this.fileName)!==p.readInt(4)?null:s.utf8decode(p.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var p=r(d.value);return p.readInt(1)!==1||a(this.fileComment)!==p.readInt(4)?null:s.utf8decode(p.readData(d.length-5))}return null}},t.exports=u},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,n){"use strict";function r(p,f,m){this.name=p,this.dir=m.dir,this.date=m.date,this.comment=m.comment,this.unixPermissions=m.unixPermissions,this.dosPermissions=m.dosPermissions,this._data=f,this._dataBinary=m.binary,this.options={compression:m.compression,compressionOptions:m.compressionOptions}}var o=e("./stream/StreamHelper"),i=e("./stream/DataWorker"),a=e("./utf8"),s=e("./compressedObject"),l=e("./stream/GenericWorker");r.prototype={internalStream:function(p){var f=null,m="string";try{if(!p)throw new Error("No output type specified.");var h=(m=p.toLowerCase())==="string"||m==="text";m!=="binarystring"&&m!=="text"||(m="string"),f=this._decompressWorker();var g=!this._dataBinary;g&&!h&&(f=f.pipe(new a.Utf8EncodeWorker)),!g&&h&&(f=f.pipe(new a.Utf8DecodeWorker))}catch(y){(f=new l("error")).error(y)}return new o(f,m,"")},async:function(p,f){return this.internalStream(p).accumulate(f)},nodeStream:function(p,f){return this.internalStream(p||"nodebuffer").toNodejsStream(f)},_compressWorker:function(p,f){if(this._data instanceof s&&this._data.compression.magic===p.magic)return this._data.getCompressedWorker();var m=this._decompressWorker();return this._dataBinary||(m=m.pipe(new a.Utf8EncodeWorker)),s.createWorkerFrom(m,p,f)},_decompressWorker:function(){return this._data instanceof s?this._data.getContentWorker():this._data instanceof l?this._data:new i(this._data)}};for(var c=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],u=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<c.length;d++)r.prototype[c[d]]=u;t.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,n){(function(r){"use strict";var o,i,a=r.MutationObserver||r.WebKitMutationObserver;if(a){var s=0,l=new a(p),c=r.document.createTextNode("");l.observe(c,{characterData:!0}),o=function(){c.data=s=++s%2}}else if(r.setImmediate||r.MessageChannel===void 0)o="document"in r&&"onreadystatechange"in r.document.createElement("script")?function(){var f=r.document.createElement("script");f.onreadystatechange=function(){p(),f.onreadystatechange=null,f.parentNode.removeChild(f),f=null},r.document.documentElement.appendChild(f)}:function(){setTimeout(p,0)};else{var u=new r.MessageChannel;u.port1.onmessage=p,o=function(){u.port2.postMessage(0)}}var d=[];function p(){var f,m;i=!0;for(var h=d.length;h;){for(m=d,d=[],f=-1;++f<h;)m[f]();h=d.length}i=!1}t.exports=function(f){d.push(f)!==1||i||o()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,t,n){"use strict";var r=e("immediate");function o(){}var i={},a=["REJECTED"],s=["FULFILLED"],l=["PENDING"];function c(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,h!==o&&f(this,h)}function u(h,g,y){this.promise=h,typeof g=="function"&&(this.onFulfilled=g,this.callFulfilled=this.otherCallFulfilled),typeof y=="function"&&(this.onRejected=y,this.callRejected=this.otherCallRejected)}function d(h,g,y){r(function(){var b;try{b=g(y)}catch(x){return i.reject(h,x)}b===h?i.reject(h,new TypeError("Cannot resolve promise with itself")):i.resolve(h,b)})}function p(h){var g=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof g=="function")return function(){g.apply(h,arguments)}}function f(h,g){var y=!1;function b(S){y||(y=!0,i.reject(h,S))}function x(S){y||(y=!0,i.resolve(h,S))}var v=m(function(){g(x,b)});v.status==="error"&&b(v.value)}function m(h,g){var y={};try{y.value=h(g),y.status="success"}catch(b){y.status="error",y.value=b}return y}(t.exports=c).prototype.finally=function(h){if(typeof h!="function")return this;var g=this.constructor;return this.then(function(y){return g.resolve(h()).then(function(){return y})},function(y){return g.resolve(h()).then(function(){throw y})})},c.prototype.catch=function(h){return this.then(null,h)},c.prototype.then=function(h,g){if(typeof h!="function"&&this.state===s||typeof g!="function"&&this.state===a)return this;var y=new this.constructor(o);return this.state!==l?d(y,this.state===s?h:g,this.outcome):this.queue.push(new u(y,h,g)),y},u.prototype.callFulfilled=function(h){i.resolve(this.promise,h)},u.prototype.otherCallFulfilled=function(h){d(this.promise,this.onFulfilled,h)},u.prototype.callRejected=function(h){i.reject(this.promise,h)},u.prototype.otherCallRejected=function(h){d(this.promise,this.onRejected,h)},i.resolve=function(h,g){var y=m(p,g);if(y.status==="error")return i.reject(h,y.value);var b=y.value;if(b)f(h,b);else{h.state=s,h.outcome=g;for(var x=-1,v=h.queue.length;++x<v;)h.queue[x].callFulfilled(g)}return h},i.reject=function(h,g){h.state=a,h.outcome=g;for(var y=-1,b=h.queue.length;++y<b;)h.queue[y].callRejected(g);return h},c.resolve=function(h){return h instanceof this?h:i.resolve(new this(o),h)},c.reject=function(h){var g=new this(o);return i.reject(g,h)},c.all=function(h){var g=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=h.length,b=!1;if(!y)return this.resolve([]);for(var x=new Array(y),v=0,S=-1,F=new this(o);++S<y;)w(h[S],S);return F;function w(C,A){g.resolve(C).then(function(T){x[A]=T,++v!==y||b||(b=!0,i.resolve(F,x))},function(T){b||(b=!0,i.reject(F,T))})}},c.race=function(h){var g=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=h.length,b=!1;if(!y)return this.resolve([]);for(var x=-1,v=new this(o);++x<y;)S=h[x],g.resolve(S).then(function(F){b||(b=!0,i.resolve(v,F))},function(F){b||(b=!0,i.reject(v,F))});var S;return v}},{immediate:36}],38:[function(e,t,n){"use strict";var r={};(0,e("./lib/utils/common").assign)(r,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,n){"use strict";var r=e("./zlib/deflate"),o=e("./utils/common"),i=e("./utils/strings"),a=e("./zlib/messages"),s=e("./zlib/zstream"),l=Object.prototype.toString,c=0,u=-1,d=0,p=8;function f(h){if(!(this instanceof f))return new f(h);this.options=o.assign({level:u,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},h||{});var g=this.options;g.raw&&0<g.windowBits?g.windowBits=-g.windowBits:g.gzip&&0<g.windowBits&&g.windowBits<16&&(g.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var y=r.deflateInit2(this.strm,g.level,g.method,g.windowBits,g.memLevel,g.strategy);if(y!==c)throw new Error(a[y]);if(g.header&&r.deflateSetHeader(this.strm,g.header),g.dictionary){var b;if(b=typeof g.dictionary=="string"?i.string2buf(g.dictionary):l.call(g.dictionary)==="[object ArrayBuffer]"?new Uint8Array(g.dictionary):g.dictionary,(y=r.deflateSetDictionary(this.strm,b))!==c)throw new Error(a[y]);this._dict_set=!0}}function m(h,g){var y=new f(g);if(y.push(h,!0),y.err)throw y.msg||a[y.err];return y.result}f.prototype.push=function(h,g){var y,b,x=this.strm,v=this.options.chunkSize;if(this.ended)return!1;b=g===~~g?g:g===!0?4:0,typeof h=="string"?x.input=i.string2buf(h):l.call(h)==="[object ArrayBuffer]"?x.input=new Uint8Array(h):x.input=h,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new o.Buf8(v),x.next_out=0,x.avail_out=v),(y=r.deflate(x,b))!==1&&y!==c)return this.onEnd(y),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||b!==4&&b!==2)||(this.options.to==="string"?this.onData(i.buf2binstring(o.shrinkBuf(x.output,x.next_out))):this.onData(o.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&y!==1);return b===4?(y=r.deflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c):b!==2||(this.onEnd(c),!(x.avail_out=0))},f.prototype.onData=function(h){this.chunks.push(h)},f.prototype.onEnd=function(h){h===c&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=h,this.msg=this.strm.msg},n.Deflate=f,n.deflate=m,n.deflateRaw=function(h,g){return(g=g||{}).raw=!0,m(h,g)},n.gzip=function(h,g){return(g=g||{}).gzip=!0,m(h,g)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,n){"use strict";var r=e("./zlib/inflate"),o=e("./utils/common"),i=e("./utils/strings"),a=e("./zlib/constants"),s=e("./zlib/messages"),l=e("./zlib/zstream"),c=e("./zlib/gzheader"),u=Object.prototype.toString;function d(f){if(!(this instanceof d))return new d(f);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},f||{});var m=this.options;m.raw&&0<=m.windowBits&&m.windowBits<16&&(m.windowBits=-m.windowBits,m.windowBits===0&&(m.windowBits=-15)),!(0<=m.windowBits&&m.windowBits<16)||f&&f.windowBits||(m.windowBits+=32),15<m.windowBits&&m.windowBits<48&&(15&m.windowBits)==0&&(m.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var h=r.inflateInit2(this.strm,m.windowBits);if(h!==a.Z_OK)throw new Error(s[h]);this.header=new c,r.inflateGetHeader(this.strm,this.header)}function p(f,m){var h=new d(m);if(h.push(f,!0),h.err)throw h.msg||s[h.err];return h.result}d.prototype.push=function(f,m){var h,g,y,b,x,v,S=this.strm,F=this.options.chunkSize,w=this.options.dictionary,C=!1;if(this.ended)return!1;g=m===~~m?m:m===!0?a.Z_FINISH:a.Z_NO_FLUSH,typeof f=="string"?S.input=i.binstring2buf(f):u.call(f)==="[object ArrayBuffer]"?S.input=new Uint8Array(f):S.input=f,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new o.Buf8(F),S.next_out=0,S.avail_out=F),(h=r.inflate(S,a.Z_NO_FLUSH))===a.Z_NEED_DICT&&w&&(v=typeof w=="string"?i.string2buf(w):u.call(w)==="[object ArrayBuffer]"?new Uint8Array(w):w,h=r.inflateSetDictionary(this.strm,v)),h===a.Z_BUF_ERROR&&C===!0&&(h=a.Z_OK,C=!1),h!==a.Z_STREAM_END&&h!==a.Z_OK)return this.onEnd(h),!(this.ended=!0);S.next_out&&(S.avail_out!==0&&h!==a.Z_STREAM_END&&(S.avail_in!==0||g!==a.Z_FINISH&&g!==a.Z_SYNC_FLUSH)||(this.options.to==="string"?(y=i.utf8border(S.output,S.next_out),b=S.next_out-y,x=i.buf2string(S.output,y),S.next_out=b,S.avail_out=F-b,b&&o.arraySet(S.output,S.output,y,b,0),this.onData(x)):this.onData(o.shrinkBuf(S.output,S.next_out)))),S.avail_in===0&&S.avail_out===0&&(C=!0)}while((0<S.avail_in||S.avail_out===0)&&h!==a.Z_STREAM_END);return h===a.Z_STREAM_END&&(g=a.Z_FINISH),g===a.Z_FINISH?(h=r.inflateEnd(this.strm),this.onEnd(h),this.ended=!0,h===a.Z_OK):g!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),!(S.avail_out=0))},d.prototype.onData=function(f){this.chunks.push(f)},d.prototype.onEnd=function(f){f===a.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},n.Inflate=d,n.inflate=p,n.inflateRaw=function(f,m){return(m=m||{}).raw=!0,p(f,m)},n.ungzip=p},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,n){"use strict";var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";n.assign=function(a){for(var s=Array.prototype.slice.call(arguments,1);s.length;){var l=s.shift();if(l){if(typeof l!="object")throw new TypeError(l+"must be non-object");for(var c in l)l.hasOwnProperty(c)&&(a[c]=l[c])}}return a},n.shrinkBuf=function(a,s){return a.length===s?a:a.subarray?a.subarray(0,s):(a.length=s,a)};var o={arraySet:function(a,s,l,c,u){if(s.subarray&&a.subarray)a.set(s.subarray(l,l+c),u);else for(var d=0;d<c;d++)a[u+d]=s[l+d]},flattenChunks:function(a){var s,l,c,u,d,p;for(s=c=0,l=a.length;s<l;s++)c+=a[s].length;for(p=new Uint8Array(c),s=u=0,l=a.length;s<l;s++)d=a[s],p.set(d,u),u+=d.length;return p}},i={arraySet:function(a,s,l,c,u){for(var d=0;d<c;d++)a[u+d]=s[l+d]},flattenChunks:function(a){return[].concat.apply([],a)}};n.setTyped=function(a){a?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,o)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,i))},n.setTyped(r)},{}],42:[function(e,t,n){"use strict";var r=e("./common"),o=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{i=!1}for(var a=new r.Buf8(256),s=0;s<256;s++)a[s]=252<=s?6:248<=s?5:240<=s?4:224<=s?3:192<=s?2:1;function l(c,u){if(u<65537&&(c.subarray&&i||!c.subarray&&o))return String.fromCharCode.apply(null,r.shrinkBuf(c,u));for(var d="",p=0;p<u;p++)d+=String.fromCharCode(c[p]);return d}a[254]=a[254]=1,n.string2buf=function(c){var u,d,p,f,m,h=c.length,g=0;for(f=0;f<h;f++)(64512&(d=c.charCodeAt(f)))==55296&&f+1<h&&(64512&(p=c.charCodeAt(f+1)))==56320&&(d=65536+(d-55296<<10)+(p-56320),f++),g+=d<128?1:d<2048?2:d<65536?3:4;for(u=new r.Buf8(g),f=m=0;m<g;f++)(64512&(d=c.charCodeAt(f)))==55296&&f+1<h&&(64512&(p=c.charCodeAt(f+1)))==56320&&(d=65536+(d-55296<<10)+(p-56320),f++),d<128?u[m++]=d:(d<2048?u[m++]=192|d>>>6:(d<65536?u[m++]=224|d>>>12:(u[m++]=240|d>>>18,u[m++]=128|d>>>12&63),u[m++]=128|d>>>6&63),u[m++]=128|63&d);return u},n.buf2binstring=function(c){return l(c,c.length)},n.binstring2buf=function(c){for(var u=new r.Buf8(c.length),d=0,p=u.length;d<p;d++)u[d]=c.charCodeAt(d);return u},n.buf2string=function(c,u){var d,p,f,m,h=u||c.length,g=new Array(2*h);for(d=p=0;d<h;)if((f=c[d++])<128)g[p++]=f;else if(4<(m=a[f]))g[p++]=65533,d+=m-1;else{for(f&=m===2?31:m===3?15:7;1<m&&d<h;)f=f<<6|63&c[d++],m--;1<m?g[p++]=65533:f<65536?g[p++]=f:(f-=65536,g[p++]=55296|f>>10&1023,g[p++]=56320|1023&f)}return l(g,p)},n.utf8border=function(c,u){var d;for((u=u||c.length)>c.length&&(u=c.length),d=u-1;0<=d&&(192&c[d])==128;)d--;return d<0||d===0?u:d+a[c[d]]>u?d:u}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(r,o,i,a){for(var s=65535&r|0,l=r>>>16&65535|0,c=0;i!==0;){for(i-=c=2e3<i?2e3:i;l=l+(s=s+o[a++]|0)|0,--c;);s%=65521,l%=65521}return s|l<<16|0}},{}],44:[function(e,t,n){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,n){"use strict";var r=(function(){for(var o,i=[],a=0;a<256;a++){o=a;for(var s=0;s<8;s++)o=1&o?3988292384^o>>>1:o>>>1;i[a]=o}return i})();t.exports=function(o,i,a,s){var l=r,c=s+a;o^=-1;for(var u=s;u<c;u++)o=o>>>8^l[255&(o^i[u])];return-1^o}},{}],46:[function(e,t,n){"use strict";var r,o=e("../utils/common"),i=e("./trees"),a=e("./adler32"),s=e("./crc32"),l=e("./messages"),c=0,u=4,d=0,p=-2,f=-1,m=4,h=2,g=8,y=9,b=286,x=30,v=19,S=2*b+1,F=15,w=3,C=258,A=C+w+1,T=42,D=113,k=1,P=2,I=3,B=4;function M(G,ie){return G.msg=l[ie],ie}function L(G){return(G<<1)-(4<G?9:0)}function _(G){for(var ie=G.length;0<=--ie;)G[ie]=0}function R(G){var ie=G.state,fe=ie.pending;fe>G.avail_out&&(fe=G.avail_out),fe!==0&&(o.arraySet(G.output,ie.pending_buf,ie.pending_out,fe,G.next_out),G.next_out+=fe,ie.pending_out+=fe,G.total_out+=fe,G.avail_out-=fe,ie.pending-=fe,ie.pending===0&&(ie.pending_out=0))}function O(G,ie){i._tr_flush_block(G,0<=G.block_start?G.block_start:-1,G.strstart-G.block_start,ie),G.block_start=G.strstart,R(G.strm)}function N(G,ie){G.pending_buf[G.pending++]=ie}function z(G,ie){G.pending_buf[G.pending++]=ie>>>8&255,G.pending_buf[G.pending++]=255&ie}function U(G,ie){var fe,$,j=G.max_chain_length,pe=G.strstart,re=G.prev_length,le=G.nice_match,Q=G.strstart>G.w_size-A?G.strstart-(G.w_size-A):0,se=G.window,De=G.w_mask,Ae=G.prev,ye=G.strstart+C,$e=se[pe+re-1],Pe=se[pe+re];G.prev_length>=G.good_match&&(j>>=2),le>G.lookahead&&(le=G.lookahead);do if(se[(fe=ie)+re]===Pe&&se[fe+re-1]===$e&&se[fe]===se[pe]&&se[++fe]===se[pe+1]){pe+=2,fe++;do;while(se[++pe]===se[++fe]&&se[++pe]===se[++fe]&&se[++pe]===se[++fe]&&se[++pe]===se[++fe]&&se[++pe]===se[++fe]&&se[++pe]===se[++fe]&&se[++pe]===se[++fe]&&se[++pe]===se[++fe]&&pe<ye);if($=C-(ye-pe),pe=ye-C,re<$){if(G.match_start=ie,le<=(re=$))break;$e=se[pe+re-1],Pe=se[pe+re]}}while((ie=Ae[ie&De])>Q&&--j!=0);return re<=G.lookahead?re:G.lookahead}function H(G){var ie,fe,$,j,pe,re,le,Q,se,De,Ae=G.w_size;do{if(j=G.window_size-G.lookahead-G.strstart,G.strstart>=Ae+(Ae-A)){for(o.arraySet(G.window,G.window,Ae,Ae,0),G.match_start-=Ae,G.strstart-=Ae,G.block_start-=Ae,ie=fe=G.hash_size;$=G.head[--ie],G.head[ie]=Ae<=$?$-Ae:0,--fe;);for(ie=fe=Ae;$=G.prev[--ie],G.prev[ie]=Ae<=$?$-Ae:0,--fe;);j+=Ae}if(G.strm.avail_in===0)break;if(re=G.strm,le=G.window,Q=G.strstart+G.lookahead,se=j,De=void 0,De=re.avail_in,se<De&&(De=se),fe=De===0?0:(re.avail_in-=De,o.arraySet(le,re.input,re.next_in,De,Q),re.state.wrap===1?re.adler=a(re.adler,le,De,Q):re.state.wrap===2&&(re.adler=s(re.adler,le,De,Q)),re.next_in+=De,re.total_in+=De,De),G.lookahead+=fe,G.lookahead+G.insert>=w)for(pe=G.strstart-G.insert,G.ins_h=G.window[pe],G.ins_h=(G.ins_h<<G.hash_shift^G.window[pe+1])&G.hash_mask;G.insert&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[pe+w-1])&G.hash_mask,G.prev[pe&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=pe,pe++,G.insert--,!(G.lookahead+G.insert<w)););}while(G.lookahead<A&&G.strm.avail_in!==0)}function V(G,ie){for(var fe,$;;){if(G.lookahead<A){if(H(G),G.lookahead<A&&ie===c)return k;if(G.lookahead===0)break}if(fe=0,G.lookahead>=w&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+w-1])&G.hash_mask,fe=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),fe!==0&&G.strstart-fe<=G.w_size-A&&(G.match_length=U(G,fe)),G.match_length>=w)if($=i._tr_tally(G,G.strstart-G.match_start,G.match_length-w),G.lookahead-=G.match_length,G.match_length<=G.max_lazy_match&&G.lookahead>=w){for(G.match_length--;G.strstart++,G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+w-1])&G.hash_mask,fe=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart,--G.match_length!=0;);G.strstart++}else G.strstart+=G.match_length,G.match_length=0,G.ins_h=G.window[G.strstart],G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+1])&G.hash_mask;else $=i._tr_tally(G,0,G.window[G.strstart]),G.lookahead--,G.strstart++;if($&&(O(G,!1),G.strm.avail_out===0))return k}return G.insert=G.strstart<w-1?G.strstart:w-1,ie===u?(O(G,!0),G.strm.avail_out===0?I:B):G.last_lit&&(O(G,!1),G.strm.avail_out===0)?k:P}function ne(G,ie){for(var fe,$,j;;){if(G.lookahead<A){if(H(G),G.lookahead<A&&ie===c)return k;if(G.lookahead===0)break}if(fe=0,G.lookahead>=w&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+w-1])&G.hash_mask,fe=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),G.prev_length=G.match_length,G.prev_match=G.match_start,G.match_length=w-1,fe!==0&&G.prev_length<G.max_lazy_match&&G.strstart-fe<=G.w_size-A&&(G.match_length=U(G,fe),G.match_length<=5&&(G.strategy===1||G.match_length===w&&4096<G.strstart-G.match_start)&&(G.match_length=w-1)),G.prev_length>=w&&G.match_length<=G.prev_length){for(j=G.strstart+G.lookahead-w,$=i._tr_tally(G,G.strstart-1-G.prev_match,G.prev_length-w),G.lookahead-=G.prev_length-1,G.prev_length-=2;++G.strstart<=j&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+w-1])&G.hash_mask,fe=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),--G.prev_length!=0;);if(G.match_available=0,G.match_length=w-1,G.strstart++,$&&(O(G,!1),G.strm.avail_out===0))return k}else if(G.match_available){if(($=i._tr_tally(G,0,G.window[G.strstart-1]))&&O(G,!1),G.strstart++,G.lookahead--,G.strm.avail_out===0)return k}else G.match_available=1,G.strstart++,G.lookahead--}return G.match_available&&($=i._tr_tally(G,0,G.window[G.strstart-1]),G.match_available=0),G.insert=G.strstart<w-1?G.strstart:w-1,ie===u?(O(G,!0),G.strm.avail_out===0?I:B):G.last_lit&&(O(G,!1),G.strm.avail_out===0)?k:P}function Z(G,ie,fe,$,j){this.good_length=G,this.max_lazy=ie,this.nice_length=fe,this.max_chain=$,this.func=j}function ee(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=g,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*S),this.dyn_dtree=new o.Buf16(2*(2*x+1)),this.bl_tree=new o.Buf16(2*(2*v+1)),_(this.dyn_ltree),_(this.dyn_dtree),_(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(F+1),this.heap=new o.Buf16(2*b+1),_(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*b+1),_(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function J(G){var ie;return G&&G.state?(G.total_in=G.total_out=0,G.data_type=h,(ie=G.state).pending=0,ie.pending_out=0,ie.wrap<0&&(ie.wrap=-ie.wrap),ie.status=ie.wrap?T:D,G.adler=ie.wrap===2?0:1,ie.last_flush=c,i._tr_init(ie),d):M(G,p)}function te(G){var ie=J(G);return ie===d&&(function(fe){fe.window_size=2*fe.w_size,_(fe.head),fe.max_lazy_match=r[fe.level].max_lazy,fe.good_match=r[fe.level].good_length,fe.nice_match=r[fe.level].nice_length,fe.max_chain_length=r[fe.level].max_chain,fe.strstart=0,fe.block_start=0,fe.lookahead=0,fe.insert=0,fe.match_length=fe.prev_length=w-1,fe.match_available=0,fe.ins_h=0})(G.state),ie}function K(G,ie,fe,$,j,pe){if(!G)return p;var re=1;if(ie===f&&(ie=6),$<0?(re=0,$=-$):15<$&&(re=2,$-=16),j<1||y<j||fe!==g||$<8||15<$||ie<0||9<ie||pe<0||m<pe)return M(G,p);$===8&&($=9);var le=new ee;return(G.state=le).strm=G,le.wrap=re,le.gzhead=null,le.w_bits=$,le.w_size=1<<le.w_bits,le.w_mask=le.w_size-1,le.hash_bits=j+7,le.hash_size=1<<le.hash_bits,le.hash_mask=le.hash_size-1,le.hash_shift=~~((le.hash_bits+w-1)/w),le.window=new o.Buf8(2*le.w_size),le.head=new o.Buf16(le.hash_size),le.prev=new o.Buf16(le.w_size),le.lit_bufsize=1<<j+6,le.pending_buf_size=4*le.lit_bufsize,le.pending_buf=new o.Buf8(le.pending_buf_size),le.d_buf=1*le.lit_bufsize,le.l_buf=3*le.lit_bufsize,le.level=ie,le.strategy=pe,le.method=fe,te(G)}r=[new Z(0,0,0,0,function(G,ie){var fe=65535;for(fe>G.pending_buf_size-5&&(fe=G.pending_buf_size-5);;){if(G.lookahead<=1){if(H(G),G.lookahead===0&&ie===c)return k;if(G.lookahead===0)break}G.strstart+=G.lookahead,G.lookahead=0;var $=G.block_start+fe;if((G.strstart===0||G.strstart>=$)&&(G.lookahead=G.strstart-$,G.strstart=$,O(G,!1),G.strm.avail_out===0)||G.strstart-G.block_start>=G.w_size-A&&(O(G,!1),G.strm.avail_out===0))return k}return G.insert=0,ie===u?(O(G,!0),G.strm.avail_out===0?I:B):(G.strstart>G.block_start&&(O(G,!1),G.strm.avail_out),k)}),new Z(4,4,8,4,V),new Z(4,5,16,8,V),new Z(4,6,32,32,V),new Z(4,4,16,16,ne),new Z(8,16,32,32,ne),new Z(8,16,128,128,ne),new Z(8,32,128,256,ne),new Z(32,128,258,1024,ne),new Z(32,258,258,4096,ne)],n.deflateInit=function(G,ie){return K(G,ie,g,15,8,0)},n.deflateInit2=K,n.deflateReset=te,n.deflateResetKeep=J,n.deflateSetHeader=function(G,ie){return G&&G.state?G.state.wrap!==2?p:(G.state.gzhead=ie,d):p},n.deflate=function(G,ie){var fe,$,j,pe;if(!G||!G.state||5<ie||ie<0)return G?M(G,p):p;if($=G.state,!G.output||!G.input&&G.avail_in!==0||$.status===666&&ie!==u)return M(G,G.avail_out===0?-5:p);if($.strm=G,fe=$.last_flush,$.last_flush=ie,$.status===T)if($.wrap===2)G.adler=0,N($,31),N($,139),N($,8),$.gzhead?(N($,($.gzhead.text?1:0)+($.gzhead.hcrc?2:0)+($.gzhead.extra?4:0)+($.gzhead.name?8:0)+($.gzhead.comment?16:0)),N($,255&$.gzhead.time),N($,$.gzhead.time>>8&255),N($,$.gzhead.time>>16&255),N($,$.gzhead.time>>24&255),N($,$.level===9?2:2<=$.strategy||$.level<2?4:0),N($,255&$.gzhead.os),$.gzhead.extra&&$.gzhead.extra.length&&(N($,255&$.gzhead.extra.length),N($,$.gzhead.extra.length>>8&255)),$.gzhead.hcrc&&(G.adler=s(G.adler,$.pending_buf,$.pending,0)),$.gzindex=0,$.status=69):(N($,0),N($,0),N($,0),N($,0),N($,0),N($,$.level===9?2:2<=$.strategy||$.level<2?4:0),N($,3),$.status=D);else{var re=g+($.w_bits-8<<4)<<8;re|=(2<=$.strategy||$.level<2?0:$.level<6?1:$.level===6?2:3)<<6,$.strstart!==0&&(re|=32),re+=31-re%31,$.status=D,z($,re),$.strstart!==0&&(z($,G.adler>>>16),z($,65535&G.adler)),G.adler=1}if($.status===69)if($.gzhead.extra){for(j=$.pending;$.gzindex<(65535&$.gzhead.extra.length)&&($.pending!==$.pending_buf_size||($.gzhead.hcrc&&$.pending>j&&(G.adler=s(G.adler,$.pending_buf,$.pending-j,j)),R(G),j=$.pending,$.pending!==$.pending_buf_size));)N($,255&$.gzhead.extra[$.gzindex]),$.gzindex++;$.gzhead.hcrc&&$.pending>j&&(G.adler=s(G.adler,$.pending_buf,$.pending-j,j)),$.gzindex===$.gzhead.extra.length&&($.gzindex=0,$.status=73)}else $.status=73;if($.status===73)if($.gzhead.name){j=$.pending;do{if($.pending===$.pending_buf_size&&($.gzhead.hcrc&&$.pending>j&&(G.adler=s(G.adler,$.pending_buf,$.pending-j,j)),R(G),j=$.pending,$.pending===$.pending_buf_size)){pe=1;break}pe=$.gzindex<$.gzhead.name.length?255&$.gzhead.name.charCodeAt($.gzindex++):0,N($,pe)}while(pe!==0);$.gzhead.hcrc&&$.pending>j&&(G.adler=s(G.adler,$.pending_buf,$.pending-j,j)),pe===0&&($.gzindex=0,$.status=91)}else $.status=91;if($.status===91)if($.gzhead.comment){j=$.pending;do{if($.pending===$.pending_buf_size&&($.gzhead.hcrc&&$.pending>j&&(G.adler=s(G.adler,$.pending_buf,$.pending-j,j)),R(G),j=$.pending,$.pending===$.pending_buf_size)){pe=1;break}pe=$.gzindex<$.gzhead.comment.length?255&$.gzhead.comment.charCodeAt($.gzindex++):0,N($,pe)}while(pe!==0);$.gzhead.hcrc&&$.pending>j&&(G.adler=s(G.adler,$.pending_buf,$.pending-j,j)),pe===0&&($.status=103)}else $.status=103;if($.status===103&&($.gzhead.hcrc?($.pending+2>$.pending_buf_size&&R(G),$.pending+2<=$.pending_buf_size&&(N($,255&G.adler),N($,G.adler>>8&255),G.adler=0,$.status=D)):$.status=D),$.pending!==0){if(R(G),G.avail_out===0)return $.last_flush=-1,d}else if(G.avail_in===0&&L(ie)<=L(fe)&&ie!==u)return M(G,-5);if($.status===666&&G.avail_in!==0)return M(G,-5);if(G.avail_in!==0||$.lookahead!==0||ie!==c&&$.status!==666){var le=$.strategy===2?(function(Q,se){for(var De;;){if(Q.lookahead===0&&(H(Q),Q.lookahead===0)){if(se===c)return k;break}if(Q.match_length=0,De=i._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++,De&&(O(Q,!1),Q.strm.avail_out===0))return k}return Q.insert=0,se===u?(O(Q,!0),Q.strm.avail_out===0?I:B):Q.last_lit&&(O(Q,!1),Q.strm.avail_out===0)?k:P})($,ie):$.strategy===3?(function(Q,se){for(var De,Ae,ye,$e,Pe=Q.window;;){if(Q.lookahead<=C){if(H(Q),Q.lookahead<=C&&se===c)return k;if(Q.lookahead===0)break}if(Q.match_length=0,Q.lookahead>=w&&0<Q.strstart&&(Ae=Pe[ye=Q.strstart-1])===Pe[++ye]&&Ae===Pe[++ye]&&Ae===Pe[++ye]){$e=Q.strstart+C;do;while(Ae===Pe[++ye]&&Ae===Pe[++ye]&&Ae===Pe[++ye]&&Ae===Pe[++ye]&&Ae===Pe[++ye]&&Ae===Pe[++ye]&&Ae===Pe[++ye]&&Ae===Pe[++ye]&&ye<$e);Q.match_length=C-($e-ye),Q.match_length>Q.lookahead&&(Q.match_length=Q.lookahead)}if(Q.match_length>=w?(De=i._tr_tally(Q,1,Q.match_length-w),Q.lookahead-=Q.match_length,Q.strstart+=Q.match_length,Q.match_length=0):(De=i._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++),De&&(O(Q,!1),Q.strm.avail_out===0))return k}return Q.insert=0,se===u?(O(Q,!0),Q.strm.avail_out===0?I:B):Q.last_lit&&(O(Q,!1),Q.strm.avail_out===0)?k:P})($,ie):r[$.level].func($,ie);if(le!==I&&le!==B||($.status=666),le===k||le===I)return G.avail_out===0&&($.last_flush=-1),d;if(le===P&&(ie===1?i._tr_align($):ie!==5&&(i._tr_stored_block($,0,0,!1),ie===3&&(_($.head),$.lookahead===0&&($.strstart=0,$.block_start=0,$.insert=0))),R(G),G.avail_out===0))return $.last_flush=-1,d}return ie!==u?d:$.wrap<=0?1:($.wrap===2?(N($,255&G.adler),N($,G.adler>>8&255),N($,G.adler>>16&255),N($,G.adler>>24&255),N($,255&G.total_in),N($,G.total_in>>8&255),N($,G.total_in>>16&255),N($,G.total_in>>24&255)):(z($,G.adler>>>16),z($,65535&G.adler)),R(G),0<$.wrap&&($.wrap=-$.wrap),$.pending!==0?d:1)},n.deflateEnd=function(G){var ie;return G&&G.state?(ie=G.state.status)!==T&&ie!==69&&ie!==73&&ie!==91&&ie!==103&&ie!==D&&ie!==666?M(G,p):(G.state=null,ie===D?M(G,-3):d):p},n.deflateSetDictionary=function(G,ie){var fe,$,j,pe,re,le,Q,se,De=ie.length;if(!G||!G.state||(pe=(fe=G.state).wrap)===2||pe===1&&fe.status!==T||fe.lookahead)return p;for(pe===1&&(G.adler=a(G.adler,ie,De,0)),fe.wrap=0,De>=fe.w_size&&(pe===0&&(_(fe.head),fe.strstart=0,fe.block_start=0,fe.insert=0),se=new o.Buf8(fe.w_size),o.arraySet(se,ie,De-fe.w_size,fe.w_size,0),ie=se,De=fe.w_size),re=G.avail_in,le=G.next_in,Q=G.input,G.avail_in=De,G.next_in=0,G.input=ie,H(fe);fe.lookahead>=w;){for($=fe.strstart,j=fe.lookahead-(w-1);fe.ins_h=(fe.ins_h<<fe.hash_shift^fe.window[$+w-1])&fe.hash_mask,fe.prev[$&fe.w_mask]=fe.head[fe.ins_h],fe.head[fe.ins_h]=$,$++,--j;);fe.strstart=$,fe.lookahead=w-1,H(fe)}return fe.strstart+=fe.lookahead,fe.block_start=fe.strstart,fe.insert=fe.lookahead,fe.lookahead=0,fe.match_length=fe.prev_length=w-1,fe.match_available=0,G.next_in=le,G.input=Q,G.avail_in=re,fe.wrap=pe,d},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,n){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,n){"use strict";t.exports=function(r,o){var i,a,s,l,c,u,d,p,f,m,h,g,y,b,x,v,S,F,w,C,A,T,D,k,P;i=r.state,a=r.next_in,k=r.input,s=a+(r.avail_in-5),l=r.next_out,P=r.output,c=l-(o-r.avail_out),u=l+(r.avail_out-257),d=i.dmax,p=i.wsize,f=i.whave,m=i.wnext,h=i.window,g=i.hold,y=i.bits,b=i.lencode,x=i.distcode,v=(1<<i.lenbits)-1,S=(1<<i.distbits)-1;e:do{y<15&&(g+=k[a++]<<y,y+=8,g+=k[a++]<<y,y+=8),F=b[g&v];t:for(;;){if(g>>>=w=F>>>24,y-=w,(w=F>>>16&255)===0)P[l++]=65535&F;else{if(!(16&w)){if((64&w)==0){F=b[(65535&F)+(g&(1<<w)-1)];continue t}if(32&w){i.mode=12;break e}r.msg="invalid literal/length code",i.mode=30;break e}C=65535&F,(w&=15)&&(y<w&&(g+=k[a++]<<y,y+=8),C+=g&(1<<w)-1,g>>>=w,y-=w),y<15&&(g+=k[a++]<<y,y+=8,g+=k[a++]<<y,y+=8),F=x[g&S];n:for(;;){if(g>>>=w=F>>>24,y-=w,!(16&(w=F>>>16&255))){if((64&w)==0){F=x[(65535&F)+(g&(1<<w)-1)];continue n}r.msg="invalid distance code",i.mode=30;break e}if(A=65535&F,y<(w&=15)&&(g+=k[a++]<<y,(y+=8)<w&&(g+=k[a++]<<y,y+=8)),d<(A+=g&(1<<w)-1)){r.msg="invalid distance too far back",i.mode=30;break e}if(g>>>=w,y-=w,(w=l-c)<A){if(f<(w=A-w)&&i.sane){r.msg="invalid distance too far back",i.mode=30;break e}if(D=h,(T=0)===m){if(T+=p-w,w<C){for(C-=w;P[l++]=h[T++],--w;);T=l-A,D=P}}else if(m<w){if(T+=p+m-w,(w-=m)<C){for(C-=w;P[l++]=h[T++],--w;);if(T=0,m<C){for(C-=w=m;P[l++]=h[T++],--w;);T=l-A,D=P}}}else if(T+=m-w,w<C){for(C-=w;P[l++]=h[T++],--w;);T=l-A,D=P}for(;2<C;)P[l++]=D[T++],P[l++]=D[T++],P[l++]=D[T++],C-=3;C&&(P[l++]=D[T++],1<C&&(P[l++]=D[T++]))}else{for(T=l-A;P[l++]=P[T++],P[l++]=P[T++],P[l++]=P[T++],2<(C-=3););C&&(P[l++]=P[T++],1<C&&(P[l++]=P[T++]))}break}}break}}while(a<s&&l<u);a-=C=y>>3,g&=(1<<(y-=C<<3))-1,r.next_in=a,r.next_out=l,r.avail_in=a<s?s-a+5:5-(a-s),r.avail_out=l<u?u-l+257:257-(l-u),i.hold=g,i.bits=y}},{}],49:[function(e,t,n){"use strict";var r=e("../utils/common"),o=e("./adler32"),i=e("./crc32"),a=e("./inffast"),s=e("./inftrees"),l=1,c=2,u=0,d=-2,p=1,f=852,m=592;function h(T){return(T>>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function y(T){var D;return T&&T.state?(D=T.state,T.total_in=T.total_out=D.total=0,T.msg="",D.wrap&&(T.adler=1&D.wrap),D.mode=p,D.last=0,D.havedict=0,D.dmax=32768,D.head=null,D.hold=0,D.bits=0,D.lencode=D.lendyn=new r.Buf32(f),D.distcode=D.distdyn=new r.Buf32(m),D.sane=1,D.back=-1,u):d}function b(T){var D;return T&&T.state?((D=T.state).wsize=0,D.whave=0,D.wnext=0,y(T)):d}function x(T,D){var k,P;return T&&T.state?(P=T.state,D<0?(k=0,D=-D):(k=1+(D>>4),D<48&&(D&=15)),D&&(D<8||15<D)?d:(P.window!==null&&P.wbits!==D&&(P.window=null),P.wrap=k,P.wbits=D,b(T))):d}function v(T,D){var k,P;return T?(P=new g,(T.state=P).window=null,(k=x(T,D))!==u&&(T.state=null),k):d}var S,F,w=!0;function C(T){if(w){var D;for(S=new r.Buf32(512),F=new r.Buf32(32),D=0;D<144;)T.lens[D++]=8;for(;D<256;)T.lens[D++]=9;for(;D<280;)T.lens[D++]=7;for(;D<288;)T.lens[D++]=8;for(s(l,T.lens,0,288,S,0,T.work,{bits:9}),D=0;D<32;)T.lens[D++]=5;s(c,T.lens,0,32,F,0,T.work,{bits:5}),w=!1}T.lencode=S,T.lenbits=9,T.distcode=F,T.distbits=5}function A(T,D,k,P){var I,B=T.state;return B.window===null&&(B.wsize=1<<B.wbits,B.wnext=0,B.whave=0,B.window=new r.Buf8(B.wsize)),P>=B.wsize?(r.arraySet(B.window,D,k-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):(P<(I=B.wsize-B.wnext)&&(I=P),r.arraySet(B.window,D,k-P,I,B.wnext),(P-=I)?(r.arraySet(B.window,D,k-P,P,0),B.wnext=P,B.whave=B.wsize):(B.wnext+=I,B.wnext===B.wsize&&(B.wnext=0),B.whave<B.wsize&&(B.whave+=I))),0}n.inflateReset=b,n.inflateReset2=x,n.inflateResetKeep=y,n.inflateInit=function(T){return v(T,15)},n.inflateInit2=v,n.inflate=function(T,D){var k,P,I,B,M,L,_,R,O,N,z,U,H,V,ne,Z,ee,J,te,K,G,ie,fe,$,j=0,pe=new r.Buf8(4),re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return d;(k=T.state).mode===12&&(k.mode=13),M=T.next_out,I=T.output,_=T.avail_out,B=T.next_in,P=T.input,L=T.avail_in,R=k.hold,O=k.bits,N=L,z=_,ie=u;e:for(;;)switch(k.mode){case p:if(k.wrap===0){k.mode=13;break}for(;O<16;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if(2&k.wrap&&R===35615){pe[k.check=0]=255&R,pe[1]=R>>>8&255,k.check=i(k.check,pe,2,0),O=R=0,k.mode=2;break}if(k.flags=0,k.head&&(k.head.done=!1),!(1&k.wrap)||(((255&R)<<8)+(R>>8))%31){T.msg="incorrect header check",k.mode=30;break}if((15&R)!=8){T.msg="unknown compression method",k.mode=30;break}if(O-=4,G=8+(15&(R>>>=4)),k.wbits===0)k.wbits=G;else if(G>k.wbits){T.msg="invalid window size",k.mode=30;break}k.dmax=1<<G,T.adler=k.check=1,k.mode=512&R?10:12,O=R=0;break;case 2:for(;O<16;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if(k.flags=R,(255&k.flags)!=8){T.msg="unknown compression method",k.mode=30;break}if(57344&k.flags){T.msg="unknown header flags set",k.mode=30;break}k.head&&(k.head.text=R>>8&1),512&k.flags&&(pe[0]=255&R,pe[1]=R>>>8&255,k.check=i(k.check,pe,2,0)),O=R=0,k.mode=3;case 3:for(;O<32;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}k.head&&(k.head.time=R),512&k.flags&&(pe[0]=255&R,pe[1]=R>>>8&255,pe[2]=R>>>16&255,pe[3]=R>>>24&255,k.check=i(k.check,pe,4,0)),O=R=0,k.mode=4;case 4:for(;O<16;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}k.head&&(k.head.xflags=255&R,k.head.os=R>>8),512&k.flags&&(pe[0]=255&R,pe[1]=R>>>8&255,k.check=i(k.check,pe,2,0)),O=R=0,k.mode=5;case 5:if(1024&k.flags){for(;O<16;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}k.length=R,k.head&&(k.head.extra_len=R),512&k.flags&&(pe[0]=255&R,pe[1]=R>>>8&255,k.check=i(k.check,pe,2,0)),O=R=0}else k.head&&(k.head.extra=null);k.mode=6;case 6:if(1024&k.flags&&(L<(U=k.length)&&(U=L),U&&(k.head&&(G=k.head.extra_len-k.length,k.head.extra||(k.head.extra=new Array(k.head.extra_len)),r.arraySet(k.head.extra,P,B,U,G)),512&k.flags&&(k.check=i(k.check,P,U,B)),L-=U,B+=U,k.length-=U),k.length))break e;k.length=0,k.mode=7;case 7:if(2048&k.flags){if(L===0)break e;for(U=0;G=P[B+U++],k.head&&G&&k.length<65536&&(k.head.name+=String.fromCharCode(G)),G&&U<L;);if(512&k.flags&&(k.check=i(k.check,P,U,B)),L-=U,B+=U,G)break e}else k.head&&(k.head.name=null);k.length=0,k.mode=8;case 8:if(4096&k.flags){if(L===0)break e;for(U=0;G=P[B+U++],k.head&&G&&k.length<65536&&(k.head.comment+=String.fromCharCode(G)),G&&U<L;);if(512&k.flags&&(k.check=i(k.check,P,U,B)),L-=U,B+=U,G)break e}else k.head&&(k.head.comment=null);k.mode=9;case 9:if(512&k.flags){for(;O<16;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if(R!==(65535&k.check)){T.msg="header crc mismatch",k.mode=30;break}O=R=0}k.head&&(k.head.hcrc=k.flags>>9&1,k.head.done=!0),T.adler=k.check=0,k.mode=12;break;case 10:for(;O<32;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}T.adler=k.check=h(R),O=R=0,k.mode=11;case 11:if(k.havedict===0)return T.next_out=M,T.avail_out=_,T.next_in=B,T.avail_in=L,k.hold=R,k.bits=O,2;T.adler=k.check=1,k.mode=12;case 12:if(D===5||D===6)break e;case 13:if(k.last){R>>>=7&O,O-=7&O,k.mode=27;break}for(;O<3;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}switch(k.last=1&R,O-=1,3&(R>>>=1)){case 0:k.mode=14;break;case 1:if(C(k),k.mode=20,D!==6)break;R>>>=2,O-=2;break e;case 2:k.mode=17;break;case 3:T.msg="invalid block type",k.mode=30}R>>>=2,O-=2;break;case 14:for(R>>>=7&O,O-=7&O;O<32;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if((65535&R)!=(R>>>16^65535)){T.msg="invalid stored block lengths",k.mode=30;break}if(k.length=65535&R,O=R=0,k.mode=15,D===6)break e;case 15:k.mode=16;case 16:if(U=k.length){if(L<U&&(U=L),_<U&&(U=_),U===0)break e;r.arraySet(I,P,B,U,M),L-=U,B+=U,_-=U,M+=U,k.length-=U;break}k.mode=12;break;case 17:for(;O<14;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if(k.nlen=257+(31&R),R>>>=5,O-=5,k.ndist=1+(31&R),R>>>=5,O-=5,k.ncode=4+(15&R),R>>>=4,O-=4,286<k.nlen||30<k.ndist){T.msg="too many length or distance symbols",k.mode=30;break}k.have=0,k.mode=18;case 18:for(;k.have<k.ncode;){for(;O<3;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}k.lens[re[k.have++]]=7&R,R>>>=3,O-=3}for(;k.have<19;)k.lens[re[k.have++]]=0;if(k.lencode=k.lendyn,k.lenbits=7,fe={bits:k.lenbits},ie=s(0,k.lens,0,19,k.lencode,0,k.work,fe),k.lenbits=fe.bits,ie){T.msg="invalid code lengths set",k.mode=30;break}k.have=0,k.mode=19;case 19:for(;k.have<k.nlen+k.ndist;){for(;Z=(j=k.lencode[R&(1<<k.lenbits)-1])>>>16&255,ee=65535&j,!((ne=j>>>24)<=O);){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if(ee<16)R>>>=ne,O-=ne,k.lens[k.have++]=ee;else{if(ee===16){for($=ne+2;O<$;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if(R>>>=ne,O-=ne,k.have===0){T.msg="invalid bit length repeat",k.mode=30;break}G=k.lens[k.have-1],U=3+(3&R),R>>>=2,O-=2}else if(ee===17){for($=ne+3;O<$;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}O-=ne,G=0,U=3+(7&(R>>>=ne)),R>>>=3,O-=3}else{for($=ne+7;O<$;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}O-=ne,G=0,U=11+(127&(R>>>=ne)),R>>>=7,O-=7}if(k.have+U>k.nlen+k.ndist){T.msg="invalid bit length repeat",k.mode=30;break}for(;U--;)k.lens[k.have++]=G}}if(k.mode===30)break;if(k.lens[256]===0){T.msg="invalid code -- missing end-of-block",k.mode=30;break}if(k.lenbits=9,fe={bits:k.lenbits},ie=s(l,k.lens,0,k.nlen,k.lencode,0,k.work,fe),k.lenbits=fe.bits,ie){T.msg="invalid literal/lengths set",k.mode=30;break}if(k.distbits=6,k.distcode=k.distdyn,fe={bits:k.distbits},ie=s(c,k.lens,k.nlen,k.ndist,k.distcode,0,k.work,fe),k.distbits=fe.bits,ie){T.msg="invalid distances set",k.mode=30;break}if(k.mode=20,D===6)break e;case 20:k.mode=21;case 21:if(6<=L&&258<=_){T.next_out=M,T.avail_out=_,T.next_in=B,T.avail_in=L,k.hold=R,k.bits=O,a(T,z),M=T.next_out,I=T.output,_=T.avail_out,B=T.next_in,P=T.input,L=T.avail_in,R=k.hold,O=k.bits,k.mode===12&&(k.back=-1);break}for(k.back=0;Z=(j=k.lencode[R&(1<<k.lenbits)-1])>>>16&255,ee=65535&j,!((ne=j>>>24)<=O);){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if(Z&&(240&Z)==0){for(J=ne,te=Z,K=ee;Z=(j=k.lencode[K+((R&(1<<J+te)-1)>>J)])>>>16&255,ee=65535&j,!(J+(ne=j>>>24)<=O);){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}R>>>=J,O-=J,k.back+=J}if(R>>>=ne,O-=ne,k.back+=ne,k.length=ee,Z===0){k.mode=26;break}if(32&Z){k.back=-1,k.mode=12;break}if(64&Z){T.msg="invalid literal/length code",k.mode=30;break}k.extra=15&Z,k.mode=22;case 22:if(k.extra){for($=k.extra;O<$;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}k.length+=R&(1<<k.extra)-1,R>>>=k.extra,O-=k.extra,k.back+=k.extra}k.was=k.length,k.mode=23;case 23:for(;Z=(j=k.distcode[R&(1<<k.distbits)-1])>>>16&255,ee=65535&j,!((ne=j>>>24)<=O);){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if((240&Z)==0){for(J=ne,te=Z,K=ee;Z=(j=k.distcode[K+((R&(1<<J+te)-1)>>J)])>>>16&255,ee=65535&j,!(J+(ne=j>>>24)<=O);){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}R>>>=J,O-=J,k.back+=J}if(R>>>=ne,O-=ne,k.back+=ne,64&Z){T.msg="invalid distance code",k.mode=30;break}k.offset=ee,k.extra=15&Z,k.mode=24;case 24:if(k.extra){for($=k.extra;O<$;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}k.offset+=R&(1<<k.extra)-1,R>>>=k.extra,O-=k.extra,k.back+=k.extra}if(k.offset>k.dmax){T.msg="invalid distance too far back",k.mode=30;break}k.mode=25;case 25:if(_===0)break e;if(U=z-_,k.offset>U){if((U=k.offset-U)>k.whave&&k.sane){T.msg="invalid distance too far back",k.mode=30;break}H=U>k.wnext?(U-=k.wnext,k.wsize-U):k.wnext-U,U>k.length&&(U=k.length),V=k.window}else V=I,H=M-k.offset,U=k.length;for(_<U&&(U=_),_-=U,k.length-=U;I[M++]=V[H++],--U;);k.length===0&&(k.mode=21);break;case 26:if(_===0)break e;I[M++]=k.length,_--,k.mode=21;break;case 27:if(k.wrap){for(;O<32;){if(L===0)break e;L--,R|=P[B++]<<O,O+=8}if(z-=_,T.total_out+=z,k.total+=z,z&&(T.adler=k.check=k.flags?i(k.check,I,z,M-z):o(k.check,I,z,M-z)),z=_,(k.flags?R:h(R))!==k.check){T.msg="incorrect data check",k.mode=30;break}O=R=0}k.mode=28;case 28:if(k.wrap&&k.flags){for(;O<32;){if(L===0)break e;L--,R+=P[B++]<<O,O+=8}if(R!==(4294967295&k.total)){T.msg="incorrect length check",k.mode=30;break}O=R=0}k.mode=29;case 29:ie=1;break e;case 30:ie=-3;break e;case 31:return-4;default:return d}return T.next_out=M,T.avail_out=_,T.next_in=B,T.avail_in=L,k.hold=R,k.bits=O,(k.wsize||z!==T.avail_out&&k.mode<30&&(k.mode<27||D!==4))&&A(T,T.output,T.next_out,z-T.avail_out)?(k.mode=31,-4):(N-=T.avail_in,z-=T.avail_out,T.total_in+=N,T.total_out+=z,k.total+=z,k.wrap&&z&&(T.adler=k.check=k.flags?i(k.check,I,z,T.next_out-z):o(k.check,I,z,T.next_out-z)),T.data_type=k.bits+(k.last?64:0)+(k.mode===12?128:0)+(k.mode===20||k.mode===15?256:0),(N==0&&z===0||D===4)&&ie===u&&(ie=-5),ie)},n.inflateEnd=function(T){if(!T||!T.state)return d;var D=T.state;return D.window&&(D.window=null),T.state=null,u},n.inflateGetHeader=function(T,D){var k;return T&&T.state?(2&(k=T.state).wrap)==0?d:((k.head=D).done=!1,u):d},n.inflateSetDictionary=function(T,D){var k,P=D.length;return T&&T.state?(k=T.state).wrap!==0&&k.mode!==11?d:k.mode===11&&o(1,D,P,0)!==k.check?-3:A(T,D,P,P)?(k.mode=31,-4):(k.havedict=1,u):d},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,n){"use strict";var r=e("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],s=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(l,c,u,d,p,f,m,h){var g,y,b,x,v,S,F,w,C,A=h.bits,T=0,D=0,k=0,P=0,I=0,B=0,M=0,L=0,_=0,R=0,O=null,N=0,z=new r.Buf16(16),U=new r.Buf16(16),H=null,V=0;for(T=0;T<=15;T++)z[T]=0;for(D=0;D<d;D++)z[c[u+D]]++;for(I=A,P=15;1<=P&&z[P]===0;P--);if(P<I&&(I=P),P===0)return p[f++]=20971520,p[f++]=20971520,h.bits=1,0;for(k=1;k<P&&z[k]===0;k++);for(I<k&&(I=k),T=L=1;T<=15;T++)if(L<<=1,(L-=z[T])<0)return-1;if(0<L&&(l===0||P!==1))return-1;for(U[1]=0,T=1;T<15;T++)U[T+1]=U[T]+z[T];for(D=0;D<d;D++)c[u+D]!==0&&(m[U[c[u+D]]++]=D);if(S=l===0?(O=H=m,19):l===1?(O=o,N-=257,H=i,V-=257,256):(O=a,H=s,-1),T=k,v=f,M=D=R=0,b=-1,x=(_=1<<(B=I))-1,l===1&&852<_||l===2&&592<_)return 1;for(;;){for(F=T-M,C=m[D]<S?(w=0,m[D]):m[D]>S?(w=H[V+m[D]],O[N+m[D]]):(w=96,0),g=1<<T-M,k=y=1<<B;p[v+(R>>M)+(y-=g)]=F<<24|w<<16|C|0,y!==0;);for(g=1<<T-1;R&g;)g>>=1;if(g!==0?(R&=g-1,R+=g):R=0,D++,--z[T]==0){if(T===P)break;T=c[u+m[D]]}if(I<T&&(R&x)!==b){for(M===0&&(M=I),v+=k,L=1<<(B=T-M);B+M<P&&!((L-=z[B+M])<=0);)B++,L<<=1;if(_+=1<<B,l===1&&852<_||l===2&&592<_)return 1;p[b=R&x]=I<<24|B<<16|v-f|0}}return R!==0&&(p[v+R]=T-M<<24|64<<16|0),h.bits=I,0}},{"../utils/common":41}],51:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,t,n){"use strict";var r=e("../utils/common"),o=0,i=1;function a(j){for(var pe=j.length;0<=--pe;)j[pe]=0}var s=0,l=29,c=256,u=c+1+l,d=30,p=19,f=2*u+1,m=15,h=16,g=7,y=256,b=16,x=17,v=18,S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],F=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],A=new Array(2*(u+2));a(A);var T=new Array(2*d);a(T);var D=new Array(512);a(D);var k=new Array(256);a(k);var P=new Array(l);a(P);var I,B,M,L=new Array(d);function _(j,pe,re,le,Q){this.static_tree=j,this.extra_bits=pe,this.extra_base=re,this.elems=le,this.max_length=Q,this.has_stree=j&&j.length}function R(j,pe){this.dyn_tree=j,this.max_code=0,this.stat_desc=pe}function O(j){return j<256?D[j]:D[256+(j>>>7)]}function N(j,pe){j.pending_buf[j.pending++]=255&pe,j.pending_buf[j.pending++]=pe>>>8&255}function z(j,pe,re){j.bi_valid>h-re?(j.bi_buf|=pe<<j.bi_valid&65535,N(j,j.bi_buf),j.bi_buf=pe>>h-j.bi_valid,j.bi_valid+=re-h):(j.bi_buf|=pe<<j.bi_valid&65535,j.bi_valid+=re)}function U(j,pe,re){z(j,re[2*pe],re[2*pe+1])}function H(j,pe){for(var re=0;re|=1&j,j>>>=1,re<<=1,0<--pe;);return re>>>1}function V(j,pe,re){var le,Q,se=new Array(m+1),De=0;for(le=1;le<=m;le++)se[le]=De=De+re[le-1]<<1;for(Q=0;Q<=pe;Q++){var Ae=j[2*Q+1];Ae!==0&&(j[2*Q]=H(se[Ae]++,Ae))}}function ne(j){var pe;for(pe=0;pe<u;pe++)j.dyn_ltree[2*pe]=0;for(pe=0;pe<d;pe++)j.dyn_dtree[2*pe]=0;for(pe=0;pe<p;pe++)j.bl_tree[2*pe]=0;j.dyn_ltree[2*y]=1,j.opt_len=j.static_len=0,j.last_lit=j.matches=0}function Z(j){8<j.bi_valid?N(j,j.bi_buf):0<j.bi_valid&&(j.pending_buf[j.pending++]=j.bi_buf),j.bi_buf=0,j.bi_valid=0}function ee(j,pe,re,le){var Q=2*pe,se=2*re;return j[Q]<j[se]||j[Q]===j[se]&&le[pe]<=le[re]}function J(j,pe,re){for(var le=j.heap[re],Q=re<<1;Q<=j.heap_len&&(Q<j.heap_len&&ee(pe,j.heap[Q+1],j.heap[Q],j.depth)&&Q++,!ee(pe,le,j.heap[Q],j.depth));)j.heap[re]=j.heap[Q],re=Q,Q<<=1;j.heap[re]=le}function te(j,pe,re){var le,Q,se,De,Ae=0;if(j.last_lit!==0)for(;le=j.pending_buf[j.d_buf+2*Ae]<<8|j.pending_buf[j.d_buf+2*Ae+1],Q=j.pending_buf[j.l_buf+Ae],Ae++,le===0?U(j,Q,pe):(U(j,(se=k[Q])+c+1,pe),(De=S[se])!==0&&z(j,Q-=P[se],De),U(j,se=O(--le),re),(De=F[se])!==0&&z(j,le-=L[se],De)),Ae<j.last_lit;);U(j,y,pe)}function K(j,pe){var re,le,Q,se=pe.dyn_tree,De=pe.stat_desc.static_tree,Ae=pe.stat_desc.has_stree,ye=pe.stat_desc.elems,$e=-1;for(j.heap_len=0,j.heap_max=f,re=0;re<ye;re++)se[2*re]!==0?(j.heap[++j.heap_len]=$e=re,j.depth[re]=0):se[2*re+1]=0;for(;j.heap_len<2;)se[2*(Q=j.heap[++j.heap_len]=$e<2?++$e:0)]=1,j.depth[Q]=0,j.opt_len--,Ae&&(j.static_len-=De[2*Q+1]);for(pe.max_code=$e,re=j.heap_len>>1;1<=re;re--)J(j,se,re);for(Q=ye;re=j.heap[1],j.heap[1]=j.heap[j.heap_len--],J(j,se,1),le=j.heap[1],j.heap[--j.heap_max]=re,j.heap[--j.heap_max]=le,se[2*Q]=se[2*re]+se[2*le],j.depth[Q]=(j.depth[re]>=j.depth[le]?j.depth[re]:j.depth[le])+1,se[2*re+1]=se[2*le+1]=Q,j.heap[1]=Q++,J(j,se,1),2<=j.heap_len;);j.heap[--j.heap_max]=j.heap[1],(function(Pe,Ne){var we,Ie,Ce,xe,Y,oe,de=Ne.dyn_tree,Le=Ne.max_code,be=Ne.stat_desc.static_tree,Be=Ne.stat_desc.has_stree,ce=Ne.stat_desc.extra_bits,Re=Ne.stat_desc.extra_base,Qe=Ne.stat_desc.max_length,W=0;for(xe=0;xe<=m;xe++)Pe.bl_count[xe]=0;for(de[2*Pe.heap[Pe.heap_max]+1]=0,we=Pe.heap_max+1;we<f;we++)Qe<(xe=de[2*de[2*(Ie=Pe.heap[we])+1]+1]+1)&&(xe=Qe,W++),de[2*Ie+1]=xe,Le<Ie||(Pe.bl_count[xe]++,Y=0,Re<=Ie&&(Y=ce[Ie-Re]),oe=de[2*Ie],Pe.opt_len+=oe*(xe+Y),Be&&(Pe.static_len+=oe*(be[2*Ie+1]+Y)));if(W!==0){do{for(xe=Qe-1;Pe.bl_count[xe]===0;)xe--;Pe.bl_count[xe]--,Pe.bl_count[xe+1]+=2,Pe.bl_count[Qe]--,W-=2}while(0<W);for(xe=Qe;xe!==0;xe--)for(Ie=Pe.bl_count[xe];Ie!==0;)Le<(Ce=Pe.heap[--we])||(de[2*Ce+1]!==xe&&(Pe.opt_len+=(xe-de[2*Ce+1])*de[2*Ce],de[2*Ce+1]=xe),Ie--)}})(j,pe),V(se,$e,j.bl_count)}function G(j,pe,re){var le,Q,se=-1,De=pe[1],Ae=0,ye=7,$e=4;for(De===0&&(ye=138,$e=3),pe[2*(re+1)+1]=65535,le=0;le<=re;le++)Q=De,De=pe[2*(le+1)+1],++Ae<ye&&Q===De||(Ae<$e?j.bl_tree[2*Q]+=Ae:Q!==0?(Q!==se&&j.bl_tree[2*Q]++,j.bl_tree[2*b]++):Ae<=10?j.bl_tree[2*x]++:j.bl_tree[2*v]++,se=Q,$e=(Ae=0)===De?(ye=138,3):Q===De?(ye=6,3):(ye=7,4))}function ie(j,pe,re){var le,Q,se=-1,De=pe[1],Ae=0,ye=7,$e=4;for(De===0&&(ye=138,$e=3),le=0;le<=re;le++)if(Q=De,De=pe[2*(le+1)+1],!(++Ae<ye&&Q===De)){if(Ae<$e)for(;U(j,Q,j.bl_tree),--Ae!=0;);else Q!==0?(Q!==se&&(U(j,Q,j.bl_tree),Ae--),U(j,b,j.bl_tree),z(j,Ae-3,2)):Ae<=10?(U(j,x,j.bl_tree),z(j,Ae-3,3)):(U(j,v,j.bl_tree),z(j,Ae-11,7));se=Q,$e=(Ae=0)===De?(ye=138,3):Q===De?(ye=6,3):(ye=7,4)}}a(L);var fe=!1;function $(j,pe,re,le){z(j,(s<<1)+(le?1:0),3),(function(Q,se,De,Ae){Z(Q),Ae&&(N(Q,De),N(Q,~De)),r.arraySet(Q.pending_buf,Q.window,se,De,Q.pending),Q.pending+=De})(j,pe,re,!0)}n._tr_init=function(j){fe||((function(){var pe,re,le,Q,se,De=new Array(m+1);for(Q=le=0;Q<l-1;Q++)for(P[Q]=le,pe=0;pe<1<<S[Q];pe++)k[le++]=Q;for(k[le-1]=Q,Q=se=0;Q<16;Q++)for(L[Q]=se,pe=0;pe<1<<F[Q];pe++)D[se++]=Q;for(se>>=7;Q<d;Q++)for(L[Q]=se<<7,pe=0;pe<1<<F[Q]-7;pe++)D[256+se++]=Q;for(re=0;re<=m;re++)De[re]=0;for(pe=0;pe<=143;)A[2*pe+1]=8,pe++,De[8]++;for(;pe<=255;)A[2*pe+1]=9,pe++,De[9]++;for(;pe<=279;)A[2*pe+1]=7,pe++,De[7]++;for(;pe<=287;)A[2*pe+1]=8,pe++,De[8]++;for(V(A,u+1,De),pe=0;pe<d;pe++)T[2*pe+1]=5,T[2*pe]=H(pe,5);I=new _(A,S,c+1,u,m),B=new _(T,F,0,d,m),M=new _(new Array(0),w,0,p,g)})(),fe=!0),j.l_desc=new R(j.dyn_ltree,I),j.d_desc=new R(j.dyn_dtree,B),j.bl_desc=new R(j.bl_tree,M),j.bi_buf=0,j.bi_valid=0,ne(j)},n._tr_stored_block=$,n._tr_flush_block=function(j,pe,re,le){var Q,se,De=0;0<j.level?(j.strm.data_type===2&&(j.strm.data_type=(function(Ae){var ye,$e=4093624447;for(ye=0;ye<=31;ye++,$e>>>=1)if(1&$e&&Ae.dyn_ltree[2*ye]!==0)return o;if(Ae.dyn_ltree[18]!==0||Ae.dyn_ltree[20]!==0||Ae.dyn_ltree[26]!==0)return i;for(ye=32;ye<c;ye++)if(Ae.dyn_ltree[2*ye]!==0)return i;return o})(j)),K(j,j.l_desc),K(j,j.d_desc),De=(function(Ae){var ye;for(G(Ae,Ae.dyn_ltree,Ae.l_desc.max_code),G(Ae,Ae.dyn_dtree,Ae.d_desc.max_code),K(Ae,Ae.bl_desc),ye=p-1;3<=ye&&Ae.bl_tree[2*C[ye]+1]===0;ye--);return Ae.opt_len+=3*(ye+1)+5+5+4,ye})(j),Q=j.opt_len+3+7>>>3,(se=j.static_len+3+7>>>3)<=Q&&(Q=se)):Q=se=re+5,re+4<=Q&&pe!==-1?$(j,pe,re,le):j.strategy===4||se===Q?(z(j,2+(le?1:0),3),te(j,A,T)):(z(j,4+(le?1:0),3),(function(Ae,ye,$e,Pe){var Ne;for(z(Ae,ye-257,5),z(Ae,$e-1,5),z(Ae,Pe-4,4),Ne=0;Ne<Pe;Ne++)z(Ae,Ae.bl_tree[2*C[Ne]+1],3);ie(Ae,Ae.dyn_ltree,ye-1),ie(Ae,Ae.dyn_dtree,$e-1)})(j,j.l_desc.max_code+1,j.d_desc.max_code+1,De+1),te(j,j.dyn_ltree,j.dyn_dtree)),ne(j),le&&Z(j)},n._tr_tally=function(j,pe,re){return j.pending_buf[j.d_buf+2*j.last_lit]=pe>>>8&255,j.pending_buf[j.d_buf+2*j.last_lit+1]=255&pe,j.pending_buf[j.l_buf+j.last_lit]=255&re,j.last_lit++,pe===0?j.dyn_ltree[2*re]++:(j.matches++,pe--,j.dyn_ltree[2*(k[re]+c+1)]++,j.dyn_dtree[2*O(pe)]++),j.last_lit===j.lit_bufsize-1},n._tr_align=function(j){z(j,2,3),U(j,y,A),(function(pe){pe.bi_valid===16?(N(pe,pe.bi_buf),pe.bi_buf=0,pe.bi_valid=0):8<=pe.bi_valid&&(pe.pending_buf[pe.pending++]=255&pe.bi_buf,pe.bi_buf>>=8,pe.bi_valid-=8)})(j)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){(function(r){(function(o,i){"use strict";if(!o.setImmediate){var a,s,l,c,u=1,d={},p=!1,f=o.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(o);m=m&&m.setTimeout?m:o,a={}.toString.call(o.process)==="[object process]"?function(b){process.nextTick(function(){g(b)})}:(function(){if(o.postMessage&&!o.importScripts){var b=!0,x=o.onmessage;return o.onmessage=function(){b=!1},o.postMessage("","*"),o.onmessage=x,b}})()?(c="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",y,!1):o.attachEvent("onmessage",y),function(b){o.postMessage(c+b,"*")}):o.MessageChannel?((l=new MessageChannel).port1.onmessage=function(b){g(b.data)},function(b){l.port2.postMessage(b)}):f&&"onreadystatechange"in f.createElement("script")?(s=f.documentElement,function(b){var x=f.createElement("script");x.onreadystatechange=function(){g(b),x.onreadystatechange=null,s.removeChild(x),x=null},s.appendChild(x)}):function(b){setTimeout(g,0,b)},m.setImmediate=function(b){typeof b!="function"&&(b=new Function(""+b));for(var x=new Array(arguments.length-1),v=0;v<x.length;v++)x[v]=arguments[v+1];var S={callback:b,args:x};return d[u]=S,a(u),u++},m.clearImmediate=h}function h(b){delete d[b]}function g(b){if(p)setTimeout(g,0,b);else{var x=d[b];if(x){p=!0;try{(function(v){var S=v.callback,F=v.args;switch(F.length){case 0:S();break;case 1:S(F[0]);break;case 2:S(F[0],F[1]);break;case 3:S(F[0],F[1],F[2]);break;default:S.apply(i,F)}})(x)}finally{h(b),p=!1}}}}function y(b){b.source===o&&typeof b.data=="string"&&b.data.indexOf(c)===0&&g(+b.data.slice(c.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})});function _sr(e){if(e.includes("\0")||e.includes("\\")||/^[A-Za-z]:/u.test(e))return!1;let t=e.startsWith("/")?e.slice(1):e;return t.startsWith("/")?!1:!t.split("/").some(n=>n==="..")}function Usr(e){let t=e._data,n=Number(t?.uncompressedSize??0);return Number.isFinite(n)&&n>0?n:0}function t3t(e){let t=e.createError;return{maxEntries:e.maxEntries??FHe.maxEntries,maxEntryBytes:e.maxEntryBytes??FHe.maxEntryBytes,maxTotalBytes:e.maxTotalBytes??FHe.maxTotalBytes,label:e.label??"ZIP",fail:(n,r,o,i)=>t?t(n,{limit:r,kind:o,actual:i}):new cfi(n,{limit:r,kind:o,actual:i})}}async function ufi(e,t,n){let r=[],o=0;for await(let s of dfi(e,t,n))r.push(s),o+=s.byteLength;if(r.length===1&&r[0])return r[0];let i=new Uint8Array(o),a=0;for(let s of r)i.set(s,a),a+=s.byteLength;return i}async function*dfi(e,t,n){let r=t3t(n),o=Usr(e),i=e.internalStream("uint8array"),a=[],s=0,l=!1,c=!1,u,d=!1,p,f=()=>{d=!0,i.pause()},m=()=>{!d||c||(d=!1,i.resume())},h=g=>{u??=g,c=!0,a.length=0,f(),p?.()};i.on("data",g=>{if(c)return f();if(s+=g.byteLength,s>o||s>r.maxEntryBytes)return h(r.fail(`${r.label} part ${e.name} inflates past its declared size`,r.maxEntryBytes,s>o?"declaredSize":"maxEntryBytes",s));if(t+s>r.maxTotalBytes)return h(r.fail(`${r.label} package exceeds the ${e3t(r.maxTotalBytes)} MiB uncompressed content limit`,r.maxTotalBytes,"maxTotalBytes",t+s));a.push(g),a.length>=Osr&&f(),p?.()}),i.on("error",g=>h(g)),i.on("end",()=>{l=!0,p?.()}),i.resume();try{for(;;){if(u)throw u;let g=a.shift();if(g){a.length<Osr/2&&m(),yield g;continue}if(l)return;await new Promise(y=>{p=y,m()}),p=void 0}}finally{c=!0,l||f()}}function pfi(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function n3t(e,t={}){let n=t3t(t),r=Object.values(e.files);if(r.length>n.maxEntries)throw n.fail(`${n.label} package exceeds the ${n.maxEntries.toLocaleString("en-US")} part limit`,n.maxEntries,"maxEntries",r.length);let o=0;for(let s of r){let l=s.unsafeOriginalName;if(!_sr(s.name)||l!==void 0&&!_sr(l))throw n.fail(`${n.label} package has an unsafe part name`,n.maxEntries,"partName");if(s.dir)continue;let c=Usr(s);if(c>n.maxEntryBytes)throw n.fail(`${n.label} part ${s.name} exceeds the uncompressed part size limit`,n.maxEntryBytes,"maxEntryBytes",c);o+=c}if(o>n.maxTotalBytes)throw n.fail(`${n.label} package exceeds the ${e3t(n.maxTotalBytes)} MiB uncompressed content limit`,n.maxTotalBytes,"maxTotalBytes",o);let i=new Map,a=0;for(let s of r){if(s.dir)continue;let l=s.async.bind(s);s.async=async(c,u)=>{let d=i.get(s.name)??0,p=await ufi(s,a-d,t);switch(p.byteLength>d&&(a+=p.byteLength-d,i.set(s.name,p.byteLength)),c){case"uint8array":return p;case"string":case"text":return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(p);case"arraybuffer":return p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength);case"base64":return pfi(p);default:return l(c,u)}}}return e}async function CHe(e,t={}){let n=t3t(t),r=t.maxInputBytes??FHe.maxInputBytes,o=e instanceof Uint8Array?e:new Uint8Array(e);if(o.byteLength>r)throw n.fail(`${n.label} package exceeds the ${e3t(r)} MiB compressed input limit`,r,"maxInputBytes",o.byteLength);return n3t(await Nsr.default.loadAsync(o),t)}function AHe(e){return CHe(e,{label:"PPTX",maxInputBytes:_1e,maxEntries:O1e,maxEntryBytes:_1e,maxTotalBytes:_1e,createError:Hsr})}function Gsr(e){return CHe(e,{label:"Embedded",createError:Hsr})}var Nsr,_1e,O1e,N1e,zsr,FHe,cfi,e3t,Osr,Hsr,r3t=X(()=>{Nsr=yC(gHe(),1),_1e=500*1024*1024,O1e=65536,N1e=class extends Error{constructor(t,n){super(t);ze(this,"code","ZIP_BOMB");ze(this,"uncompressedBytes");ze(this,"limit");ze(this,"entryCount");ze(this,"loadLimit");ze(this,"actual");this.name="ZipBombError",this.uncompressedBytes=n.uncompressedBytes,this.limit=n.limit,this.entryCount=n.entryCount,this.loadLimit=n.loadLimit,this.actual=n.actual}},zsr="http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin",FHe={maxInputBytes:100*1024*1024,maxEntries:1e4,maxEntryBytes:100*1024*1024,maxTotalBytes:100*1024*1024},cfi=class extends Error{constructor(t,n){super(t);ze(this,"code","ZIP_BOMB");ze(this,"limit");ze(this,"kind");ze(this,"actual");this.name="ZipLimitError",this.limit=n.limit,this.kind=n.kind,this.actual=n.actual}},e3t=e=>Math.round(e/1048576);Osr=8;Hsr=(e,t)=>new N1e(e,t)});function mfi(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function a3t(e,t){if(Array.isArray(e)){let o=t.get(e);if(o!==void 0)return o;let i=new Array(e.length);t.set(e,i);for(let a=0;a<e.length;a++)i[a]=a3t(e[a],t);return i}if(!mfi(e))return e;let n=t.get(e);if(n!==void 0)return n;let r={};t.set(e,r);for(let o of Object.keys(e)){let i=e[o];r[o]=ffi.has(o)?i:a3t(i,t)}return r}function hfi(e){return a3t(e,new WeakMap)}function Ksr(e){return hfi(e)}function Co(e){if(e)try{return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}catch(t){console.warn("Failed to clone XML object, returning undefined.",e,t);return}}function z1e(e){if(e===void 0||e.trim()==="")return;if(e==="NaN")return Number.NaN;if(e==="INF")return Number.POSITIVE_INFINITY;if(e==="-INF")return Number.NEGATIVE_INFINITY;let t=Number(e);return Number.isNaN(t)?void 0:t}function yfi(e){return Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"INF":e===Number.NEGATIVE_INFINITY?"-INF":String(e)}function Jsr(e){return{for:e("for"),forName:e("forName"),pointType:e("ptType")}}function bfi(e,t){return{type:e("type")??"",...Jsr(e),referenceType:e("refType"),referenceFor:e("refFor"),referenceForName:e("refForName"),referencePointType:e("refPtType"),operator:e("op"),value:z1e(e("val")),factor:z1e(e("fact")),rawXml:t}}function xfi(e,t){return{type:e("type")??"",...Jsr(e),value:z1e(e("val")),factor:z1e(e("fact")),max:z1e(e("max")),rawXml:t}}function jsr(e,t){let n=[];return Ysr.has(e.type)||n.push(`${t}.type is invalid`),e.for!==void 0&&!$sr.has(e.for)&&n.push(`${t}.for is invalid`),e.pointType!==void 0&&!Zsr.has(e.pointType)&&n.push(`${t}.pointType is invalid`),n}function Qsr(e){let t=[];return e.constraints?.forEach((n,r)=>{let o=`constraints[${r}]`;t.push(...jsr(n,o)),n.referenceType!==void 0&&!Ysr.has(n.referenceType)&&t.push(`${o}.referenceType is invalid`),n.referenceFor!==void 0&&!$sr.has(n.referenceFor)&&t.push(`${o}.referenceFor is invalid`),n.referencePointType!==void 0&&!Zsr.has(n.referencePointType)&&t.push(`${o}.referencePointType is invalid`),n.operator!==void 0&&!gfi.has(n.operator)&&t.push(`${o}.operator is invalid`)}),e.rules?.forEach((n,r)=>t.push(...jsr(n,`rules[${r}]`))),t}function s3t(e){return typeof e=="number"?yfi(e):e}function elr(e){return[["type",e.type],["for",e.for],["forName",e.forName],["ptType",e.pointType],["val",s3t(e.value)],["fact",s3t(e.factor)]]}function vfi(e){return[...elr(e),["refType",e.referenceType],["refFor",e.referenceFor],["refForName",e.referenceForName],["refPtType",e.referencePointType],["op",e.operator]]}function Sfi(e){return[...elr(e),["max",s3t(e.max)]]}function DHe(e,t,n){return Object.keys(e).find(r=>n(r)===t)}function l3t(e,t,n){let r=DHe(e,t,n),o=r?e[r]:void 0;return o&&typeof o=="object"&&!Array.isArray(o)?o:void 0}function c3t(e,t,n){let r=DHe(e,t,n),o=r?e[r]:void 0;return Array.isArray(o)?o:o&&typeof o=="object"?[o]:[]}function wfi(e,t,n){let r=Object.keys(e).find(o=>o.startsWith("@_")&&n(o.replace(/^@_/u,""))===t);return r&&e[r]!==void 0?String(e[r]):void 0}function tlr(e,t){return n=>wfi(e,n,t)}function u3t(e,t){return bfi(tlr(e,t),Co(e))}function nlr(e,t){return xfi(tlr(e,t),Co(e))}function Ffi(e,t){let n=l3t(e,"constrLst",t),r=l3t(e,"ruleLst",t);return{constraints:n?c3t(n,"constr",t).map(o=>u3t(o,t)):void 0,rules:r?c3t(r,"rule",t).map(o=>nlr(o,t)):void 0}}function Cfi(e,t,n){for(let[r,o]of t){let i=Object.keys(e).find(a=>a.startsWith("@_")&&n(a.replace(/^@_/u,""))===r)??`@_${r}`;o===void 0?delete e[i]:e[i]=o}}function Afi(e){return e?.includes(":")?`${e.slice(0,e.indexOf(":"))}:`:"dgm:"}function Tfi(e,t,n){if(Qsr(t).length>0)return!1;for(let[r,o,i]of[["constrLst","constr",t.constraints],["ruleLst","rule",t.rules]]){if(i===void 0)continue;let a=DHe(e,r,n)??`dgm:${r}`,s=l3t(e,r,n)??{},l=c3t(s,o,n),c=DHe(s,o,n)??`${Afi(a)}${o}`;for(let u of Object.keys(s))n(u)===o&&delete s[u];s[c]=i.map((u,d)=>{let p=Co(l[d])??Co(u.rawXml)??{};return Cfi(p,o==="constr"?vfi(u):Sfi(u),n),p}),e[a]=s}return!0}function Dfi(e,t,n){let r=Object.keys(e).find(i=>n(i)===t),o=r?e[r]:void 0;return Array.isArray(o)?o[0]:o}function rlr(e,t,n){let r=Object.keys(e).find(i=>n(i)===t),o=r?e[r]:void 0;return Array.isArray(o)?o:o&&typeof o=="object"?[o]:[]}function o3t(e){let t=String(e??"").trim();return t.length>0?t:void 0}function kfi(e,t){let n=Dfi(e,"alg",t),r=n?o3t(n["@_type"]):void 0;if(!n||!r)return;let o=Number(n["@_rev"]),i=Number.isInteger(o)&&o>=0&&o<=4294967295?o:void 0,a=rlr(n,"param",t).map(s=>{let l=o3t(s["@_type"]);return l?{type:l,value:o3t(s["@_val"])}:void 0}).filter(s=>s!==void 0);return{type:r,...i===void 0?{}:{revision:i},...a.length===0?{}:{parameters:a}}}function Efi(e){let t=e.algorithm;if(!t)return[];let n=[];return t.type.trim()||n.push("algorithm.type is required"),t.revision!==void 0&&(!Number.isInteger(t.revision)||t.revision<0||t.revision>4294967295)&&n.push("algorithm.revision must be an unsigned 32-bit integer"),t.parameters?.forEach((r,o)=>{r.type.trim()||n.push(`algorithm.parameters[${o}].type is required`)}),n}function Ifi(e,t){let n={},r=!1;for(let[o,i]of Object.entries(e))!r&&!o.startsWith("@_")&&(n["dgm:alg"]=t,r=!0),n[o]=i;r||(n["dgm:alg"]=t);for(let o of Object.keys(e))delete e[o];Object.assign(e,n)}function Pfi(e,t,n){let r=Object.keys(e).find(i=>n(i)==="alg");if(!t){r&&delete e[r];return}let o=r?e[r]:{};if(o["@_type"]=t.type,t.revision===void 0?delete o["@_rev"]:o["@_rev"]=String(t.revision),t.parameters!==void 0){let i=Object.keys(o).find(s=>n(s)==="param")??"dgm:param",a=rlr(o,"param",n);o[i]=t.parameters.map((s,l)=>{let c=a[l]??{};return c["@_type"]=s.type,s.value===void 0?delete c["@_val"]:c["@_val"]=s.value,c})}r||Ifi(e,o)}function mV(e){let t=(e??"").trim();return t.length>0?t:void 0}function kHe(e){let t=mV(e)?.split(/\s+/u);return t?.length?t:void 0}function Mfi(e){let t=kHe(e);if(!(!t||t.some(n=>!["0","1","true","false"].includes(n))))return t.map(n=>n==="1"||n==="true")}function i3t(e,t=!1){let n=kHe(e);if(!n)return;let r=n.map(Number);if(!r.some(o=>!Number.isInteger(o)||o<(t?0:-2147483648)||o>(t?olr:2147483647)))return r}function Bfi(e){return t=>e.attrs[t]}function ilr(e){return{name:mV(e("name")),reference:mV(e("ref")),axis:kHe(e("axis")),pointTypes:kHe(e("ptType")),hideLastTransition:Mfi(e("hideLastTrans")),start:i3t(e("st")),count:i3t(e("cnt"),!0),step:i3t(e("step"))}}function alr(e,t){let n=mV(e("func")),r=mV(e("op")),o=mV(e("val"));return n&&r&&o?{...ilr(e),function:n,argument:mV(e("arg")),operator:r,value:o,rawXml:t}:void 0}function slr(e){return alr(Bfi(e),e)}function Lfi(e){let t=[],n=(r,o)=>{for(let i of["start","step"])r[i]?.some(a=>!Number.isInteger(a)||a<-2147483648||a>2147483647)&&t.push(`${o}.${i} values must be signed 32-bit integers`);r.count?.some(i=>!Number.isInteger(i)||i<0||i>olr)&&t.push(`${o}.count values must be unsigned 32-bit integers`)};return e.forEach?.forEach((r,o)=>n(r,`forEach[${o}]`)),e.choose?.forEach((r,o)=>{r.when.length===0&&t.push(`choose[${o}].when requires at least one branch`),r.when.forEach((i,a)=>{let s=`choose[${o}].when[${a}]`;n(i,s);for(let l of["function","operator","value"])i[l].trim()||t.push(`${s}.${l} is required`)})}),t}function THe(e,t,n){let r=Object.keys(e).find(i=>n(i)===t),o=r?e[r]:void 0;return Array.isArray(o)?o:o&&typeof o=="object"?[o]:[]}function llr(e){return t=>{let n=e[`@_${t}`];return n==null?void 0:String(n)}}function Vsr(e){let t=String(e??"").trim();return t.length>0?t:void 0}function EHe(e){return ilr(llr(e))}function qne(e){return alr(llr(e),e)}function Rfi(e,t){let n=THe(e,"forEach",t).map(o=>({...EHe(o),rawXml:o})),r=THe(e,"choose",t).map(o=>{let i=THe(o,"else",t)[0];return{name:Vsr(o["@_name"]),when:THe(o,"if",t).map(qne).filter(a=>a!==void 0),otherwise:i?{name:Vsr(i["@_name"]),rawXml:i}:void 0,rawXml:o}});return{...n.length?{forEach:n}:{},...r.length?{choose:r}:{}}}function lv(e,t,n){n===void 0?delete e[`@_${t}`]:e[`@_${t}`]=n}function clr(e,t){lv(e,"name",t.name),lv(e,"ref",t.reference),lv(e,"axis",t.axis?.join(" ")),lv(e,"ptType",t.pointTypes?.join(" ")),lv(e,"hideLastTrans",t.hideLastTransition?.map(n=>n?"1":"0").join(" ")),lv(e,"st",t.start?.join(" ")),lv(e,"cnt",t.count?.join(" ")),lv(e,"step",t.step?.join(" "))}function _fi(e){let t={...e.rawXml??{}};return clr(t,e),lv(t,"func",e.function),lv(t,"arg",e.argument),lv(t,"op",e.operator),lv(t,"val",e.value),t}function Ofi(e,t){let n={...e.rawXml??{}};lv(n,"name",e.name);let r=Object.keys(n).find(i=>t(i)==="if")??"dgm:if";n[r]=e.when.map(_fi);let o=Object.keys(n).find(i=>t(i)==="else")??"dgm:else";if(e.otherwise===null)delete n[o];else if(e.otherwise){let i={...e.otherwise.rawXml??{}};lv(i,"name",e.otherwise.name),n[o]=i}return n}function Xsr(e,t,n,r){if(n===void 0)return;let o=Object.keys(e).find(i=>r(i)===t)??`dgm:${t}`;n.length===0?delete e[o]:e[o]=n}function Nfi(e,t,n){Xsr(e,"forEach",t.forEach?.map(r=>{let o={...r.rawXml??{}};return clr(o,r),o}),n),Xsr(e,"choose",t.choose?.map(r=>Ofi(r,n)),n)}function zfi(e,t,n){let r=Object.keys(e).find(i=>n(i)===t),o=r?e[r]:void 0;return Array.isArray(o)?o:o&&typeof o=="object"?[o]:[]}function Ufi(e,t){let n=[],r=(o,i)=>{if(!(!o||typeof o!="object")){if(Array.isArray(o)){o.forEach(a=>r(a,i));return}for(let[a,s]of Object.entries(o)){if(a.startsWith("@_"))continue;let l=t(a);if(l!=="layoutNode"){if(l==="constrLst"){for(let c of Array.isArray(s)?s:[s])if(c&&typeof c=="object")for(let u of zfi(c,"constr",t))n.push({constr:u,guard:i});continue}if(l==="if"){for(let c of Array.isArray(s)?s:[s])if(c&&typeof c=="object"){let u=qne(c);r(c,u?[...i,u]:i)}continue}if(l==="else"){for(let c of Array.isArray(s)?s:[s])c&&typeof c=="object"&&r(c,i);continue}r(s,i)}}}};for(let[o,i]of Object.entries(e))!o.startsWith("@_")&&t(o)!=="extLst"&&r({[o]:i},[]);return n}function Hfi(e,t){let n=Ufi(e,t);return n.length>1?n:void 0}function ulr(e,t,n){let r=Object.keys(e).find(i=>n(i)===t),o=r?e[r]:void 0;return Array.isArray(o)?o:o&&typeof o=="object"?[o]:[]}function Gfi(e,t){let n=[],r=o=>{if(!(!o||typeof o!="object")){if(Array.isArray(o)){o.forEach(r);return}for(let[i,a]of Object.entries(o)){if(i.startsWith("@_"))continue;let s=t(i);if(s!=="layoutNode"){if(s==="constrLst"){for(let l of Array.isArray(a)?a:[a])l&&typeof l=="object"&&n.push(...ulr(l,"constr",t));continue}r(a)}}}};for(let[o,i]of Object.entries(e))!o.startsWith("@_")&&t(o)!=="extLst"&&r({[o]:i});return n}function jfi(e){return typeof e["@_axis"]=="string"&&e["@_axis"].trim().length>0}function dlr(e,t){let n=[],r=(o,i)=>{if(!(!o||typeof o!="object")){if(Array.isArray(o)){o.forEach(a=>r(a,i));return}for(let[a,s]of Object.entries(o)){if(a.startsWith("@_"))continue;let l=t(a);if(l!=="layoutNode"){if(l==="presOf"){for(let c of Array.isArray(s)?s:[s])n.push({presOf:c&&typeof c=="object"?c:{},guard:i});continue}if(l==="if"){for(let c of Array.isArray(s)?s:[s])if(c&&typeof c=="object"){let u=qne(c);r(c,u?[...i,u]:i)}continue}if(l==="else"){for(let c of Array.isArray(s)?s:[s])c&&typeof c=="object"&&r(c,i);continue}r(s,i)}}}};for(let[o,i]of Object.entries(e))!o.startsWith("@_")&&t(o)!=="extLst"&&r({[o]:i},[]);return n}function Vfi(e,t){let n=dlr(e,t).map(r=>r.presOf);return n.find(jfi)??n[0]}function Xfi(e,t){let n=dlr(e,t);return n.length>1?n:void 0}function Wfi(e,t){let n=[],r=(o,i)=>{if(!(!o||typeof o!="object")){if(Array.isArray(o)){o.forEach(a=>r(a,i));return}for(let[a,s]of Object.entries(o)){if(a.startsWith("@_"))continue;let l=t(a);if(l!=="layoutNode"){if(l==="ruleLst"){for(let c of Array.isArray(s)?s:[s])if(c&&typeof c=="object")for(let u of ulr(c,"rule",t))n.push({rule:u,guard:i});continue}if(l==="if"){for(let c of Array.isArray(s)?s:[s])if(c&&typeof c=="object"){let u=qne(c);r(c,u?[...i,u]:i)}continue}if(l==="else"){for(let c of Array.isArray(s)?s:[s])c&&typeof c=="object"&&r(c,i);continue}r(s,i)}}}};for(let[o,i]of Object.entries(e))!o.startsWith("@_")&&t(o)!=="extLst"&&r({[o]:i},[]);return n}function qfi(e,t){let n=Wfi(e,t);return n.length>1?n:void 0}function plr(e,t){let n=[],r=0,o=(i,a,s,l,c)=>{if(!(!i||typeof i!="object")){if(Array.isArray(i)){i.forEach(u=>o(u,a,s,l,c));return}for(let[u,d]of Object.entries(i)){if(u.startsWith("@_"))continue;let p=t(u);if(p==="layoutNode")for(let f of Array.isArray(d)?d:[d])f&&typeof f=="object"&&n.push({xml:f,origin:a,guard:s,guardOrigins:l,groups:c});else if(p==="forEach")for(let f of Array.isArray(d)?d:[d])f&&typeof f=="object"&&o(f,EHe(f),s,l,c);else if(p==="choose")for(let f of Array.isArray(d)?d:[d]){if(!f||typeof f!="object")continue;let m=`choose${r++}`,h=0;for(let[g,y]of Object.entries(f)){if(g.startsWith("@_"))continue;let b=t(g);if(b==="if"){for(let x of Array.isArray(y)?y:[y])if(x&&typeof x=="object"){let v=qne(x);o(x,a,v?[...s,v]:s,v?[...l,a]:l,[...c,{id:m,ordinal:h++,guard:v,origin:a}])}}else if(b==="else")for(let x of Array.isArray(y)?y:[y])x&&typeof x=="object"&&o(x,a,s,l,[...c,{id:m,ordinal:h++,origin:a}]);else o(y,a,s,l,c)}}else if(p==="if"){for(let f of Array.isArray(d)?d:[d])if(f&&typeof f=="object"){let m=qne(f);o(f,a,m?[...s,m]:s,m?[...l,a]:l,c)}}else if(p==="else")for(let f of Array.isArray(d)?d:[d])f&&typeof f=="object"&&o(f,a,s,l,c);else o(d,a,s,l,c)}}};for(let[i,a]of Object.entries(e))!i.startsWith("@_")&&t(i)!=="extLst"&&o({[i]:a},void 0,[],[],[]);return n}function flr(e,t,n){if(!e)return;let r=Object.keys(e).find(i=>n(i)===t),o=r?e[r]:void 0;return Array.isArray(o)?o[0]:o}function Kfi(e,t,n){if(!e)return[];let r=Object.keys(e).find(i=>n(i)===t),o=r?e[r]:void 0;return Array.isArray(o)?o:o&&typeof o=="object"?[o]:[]}function Yfi(e){let t=String(e["@_hideGeom"]??"").trim().toLowerCase();return t==="1"||t==="true"?!0:void 0}function $fi(e){if(!e)return!1;let t=String(e["@_lkTxEntry"]??"").trim().toLowerCase();return t==="1"||t==="true"}function Zfi(e,t){let n=flr(e,"adjLst",t),r=Kfi(n,"adj",t).map(o=>{let i=Number.parseInt(String(o["@_idx"]??""),10),a=Number.parseFloat(String(o["@_val"]??""));return Number.isInteger(i)&&Number.isFinite(a)?{index:i,value:a}:void 0}).filter(o=>!!o);return r.length>0?r:void 0}function Jfi(e,t){let n=[],r=o=>{if(!(!o||typeof o!="object")){if(Array.isArray(o)){o.forEach(r);return}for(let[i,a]of Object.entries(o)){if(i.startsWith("@_"))continue;let s=t(i);if(s!=="layoutNode"){if(s==="shape"){for(let l of Array.isArray(a)?a:[a])n.push(l&&typeof l=="object"?l:{});continue}r(a)}}}};for(let[o,i]of Object.entries(e))!o.startsWith("@_")&&t(o)!=="extLst"&&r({[o]:i});return n}function Qfi(e,t){let n=flr(e,"shape",t)??Jfi(e,t)[0];if(!n)return;let r=String(n["@_type"]??"").trim()||void 0,o=Yfi(n),i=Zfi(n,t),a=$fi(n)||void 0;if(!(!r&&!o&&!i&&!a))return{...r?{presetGeometry:r}:{},...i?{adjustments:i}:{},...o?{hideGeometry:o}:{},...a?{lkTxEntry:a}:{}}}function emi(e,t,n){if(t===void 0)return;let r=Object.keys(e).find(a=>n(a)==="shape"),i=(r?e[r]:void 0)??{};if(t.presetGeometry!==void 0?i["@_type"]=t.presetGeometry:delete i["@_type"],t.hideGeometry?i["@_hideGeom"]="1":delete i["@_hideGeom"],t.lkTxEntry?i["@_lkTxEntry"]="1":delete i["@_lkTxEntry"],t.adjustments&&t.adjustments.length>0){let a=Object.keys(i).find(c=>n(c)==="adjLst")??"dgm:adjLst",s=i[a]??{},l=Object.keys(s).find(c=>n(c)==="adj")??"dgm:adj";s[l]=t.adjustments.map(c=>({"@_idx":String(c.index),"@_val":String(c.value)})),i[a]=s}e[r??"dgm:shape"]=i}function IHe(e,t,n){if(!e)return;let r=Object.keys(e).find(i=>n(i)===t),o=r?e[r]:void 0;return Array.isArray(o)?o[0]:o}function U1e(e,t,n){if(!e)return[];let r=Object.keys(e).find(i=>n(i)===t),o=r?e[r]:void 0;return Array.isArray(o)?o:o&&typeof o=="object"?[o]:[]}function TE(e){let t=String(e??"").trim();return t.length>0?t:void 0}function Wsr(e){let t=TE(e["@_val"]);return t?{value:t,language:TE(e["@_lang"])}:void 0}function mlr(e,t){let n=plr(e,t).map(u=>({...mlr(u.xml,t),forEachOrigin:u.origin,chooseGuard:u.guard.length>0?u.guard:void 0,chooseGuardOrigins:u.guard.length>0?u.guardOrigins:void 0,chooseGroups:u.groups.length>0?u.groups:void 0})),r=TE(e["@_chOrder"]),o=Vfi(e,t),i=o?EHe(o):void 0,a=Gfi(e,t).map(u=>u3t(u,t)),s=Xfi(e,t)?.map(u=>({guard:u.guard,presentationOf:EHe(u.presOf)})),l=qfi(e,t)?.map(u=>({guard:u.guard,rule:nlr(u.rule,t)})),c=Hfi(e,t)?.map(u=>({guard:u.guard,constraint:u3t(u.constr,t)}));return{name:TE(e["@_name"]),styleLabel:TE(e["@_styleLbl"]),childOrder:r==="b"||r==="t"?r:void 0,moveWith:TE(e["@_moveWith"]),algorithm:kfi(e,t),...Rfi(e,t),...Ffi(e,t),shape:Qfi(e,t),presentationOf:i&&(i.axis?.length??0)>0?i:void 0,presentationOfCandidates:s,allConstraints:a.length>0?a:void 0,ruleCandidates:l,constraintCandidates:c,children:n.length>0?n:void 0}}function hlr(e,t){let n=IHe(e,"layoutNode",t);if(!e||!n)return;let r=IHe(e,"catLst",t),o=U1e(r,"cat",t).map(i=>{let a=TE(i["@_type"]),s=Number(i["@_pri"]);return a&&Number.isInteger(s)&&s>=0?{type:a,priority:s}:void 0}).filter(i=>!!i);return{uniqueId:TE(e["@_uniqueId"]),minimumVersion:TE(e["@_minVer"]),defaultStyle:TE(e["@_defStyle"]),titles:U1e(e,"title",t).map(Wsr).filter(Boolean),descriptions:U1e(e,"desc",t).map(Wsr).filter(Boolean),categories:o.length>0?o:void 0,rootNode:mlr(n,t),rawXml:JSON.parse(JSON.stringify(e))}}function tmi(e){let t=[],n=(r,o)=>{t.push(...Qsr(r).map(i=>`${o}.${i}`)),t.push(...Efi(r).map(i=>`${o}.${i}`)),t.push(...Lfi(r).map(i=>`${o}.${i}`)),r.childOrder!==void 0&&r.childOrder!=="b"&&r.childOrder!=="t"&&t.push(`${o}.childOrder must be b or t`),r.children?.forEach((i,a)=>n(i,`${o}.children[${a}]`))};n(e.rootNode,"rootNode"),e.categories?.forEach((r,o)=>{r.type.trim()||t.push(`categories[${o}].type is required`),(!Number.isInteger(r.priority)||r.priority<0||r.priority>4294967295)&&t.push(`categories[${o}].priority must be an unsigned 32-bit integer`)});for(let[r,o]of[["titles",e.titles],["descriptions",e.descriptions]])o?.forEach((i,a)=>{i.value.trim()||t.push(`${r}[${a}].value is required`)});return t}function rO(e,t,n){n===void 0?delete e[t]:e[t]=n}function glr(e,t,n){rO(e,"@_name",t.name),rO(e,"@_styleLbl",t.styleLabel),rO(e,"@_chOrder",t.childOrder),rO(e,"@_moveWith",t.moveWith),Pfi(e,t.algorithm,n),Nfi(e,t,n),Tfi(e,t,n),emi(e,t.shape,n);let r=plr(e,n);t.children?.forEach((o,i)=>{r[i]&&glr(r[i].xml,o,n)})}function qsr(e,t,n,r){if(n===void 0)return;let o=Object.keys(e).find(a=>r(a)===t)??`dgm:${t}`,i=U1e(e,t,r);e[o]=n.map((a,s)=>{let l=i[s]??{};return l["@_val"]=a.value,rO(l,"@_lang",a.language),l})}function ylr(e,t,n){if(tmi(t).length>0)return!1;let r=IHe(e,"layoutNode",n);if(!r)return!1;if(rO(e,"@_uniqueId",t.uniqueId),rO(e,"@_minVer",t.minimumVersion),rO(e,"@_defStyle",t.defaultStyle),qsr(e,"title",t.titles,n),qsr(e,"desc",t.descriptions,n),t.categories!==void 0){let o=IHe(e,"catLst",n);if(o){let i=Object.keys(o).find(s=>n(s)==="cat")??"dgm:cat",a=U1e(o,"cat",n);o[i]=t.categories.map((s,l)=>({...a[l]??{},"@_type":s.type,"@_pri":String(s.priority)}))}}return glr(r,t.rootNode,n),!0}function PHe(e,t){for(let r of t){let o=nmi[r.trim().toLowerCase()];if(o)return o}let n=e.toLowerCase();if(n.length>0){for(let[r,o]of rmi)if(r.test(n))return o}}var ffi,Ysr,$sr,Zsr,gfi,olr,nmi,rmi,MHe=X(()=>{ffi=new Set(["rawXml","rawTiming","inkPartRawXml","rawMediaReferenceXml"]);Ysr=new Set(["none","alignOff","begMarg","bendDist","begPad","bkPtFixedVal","b","bMarg","bOff","ctrX","ctrXOff","ctrY","ctrYOff","connDist","diam","endMarg","endPad","h","hArH","hOff","l","lMarg","lOff","r","rMarg","rOff","primFontSz","pyraAcctRatio","secFontSz","sibSp","secSibSp","sp","stemThick","t","tMarg","tOff",...Array.from({length:26},(e,t)=>`user${String.fromCharCode(65+t)}`),"w","wArH","wOff"]),$sr=new Set(["self","ch","des"]),Zsr=new Set(["all","doc","node","norm","nonNorm","asst","nonAsst","parTrans","pres","sibTrans"]),gfi=new Set(["none","equ","gte","lte"]);olr=4294967295;nmi={list:"list",process:"process",cycle:"cycle",hierarchy:"hierarchy",relationship:"relationship",matrix:"matrix",pyramid:"pyramid"},rmi=[[/hier|org/u,"hierarchy"],[/cycle|radial|circular/u,"cycle"],[/process|flow|chevron|arrow|equation/u,"process"],[/timeline/u,"timeline"],[/matrix|grid/u,"matrix"],[/pyramid/u,"pyramid"],[/venn/u,"venn"],[/funnel/u,"funnel"],[/gear/u,"gear"],[/target/u,"target"],[/list/u,"list"]]});function tl(e){return Math.min(1,Math.max(0,e))}function f3t(e,t="#111827"){if(!e||e==="transparent")return t;let n=e.startsWith("#")?e:`#${e}`;return/^#[0-9A-Fa-f]{6}$/.test(n)?n:t}function BHe(e){let t=e.replace("#","");return/^[0-9a-fA-F]{6}$/.test(t)?{r:Number.parseInt(t.slice(0,2),16),g:Number.parseInt(t.slice(2,4),16),b:Number.parseInt(t.slice(4,6),16)}:null}function xlr(e,t){if(t===void 0)return e;let n=tl(t);if(n>=1)return e;let r=BHe(e);if(!r)return e;let o=i=>lg(i*n+255*(1-n));return`#${o(r.r)}${o(r.g)}${o(r.b)}`}function omi(e){return e.endsWith("%")?100:1e5}function $h(e){let t=String(e??"").trim(),n=omi(t),r=Number.parseFloat(n===100?t.slice(0,-1):t);if(Number.isFinite(r))return r/n}function Kne(e){let t=$h(e);return t===void 0?void 0:tl(t)}function oO(e){let t=Math.min(1,Math.max(0,e)),n=t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055;return Math.min(255,Math.max(0,Math.round(n*255)))}function lg(e){return Math.min(255,Math.max(0,Math.round(e))).toString(16).padStart(2,"0").toUpperCase()}function Yne(e,t,n){let r=e/255,o=t/255,i=n/255,a=Math.max(r,o,i),s=Math.min(r,o,i),l=a-s,c=(a+s)/2,u=0;l!==0&&(u=l/(1-Math.abs(2*c-1)));let d=0;return l!==0&&(a===r?d=60*((o-i)/l%6):a===o?d=60*((i-r)/l+2):d=60*((r-o)/l+4)),d<0&&(d+=360),{h:d,s:tl(u),l:tl(c)}}function WP(e,t,n,r=Math.round,o){let i=o?.clampSaturation===!1?t:tl(t),a=tl(n),s=(e%360+360)%360,l=(1-Math.abs(2*a-1))*i,c=l*(1-Math.abs(s/60%2-1)),u=a-l/2,d=0,p=0,f=0;return s<60?(d=l,p=c,f=0):s<120?(d=c,p=l,f=0):s<180?(d=0,p=l,f=c):s<240?(d=0,p=c,f=l):s<300?(d=c,p=0,f=l):(d=l,p=0,f=c),{r:r((d+u)*255),g:r((p+u)*255),b:r((f+u)*255)}}function el(e){return $h(e)}function DE(e){let t=Number.parseFloat(String(e??"").trim());if(Number.isFinite(t))return t/6e4}function F1(e){let t=tl(e/255);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function cv(e){let t=tl(e);return 255*(t<=.0031308?t*12.92:1.055*t**(1/2.4)-.055)}function $ne(e,t){let n=BHe(e);if(!n)return e;let r=n.r,o=n.g,i=n.b,a=v=>t[v]?.["@_val"];if(t["a:gamma"]!==void 0){let v=imi(r,o,i);r=v.r,o=v.g,i=v.b}if(t["a:invGamma"]!==void 0){let v=ami(r,o,i);r=v.r,o=v.g,i=v.b}if(t["a:comp"]!==void 0){let v=Yne(r,o,i);v.h=(v.h+180)%360;let S=WP(v.h,v.s,v.l);r=S.r,o=S.g,i=S.b}if(t["a:inv"]!==void 0&&(r=255-r,o=255-o,i=255-i),t["a:gray"]!==void 0){let v=Math.round(.299*r+.587*o+.114*i);r=v,o=v,i=v}let s=Kne(a("a:shade"));s!==void 0&&(r=cv(F1(r)*s),o=cv(F1(o)*s),i=cv(F1(i)*s));let l=Kne(a("a:tint"));if(l!==void 0&&(r=cv(1-(1-F1(r))*l),o=cv(1-(1-F1(o))*l),i=cv(1-(1-F1(i))*l)),["a:hue","a:hueMod","a:hueOff","a:sat","a:satMod","a:satOff","a:lum","a:lumMod","a:lumOff"].some(v=>t[v]!==void 0)){let v=Yne(r,o,i),S=DE(a("a:hue"));S!==void 0&&(v.h=(S%360+360)%360);let F=el(a("a:hueMod"));F!==void 0&&(v.h=(v.h*F%360+360)%360);let w=DE(a("a:hueOff"));w!==void 0&&(v.h=((v.h+w)%360+360)%360);let C=el(a("a:sat"));C!==void 0&&(v.s=tl(C));let A=el(a("a:satMod"));A!==void 0&&(v.s=tl(v.s*A));let T=el(a("a:satOff"));T!==void 0&&(v.s=tl(v.s+T));let D=el(a("a:lum"));D!==void 0&&(v.l=tl(D));let k=el(a("a:lumMod"));k!==void 0&&(v.l=tl(v.l*k));let P=el(a("a:lumOff"));P!==void 0&&(v.l=tl(v.l+P));let I=WP(v.h,v.s,v.l);r=I.r,o=I.g,i=I.b}let d=el(a("a:red"));d!==void 0&&(r=Math.round(tl(d)*255));let p=el(a("a:redMod"));p!==void 0&&(r=Math.min(255,Math.max(0,Math.round(r*p))));let f=el(a("a:redOff"));f!==void 0&&(r=Math.min(255,Math.max(0,Math.round(r+255*f))));let m=el(a("a:green"));m!==void 0&&(o=Math.round(tl(m)*255));let h=el(a("a:greenMod"));h!==void 0&&(o=Math.min(255,Math.max(0,Math.round(o*h))));let g=el(a("a:greenOff"));g!==void 0&&(o=Math.min(255,Math.max(0,Math.round(o+255*g))));let y=el(a("a:blue"));y!==void 0&&(i=Math.round(tl(y)*255));let b=el(a("a:blueMod"));b!==void 0&&(i=Math.min(255,Math.max(0,Math.round(i*b))));let x=el(a("a:blueOff"));return x!==void 0&&(i=Math.min(255,Math.max(0,Math.round(i+255*x)))),`#${lg(r)}${lg(o)}${lg(i)}`}function d3t(e){let t=Math.min(1,Math.max(0,e/255)),n=t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055;return Math.min(255,Math.max(0,Math.round(n*255)))}function p3t(e){let t=Math.min(1,Math.max(0,e/255)),n=t<=.04045?t/12.92:((t+.055)/1.055)**2.4;return Math.min(255,Math.max(0,Math.round(n*255)))}function imi(e,t,n){return{r:d3t(e),g:d3t(t),b:d3t(n)}}function ami(e,t,n){return{r:p3t(e),g:p3t(t),b:p3t(n)}}function lmi(e){return typeof e=="string"&&smi.has(e)}function H1e(e){return String(Math.round(e*1e5))}function LHe(e){let t={"@_val":e.scheme};return e.tint!==void 0&&(t["a:tint"]={"@_val":H1e(e.tint)}),e.shade!==void 0&&(t["a:shade"]={"@_val":H1e(e.shade)}),e.lumMod!==void 0&&(t["a:lumMod"]={"@_val":H1e(e.lumMod)}),e.lumOff!==void 0&&(t["a:lumOff"]={"@_val":H1e(e.lumOff)}),e.alpha!==void 0&&(t["a:alpha"]={"@_val":H1e(e.alpha)}),t}function blr(e){return{"a:schemeClr":LHe(e)}}function RHe(e,t){return e.alpha===void 0&&typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<1?blr({...e,alpha:Math.max(0,Math.min(1,t))}):blr(e)}function G1e(e,t){let n=e[t]?.["@_val"];if(n==null||n==="")return;let r=String(n).trim(),o=Number.parseFloat(r);if(Number.isFinite(o))return r.endsWith("%")?o/100:o/1e5}function j1e(e){if(!e)return;let t=e["@_val"];if(!lmi(t)||Object.keys(e).some(l=>!umi.has(l)))return;let n={scheme:t},r=G1e(e,"a:tint"),o=G1e(e,"a:shade"),i=G1e(e,"a:lumMod"),a=G1e(e,"a:lumOff"),s=G1e(e,"a:alpha");return r!==void 0&&(n.tint=r),o!==void 0&&(n.shade=o),i!==void 0&&(n.lumMod=i),a!==void 0&&(n.lumOff=a),s!==void 0&&(n.alpha=s),n}function qP(e){return j1e(e?.["a:schemeClr"])}function vlr(e,t){if(!t)return;let n=t[e.scheme]??t[cmi[e.scheme]??""];if(!n)return;let r=LHe(e);return delete r["a:alpha"],f3t($ne(f3t(n),r)).toLowerCase()}var smi,cmi,umi,m3t=X(()=>{smi=new Set(["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink","bg1","tx1","bg2","tx2","phClr"]);cmi={bg1:"lt1",tx1:"dk1",bg2:"lt2",tx2:"dk2"};umi=new Set(["@_val","a:tint","a:shade","a:lumMod","a:lumOff","a:alpha"])});var gV=Fo(cg=>{"use strict";function dmi(e,t,n){if(n===void 0&&(n=Array.prototype),e&&typeof n.find=="function")return n.find.call(e,t);for(var r=0;r<e.length;r++)if(hV(e,r)){var o=e[r];if(t.call(void 0,o,r,e))return o}}function Zne(e,t){return t===void 0&&(t=Object),t&&typeof t.getOwnPropertyDescriptors=="function"&&(e=t.create(null,t.getOwnPropertyDescriptors(e))),t&&typeof t.freeze=="function"?t.freeze(e):e}function hV(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function pmi(e,t){if(e===null||typeof e!="object")throw new TypeError("target is not an object");for(var n in t)hV(t,n)&&(e[n]=t[n]);return e}var Slr=Zne({allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,default:!0,defer:!0,disabled:!0,formnovalidate:!0,hidden:!0,ismap:!0,itemscope:!0,loop:!0,multiple:!0,muted:!0,nomodule:!0,novalidate:!0,open:!0,playsinline:!0,readonly:!0,required:!0,reversed:!0,selected:!0});function fmi(e){return hV(Slr,e.toLowerCase())}var wlr=Zne({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function mmi(e){return hV(wlr,e.toLowerCase())}var V1e=Zne({script:!1,style:!1,textarea:!0,title:!0});function hmi(e){var t=e.toLowerCase();return hV(V1e,t)&&!V1e[t]}function gmi(e){var t=e.toLowerCase();return hV(V1e,t)&&V1e[t]}function Flr(e){return e===X1e.HTML}function ymi(e){return Flr(e)||e===X1e.XML_XHTML_APPLICATION}var X1e=Zne({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),bmi=Object.keys(X1e).map(function(e){return X1e[e]});function xmi(e){return bmi.indexOf(e)>-1}var vmi=Zne({HTML:"http://www.w3.org/1999/xhtml",SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});cg.assign=pmi;cg.find=dmi;cg.freeze=Zne;cg.HTML_BOOLEAN_ATTRIBUTES=Slr;cg.HTML_RAW_TEXT_ELEMENTS=V1e;cg.HTML_VOID_ELEMENTS=wlr;cg.hasDefaultHTMLNamespace=ymi;cg.hasOwn=hV;cg.isHTMLBooleanAttribute=fmi;cg.isHTMLRawTextElement=hmi;cg.isHTMLEscapableRawTextElement=gmi;cg.isHTMLMimeType=Flr;cg.isHTMLVoidElement=mmi;cg.isValidMimeType=xmi;cg.MIME_TYPE=X1e;cg.NAMESPACE=vmi});var $1e=Fo(Y1e=>{"use strict";var Smi=gV();function Alr(e,t){e.prototype=Object.create(Error.prototype,{constructor:{value:e},name:{value:e.name,enumerable:!0,writable:t}})}var q1e=Smi.freeze({Error:"Error",IndexSizeError:"IndexSizeError",DomstringSizeError:"DomstringSizeError",HierarchyRequestError:"HierarchyRequestError",WrongDocumentError:"WrongDocumentError",InvalidCharacterError:"InvalidCharacterError",NoDataAllowedError:"NoDataAllowedError",NoModificationAllowedError:"NoModificationAllowedError",NotFoundError:"NotFoundError",NotSupportedError:"NotSupportedError",InUseAttributeError:"InUseAttributeError",InvalidStateError:"InvalidStateError",SyntaxError:"SyntaxError",InvalidModificationError:"InvalidModificationError",NamespaceError:"NamespaceError",InvalidAccessError:"InvalidAccessError",ValidationError:"ValidationError",TypeMismatchError:"TypeMismatchError",SecurityError:"SecurityError",NetworkError:"NetworkError",AbortError:"AbortError",URLMismatchError:"URLMismatchError",QuotaExceededError:"QuotaExceededError",TimeoutError:"TimeoutError",InvalidNodeTypeError:"InvalidNodeTypeError",DataCloneError:"DataCloneError",EncodingError:"EncodingError",NotReadableError:"NotReadableError",UnknownError:"UnknownError",ConstraintError:"ConstraintError",DataError:"DataError",TransactionInactiveError:"TransactionInactiveError",ReadOnlyError:"ReadOnlyError",VersionError:"VersionError",OperationError:"OperationError",NotAllowedError:"NotAllowedError",OptOutError:"OptOutError"}),Tlr=Object.keys(q1e);function Dlr(e){return typeof e=="number"&&e>=1&&e<=25}function wmi(e){return typeof e=="string"&&e.substring(e.length-q1e.Error.length)===q1e.Error}function K1e(e,t){Dlr(e)?(this.name=Tlr[e],this.message=t||""):(this.message=e,this.name=wmi(t)?t:q1e.Error),Error.captureStackTrace&&Error.captureStackTrace(this,K1e)}Alr(K1e,!0);Object.defineProperties(K1e.prototype,{code:{enumerable:!0,get:function(){var e=Tlr.indexOf(this.name);return Dlr(e)?e:0}}});var klr={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25},h3t=Object.entries(klr);for(W1e=0;W1e<h3t.length;W1e++)Clr=h3t[W1e][0],K1e[Clr]=h3t[W1e][1];var Clr,W1e;function g3t(e,t,n){this.message=e,this.locator=t,this.cause=n,Error.captureStackTrace&&Error.captureStackTrace(this,g3t)}Alr(g3t);Y1e.DOMException=K1e;Y1e.DOMExceptionName=q1e;Y1e.ExceptionCode=klr;Y1e.ParseError=g3t});var F3t=Fo(Ji=>{"use strict";function Llr(e){try{typeof e!="function"&&(e=RegExp);var t=new e("\u{1D306}","u").exec("\u{1D306}");return!!t&&t[0].length===2}catch{}return!1}var ere=Llr();function iO(e){if(e.source[0]!=="[")throw new Error(e+" can not be used with chars");return e.source.slice(1,e.source.lastIndexOf("]"))}function Jne(e,t){if(e.source[0]!=="[")throw new Error("/"+e.source+"/ can not be used with chars_without");if(!t||typeof t!="string")throw new Error(JSON.stringify(t)+" is not a valid search");if(e.source.indexOf(t)===-1)throw new Error('"'+t+'" is not is /'+e.source+"/");if(t==="-"&&e.source.indexOf(t)!==1)throw new Error('"'+t+'" is not at the first postion of /'+e.source+"/");return new RegExp(e.source.replace(t,""),ere?"u":"")}function Da(e){var t=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(n){var r=typeof n=="string";if(r&&t===void 0&&n==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return r?n:n.source}).join(""),ere?"u":"")}function Ei(e){if(arguments.length===0)throw new Error("no parameters provided");return Da.apply(Ei,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var Fmi="\uFFFD",aO=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;ere&&(aO=Da("[",iO(aO),"\\u{10000}-\\u{10FFFF}","]"));var Cmi=new RegExp("[^"+iO(aO)+"]",ere?"u":""),_He=/[\x20\x09\x0D\x0A]/,Ami=iO(_He),kc=Da(_He,"+"),qd=Da(_He,"*"),Z1e=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;ere&&(Z1e=Da("[",iO(Z1e),"\\u{10000}-\\u{10FFFF}","]"));var Tmi=iO(Z1e),x3t=Da("[",Tmi,iO(/[-.0-9\xB7]/),iO(/[\u0300-\u036F\u203F-\u2040]/),"]"),oS=Da(Z1e,x3t,"*"),Dmi=Da("^",oS,"$"),Elr=Da(x3t,"+"),kmi=Da("&",oS,";"),Emi=Ei(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),J1e=Ei(kmi,"|",Emi),Q1e=Da("%",oS,";"),v3t=Ei(Da('"',Ei(/[^%&"]/,"|",Q1e,"|",J1e),"*",'"'),"|",Da("'",Ei(/[^%&']/,"|",Q1e,"|",J1e),"*","'")),Imi=Ei('"',Ei(/[^<&"]/,"|",J1e),"*",'"',"|","'",Ei(/[^<&']/,"|",J1e),"*","'"),Pmi=Jne(Z1e,":"),Mmi=Jne(x3t,":"),y3t=Da(Pmi,Mmi,"*"),Bmi=Da("^",y3t,"$"),exe=Da(y3t,Ei(":",y3t),"?"),Lmi=Da("^",exe,"$"),Rmi=Da("(",exe,")"),Qne=Ei(/"[^"]*"|'[^']*'/),_mi=Da(/^<\?/,"(",oS,")",Ei(kc,"(?!",_He,")(",aO,"*?)"),"?",/\?>/),Ilr=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,txe=Ei('"',Ilr,'*"',"|","'",Jne(Ilr,"'"),"*'"),Rlr="<!--",_lr="-->",Omi=Da(Rlr,Ei(Jne(aO,"-"),"|",Da("-",Jne(aO,"-"))),"*",_lr),Plr="#PCDATA",Nmi=Ei(Da(/\(/,qd,Plr,Ei(qd,/\|/,qd,exe),"*",qd,/\)\*/),"|",Da(/\(/,qd,Plr,qd,/\)/)),zmi=/[?*+]?/,Umi=Da(/\([^>]+\)/,zmi),Hmi=Ei("EMPTY","|","ANY","|",Nmi,"|",Umi),Gmi="<!ELEMENT",jmi=Da(Gmi,kc,Ei(exe,"|",Q1e),kc,Ei(Hmi,"|",Q1e),qd,">"),Vmi=Da("NOTATION",kc,/\(/,qd,oS,Ei(qd,/\|/,qd,oS),"*",qd,/\)/),Xmi=Da(/\(/,qd,Elr,Ei(qd,/\|/,qd,Elr),"*",qd,/\)/),Wmi=Ei(Vmi,"|",Xmi),qmi=Ei(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",Wmi),Kmi=Ei(/#REQUIRED|#IMPLIED/,"|",Ei(Ei("#FIXED",kc),"?",Imi)),Ymi=Ei(kc,oS,kc,qmi,kc,Kmi),$mi="<!ATTLIST",Zmi=Da($mi,kc,oS,Ymi,"*",qd,">"),b3t="about:legacy-compat",Jmi=Ei('"'+b3t+'"',"|","'"+b3t+"'"),S3t="SYSTEM",OHe="PUBLIC",NHe=Ei(Ei(S3t,kc,Qne),"|",Ei(OHe,kc,txe,kc,Qne)),Qmi=Da("^",Ei(Ei(S3t,kc,"(?<SystemLiteralOnly>",Qne,")"),"|",Ei(OHe,kc,"(?<PubidLiteral>",txe,")",kc,"(?<SystemLiteral>",Qne,")"))),ehi=Da("^",txe,"$"),thi=Da("^",Qne,"$"),nhi=Ei(kc,"NDATA",kc,oS),rhi=Ei(v3t,"|",Ei(NHe,nhi,"?")),Olr="<!ENTITY",ohi=Da(Olr,kc,oS,kc,rhi,qd,">"),ihi=Ei(v3t,"|",NHe),ahi=Da(Olr,kc,"%",kc,oS,kc,ihi,qd,">"),shi=Ei(ohi,"|",ahi),lhi=Da(OHe,kc,txe),chi=Da("<!NOTATION",kc,oS,kc,Ei(NHe,"|",lhi),qd,">"),w3t=Da(qd,"=",qd),Mlr=/1[.]\d+/,uhi=Da(kc,"version",w3t,Ei("'",Mlr,"'","|",'"',Mlr,'"')),Blr=/[A-Za-z][-A-Za-z0-9._]*/,dhi=Ei(kc,"encoding",w3t,Ei('"',Blr,'"',"|","'",Blr,"'")),phi=Ei(kc,"standalone",w3t,Ei("'",Ei("yes","|","no"),"'","|",'"',Ei("yes","|","no"),'"')),fhi=Da(/^<\?xml/,uhi,dhi,"?",phi,"?",qd,/\?>/),mhi="<!DOCTYPE",hhi="<![CDATA[",ghi="]]>",yhi=/<!\[CDATA\[/,bhi=/\]\]>/,xhi=Da(aO,"*?",bhi),vhi=Da(yhi,xhi);Ji.chars=iO;Ji.chars_without=Jne;Ji.detectUnicodeSupport=Llr;Ji.reg=Da;Ji.regg=Ei;Ji.ABOUT_LEGACY_COMPAT=b3t;Ji.ABOUT_LEGACY_COMPAT_SystemLiteral=Jmi;Ji.AttlistDecl=Zmi;Ji.CDATA_START=hhi;Ji.CDATA_END=ghi;Ji.CDSect=vhi;Ji.Char=aO;Ji.Comment=Omi;Ji.COMMENT_START=Rlr;Ji.COMMENT_END=_lr;Ji.DOCTYPE_DECL_START=mhi;Ji.elementdecl=jmi;Ji.EntityDecl=shi;Ji.EntityValue=v3t;Ji.ExternalID=NHe;Ji.ExternalID_match=Qmi;Ji.Name=oS;Ji.Name_exact=Dmi;Ji.NCName_exact=Bmi;Ji.NotationDecl=chi;Ji.Reference=J1e;Ji.PEReference=Q1e;Ji.PI=_mi;Ji.PUBLIC=OHe;Ji.PubidLiteral=txe;Ji.PubidLiteral_match=ehi;Ji.QName=exe;Ji.QName_exact=Lmi;Ji.QName_group=Rmi;Ji.S=kc;Ji.SChar_s=Ami;Ji.S_OPT=qd;Ji.SYSTEM=S3t;Ji.SystemLiteral=Qne;Ji.SystemLiteral_match=thi;Ji.InvalidChar=Cmi;Ji.UNICODE_REPLACEMENT_CHARACTER=Fmi;Ji.UNICODE_SUPPORT=ere;Ji.XMLDecl=fhi});var B3t=Fo(Bp=>{"use strict";var SF=gV(),EE=SF.find,Shi=SF.hasDefaultHTMLNamespace,nre=SF.hasOwn,whi=SF.isHTMLMimeType,Fhi=SF.isHTMLRawTextElement,Chi=SF.isHTMLVoidElement,nxe=SF.MIME_TYPE,IE=SF.NAMESPACE,C1=Symbol(),Vlr=$1e(),eo=Vlr.DOMException,Oy=Vlr.DOMExceptionName,Mp=F3t();function uv(e){if(e!==C1)throw new TypeError("Illegal constructor")}function Ahi(e){return e!==""}function Thi(e){return e?e.split(/[\t\n\f\r ]+/).filter(Ahi):[]}function Dhi(e,t){return nre(e,t)||(e[t]=!0),e}function Nlr(e){if(!e)return[];var t=Thi(e);return Object.keys(t.reduce(Dhi,{}))}function khi(e){return function(t){return e&&e.indexOf(t)!==-1}}function Xlr(e){if(!Mp.QName_exact.test(e))throw new eo(eo.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+e+'"')}function A3t(e,t){Xlr(t),e=e||null;var n=null,r=t;if(t.indexOf(":")>=0){var o=t.split(":");n=o[0],r=o[1]}if(n!==null&&e===null)throw new eo(eo.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(n==="xml"&&e!==SF.NAMESPACE.XML)throw new eo(eo.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((n==="xmlns"||t==="xmlns")&&e!==SF.NAMESPACE.XMLNS)throw new eo(eo.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(e===SF.NAMESPACE.XMLNS&&n!=="xmlns"&&t!=="xmlns")throw new eo(eo.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[e,n,r]}function ire(e,t){for(var n in e)nre(e,n)&&(t[n]=e[n])}function dv(e,t){var n=e.prototype;if(!(n instanceof t)){let r=function(){};r.prototype=t.prototype,r=new r,ire(n,r),e.prototype=n=r}n.constructor!=e&&(typeof e!="function"&&console.error("unknown Class:"+e),n.constructor=e)}var pv={},vF=pv.ELEMENT_NODE=1,rre=pv.ATTRIBUTE_NODE=2,rxe=pv.TEXT_NODE=3,Wlr=pv.CDATA_SECTION_NODE=4,qlr=pv.ENTITY_REFERENCE_NODE=5,Ehi=pv.ENTITY_NODE=6,T3t=pv.PROCESSING_INSTRUCTION_NODE=7,D3t=pv.COMMENT_NODE=8,tre=pv.DOCUMENT_NODE=9,Klr=pv.DOCUMENT_TYPE_NODE=10,sO=pv.DOCUMENT_FRAGMENT_NODE=11,Ihi=pv.NOTATION_NODE=12,Pp=SF.freeze({DOCUMENT_POSITION_DISCONNECTED:1,DOCUMENT_POSITION_PRECEDING:2,DOCUMENT_POSITION_FOLLOWING:4,DOCUMENT_POSITION_CONTAINS:8,DOCUMENT_POSITION_CONTAINED_BY:16,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:32});function Ylr(e,t){if(t.length<e.length)return Ylr(t,e);var n=null;for(var r in e){if(e[r]!==t[r])return n;n=e[r]}return n}function zlr(e){return e.guid||(e.guid=Math.random()),e.guid}function eh(){}eh.prototype={length:0,item:function(e){return e>=0&&e<this.length?this[e]:null},toString:function(e){var t;typeof e=="function"?t={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:e}:e?t={requireWellFormed:!!e.requireWellFormed,splitCDATASections:e.splitCDATASections!==!1,nodeFilter:e.nodeFilter||null}:t={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var n=[],r=0;r<this.length;r++)M3t(this[r],n,null,t);return n.join("")},filter:function(e){return Array.prototype.filter.call(this,e)},indexOf:function(e){return Array.prototype.indexOf.call(this,e)}};eh.prototype[Symbol.iterator]=function(){var e=this,t=0;return{next:function(){return t<e.length?{value:e[t++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function kE(e,t){this._node=e,this._refresh=t,GHe(this)}function GHe(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!==t){var n=e._refresh(e._node);if(acr(e,"length",n.length),!e.$$length||n.length<e.$$length)for(var r=n.length;r in e;r++)nre(e,r)&&delete e[r];ire(n,e),e._inc=t}}kE.prototype.item=function(e){return GHe(this),this[e]||null};dv(kE,eh);function ore(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function $lr(e,t){for(var n=0;n<e.length;){if(e[n]===t)return n;n++}}function k3t(e,t,n){if(!t)return e._noNsIndex;var r=e._nsIndex[t];return!r&&n&&(r=e._nsIndex[t]=Object.create(null)),r}function Phi(e,t,n){var r=k3t(e,t,!1),o=r&&r[n];return o||null}function Mhi(e,t){k3t(e,t.namespaceURI,!0)[t.localName]=t}function Bhi(e,t){var n=k3t(e,t.namespaceURI,!1);n&&delete n[t.localName]}function Lhi(e,t,n,r){if(r?t[$lr(t,r)]=n:(t[t.length]=n,t.length++),Mhi(t,n),e){n.ownerElement=e;var o=e.ownerDocument;o&&(r&&Qlr(o,e,r),Rhi(o,e,n))}}function Ulr(e,t,n){var r=$lr(t,n);if(r>=0){for(var o=t.length-1;r<=o;)t[r]=t[++r];if(t.length=o,Bhi(t,n),e){var i=e.ownerDocument;i&&Qlr(i,e,n),n.ownerElement=null}}}ore.prototype={length:0,item:eh.prototype.item,getNamedItem:function(e){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(e=e.toLowerCase());for(var t=0;t<this.length;){var n=this[t];if(n.nodeName===e)return n;t++}return null},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!==this._ownerElement)throw new eo(eo.INUSE_ATTRIBUTE_ERR);var n=Phi(this,e.namespaceURI,e.localName);return n===e?e:(Lhi(this._ownerElement,this,e,n),n)},setNamedItemNS:function(e){return this.setNamedItem(e)},removeNamedItem:function(e){var t=this.getNamedItem(e);if(!t)throw new eo(eo.NOT_FOUND_ERR,e);return Ulr(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);if(!n)throw new eo(eo.NOT_FOUND_ERR,e?e+" : "+t:t);return Ulr(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){e||(e=null);for(var n=0;n<this.length;){var r=this[n];if(r.localName===t&&r.namespaceURI===e)return r;n++}return null}};ore.prototype[Symbol.iterator]=function(){var e=this,t=0;return{next:function(){return t<e.length?{value:e[t++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Zlr(){}Zlr.prototype={hasFeature:function(e,t){return!0},createDocument:function(e,t,n){var r=nxe.XML_APPLICATION;e===IE.HTML?r=nxe.XML_XHTML_APPLICATION:e===IE.SVG&&(r=nxe.XML_SVG_IMAGE);var o=new YP(C1,{contentType:r});if(o.implementation=this,o.childNodes=new eh,o.doctype=n||null,n&&o.appendChild(n),t){var i=o.createElementNS(e,t);o.appendChild(i)}return o},createDocumentType:function(e,t,n,r){Xlr(e);var o=new XHe(C1);return o.name=e,o.nodeName=e,o.publicId=t||"",o.systemId=n||"",o.internalSubset=r||"",o.childNodes=new eh,o},createHTMLDocument:function(e){var t=new YP(C1,{contentType:nxe.HTML});if(t.implementation=this,t.childNodes=new eh,e!==!1){t.doctype=this.createDocumentType("html"),t.doctype.ownerDocument=t,t.appendChild(t.doctype);var n=t.createElement("html");t.appendChild(n);var r=t.createElement("head");if(n.appendChild(r),typeof e=="string"){var o=t.createElement("title");o.appendChild(t.createTextNode(e)),r.appendChild(o)}n.appendChild(t.createElement("body"))}return t}};function nl(e){uv(e)}nl.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,parentNode:null,get parentElement(){return this.parentNode&&this.parentNode.nodeType===this.ELEMENT_NODE?this.parentNode:null},childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,baseURI:"about:blank",get isConnected(){var e=this.getRootNode();return e&&e.nodeType===e.DOCUMENT_NODE},contains:function(e){if(!e)return!1;var t=e;do{if(this===t)return!0;t=t.parentNode}while(t);return!1},getRootNode:function(e){var t=this;do{if(!t.parentNode)return t;t=t.parentNode}while(t)},isEqualNode:function(e){if(!e)return!1;for(var t=[{node:this,other:e}];t.length>0;){var n=t.pop(),r=n.node,o=n.other;if(r.nodeType!==o.nodeType)return!1;switch(r.nodeType){case r.DOCUMENT_TYPE_NODE:if(r.name!==o.name||r.publicId!==o.publicId||r.systemId!==o.systemId)return!1;break;case r.ELEMENT_NODE:if(r.namespaceURI!==o.namespaceURI||r.prefix!==o.prefix||r.localName!==o.localName||r.attributes.length!==o.attributes.length)return!1;for(var i=0;i<r.attributes.length;i++){var a=r.attributes.item(i),s=o.getAttributeNodeNS(a.namespaceURI,a.localName);if(!s)return!1;t.push({node:a,other:s})}break;case r.ATTRIBUTE_NODE:if(r.namespaceURI!==o.namespaceURI||r.localName!==o.localName||r.value!==o.value)return!1;break;case r.PROCESSING_INSTRUCTION_NODE:if(r.target!==o.target||r.data!==o.data)return!1;break;case r.TEXT_NODE:case r.CDATA_SECTION_NODE:case r.COMMENT_NODE:if(r.data!==o.data)return!1;break}if(r.childNodes.length!==o.childNodes.length)return!1;for(var i=r.childNodes.length-1;i>=0;i--)t.push({node:r.childNodes[i],other:o.childNodes[i]})}return!0},isSameNode:function(e){return this===e},insertBefore:function(e,t){return HHe(this,e,t)},replaceChild:function(e,t){HHe(this,e,t,ncr),t&&this.removeChild(t)},removeChild:function(e){return ecr(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(e){return icr(this.ownerDocument||this,this,e)},normalize:function(){ug(this,null,{enter:function(e){for(var t=e.firstChild;t;){var n=t.nextSibling;if(n!==null&&n.nodeType===rxe&&t.nodeType===rxe){for(var r=[],o=n;o!==null&&o.nodeType===rxe;)r.push(o.data),o=o.nextSibling;for(var i=t.nextSibling;i!==o;){var a=i.nextSibling;i.parentNode=null,i.previousSibling=null,i.nextSibling=null,i=a}t.nextSibling=o,o!==null?o.previousSibling=t:e.lastChild=t,t.appendData(r.join("")),E3t(e.ownerDocument,e),t=o}else t=n}return!0}})},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n){for(var r in n)if(nre(n,r)&&n[r]===e)return r}t=t.nodeType==rre?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&nre(n,e))return n[e];t=t.nodeType==rre?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){var t=this.lookupPrefix(e);return t==null},compareDocumentPosition:function(e){if(this===e)return 0;var t=e,n=this,r=null,o=null;if(t instanceof yV&&(r=t,t=r.ownerElement),n instanceof yV&&(o=n,n=o.ownerElement,r&&t&&n===t))for(var i=0,a;a=n.attributes[i];i++){if(a===r)return Pp.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+Pp.DOCUMENT_POSITION_PRECEDING;if(a===o)return Pp.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+Pp.DOCUMENT_POSITION_FOLLOWING}if(!t||!n||n.ownerDocument!==t.ownerDocument)return Pp.DOCUMENT_POSITION_DISCONNECTED+Pp.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(zlr(n.ownerDocument)>zlr(t.ownerDocument)?Pp.DOCUMENT_POSITION_FOLLOWING:Pp.DOCUMENT_POSITION_PRECEDING);if(o&&t===n)return Pp.DOCUMENT_POSITION_CONTAINS+Pp.DOCUMENT_POSITION_PRECEDING;if(r&&t===n)return Pp.DOCUMENT_POSITION_CONTAINED_BY+Pp.DOCUMENT_POSITION_FOLLOWING;for(var s=[],l=t.parentNode;l;){if(!o&&l===n)return Pp.DOCUMENT_POSITION_CONTAINED_BY+Pp.DOCUMENT_POSITION_FOLLOWING;s.push(l),l=l.parentNode}s.reverse();for(var c=[],u=n.parentNode;u;){if(!r&&u===t)return Pp.DOCUMENT_POSITION_CONTAINS+Pp.DOCUMENT_POSITION_PRECEDING;c.push(u),u=u.parentNode}c.reverse();var d=Ylr(s,c);for(var p in d.childNodes){var f=d.childNodes[p];if(f===n)return Pp.DOCUMENT_POSITION_FOLLOWING;if(f===t)return Pp.DOCUMENT_POSITION_PRECEDING;if(c.indexOf(f)>=0)return Pp.DOCUMENT_POSITION_FOLLOWING;if(s.indexOf(f)>=0)return Pp.DOCUMENT_POSITION_PRECEDING}return 0}};function Jlr(e){return e=="<"&&"&lt;"||e==">"&&"&gt;"||e=="&"&&"&amp;"||e=='"'&&"&quot;"||"&#"+e.charCodeAt()+";"}ire(pv,nl);ire(pv,nl.prototype);ire(Pp,nl);ire(Pp,nl.prototype);function UHe(e,t){ug(e,null,{enter:function(n){return t(n)?ug.STOP:!0}})}function ug(e,t,n){for(var r=[{node:e,context:t,phase:ug.ENTER}];r.length>0;){var o=r.pop();if(o.phase===ug.ENTER){var i=n.enter(o.node,o.context);if(i===ug.STOP)return ug.STOP;if(r.push({node:o.node,context:i,phase:ug.EXIT}),i==null)continue;for(var a=o.node.lastChild;a;)r.push({node:a,context:i,phase:ug.ENTER}),a=a.previousSibling}else n.exit&&n.exit(o.node,o.context)}}ug.STOP=Symbol("walkDOM.STOP");ug.ENTER=0;ug.EXIT=1;function YP(e,t){uv(e);var n=t||{};this.ownerDocument=this,this.contentType=n.contentType||nxe.XML_APPLICATION,this.type=whi(this.contentType)?"html":"xml"}function Rhi(e,t,n){e&&e._inc++;var r=n.namespaceURI;r===IE.XMLNS&&(t._nsMap[n.prefix?n.localName:""]=n.value)}function Qlr(e,t,n,r){e&&e._inc++;var o=n.namespaceURI;o===IE.XMLNS&&delete t._nsMap[n.prefix?n.localName:""]}function E3t(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n&&!n.nextSibling)r[r.length++]=n;else{for(var o=t.firstChild,i=0;o;)r[i++]=o,o=o.nextSibling;r.length=i,delete r[r.length]}}}function ecr(e,t){if(e!==t.parentNode)throw new eo(eo.NOT_FOUND_ERR,"child's parent is not parent");var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,E3t(e.ownerDocument,e),t.parentNode=null,t.previousSibling=null,t.nextSibling=null,t}function _hi(e){return e&&(e.nodeType===nl.DOCUMENT_NODE||e.nodeType===nl.DOCUMENT_FRAGMENT_NODE||e.nodeType===nl.ELEMENT_NODE)}function Ohi(e){return e&&(e.nodeType===nl.CDATA_SECTION_NODE||e.nodeType===nl.COMMENT_NODE||e.nodeType===nl.DOCUMENT_FRAGMENT_NODE||e.nodeType===nl.DOCUMENT_TYPE_NODE||e.nodeType===nl.ELEMENT_NODE||e.nodeType===nl.PROCESSING_INSTRUCTION_NODE||e.nodeType===nl.TEXT_NODE)}function lO(e){return e&&e.nodeType===nl.DOCUMENT_TYPE_NODE}function KP(e){return e&&e.nodeType===nl.ELEMENT_NODE}function tcr(e){return e&&e.nodeType===nl.TEXT_NODE}function Hlr(e,t){var n=e.childNodes||[];if(EE(n,KP)||lO(t))return!1;var r=EE(n,lO);return!(t&&r&&n.indexOf(r)>n.indexOf(t))}function Glr(e,t){var n=e.childNodes||[];function r(i){return KP(i)&&i!==t}if(EE(n,r))return!1;var o=EE(n,lO);return!(t&&o&&n.indexOf(o)>n.indexOf(t))}function Nhi(e,t,n){if(!_hi(e))throw new eo(eo.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+e.nodeType);if(n&&n.parentNode!==e)throw new eo(eo.NOT_FOUND_ERR,"child not in parent");if(!Ohi(t)||lO(t)&&e.nodeType!==nl.DOCUMENT_NODE)throw new eo(eo.HIERARCHY_REQUEST_ERR,"Unexpected node type "+t.nodeType+" for parent node type "+e.nodeType)}function zhi(e,t,n){var r=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===nl.DOCUMENT_FRAGMENT_NODE){var i=o.filter(KP);if(i.length>1||EE(o,tcr))throw new eo(eo.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!Hlr(e,n))throw new eo(eo.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(KP(t)&&!Hlr(e,n))throw new eo(eo.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(lO(t)){if(EE(r,lO))throw new eo(eo.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var a=EE(r,KP);if(n&&r.indexOf(a)<r.indexOf(n))throw new eo(eo.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!n&&a)throw new eo(eo.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function ncr(e,t,n){var r=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===nl.DOCUMENT_FRAGMENT_NODE){var i=o.filter(KP);if(i.length>1||EE(o,tcr))throw new eo(eo.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!Glr(e,n))throw new eo(eo.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(KP(t)&&!Glr(e,n))throw new eo(eo.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(lO(t)){if(EE(r,function(l){return lO(l)&&l!==n}))throw new eo(eo.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var a=EE(r,KP);if(n&&r.indexOf(a)<r.indexOf(n))throw new eo(eo.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function HHe(e,t,n,r){Nhi(e,t,n),e.nodeType===nl.DOCUMENT_NODE&&(r||zhi)(e,t,n);var o=t.parentNode;if(o&&o.removeChild(t),t.nodeType===sO){var i=t.firstChild;if(i==null)return t;var a=t.lastChild}else i=a=t;var s=n?n.previousSibling:e.lastChild;i.previousSibling=s,a.nextSibling=n,s?s.nextSibling=i:e.firstChild=i,n==null?e.lastChild=a:n.previousSibling=a;do i.parentNode=e;while(i!==a&&(i=i.nextSibling));return E3t(e.ownerDocument||e,e,t),t.nodeType==sO&&(t.firstChild=t.lastChild=null),t}YP.prototype={implementation:null,nodeName:"#document",nodeType:tre,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType===sO){for(var n=e.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return HHe(this,e,t),e.ownerDocument=this,this.documentElement===null&&e.nodeType===vF&&(this.documentElement=e),e},removeChild:function(e){var t=ecr(this,e);return t===this.documentElement&&(this.documentElement=null),t},replaceChild:function(e,t){HHe(this,e,t,ncr),e.ownerDocument=this,t&&this.removeChild(t),KP(e)&&(this.documentElement=e)},importNode:function(e,t){return Uhi(this,e,t)},getElementById:function(e){var t=null;return UHe(this.documentElement,function(n){if(n.nodeType==vF&&n.getAttribute("id")==e)return t=n,!0}),t},createElement:function(e){var t=new $P(C1);t.ownerDocument=this,this.type==="html"&&(e=e.toLowerCase()),Shi(this.contentType)&&(t.namespaceURI=IE.HTML),t.nodeName=e,t.tagName=e,t.localName=e,t.childNodes=new eh;var n=t.attributes=new ore;return n._ownerElement=t,t},createDocumentFragment:function(){var e=new are(C1);return e.ownerDocument=this,e.childNodes=new eh,e},createTextNode:function(e){var t=new oxe(C1);return t.ownerDocument=this,t.childNodes=new eh,t.appendData(e),t},createComment:function(e){var t=new jHe(C1);return t.ownerDocument=this,t.childNodes=new eh,t.appendData(e),t},createCDATASection:function(e){if(e.indexOf("]]>")!==-1)throw new eo(eo.INVALID_CHARACTER_ERR,'data contains "]]>"');var t=new VHe(C1);return t.ownerDocument=this,t.childNodes=new eh,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new qHe(C1);return n.ownerDocument=this,n.childNodes=new eh,n.nodeName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){if(!Mp.QName_exact.test(e))throw new eo(eo.INVALID_CHARACTER_ERR,'invalid character in name "'+e+'"');return this.type==="html"&&(e=e.toLowerCase()),this._createAttribute(e)},_createAttribute:function(e){var t=new yV(C1);return t.ownerDocument=this,t.childNodes=new eh,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){if(!Mp.Name_exact.test(e))throw new eo(eo.INVALID_CHARACTER_ERR,'not a valid xml name "'+e+'"');if(this.type==="html")throw new eo("document is an html document",Oy.NotSupportedError);var t=new WHe(C1);return t.ownerDocument=this,t.childNodes=new eh,t.nodeName=e,t},createElementNS:function(e,t){var n=A3t(e,t),r=new $P(C1),o=r.attributes=new ore;return r.childNodes=new eh,r.ownerDocument=this,r.nodeName=t,r.tagName=t,r.namespaceURI=n[0],r.prefix=n[1],r.localName=n[2],o._ownerElement=r,r},createAttributeNS:function(e,t){var n=A3t(e,t),r=new yV(C1);return r.ownerDocument=this,r.childNodes=new eh,r.nodeName=t,r.name=t,r.specified=!0,r.namespaceURI=n[0],r.prefix=n[1],r.localName=n[2],r}};dv(YP,nl);function $P(e){uv(e),this._nsMap=Object.create(null)}$P.prototype={nodeType:vF,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===IE.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(e){return!!this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t?t.value:null},getAttributeNode:function(e){return this._isInHTMLDocumentAndNamespace()&&(e=e.toLowerCase()),this.attributes.getNamedItem(e)},setAttribute:function(e,t){this._isInHTMLDocumentAndNamespace()&&(e=e.toLowerCase());var n=this.getAttributeNode(e);n?n.value=n.nodeValue=""+t:(n=this.ownerDocument._createAttribute(e),n.value=n.nodeValue=""+t,this.setAttributeNode(n))},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return this.getAttributeNodeNS(e,t)!=null},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n?n.value:null},setAttributeNS:function(e,t,n){var r=A3t(e,t),o=r[2],i=this.getAttributeNodeNS(e,o);i?i.value=i.nodeValue=""+n:(i=this.ownerDocument.createAttributeNS(e,t),i.value=i.nodeValue=""+n,this.setAttributeNode(i))},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByClassName:function(e){var t=Nlr(e);return new kE(this,function(n){var r=[];return t.length>0&&UHe(n,function(o){if(o!==n&&o.nodeType===vF){var i=o.getAttribute("class");if(i){var a=e===i;if(!a){var s=Nlr(i);a=t.every(khi(s))}a&&r.push(o)}}}),r})},getElementsByTagName:function(e){var t=(this.nodeType===tre?this:this.ownerDocument).type==="html",n=e.toLowerCase();return new kE(this,function(r){var o=[];return UHe(r,function(i){if(!(i===r||i.nodeType!==vF))if(e==="*")o.push(i);else{var a=i.getQualifiedName(),s=t&&i.namespaceURI===IE.HTML?n:e;a===s&&o.push(i)}}),o})},getElementsByTagNameNS:function(e,t){return new kE(this,function(n){var r=[];return UHe(n,function(o){o!==n&&o.nodeType===vF&&(e==="*"||o.namespaceURI===e)&&(t==="*"||o.localName==t)&&r.push(o)}),r})}};YP.prototype.getElementsByClassName=$P.prototype.getElementsByClassName;YP.prototype.getElementsByTagName=$P.prototype.getElementsByTagName;YP.prototype.getElementsByTagNameNS=$P.prototype.getElementsByTagNameNS;dv($P,nl);function yV(e){uv(e),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}yV.prototype.nodeType=rre;dv(yV,nl);function cO(e){uv(e)}cO.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){var r=this.data.substring(0,e),o=this.data.substring(e+t);n=r+n+o,this.nodeValue=this.data=n,this.length=n.length}};dv(cO,nl);function oxe(e){uv(e)}oxe.prototype={nodeName:"#text",nodeType:rxe,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}};dv(oxe,cO);function jHe(e){uv(e)}jHe.prototype={nodeName:"#comment",nodeType:D3t};dv(jHe,cO);function VHe(e){uv(e)}VHe.prototype={nodeName:"#cdata-section",nodeType:Wlr};dv(VHe,oxe);function XHe(e){uv(e)}XHe.prototype.nodeType=Klr;dv(XHe,nl);function I3t(e){uv(e)}I3t.prototype.nodeType=Ihi;dv(I3t,nl);function P3t(e){uv(e)}P3t.prototype.nodeType=Ehi;dv(P3t,nl);function WHe(e){uv(e)}WHe.prototype.nodeType=qlr;dv(WHe,nl);function are(e){uv(e)}are.prototype.nodeName="#document-fragment";are.prototype.nodeType=sO;dv(are,nl);function qHe(e){uv(e)}qHe.prototype.nodeType=T3t;dv(qHe,cO);function rcr(){}rcr.prototype.serializeToString=function(e,t){return ocr.call(e,t)};nl.prototype.toString=ocr;function ocr(e){var t;typeof e=="function"?t={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:e}:e!=null?t={requireWellFormed:!!e.requireWellFormed,splitCDATASections:e.splitCDATASections!==!1,nodeFilter:e.nodeFilter||null}:t={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var n=[],r=this.nodeType===tre&&this.documentElement||this,o=r.prefix,i=r.namespaceURI;if(i&&o==null){var o=r.lookupPrefix(i);if(o==null)var a=[{namespace:i,prefix:null}]}return M3t(this,n,a,t),n.join("")}function jlr(e,t,n){var r=e.prefix||"",o=e.namespaceURI;if(!o||r==="xml"&&o===IE.XML||o===IE.XMLNS)return!1;for(var i=n.length;i--;){var a=n[i];if(a.prefix===r)return a.namespace!==o}return!0}function zHe(e,t,n,r){if(r&&!Mp.QName_exact.test(t))throw new eo('The attribute name "'+t+'" is not a valid XML QName',Oy.InvalidStateError);e.push(" ",t,'="',n.replace(/[<>&"\t\n\r]/g,Jlr),'"')}function M3t(e,t,n,r){n||(n=[]);var o=r.nodeFilter,i=r.requireWellFormed,a=r.splitCDATASections,s=e.nodeType===tre?e:e.ownerDocument,l=s.type==="html";ug(e,{ns:n},{enter:function(c,u){var d=u.ns;if(o)if(c=o(c),c){if(typeof c=="string")return t.push(c),null}else return null;switch(c.nodeType){case vF:var p=c.attributes,f=p.length,m=c.tagName,h=m;if(!l&&!c.prefix&&c.namespaceURI){for(var g,y=0;y<p.length;y++)if(p.item(y).name==="xmlns"){g=p.item(y).value;break}if(!g)for(var b=d.length-1;b>=0;b--){var x=d[b];if(x.prefix===""&&x.namespace===c.namespaceURI){g=x.namespace;break}}if(g!==c.namespaceURI)for(var b=d.length-1;b>=0;b--){var x=d[b];if(x.namespace===c.namespaceURI){x.prefix&&(h=x.prefix+":"+m);break}}}if(i&&!Mp.QName_exact.test(h))throw new eo('The element name "'+h+'" is not a valid XML QName',Oy.InvalidStateError);t.push("<",h);for(var v=d.slice(),S=0;S<f;S++){var F=p.item(S);F.prefix=="xmlns"?v.push({prefix:F.localName,namespace:F.value}):F.nodeName=="xmlns"&&v.push({prefix:"",namespace:F.value})}for(var S=0;S<f;S++){var F=p.item(S);if(jlr(F,l,v)){var w=F.prefix||"",C=F.namespaceURI;zHe(t,w?"xmlns:"+w:"xmlns",C,i),v.push({prefix:w,namespace:C})}var A=o?o(F):F;A&&(typeof A=="string"?t.push(A):zHe(t,A.name,A.value,i))}if(m===h&&jlr(c,l,v)){var T=c.prefix||"",C=c.namespaceURI;zHe(t,T?"xmlns:"+T:"xmlns",C,i),v.push({prefix:T,namespace:C})}var D=!c.firstChild;if(D&&(l||c.namespaceURI===IE.HTML)&&(D=Chi(m)),D)return t.push("/>"),null;if(t.push(">"),l&&Fhi(m)){for(var k=c.firstChild;k;)k.data?t.push(k.data):M3t(k,t,v.slice(),r),k=k.nextSibling;return t.push("</",h,">"),null}return{ns:v,tag:h};case tre:case sO:if(i&&c.nodeType===tre&&c.documentElement==null)throw new eo("The Document has no documentElement",Oy.InvalidStateError);return{ns:d};case rre:return zHe(t,c.name,c.value,i),null;case rxe:if(i&&Mp.InvalidChar.test(c.data))throw new eo("The Text node data contains characters outside the XML Char production",Oy.InvalidStateError);return t.push(c.data.replace(/[<&>]/g,Jlr)),null;case Wlr:if(i&&c.data.indexOf("]]>")!==-1)throw new eo('The CDATASection data contains "]]>"',Oy.InvalidStateError);return a?t.push(Mp.CDATA_START,c.data.replace(/]]>/g,"]]]]><![CDATA[>"),Mp.CDATA_END):t.push(Mp.CDATA_START,c.data,Mp.CDATA_END),null;case D3t:if(i){if(Mp.InvalidChar.test(c.data))throw new eo("The comment node data contains characters outside the XML Char production",Oy.InvalidStateError);if(c.data.indexOf("--")!==-1||c.data[c.data.length-1]==="-")throw new eo('The comment node data contains "--" or ends with "-"',Oy.InvalidStateError)}return t.push(Mp.COMMENT_START,c.data,Mp.COMMENT_END),null;case Klr:var P=c.publicId,I=c.systemId;if(i){if(!Mp.Name_exact.test(c.name))throw new eo('The doctype name "'+c.name+'" is not a valid XML Name',Oy.InvalidStateError);if(P&&!Mp.PubidLiteral_match.test(P))throw new eo("DocumentType publicId is not a valid PubidLiteral",Oy.InvalidStateError);if(I&&I!=="."&&!Mp.SystemLiteral_match.test(I))throw new eo("DocumentType systemId is not a valid SystemLiteral",Oy.InvalidStateError);if(c.internalSubset&&c.internalSubset.indexOf("]>")!==-1)throw new eo('DocumentType internalSubset contains "]>"',Oy.InvalidStateError)}return t.push(Mp.DOCTYPE_DECL_START," ",c.name),P?(t.push(" ",Mp.PUBLIC," ",P),I&&I!=="."&&t.push(" ",I)):I&&I!=="."&&t.push(" ",Mp.SYSTEM," ",I),c.internalSubset&&t.push(" [",c.internalSubset,"]"),t.push(">"),null;case T3t:if(i){if(!Mp.NCName_exact.test(c.target)||c.target.toLowerCase()==="xml")throw new eo('The processing instruction target "'+c.target+'" is not a valid XML NCName or is reserved',Oy.InvalidStateError);if(Mp.InvalidChar.test(c.data))throw new eo("The ProcessingInstruction data contains characters outside the XML Char production",Oy.InvalidStateError);if(c.data.indexOf("?>")!==-1)throw new eo('The ProcessingInstruction data contains "?>"',Oy.InvalidStateError)}return t.push("<?",c.target," ",c.data,"?>"),null;case qlr:if(i&&!Mp.Name_exact.test(c.nodeName))throw new eo('The entity reference name "'+c.nodeName+'" is not a valid XML Name',Oy.InvalidStateError);return t.push("&",c.nodeName,";"),null;default:return t.push("??",c.nodeName),null}},exit:function(c,u){u&&u.tag&&t.push("</",u.tag,">")}})}function Uhi(e,t,n){var r;return ug(t,null,{enter:function(o,i){var a=o.cloneNode(!1);a.ownerDocument=e,a.parentNode=null,i===null?r=a:i.appendChild(a);var s=o.nodeType===rre||n;return s?a:null}}),r}function icr(e,t,n){var r;return ug(t,null,{enter:function(o,i){var a=new o.constructor(C1);for(var s in o)if(nre(o,s)){var l=o[s];typeof l!="object"&&l!=a[s]&&(a[s]=l)}o.childNodes&&(a.childNodes=new eh),a.ownerDocument=e;var c=n;switch(a.nodeType){case vF:var u=o.attributes,d=a.attributes=new ore,p=u.length;d._ownerElement=a;for(var f=0;f<p;f++)a.setAttributeNode(icr(e,u.item(f),!0));break;case rre:c=!0}return i!==null?i.appendChild(a):r=a,c?a:null}}),r}function acr(e,t,n){e[t]=n}function C3t(e){for(var t=[],n=e.firstChild;n;)n.nodeType===vF&&t.push(n),n=n.nextSibling;return t}try{Object.defineProperty&&(Object.defineProperty(kE.prototype,"length",{get:function(){return GHe(this),this.$$length}}),Object.defineProperty(nl.prototype,"textContent",{get:function(){if(this.nodeType===vF||this.nodeType===sO){var e=[];return ug(this,null,{enter:function(t){if(t.nodeType===vF||t.nodeType===sO)return!0;if(t.nodeType===T3t||t.nodeType===D3t)return null;e.push(t.nodeValue)}}),e.join("")}return this.nodeValue},set:function(e){switch(this.nodeType){case vF:case sO:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),Object.defineProperty(cO.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(e){this._data=e,this.length=typeof e=="string"?e.length:0}}),Object.defineProperty(cO.prototype,"nodeValue",{get:function(){return this.data},set:function(e){this.data=e},enumerable:!0,configurable:!0}),Object.defineProperty($P.prototype,"children",{get:function(){return new kE(this,C3t)}}),Object.defineProperty(YP.prototype,"children",{get:function(){return new kE(this,C3t)}}),Object.defineProperty(are.prototype,"children",{get:function(){return new kE(this,C3t)}}),acr=function(e,t,n){e["$$"+t]=n})}catch{}Bp._updateLiveList=GHe;Bp.Attr=yV;Bp.CDATASection=VHe;Bp.CharacterData=cO;Bp.Comment=jHe;Bp.Document=YP;Bp.DocumentFragment=are;Bp.DocumentType=XHe;Bp.DOMImplementation=Zlr;Bp.Element=$P;Bp.Entity=P3t;Bp.EntityReference=WHe;Bp.LiveNodeList=kE;Bp.NamedNodeMap=ore;Bp.Node=nl;Bp.NodeList=eh;Bp.Notation=I3t;Bp.Text=oxe;Bp.ProcessingInstruction=qHe;Bp.walkDOM=ug;Bp.XMLSerializer=rcr});var lcr=Fo(ixe=>{"use strict";var scr=gV().freeze;ixe.XML_ENTITIES=scr({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});ixe.HTML_ENTITIES=scr({Aacute:"\xC1",aacute:"\xE1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",Acirc:"\xC2",acirc:"\xE2",acute:"\xB4",Acy:"\u0410",acy:"\u0430",AElig:"\xC6",aelig:"\xE6",af:"\u2061",Afr:"\u{1D504}",afr:"\u{1D51E}",Agrave:"\xC0",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03B1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2A3F",AMP:"&",amp:"&",And:"\u2A53",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",Aogon:"\u0104",aogon:"\u0105",Aopf:"\u{1D538}",aopf:"\u{1D552}",ap:"\u2248",apacir:"\u2A6F",apE:"\u2A70",ape:"\u224A",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",Aring:"\xC5",aring:"\xE5",Ascr:"\u{1D49C}",ascr:"\u{1D4B6}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",Barwed:"\u2306",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",Because:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",Beta:"\u0392",beta:"\u03B2",beth:"\u2136",between:"\u226C",Bfr:"\u{1D505}",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bNot:"\u2AED",bnot:"\u2310",Bopf:"\u{1D539}",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxDL:"\u2557",boxDl:"\u2556",boxdL:"\u2555",boxdl:"\u2510",boxDR:"\u2554",boxDr:"\u2553",boxdR:"\u2552",boxdr:"\u250C",boxH:"\u2550",boxh:"\u2500",boxHD:"\u2566",boxHd:"\u2564",boxhD:"\u2565",boxhd:"\u252C",boxHU:"\u2569",boxHu:"\u2567",boxhU:"\u2568",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxUL:"\u255D",boxUl:"\u255C",boxuL:"\u255B",boxul:"\u2518",boxUR:"\u255A",boxUr:"\u2559",boxuR:"\u2558",boxur:"\u2514",boxV:"\u2551",boxv:"\u2502",boxVH:"\u256C",boxVh:"\u256B",boxvH:"\u256A",boxvh:"\u253C",boxVL:"\u2563",boxVl:"\u2562",boxvL:"\u2561",boxvl:"\u2524",boxVR:"\u2560",boxVr:"\u255F",boxvR:"\u255E",boxvr:"\u251C",bprime:"\u2035",Breve:"\u02D8",breve:"\u02D8",brvbar:"\xA6",Bscr:"\u212C",bscr:"\u{1D4B7}",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",Bumpeq:"\u224E",bumpeq:"\u224F",Cacute:"\u0106",cacute:"\u0107",Cap:"\u22D2",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",CapitalDifferentialD:"\u2145",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",Cayleys:"\u212D",ccaps:"\u2A4D",Ccaron:"\u010C",ccaron:"\u010D",Ccedil:"\xC7",ccedil:"\xE7",Ccirc:"\u0108",ccirc:"\u0109",Cconint:"\u2230",ccups:"\u2A4C",ccupssm:"\u2A50",Cdot:"\u010A",cdot:"\u010B",cedil:"\xB8",Cedilla:"\xB8",cemptyv:"\u29B2",cent:"\xA2",CenterDot:"\xB7",centerdot:"\xB7",Cfr:"\u212D",cfr:"\u{1D520}",CHcy:"\u0427",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",Chi:"\u03A7",chi:"\u03C7",cir:"\u25CB",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",CircleDot:"\u2299",circledR:"\xAE",circledS:"\u24C8",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",cirE:"\u29C3",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",clubs:"\u2663",clubsuit:"\u2663",Colon:"\u2237",colon:":",Colone:"\u2A74",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",Congruent:"\u2261",Conint:"\u222F",conint:"\u222E",ContourIntegral:"\u222E",Copf:"\u2102",copf:"\u{1D554}",coprod:"\u2210",Coproduct:"\u2210",COPY:"\xA9",copy:"\xA9",copysr:"\u2117",CounterClockwiseContourIntegral:"\u2233",crarr:"\u21B5",Cross:"\u2A2F",cross:"\u2717",Cscr:"\u{1D49E}",cscr:"\u{1D4B8}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",Cup:"\u22D3",cup:"\u222A",cupbrcap:"\u2A48",CupCap:"\u224D",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",Dagger:"\u2021",dagger:"\u2020",daleth:"\u2138",Darr:"\u21A1",dArr:"\u21D3",darr:"\u2193",dash:"\u2010",Dashv:"\u2AE4",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",Dcaron:"\u010E",dcaron:"\u010F",Dcy:"\u0414",dcy:"\u0434",DD:"\u2145",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",DDotrahd:"\u2911",ddotseq:"\u2A77",deg:"\xB0",Del:"\u2207",Delta:"\u0394",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",Dfr:"\u{1D507}",dfr:"\u{1D521}",dHar:"\u2965",dharl:"\u21C3",dharr:"\u21C2",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",diam:"\u22C4",Diamond:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",DifferentialD:"\u2146",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",DJcy:"\u0402",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",Dopf:"\u{1D53B}",dopf:"\u{1D555}",Dot:"\xA8",dot:"\u02D9",DotDot:"\u20DC",doteq:"\u2250",doteqdot:"\u2251",DotEqual:"\u2250",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",Downarrow:"\u21D3",downarrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",Dscr:"\u{1D49F}",dscr:"\u{1D4B9}",DScy:"\u0405",dscy:"\u0455",dsol:"\u29F6",Dstrok:"\u0110",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",DZcy:"\u040F",dzcy:"\u045F",dzigrarr:"\u27FF",Eacute:"\xC9",eacute:"\xE9",easter:"\u2A6E",Ecaron:"\u011A",ecaron:"\u011B",ecir:"\u2256",Ecirc:"\xCA",ecirc:"\xEA",ecolon:"\u2255",Ecy:"\u042D",ecy:"\u044D",eDDot:"\u2A77",Edot:"\u0116",eDot:"\u2251",edot:"\u0117",ee:"\u2147",efDot:"\u2252",Efr:"\u{1D508}",efr:"\u{1D522}",eg:"\u2A9A",Egrave:"\xC8",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",Element:"\u2208",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",Emacr:"\u0112",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",EmptySmallSquare:"\u25FB",emptyv:"\u2205",EmptyVerySmallSquare:"\u25AB",emsp:"\u2003",emsp13:"\u2004",emsp14:"\u2005",ENG:"\u014A",eng:"\u014B",ensp:"\u2002",Eogon:"\u0118",eogon:"\u0119",Eopf:"\u{1D53C}",eopf:"\u{1D556}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",Epsilon:"\u0395",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",Equal:"\u2A75",equals:"=",EqualTilde:"\u2242",equest:"\u225F",Equilibrium:"\u21CC",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erarr:"\u2971",erDot:"\u2253",Escr:"\u2130",escr:"\u212F",esdot:"\u2250",Esim:"\u2A73",esim:"\u2242",Eta:"\u0397",eta:"\u03B7",ETH:"\xD0",eth:"\xF0",Euml:"\xCB",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",Exists:"\u2203",expectation:"\u2130",ExponentialE:"\u2147",exponentiale:"\u2147",fallingdotseq:"\u2252",Fcy:"\u0424",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",Ffr:"\u{1D509}",ffr:"\u{1D523}",filig:"\uFB01",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",Fopf:"\u{1D53D}",fopf:"\u{1D557}",ForAll:"\u2200",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",Fouriertrf:"\u2131",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",Fscr:"\u2131",fscr:"\u{1D4BB}",gacute:"\u01F5",Gamma:"\u0393",gamma:"\u03B3",Gammad:"\u03DC",gammad:"\u03DD",gap:"\u2A86",Gbreve:"\u011E",gbreve:"\u011F",Gcedil:"\u0122",Gcirc:"\u011C",gcirc:"\u011D",Gcy:"\u0413",gcy:"\u0433",Gdot:"\u0120",gdot:"\u0121",gE:"\u2267",ge:"\u2265",gEl:"\u2A8C",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",Gfr:"\u{1D50A}",gfr:"\u{1D524}",Gg:"\u22D9",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",GJcy:"\u0403",gjcy:"\u0453",gl:"\u2277",gla:"\u2AA5",glE:"\u2A92",glj:"\u2AA4",gnap:"\u2A8A",gnapprox:"\u2A8A",gnE:"\u2269",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",Gopf:"\u{1D53E}",gopf:"\u{1D558}",grave:"`",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\u{1D4A2}",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",Gt:"\u226B",GT:">",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",Hacek:"\u02C7",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",HARDcy:"\u042A",hardcy:"\u044A",hArr:"\u21D4",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",Hat:"^",hbar:"\u210F",Hcirc:"\u0124",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",Hfr:"\u210C",hfr:"\u{1D525}",HilbertSpace:"\u210B",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",Hopf:"\u210D",hopf:"\u{1D559}",horbar:"\u2015",HorizontalLine:"\u2500",Hscr:"\u210B",hscr:"\u{1D4BD}",hslash:"\u210F",Hstrok:"\u0126",hstrok:"\u0127",HumpDownHump:"\u224E",HumpEqual:"\u224F",hybull:"\u2043",hyphen:"\u2010",Iacute:"\xCD",iacute:"\xED",ic:"\u2063",Icirc:"\xCE",icirc:"\xEE",Icy:"\u0418",icy:"\u0438",Idot:"\u0130",IEcy:"\u0415",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",Ifr:"\u2111",ifr:"\u{1D526}",Igrave:"\xCC",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",IJlig:"\u0132",ijlig:"\u0133",Im:"\u2111",Imacr:"\u012A",imacr:"\u012B",image:"\u2111",ImaginaryI:"\u2148",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",Implies:"\u21D2",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",Int:"\u222C",int:"\u222B",intcal:"\u22BA",integers:"\u2124",Integral:"\u222B",intercal:"\u22BA",Intersection:"\u22C2",intlarhk:"\u2A17",intprod:"\u2A3C",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",IOcy:"\u0401",iocy:"\u0451",Iogon:"\u012E",iogon:"\u012F",Iopf:"\u{1D540}",iopf:"\u{1D55A}",Iota:"\u0399",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",Iscr:"\u2110",iscr:"\u{1D4BE}",isin:"\u2208",isindot:"\u22F5",isinE:"\u22F9",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",Itilde:"\u0128",itilde:"\u0129",Iukcy:"\u0406",iukcy:"\u0456",Iuml:"\xCF",iuml:"\xEF",Jcirc:"\u0134",jcirc:"\u0135",Jcy:"\u0419",jcy:"\u0439",Jfr:"\u{1D50D}",jfr:"\u{1D527}",jmath:"\u0237",Jopf:"\u{1D541}",jopf:"\u{1D55B}",Jscr:"\u{1D4A5}",jscr:"\u{1D4BF}",Jsercy:"\u0408",jsercy:"\u0458",Jukcy:"\u0404",jukcy:"\u0454",Kappa:"\u039A",kappa:"\u03BA",kappav:"\u03F0",Kcedil:"\u0136",kcedil:"\u0137",Kcy:"\u041A",kcy:"\u043A",Kfr:"\u{1D50E}",kfr:"\u{1D528}",kgreen:"\u0138",KHcy:"\u0425",khcy:"\u0445",KJcy:"\u040C",kjcy:"\u045C",Kopf:"\u{1D542}",kopf:"\u{1D55C}",Kscr:"\u{1D4A6}",kscr:"\u{1D4C0}",lAarr:"\u21DA",Lacute:"\u0139",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",Lambda:"\u039B",lambda:"\u03BB",Lang:"\u27EA",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",Laplacetrf:"\u2112",laquo:"\xAB",Larr:"\u219E",lArr:"\u21D0",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",lAtail:"\u291B",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lBarr:"\u290E",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",Lcaron:"\u013D",lcaron:"\u013E",Lcedil:"\u013B",lcedil:"\u013C",lceil:"\u2308",lcub:"{",Lcy:"\u041B",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",lE:"\u2266",le:"\u2264",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",Leftarrow:"\u21D0",leftarrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",leftarrowtail:"\u21A2",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",LeftRightArrow:"\u2194",Leftrightarrow:"\u21D4",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",leftthreetimes:"\u22CB",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",lEg:"\u2A8B",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",lessgtr:"\u2276",LessLess:"\u2AA1",lesssim:"\u2272",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",lfisht:"\u297C",lfloor:"\u230A",Lfr:"\u{1D50F}",lfr:"\u{1D529}",lg:"\u2276",lgE:"\u2A91",lHar:"\u2962",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",LJcy:"\u0409",ljcy:"\u0459",Ll:"\u22D8",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",Lleftarrow:"\u21DA",llhard:"\u296B",lltri:"\u25FA",Lmidot:"\u013F",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnap:"\u2A89",lnapprox:"\u2A89",lnE:"\u2268",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",LongLeftArrow:"\u27F5",Longleftarrow:"\u27F8",longleftarrow:"\u27F5",LongLeftRightArrow:"\u27F7",Longleftrightarrow:"\u27FA",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",LongRightArrow:"\u27F6",Longrightarrow:"\u27F9",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",Lopf:"\u{1D543}",lopf:"\u{1D55D}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",Lscr:"\u2112",lscr:"\u{1D4C1}",Lsh:"\u21B0",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",Lstrok:"\u0141",lstrok:"\u0142",Lt:"\u226A",LT:"<",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",ltrPar:"\u2996",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",Map:"\u2905",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",Mcy:"\u041C",mcy:"\u043C",mdash:"\u2014",mDDot:"\u223A",measuredangle:"\u2221",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\u{1D510}",mfr:"\u{1D52A}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",MinusPlus:"\u2213",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",Mopf:"\u{1D544}",mopf:"\u{1D55E}",mp:"\u2213",Mscr:"\u2133",mscr:"\u{1D4C2}",mstpos:"\u223E",Mu:"\u039C",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nabla:"\u2207",Nacute:"\u0143",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",Ncaron:"\u0147",ncaron:"\u0148",Ncedil:"\u0145",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",Ncy:"\u041D",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",nearhk:"\u2924",neArr:"\u21D7",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
8841
8841
  `,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",PartialD:"\u2202",Pcy:"\u041F",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",Pfr:"\u{1D513}",pfr:"\u{1D52D}",Phi:"\u03A6",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",Pi:"\u03A0",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",PlusMinus:"\xB1",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",Poincareplane:"\u210C",pointint:"\u2A15",Popf:"\u2119",popf:"\u{1D561}",pound:"\xA3",Pr:"\u2ABB",pr:"\u227A",prap:"\u2AB7",prcue:"\u227C",prE:"\u2AB3",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",Prime:"\u2033",prime:"\u2032",primes:"\u2119",prnap:"\u2AB9",prnE:"\u2AB5",prnsim:"\u22E8",prod:"\u220F",Product:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",Proportion:"\u2237",Proportional:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",Pscr:"\u{1D4AB}",pscr:"\u{1D4C5}",Psi:"\u03A8",psi:"\u03C8",puncsp:"\u2008",Qfr:"\u{1D514}",qfr:"\u{1D52E}",qint:"\u2A0C",Qopf:"\u211A",qopf:"\u{1D562}",qprime:"\u2057",Qscr:"\u{1D4AC}",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",QUOT:'"',quot:'"',rAarr:"\u21DB",race:"\u223D\u0331",Racute:"\u0154",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",Rang:"\u27EB",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",Rarr:"\u21A0",rArr:"\u21D2",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",Rarrtl:"\u2916",rarrtl:"\u21A3",rarrw:"\u219D",rAtail:"\u291C",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",RBarr:"\u2910",rBarr:"\u290F",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",Rcaron:"\u0158",rcaron:"\u0159",Rcedil:"\u0156",rcedil:"\u0157",rceil:"\u2309",rcub:"}",Rcy:"\u0420",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",Re:"\u211C",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",REG:"\xAE",reg:"\xAE",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",rfisht:"\u297D",rfloor:"\u230B",Rfr:"\u211C",rfr:"\u{1D52F}",rHar:"\u2964",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",Rho:"\u03A1",rho:"\u03C1",rhov:"\u03F1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",Rightarrow:"\u21D2",rightarrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",rightarrowtail:"\u21A3",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",rightthreetimes:"\u22CC",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",Ropf:"\u211D",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",RoundImplies:"\u2970",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",Rrightarrow:"\u21DB",rsaquo:"\u203A",Rscr:"\u211B",rscr:"\u{1D4C7}",Rsh:"\u21B1",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",RuleDelayed:"\u29F4",ruluhar:"\u2968",rx:"\u211E",Sacute:"\u015A",sacute:"\u015B",sbquo:"\u201A",Sc:"\u2ABC",sc:"\u227B",scap:"\u2AB8",Scaron:"\u0160",scaron:"\u0161",sccue:"\u227D",scE:"\u2AB4",sce:"\u2AB0",Scedil:"\u015E",scedil:"\u015F",Scirc:"\u015C",scirc:"\u015D",scnap:"\u2ABA",scnE:"\u2AB6",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",Scy:"\u0421",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",searhk:"\u2925",seArr:"\u21D8",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",Sfr:"\u{1D516}",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",SHCHcy:"\u0429",shchcy:"\u0449",SHcy:"\u0428",shcy:"\u0448",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",shortmid:"\u2223",shortparallel:"\u2225",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",shy:"\xAD",Sigma:"\u03A3",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",SmallCircle:"\u2218",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",SOFTcy:"\u042C",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",Sopf:"\u{1D54A}",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",Sqrt:"\u221A",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",Square:"\u25A1",square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",Sscr:"\u{1D4AE}",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",Star:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",Sub:"\u22D0",sub:"\u2282",subdot:"\u2ABD",subE:"\u2AC5",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",Subset:"\u22D0",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",SubsetEqual:"\u2286",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",SuchThat:"\u220B",Sum:"\u2211",sum:"\u2211",sung:"\u266A",Sup:"\u22D1",sup:"\u2283",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supdot:"\u2ABE",supdsub:"\u2AD8",supE:"\u2AC6",supe:"\u2287",supedot:"\u2AC4",Superset:"\u2283",SupersetEqual:"\u2287",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",Supset:"\u22D1",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swarhk:"\u2926",swArr:"\u21D9",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",Tab:" ",target:"\u2316",Tau:"\u03A4",tau:"\u03C4",tbrk:"\u23B4",Tcaron:"\u0164",tcaron:"\u0165",Tcedil:"\u0162",tcedil:"\u0163",Tcy:"\u0422",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",Tfr:"\u{1D517}",tfr:"\u{1D531}",there4:"\u2234",Therefore:"\u2234",therefore:"\u2234",Theta:"\u0398",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",ThickSpace:"\u205F\u200A",thinsp:"\u2009",ThinSpace:"\u2009",thkap:"\u2248",thksim:"\u223C",THORN:"\xDE",thorn:"\xFE",Tilde:"\u223C",tilde:"\u02DC",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",Topf:"\u{1D54B}",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",TRADE:"\u2122",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",TripleDot:"\u20DB",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",Tscr:"\u{1D4AF}",tscr:"\u{1D4C9}",TScy:"\u0426",tscy:"\u0446",TSHcy:"\u040B",tshcy:"\u045B",Tstrok:"\u0166",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",Uacute:"\xDA",uacute:"\xFA",Uarr:"\u219F",uArr:"\u21D1",uarr:"\u2191",Uarrocir:"\u2949",Ubrcy:"\u040E",ubrcy:"\u045E",Ubreve:"\u016C",ubreve:"\u016D",Ucirc:"\xDB",ucirc:"\xFB",Ucy:"\u0423",ucy:"\u0443",udarr:"\u21C5",Udblac:"\u0170",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",Ufr:"\u{1D518}",ufr:"\u{1D532}",Ugrave:"\xD9",ugrave:"\xF9",uHar:"\u2963",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",Umacr:"\u016A",umacr:"\u016B",uml:"\xA8",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",uogon:"\u0173",Uopf:"\u{1D54C}",uopf:"\u{1D566}",UpArrow:"\u2191",Uparrow:"\u21D1",uparrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",Updownarrow:"\u21D5",updownarrow:"\u2195",UpEquilibrium:"\u296E",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",upsi:"\u03C5",upsih:"\u03D2",Upsilon:"\u03A5",upsilon:"\u03C5",UpTee:"\u22A5",UpTeeArrow:"\u21A5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",Uring:"\u016E",uring:"\u016F",urtri:"\u25F9",Uscr:"\u{1D4B0}",uscr:"\u{1D4CA}",utdot:"\u22F0",Utilde:"\u0168",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",Uuml:"\xDC",uuml:"\xFC",uwangle:"\u29A7",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",vArr:"\u21D5",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",Vbar:"\u2AEB",vBar:"\u2AE8",vBarv:"\u2AE9",Vcy:"\u0412",vcy:"\u0432",VDash:"\u22AB",Vdash:"\u22A9",vDash:"\u22A8",vdash:"\u22A2",Vdashl:"\u2AE6",Vee:"\u22C1",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",Verbar:"\u2016",verbar:"|",Vert:"\u2016",vert:"|",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",Vopf:"\u{1D54D}",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",Vscr:"\u{1D4B1}",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",Vvdash:"\u22AA",vzigzag:"\u299A",Wcirc:"\u0174",wcirc:"\u0175",wedbar:"\u2A5F",Wedge:"\u22C0",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",Wfr:"\u{1D51A}",wfr:"\u{1D534}",Wopf:"\u{1D54E}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",Wscr:"\u{1D4B2}",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",Xfr:"\u{1D51B}",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",Xi:"\u039E",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",Xopf:"\u{1D54F}",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",Xscr:"\u{1D4B3}",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",Yacute:"\xDD",yacute:"\xFD",YAcy:"\u042F",yacy:"\u044F",Ycirc:"\u0176",ycirc:"\u0177",Ycy:"\u042B",ycy:"\u044B",yen:"\xA5",Yfr:"\u{1D51C}",yfr:"\u{1D536}",YIcy:"\u0407",yicy:"\u0457",Yopf:"\u{1D550}",yopf:"\u{1D56A}",Yscr:"\u{1D4B4}",yscr:"\u{1D4CE}",YUcy:"\u042E",yucy:"\u044E",Yuml:"\u0178",yuml:"\xFF",Zacute:"\u0179",zacute:"\u017A",Zcaron:"\u017D",zcaron:"\u017E",Zcy:"\u0417",zcy:"\u0437",Zdot:"\u017B",zdot:"\u017C",zeetrf:"\u2128",ZeroWidthSpace:"\u200B",Zeta:"\u0396",zeta:"\u03B6",Zfr:"\u2128",zfr:"\u{1D537}",ZHcy:"\u0416",zhcy:"\u0436",zigrarr:"\u21DD",Zopf:"\u2124",zopf:"\u{1D56B}",Zscr:"\u{1D4B5}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"});ixe.entityMap=ixe.HTML_ENTITIES});var ycr=Fo(YHe=>{"use strict";var dre=gV(),ra=F3t(),pcr=$1e(),Hhi=dre.isHTMLEscapableRawTextElement,Ghi=dre.isHTMLMimeType,jhi=dre.isHTMLRawTextElement,lxe=dre.hasOwn,ccr=dre.NAMESPACE,Vhi=pcr.ParseError,Xhi=pcr.DOMException,sre=0,uO=1,lre=2,axe=3,cre=4,ure=5,sxe=6,KHe=7;function fcr(){}fcr.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),Yhi(t,t=Object.create(null)),Whi(e,t,n,r,this.errorHandler),r.endDocument()}};var L3t=/&#?\w+;?/g;function Whi(e,t,n,r,o){var i=Ghi(r.mimeType);e.indexOf(ra.UNICODE_REPLACEMENT_CHARACTER)>=0&&o.warning("Unicode replacement character detected, source encoding issues?");function a(N){if(N>65535){N-=65536;var z=55296+(N>>10),U=56320+(N&1023);return String.fromCharCode(z,U)}else return String.fromCharCode(N)}function s(N){var z=N[N.length-1]===";"?N:N+";";if(!i&&z!==N)return o.error("EntityRef: expecting ;"),N;var U=ra.Reference.exec(z);if(!U||U[0].length!==z.length)return o.error("entity not matching Reference production: "+N),N;var H=z.slice(1,-1);return lxe(n,H)?n[H]:H.charAt(0)==="#"?a(parseInt(H.substring(1).replace("x","0x"))):(o.error("entity not found:"+N),N)}function l(N){if(N>g){var z=e.substring(g,N).replace(L3t,s);p&&f(g),r.characters(z,0,N-g),g=N}}var c=0,u=0,d=/\r\n?|\n|$/g,p=r.locator;function f(N,z){for(;N>=u&&(z=d.exec(e));)c=u,u=z.index+z[0].length,p.lineNumber++;p.columnNumber=N-c+1}for(var m=[{currentNSMap:t}],h=[],g=0;;){try{var y=e.indexOf("<",g);if(y<0){if(!i&&h.length>0)return o.fatalError("unclosed xml tag(s): "+h.join(", "));if(!e.substring(g).match(/^\s*$/)){var b=r.doc,x=b.createTextNode(e.substring(g));if(b.documentElement)return o.error("Extra content at the end of the document");b.appendChild(x),r.currentElement=x}return}if(y>g){var v=e.substring(g,y);!i&&h.length===0&&(v=v.replace(new RegExp(ra.S_OPT.source,"g"),""),v&&o.error("Unexpected content outside root element: '"+v+"'")),l(y)}switch(e.charAt(y+1)){case"/":var M=e.indexOf(">",y+2),S=e.substring(y+2,M>0?M:void 0);if(!S)return o.fatalError("end tag name missing");var F=ra.reg("^",ra.QName_group,ra.S_OPT,"$"),w=M>0&&F.exec(S);if(!w){var C=M>0&&ra.reg("^",ra.QName_group).exec(S);if(i&&C)o.warning('end tag name contains invalid trailing characters: "'+S+'"'),w=C;else if(C&&new RegExp(F.source,F.flags+"m").test(S))o.error('end tag name is followed by a line break and trailing content: "'+S+'"'),w=C;else return o.fatalError('end tag name contains invalid characters: "'+S+'"')}if(!r.currentElement&&!r.doc.documentElement)return;var A=h[h.length-1]||r.currentElement.tagName||r.doc.documentElement.tagName||"";if(A!==w[1]){var T=w[1].toLowerCase();if(!i||A.toLowerCase()!==T)return o.fatalError('Opening and ending tag mismatch: "'+A+'" != "'+S+'"')}var D=m.pop();h.pop();var k=D.localNSMap;if(r.endElement(D.uri,D.localName,A),k)for(var P in k)lxe(k,P)&&r.endPrefixMapping(P);M++;break;case"?":p&&f(y),M=Zhi(e,y,r,o);break;case"!":p&&f(y),M=hcr(e,y,r,o,i);break;default:p&&f(y);var I=new gcr,B=m[m.length-1].currentNSMap,M=qhi(e,y,I,B,s,o,i),L=I.length;if(I.closed||(i&&dre.isHTMLVoidElement(I.tagName)?I.closed=!0:h.push(I.tagName)),p&&L){for(var _=ucr(p,{}),R=0;R<L;R++){var O=I[R];f(O.offset),O.locator=ucr(p,{})}r.locator=_,dcr(I,r,B)&&m.push(I),r.locator=p}else dcr(I,r,B)&&m.push(I);i&&!I.closed?M=Khi(e,M,I.tagName,s,r):M++}}catch(N){if(N instanceof Vhi)throw N;if(N instanceof Xhi)return o.fatalError("Error constructing the DOM: "+N.name+": "+N.message,N);o.error("element parse error: "+N),M=-1}M>g?g=M:l(Math.max(y,g)+1)}}function ucr(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function qhi(e,t,n,r,o,i,a){function s(f,m,h){if(lxe(n.attributeNames,f))return i.fatalError("Attribute "+f+" redefined");if(!a&&m.indexOf("<")>=0)return i.fatalError("Unescaped '<' not allowed in attributes values");n.addValue(f,m.replace(/[\t\n\r]/g," ").replace(L3t,o),h)}for(var l,c,u=++t,d=sre;;){var p=e.charAt(u);if(d===sre&&p==="<")throw new Error("unexpected < in tag name: "+e.slice(t,u));switch(p){case"=":if(d===uO)l=e.slice(t,u),d=axe;else if(d===lre)d=axe;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===axe||d===uO)if(d===uO&&(i.warning('attribute value must after "="'),l=e.slice(t,u)),t=u+1,u=e.indexOf(p,t),u>0)c=e.slice(t,u),s(l,c,t-1),d=ure;else throw new Error("attribute value no end '"+p+"' match");else if(d==cre)c=e.slice(t,u),s(l,c,t),i.warning('attribute "'+l+'" missed start quot('+p+")!!"),t=u+1,d=ure;else throw new Error('attribute value must after "="');break;case"/":switch(d){case sre:n.setTagName(e.slice(t,u));case ure:case sxe:case KHe:d=KHe,n.closed=!0;case cre:case uO:break;case lre:n.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),d==sre&&n.setTagName(e.slice(t,u)),u;case">":switch(d){case sre:n.setTagName(e.slice(t,u));case ure:case sxe:case KHe:break;case cre:case uO:c=e.slice(t,u),c.slice(-1)==="/"&&(n.closed=!0,c=c.slice(0,-1));case lre:d===lre&&(c=l),d==cre?(i.warning('attribute "'+c+'" missed quot(")!'),s(l,c,t)):(a||i.warning('attribute "'+c+'" missed value!! "'+c+'" instead!!'),s(c,c,t));break;case axe:if(!a)return i.fatalError(`AttValue: ' or " expected`)}return u;case"\x80":p=" ";default:if(p<=" ")switch(d){case sre:n.setTagName(e.slice(t,u)),d=sxe;break;case uO:l=e.slice(t,u),d=lre;break;case cre:var c=e.slice(t,u);i.warning('attribute "'+c+'" missed quot(")!!'),s(l,c,t);case ure:d=sxe;break}else switch(d){case lre:a||i.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),s(l,l,t),t=u,d=uO;break;case ure:i.warning('attribute space is required"'+l+'"!!');case sxe:d=uO,t=u;break;case axe:d=cre,t=u;break;case KHe:throw new Error("elements closed character '/' and '>' must be connected to")}}u++}}function dcr(e,t,n){for(var r=e.tagName,o=null,d=e.length;d--;){var i=e[d],a=i.qName,s=i.value,p=a.indexOf(":");if(p>0)var l=i.prefix=a.slice(0,p),c=a.slice(p+1),u=l==="xmlns"&&c;else c=a,l=null,u=a==="xmlns"&&"";i.localName=c,u!==!1&&(o==null&&(o=Object.create(null),n=Object.create(n)),n[u]=o[u]=s,i.uri=ccr.XMLNS,t.startPrefixMapping(u,s))}for(var d=e.length;d--;)i=e[d],i.prefix&&(i.prefix==="xml"&&(i.uri=ccr.XML),i.prefix!=="xmlns"&&(i.uri=n[i.prefix]));var p=r.indexOf(":");p>0?(l=e.prefix=r.slice(0,p),c=e.localName=r.slice(p+1)):(l=null,c=e.localName=r);var f=e.uri=n[l||""];if(t.startElement(f,c,r,e),e.closed){if(t.endElement(f,c,r),o)for(l in o)lxe(o,l)&&t.endPrefixMapping(l)}else return e.currentNSMap=n,e.localNSMap=o,!0}function Khi(e,t,n,r,o){var i=Hhi(n);if(i||jhi(n)){var a=new RegExp("</"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");a.lastIndex=t;var s=a.exec(e),l=s?s.index:-1;if(l<0)return t+1;var c=e.substring(t+1,l);return i&&(c=c.replace(L3t,r)),o.characters(c,0,c.length),l}return t+1}function Yhi(e,t){for(var n in e)lxe(e,n)&&(t[n]=e[n])}function mcr(e,t){var n=t;function r(u){return u=u||0,e.charAt(n+u)}function o(u){u=u||1,n+=u}function i(){for(var u=0;n<e.length;){var d=r();if(d!==" "&&d!==`
8842
8842
  `&&d!==" "&&d!=="\r")return u;u++,o()}return-1}function a(){return e.substring(n)}function s(u){return e.substring(n,n+u.length)===u}function l(u){return e.substring(n,n+u.length).toUpperCase()===u.toUpperCase()}function c(u){var d=ra.reg("^",u),p=d.exec(a());return p?(o(p[0].length),p[0]):null}return{char:r,getIndex:function(){return n},getMatch:c,getSource:function(){return e},skip:o,skipBlanks:i,substringFromIndex:a,substringStartsWith:s,substringStartsWithCaseInsensitive:l}}function $hi(e,t){function n(s,l){var c=ra.PI.exec(s.substringFromIndex());return c?c[1].toLowerCase()==="xml"?l.fatalError("xml declaration is only allowed at the start of the document, but found at position "+s.getIndex()):(s.skip(c[0].length),c[0]):l.fatalError("processing instruction is not well-formed at position "+s.getIndex())}var r=e.getSource();if(e.char()==="["){e.skip(1);for(var o=e.getIndex();e.getIndex()<r.length;){if(e.skipBlanks(),e.char()==="]"){var i=r.substring(o,e.getIndex());return e.skip(1),i}var a=null;if(e.char()==="<"&&e.char(1)==="!")switch(e.char(2)){case"E":e.char(3)==="L"?a=e.getMatch(ra.elementdecl):e.char(3)==="N"&&(a=e.getMatch(ra.EntityDecl));break;case"A":a=e.getMatch(ra.AttlistDecl);break;case"N":a=e.getMatch(ra.NotationDecl);break;case"-":a=e.getMatch(ra.Comment);break}else if(e.char()==="<"&&e.char(1)==="?")a=n(e,t);else if(e.char()==="%")a=e.getMatch(ra.PEReference);else return t.fatalError("Error detected in Markup declaration");if(!a)return t.fatalError("Error in internal subset at position "+e.getIndex())}return t.fatalError("doctype internal subset is not well-formed, missing ]")}}function hcr(e,t,n,r,o){var i=mcr(e,t);switch(o?i.char(2).toUpperCase():i.char(2)){case"-":var a=i.getMatch(ra.Comment);return a?(n.comment(a,ra.COMMENT_START.length,a.length-ra.COMMENT_START.length-ra.COMMENT_END.length),i.getIndex()):r.fatalError("comment is not well-formed at position "+i.getIndex());case"[":var s=i.getMatch(ra.CDSect);return s?!o&&!n.currentElement?r.fatalError("CDATA outside of element"):(n.startCDATA(),n.characters(s,ra.CDATA_START.length,s.length-ra.CDATA_START.length-ra.CDATA_END.length),n.endCDATA(),i.getIndex()):r.fatalError("Invalid CDATA starting at position "+t);case"D":{if(n.doc&&n.doc.documentElement)return r.fatalError("Doctype not allowed inside or after documentElement at position "+i.getIndex());if(o?!i.substringStartsWithCaseInsensitive(ra.DOCTYPE_DECL_START):!i.substringStartsWith(ra.DOCTYPE_DECL_START))return r.fatalError("Expected "+ra.DOCTYPE_DECL_START+" at position "+i.getIndex());if(i.skip(ra.DOCTYPE_DECL_START.length),i.skipBlanks()<1)return r.fatalError("Expected whitespace after "+ra.DOCTYPE_DECL_START+" at position "+i.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=i.getMatch(ra.Name),!l.name)return r.fatalError("doctype name missing or contains unexpected characters at position "+i.getIndex());if(o&&l.name.toLowerCase()!=="html"&&r.warning("Unexpected DOCTYPE in HTML document at position "+i.getIndex()),i.skipBlanks(),i.substringStartsWith(ra.PUBLIC)||i.substringStartsWith(ra.SYSTEM)){var c=ra.ExternalID_match.exec(i.substringFromIndex());if(!c)return r.fatalError("doctype external id is not well-formed at position "+i.getIndex());c.groups.SystemLiteralOnly!==void 0?l.systemId=c.groups.SystemLiteralOnly:(l.systemId=c.groups.SystemLiteral,l.publicId=c.groups.PubidLiteral),i.skip(c[0].length)}else if(o&&i.substringStartsWithCaseInsensitive(ra.SYSTEM)){if(i.skip(ra.SYSTEM.length),i.skipBlanks()<1)return r.fatalError("Expected whitespace after "+ra.SYSTEM+" at position "+i.getIndex());if(l.systemId=i.getMatch(ra.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return r.fatalError("Expected "+ra.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+ra.SYSTEM+" at position "+i.getIndex())}return o&&l.systemId&&!ra.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&r.warning("Unexpected doctype.systemId in HTML document at position "+i.getIndex()),o||(i.skipBlanks(),l.internalSubset=$hi(i,r)),i.skipBlanks(),i.char()!==">"?r.fatalError("doctype not terminated with > at position "+i.getIndex()):(i.skip(1),n.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),n.endDTD(),i.getIndex())}default:return r.fatalError('Not well-formed XML starting with "<!" at position '+t)}}function Zhi(e,t,n,r){var o=e.substring(t).match(ra.PI);if(!o)return r.fatalError("Invalid processing instruction starting at position "+t);if(o[1].toLowerCase()==="xml"){if(t>0)return r.fatalError("processing instruction at position "+t+" is an xml declaration which is only at the start of the document");if(!ra.XMLDecl.test(e.substring(t)))return r.fatalError("xml declaration is not well-formed")}return n.processingInstruction(o[1],o[2]),t+o[0].length}function gcr(){this.attributeNames=Object.create(null)}gcr.prototype={setTagName:function(e){if(!ra.QName_exact.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,n){if(!ra.QName_exact.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:n}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}};YHe.XMLReader=fcr;YHe.parseUtils=mcr;YHe.parseDoctypeCommentOrCData=hcr});var Ccr=Fo(fre=>{"use strict";var bV=gV(),Jhi=B3t(),Qhi=$1e(),bcr=lcr(),e0i=ycr(),t0i=Jhi.DOMImplementation,n0i=bV.hasDefaultHTMLNamespace,r0i=bV.isHTMLMimeType,o0i=bV.isValidMimeType,Scr=bV.MIME_TYPE,R3t=bV.NAMESPACE,xcr=Qhi.ParseError,i0i=e0i.XMLReader;function wcr(e){return e.replace(/\r[\n\u0085]/g,`