1import{_ as e,b as t,g as n,l as r,r as i}from"./mobx.esm-d47kztp6.js";import{n as a,t as o}from"./decorate-nyiu1wsn.js";import{r as s}from"./registry-jjmq0p36.js";import{K as c,U as l,W as u}from"./health-summary.api-ibf8tb4n.js";var d=3,f=new Set(c);function p(e){return f.has(e)}function m(e,t){let n=new Set(t);return[...e.filter(e=>n.has(e)),...e.filter(e=>!n.has(e))]}function h(e,t){let n=new Set(t);return e.filter(e=>n.has(e))}function g(e,t,n,r){if(t.includes(n)||t.length<r)return null;let i=h(e,t).filter(e=>e!==n);return i[i.length-1]??null}function _(e){return{order:[...e,...c.filter(t=>!e.includes(t))],favs:[...e]}}function v(e){if(e.length>d)return null;let t=[],n=new Set;for(let r of e)if(r!==null){if(typeof r!=`string`||n.has(r)||!s(r))return null;n.add(r),p(r)&&t.push(r)}return t.length===0&&e.some(e=>e!==null)?null:t}function y(e,t){if(typeof e==`object`&&e&&!Array.isArray(e)){let{order:n,favs:r,slots:i}=e;if(Array.isArray(r)){if(r.some(e=>typeof e!=`string`)||new Set(r).size!==r.length)return null;let e=r.filter(p);if(e.length===0&&r.length>0||t!==null&&e.length>t)return null;if(!Array.isArray(n))return _(e);let i=[...new Set(n.filter(e=>typeof e==`string`&&p(e)))];return i.length===0?_(e):{order:[...i,...c.filter(e=>!i.includes(e))],favs:e}}return Array.isArray(i)?y(i,t):null}if(!Array.isArray(e))return null;let n=v(e);return n===null||t!==null&&n.length>t?null:_(n)}function b(e){if(!Array.isArray(e)||e.length===0||e.some(e=>typeof e!=`string`))return null;let t=v(e);return t===null||t.length===0?null:t}function x(e,t){w(e,`health_favorites_changed`,t)}function S(e,t){w(e,`health_metrics_reordered`,t)}function C(e,t){w(e,`health_favorites_bulk_set`,t)}function w(e,t,n){try{Promise.resolve(e.sendTrackedAction(t,JSON.stringify(n))).catch(()=>void 0)}catch(e){console.error(`[health-data] analytics send failed`,t,e)}}var T=class{constructor(e,r,i){this.settings=e,this.analytics=r,this.config=i,this._initStarted=!1,this._loadFailed=!1,this.init=()=>{this._initStarted||(this._initStarted=!0,this.settings.loadMany([this.config.settingKey,this.config.legacyKey]).then(()=>{t(()=>{this._loadFailed=!1})}).catch(e=>{console.error(`[health-data] favorites load failed`,this.config.settingKey,e),this._initStarted=!1,t(()=>{this._loadFailed=!0})}))},this.placeMetric=(e,t,n=null)=>{if(!p(e)||this._loadFailed)return null;let r=this.state,i=t===null?r.order:this.validatedOrder(r,t);if(i===null)return null;let a=r.favs.includes(e),o=r.favs,s=null;n!==null&&n===`favorites`!==a&&(n===`favorites`?(s=this.config.cap===null?null:g(i,r.favs,e,this.config.cap),o=[...r.favs.filter(e=>e!==s),e]):o=r.favs.filter(t=>t!==e));let c=n===null?m(i,o):[...i],l=c.every((e,t)=>e===r.order[t]),u=o.length===r.favs.length&&o.every(e=>r.favs.includes(e));return l&&u?null:(this.persist({order:c,favs:[...o]}),u||x(this.analytics,{surface:this.config.defaultAnalyticsSurface,favorites:h(c,o),metric:e,...s===null?{}:{bumped:s}}),l||S(this.analytics,{surface:this.config.defaultAnalyticsSurface,order:c}),s)},this.setAllFavorites=e=>{if(e&&this.config.cap!==null||this._loadFailed)return;let t=this.state,n=e?[...t.order]:[];n.length!==t.favs.length&&(this.persist({order:[...t.order],favs:n}),C(this.analytics,{surface:this.config.defaultAnalyticsSurface,on:e,favorites:h(t.order,n)}))},n(this)}get state(){let e=this.settings.settings.get(this.config.settingKey);if(e!=null)return y(e,this.config.cap)??_(this.config.defaultFavorites);let t=this.settings.settings.get(this.config.legacyKey);return _(t==null?this.config.defaultFavorites:b(t)??this.config.defaultFavorites)}get cap(){return this.config.cap}get order(){return this.state.order}get favs(){return this.state.favs}get slots(){return h(this.state.order,this.state.favs)}get partition(){return m(this.state.order,this.state.favs)}validatedOrder(e,t){return t.length!==e.order.length||new Set(t).size!==t.length||t.some(t=>!e.order.includes(t))?null:t}persist(e){this.settings.setLocal(this.config.settingKey,e),this.settings.set(this.config.settingKey,{order:[...e.order],favs:[...e.favs]}).catch(e=>{console.error(`[health-data] favorites persist failed`,this.config.settingKey,e)})}};o([e,a(`design:type`,Object)],T.prototype,`_loadFailed`,void 0),o([r,a(`design:type`,Object),a(`design:paramtypes`,[])],T.prototype,`state`,null),o([r,a(`design:type`,Array),a(`design:paramtypes`,[])],T.prototype,`order`,null),o([r,a(`design:type`,Array),a(`design:paramtypes`,[])],T.prototype,`favs`,null),o([r,a(`design:type`,Array),a(`design:paramtypes`,[])],T.prototype,`slots`,null),o([r,a(`design:type`,Array),a(`design:paramtypes`,[])],T.prototype,`partition`,null),o([i,a(`design:type`,Object)],T.prototype,`placeMetric`,void 0),o([i,a(`design:type`,Object)],T.prototype,`setAllFavorites`,void 0);var E=class extends T{constructor(e,t){super(e,t,{settingKey:`calendarHealthFavorites`,legacyKey:`calendarHealthSlots`,defaultFavorites:l,cap:3,defaultAnalyticsSurface:`calendar`})}},D=class extends T{constructor(e,t){super(e,t,{settingKey:`careerHealthFavorites`,legacyKey:`careerHealthSlots`,defaultFavorites:u,cap:null,defaultAnalyticsSurface:`career`})}};export{E as n,D as t}; 2//# sourceMappingURL=career-health-slots-view-model-i06uk8df.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.