import{f as r,eH as O,d as C,L as D,z as _,r as y,b as V,ev as z,w as l,e as B,u as i,ar as c,bF as P,ez as k,eG as A,cx as E,aD as I,cv as L}from"./outputWidgets.be3472c2.js";import{U as H}from"./UnsavedChangesHandler.080c92ef.js";import{a as j}from"./Text.c9febe27.js";import{A as N}from"./Link.bbb85664.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]="21ff319e-4381-470d-8ce2-7b246e543234",e._sentryDebugIdIdentifier="sentry-dbid-21ff319e-4381-470d-8ce2-7b246e543234")}catch{}})();var M={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 U=M;function S(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(o){return Object.getOwnPropertyDescriptor(t,o).enumerable}))),s.forEach(function(o){$(e,o,t[o])})}return e}function $(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=S({},a,t.attrs);return r(O,S({},s,{icon:U}),null)};f.displayName="SaveOutlined";f.inheritAttrs=!1;const x=f,F={style:{padding:"0px 4px"}},J=C({__name:"SaveButton",props:{model:{},neverShowPopover:{type:Boolean}},emits:["save"],setup(e,{emit:a}){var g;const t=e,s=new D(_.boolean(),"dontShowUnsavedChanges"),o=y((g=s.get())!=null?g:!1),w=()=>{s.set(!0),o.value=!0},d=y(!1);async function v(){d.value=!0;try{await t.model.save(),a("save")}catch{L.error({message:"Error saving"})}finally{d.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(I,null,[r(i(E),{placement:"left",open:n.model.hasChanges()&&!o.value&&!n.neverShowPopover},{content:l(()=>[B("div",F,[r(i(j),null,{default:l(()=>[c("You have unsaved changes")]),_:1}),r(i(N),{onClick:w},{default:l(()=>[c("Don't show this again")]),_:1})])]),default:l(()=>{var m,b;return[r(i(P),{class:k(["save-button",{changes:(m=n.model)==null?void 0:m.hasChanges()}]),loading:d.value,disabled:!((b=n.model)!=null&&b.hasChanges()),onClick:h[0]||(h[0]=u=>v())},{icon:l(()=>[r(i(x))]),default:l(()=>{var u;return[c(A((u=n.model)!=null&&u.hasChanges()?"Save":"Saved")+" ",1)]}),_:1},8,["class","loading","disabled"])]}),_:1},8,["open"]),r(H,{"has-changes":(p=n.model)==null?void 0:p.hasChanges()},null,8,["has-changes"])],64)}}});export{J as _};
//# sourceMappingURL=SaveButton.vue_vue_type_script_setup_true_lang.37d6810a.js.map
