import{U as C}from"./UnsavedChangesHandler.76a1ee3f.js";import{f as o,eG as O,d as D,r as b,S,b as _,eu as V,w as l,e as P,u as d,aq as u,bE as A,ey as B,eD as E,cy as k,aC as z,cw as I}from"./outputWidgets.260a3c99.js";import{a as j}from"./Text.3b774738.js";import{A as H}from"./Link.e028ce0e.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="dc118d7d-43d9-425e-8ba7-dc38016aa1c5",e._sentryDebugIdIdentifier="sentry-dbid-dc118d7d-43d9-425e-8ba7-dc38016aa1c5")}catch{}})();var L={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M893.3 293.3L730.7 130.7c-7.5-7.5-16.7-13-26.7-16V112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V338.5c0-17-6.7-33.2-18.7-45.2zM384 184h256v104H384V184zm456 656H184V184h136v136c0 17.7 14.3 32 32 32h320c17.7 0 32-14.3 32-32V205.8l136 136V840zM512 442c-79.5 0-144 64.5-144 144s64.5 144 144 144 144-64.5 144-144-64.5-144-144-144zm0 224c-44.2 0-80-35.8-80-80s35.8-80 80-80 80 35.8 80 80-35.8 80-80 80z"}}]},name:"save",theme:"outlined"};const N=L;function w(e){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?Object(arguments[a]):{},s=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(s=s.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),s.forEach(function(r){U(e,r,t[r])})}return e}function U(e,a,t){return a in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}var f=function(a,t){var s=w({},a,t.attrs);return o(O,w({},s,{icon:N}),null)};f.displayName="SaveOutlined";f.inheritAttrs=!1;const M=f,$={style:{padding:"0px 4px"}},G=D({__name:"SaveButton",props:{model:{},neverShowPopover:{type:Boolean}},emits:["save"],setup(e,{emit:a}){var g;const t=e,s=b((g=S.get("dontShowUnsavedChanges"))!=null?g:!1),r=()=>{S.set("dontShowUnsavedChanges",!0),s.value=!0},i=b(!1);async function v(){i.value=!0;try{await t.model.save(),a("save")}catch{I.error({message:"Error saving"})}finally{i.value=!1}}return addEventListener("keydown",n=>{(n.metaKey||n.ctrlKey)&&n.key==="s"&&(n.preventDefault(),v())}),addEventListener("beforeunload",n=>{t.model.hasChanges()&&(n.preventDefault(),n.returnValue="")}),(n,h)=>{var p;return _(),V(z,null,[o(d(k),{placement:"left",open:n.model.hasChanges()&&!s.value&&!n.neverShowPopover},{content:l(()=>[P("div",$,[o(d(j),null,{default:l(()=>[u("You have unsaved changes")]),_:1}),o(d(H),{onClick:r},{default:l(()=>[u("Don't show this again")]),_:1})])]),default:l(()=>{var m,y;return[o(d(A),{class:B(["save-button",{changes:(m=n.model)==null?void 0:m.hasChanges()}]),loading:i.value,disabled:!((y=n.model)!=null&&y.hasChanges()),onClick:h[0]||(h[0]=c=>v())},{icon:l(()=>[o(d(M))]),default:l(()=>{var c;return[u(E((c=n.model)!=null&&c.hasChanges()?"Save":"Saved")+" ",1)]}),_:1},8,["class","loading","disabled"])]}),_:1},8,["open"]),o(C,{"has-changes":(p=n.model)==null?void 0:p.hasChanges()},null,8,["has-changes"])],64)}}});export{G as _};
//# sourceMappingURL=SaveButton.vue_vue_type_script_setup_true_lang.3b17b3c2.js.map
