- md5
- 3ed34078a32043222d977e67693d5b0c
- sha1
- 5a93560c14a0d122bed16fcc8253e5d8bf5c50b1
- sha256
- 6eff8e87a377383c207af8a68af05ca46fe65962c647b571e62090ca9e80dbc5
function _extends(){return _extends=Object.assign?Object.assign.bind():function($){for(var R=1;R<arguments.length;R++){var M=arguments[R];for(var b in M)({}).hasOwnProperty.call(M,b)&&($[b]=M[b])}return $},_extends.apply(null,arguments)}/**
* @copyright (C) 2026 Open Source Matters
* @license GNU GPL v2 or later; see LICENSE.txt
*/Joomla=window.Joomla||{},(()=>{const e={workflow:null,stages:[],transitions:[],scale:1,panX:0,panY:0,isDraggingStage:!1,highlightedEdge:null},S=t=>Joomla.Text._(t),H=(t,...a)=>{const l=Joomla.Text._(t,t);let d=0;return l.replace(/%((%)|s|d)/g,n=>{let r=a[d];return n==="%d"&&(r=parseFloat(r),Number.isNaN(r)&&(r=0)),d+=1,r})},D=t=>`url(${window.location.href.split("#")[0]}#${t})`;function v(t,a){const l={};l[a]=[Joomla.Text._(t)],Joomla.renderMessages(l);{const d=document.querySelector("joomla-dialog");d&&d.close()}}async function T(t){try{const a=Joomla.getOptions("system.paths"),d=`${`${a?`${a.baseFull}index.php`:window.location.pathname}`}?option=com_workflow&extension=com_content&layout=modal&view=graph${t}`,n=await fetch(d,{credentials:"same-origin"});if(!n.ok){let u="COM_WORKFLOW_GRAPH_ERROR_UNKNOWN";throw n.status===401?u="COM_WORKFLOW_GRAPH_ERROR_NOT_AUTHENTICATED":n.status>=403?u="COM_WORKFLOW_GRAPH_ERROR_NO_PERMISSION":n.status!=200&&(u=H("COM_WORKFLOW_GRAPH_ERROR_REQUEST_FAILED",n.status)),new Error(u)}const r=await n.json();if(r.success===!1)throw new Error(r.message||"COM_WORKFLOW_GRAPH_ERROR_API_RETURNED_ERROR");return r}catch(a){return v(a.message,"error"),!1}}function G(t){const a=t.filter(i=>!i.position||isNaN(i.position.x)||isNaN(i.position.y));if(a.length===0)return t;const l=t.find(i=>i.id==="From Any"),d=t.filter(i=>i.id!=="From Any"),n=400,r=300,u=100,f=100,o=Math.min(4,Math.ceil(Math.sqrt(d.length)+1));return d.forEach((i,g)=>{if(a.some(s=>s.id===i.id)){const s=g%o,c=Math.floor(g/o);i.position={x:s*n+u,y:c*r+f}}}),l&&a.some(i=>i.id===l.id)&&(!l.position||isNaN(l.position.x)||isNaN(l.position.y))&&(l.position={x:600,y:-200}),t}function W(t){let a=`M ${t[0].x} ${t[0].y-50}`;for(let l=1;l<t.length-1;l++){const d=t[l-1],n=t[l],r=t[l+1],u=d.x-n.x,f=d.y-n.y,o=Math.sqrt(u*u+f*f),i=r.x-n.x,g=r.y-n.y,s=Math.sqrt(i*i+g*g);if(o<1||s<1){a+=` L ${n.x} ${n.y}`;continue}const c=Math.min(10,o/2,s/2),p=n.x+u/o*c,h=n.y+f/o*c,y=n.x+i/s*c,m=n.y+g/s*c;a+=` L ${p} ${h}`,a+=` Q ${n.x} ${n.y} ${y} ${m}`}return a+=` L ${t[t.length-1].x} ${t[t.length-1].y}`,a}function F(t,a,l,d,n){return[W([{x:t,y:a},{x:t,y:n},{x:l,y:n},{x:l,y:d}]),(t+l)/2,n]}function P(t,a,l,d,n){const r=a+30,u=d-30;return[W([{x:t,y:a},{x:t,y:r},{x:n,y:r},{x:n,y:u},{x:l,y:u},{x:l,y:d}]),n,(r+u)/2]}function q(t,a){const l=new Map(a.map(n=>[n.id,n])),d={};return t.forEach(n=>{const r=n.from_stage_id===-1?"From Any":n.from_stage_id,u=n.to_stage_id,f=String(r),o=String(u),i=f<o?`${f}|${o}`:`${o}|${f}`;d[i]||(d[i]=[]),d[i].push(n)}),Object.values(d).forEach(n=>n.sort((r,u)=>r.id-u.id)),t.flatMap(n=>{const r=n.from_stage_id===-1?"From Any":n.from_stage_id,u=n.to_stage_id,f=l.get(r),o=l.get(u);if(!(f!=null&&f.position)||!(o!=null&&o.position))return[];const i=f.position.x+200/2,g=f.position.y+100,s=o.position.x+200/2,c=o.position.y,p=String(r),h=String(u),y=p<h?`${p}|${h}`:`${h}|${p}`,m=d[y]||[n];let x=m.findIndex(w=>w.id===n.id)-(m.length-1)/2;const _=40;let A,L,I,k=!1;const N=Math.abs(i-s);if(N<200&&c>g&&(k=a.some(w=>{if(w.id===r||w.id===u)return!1;const K=w.position.y,j=w.position.y+100,B=K>g&&j<c,U=w.position.x,z=w.position.x+200,C=i,Z=C>U-20&&C<z+20;return B&&Z})),c>g+50&&!k&&N>40){let w=(g+c)/2;w+=x*_,[A,L,I]=F(i,g,s,c,w),L+=x*60}else{let w=(i+s)/2;(N<200||k)&&(w=Math.max(i,s)+200/2+60),w+=x*_,[A,L,I]=P(i,g,s,c,w),I+=x*35}return{id:`transition-${n.id}`,pathData:A,label:n.title,labelPosition:{x:L,y:I},fromId:r,toId:u}}).filter(Boolean)}function E(t){const a=t.querySelector("#graph"),l=t.querySelector("#stages"),d=t.querySelector("#connections");if(!a||!l||!d)return;l.querySelectorAll('[id^="stage-"]').forEach(o=>o.remove()),e.stages.forEach(o=>{let i=document.createElement("div");i.id=`stage-${o.id}`,i.addEventListener("mousedown",c=>{c.button===0&&Y(c,o)});const g=o.id==="From Any";i.className=`stage ${o.default?"default":""} ${g?"virtual":""}`,i.style.left=`${o.position.x}px`,i.style.top=`${o.position.y}px`;let s=g?`<div class="stage-title text-truncate">${o.title}</div>
<div class="d-flex justify-content-between align-items-center mt-2"><div class="badge bg-info rounded-pill p-1"></div></div>`:`<div class="stage-title text-truncate" title="${o.title}">${o.title}</div>
<div class="d-flex align-items-center gap-2">
${o.description?`<div class="stage-description text-truncate small">${o.description}</div>`:""}
</div>
<div class="d-flex justify-content-between align-items-center mt-2">
${typeof o.published<"u"?`<div class="badge ${o.published=="1"?"bg-success":"bg-danger"} rounded-pill p-1">${o.published=="1"?S("COM_WORKFLOW_GRAPH_ENABLED"):S("COM_WORKFLOW_GRAPH_DISABLED")}</div>`:""}
${o.default?`<div class="badge bg-warning rounded-pill p-1">${S("COM_WORKFLOW_GRAPH_DEFAULT")}</div>`:""}
</div>`;i.innerHTML=s,l.appendChild(i)});let n=d.querySelector("g.layers-paths"),r=d.querySelector("g.layers-labels");n||(n=document.createElementNS("http://www.w3.org/2000/svg","g"),n.classList.add("layers-paths"),d.appendChild(n)),r||(r=document.createElementNS("http://www.w3.org/2000/svg","g"),r.classList.add("layers-labels")),d.appendChild(r);const u=q(e.transitions,e.stages);n.querySelectorAll("path[data-edge-id]").forEach(o=>{u.find(i=>i.id===o.dataset.edgeId)||o.remove()}),r.querySelectorAll("foreignObject[data-edge-id]").forEach(o=>{u.find(i=>i.id===o.dataset.edgeId)||o.remove()}),u.forEach(o=>{let i=n.querySelector(`path[data-edge-id="${o.id}"]`);i||(i=document.createElementNS("http://www.w3.org/2000/svg","path"),i.dataset.edgeId=o.id,i.setAttribute("class","transition-path"),n.appendChild(i)),i.setAttribute("d",o.pathData),i.classList.toggle("highlighted",e.highlightedEdge===o.id),i.setAttribute("marker-end",D("arrowhead"));let g=r.querySelector(`foreignObject[data-edge-id="${o.id}"]`),s;g?s=g.querySelector("div"):(g=document.createElementNS("http://www.w3.org/2000/svg","foreignObject"),g.dataset.edgeId=o.id,g.style.overflow="visible",s=document.createElement("div"),s.className="transition-label-content",s.addEventListener("click",c=>{c.stopPropagation(),e.highlightedEdge=e.highlightedEdge===o.id?null:o.id,E(t)}),g.appendChild(s),r.appendChild(g)),s.textContent=o.label,s.classList.toggle("highlighted",e.highlightedEdge===o.id),a.style.transform=`translate(${e.panX}px, ${e.panY}px) scale(${e.scale})`,requestAnimationFrame(()=>{s.style.width="max-content";const c=s.getBoundingClientRect();if(c.width===0&&c.height===0)return;const p=c.width/e.scale,h=c.height/e.scale||24;g.setAttribute("width",p+4),g.setAttribute("height",h+4),g.setAttribute("x",o.labelPosition.x-p/2),g.setAttribute("y",o.labelPosition.y-h/2)})});const f=t.querySelector("#workflow-graph");if(f){const o=Math.max(.3,Math.min(1,e.scale)),i=20*e.scale;f.style.backgroundImage=`
radial-gradient(circle,
color-mix(in srgb, var(--body-color) 80%, transparent) 0px,
color-mix(in srgb, var(--body-color) 60%, transparent) ${o}px,
transparent ${o*2}px
)
`,f.style.backgroundSize=`${i}px ${i}px`,f.style.backgroundPosition=`${e.panX}px ${e.panY}px`}}function Y(t,a){if(a.id==="From Any")return;const l=document.getElementById(`stage-${a.id}`);e.isDraggingStage=!0;const d={x:t.clientX,y:t.clientY,stageX:a.position.x,stageY:a.position.y};l.classList.add("dragging");const n=u=>{const f=d.stageX+(u.clientX-d.x)/e.scale,o=d.stageY+(u.clientY-d.y)/e.scale,i=e.stages.find(g=>g.id===a.id);i&&(i.position.x=f,i.position.y=o),E(document.querySelector("#workflow-graph"))},r=()=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),l.classList.remove("dragging"),e.isDraggingStage=!1};document.addEventListener("mousemove",n),document.addEventListener("mouseup",r)}async function X(t){const a=t.querySelector("#workflow-graph"),l=t.querySelector("#graph");if(!a||a.dataset.initialized)return;a.dataset.initialized="true";const d=a.querySelector("#workflow-container"),n=parseInt(d.dataset.workflowId,10);if(!n)return v("COM_WORKFLOW_GRAPH_ERROR_INVALID_ID","error");t.querySelector("#connections").innerHTML=`<defs>
<marker id="arrowhead" viewBox="0 0 10 10" refX="10" refY="5"
markerWidth="6" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2071c6" />
</marker>
</defs>`;try{const s=await T(`&task=graph.getWorkflow&workflow_id=${n}&format=json`);if(!s)return;const c=await T(`&task=graph.getStages&workflow_id=${n}&format=json`);if(!c)return;const p=await T(`&task=graph.getTransitions&workflow_id=${n}&format=json`);if(!p)return;e.workflow=s?.data||{};let h=c?.data||[];if(e.transitions=p?.data||[],!h.length)return v("COM_WORKFLOW_GRAPH_ERROR_STAGES_NOT_FOUND","error");e.transitions.some(_=>_.from_stage_id===-1)&&!h.some(_=>_.id==="From Any")&&h.unshift({id:"From Any",title:"From Any",position:null}),e.stages=h.map(_=>_extends({},_,{position:_.position||{x:NaN,y:NaN}})),e.stages=G(e.stages),t.querySelector(".joomla-dialog-header h3").textContent=e.workflow.title||S("COM_WORKFLOW_GRAPH_WORKFLOW");const y=t.querySelector("#workflow-status-badge");y&&(y.textContent=e.workflow.published=="1"?S("COM_WORKFLOW_GRAPH_ENABLED"):S("COM_WORKFLOW_GRAPH_DISABLED"),y.classList.add(e.workflow.published=="1"?"bg-success":"bg-warning"));const m=e.stages.filter(_=>_.id!=="From Any").length,O=t.querySelector("#workflow-stage-count");O&&(O.textContent=`${m} ${S(m===1?"COM_WORKFLOW_GRAPH_STAGE":"COM_WORKFLOW_GRAPH_STAGES")}`);const x=t.querySelector("#workflow-transition-count");x&&(x.textContent=`${e.transitions.length} ${e.transitions.length===1?S("COM_WORKFLOW_GRAPH_TRANSITION"):S("COM_WORKFLOW_GRAPH_TRANSITIONS")}`),E(t),setTimeout(()=>g(t),150)}catch(s){v(s.message,"error");return}let r=!1,u={};a.addEventListener("mousedown",s=>{s.target.closest(".stage")||s.target.closest(".zoom-controls")||s.button!==0||(r=!0,u={x:s.clientX-e.panX,y:s.clientY-e.panY},l&&l.classList.add("dragging"))}),document.addEventListener("mousemove",s=>{r&&(e.panX=s.clientX-u.x,e.panY=s.clientY-u.y,E(t))});const f=()=>{r=!1,l&&l.classList.remove("dragging")};document.addEventListener("mouseup",f),a.addEventListener("mouseleave",f),a.addEventListener("wheel",s=>{s.preventDefault();const c=a.getBoundingClientRect(),p=s.clientX-c.left,h=s.clientY-c.top,y=e.scale,m=s.deltaY<0?1:-1;e.scale=Math.max(.5,Math.min(e.scale*(1+m*.1),2));const O=e.scale/y;e.panX=p-(p-e.panX)*O,e.panY=h-(h-e.panY)*O,E(t)});const o=a.querySelector(".zoom-controls");o.querySelector(".zoom-in").addEventListener("click",()=>i(1.2,t)),o.querySelector(".zoom-out").addEventListener("click",()=>i(1/1.2,t)),o.querySelector(".fit-screen").addEventListener("click",()=>g(t));function i(s,c){const p=c.querySelector("#workflow-graph").getBoundingClientRect(),h=p.width/2,y=p.height/2,m=e.scale;e.scale=Math.max(.5,Math.min(e.scale*s,2));const O=e.scale/m;e.panX=h-(h-e.panX)*O,e.panY=y-(y-e.panY)*O,E(c)}function g(s){if(!e.stages.length)return;let c=1/0,p=1/0,h=-1/0,y=-1/0;if(e.stages.forEach(A=>{A.position&&(c=Math.min(c,A.position.x),p=Math.min(p,A.position.y),h=Math.max(h,A.position.x+200),y=Math.max(y,A.position.y+100))}),c===1/0)return;const m=s.querySelector("#workflow-graph").getBoundingClientRect(),O=50,x=h-c,_=y-p;e.scale=Math.max(.5,Math.min((m.width-O)/x,(m.height-O)/_,2)),e.panX=(m.width-x*e.scale)/2-c*e.scale,e.panY=(m.height-_*e.scale)/2-p*e.scale,E(s)}document.addEventListener("keydown",s=>{if(["INPUT","TEXTAREA"].includes(document.activeElement.tagName))return;const c=30,p=1.1;switch(s.code){case"Equal":i(p,t);break;case"Minus":i(1/p,t);break;case"ArrowLeft":case"KeyA":e.panX+=c,E(t);break;case"ArrowRight":case"KeyD":e.panX-=c,E(t);break;case"ArrowUp":case"KeyW":e.panY+=c,E(t);break;case"ArrowDown":case"KeyS":e.panY-=c,E(t);break;case"Digit0":case"KeyF":g(t);break}})}document.addEventListener("joomla-dialog:open",t=>{const a=t.target;a.querySelector("#workflow-container")&&X(a)})})();
No other release has this exact content. See every version of this file.