import{fH as a,ck as h,aM as C,aD as S,iv as x,bL as k,aZ as b,bU as w,iG as T,hi as I,is as O,gH as u,hA as P,jc as W,hF as G}from"./strapi-ye6TfKul.js";import{u as H}from"./useDragLayer-DA6r3b6h.js";const L={STAGE:"stage"},_=({name:n})=>a.jsxs(h,{background:"primary100",borderStyle:"dashed",borderColor:"primary600",borderWidth:"1px",gap:3,hasRadius:!0,padding:3,shadow:"tableShadow",width:"30rem",children:[a.jsx(h,{alignItems:"center",background:"neutral200",borderRadius:"50%",height:6,justifyContent:"center",width:6,children:a.jsx(C,{width:"0.8rem",fill:"neutral600"})}),a.jsx(S,{fontWeight:"bold",children:n})]});function v(n,e,t){if(!n||!e||!t)return{display:"none"};const{x:r,y:i}=t;return{transform:`translate(${r}px, ${i}px)`}}const N=()=>{const{itemType:n,isDragging:e,item:t,initialOffset:r,currentOffset:i,mouseOffset:g}=H(o=>({item:o.getItem(),itemType:o.getItemType(),initialOffset:o.getInitialSourceClientOffset(),currentOffset:o.getSourceClientOffset(),isDragging:o.isDragging(),mouseOffset:o.getClientOffset()}));return!e||n!==L.STAGE?null:a.jsx(w,{height:"100%",left:0,position:"fixed",pointerEvents:"none",top:0,zIndex:100,width:"100%",children:a.jsxs(w,{style:v(r,i,g),children:[a.jsx(_,{name:typeof t.item=="string"?t.item:null}),";"]})})},$=({children:n})=>a.jsx(k.Main,{children:a.jsx(b.Content,{children:n})}),q=({title:n,subtitle:e,navigationAction:t,primaryAction:r})=>{const{formatMessage:i}=x();return a.jsxs(a.Fragment,{children:[a.jsx(k.Title,{children:i({id:"Settings.PageTitle",defaultMessage:"Settings - {name}"},{name:n})}),a.jsx(b.BaseHeader,{navigationAction:t,primaryAction:r,title:n,subtitle:e})]})},f={id:"notification.error",defaultMessage:"An error occurred, please try again"},z=(n={})=>{const{toggleNotification:e}=T(),{formatMessage:t}=x(),{_unstableFormatAPIError:r}=I(),{skip:i=!1,...g}=n,{data:o,isLoading:j,error:l}=O({...g},{skip:i});u.useEffect(()=>{l&&e({type:"danger",message:r(l)})},[l,r,e]);const[p]=P(),E=u.useCallback(async d=>{try{const s=await p({data:d});return"error"in s?(e({type:"danger",message:r(s.error)}),s):(e({type:"success",message:t({id:"actions.created",defaultMessage:"Created workflow"})}),s)}catch(s){throw e({type:"danger",message:t(f)}),s}},[p,r,t,e]),[m]=W(),D=u.useCallback(async(d,s)=>{try{const c=await m({id:d,data:s});return"error"in c?(e({type:"danger",message:r(c.error)}),c):(e({type:"success",message:t({id:"actions.updated",defaultMessage:"Updated workflow"})}),c)}catch(c){throw e({type:"danger",message:t(f)}),c}},[r,t,e,m]),[y]=G(),M=u.useCallback(async d=>{try{const s=await y({id:d});if("error"in s){e({type:"danger",message:r(s.error)});return}return e({type:"success",message:t({id:"actions.deleted",defaultMessage:"Deleted workflow"})}),s.data}catch(s){throw e({type:"danger",message:t(f)}),s}},[y,r,t,e]),{workflows:R=[],meta:A}=o??{};return{meta:A,workflows:R,isLoading:j,error:l,create:E,delete:M,update:D}};export{L as D,q as H,$ as R,N as a,z as u};
