@ohif/extension-measurement-tracking 3.10.0 → 3.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see ohif-extension-measurement-tracking.umd.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@ohif/ui-next"),require("@ohif/extension-cornerstone-dicom-sr"),require("@ohif/core"),require("@ohif/extension-default/src/Panels/StudyBrowser/PanelStudyBrowser"),require("@ohif/extension-default"),require("@ohif/extension-cornerstone"),require("@ohif/i18n"),require("@cornerstonejs/tools"),require("@cornerstonejs/core")):"function"==typeof define&&define.amd?define(["@ohif/ui-next","@ohif/extension-cornerstone-dicom-sr","@ohif/core","@ohif/extension-default/src/Panels/StudyBrowser/PanelStudyBrowser","@ohif/extension-default","@ohif/extension-cornerstone","@ohif/i18n","@cornerstonejs/tools","@cornerstonejs/core"],t):"object"==typeof exports?exports["ohif-extension-measurement-tracking"]=t(require("@ohif/ui-next"),require("@ohif/extension-cornerstone-dicom-sr"),require("@ohif/core"),require("@ohif/extension-default/src/Panels/StudyBrowser/PanelStudyBrowser"),require("@ohif/extension-default"),require("@ohif/extension-cornerstone"),require("@ohif/i18n"),require("@cornerstonejs/tools"),require("@cornerstonejs/core")):e["ohif-extension-measurement-tracking"]=t(e["@ohif/ui-next"],e["@ohif/extension-cornerstone-dicom-sr"],e["@ohif/core"],e["@ohif/extension-default/src/Panels/StudyBrowser/PanelStudyBrowser"],e["@ohif/extension-default"],e["@ohif/extension-cornerstone"],e["@ohif/i18n"],e["@cornerstonejs/tools"],e["@cornerstonejs/core"])}(globalThis,((e,t,n,r,i,o,a,s,c)=>(()=>{var u,l,d={123:(e,t,n)=>{"use strict";n.d(t,{A:()=>c,v:()=>s});var r=n(228);const i=-1,o=0,a=3,s={STANDARD:"standard",SIMPLIFIED:"simplified",NONE:"none"};const c=function({servicesManager:e,extensionManager:t},n,c){const{uiViewportDialogService:u,customizationService:l}=e.services,d=t._appConfig,{viewportId:f,StudyInstanceUID:p,SeriesInstanceUID:h}=c.data||c;return new Promise((async function(e,t){const n=d?.measurementTrackingMode===s.STANDARD;let c;c=d?.measurementTrackingMode===s.NONE?i:n?await function(e,t,n){return new Promise((function(s,c){const u=t.getCustomization("viewportNotification.beginTrackingMessage"),l=[{id:"prompt-begin-tracking-cancel",type:"secondary",text:r.A.t("Common:No"),value:o},{id:"prompt-begin-tracking-no-do-not-ask-again",type:"secondary",text:r.A.t("MeasurementTable:No, do not ask again"),value:i},{id:"prompt-begin-tracking-yes",type:"primary",text:r.A.t("Common:Yes"),value:a}],d=t=>{e.hide(),s(t)};e.show({viewportId:n,id:"measurement-tracking-prompt-begin-tracking",type:"info",message:u,actions:l,onSubmit:d,onOutsideClick:()=>{e.hide(),s(o)},onKeyPress:e=>{if("Enter"===e.key){const e=l.find((e=>"prompt-begin-tracking-yes"===e.id));d(e.value)}}})}))}(u,l,f):a,e({userResponse:c,StudyInstanceUID:p,SeriesInstanceUID:h,viewportId:f})}))}},440:(e,t,n)=>{"use strict";n.d(t,{A:()=>Ht,B:()=>Lt});var r,i,o=n(326),a=n(598),s=n.n(a),c=function(){return c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},c.apply(this,arguments)};function u(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function f(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}!function(e){e.Start="xstate.start",e.Stop="xstate.stop",e.Raise="xstate.raise",e.Send="xstate.send",e.Cancel="xstate.cancel",e.NullEvent="",e.Assign="xstate.assign",e.After="xstate.after",e.DoneState="done.state",e.DoneInvoke="done.invoke",e.Log="xstate.log",e.Init="xstate.init",e.Invoke="xstate.invoke",e.ErrorExecution="error.execution",e.ErrorCommunication="error.communication",e.ErrorPlatform="error.platform",e.ErrorCustom="xstate.error",e.Update="xstate.update",e.Pure="xstate.pure",e.Choose="xstate.choose"}(r||(r={})),function(e){e.Parent="#_parent",e.Internal="#_internal"}(i||(i={}));var p,h=r.Start,v=r.Stop,g=r.Raise,y=r.Send,m=r.Cancel,S=r.NullEvent,b=r.Assign,w=(r.After,r.DoneState,r.Log),x=r.Init,k=r.Invoke,I=(r.ErrorExecution,r.ErrorPlatform),E=r.ErrorCustom,O=r.Update,D=r.Choose,T=r.Pure,R={},A="xstate.guard";function M(e,t,n){void 0===n&&(n=".");var r=N(e,n),i=N(t,n);return G(i)?!!G(r)&&i===r:G(r)?r in i:Object.keys(r).every((function(e){return e in i&&M(r[e],i[e])}))}function _(e){try{return G(e)||"number"==typeof e?"".concat(e):e.type}catch(e){throw new Error("Events must be strings or objects with a string event.type property.")}}function C(e,t){try{return Y(e)?e:e.toString().split(t)}catch(t){throw new Error("'".concat(e,"' is not a valid state path."))}}function N(e,t){return"object"==typeof(n=e)&&"value"in n&&"context"in n&&"event"in n&&"_event"in n?e.value:Y(e)?P(e):"string"!=typeof e?e:P(C(e,t));var n}function P(e){if(1===e.length)return e[0];for(var t={},n=t,r=0;r<e.length-1;r++)r===e.length-2?n[e[r]]=e[r+1]:(n[e[r]]={},n=n[e[r]]);return t}function j(e,t){for(var n={},r=Object.keys(e),i=0;i<r.length;i++){var o=r[i];n[o]=t(e[o],o,e,i)}return n}function U(e,t,n){var r,i,o={};try{for(var a=l(Object.keys(e)),s=a.next();!s.done;s=a.next()){var c=s.value,u=e[c];n(u)&&(o[c]=t(u,c,e))}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return o}var L=function(e){return function(t){var n,r,i=t;try{for(var o=l(e),a=o.next();!a.done;a=o.next()){i=i[a.value]}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}};function V(e){return e?G(e)?[[e]]:F(Object.keys(e).map((function(t){var n=e[t];return"string"==typeof n||n&&Object.keys(n).length?V(e[t]).map((function(e){return[t].concat(e)})):[[t]]}))):[[]]}function F(e){var t;return(t=[]).concat.apply(t,f([],d(e),!1))}function H(e){return Y(e)?e:[e]}function B(e){return void 0===e?[]:H(e)}function z(e,t,n){var r,i;if(J(e))return e(t,n.data);var o={};try{for(var a=l(Object.keys(e)),s=a.next();!s.done;s=a.next()){var c=s.value,u=e[c];J(u)?o[c]=u(t,n.data):o[c]=u}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return o}function q(e){return e instanceof Promise||!(null===e||!J(e)&&"object"!=typeof e||!J(e.then))}function K(e,t){return j(e.states,(function(e,n){if(e){var r=(G(t)?void 0:t[n])||(e?e.current:void 0);if(r)return{current:r,states:K(e,r)}}}))}function $(e,t,n,r){var i=e?n.reduce((function(e,n){var i,o,a=n.assignment,s={state:r,action:n,_event:t},c={};if(J(a))c=a(e,t.data,s);else try{for(var u=l(Object.keys(a)),d=u.next();!d.done;d=u.next()){var f=d.value,p=a[f];c[f]=J(p)?p(e,t.data,s):p}}catch(e){i={error:e}}finally{try{d&&!d.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}return Object.assign({},e,c)}),e):e;return i}var W=function(){};function Y(e){return Array.isArray(e)}function J(e){return"function"==typeof e}function G(e){return"string"==typeof e}function Q(e,t){if(e)return G(e)?{type:A,name:e,predicate:t?t[e]:void 0}:J(e)?{type:A,name:e.name,predicate:e}:e}var X=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();(p={})[X]=function(){return this},p[Symbol.observable]=function(){return this};function Z(e){return!!e&&"__xstatenode"in e}function ee(e,t){return G(e)||"number"==typeof e?c({type:e},t):e}function te(e,t){if(!G(e)&&"$$type"in e&&"scxml"===e.$$type)return e;var n=ee(e);return c({name:n.type,data:n,$$type:"scxml",type:"external"},t)}function ne(e,t){return H(t).map((function(t){return void 0===t||"string"==typeof t||Z(t)?{target:t,event:e}:c(c({},t),{event:e})}))}function re(e,t,n,r,i){var o=e.options.guards,a={state:i,cond:t,_event:r};if(t.type===A)return((null==o?void 0:o[t.name])||t.predicate)(n,r.data,a);var s=null==o?void 0:o[t.type];if(!s)throw new Error("Guard '".concat(t.type,"' is not implemented on machine '").concat(e.id,"'."));return s(n,r.data,a)}function ie(e){return"string"==typeof e?{type:e}:e}function oe(e,t,n){var r=function(){},i="object"==typeof e,o=i?e:null;return{next:((i?e.next:e)||r).bind(o),error:((i?e.error:t)||r).bind(o),complete:((i?e.complete:n)||r).bind(o)}}function ae(e,t){return"".concat(e,":invocation[").concat(t,"]")}function se(e){return(e.type===g||e.type===y&&e.to===i.Internal)&&"number"!=typeof e.delay}var ce=te({type:x});function ue(e,t){return t&&t[e]||void 0}function le(e,t){var n;if(G(e)||"number"==typeof e)n=J(r=ue(e,t))?{type:e,exec:r}:r||{type:e,exec:void 0};else if(J(e))n={type:e.name||e.toString(),exec:e};else{var r;if(J(r=ue(e.type,t)))n=c(c({},e),{exec:r});else if(r){var i=r.type||e.type;n=c(c(c({},r),e),{type:i})}else n=e}return n}var de=function(e,t){return e?(Y(e)?e:[e]).map((function(e){return le(e,t)})):[]};function fe(e){var t=le(e);return c(c({id:G(e)?e:t.id},t),{type:t.type})}function pe(e,t){return{to:t?t.to:void 0,type:y,event:J(e)?e:ee(e),delay:t?t.delay:void 0,id:t&&void 0!==t.id?t.id:J(e)?e.name:_(e)}}function he(e,t){var n="".concat(r.DoneState,".").concat(e),i={type:n,data:t,toString:function(){return n}};return i}function ve(e,t){var n="".concat(r.DoneInvoke,".").concat(e),i={type:n,data:t,toString:function(){return n}};return i}function ge(e,t){var n="".concat(r.ErrorPlatform,".").concat(e),i={type:n,data:t,toString:function(){return n}};return i}function ye(e,t,n,o,a,s,u){void 0===u&&(u=!1);var p=u?[]:function(e){var t,n,r=[];try{for(var i=l(e),o=i.next();!o.done;o=i.next())for(var a=o.value,s=0;s<a.actions.length;)a.actions[s].type!==b?s++:(r.push(a.actions[s]),a.actions.splice(s,1))}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}(a),h=p.length?$(n,o,p,t):n,m=u?[n]:void 0,S=[];function x(a,l){var p;switch(l.type){case g:var x=function(e,t,n,r){var i,o={_event:n},a=te(J(e.event)?e.event(t,n.data,o):e.event);if(G(e.delay)){var s=r&&r[e.delay];i=J(s)?s(t,n.data,o):s}else i=J(e.delay)?e.delay(t,n.data,o):e.delay;return c(c({},e),{type:g,_event:a,delay:i})}(l,h,o,e.options.delays);return s&&"number"==typeof x.delay&&s(x,h,o),x;case y:var k=function(e,t,n,r){var i,o={_event:n},a=te(J(e.event)?e.event(t,n.data,o):e.event);if(G(e.delay)){var s=r&&r[e.delay];i=J(s)?s(t,n.data,o):s}else i=J(e.delay)?e.delay(t,n.data,o):e.delay;var u=J(e.to)?e.to(t,n.data,o):e.to;return c(c({},e),{to:u,_event:a,event:a.data,delay:i})}(l,h,o,e.options.delays);return s&&k.to!==i.Internal&&("entry"===a?S.push(k):s(k,h,o)),k;case w:var I=function(e,t,n){return c(c({},e),{value:G(e.expr)?e.expr:e.expr(t,n.data,{_event:n})})}(l,h,o);return null==s||s(I,h,o),I;case D:if(!(A=null===(p=l.conds.find((function(n){var r=Q(n.cond,e.options.guards);return!r||re(e,r,h,o,s?void 0:t)})))||void 0===p?void 0:p.actions))return[];var E=d(ye(e,t,h,o,[{type:a,actions:de(B(A),e.options.actions)}],s,u),2),O=E[0],R=E[1];return h=R,null==m||m.push(h),O;case T:var A;if(!(A=l.get(h,o.data)))return[];var M=d(ye(e,t,h,o,[{type:a,actions:de(B(A),e.options.actions)}],s,u),2),_=M[0],C=M[1];return h=C,null==m||m.push(h),_;case v:I=function(e,t,n){var i=J(e.activity)?e.activity(t,n.data):e.activity,o="string"==typeof i?{id:i}:i;return{type:r.Stop,activity:o}}(l,h,o);return null==s||s(I,n,o),I;case b:h=$(h,o,[l],s?void 0:t),null==m||m.push(h);break;default:var N=le(l,e.options.actions),P=N.exec;if(s)s(N,h,o);else if(P&&m){var j=m.length-1,U=c(c({},N),{exec:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];P.apply(void 0,f([m[j]],d(t),!1))}});N=U}return N}}var k=F(a.map((function(e){var t,n,r=[];try{for(var i=l(e.actions),a=i.next();!a.done;a=i.next()){var c=a.value,u=x(e.type,c);u&&(r=r.concat(u))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return S.forEach((function(e){s(e,h,o)})),S.length=0,r})));return[k,h]}var me=[],Se=function(e,t){me.push(e);var n=t(e);return me.pop(),n};function be(e){var t;return(t={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:e}}})[X]=function(){return this},t}function we(e,t,n){var r=be(t);if(r.deferred=!0,Z(e)){var i=r.state=Se(void 0,(function(){return(n?e.withContext(n):e).initialState}));r.getSnapshot=function(){return i}}return r}var xe=function(e){return"atomic"===e.type||"final"===e.type};function ke(e){return Object.keys(e.states).map((function(t){return e.states[t]}))}function Ie(e){return ke(e).filter((function(e){return"history"!==e.type}))}function Ee(e){var t=[e];return xe(e)?t:t.concat(F(Ie(e).map(Ee)))}function Oe(e,t){var n,r,i,o,a,s,c,u,d=Te(new Set(e)),f=new Set(t);try{for(var p=l(f),h=p.next();!h.done;h=p.next())for(var v=(I=h.value).parent;v&&!f.has(v);)f.add(v),v=v.parent}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}var g=Te(f);try{for(var y=l(f),m=y.next();!m.done;m=y.next()){if("compound"!==(I=m.value).type||g.get(I)&&g.get(I).length){if("parallel"===I.type)try{for(var S=(a=void 0,l(Ie(I))),b=S.next();!b.done;b=S.next()){var w=b.value;f.has(w)||(f.add(w),d.get(w)?d.get(w).forEach((function(e){return f.add(e)})):w.initialStateNodes.forEach((function(e){return f.add(e)})))}}catch(e){a={error:e}}finally{try{b&&!b.done&&(s=S.return)&&s.call(S)}finally{if(a)throw a.error}}}else d.get(I)?d.get(I).forEach((function(e){return f.add(e)})):I.initialStateNodes.forEach((function(e){return f.add(e)}))}}catch(e){i={error:e}}finally{try{m&&!m.done&&(o=y.return)&&o.call(y)}finally{if(i)throw i.error}}try{for(var x=l(f),k=x.next();!k.done;k=x.next()){var I;for(v=(I=k.value).parent;v&&!f.has(v);)f.add(v),v=v.parent}}catch(e){c={error:e}}finally{try{k&&!k.done&&(u=x.return)&&u.call(x)}finally{if(c)throw c.error}}return f}function De(e,t){var n=t.get(e);if(!n)return{};if("compound"===e.type){var r=n[0];if(!r)return{};if(xe(r))return r.key}var i={};return n.forEach((function(e){i[e.key]=De(e,t)})),i}function Te(e){var t,n,r=new Map;try{for(var i=l(e),o=i.next();!o.done;o=i.next()){var a=o.value;r.has(a)||r.set(a,[]),a.parent&&(r.has(a.parent)||r.set(a.parent,[]),r.get(a.parent).push(a))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}function Re(e,t){return De(e,Te(Oe([e],t)))}function Ae(e,t){return Array.isArray(e)?e.some((function(e){return e===t})):e instanceof Set&&e.has(t)}function Me(e,t){return"compound"===t.type?Ie(t).some((function(t){return"final"===t.type&&Ae(e,t)})):"parallel"===t.type&&Ie(t).every((function(t){return Me(e,t)}))}function _e(e){return new Set(F(e.map((function(e){return e.tags}))))}function Ce(e,t){if(e===t)return!0;if(void 0===e||void 0===t)return!1;if(G(e)||G(t))return e===t;var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((function(n){return Ce(e[n],t[n])}))}function Ne(e){return"object"==typeof e&&null!==e&&("value"in e&&"_event"in e)}var Pe=function(){function e(e){var t,n,r=this;this.actions=[],this.activities=R,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||R,this.meta=(void 0===(n=e.configuration)&&(n=[]),n.reduce((function(e,t){return void 0!==t.meta&&(e[t.id]=t.meta),e}),{})),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=null!==(t=Array.isArray(e.tags)?new Set(e.tags):e.tags)&&void 0!==t?t:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return function(e){return f([],d(new Set(F(f([],d(e.map((function(e){return e.ownEvents}))),!1)))),!1)}(r.configuration)}})}return e.from=function(t,n){return t instanceof e?t.context!==n?new e({value:t.value,context:n,_event:t._event,_sessionid:null,historyValue:t.historyValue,history:t.history,actions:[],activities:t.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):t:new e({value:t,context:n,_event:ce,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},e.create=function(t){return new e(t)},e.inert=function(t,n){if(t instanceof e){if(!t.actions.length)return t;var r=ce;return new e({value:t.value,context:n,_event:r,_sessionid:null,historyValue:t.historyValue,history:t.history,activities:t.activities,configuration:t.configuration,transitions:[],children:{}})}return e.from(t,n)},e.prototype.toStrings=function(e,t){var n=this;if(void 0===e&&(e=this.value),void 0===t&&(t="."),G(e))return[e];var r=Object.keys(e);return r.concat.apply(r,f([],d(r.map((function(r){return n.toStrings(e[r],t).map((function(e){return r+t+e}))}))),!1))},e.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var t=e.tags;e.machine;var n=u(e,["configuration","transitions","tags","machine"]);return c(c({},n),{tags:Array.from(t)})},e.prototype.matches=function(e){return M(e,this.value)},e.prototype.hasTag=function(e){return this.tags.has(e)},e.prototype.can=function(e){var t;W(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=null===(t=this.machine)||void 0===t?void 0:t.getTransitionData(this,e);return!!(null==n?void 0:n.transitions.length)&&n.transitions.some((function(e){return void 0!==e.target||e.actions.length}))},e}(),je={deferEvents:!1},Ue=function(){function e(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=c(c({},je),e)}return e.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents)return void this.schedule(e);this.process(e)}this.flushEvents()},e.prototype.schedule=function(e){if(this.initialized&&!this.processingEvent){if(0!==this.queue.length)throw new Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()}else this.queue.push(e)},e.prototype.clear=function(){this.queue=[]},e.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},e.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(e){throw this.clear(),e}finally{this.processingEvent=!1}},e}(),Le=new Map,Ve=0,Fe=function(){return"x:".concat(Ve++)},He=function(e,t){return Le.set(e,t),e},Be=function(e){return Le.get(e)},ze=function(e){Le.delete(e)};function qe(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n.g?n.g:void 0}function Ke(e){if(qe()){var t=function(){var e=qe();if(e&&"__xstate__"in e)return e.__xstate__}();t&&t.register(e)}}function $e(e,t){void 0===t&&(t={});var n=e.initialState,r=new Set,i=[],o=!1,a=function(e){var t;return c(((t={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}})[X]=function(){return this},t),e)}({id:t.id,send:function(t){i.push(t),function(){if(!o){for(o=!0;i.length>0;){var t=i.shift();n=e.transition(n,t,s),r.forEach((function(e){return e.next(n)}))}o=!1}}()},getSnapshot:function(){return n},subscribe:function(e,t,i){var o=oe(e,t,i);return r.add(o),o.next(n),{unsubscribe:function(){r.delete(o)}}}}),s={parent:t.parent,self:a,id:t.id||"anonymous",observers:r};return n=e.start?e.start(s):n,a}var We,Ye={sync:!1,autoForward:!1};!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(We||(We={}));var Je=function(){function e(t,n){void 0===n&&(n=e.defaultOptions);var o=this;this.machine=t,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=We.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(e,t){if(Y(e))return o.batch(e),o.state;var n=te(ee(e,t));if(o.status===We.Stopped)return o.state;if(o.status!==We.Running&&!o.options.deferEvents)throw new Error('Event "'.concat(n.name,'" was sent to uninitialized service "').concat(o.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ').concat(JSON.stringify(n.data)));return o.scheduler.schedule((function(){o.forward(n);var e=o._nextState(n);o.update(e,n)})),o._state},this.sendTo=function(e,t,n){var r,a=o.parent&&(t===i.Parent||o.parent.id===t),s=a?o.parent:G(t)?t===i.Internal?o:o.children.get(t)||Be(t):(r=t)&&"function"==typeof r.send?t:void 0;if(s)if("machine"in s){if(o.status!==We.Stopped||o.parent!==s||o.state.done){var u=c(c({},e),{name:e.name===E?"".concat(ge(o.id)):e.name,origin:o.sessionId});!n&&o.machine.config.predictableActionArguments?o._outgoingQueue.push([s,u]):s.send(u)}}else!n&&o.machine.config.predictableActionArguments?o._outgoingQueue.push([s,e.data]):s.send(e.data);else if(!a)throw new Error("Unable to send event to child '".concat(t,"' from service '").concat(o.id,"'."))},this._exec=function(e,t,n,i){void 0===i&&(i=o.machine.options.actions);var a=e.exec||ue(e.type,i),s=J(a)?a:a?a.exec:e.exec;if(s)try{return s(t,n.data,o.machine.config.predictableActionArguments?{action:e,_event:n}:{action:e,state:o.state,_event:n})}catch(e){throw o.parent&&o.parent.send({type:"xstate.error",data:e}),e}switch(e.type){case g:var c=e;o.defer(c);break;case y:var u=e;if("number"==typeof u.delay)return void o.defer(u);u.to?o.sendTo(u._event,u.to,n===ce):o.send(u._event);break;case m:o.cancel(e.sendId);break;case h:if(o.status!==We.Running)return;var l=e.activity;if(!o.machine.config.predictableActionArguments&&!o.state.activities[l.id||l.type])break;if(l.type===r.Invoke){var d=ie(l.src),f=o.machine.options.services?o.machine.options.services[d.type]:void 0,p=l.id,S=l.data;0;var b="autoForward"in l?l.autoForward:!!l.forward;if(!f)return void 0;var x=S?z(S,t,n):void 0;if("string"==typeof f)return;var k=J(f)?f(t,n.data,{data:x,src:d,meta:l.meta}):f;if(!k)return;var I=void 0;Z(k)&&(k=x?k.withContext(x):k,I={autoForward:b}),o.spawn(k,p,I)}else o.spawnActivity(l);break;case v:o.stopChild(e.activity.id);break;case w:var E=e,O=E.label,D=E.value;O?o.logger(O,D):o.logger(D)}};var a=c(c({},e.defaultOptions),n),s=a.clock,u=a.logger,l=a.parent,d=a.id,f=void 0!==d?d:t.id;this.id=f,this.logger=u,this.clock=s,this.parent=l,this.options=a,this.scheduler=new Ue({deferEvents:this.options.deferEvents}),this.sessionId=Fe()}return Object.defineProperty(e.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:Se(this,(function(){return e._initialState=e.machine.initialState,e._initialState}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.execute=function(e,t){var n,r;try{for(var i=l(e.actions),o=i.next();!o.done;o=i.next()){var a=o.value;this.exec(a,e,t)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype.update=function(e,t){var n,r,i,o,a,s,c,u,d=this;if(e._sessionid=this.sessionId,this._state=e,this.machine.config.predictableActionArguments&&t!==ce||!this.options.execute)for(var f=void 0;f=this._outgoingQueue.shift();)f[0].send(f[1]);else this.execute(this.state);if(this.children.forEach((function(e){d.state.children[e.id]=e})),this.devTools&&this.devTools.send(t.data,e),e.event)try{for(var p=l(this.eventListeners),h=p.next();!h.done;h=p.next()){(0,h.value)(e.event)}}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}try{for(var v=l(this.listeners),g=v.next();!g.done;g=v.next()){(0,g.value)(e,e.event)}}catch(e){i={error:e}}finally{try{g&&!g.done&&(o=v.return)&&o.call(v)}finally{if(i)throw i.error}}try{for(var y=l(this.contextListeners),m=y.next();!m.done;m=y.next()){(0,m.value)(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(e){a={error:e}}finally{try{m&&!m.done&&(s=y.return)&&s.call(y)}finally{if(a)throw a.error}}if(this.state.done){var S=e.configuration.find((function(e){return"final"===e.type&&e.parent===d.machine})),b=S&&S.doneData?z(S.doneData,e.context,t):void 0;this._doneEvent=ve(this.id,b);try{for(var w=l(this.doneListeners),x=w.next();!x.done;x=w.next()){(0,x.value)(this._doneEvent)}}catch(e){c={error:e}}finally{try{x&&!x.done&&(u=w.return)&&u.call(w)}finally{if(c)throw c.error}}this._stop(),this._stopChildren(),ze(this.sessionId)}},e.prototype.onTransition=function(e){return this.listeners.add(e),this.status===We.Running&&e(this.state,this.state.event),this},e.prototype.subscribe=function(e,t,n){var r=this,i=oe(e,t,n);this.listeners.add(i.next),this.status!==We.NotStarted&&i.next(this.state);var o=function(){r.doneListeners.delete(o),r.stopListeners.delete(o),i.complete()};return this.status===We.Stopped?i.complete():(this.onDone(o),this.onStop(o)),{unsubscribe:function(){r.listeners.delete(i.next),r.doneListeners.delete(o),r.stopListeners.delete(o)}}},e.prototype.onEvent=function(e){return this.eventListeners.add(e),this},e.prototype.onSend=function(e){return this.sendListeners.add(e),this},e.prototype.onChange=function(e){return this.contextListeners.add(e),this},e.prototype.onStop=function(e){return this.stopListeners.add(e),this},e.prototype.onDone=function(e){return this.status===We.Stopped&&this._doneEvent?e(this._doneEvent):this.doneListeners.add(e),this},e.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},e.prototype.start=function(e){var t=this;if(this.status===We.Running)return this;this.machine._init(),He(this.sessionId,this),this.initialized=!0,this.status=We.Running;var n=void 0===e?this.initialState:Se(this,(function(){return Ne(e)?t.machine.resolveState(e):t.machine.resolveState(Pe.from(e,t.machine.context))}));return this.options.devTools&&this.attachDev(),this.scheduler.initialize((function(){t.update(n,ce)})),this},e.prototype._stopChildren=function(){this.children.forEach((function(e){J(e.stop)&&e.stop()})),this.children.clear()},e.prototype._stop=function(){var e,t,n,r,i,o,a,s,c,u;try{for(var d=l(this.listeners),f=d.next();!f.done;f=d.next()){var p=f.value;this.listeners.delete(p)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}try{for(var h=l(this.stopListeners),v=h.next();!v.done;v=h.next()){(p=v.value)(),this.stopListeners.delete(p)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}try{for(var g=l(this.contextListeners),y=g.next();!y.done;y=g.next()){p=y.value;this.contextListeners.delete(p)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(i)throw i.error}}try{for(var m=l(this.doneListeners),S=m.next();!S.done;S=m.next()){p=S.value;this.doneListeners.delete(p)}}catch(e){a={error:e}}finally{try{S&&!S.done&&(s=m.return)&&s.call(m)}finally{if(a)throw a.error}}if(!this.initialized)return this;this.initialized=!1,this.status=We.Stopped,this._initialState=void 0;try{for(var b=l(Object.keys(this.delayedEventsMap)),w=b.next();!w.done;w=b.next()){var x=w.value;this.clock.clearTimeout(this.delayedEventsMap[x])}}catch(e){c={error:e}}finally{try{w&&!w.done&&(u=b.return)&&u.call(b)}finally{if(c)throw c.error}}this.scheduler.clear(),this.scheduler=new Ue({deferEvents:this.options.deferEvents})},e.prototype.stop=function(){var e=this,t=this.scheduler;return this._stop(),t.schedule((function(){var t;if(!(null===(t=e._state)||void 0===t?void 0:t.done)){var n=te({type:"xstate.stop"}),r=Se(e,(function(){var t=F(f([],d(e.state.configuration),!1).sort((function(e,t){return t.order-e.order})).map((function(t){return de(t.onExit,e.machine.options.actions)}))),r=d(ye(e.machine,e.state,e.state.context,n,[{type:"exit",actions:t}],e.machine.config.predictableActionArguments?e._exec:void 0,e.machine.config.predictableActionArguments||e.machine.config.preserveActionOrder),2),i=r[0],o=r[1],a=new Pe({value:e.state.value,context:o,_event:n,_sessionid:e.sessionId,historyValue:void 0,history:e.state,actions:i.filter((function(e){return!se(e)})),activities:{},events:[],configuration:[],transitions:[],children:{},done:e.state.done,tags:e.state.tags,machine:e.machine});return a.changed=!0,a}));e.update(r,n),e._stopChildren(),ze(e.sessionId)}})),this},e.prototype.batch=function(e){var t=this;if(this.status===We.NotStarted&&this.options.deferEvents)0;else if(this.status!==We.Running)throw new Error("".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));if(e.length){var n=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule((function(){var r,i,o=t.state,a=!1,s=[],u=function(e){var r=te(e);t.forward(r),o=Se(t,(function(){return t.machine.transition(o,r,void 0,n||void 0)})),s.push.apply(s,f([],d(t.machine.config.predictableActionArguments?o.actions:o.actions.map((function(e){return function(e,t){var n=e.exec;return c(c({},e),{exec:void 0!==n?function(){return n(t.context,t.event,{action:e,state:t,_event:t._event})}:void 0})}(e,o)}))),!1)),a=a||!!o.changed};try{for(var p=l(e),h=p.next();!h.done;h=p.next()){u(h.value)}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}o.changed=a,o.actions=s,t.update(o,te(e[e.length-1]))}))}},e.prototype.sender=function(e){return this.send.bind(this,e)},e.prototype._nextState=function(e,t){var n=this;void 0===t&&(t=!!this.machine.config.predictableActionArguments&&this._exec);var r=te(e);if(0===r.name.indexOf(I)&&!this.state.nextEvents.some((function(e){return 0===e.indexOf(I)})))throw r.data.data;return Se(this,(function(){return n.machine.transition(n.state,r,void 0,t||void 0)}))},e.prototype.nextState=function(e){return this._nextState(e,!1)},e.prototype.forward=function(e){var t,n;try{for(var r=l(this.forwardTo),i=r.next();!i.done;i=r.next()){var o=i.value,a=this.children.get(o);if(!a)throw new Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(o,"'."));a.send(e)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},e.prototype.defer=function(e){var t=this,n=this.clock.setTimeout((function(){"to"in e&&e.to?t.sendTo(e._event,e.to,!0):t.send(e._event)}),e.delay);e.id&&(this.delayedEventsMap[e.id]=n)},e.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},e.prototype.exec=function(e,t,n){void 0===n&&(n=this.machine.options.actions),this._exec(e,t.context,t._event,n)},e.prototype.removeChild=function(e){var t;this.children.delete(e),this.forwardTo.delete(e),null===(t=this.state)||void 0===t||delete t.children[e]},e.prototype.stopChild=function(e){var t=this.children.get(e);t&&(this.removeChild(e),J(t.stop)&&t.stop())},e.prototype.spawn=function(e,t,n){if(this.status!==We.Running)return we(e,t);if(q(e))return this.spawnPromise(Promise.resolve(e),t);if(J(e))return this.spawnCallback(e,t);if(function(e){try{return"function"==typeof e.send}catch(e){return!1}}(i=e)&&"id"in i)return this.spawnActor(e,t);if(function(e){try{return"subscribe"in e&&J(e.subscribe)}catch(e){return!1}}(e))return this.spawnObservable(e,t);if(Z(e))return this.spawnMachine(e,c(c({},n),{id:t}));if(null!==(r=e)&&"object"==typeof r&&"transition"in r&&"function"==typeof r.transition)return this.spawnBehavior(e,t);throw new Error('Unable to spawn entity "'.concat(t,'" of type "').concat(typeof e,'".'));var r,i},e.prototype.spawnMachine=function(t,n){var r=this;void 0===n&&(n={});var i=new e(t,c(c({},this.options),{parent:this,id:n.id||t.id})),o=c(c({},Ye),n);o.sync&&i.onTransition((function(e){r.send(O,{state:e,id:i.id})}));var a=i;return this.children.set(i.id,a),o.autoForward&&this.forwardTo.add(i.id),i.onDone((function(e){r.removeChild(i.id),r.send(te(e,{origin:i.id}))})).start(),a},e.prototype.spawnBehavior=function(e,t){var n=$e(e,{id:t,parent:this});return this.children.set(t,n),n},e.prototype.spawnPromise=function(e,t){var n,r,i=this,o=!1;e.then((function(e){o||(r=e,i.removeChild(t),i.send(te(ve(t,e),{origin:t})))}),(function(e){if(!o){i.removeChild(t);var n=ge(t,e);try{i.send(te(n,{origin:t}))}catch(e){i.devTools&&i.devTools.send(n,i.state),i.machine.strict&&i.stop()}}}));var a=((n={id:t,send:function(){},subscribe:function(t,n,r){var i=oe(t,n,r),o=!1;return e.then((function(e){o||(i.next(e),o||i.complete())}),(function(e){o||i.error(e)})),{unsubscribe:function(){return o=!0}}},stop:function(){o=!0},toJSON:function(){return{id:t}},getSnapshot:function(){return r}})[X]=function(){return this},n);return this.children.set(t,a),a},e.prototype.spawnCallback=function(e,t){var n,r,i,o=this,a=!1,s=new Set,c=new Set;try{i=e((function(e){r=e,c.forEach((function(t){return t(e)})),a||o.send(te(e,{origin:t}))}),(function(e){s.add(e)}))}catch(e){this.send(ge(t,e))}if(q(i))return this.spawnPromise(i,t);var u=((n={id:t,send:function(e){return s.forEach((function(t){return t(e)}))},subscribe:function(e){var t=oe(e);return c.add(t.next),{unsubscribe:function(){c.delete(t.next)}}},stop:function(){a=!0,J(i)&&i()},toJSON:function(){return{id:t}},getSnapshot:function(){return r}})[X]=function(){return this},n);return this.children.set(t,u),u},e.prototype.spawnObservable=function(e,t){var n,r,i=this,o=e.subscribe((function(e){r=e,i.send(te(e,{origin:t}))}),(function(e){i.removeChild(t),i.send(te(ge(t,e),{origin:t}))}),(function(){i.removeChild(t),i.send(te(ve(t),{origin:t}))})),a=((n={id:t,send:function(){},subscribe:function(t,n,r){return e.subscribe(t,n,r)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return r},toJSON:function(){return{id:t}}})[X]=function(){return this},n);return this.children.set(t,a),a},e.prototype.spawnActor=function(e,t){return this.children.set(t,e),e},e.prototype.spawnActivity=function(e){var t=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(t){var n=t(this.state.context,e);this.spawnEffect(e.id,n)}},e.prototype.spawnEffect=function(e,t){var n;this.children.set(e,((n={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:t||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}})[X]=function(){return this},n))},e.prototype.attachDev=function(){var e=qe();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var t="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect(c(c({name:this.id,autoPause:!0,stateSanitizer:function(e){return{value:e.value,context:e.context,actions:e.actions}}},t),{features:c({jump:!1,skip:!1},t?t.features:void 0)}),this.machine),this.devTools.init(this.state)}Ke(this)}},e.prototype.toJSON=function(){return{id:this.id}},e.prototype[X]=function(){return this},e.prototype.getSnapshot=function(){return this.status===We.NotStarted?this.initialState:this._state},e.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,t){return setTimeout(e,t)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},e.interpret=Ge,e}();function Ge(e,t){return new Je(e,t)}function Qe(e){if("string"==typeof e){var t={type:e,toString:function(){return e}};return t}return e}function Xe(e){return c(c({type:k},e),{toJSON:function(){e.onDone,e.onError;var t=u(e,["onDone","onError"]);return c(c({},t),{type:k,src:Qe(e.src)})}})}var Ze="",et="*",tt={},nt=function(e){return"#"===e[0]},rt=function(){function e(t,n,r,i){void 0===r&&(r="context"in t?t.context:void 0);var o,a=this;this.config=t,this._context=r,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign({actions:{},guards:{},services:{},activities:{},delays:{}},n),this.parent=null==i?void 0:i.parent,this.key=this.config.key||(null==i?void 0:i.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:"."),this.id=this.config.id||f([this.machine.key],d(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:null!==(o=this.config.schema)&&void 0!==o?o:{},this.description=this.config.description,this.initial=this.config.initial,this.states=this.config.states?j(this.config.states,(function(t,n){var r,i=new e(t,{},void 0,{parent:a,key:n});return Object.assign(a.idMap,c(((r={})[i.id]=i,r),i.idMap)),i})):tt;var s=0;!function e(t){var n,r;t.order=s++;try{for(var i=l(ke(t)),o=i.next();!o.done;o=i.next()){e(o.value)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}(this),this.history=!0===this.config.history?"shallow":this.config.history||!1,this._transient=!!this.config.always||!!this.config.on&&(Array.isArray(this.config.on)?this.config.on.some((function(e){return e.event===Ze})):Ze in this.config.on),this.strict=!!this.config.strict,this.onEntry=B(this.config.entry||this.config.onEntry).map((function(e){return le(e)})),this.onExit=B(this.config.exit||this.config.onExit).map((function(e){return le(e)})),this.meta=this.config.meta,this.doneData="final"===this.type?this.config.data:void 0,this.invoke=B(this.config.invoke).map((function(e,t){var n,r;if(Z(e)){var i=ae(a.id,t);return a.machine.options.services=c(((n={})[i]=e,n),a.machine.options.services),Xe({src:i,id:i})}if(G(e.src)){i=e.id||ae(a.id,t);return Xe(c(c({},e),{id:i,src:e.src}))}if(Z(e.src)||J(e.src)){i=e.id||ae(a.id,t);return a.machine.options.services=c(((r={})[i]=e.src,r),a.machine.options.services),Xe(c(c({id:i},e),{src:i}))}var o=e.src;return Xe(c(c({id:ae(a.id,t)},e),{src:o}))})),this.activities=B(this.config.activities).concat(this.invoke).map((function(e){return fe(e)})),this.transition=this.transition.bind(this),this.tags=B(this.config.tags)}return e.prototype._init=function(){this.__cache.transitions||Ee(this).forEach((function(e){return e.on}))},e.prototype.withConfig=function(t,n){var r=this.options,i=r.actions,o=r.activities,a=r.guards,s=r.services,u=r.delays;return new e(this.config,{actions:c(c({},i),t.actions),activities:c(c({},o),t.activities),guards:c(c({},a),t.guards),services:c(c({},s),t.services),delays:c(c({},u),t.delays)},null!=n?n:this.context)},e.prototype.withContext=function(t){return new e(this.config,this.options,t)},Object.defineProperty(e.prototype,"context",{get:function(){return J(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:j(this.states,(function(e){return e.definition})),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){return this.definition},Object.defineProperty(e.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce((function(e,t){return e[t.eventType]=e[t.eventType]||[],e[t.eventType].push(t),e}),{})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),e.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var t=e===Ze,n=this.transitions.filter((function(n){var r=n.eventType===e;return t?r:r||n.eventType===et}));return this.__cache.candidates[e]=n,n},e.prototype.getDelayedTransitions=function(){var e=this,t=this.config.after;if(!t)return[];var n=function(t,n){var i=function(e,t){var n=t?"#".concat(t):"";return"".concat(r.After,"(").concat(e,")").concat(n)}(J(t)?"".concat(e.id,":delay[").concat(n,"]"):t,e.id);return e.onEntry.push(pe(i,{delay:t})),e.onExit.push({type:m,sendId:i}),i};return(Y(t)?t.map((function(e,t){var r=n(e.delay,t);return c(c({},e),{event:r})})):F(Object.keys(t).map((function(e,r){var i=t[e],o=G(i)?{target:i}:i,a=isNaN(+e)?e:+e,s=n(a,r);return B(o).map((function(e){return c(c({},e),{event:s,delay:a})}))})))).map((function(t){var n=t.delay;return c(c({},e.formatTransition(t)),{delay:n})}))},e.prototype.getStateNodes=function(e){var t,n=this;if(!e)return[];var r=e instanceof Pe?e.value:N(e,this.delimiter);if(G(r)){var i=this.getStateNode(r).initial;return void 0!==i?this.getStateNodes(((t={})[r]=i,t)):[this,this.states[r]]}var o=Object.keys(r),a=[this];return a.push.apply(a,f([],d(F(o.map((function(e){return n.getStateNode(e).getStateNodes(r[e])})))),!1)),a},e.prototype.handles=function(e){var t=_(e);return this.events.includes(t)},e.prototype.resolveState=function(e){var t=e instanceof Pe?e:Pe.create(e),n=Array.from(Oe([],this.getStateNodes(t.value)));return new Pe(c(c({},t),{value:this.resolve(t.value),configuration:n,done:Me(n,this),tags:_e(n),machine:this.machine}))},e.prototype.transitionLeafNode=function(e,t,n){var r=this.getStateNode(e).next(t,n);return r&&r.transitions.length?r:this.next(t,n)},e.prototype.transitionCompoundNode=function(e,t,n){var r=Object.keys(e),i=this.getStateNode(r[0])._transition(e[r[0]],t,n);return i&&i.transitions.length?i:this.next(t,n)},e.prototype.transitionParallelNode=function(e,t,n){var r,i,o={};try{for(var a=l(Object.keys(e)),s=a.next();!s.done;s=a.next()){var c=s.value,u=e[c];if(u){var d=this.getStateNode(c)._transition(u,t,n);d&&(o[c]=d)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}var f=Object.keys(o).map((function(e){return o[e]})),p=F(f.map((function(e){return e.transitions})));if(!f.some((function(e){return e.transitions.length>0})))return this.next(t,n);var h=F(Object.keys(o).map((function(e){return o[e].configuration})));return{transitions:p,exitSet:F(f.map((function(e){return e.exitSet}))),configuration:h,source:t,actions:F(Object.keys(o).map((function(e){return o[e].actions})))}},e.prototype._transition=function(e,t,n){return G(e)?this.transitionLeafNode(e,t,n):1===Object.keys(e).length?this.transitionCompoundNode(e,t,n):this.transitionParallelNode(e,t,n)},e.prototype.getTransitionData=function(e,t){return this._transition(e.value,e,te(t))},e.prototype.next=function(e,t){var n,r,i,o=this,a=t.name,s=[],c=[];try{for(var u=l(this.getCandidates(a)),p=u.next();!p.done;p=u.next()){var h=p.value,v=h.cond,g=h.in,y=e.context,m=!g||(G(g)&&nt(g)?e.matches(N(this.getStateNodeById(g).path,this.delimiter)):M(N(g,this.delimiter),L(this.path.slice(0,-2))(e.value))),S=!1;try{S=!v||re(this.machine,v,y,t,e)}catch(e){throw new Error("Unable to evaluate guard '".concat(v.name||v.type,"' in transition for event '").concat(a,"' in state node '").concat(this.id,"':\n").concat(e.message))}if(S&&m){void 0!==h.target&&(c=h.target),s.push.apply(s,f([],d(h.actions),!1)),i=h;break}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}if(i){if(!c.length)return{transitions:[i],exitSet:[],configuration:e.value?[this]:[],source:e,actions:s};var b=F(c.map((function(t){return o.getRelativeStateNodes(t,e.historyValue)})));return{transitions:[i],exitSet:!!i.internal?[]:F(c.map((function(e){return o.getPotentiallyReenteringNodes(e)}))),configuration:b,source:e,actions:s}}},e.prototype.getPotentiallyReenteringNodes=function(e){if(this.order<e.order)return[this];for(var t=[],n=this,r=e;n&&n!==r;)t.push(n),n=n.parent;return n!==r?[]:(t.push(r),t)},e.prototype.getActions=function(e,t,n,i,o,a,s){var c,u,p,h,v=this,y=a?Oe([],this.getStateNodes(a.value)):[],m=new Set;try{for(var S=l(Array.from(e).sort((function(e,t){return e.order-t.order}))),b=S.next();!b.done;b=S.next()){(!Ae(y,k=b.value)||Ae(n.exitSet,k)||k.parent&&m.has(k.parent))&&m.add(k)}}catch(e){c={error:e}}finally{try{b&&!b.done&&(u=S.return)&&u.call(S)}finally{if(c)throw c.error}}try{for(var w=l(y),x=w.next();!x.done;x=w.next()){var k;Ae(e,k=x.value)&&!Ae(n.exitSet,k.parent)||n.exitSet.push(k)}}catch(e){p={error:e}}finally{try{x&&!x.done&&(h=w.return)&&h.call(w)}finally{if(p)throw p.error}}n.exitSet.sort((function(e,t){return t.order-e.order}));var I=Array.from(m).sort((function(e,t){return e.order-t.order})),E=new Set(n.exitSet),O=F(I.map((function(e){var t=[];if("final"!==e.type)return t;var r=e.parent;if(!r.parent)return t;t.push(he(e.id,e.doneData),he(r.id,e.doneData?z(e.doneData,i,o):void 0));var a=r.parent;return"parallel"===a.type&&Ie(a).every((function(e){return Me(n.configuration,e)}))&&t.push(he(a.id)),t}))),D=I.map((function(e){var t=e.onEntry,n=e.activities.map((function(e){return function(e){var t=fe(e);return{type:r.Start,activity:t,exec:void 0}}(e)}));return{type:"entry",actions:de(s?f(f([],d(t),!1),d(n),!1):f(f([],d(n),!1),d(t),!1),v.machine.options.actions)}})).concat({type:"state_done",actions:O.map((function(e){return function(e,t){return{type:g,event:"function"==typeof e?e:ee(e),delay:t?t.delay:void 0,id:null==t?void 0:t.id}}(e)}))}),T=Array.from(E).map((function(e){return{type:"exit",actions:de(f(f([],d(e.onExit),!1),d(e.activities.map((function(e){return function(e){var t=J(e)?e:fe(e);return{type:r.Stop,activity:t,exec:void 0}}(e)}))),!1),v.machine.options.actions)}})).concat({type:"transition",actions:de(n.actions,this.machine.options.actions)}).concat(D);if(t){var R=de(F(f([],d(e),!1).sort((function(e,t){return t.order-e.order})).map((function(e){return e.onExit}))),this.machine.options.actions).filter((function(e){return!se(e)}));return T.concat({type:"stop",actions:R})}return T},e.prototype.transition=function(e,t,n,r){void 0===e&&(e=this.initialState);var i,o,a=te(t);if(e instanceof Pe)i=void 0===n?e:this.resolveState(Pe.from(e,n));else{var s=G(e)?this.resolve(P(this.getResolvedPath(e))):this.resolve(e),c=null!=n?n:this.machine.context;i=this.resolveState(Pe.from(s,c))}if(this.strict&&!this.events.includes(a.name)&&(o=a.name,!/^(done|error)\./.test(o)))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(a.name,"'"));var u=this._transition(i.value,i,a)||{transitions:[],configuration:[],exitSet:[],source:i,actions:[]},l=Oe([],this.getStateNodes(i.value)),p=u.configuration.length?Oe(l,u.configuration):l;return u.configuration=f([],d(p),!1),this.resolveTransition(u,i,i.context,r,a)},e.prototype.resolveRaisedTransition=function(e,t,n,r){var i,o=e.actions;return(e=this.transition(e,t,void 0,r))._event=n,e.event=n.data,(i=e.actions).unshift.apply(i,f([],d(o),!1)),e},e.prototype.resolveTransition=function(e,t,n,r,i){var o,a,s,u,f=this;void 0===i&&(i=ce);var p=e.configuration,g=!t||e.transitions.length>0,y=g?e.configuration:t?t.configuration:[],m=Me(y,this),b=g?Re(this.machine,p):void 0,w=t?t.historyValue?t.historyValue:e.source?this.machine.historyValue(t.value):void 0:void 0,x=this.getActions(new Set(y),m,e,n,i,t,r),I=t?c({},t.activities):{};try{for(var E=l(x),D=E.next();!D.done;D=E.next()){var T=D.value;try{for(var R=(s=void 0,l(T.actions)),A=R.next();!A.done;A=R.next()){var M=A.value;M.type===h?I[M.activity.id||M.activity.type]=M:M.type===v&&(I[M.activity.id||M.activity.type]=!1)}}catch(e){s={error:e}}finally{try{A&&!A.done&&(u=R.return)&&u.call(R)}finally{if(s)throw s.error}}}}catch(e){o={error:e}}finally{try{D&&!D.done&&(a=E.return)&&a.call(E)}finally{if(o)throw o.error}}var _,C,N=d(ye(this,t,n,i,x,r,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),P=N[0],j=N[1],U=d(function(e,t){var n,r,i=d([[],[]],2),o=i[0],a=i[1];try{for(var s=l(e),c=s.next();!c.done;c=s.next()){var u=c.value;t(u)?o.push(u):a.push(u)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return[o,a]}(P,se),2),L=U[0],V=U[1],F=P.filter((function(e){var t;return e.type===h&&(null===(t=e.activity)||void 0===t?void 0:t.type)===k})),H=F.reduce((function(e,t){return e[t.activity.id]=function(e,t,n,r){var i,o=ie(e.src),a=null===(i=null==t?void 0:t.options.services)||void 0===i?void 0:i[o.type],s=e.data?z(e.data,n,r):void 0,c=a?we(a,e.id,s):be(e.id);return c.meta=e,c}(t.activity,f.machine,j,i),e}),t?c({},t.children):{}),B=new Pe({value:b||t.value,context:j,_event:i,_sessionid:t?t._sessionid:null,historyValue:b?w?(_=w,C=b,{current:C,states:K(_,C)}):void 0:t?t.historyValue:void 0,history:!b||e.source?t:void 0,actions:b?V:[],activities:b?I:t?t.activities:{},events:[],configuration:y,transitions:e.transitions,children:H,done:m,tags:_e(y),machine:this}),q=n!==j;B.changed=i.name===O||q;var $=B.history;$&&delete $.history;var W=!m&&(this._transient||p.some((function(e){return e._transient})));if(!(g||W&&i.name!==Ze))return B;var Y=B;if(!m)for(W&&(Y=this.resolveRaisedTransition(Y,{type:S},i,r));L.length;){var J=L.shift();Y=this.resolveRaisedTransition(Y,J._event,i,r)}var G=Y.changed||($?!!Y.actions.length||q||typeof $.value!=typeof Y.value||!Ce(Y.value,$.value):void 0);return Y.changed=G,Y.history=$,Y},e.prototype.getStateNode=function(e){if(nt(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var t=this.states[e];if(!t)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return t},e.prototype.getStateNodeById=function(e){var t=nt(e)?e.slice(1):e;if(t===this.id)return this;var n=this.machine.idMap[t];if(!n)throw new Error("Child state node '#".concat(t,"' does not exist on machine '").concat(this.id,"'"));return n},e.prototype.getStateNodeByPath=function(e){if("string"==typeof e&&nt(e))try{return this.getStateNodeById(e.slice(1))}catch(e){}for(var t=C(e,this.delimiter).slice(),n=this;t.length;){var r=t.shift();if(!r.length)break;n=n.getStateNode(r)}return n},e.prototype.resolve=function(e){var t,n=this;if(!e)return this.initialStateValue||tt;switch(this.type){case"parallel":return j(this.initialStateValue,(function(t,r){return t?n.getStateNode(r).resolve(e[r]||t):tt}));case"compound":if(G(e)){var r=this.getStateNode(e);return"parallel"===r.type||"compound"===r.type?((t={})[e]=r.initialStateValue,t):e}return Object.keys(e).length?j(e,(function(e,t){return e?n.getStateNode(t).resolve(e):tt})):this.initialStateValue||{};default:return e||tt}},e.prototype.getResolvedPath=function(e){if(nt(e)){var t=this.machine.idMap[e.slice(1)];if(!t)throw new Error("Unable to find state node '".concat(e,"'"));return t.path}return C(e,this.delimiter)},Object.defineProperty(e.prototype,"initialStateValue",{get:function(){var e,t;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;if("parallel"===this.type)t=U(this.states,(function(e){return e.initialStateValue||tt}),(function(e){return!("history"===e.type)}));else if(void 0!==this.initial){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));t=xe(this.states[this.initial])?this.initial:((e={})[this.initial]=this.states[this.initial].initialStateValue,e)}else t={};return this.__cache.initialStateValue=t,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),e.prototype.getInitialState=function(e,t){this._init();var n=this.getStateNodes(e);return this.resolveTransition({configuration:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,null!=t?t:this.machine.context,void 0)},Object.defineProperty(e.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){var e;if("history"===this.type){var t=this.config;e=G(t.target)&&nt(t.target)?P(this.machine.getStateNodeById(t.target).path.slice(this.path.length-1)):t.target}return e},enumerable:!1,configurable:!0}),e.prototype.getRelativeStateNodes=function(e,t,n){return void 0===n&&(n=!0),n?"history"===e.type?e.resolveHistory(t):e.initialStateNodes:[e]},Object.defineProperty(e.prototype,"initialStateNodes",{get:function(){var e=this;return xe(this)?[this]:"compound"!==this.type||this.initial?F(V(this.initialStateValue).map((function(t){return e.getFromRelativePath(t)}))):[this]},enumerable:!1,configurable:!0}),e.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var t=d(e),n=t[0],r=t.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(n,"' from node with no states"));var i=this.getStateNode(n);if("history"===i.type)return i.resolveHistory();if(!this.states[n])throw new Error("Child state '".concat(n,"' does not exist on '").concat(this.id,"'"));return this.states[n].getFromRelativePath(r)},e.prototype.historyValue=function(e){if(Object.keys(this.states).length)return{current:e||this.initialStateValue,states:U(this.states,(function(t,n){if(!e)return t.historyValue();var r=G(e)?void 0:e[n];return t.historyValue(r||t.initialStateValue)}),(function(e){return!e.history}))}},e.prototype.resolveHistory=function(e){var t=this;if("history"!==this.type)return[this];var n=this.parent;if(!e){var r=this.target;return r?F(V(r).map((function(e){return n.getFromRelativePath(e)}))):n.initialStateNodes}var i,o,a=(i=n.path,o="states",function(e){var t,n,r=e;try{for(var a=l(i),s=a.next();!s.done;s=a.next()){var c=s.value;r=r[o][c]}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return r})(e).current;return G(a)?[n.getStateNode(a)]:F(V(a).map((function(e){return"deep"===t.history?n.getFromRelativePath(e):[n.states[e[0]]]})))},Object.defineProperty(e.prototype,"stateIds",{get:function(){var e=this,t=F(Object.keys(this.states).map((function(t){return e.states[t].stateIds})));return[this.id].concat(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"events",{get:function(){var e,t,n,r;if(this.__cache.events)return this.__cache.events;var i=this.states,o=new Set(this.ownEvents);if(i)try{for(var a=l(Object.keys(i)),s=a.next();!s.done;s=a.next()){var c=i[s.value];if(c.states)try{for(var u=(n=void 0,l(c.events)),d=u.next();!d.done;d=u.next()){var f=d.value;o.add("".concat(f))}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(o)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter((function(e){return!(!e.target&&!e.actions.length&&e.internal)})).map((function(e){return e.eventType})));return Array.from(e)},enumerable:!1,configurable:!0}),e.prototype.resolveTarget=function(e){var t=this;if(void 0!==e)return e.map((function(e){if(!G(e))return e;var n=e[0]===t.delimiter;if(n&&!t.parent)return t.getStateNodeByPath(e.slice(1));var r=n?t.key+e:e;if(!t.parent)return t.getStateNodeByPath(r);try{return t.parent.getStateNodeByPath(r)}catch(e){throw new Error("Invalid transition definition for state node '".concat(t.id,"':\n").concat(e.message))}}))},e.prototype.formatTransition=function(e){var t=this,n=function(e){if(void 0!==e&&""!==e)return B(e)}(e.target),r="internal"in e?e.internal:!n||n.some((function(e){return G(e)&&e[0]===t.delimiter})),i=this.machine.options.guards,o=this.resolveTarget(n),a=c(c({},e),{actions:de(B(e.actions)),cond:Q(e.cond,i),target:o,source:this,internal:r,eventType:e.event,toJSON:function(){return c(c({},a),{target:a.target?a.target.map((function(e){return"#".concat(e.id)})):void 0,source:"#".concat(t.id)})}});return a},e.prototype.formatTransitions=function(){var e,t,n,r=this;if(this.config.on)if(Array.isArray(this.config.on))n=this.config.on;else{var i=this.config.on,o=et,a=i[o],s=void 0===a?[]:a,c=u(i,["*"]);n=F(Object.keys(c).map((function(e){var t=ne(e,c[e]);return t})).concat(ne(et,s)))}else n=[];var p=this.config.always?ne("",this.config.always):[],h=this.config.onDone?ne(String(he(this.id)),this.config.onDone):[];var v=F(this.invoke.map((function(e){var t=[];return e.onDone&&t.push.apply(t,f([],d(ne(String(ve(e.id)),e.onDone)),!1)),e.onError&&t.push.apply(t,f([],d(ne(String(ge(e.id)),e.onError)),!1)),t}))),g=this.after,y=F(f(f(f(f([],d(h),!1),d(v),!1),d(n),!1),d(p),!1).map((function(e){return B(e).map((function(e){return r.formatTransition(e)}))})));try{for(var m=l(g),S=m.next();!S.done;S=m.next()){var b=S.value;y.push(b)}}catch(t){e={error:t}}finally{try{S&&!S.done&&(t=m.return)&&t.call(m)}finally{if(e)throw e.error}}return y},e}();var it=function(e){return{type:b,assignment:e}},ot=n(100),at=o.useLayoutEffect;function st(e){var t=o.useRef();return t.current||(t.current={v:e()}),t.current.v}var ct=function(){return ct=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ct.apply(this,arguments)},ut=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n};function lt(e,t){var n=st((function(){return"function"==typeof e?e():e})),r=t.context,i=t.guards,o=t.actions,a=t.activities,s=t.services,c=t.delays,u=(t.state,ut(t,["context","guards","actions","activities","services","delays","state"])),l=st((function(){var e={context:r,guards:i,actions:o,activities:a,services:s,delays:c};return Ge(n.withConfig(e,(function(){return ct(ct({},n.context),r)})),u)}));return at((function(){Object.assign(l.machine.options.actions,o),Object.assign(l.machine.options.guards,i),Object.assign(l.machine.options.activities,a),Object.assign(l.machine.options.services,s),Object.assign(l.machine.options.delays,c)}),[o,i,a,s,c]),l}var dt=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a};function ft(e){return e}function pt(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=dt(t,1)[0],i=void 0===r?{}:r,a=lt(e,i),s=(0,o.useCallback)((function(){return a.status===We.NotStarted?i.state?Pe.create(i.state):a.machine.initialState:a.getSnapshot()}),[a]),c=(0,o.useCallback)((function(e,t){return function(e,t,n){if(e.status===We.NotStarted)return!0;var r=void 0===n.changed&&(Object.keys(n.children).length>0||"boolean"==typeof t.changed);return!(n.changed||r)}(a,e,t)}),[a]),u=(0,o.useCallback)((function(e){return a.subscribe(e).unsubscribe}),[a]),l=(0,ot.useSyncExternalStoreWithSelector)(u,s,s,ft,c);return(0,o.useEffect)((function(){var e=i.state;return a.start(e?Pe.create(e):void 0),function(){a.stop(),a.status=We.NotStarted}}),[]),[l,a.send,a]}var ht=n(55);const vt=-1,gt=0,yt=1,mt=2,St=3,bt=4,wt=5,xt={id:"measurementTracking",initial:"idle",context:{activeViewportId:null,trackedStudy:"",trackedSeries:[],ignoredSeries:[],prevTrackedStudy:"",prevTrackedSeries:[],prevIgnoredSeries:[],ignoredSRSeriesForHydration:[],isDirty:!1},states:{off:{type:"final"},labellingOnly:{on:{TRACK_SERIES:[{target:"promptLabelAnnotation",actions:["setPreviousState"]},{target:"off"}]}},idle:{entry:"clearContext",on:{TRACK_SERIES:[{target:"promptLabelAnnotation",cond:"isLabelOnMeasure",actions:["setPreviousState"]},{target:"promptBeginTracking",actions:["setPreviousState"]}],SET_TRACKED_SERIES:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries","setIsDirtyToClean"]}],PROMPT_HYDRATE_SR:{target:"promptHydrateStructuredReport",cond:"hasNotIgnoredSRSeriesForHydration"},RESTORE_PROMPT_HYDRATE_SR:"promptHydrateStructuredReport",HYDRATE_SR:"hydrateStructuredReport",UPDATE_ACTIVE_VIEWPORT_ID:{actions:it({activeViewportId:(e,t)=>t.activeViewportId})}}},promptBeginTracking:{invoke:{src:"promptBeginTracking",onDone:[{target:"tracking",actions:["setTrackedStudyAndSeries","setIsDirty"],cond:"shouldSetStudyAndSeries"},{target:"labellingOnly",cond:"isLabelOnMeasureAndShouldKillMachine"},{target:"off",cond:"shouldKillMachine"},{target:"idle"}],onError:{target:"idle"}}},tracking:{on:{TRACK_SERIES:[{target:"promptLabelAnnotation",cond:"isLabelOnMeasure",actions:["setPreviousState"]},{target:"promptTrackNewStudy",cond:"isNewStudy"},{target:"promptTrackNewSeries",cond:"isNewSeries"}],UNTRACK_SERIES:[{target:"tracking",actions:["removeTrackedSeries","setIsDirty","clearDisplaySetHydratedState"],cond:"hasRemainingTrackedSeries"},{target:"idle"}],UNTRACK_ALL:[{target:"tracking",actions:["clearContext","setIsDirtyToClean","clearDisplaySetHydratedState","clearAllMeasurements"]},{target:"idle"}],SET_TRACKED_SERIES:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries"]}],SAVE_REPORT:"promptSaveReport",SET_DIRTY:[{target:"tracking",actions:["setIsDirty"],cond:"shouldSetDirty"},{target:"tracking"}],CHECK_DIRTY:{target:"promptHasDirtyAnnotations",cond:"hasDirtyAndSimplified"},PROMPT_HYDRATE_SR:{target:"promptHydrateStructuredReport",cond:"isSimplifiedConfig",actions:["clearAllMeasurements","clearDisplaySetHydratedState"]}}},promptTrackNewSeries:{invoke:{src:"promptTrackNewSeries",onDone:[{target:"tracking",actions:["addTrackedSeries","setIsDirty"],cond:"shouldAddSeries"},{target:"tracking",actions:["discardPreviouslyTrackedMeasurements","setTrackedStudyAndSeries","setIsDirty"],cond:"shouldSetStudyAndSeries"},{target:"promptSaveReport",cond:"shouldPromptSaveReport"},{target:"tracking"}],onError:{target:"idle"}}},promptTrackNewStudy:{invoke:{src:"promptTrackNewStudy",onDone:[{target:"tracking",actions:["discardPreviouslyTrackedMeasurements","setTrackedStudyAndSeries","setIsDirty"],cond:"shouldSetStudyAndSeries"},{target:"tracking",actions:["ignoreSeries"],cond:"shouldAddIgnoredSeries"},{target:"promptSaveReport",cond:"shouldPromptSaveReport"},{target:"tracking"}],onError:{target:"idle"}}},promptSaveReport:{invoke:{src:"promptSaveReport",onDone:[{target:"tracking",actions:["clearAllMeasurements","clearDisplaySetHydratedState","setIsDirty","updatedViewports"],cond:"simplifiedAndLoadSR"},{target:"idle",actions:["clearAllMeasurements","showStructuredReportDisplaySetInActiveViewport"],cond:"shouldSaveAndContinueWithSameReport"},{target:"tracking",actions:["discardPreviouslyTrackedMeasurements","setTrackedStudyAndSeries"],cond:"shouldSaveAndStartNewReport"},{target:"tracking"}],onError:{target:"idle"}}},promptHydrateStructuredReport:{invoke:{src:"promptHydrateStructuredReport",onDone:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries","jumpToSameImageInActiveViewport","setIsDirtyToClean"],cond:"shouldHydrateStructuredReport"},{target:"idle",actions:["ignoreHydrationForSRSeries"],cond:"shouldIgnoreHydrationForSR"}],onError:{target:"idle"}}},hydrateStructuredReport:{invoke:{src:"hydrateStructuredReport",onDone:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries","jumpToSameImageInActiveViewport","setIsDirtyToClean"]}],onError:{target:"idle"}}},promptLabelAnnotation:{invoke:{src:"promptLabelAnnotation",onDone:[{target:"labellingOnly",cond:"wasLabellingOnly"},{target:"promptBeginTracking",cond:"wasIdle"},{target:"promptTrackNewStudy",cond:"wasTrackingAndIsNewStudy"},{target:"promptTrackNewSeries",cond:"wasTrackingAndIsNewSeries"},{target:"tracking",cond:"wasTracking"},{target:"off"}]}},promptHasDirtyAnnotations:{invoke:{src:"promptHasDirtyAnnotations",onDone:[{target:"tracking",actions:["clearAllMeasurements","clearDisplaySetHydratedState","setIsDirty","updatedViewports"],cond:"shouldSetStudyAndSeries"},{target:"promptSaveReport",cond:"shouldPromptSaveReport"},{target:"tracking"}]}}},strict:!0},kt={services:{promptBeginTracking:(e,t)=>{},promptTrackNewStudy:(e,t)=>{},promptTrackNewSeries:(e,t)=>{}},actions:{discardPreviouslyTrackedMeasurements:(e,t)=>{console.log("discardPreviouslyTrackedMeasurements: not implemented")},clearAllMeasurements:(e,t)=>{console.log("clearAllMeasurements: not implemented")},jumpToFirstMeasurementInActiveViewport:(e,t)=>{console.warn("jumpToFirstMeasurementInActiveViewport: not implemented")},showStructuredReportDisplaySetInActiveViewport:(e,t)=>{console.warn("showStructuredReportDisplaySetInActiveViewport: not implemented")},clearContext:it({trackedStudy:"",trackedSeries:[],ignoredSeries:[],prevTrackedStudy:"",prevTrackedSeries:[],prevIgnoredSeries:[]}),setTrackedStudyAndSeries:it(((e,t)=>({prevTrackedStudy:e.trackedStudy,prevTrackedSeries:e.trackedSeries.slice(),prevIgnoredSeries:e.ignoredSeries.slice(),trackedStudy:t.data.StudyInstanceUID,trackedSeries:[t.data.SeriesInstanceUID],ignoredSeries:[]}))),setTrackedStudyAndMultipleSeries:it(((e,t)=>{const n=t.StudyInstanceUID||t.data.StudyInstanceUID,r=t.SeriesInstanceUIDs||t.data.SeriesInstanceUIDs;return{prevTrackedStudy:e.trackedStudy,prevTrackedSeries:e.trackedSeries.slice(),prevIgnoredSeries:e.ignoredSeries.slice(),trackedStudy:n,trackedSeries:[...e.trackedSeries,...r],ignoredSeries:[]}})),setIsDirtyToClean:it(((e,t)=>({isDirty:!1}))),setIsDirty:it(((e,t)=>({isDirty:!0}))),ignoreSeries:it(((e,t)=>({prevIgnoredSeries:[...e.ignoredSeries],ignoredSeries:[...e.ignoredSeries,t.data.SeriesInstanceUID]}))),ignoreHydrationForSRSeries:it(((e,t)=>({ignoredSRSeriesForHydration:[...e.ignoredSRSeriesForHydration,t.data.srSeriesInstanceUID]}))),addTrackedSeries:it(((e,t)=>({prevTrackedSeries:[...e.trackedSeries],trackedSeries:[...e.trackedSeries,t.data.SeriesInstanceUID]}))),removeTrackedSeries:it(((e,t)=>({prevTrackedSeries:e.trackedSeries.slice().filter((e=>e!==t.SeriesInstanceUID)),trackedSeries:e.trackedSeries.slice().filter((e=>e!==t.SeriesInstanceUID))}))),setPreviousState:it(((e,t,n)=>({prevState:n.state.value})))},guards:{shouldSetDirty:(e,t)=>void 0===t.SeriesInstanceUID||e.trackedSeries.includes(t.SeriesInstanceUID),wasLabellingOnly:(e,t,n)=>"labellingOnly"===e.prevState,wasIdle:(e,t,n)=>"idle"===e.prevState,wasTracking:(e,t,n)=>"tracking"===e.prevState,wasTrackingAndIsNewStudy:(e,t,n)=>"tracking"===e.prevState&&!e.ignoredSeries.includes(t.data.SeriesInstanceUID)&&e.trackedStudy!==t.data.StudyInstanceUID,wasTrackingAndIsNewSeries:(e,t,n)=>"tracking"===e.prevState&&!e.ignoredSeries.includes(t.data.SeriesInstanceUID)&&!e.trackedSeries.includes(t.data.SeriesInstanceUID),shouldKillMachine:(e,t)=>t.data&&t.data.userResponse===vt,shouldAddSeries:(e,t)=>t.data&&t.data.userResponse===mt,shouldSetStudyAndSeries:(e,t)=>t.data&&t.data.userResponse===St,shouldAddIgnoredSeries:(e,t)=>t.data&&t.data.userResponse===bt,shouldPromptSaveReport:(e,t)=>t.data&&t.data.userResponse===yt,shouldIgnoreHydrationForSR:(e,t)=>t.data&&t.data.userResponse===gt,shouldSaveAndContinueWithSameReport:(e,t)=>t.data&&t.data.userResponse===yt&&!0===t.data.isBackupSave,shouldSaveAndStartNewReport:(e,t)=>t.data&&t.data.userResponse===yt&&!1===t.data.isBackupSave,shouldHydrateStructuredReport:(e,t)=>t.data&&t.data.userResponse===wt,hasRemainingTrackedSeries:(e,t)=>e.trackedSeries.length>1||!e.trackedSeries.includes(t.SeriesInstanceUID),hasNotIgnoredSRSeriesForHydration:(e,t)=>!e.ignoredSRSeriesForHydration.includes(t.SeriesInstanceUID),isNewStudy:(e,t)=>!e.ignoredSeries.includes(t.SeriesInstanceUID)&&e.trackedStudy!==t.StudyInstanceUID,isNewSeries:(e,t)=>!e.ignoredSeries.includes(t.SeriesInstanceUID)&&!e.trackedSeries.includes(t.SeriesInstanceUID)}};var It=n(123),Et=n(838);const Ot=function({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},i,o){const{displaySetService:a}=e.services,{viewportId:s,displaySetInstanceUID:c}=o,u=a.getDisplaySetByUID(c);return new Promise(((i,a)=>{const l=(0,Et.hydrateStructuredReport)({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},c),d=l.StudyInstanceUID,f=l.SeriesInstanceUIDs;i({displaySetInstanceUID:o.displaySetInstanceUID,srSeriesInstanceUID:u.SeriesInstanceUID,viewportId:s,StudyInstanceUID:d,SeriesInstanceUIDs:f})}))},Dt=(0,o.createContext)(null),{Provider:Tt}=Dt;function Rt({children:e,value:t}){const[n,r]=(0,o.useState)(t);return o.createElement(Tt,{value:[n,r]},e)}Rt.propTypes={children:s().any,value:s().any};const At=({servicesManager:e,extensionManager:t},n,r)=>{const{customizationService:i}=e.services;return i.getCustomization("measurement.promptBeginTracking")({servicesManager:e,extensionManager:t},n,r)},Mt=({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},i,o)=>{const{customizationService:a}=e.services;return a.getCustomization("measurement.promptHydrateStructuredReport")({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},i,o)},_t=({servicesManager:e,extensionManager:t},n,r)=>{const{customizationService:i}=e.services;return i.getCustomization("measurement.promptTrackNewSeries")({servicesManager:e,extensionManager:t},n,r)},Ct=({servicesManager:e,extensionManager:t},n,r)=>{const{customizationService:i}=e.services;return i.getCustomization("measurement.promptTrackNewStudy")({servicesManager:e,extensionManager:t},n,r)},Nt=({servicesManager:e},t,n)=>{const{customizationService:r}=e.services;return r.getCustomization("measurement.promptLabelAnnotation")({servicesManager:e},t,n)},Pt=({servicesManager:e,commandsManager:t,extensionManager:n},r,i)=>{const{customizationService:o}=e.services;return o.getCustomization("measurement.promptSaveReport")({servicesManager:e,commandsManager:t,extensionManager:n},r,i)},jt=({servicesManager:e,commandsManager:t,extensionManager:n},r,i)=>{const{customizationService:o}=e.services;return o.getCustomization("measurement.promptHasDirtyAnnotations")({servicesManager:e,commandsManager:t,extensionManager:n},r,i)},Ut=o.createContext();Ut.displayName="TrackedMeasurementsContext";const Lt=()=>(0,o.useContext)(Ut),Vt="@ohif/extension-cornerstone-dicom-sr.sopClassHandlerModule.dicom-sr";function Ft({servicesManager:e,commandsManager:t,extensionManager:n},{children:r}){const[i]=(0,o.useContext)(Dt),[a,s]=(0,ht.useViewportGrid)(),{activeViewportId:c,viewports:u}=a,{measurementService:l,displaySetService:d,customizationService:f}=e.services,p=Object.assign({},kt);p.actions=Object.assign({},p.actions,{jumpToFirstMeasurementInActiveViewport:(e,t)=>{const{trackedStudy:n,trackedSeries:r}=e,{viewportId:i}=t.data,o=l.getMeasurements().filter((e=>n===e.referenceStudyUID&&r.includes(e.referenceSeriesUID)));console.log("jumping to measurement reset viewport",i,o[0]);const a=o[0].displaySetInstanceUID,c=d.getDisplaySetByUID(a).images,u=c[0].imageId.startsWith("volumeId"),f=o[0].data;let p=0;!u&&f&&(p=c.findIndex((e=>{const t=Object.keys(f)[0].substring(8);return e.imageId===t})),-1===p&&(console.warn("Could not find image index for tracked measurement, using 0"),p=0)),s.setDisplaySetsForViewport({viewportId:i,displaySetInstanceUIDs:[a],viewportOptions:{initialImageOptions:{index:p}}})},jumpToSameImageInActiveViewport:(e,n)=>{const{trackedStudy:r,trackedSeries:i}=e,{viewportId:o}=n.data,a=l.getMeasurements(),c=a.filter((e=>r===e.referenceStudyUID&&i.includes(e.referenceSeriesUID)));if(!c?.length)return void console.warn("Didn't find any tracked measurements",a,r,i);const u=c[c.length-1],d=u.displaySetInstanceUID;t.runCommand("updateStoredPositionPresentation",{viewportId:o,displaySetInstanceUID:d,referencedImageId:u.referencedImageId}),s.setDisplaySetsForViewport({viewportId:o,displaySetInstanceUIDs:[d]})},showStructuredReportDisplaySetInActiveViewport:(e,t)=>{if(t.data.createdDisplaySetInstanceUIDs.length>0){const e=t.data.createdDisplaySetInstanceUIDs[0];s.setDisplaySetsForViewport({viewportId:t.data.viewportId,displaySetInstanceUIDs:[e]})}},discardPreviouslyTrackedMeasurements:(e,t)=>{const n=l.getMeasurements().filter((t=>e.prevTrackedSeries.includes(t.referenceSeriesUID))).map((e=>e.id));for(let e=0;e<n.length;e++)l.remove(n[e])},clearAllMeasurements:(e,t)=>{const n=l.getMeasurements().map((e=>e.uid));for(let e=0;e<n.length;e++)l.remove(n[e]);l.setIsMeasurementDeletedIndividually(!1)},clearDisplaySetHydratedState:(e,t)=>{const{displaySetInstanceUID:n}=t.data??t,r=d.getActiveDisplaySets();r?.forEach((e=>{"SR"===e.Modality&&e.displaySetInstanceUID!==n&&e.isHydrated&&(e.isHydrated=!1,e.isLoaded=!1)}))},updatedViewports:(t,n)=>{const{hangingProtocolService:r}=e.services,{displaySetInstanceUID:i,viewportId:o}=n.data??n,a=r.getViewportsRequireUpdate(o,i);s.setDisplaySetsForViewports(a)}}),p.services=Object.assign({},p.services,{promptBeginTracking:At.bind(null,{servicesManager:e,extensionManager:n,appConfig:i}),promptTrackNewSeries:_t.bind(null,{servicesManager:e,extensionManager:n,appConfig:i}),promptTrackNewStudy:Ct.bind(null,{servicesManager:e,extensionManager:n,appConfig:i}),promptSaveReport:Pt.bind(null,{servicesManager:e,commandsManager:t,extensionManager:n,appConfig:i}),promptHydrateStructuredReport:Mt.bind(null,{servicesManager:e,extensionManager:n,commandsManager:t,appConfig:i}),promptHasDirtyAnnotations:jt.bind(null,{servicesManager:e,extensionManager:n,commandsManager:t,appConfig:i}),hydrateStructuredReport:Ot.bind(null,{servicesManager:e,extensionManager:n,commandsManager:t,appConfig:i}),promptLabelAnnotation:Nt.bind(null,{servicesManager:e,extensionManager:n,commandsManager:t})}),p.guards=Object.assign({},p.guards,{isLabelOnMeasure:(e,t,n)=>{const r=f.getCustomization("measurementLabels");return r?.labelOnMeasure},isLabelOnMeasureAndShouldKillMachine:(e,t,n)=>{const r=f.getCustomization("measurementLabels");return t.data&&t.data.userResponse===vt&&r?.labelOnMeasure},isSimplifiedConfig:(e,t,n)=>i?.measurementTrackingMode===It.v.SIMPLIFIED,simplifiedAndLoadSR:(e,t,n)=>i?.measurementTrackingMode===It.v.SIMPLIFIED&&!1===t.data.isBackupSave,hasDirtyAndSimplified:(e,t,n)=>{const r=l.getMeasurements(),o=r.some((e=>e.isDirty))||r.length&&l.getIsMeasurementDeletedIndividually();return i?.measurementTrackingMode===It.v.SIMPLIFIED&&o}});const h=(0,o.useMemo)((()=>{return e=xt,t=p,void 0===n&&(n=e.context),new rt(e,t,n);var e,t,n}),[]),[v,g]=pt(h);return(0,o.useEffect)((()=>{g("UPDATE_ACTIVE_VIEWPORT_ID",{activeViewportId:c})}),[c,g]),(0,o.useEffect)((()=>{(async()=>{if(u.size>0){const t=u.get(c);if(!t||!t?.displaySetInstanceUIDs?.length)return;const{displaySetService:n}=e.services,r=n.getDisplaySetByUID(t.displaySetInstanceUIDs[0]);if(!r)return;if(r.SOPClassHandlerId===Vt&&!r.isLoaded&&r.load&&await r.load(),r.SOPClassHandlerId===Vt&&!0===r.isRehydratable&&!r.isHydrated){const e={displaySetInstanceUID:r.displaySetInstanceUID,SeriesInstanceUID:r.SeriesInstanceUID,viewportId:c},t=i?.disableConfirmationPrompts;g(t?"HYDRATE_SR":"PROMPT_HYDRATE_SR",e)}}})()}),[v,c,g,e.services,u,i]),(0,o.useEffect)((()=>{t.registerCommand("DEFAULT","loadTrackedSRMeasurements",{commandFn:e=>g("HYDRATE_SR",e)})}),[t,g]),o.createElement(Ut.Provider,{value:[v,g]},r)}Ft.propTypes={children:s().oneOf([s().func,s().node]),appConfig:s().object};const Ht=function({servicesManager:e,extensionManager:t,commandsManager:n}){const r=Ft.bind(null,{servicesManager:e,extensionManager:t,commandsManager:n});return[{name:"TrackedMeasurementsContext",context:Ut,provider:r}]}},132:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>N});var r=n(326),i=n(598),o=n.n(i),a=n(55),s=n(713),c=n(440),u=n(557),l=n(111);var d=n(224);n(741);Object.create(null);function f(){if(console&&console.warn){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];"string"==typeof n[0]&&(n[0]="react-i18next:: ".concat(n[0])),(e=console).warn.apply(e,n)}}var p={};function h(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&p[t[0]]||("string"==typeof t[0]&&(p[t[0]]=new Date),f.apply(void 0,t))}var v=function(e,t){return function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}};function g(e,t,n){e.loadNamespaces(t,v(e,n))}function y(e,t,n,r){"string"==typeof n&&(n=[n]),n.forEach((function(t){e.options.ns.indexOf(t)<0&&e.options.ns.push(t)})),e.loadLanguages(t,v(e,r))}var m=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,S={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},b=function(e){return S[e]};var w,x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:function(e){return e.replace(m,b)}};var k=n(561),I=n(1);var E=(0,r.createContext)(),O=function(){function e(){(0,k.A)(this,e),this.usedNamespaces={}}return(0,I.A)(e,[{key:"addUsedNamespaces",value:function(e){var t=this;e.forEach((function(e){t.usedNamespaces[e]||(t.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}]),e}();var D=n(730);function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){(0,l.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function A(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.i18n,i=(0,r.useContext)(E)||{},o=i.i18n,a=i.defaultNS,s=n||o||w;if(s&&!s.reportNamespaces&&(s.reportNamespaces=new O),!s){h("You will need to pass in an i18next instance by using initReactI18next");var c=function(e,t){return"string"==typeof t?t:t&&"object"===(0,d.A)(t)&&"string"==typeof t.defaultValue?t.defaultValue:Array.isArray(e)?e[e.length-1]:e},u=[c,{},!1];return u.t=c,u.i18n={},u.ready=!1,u}s.options.react&&void 0!==s.options.react.wait&&h("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var l=R(R(R({},x),s.options.react),t),f=l.useSuspense,p=l.keyPrefix,v=e||a||s.options&&s.options.defaultNS;v="string"==typeof v?[v]:v||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(v);var m=(s.isInitialized||s.initializedStoreOnce)&&v.every((function(e){return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.languages&&t.languages.length?void 0!==t.options.ignoreJSONStructure?t.hasLoadedNamespace(e,{lng:n.lng,precheck:function(t,r){if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}):function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=t.languages[0],i=!!t.options&&t.options.fallbackLng,o=t.languages[t.languages.length-1];if("cimode"===r.toLowerCase())return!0;var a=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===r||2===r};return!(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)||!t.hasResourceBundle(r,e)&&t.services.backendConnector.backend&&(!t.options.resources||t.options.partialBundledLanguages)&&(!a(r,e)||i&&!a(o,e)))}(e,t,n):(h("i18n.languages were undefined or empty",t.languages),!0)}(e,s,l)}));function S(){return s.getFixedT(t.lng||null,"fallback"===l.nsMode?v:v[0],p)}var b=(0,r.useState)(S),k=(0,D.A)(b,2),I=k[0],T=k[1],A=v.join();t.lng&&(A="".concat(t.lng).concat(A));var M,_,C,N=(M=A,C=(0,r.useRef)(),(0,r.useEffect)((function(){C.current=_?C.current:M}),[M,_]),C.current),P=(0,r.useRef)(!0);(0,r.useEffect)((function(){var e=l.bindI18n,n=l.bindI18nStore;function r(){P.current&&T(S)}return P.current=!0,m||f||(t.lng?y(s,t.lng,v,(function(){P.current&&T(S)})):g(s,v,(function(){P.current&&T(S)}))),m&&N&&N!==A&&P.current&&T(S),e&&s&&s.on(e,r),n&&s&&s.store.on(n,r),function(){P.current=!1,e&&s&&e.split(" ").forEach((function(e){return s.off(e,r)})),n&&s&&n.split(" ").forEach((function(e){return s.store.off(e,r)}))}}),[s,A]);var j=(0,r.useRef)(!0);(0,r.useEffect)((function(){P.current&&!j.current&&T(S),j.current=!1}),[s,p]);var U=[I,s,m];if(U.t=I,U.i18n=s,U.ready=m,m)return U;if(!m&&!f)return U;throw new Promise((function(e){t.lng?y(s,t.lng,v,(function(){return e()})):g(s,v,(function(){return e()}))}))}function M(){return M=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},M.apply(null,arguments)}function _(e){const{displaySets:t,viewportId:n,servicesManager:i,extensionManager:o}=e,{measurementService:l,cornerstoneViewportService:d,viewportGridService:f,viewportActionCornersService:p}=i.services,h=t[0],{t:v}=A("Common"),[g]=(0,a.useViewportGrid)(),{activeViewportId:y}=g,[m,S]=(0,c.B)(),[b,w]=(0,r.useState)(!1),[x,k]=(0,r.useState)(null),[I,E]=(0,r.useState)(null),{trackedSeries:O}=m.context,{SeriesInstanceUID:D}=h,T=(0,r.useCallback)((()=>{const e=d.getCornerstoneViewport(n);if(e instanceof u.BaseVolumeViewport){const t=e?.getCurrentImageId();if(!t)return void(b&&w(!1))}O.includes(D)!==b&&w(!b)}),[b,m,n,D]),R=(0,r.useCallback)((e=>{e.detail.element!==I&&(e.detail.element?.addEventListener(u.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,T),E(e.detail.element))}),[T,I]),_=(0,r.useCallback)((()=>{I?.removeEventListener(u.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,T)}),[T,I]);(0,r.useEffect)(T,[T]),(0,r.useEffect)((()=>{const{unsubscribe:e}=d.subscribe(d.EVENTS.VIEWPORT_DATA_CHANGED,(e=>{e.viewportId===n&&T()}));return()=>{e()}}),[T,n]),(0,r.useEffect)((()=>b?(s.annotation.config.style.setViewportToolStyles(n,{ReferenceLines:{lineDash:"4,4"},global:{lineDash:""}}),void d.getRenderingEngine().renderViewport(n)):(s.annotation.config.style.setViewportToolStyles(n,{global:{lineDash:"4,4"}}),d.getRenderingEngine().renderViewport(n),()=>{s.annotation.config.style.setViewportToolStyles(n,{})})),[b]),(0,r.useEffect)((()=>{const e=l.EVENTS.MEASUREMENT_ADDED,t=l.EVENTS.RAW_MEASUREMENT_ADDED,r=[];return[e,t].forEach((e=>{r.push(l.subscribe(e,(({source:e,measurement:t})=>{const{activeViewportId:r}=f.getState();if(n===r){const{referenceStudyUID:e,referenceSeriesUID:r,uid:i,toolName:o}=t;S("SET_DIRTY",{SeriesInstanceUID:r}),S("TRACK_SERIES",{viewportId:n,StudyInstanceUID:e,SeriesInstanceUID:r,measurementId:i,toolName:o})}})).unsubscribe)})),()=>{r.forEach((e=>{e()}))}}),[l,S,n,f]);const N=(0,r.useCallback)((e=>{const t=function(e,t,n,r){const{measurementService:i,viewportGridService:o}=t.services,a=i.getMeasurements(),{activeViewportId:s,viewports:c}=o.getState(),{displaySetInstanceUIDs:u}=c.get(s),{trackedSeries:l}=r.context,d=a.filter((e=>l.includes(e.referenceSeriesUID)&&u.includes(e.displaySetInstanceUID)));if(!d.length)return;const f=d.length,p=d.map((e=>e.uid));let h=p.findIndex((e=>e===n));-1===h?h=0:(h+=e,h<0?h=f-1:h===f&&(h=0));return p[h]}(e,i,x,m);t&&(k(t),l.jumpToMeasurement(n,t))}),[l,i,x,m,n]);(0,r.useEffect)((()=>{const e=function(e,t){if(!e)return null;return r.createElement(a.Tooltip,null,r.createElement(a.TooltipTrigger,{asChild:!0},r.createElement("span",null,r.createElement(a.Icons.StatusTracking,{className:"text-muted-foreground mt-0.5 ml-0.5"}))),r.createElement(a.TooltipContent,{align:"start",side:"bottom"},e?r.createElement(r.Fragment,null,t("Series is tracked and can be viewed in the measurement panel")):r.createElement(r.Fragment,null,t("Measurements for untracked series will not be shown in the measurements panel"))))}(b,v),t=C(b,N,n===y);p.addComponents([{viewportId:n,id:"viewportStatusComponent",component:e,indexPriority:-100,location:p.LOCATIONS.topLeft},{viewportId:n,id:"viewportActionArrowsComponent",component:t,indexPriority:0,location:p.LOCATIONS.topRight}])}),[y,b,N,p,n]);return r.createElement("div",{className:"relative flex h-full w-full flex-row overflow-hidden"},(()=>{const{component:t}=o.getModuleEntry("@ohif/extension-cornerstone.viewportModule.cornerstone");return r.createElement(t,M({},e,{onElementEnabled:t=>{e.onElementEnabled?.(t),R(t)},onElementDisabled:_}))})())}_.propTypes={displaySets:o().arrayOf(o().object.isRequired).isRequired,viewportId:o().string.isRequired,dataSource:o().object,children:o().node};const C=(e,t,n)=>e?r.createElement(a.ViewportActionArrows,{onArrowsClick:e=>t(e),className:n?"visible":"invisible group-hover/pane:visible"}):null;const N=_},228:(e,t,n)=>{"use strict";n.d(t,{A:()=>B});var r=n(224),i=n(111);function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?Object(arguments[t]):{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach((function(t){(0,i.A)(e,t,n[t])}))}return e}var a=n(561),s=n(1);function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){if(t&&("object"==(0,r.A)(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}var p=n(85);var h=n(492);function v(e){return function(e){if(Array.isArray(e))return(0,p.A)(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||(0,h.A)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var g=n(730),y={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){var n;console&&console[e]&&(n=console)[e].apply(n,v(t))}},m=new(function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,a.A)(this,e),this.init(t,n)}return(0,s.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||y,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,r){return r&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,o({},{prefix:"".concat(this.prefix,":").concat(t,":")},this.options))}}]),e}()),S=function(){function e(){(0,a.A)(this,e),this.observers={}}return(0,s.A)(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach((function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==t})):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.observers[e]&&[].concat(this.observers[e]).forEach((function(e){e.apply(void 0,n)}));this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(n))}))}}]),e}();function b(){var e,t,n=new Promise((function(n,r){e=n,t=r}));return n.resolve=e,n.reject=t,n}function w(e){return null==e?"":""+e}function x(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var o="string"!=typeof t?[].concat(t):t.split(".");o.length>1;){if(i())return{};var a=r(o.shift());!e[a]&&n&&(e[a]=new n),e=e[a]}return i()?{}:{obj:e,k:r(o.shift())}}function k(e,t,n){var r=x(e,t,Object);r.obj[r.k]=n}function I(e,t){var n=x(e,t),r=n.obj,i=n.k;if(r)return r[i]}function E(e,t,n){var r=I(e,n);return void 0!==r?r:I(t,n)}function O(e,t,n){for(var r in t)r in e?"string"==typeof e[r]||e[r]instanceof String||"string"==typeof t[r]||t[r]instanceof String?n&&(e[r]=t[r]):O(e[r],t[r],n):e[r]=t[r];return e}function D(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var T={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function R(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return T[e]})):e}var A=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return(0,a.A)(this,t),n=u(this,l(t).call(this)),S.call(c(n)),n.data=e||{},n.options=r,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n}return f(t,e),(0,s.A)(t,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,o=[e,t];return n&&"string"!=typeof n&&(o=o.concat(n)),n&&"string"==typeof n&&(o=o.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(o=e.split(".")),I(this.data,o)}},{key:"addResource",value:function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},o=this.options.keySeparator;void 0===o&&(o=".");var a=[e,t];n&&(a=a.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(r=t,t=(a=e.split("."))[1]),this.addNamespaces(t),k(this.data,a,r),i.silent||this.emit("added",e,t,n,r)}},{key:"addResources",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in n)"string"!=typeof n[i]&&"[object Array]"!==Object.prototype.toString.apply(n[i])||this.addResource(e,t,i,n[i],{silent:!0});r.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,r,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},s=[e,t];e.indexOf(".")>-1&&(r=n,n=t,t=(s=e.split("."))[1]),this.addNamespaces(t);var c=I(this.data,s)||{};r?O(c,n,i):c=o({},c,n),k(this.data,s,c),a.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?o({},{},this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"toJSON",value:function(){return this.data}}]),t}(S),M={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,r,i){var o=this;return e.forEach((function(e){o.processors[e]&&(t=o.processors[e].process(t,n,r,i))})),t}},_=function(e){function t(e){var n,r,i,o,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,a.A)(this,t),n=u(this,l(t).call(this)),S.call(c(n)),r=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],i=e,o=c(n),r.forEach((function(e){i[e]&&(o[e]=i[e])})),n.options=s,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=m.create("translator"),n}return f(t,e),(0,s.A)(t,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=t.nsSeparator||this.options.nsSeparator;void 0===n&&(n=":");var r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS;if(n&&e.indexOf(n)>-1){var o=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(o[0])>-1)&&(i=o.shift()),e=o.join(r)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,t){var n=this;if("object"!==(0,r.A)(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,a=this.extractFromKey(e[e.length-1],t),s=a.key,c=a.namespaces,u=c[c.length-1],l=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(d){var f=t.nsSeparator||this.options.nsSeparator;return u+f+s}return s}var p=this.resolve(e,t),h=p&&p.res,v=p&&p.usedKey||s,g=p&&p.exactUsedKey||s,y=Object.prototype.toString.apply(h),m=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject;if(S&&h&&("string"!=typeof h&&"boolean"!=typeof h&&"number"!=typeof h)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(y)<0&&("string"!=typeof m||"[object Array]"!==y)){if(!t.returnObjects&&!this.options.returnObjects)return this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,h,t):"key '".concat(s," (").concat(this.language,")' returned an object instead of string.");if(i){var b="[object Array]"===y,w=b?[]:{},x=b?g:v;for(var k in h)if(Object.prototype.hasOwnProperty.call(h,k)){var I="".concat(x).concat(i).concat(k);w[k]=this.translate(I,o({},t,{joinArrays:!1,ns:c})),w[k]===I&&(w[k]=h[k])}h=w}}else if(S&&"string"==typeof m&&"[object Array]"===y)(h=h.join(m))&&(h=this.extendTranslation(h,e,t));else{var E=!1,O=!1;if(!this.isValidLookup(h)&&void 0!==t.defaultValue){if(E=!0,void 0!==t.count){var D=this.pluralResolver.getSuffix(l,t.count);h=t["defaultValue".concat(D)]}h||(h=t.defaultValue)}this.isValidLookup(h)||(O=!0,h=s);var T=t.defaultValue&&t.defaultValue!==h&&this.options.updateMissing;if(O||E||T){this.logger.log(T?"updateKey":"missingKey",l,u,s,T?t.defaultValue:h);var R=[],A=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&A&&A[0])for(var M=0;M<A.length;M++)R.push(A[M]);else"all"===this.options.saveMissingTo?R=this.languageUtils.toResolveHierarchy(t.lng||this.language):R.push(t.lng||this.language);var _=function(e,r){n.options.missingKeyHandler?n.options.missingKeyHandler(e,u,r,T?t.defaultValue:h,T,t):n.backendConnector&&n.backendConnector.saveMissing&&n.backendConnector.saveMissing(e,u,r,T?t.defaultValue:h,T,t),n.emit("missingKey",e,u,r,h)};if(this.options.saveMissing){var C=void 0!==t.count&&"string"!=typeof t.count;this.options.saveMissingPlurals&&C?R.forEach((function(e){n.pluralResolver.getPluralFormsOfKey(e,s).forEach((function(t){return _([e],t)}))})):_(R,s)}}h=this.extendTranslation(h,e,t,p),O&&h===s&&this.options.appendNamespaceToMissingKey&&(h="".concat(u,":").concat(s)),O&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(h))}return h}},{key:"extendTranslation",value:function(e,t,n,r){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,n,r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(o({},n,{interpolation:o({},this.options.interpolation,n.interpolation)}));var a=n.replace&&"string"!=typeof n.replace?n.replace:n;this.options.interpolation.defaultVariables&&(a=o({},this.options.interpolation.defaultVariables,a)),e=this.interpolator.interpolate(e,a,n.lng||this.language,n),!1!==n.nest&&(e=this.interpolator.nest(e,(function(){return i.translate.apply(i,arguments)}),n)),n.interpolation&&this.interpolator.reset()}var s=n.postProcess||this.options.postProcess,c="string"==typeof s?[s]:s;return null!=e&&c&&c.length&&!1!==n.applyPostProcessor&&(e=M.handle(c,e,t,this.options&&this.options.postProcessPassResolved?o({i18nResolved:r},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,r,i,o,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!a.isValidLookup(t)){var c=a.extractFromKey(e,s),u=c.key;n=u;var l=c.namespaces;a.options.fallbackNS&&(l=l.concat(a.options.fallbackNS));var d=void 0!==s.count&&"string"!=typeof s.count,f=void 0!==s.context&&"string"==typeof s.context&&""!==s.context,p=s.lngs?s.lngs:a.languageUtils.toResolveHierarchy(s.lng||a.language,s.fallbackLng);l.forEach((function(e){a.isValidLookup(t)||(o=e,a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(o)&&a.logger.warn('key "'.concat(n,'" for namespace "').concat(o,"\" won't get resolved as namespace was not yet loaded"),"This means something IS WRONG in your application setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"),p.forEach((function(n){if(!a.isValidLookup(t)){i=n;var o,c,l=u,p=[l];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(p,u,n,e,s);else d&&(o=a.pluralResolver.getSuffix(n,s.count)),d&&f&&p.push(l+o),f&&p.push(l+="".concat(a.options.contextSeparator).concat(s.context)),d&&p.push(l+=o);for(;c=p.pop();)a.isValidLookup(t)||(r=c,t=a.getResource(n,e,c,s))}})))}))}})),{res:t,usedKey:n,exactUsedKey:r,usedLng:i,usedNS:o}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}}]),t}(S);function C(e){return e.charAt(0).toUpperCase()+e.slice(1)}var N=function(){function e(t){(0,a.A)(this,e),this.options=t,this.whitelist=this.options.whitelist||!1,this.logger=m.create("languageUtils")}return(0,s.A)(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=C(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=C(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=C(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isWhitelisted",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitWhitelist)&&(e=this.getLanguagePartFromCode(e)),!this.whitelist||!this.whitelist.length||this.whitelist.indexOf(e)>-1}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,r=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],o=function(e){e&&(n.isWhitelisted(e)?i.push(e):n.logger.warn("rejecting non-whitelisted language code: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):"string"==typeof e&&o(this.formatLanguageCode(e)),r.forEach((function(e){i.indexOf(e)<0&&o(n.formatLanguageCode(e))})),i}}]),e}(),P=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","id","ja","jbo","ka","kk","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he"],nr:[1,2,20,21],fc:22}],j={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0===e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1===e?0:2===e?1:(e<0||e>10)&&e%10==0?2:3)}};var U=function(){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,a.A)(this,e),this.languageUtils=t,this.options=r,this.logger=m.create("pluralResolver"),this.rules=(n={},P.forEach((function(e){e.lngs.forEach((function(t){n[t]={numbers:e.nr,plurals:j[e.fc]}}))})),n)}return(0,s.A)(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=this.getRule(e);return t&&t.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=this,r=[],i=this.getRule(e);return i?(i.numbers.forEach((function(i){var o=n.getSuffix(e,i);r.push("".concat(t).concat(o))})),r):r}},{key:"getSuffix",value:function(e,t){var n=this,r=this.getRule(e);if(r){var i=r.noAbs?r.plurals(t):r.plurals(Math.abs(t)),o=r.numbers[i];this.options.simplifyPluralSuffix&&2===r.numbers.length&&1===r.numbers[0]&&(2===o?o="plural":1===o&&(o=""));var a=function(){return n.options.prepend&&o.toString()?n.options.prepend+o.toString():o.toString()};return"v1"===this.options.compatibilityJSON?1===o?"":"number"==typeof o?"_plural_".concat(o.toString()):a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===r.numbers.length&&1===r.numbers[0]?a():this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString()}return this.logger.warn("no plural rule found for: ".concat(e)),""}}]),e}(),L=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,a.A)(this,e),this.logger=m.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return(0,s.A)(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:R,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?D(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?D(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?D(t.nestingPrefix):t.nestingPrefixEscaped||D("$t("),this.nestingSuffix=t.nestingSuffix?D(t.nestingSuffix):t.nestingSuffixEscaped||D(")"),this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,r){var i,o,a,s=this,c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(e){return e.replace(/\$/g,"$$$$")}var l=function(e){if(e.indexOf(s.formatSeparator)<0)return E(t,c,e);var r=e.split(s.formatSeparator),i=r.shift().trim(),o=r.join(s.formatSeparator).trim();return s.format(E(t,c,i),o,n)};this.resetRegExp();var d=r&&r.missingInterpolationHandler||this.options.missingInterpolationHandler;for(a=0;i=this.regexpUnescape.exec(e);){if(void 0===(o=l(i[1].trim())))if("function"==typeof d){var f=d(e,i,r);o="string"==typeof f?f:""}else this.logger.warn("missed to pass in variable ".concat(i[1]," for interpolating ").concat(e)),o="";else"string"==typeof o||this.useRawValueToEscape||(o=w(o));if(e=e.replace(i[0],u(o)),this.regexpUnescape.lastIndex=0,++a>=this.maxReplaces)break}for(a=0;i=this.regexp.exec(e);){if(void 0===(o=l(i[1].trim())))if("function"==typeof d){var p=d(e,i,r);o="string"==typeof p?p:""}else this.logger.warn("missed to pass in variable ".concat(i[1]," for interpolating ").concat(e)),o="";else"string"==typeof o||this.useRawValueToEscape||(o=w(o));if(o=this.escapeValue?u(this.escape(o)):u(o),e=e.replace(i[0],o),this.regexp.lastIndex=0,++a>=this.maxReplaces)break}return e}},{key:"nest",value:function(e,t){var n,r,i=o({},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{});function a(e,t){if(e.indexOf(",")<0)return e;var n=e.split(",");e=n.shift();var r=n.join(",");r=(r=this.interpolate(r,i)).replace(/'/g,'"');try{i=JSON.parse(r),t&&(i=o({},t,i))}catch(t){this.logger.error("failed parsing options string in nesting for key ".concat(e),t)}return delete i.defaultValue,e}for(i.applyPostProcessor=!1,delete i.defaultValue;n=this.nestingRegexp.exec(e);){if((r=t(a.call(this,n[1].trim(),i),i))&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=w(r)),r||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),r=""),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}]),e}();var V=function(e){function t(e,n,r){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,a.A)(this,t),i=u(this,l(t).call(this)),S.call(c(i)),i.backend=e,i.store=n,i.services=r,i.languageUtils=r.languageUtils,i.options=o,i.logger=m.create("backendConnector"),i.state={},i.queue=[],i.backend&&i.backend.init&&i.backend.init(r,o.backend,o),i}return f(t,e),(0,s.A)(t,[{key:"queueLoad",value:function(e,t,n,r){var i=this,o=[],a=[],s=[],c=[];return e.forEach((function(e){var r=!0;t.forEach((function(t){var s="".concat(e,"|").concat(t);!n.reload&&i.store.hasResourceBundle(e,t)?i.state[s]=2:i.state[s]<0||(1===i.state[s]?a.indexOf(s)<0&&a.push(s):(i.state[s]=1,r=!1,a.indexOf(s)<0&&a.push(s),o.indexOf(s)<0&&o.push(s),c.indexOf(t)<0&&c.push(t)))})),r||s.push(e)})),(o.length||a.length)&&this.queue.push({pending:a,loaded:{},errors:[],callback:r}),{toLoad:o,pending:a,toLoadLanguages:s,toLoadNamespaces:c}}},{key:"loaded",value:function(e,t,n){var r=e.split("|"),i=(0,g.A)(r,2),o=i[0],a=i[1];t&&this.emit("failedLoading",o,a,t),n&&this.store.addResourceBundle(o,a,n),this.state[e]=t?-1:2;var s={};this.queue.forEach((function(n){var r,i,c,u,l,d;r=n.loaded,i=a,u=x(r,[o],Object),l=u.obj,d=u.k,l[d]=l[d]||[],c&&(l[d]=l[d].concat(i)),c||l[d].push(i),function(e,t){for(var n=e.indexOf(t);-1!==n;)e.splice(n,1),n=e.indexOf(t)}(n.pending,e),t&&n.errors.push(t),0!==n.pending.length||n.done||(Object.keys(n.loaded).forEach((function(e){s[e]||(s[e]=[]),n.loaded[e].length&&n.loaded[e].forEach((function(t){s[e].indexOf(t)<0&&s[e].push(t)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",s),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:250,a=arguments.length>5?arguments[5]:void 0;return e.length?this.backend[n](e,t,(function(s,c){s&&c&&i<5?setTimeout((function(){r.read.call(r,e,t,n,i+1,2*o,a)}),o):a(s,c)})):a(null,{})}},{key:"prepareLoading",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var o=this.queueLoad(e,t,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split("|"),i=(0,g.A)(r,2),o=i[0],a=i[1];this.read(o,a,"read",null,null,(function(r,i){r&&t.logger.warn("".concat(n,"loading namespace ").concat(a," for language ").concat(o," failed"),r),!r&&i&&t.logger.log("".concat(n,"loaded namespace ").concat(a," for language ").concat(o),i),t.loaded(e,r,i)}))}},{key:"saveMissing",value:function(e,t,n,r,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" for namespace "').concat(t,'" as the namespace was not yet loaded'),"This means something IS WRONG in your application setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):(this.backend&&this.backend.create&&this.backend.create(e,t,n,r,null,o({},a,{isUpdate:i})),e&&e[0]&&this.store.addResource(e[0],t,n,r))}}]),t}(S);function F(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.whitelist&&e.whitelist.indexOf("cimode")<0&&(e.whitelist=e.whitelist.concat(["cimode"])),e}function H(){}const B=new(function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,a.A)(this,t),e=u(this,l(t).call(this)),S.call(c(e)),e.options=F(n),e.services={},e.logger=m,e.modules={external:[]},r&&!e.isInitialized&&!n.isClone){if(!e.options.initImmediate)return e.init(n,r),u(e,c(e));setTimeout((function(){e.init(n,r)}),0)}return e}return f(t,e),(0,s.A)(t,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;function i(e){return e?"function"==typeof e?new e:e:null}if("function"==typeof t&&(n=t,t={}),this.options=o({},{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===(0,r.A)(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===(0,r.A)(e[2])||"object"===(0,r.A)(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",maxReplaces:1e3}},this.options,F(t)),this.format=this.options.interpolation.format,n||(n=H),!this.options.isClone){this.modules.logger?m.init(i(this.modules.logger),this.options):m.init(null,this.options);var a=new N(this.options);this.store=new A(this.options.resources,this.options);var s=this.services;s.logger=m,s.resourceStore=this.store,s.languageUtils=a,s.pluralResolver=new U(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),s.interpolator=new L(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new V(i(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.languageDetector&&(s.languageDetector=i(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=i(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new _(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}["getResource","addResource","addResources","addResourceBundle","removeResourceBundle","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}}));var c=b(),u=function(){e.changeLanguage(e.options.lng,(function(t,r){e.isInitialized=!0,e.logger.log("initialized",e.options),e.emit("initialized",e.options),c.resolve(r),n(t,r)}))};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}},{key:"loadResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:H;if(!this.options.resources||this.options.partialBundledLanguages){if(this.language&&"cimode"===this.language.toLowerCase())return t();var n=[],r=function(t){t&&e.services.languageUtils.toResolveHierarchy(t).forEach((function(e){n.indexOf(e)<0&&n.push(e)}))};if(this.language)r(this.language);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return r(e)}));this.options.preload&&this.options.preload.forEach((function(e){return r(e)})),this.services.backendConnector.load(n,this.options.ns,t)}else t(null)}},{key:"reloadResources",value:function(e,t,n){var r=b();return e||(e=this.languages),t||(t=this.options.ns),n||(n=H),this.services.backendConnector.reload(e,t,(function(e){r.resolve(),n(e)})),r}},{key:"use",value:function(e){return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&M.addPostProcessor(e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"changeLanguage",value:function(e,t){var n=this,r=b();this.emit("languageChanging",e);var i=function(e){e&&(n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.translator.language||n.translator.changeLanguage(e),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(e)),n.loadResources((function(i){!function(e,i){n.translator.changeLanguage(i),i&&(n.emit("languageChanged",i),n.logger.log("languageChanged",i)),r.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(i,e)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),r}},{key:"getFixedT",value:function(e,t){var n=this,i=function e(t,i){var a;if("object"!==(0,r.A)(i)){for(var s=arguments.length,c=new Array(s>2?s-2:0),u=2;u<s;u++)c[u-2]=arguments[u];a=n.options.overloadTranslationOptionHandler([t,i].concat(c))}else a=o({},i);return a.lng=a.lng||e.lng,a.lngs=a.lngs||e.lngs,a.ns=a.ns||e.ns,n.t(t,a)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this;if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var n=this.languages[0],r=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var o=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===r||2===r};return!!this.hasResourceBundle(n,e)||(!this.services.backendConnector.backend||!(!o(n,e)||r&&!o(i,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,r=b();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){r.resolve(),t&&t(e)})),r):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=b();"string"==typeof e&&(e=[e]);var r=this.options.preload||[],i=e.filter((function(e){return r.indexOf(e)<0}));return i.length?(this.options.preload=r.concat(i),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.languages&&this.languages.length>0?this.languages[0]:this.language),!e)return"rtl";return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>=0?"rtl":"ltr"}},{key:"createInstance",value:function(){return new t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}},{key:"cloneInstance",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:H,i=o({},this.options,n,{isClone:!0}),a=new t(i);return["store","services","language"].forEach((function(t){a[t]=e[t]})),a.translator=new _(a.services,a.options),a.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];a.emit.apply(a,[e].concat(n))})),a.init(i,r),a.translator.options=a.options,a}}]),t}(S))},856:(e,t,n)=>{"use strict";var r=n(183);function i(){}function o(){}o.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,o,a){if(a!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:i};return n.PropTypes=n,n}},598:(e,t,n)=>{e.exports=n(856)()},183:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},249:(e,t)=>{"use strict";var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}function m(){}function S(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},m.prototype=y.prototype;var b=S.prototype=new m;b.constructor=S,v(b,y.prototype),b.isPureReactComponent=!0;var w=Array.isArray,x=Object.prototype.hasOwnProperty,k={current:null},I={key:!0,ref:!0,__self:!0,__source:!0};function E(e,t,r){var i,o={},a=null,s=null;if(null!=t)for(i in void 0!==t.ref&&(s=t.ref),void 0!==t.key&&(a=""+t.key),t)x.call(t,i)&&!I.hasOwnProperty(i)&&(o[i]=t[i]);var c=arguments.length-2;if(1===c)o.children=r;else if(1<c){for(var u=Array(c),l=0;l<c;l++)u[l]=arguments[l+2];o.children=u}if(e&&e.defaultProps)for(i in c=e.defaultProps)void 0===o[i]&&(o[i]=c[i]);return{$$typeof:n,type:e,key:a,ref:s,props:o,_owner:k.current}}function O(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var D=/\/+/g;function T(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function R(e,t,i,o,a){var s=typeof e;"undefined"!==s&&"boolean"!==s||(e=null);var c=!1;if(null===e)c=!0;else switch(s){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case n:case r:c=!0}}if(c)return a=a(c=e),e=""===o?"."+T(c,0):o,w(a)?(i="",null!=e&&(i=e.replace(D,"$&/")+"/"),R(a,t,i,"",(function(e){return e}))):null!=a&&(O(a)&&(a=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(a,i+(!a.key||c&&c.key===a.key?"":(""+a.key).replace(D,"$&/")+"/")+e)),t.push(a)),1;if(c=0,o=""===o?".":o+":",w(e))for(var u=0;u<e.length;u++){var l=o+T(s=e[u],u);c+=R(s,t,i,l,a)}else if(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(e),"function"==typeof l)for(e=l.call(e),u=0;!(s=e.next()).done;)c+=R(s=s.value,t,i,l=o+T(s,u++),a);else if("object"===s)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function A(e,t,n){if(null==e)return e;var r=[],i=0;return R(e,r,"","",(function(e){return t.call(n,e,i++)})),r}function M(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var _={current:null},C={transition:null},N={ReactCurrentDispatcher:_,ReactCurrentBatchConfig:C,ReactCurrentOwner:k};function P(){throw Error("act(...) is not supported in production builds of React.")}t.Children={map:A,forEach:function(e,t,n){A(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return A(e,(function(){t++})),t},toArray:function(e){return A(e,(function(e){return e}))||[]},only:function(e){if(!O(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=y,t.Fragment=i,t.Profiler=a,t.PureComponent=S,t.StrictMode=o,t.Suspense=l,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=N,t.act=P,t.cloneElement=function(e,t,r){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var i=v({},e.props),o=e.key,a=e.ref,s=e._owner;if(null!=t){if(void 0!==t.ref&&(a=t.ref,s=k.current),void 0!==t.key&&(o=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(u in t)x.call(t,u)&&!I.hasOwnProperty(u)&&(i[u]=void 0===t[u]&&void 0!==c?c[u]:t[u])}var u=arguments.length-2;if(1===u)i.children=r;else if(1<u){c=Array(u);for(var l=0;l<u;l++)c[l]=arguments[l+2];i.children=c}return{$$typeof:n,type:e.type,key:o,ref:a,props:i,_owner:s}},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:s,_context:e},e.Consumer=e},t.createElement=E,t.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:u,render:e}},t.isValidElement=O,t.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:M}},t.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=C.transition;C.transition={};try{e()}finally{C.transition=t}},t.unstable_act=P,t.useCallback=function(e,t){return _.current.useCallback(e,t)},t.useContext=function(e){return _.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return _.current.useDeferredValue(e)},t.useEffect=function(e,t){return _.current.useEffect(e,t)},t.useId=function(){return _.current.useId()},t.useImperativeHandle=function(e,t,n){return _.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return _.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return _.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return _.current.useMemo(e,t)},t.useReducer=function(e,t,n){return _.current.useReducer(e,t,n)},t.useRef=function(e){return _.current.useRef(e)},t.useState=function(e){return _.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return _.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return _.current.useTransition()},t.version="18.3.1"},326:(e,t,n)=>{"use strict";e.exports=n(249)},785:(e,t,n)=>{"use strict";var r=n(326);var i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=r.useState,a=r.useEffect,s=r.useLayoutEffect,c=r.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=o({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s((function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})}),[e,n,t]),a((function(){return u(i)&&l({inst:i}),e((function(){u(i)&&l({inst:i})}))}),[e]),c(n),n};t.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:l},462:(e,t,n)=>{"use strict";var r=n(326),i=n(634);var o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=i.useSyncExternalStore,s=r.useRef,c=r.useEffect,u=r.useMemo,l=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=u((function(){function e(e){if(!c){if(c=!0,a=e,e=r(e),void 0!==i&&f.hasValue){var t=f.value;if(i(t,e))return s=t}return s=e}if(t=s,o(a,e))return t;var n=r(e);return void 0!==i&&i(t,n)?t:(a=e,s=n)}var a,s,c=!1,u=void 0===n?null:n;return[function(){return e(t())},null===u?void 0:function(){return e(u())}]}),[t,n,r,i]);var p=a(e,d[0],d[1]);return c((function(){f.hasValue=!0,f.value=p}),[p]),l(p),p}},634:(e,t,n)=>{"use strict";e.exports=n(785)},100:(e,t,n)=>{"use strict";e.exports=n(462)},741:e=>{e.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}},557:e=>{"use strict";e.exports=c},713:e=>{"use strict";e.exports=s},2:e=>{"use strict";e.exports=n},669:e=>{"use strict";e.exports=o},838:e=>{"use strict";e.exports=t},438:e=>{"use strict";e.exports=i},21:e=>{"use strict";e.exports=r},545:e=>{"use strict";e.exports=a},55:t=>{"use strict";t.exports=e},85:(e,t,n)=>{"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,{A:()=>r})},561:(e,t,n)=>{"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,{A:()=>r})},1:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(236);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(0,r.A)(i.key),i)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}},111:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(236);function i(e,t,n){return(t=(0,r.A)(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},730:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(492);function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||(0,r.A)(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},236:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(224);function i(e){var t=function(e,t){if("object"!=(0,r.A)(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=(0,r.A)(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==(0,r.A)(t)?t:t+""}},224:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}n.d(t,{A:()=>r})},492:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(85);function i(e,t){if(e){if("string"==typeof e)return(0,r.A)(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?(0,r.A)(e,t):void 0}}}},f={};function p(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return d[e](n,n.exports,p),n.exports}p.m=d,u=[],p.O=(e,t,n,r)=>{if(!t){var i=1/0;for(c=0;c<u.length;c++){for(var[t,n,r]=u[c],o=!0,a=0;a<t.length;a++)(!1&r||i>=r)&&Object.keys(p.O).every((e=>p.O[e](t[a])))?t.splice(a--,1):(o=!1,r<i&&(i=r));if(o){u.splice(c--,1);var s=n();void 0!==s&&(e=s)}}return e}r=r||0;for(var c=u.length;c>0&&u[c-1][2]>r;c--)u[c]=u[c-1];u[c]=[t,n,r]},p.F={},p.E=e=>{Object.keys(p.F).map((t=>{p.F[t](e)}))},p.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return p.d(t,{a:t}),t},p.d=(e,t)=>{for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l={524:0},p.F.j=e=>{if(!p.o(l,e)||void 0===l[e]){l[e]=null;var t=document.createElement("link");p.nc&&t.setAttribute("nonce",p.nc),t.rel="prefetch",t.as="script",t.href=p.p+p.u(e),document.head.appendChild(t)}},p.O.j=e=>0===l[e],p.O(0,[524],(()=>{p.E(524)}),5);var h={};return(()=>{"use strict";p.r(h),p.d(h,{default:()=>te,measurementTrackingMode:()=>_.v});var e=p(326),t=p(440),n=p(598),r=p.n(n),i=p(2),o=p(21),a=p.n(o),s=p(55);function c({hide:t,onConfirm:n,message:r}){return e.createElement("div",{className:"text-foreground text-[13px]"},e.createElement("div",null,e.createElement("p",null,r),e.createElement("p",{className:"mt-2"},"This action cannot be undone and will delete all your existing measurements.")),e.createElement(s.FooterAction,{className:"mt-4"},e.createElement(s.FooterAction.Right,null,e.createElement(s.FooterAction.Secondary,{onClick:t},"Cancel"),e.createElement(s.FooterAction.Primary,{onClick:()=>{n(),t()}},"Untrack"))))}const u=["SR","SEG","SM","RTSTRUCT","RTPLAN","RTDOSE","DOC","OT","PMAP"];function l({getImageSrc:n,getStudiesForPatientByMRN:r,requestDisplaySetCreationForStudy:o,dataSource:s}){const{servicesManager:l}=(0,i.useSystem)(),{displaySetService:d,uiModalService:f,measurementService:p,viewportGridService:h}=l.services,[v,g]=(0,t.B)(),{trackedSeries:y}=v.context,m=e=>{if("SR"===d.getDisplaySetByUID(e).Modality){const t=h.getActiveViewportId();g("CHECK_DIRTY",{viewportId:t,displaySetInstanceUID:e})}};(0,e.useEffect)((()=>{const e=h.subscribe(h.EVENTS.VIEWPORT_ONDROP_HANDLED,(({eventData:e})=>{m(e.displaySetInstanceUID)}));return()=>{e.unsubscribe()}}),[]);const S=e=>u.includes(e.Modality)||e?.unsupported?"thumbnailNoImage":"thumbnailTracked";return e.createElement(a(),{getImageSrc:n,getStudiesForPatientByMRN:r,requestDisplaySetCreationForStudy:o,dataSource:s,customMapDisplaySets:(e,t,n,r)=>{const i=[],o=[];return e.filter((e=>!e.excludeFromThumbnailBrowser)).forEach((e=>{const{thumbnailSrc:r,displaySetInstanceUID:a}=e,s=S(e),c="thumbnailTracked"===s?i:o,u=t?.[a];c.push({displaySetInstanceUID:a,description:e.SeriesDescription||"",seriesNumber:e.SeriesNumber,modality:e.Modality,seriesDate:e.SeriesDate?new Date(e.SeriesDate).toLocaleDateString():"",numInstances:e.numImageFrames,loadingProgress:u,countIcon:e.countIcon,messages:e.messages,StudyInstanceUID:e.StudyInstanceUID,componentType:s,imageSrc:r||n[a],dragData:{type:"displayset",displaySetInstanceUID:a},isTracked:y.includes(e.SeriesInstanceUID),isHydratedForDerivedDisplaySet:e.isHydrated})})),[...i,...o]},onClickUntrack:e=>{f.show({title:"Untrack Series",content:c,contentProps:{onConfirm:()=>{const t=d.getDisplaySetByUID(e);g("UNTRACK_SERIES",{SeriesInstanceUID:t.SeriesInstanceUID});p.getMeasurements().forEach((e=>{e.referenceSeriesUID===t.SeriesInstanceUID&&p.remove(e.uid)}))},message:"Are you sure you want to untrack this series?"}})},onDoubleClickThumbnailHandlerCallBack:m})}l.propTypes={dataSource:r().shape({getImageIdsForDisplaySet:r().func.isRequired}).isRequired,getImageSrc:r().func.isRequired,getStudiesForPatientByMRN:r().func.isRequired,requestDisplaySetCreationForStudy:r().func.isRequired};const d=function(e,t){return new Promise(((n,r)=>{const i=document.createElement("canvas");e.utilities.loadImageToCanvas({canvas:i,imageId:t,thumbnail:!0}).then((e=>{n(i.toDataURL())})).catch(r)}))};var f=p(438);const v=function(){const{extensionManager:t}=(0,i.useSystem)(),n=t.getActiveDataSource()[0],r=function(e){const t=e.getModuleEntry("@ohif/extension-default.utilityModule.common"),{getStudiesForPatientByMRN:n}=t.exports;return n}(t).bind(null,n),o=(0,e.useCallback)(function(e){const t=e.getModuleEntry("@ohif/extension-cornerstone.utilityModule.common");try{const{cornerstone:e}=t.exports.getCornerstoneLibraries();return d.bind(null,e)}catch(e){throw new Error("Required command not found")}}(t),[]),a=f.requestDisplaySetCreationForStudy.bind(null,n);return e.createElement(l,{dataSource:n,getImageSrc:o,getStudiesForPatientByMRN:r,requestDisplaySetCreationForStudy:a})};var g=p(669);function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(null,arguments)}const{filterAnd:m,filterPlanarMeasurement:S,filterMeasurementsBySeriesUID:b}=i.utils.MeasurementFilters;const w=function(n){const[r]=(0,s.useViewportGrid)(),{measurementService:i,uiModalService:o}=n.servicesManager.services,[a,u]=(0,t.B)(),{trackedStudy:l,trackedSeries:d}=a.context,f=l?m(S,b(d)):S,p=()=>{u("UNTRACK_ALL",{})},h={createSR:({StudyInstanceUID:e})=>{u("SAVE_REPORT",{viewportId:r.activeViewportId,isBackupSave:!0,StudyInstanceUID:e,measurementFilter:f})},onDelete:()=>{i.getMeasurements().some((e=>e.isDirty))?o.show({title:"Untrack Study",content:c,contentProps:{onConfirm:p,message:"Are you sure you want to untrack study and delete all measurements?"}}):p()}},v=t=>e.createElement(s.AccordionTrigger,{asChild:!0,className:"px-0"},e.createElement("div",{"data-cy":"TrackingHeader"},e.createElement(g.StudySummaryFromMetadata,y({},t,{actions:h}))));return e.createElement("div",{"data-cy":"trackedMeasurements-panel"},e.createElement(g.PanelMeasurement,{measurementFilter:f,emptyComponent:()=>e.createElement("div",{"data-cy":"trackedMeasurements-panel"},e.createElement(s.MeasurementTable,{title:"Measurements",isExpanded:!1},e.createElement(s.MeasurementTable.Body,null))),sourceChildren:n.children},e.createElement(g.StudyMeasurements,{grouping:n.grouping},e.createElement(g.AccordionGroup.Trigger,{key:"trackingMeasurementsHeader",asChild:!0},e.createElement(v,{key:"trackingHeadChild"})),e.createElement(g.MeasurementsOrAdditionalFindings,{key:"measurementsOrAdditionalFindings",activeStudyUID:l,customHeader:g.StudyMeasurementsActions,measurementFilter:f,actions:h}))))};var x=p(228);function k(){return k=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},k.apply(null,arguments)}const I=function({commandsManager:t,extensionManager:n,servicesManager:r}){return[{name:"seriesList",iconName:"tab-studies",iconLabel:"Studies",label:x.A.t("SidePanel:Studies"),component:t=>e.createElement(v,t)},{name:"trackedMeasurements",iconName:"tab-linear",iconLabel:"Measure",label:x.A.t("SidePanel:Measurements"),component:i=>e.createElement(w,k({},i,{key:"trackedMeasurements-panel",commandsManager:t,extensionManager:n,servicesManager:r}))}]};function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},E.apply(null,arguments)}const O=e.lazy((()=>Promise.resolve().then(p.bind(p,132)))),D=t=>e.createElement(e.Suspense,{fallback:e.createElement("div",null,"Loading...")},e.createElement(O,t));const T=function({servicesManager:t,commandsManager:n,extensionManager:r}){return[{name:"cornerstone-tracked",component:i=>e.createElement(D,E({servicesManager:t,commandsManager:n,extensionManager:r},i)),isReferenceViewable:e=>g.utils.isReferenceViewable({...e,servicesManager:t})}]},R=JSON.parse('{"UU":"@ohif/extension-measurement-tracking"}').UU;var A=p(545),M=p.n(A),_=p(123);const C=0,N=1,P=3;const j=function({servicesManager:e},t,n){const{viewportId:r,displaySetInstanceUID:i}=n.data||n;return new Promise((async function(t,n){const{uiViewportDialogService:o,customizationService:a}=e.services,s=await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.discardDirtyMessage"),a=[{id:"cancel",type:"cancel",text:"Cancel",value:C},{id:"discard-existing",type:"secondary",text:"No, discard existing",value:P},{id:"save-existing",type:"primary",text:"Yes",value:N}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,id:"measurement-tracking-prompt-dirty-measurement",type:"info",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r(C)},onKeyPress:e=>{if("Enter"===e.key){const e=a.find((e=>"save-existing"===e.id));s(e.value)}}})}))}(o,a,r);t({displaySetInstanceUID:i,userResponse:s,viewportId:r,isBackupSave:!1})}))};var U=p(838);const L=0,V=5;const F=function({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},i,o){const{uiViewportDialogService:a,displaySetService:s,customizationService:c}=e.services,{viewportId:u,displaySetInstanceUID:l}=o,d=s.getDisplaySetByUID(l);return new Promise((async function(i,s){const f=r?.measurementTrackingMode===_.v.STANDARD?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.hydrateSRMessage"),a=[{id:"no-hydrate",type:"secondary",text:"No",value:L},{id:"yes-hydrate",type:"primary",text:"Yes",value:V}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"info",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r(L)},onKeyPress:e=>{if("Enter"===e.key){const e=a.find((e=>e.value===V));s(e.value)}}})}))}(a,c,u):V;let p,h;if(f===V){console.warn("!! HYDRATING STRUCTURED REPORT");const i=(0,U.hydrateStructuredReport)({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},l);p=i.StudyInstanceUID,h=i.SeriesInstanceUIDs}i({userResponse:f,displaySetInstanceUID:o.displaySetInstanceUID,srSeriesInstanceUID:d.SeriesInstanceUID,viewportId:u,StudyInstanceUID:p,SeriesInstanceUIDs:h})}))},H=0,B=1,z=2,q=3;const K=function({servicesManager:e,extensionManager:t},n,r){const{UIViewportDialogService:i,customizationService:o}=e.services,{viewportId:a,StudyInstanceUID:s,SeriesInstanceUID:c}=r.data||r;return new Promise((async function(e,r){const u=t._appConfig;let l=u?.measurementTrackingMode===_.v.STANDARD?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.trackNewSeriesMessage"),a=[{type:"secondary",text:"Cancel",value:H},{type:"primary",text:"Create new report",value:B},{type:"primary",text:"Add to existing report",value:z}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"info",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r(H)}})}))}(i,o,a):z;l===B&&(l=n.isDirty?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.discardSeriesMessage"),a=[{type:"secondary",text:"Cancel",value:H},{type:"secondary",text:"Save",value:B},{type:"primary",text:"Discard",value:q}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"warning",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r(H)}})}))}(i,o,a):q),e({userResponse:l,StudyInstanceUID:s,SeriesInstanceUID:c,viewportId:a,isBackupSave:!1})}))},$=0,W=1,Y=3,J=4;const G=function({servicesManager:e,extensionManager:t},n,r){const{uiViewportDialogService:i,customizationService:o}=e.services,{viewportId:a,StudyInstanceUID:s,SeriesInstanceUID:c}=r.data||r;return new Promise((async function(e,r){const u=t._appConfig,l=u?.measurementTrackingMode===_.v.STANDARD,d=u?.measurementTrackingMode===_.v.SIMPLIFIED;let f=l?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.trackNewStudyMessage"),a=[{type:"cancel",text:x.A.t("MeasurementTable:No"),value:$},{type:"secondary",text:x.A.t("MeasurementTable:No, do not ask again"),value:J},{type:"primary",text:x.A.t("MeasurementTable:Yes"),value:Y}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"info",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r($)},onKeyPress:e=>{if("Enter"===e.key){const e=a.find((e=>e.value===Y));s(e.value)}}})}))}(i,o,a):Y;f===Y&&(f=n.isDirty&&(l||d)?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.discardStudyMessage"),a=[{type:"cancel",text:"Cancel",value:$},{type:"secondary",text:"No, discard previously tracked series & measurements",value:Y},{type:"primary",text:"Yes",value:W}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"warning",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r($)}})}))}(i,o,a):Y),e({userResponse:f,StudyInstanceUID:s,SeriesInstanceUID:c,viewportId:a,isBackupSave:!1})}))},Q={"measurement.promptBeginTracking":_.A,"measurement.promptHydrateStructuredReport":F,"measurement.promptTrackNewSeries":K,"measurement.promptTrackNewStudy":G,"measurement.promptLabelAnnotation":f.promptLabelAnnotation,"measurement.promptSaveReport":f.promptSaveReport,"measurement.promptHasDirtyAnnotations":j};const X={callbacks:[({activeViewportId:e,servicesManager:t,isHangingProtocolLayout:n,appConfig:r})=>async i=>{const{hangingProtocolService:o,viewportGridService:a,uiNotificationService:s}=t.services;let c=[];const u=e,l=ee({servicesManager:t,appConfig:r,displaySetInstanceUID:i});try{l||(c=o.getViewportsRequireUpdate(u,i,n),a.setDisplaySetsForViewports(c))}catch(e){console.warn(e),s.show({title:"Thumbnail Double Click",message:"The selected display sets could not be added to the viewport.",type:"error",duration:3e3})}}]},Z=async e=>{const t=ee(e);return Promise.resolve({handled:t})},ee=e=>{const{servicesManager:t,appConfig:n,displaySetInstanceUID:r}=e,i=n.measurementTrackingMode===_.v.SIMPLIFIED,{measurementService:o,displaySetService:a}=t.services,s=o.getMeasurements(),c=s.some((e=>e.isDirty))||s.length&&o.getIsMeasurementDeletedIndividually();return"SR"===a.getDisplaySetByUID(r).Modality&&i&&c},te={id:R,getContextModule:t.A,getPanelModule:I,getViewportModule:T,onModeEnter({servicesManager:t}){const{toolbarService:n,customizationService:r}=t.services;r.setCustomizations({"studyBrowser.thumbnailDoubleClickCallback":{$set:X},customOnDropHandler:{$set:Z}}),n.addButtons([{id:"loadSRMeasurements",component:t=>e.createElement(s.ViewportActionButton,t,M().t("Common:LOAD")),props:{commands:["loadTrackedSRMeasurements"]}}],!0)},getCustomizationModule:function(){return[{name:"default",value:{...Q}}]}}})(),h=p.O(h)})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@ohif/ui-next"),require("@ohif/extension-cornerstone-dicom-sr"),require("@ohif/core"),require("@ohif/extension-default/src/Panels/StudyBrowser/PanelStudyBrowser"),require("@ohif/extension-default"),require("@ohif/extension-cornerstone"),require("@ohif/i18n"),require("@cornerstonejs/tools"),require("@cornerstonejs/core")):"function"==typeof define&&define.amd?define(["@ohif/ui-next","@ohif/extension-cornerstone-dicom-sr","@ohif/core","@ohif/extension-default/src/Panels/StudyBrowser/PanelStudyBrowser","@ohif/extension-default","@ohif/extension-cornerstone","@ohif/i18n","@cornerstonejs/tools","@cornerstonejs/core"],t):"object"==typeof exports?exports["ohif-extension-measurement-tracking"]=t(require("@ohif/ui-next"),require("@ohif/extension-cornerstone-dicom-sr"),require("@ohif/core"),require("@ohif/extension-default/src/Panels/StudyBrowser/PanelStudyBrowser"),require("@ohif/extension-default"),require("@ohif/extension-cornerstone"),require("@ohif/i18n"),require("@cornerstonejs/tools"),require("@cornerstonejs/core")):e["ohif-extension-measurement-tracking"]=t(e["@ohif/ui-next"],e["@ohif/extension-cornerstone-dicom-sr"],e["@ohif/core"],e["@ohif/extension-default/src/Panels/StudyBrowser/PanelStudyBrowser"],e["@ohif/extension-default"],e["@ohif/extension-cornerstone"],e["@ohif/i18n"],e["@cornerstonejs/tools"],e["@cornerstonejs/core"])}(globalThis,((e,t,n,r,i,o,a,s,c)=>(()=>{var u,l,d={123:(e,t,n)=>{"use strict";n.d(t,{A:()=>c,v:()=>s});var r=n(228);const i=-1,o=0,a=3,s={STANDARD:"standard",SIMPLIFIED:"simplified",NONE:"none"};const c=function({servicesManager:e,extensionManager:t},n,c){const{uiViewportDialogService:u,customizationService:l}=e.services,d=t._appConfig,{viewportId:f,StudyInstanceUID:p,SeriesInstanceUID:h}=c.data||c;return new Promise((async function(e,t){const n=d?.measurementTrackingMode===s.STANDARD;let c;c=d?.measurementTrackingMode===s.NONE?i:n?await function(e,t,n){return new Promise((function(s,c){const u=t.getCustomization("viewportNotification.beginTrackingMessage"),l=[{id:"prompt-begin-tracking-cancel",type:"secondary",text:r.A.t("Common:No"),value:o},{id:"prompt-begin-tracking-no-do-not-ask-again",type:"secondary",text:r.A.t("MeasurementTable:No, do not ask again"),value:i},{id:"prompt-begin-tracking-yes",type:"primary",text:r.A.t("Common:Yes"),value:a}],d=t=>{e.hide(),s(t)};e.show({viewportId:n,id:"measurement-tracking-prompt-begin-tracking",type:"info",message:u,actions:l,onSubmit:d,onOutsideClick:()=>{e.hide(),s(o)},onKeyPress:e=>{if("Enter"===e.key){const e=l.find((e=>"prompt-begin-tracking-yes"===e.id));d(e.value)}}})}))}(u,l,f):a,e({userResponse:c,StudyInstanceUID:p,SeriesInstanceUID:h,viewportId:f})}))}},440:(e,t,n)=>{"use strict";n.d(t,{A:()=>Ht,B:()=>Lt});var r,i,o=n(326),a=n(598),s=n.n(a),c=function(){return c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},c.apply(this,arguments)};function u(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function f(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}!function(e){e.Start="xstate.start",e.Stop="xstate.stop",e.Raise="xstate.raise",e.Send="xstate.send",e.Cancel="xstate.cancel",e.NullEvent="",e.Assign="xstate.assign",e.After="xstate.after",e.DoneState="done.state",e.DoneInvoke="done.invoke",e.Log="xstate.log",e.Init="xstate.init",e.Invoke="xstate.invoke",e.ErrorExecution="error.execution",e.ErrorCommunication="error.communication",e.ErrorPlatform="error.platform",e.ErrorCustom="xstate.error",e.Update="xstate.update",e.Pure="xstate.pure",e.Choose="xstate.choose"}(r||(r={})),function(e){e.Parent="#_parent",e.Internal="#_internal"}(i||(i={}));var p,h=r.Start,v=r.Stop,g=r.Raise,y=r.Send,m=r.Cancel,S=r.NullEvent,b=r.Assign,w=(r.After,r.DoneState,r.Log),x=r.Init,k=r.Invoke,I=(r.ErrorExecution,r.ErrorPlatform),E=r.ErrorCustom,O=r.Update,D=r.Choose,T=r.Pure,R={},A="xstate.guard";function M(e,t,n){void 0===n&&(n=".");var r=N(e,n),i=N(t,n);return G(i)?!!G(r)&&i===r:G(r)?r in i:Object.keys(r).every((function(e){return e in i&&M(r[e],i[e])}))}function _(e){try{return G(e)||"number"==typeof e?"".concat(e):e.type}catch(e){throw new Error("Events must be strings or objects with a string event.type property.")}}function C(e,t){try{return Y(e)?e:e.toString().split(t)}catch(t){throw new Error("'".concat(e,"' is not a valid state path."))}}function N(e,t){return"object"==typeof(n=e)&&"value"in n&&"context"in n&&"event"in n&&"_event"in n?e.value:Y(e)?P(e):"string"!=typeof e?e:P(C(e,t));var n}function P(e){if(1===e.length)return e[0];for(var t={},n=t,r=0;r<e.length-1;r++)r===e.length-2?n[e[r]]=e[r+1]:(n[e[r]]={},n=n[e[r]]);return t}function j(e,t){for(var n={},r=Object.keys(e),i=0;i<r.length;i++){var o=r[i];n[o]=t(e[o],o,e,i)}return n}function U(e,t,n){var r,i,o={};try{for(var a=l(Object.keys(e)),s=a.next();!s.done;s=a.next()){var c=s.value,u=e[c];n(u)&&(o[c]=t(u,c,e))}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return o}var L=function(e){return function(t){var n,r,i=t;try{for(var o=l(e),a=o.next();!a.done;a=o.next()){i=i[a.value]}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}};function V(e){return e?G(e)?[[e]]:F(Object.keys(e).map((function(t){var n=e[t];return"string"==typeof n||n&&Object.keys(n).length?V(e[t]).map((function(e){return[t].concat(e)})):[[t]]}))):[[]]}function F(e){var t;return(t=[]).concat.apply(t,f([],d(e),!1))}function H(e){return Y(e)?e:[e]}function B(e){return void 0===e?[]:H(e)}function z(e,t,n){var r,i;if(J(e))return e(t,n.data);var o={};try{for(var a=l(Object.keys(e)),s=a.next();!s.done;s=a.next()){var c=s.value,u=e[c];J(u)?o[c]=u(t,n.data):o[c]=u}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return o}function q(e){return e instanceof Promise||!(null===e||!J(e)&&"object"!=typeof e||!J(e.then))}function K(e,t){return j(e.states,(function(e,n){if(e){var r=(G(t)?void 0:t[n])||(e?e.current:void 0);if(r)return{current:r,states:K(e,r)}}}))}function $(e,t,n,r){var i=e?n.reduce((function(e,n){var i,o,a=n.assignment,s={state:r,action:n,_event:t},c={};if(J(a))c=a(e,t.data,s);else try{for(var u=l(Object.keys(a)),d=u.next();!d.done;d=u.next()){var f=d.value,p=a[f];c[f]=J(p)?p(e,t.data,s):p}}catch(e){i={error:e}}finally{try{d&&!d.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}return Object.assign({},e,c)}),e):e;return i}var W=function(){};function Y(e){return Array.isArray(e)}function J(e){return"function"==typeof e}function G(e){return"string"==typeof e}function Q(e,t){if(e)return G(e)?{type:A,name:e,predicate:t?t[e]:void 0}:J(e)?{type:A,name:e.name,predicate:e}:e}var X=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();(p={})[X]=function(){return this},p[Symbol.observable]=function(){return this};function Z(e){return!!e&&"__xstatenode"in e}function ee(e,t){return G(e)||"number"==typeof e?c({type:e},t):e}function te(e,t){if(!G(e)&&"$$type"in e&&"scxml"===e.$$type)return e;var n=ee(e);return c({name:n.type,data:n,$$type:"scxml",type:"external"},t)}function ne(e,t){return H(t).map((function(t){return void 0===t||"string"==typeof t||Z(t)?{target:t,event:e}:c(c({},t),{event:e})}))}function re(e,t,n,r,i){var o=e.options.guards,a={state:i,cond:t,_event:r};if(t.type===A)return((null==o?void 0:o[t.name])||t.predicate)(n,r.data,a);var s=null==o?void 0:o[t.type];if(!s)throw new Error("Guard '".concat(t.type,"' is not implemented on machine '").concat(e.id,"'."));return s(n,r.data,a)}function ie(e){return"string"==typeof e?{type:e}:e}function oe(e,t,n){var r=function(){},i="object"==typeof e,o=i?e:null;return{next:((i?e.next:e)||r).bind(o),error:((i?e.error:t)||r).bind(o),complete:((i?e.complete:n)||r).bind(o)}}function ae(e,t){return"".concat(e,":invocation[").concat(t,"]")}function se(e){return(e.type===g||e.type===y&&e.to===i.Internal)&&"number"!=typeof e.delay}var ce=te({type:x});function ue(e,t){return t&&t[e]||void 0}function le(e,t){var n;if(G(e)||"number"==typeof e)n=J(r=ue(e,t))?{type:e,exec:r}:r||{type:e,exec:void 0};else if(J(e))n={type:e.name||e.toString(),exec:e};else{var r;if(J(r=ue(e.type,t)))n=c(c({},e),{exec:r});else if(r){var i=r.type||e.type;n=c(c(c({},r),e),{type:i})}else n=e}return n}var de=function(e,t){return e?(Y(e)?e:[e]).map((function(e){return le(e,t)})):[]};function fe(e){var t=le(e);return c(c({id:G(e)?e:t.id},t),{type:t.type})}function pe(e,t){return{to:t?t.to:void 0,type:y,event:J(e)?e:ee(e),delay:t?t.delay:void 0,id:t&&void 0!==t.id?t.id:J(e)?e.name:_(e)}}function he(e,t){var n="".concat(r.DoneState,".").concat(e),i={type:n,data:t,toString:function(){return n}};return i}function ve(e,t){var n="".concat(r.DoneInvoke,".").concat(e),i={type:n,data:t,toString:function(){return n}};return i}function ge(e,t){var n="".concat(r.ErrorPlatform,".").concat(e),i={type:n,data:t,toString:function(){return n}};return i}function ye(e,t,n,o,a,s,u){void 0===u&&(u=!1);var p=u?[]:function(e){var t,n,r=[];try{for(var i=l(e),o=i.next();!o.done;o=i.next())for(var a=o.value,s=0;s<a.actions.length;)a.actions[s].type!==b?s++:(r.push(a.actions[s]),a.actions.splice(s,1))}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}(a),h=p.length?$(n,o,p,t):n,m=u?[n]:void 0,S=[];function x(a,l){var p;switch(l.type){case g:var x=function(e,t,n,r){var i,o={_event:n},a=te(J(e.event)?e.event(t,n.data,o):e.event);if(G(e.delay)){var s=r&&r[e.delay];i=J(s)?s(t,n.data,o):s}else i=J(e.delay)?e.delay(t,n.data,o):e.delay;return c(c({},e),{type:g,_event:a,delay:i})}(l,h,o,e.options.delays);return s&&"number"==typeof x.delay&&s(x,h,o),x;case y:var k=function(e,t,n,r){var i,o={_event:n},a=te(J(e.event)?e.event(t,n.data,o):e.event);if(G(e.delay)){var s=r&&r[e.delay];i=J(s)?s(t,n.data,o):s}else i=J(e.delay)?e.delay(t,n.data,o):e.delay;var u=J(e.to)?e.to(t,n.data,o):e.to;return c(c({},e),{to:u,_event:a,event:a.data,delay:i})}(l,h,o,e.options.delays);return s&&k.to!==i.Internal&&("entry"===a?S.push(k):s(k,h,o)),k;case w:var I=function(e,t,n){return c(c({},e),{value:G(e.expr)?e.expr:e.expr(t,n.data,{_event:n})})}(l,h,o);return null==s||s(I,h,o),I;case D:if(!(A=null===(p=l.conds.find((function(n){var r=Q(n.cond,e.options.guards);return!r||re(e,r,h,o,s?void 0:t)})))||void 0===p?void 0:p.actions))return[];var E=d(ye(e,t,h,o,[{type:a,actions:de(B(A),e.options.actions)}],s,u),2),O=E[0],R=E[1];return h=R,null==m||m.push(h),O;case T:var A;if(!(A=l.get(h,o.data)))return[];var M=d(ye(e,t,h,o,[{type:a,actions:de(B(A),e.options.actions)}],s,u),2),_=M[0],C=M[1];return h=C,null==m||m.push(h),_;case v:I=function(e,t,n){var i=J(e.activity)?e.activity(t,n.data):e.activity,o="string"==typeof i?{id:i}:i;return{type:r.Stop,activity:o}}(l,h,o);return null==s||s(I,n,o),I;case b:h=$(h,o,[l],s?void 0:t),null==m||m.push(h);break;default:var N=le(l,e.options.actions),P=N.exec;if(s)s(N,h,o);else if(P&&m){var j=m.length-1,U=c(c({},N),{exec:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];P.apply(void 0,f([m[j]],d(t),!1))}});N=U}return N}}var k=F(a.map((function(e){var t,n,r=[];try{for(var i=l(e.actions),a=i.next();!a.done;a=i.next()){var c=a.value,u=x(e.type,c);u&&(r=r.concat(u))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return S.forEach((function(e){s(e,h,o)})),S.length=0,r})));return[k,h]}var me=[],Se=function(e,t){me.push(e);var n=t(e);return me.pop(),n};function be(e){var t;return(t={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:e}}})[X]=function(){return this},t}function we(e,t,n){var r=be(t);if(r.deferred=!0,Z(e)){var i=r.state=Se(void 0,(function(){return(n?e.withContext(n):e).initialState}));r.getSnapshot=function(){return i}}return r}var xe=function(e){return"atomic"===e.type||"final"===e.type};function ke(e){return Object.keys(e.states).map((function(t){return e.states[t]}))}function Ie(e){return ke(e).filter((function(e){return"history"!==e.type}))}function Ee(e){var t=[e];return xe(e)?t:t.concat(F(Ie(e).map(Ee)))}function Oe(e,t){var n,r,i,o,a,s,c,u,d=Te(new Set(e)),f=new Set(t);try{for(var p=l(f),h=p.next();!h.done;h=p.next())for(var v=(I=h.value).parent;v&&!f.has(v);)f.add(v),v=v.parent}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}var g=Te(f);try{for(var y=l(f),m=y.next();!m.done;m=y.next()){if("compound"!==(I=m.value).type||g.get(I)&&g.get(I).length){if("parallel"===I.type)try{for(var S=(a=void 0,l(Ie(I))),b=S.next();!b.done;b=S.next()){var w=b.value;f.has(w)||(f.add(w),d.get(w)?d.get(w).forEach((function(e){return f.add(e)})):w.initialStateNodes.forEach((function(e){return f.add(e)})))}}catch(e){a={error:e}}finally{try{b&&!b.done&&(s=S.return)&&s.call(S)}finally{if(a)throw a.error}}}else d.get(I)?d.get(I).forEach((function(e){return f.add(e)})):I.initialStateNodes.forEach((function(e){return f.add(e)}))}}catch(e){i={error:e}}finally{try{m&&!m.done&&(o=y.return)&&o.call(y)}finally{if(i)throw i.error}}try{for(var x=l(f),k=x.next();!k.done;k=x.next()){var I;for(v=(I=k.value).parent;v&&!f.has(v);)f.add(v),v=v.parent}}catch(e){c={error:e}}finally{try{k&&!k.done&&(u=x.return)&&u.call(x)}finally{if(c)throw c.error}}return f}function De(e,t){var n=t.get(e);if(!n)return{};if("compound"===e.type){var r=n[0];if(!r)return{};if(xe(r))return r.key}var i={};return n.forEach((function(e){i[e.key]=De(e,t)})),i}function Te(e){var t,n,r=new Map;try{for(var i=l(e),o=i.next();!o.done;o=i.next()){var a=o.value;r.has(a)||r.set(a,[]),a.parent&&(r.has(a.parent)||r.set(a.parent,[]),r.get(a.parent).push(a))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}function Re(e,t){return De(e,Te(Oe([e],t)))}function Ae(e,t){return Array.isArray(e)?e.some((function(e){return e===t})):e instanceof Set&&e.has(t)}function Me(e,t){return"compound"===t.type?Ie(t).some((function(t){return"final"===t.type&&Ae(e,t)})):"parallel"===t.type&&Ie(t).every((function(t){return Me(e,t)}))}function _e(e){return new Set(F(e.map((function(e){return e.tags}))))}function Ce(e,t){if(e===t)return!0;if(void 0===e||void 0===t)return!1;if(G(e)||G(t))return e===t;var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((function(n){return Ce(e[n],t[n])}))}function Ne(e){return"object"==typeof e&&null!==e&&("value"in e&&"_event"in e)}var Pe=function(){function e(e){var t,n,r=this;this.actions=[],this.activities=R,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||R,this.meta=(void 0===(n=e.configuration)&&(n=[]),n.reduce((function(e,t){return void 0!==t.meta&&(e[t.id]=t.meta),e}),{})),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=null!==(t=Array.isArray(e.tags)?new Set(e.tags):e.tags)&&void 0!==t?t:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return function(e){return f([],d(new Set(F(f([],d(e.map((function(e){return e.ownEvents}))),!1)))),!1)}(r.configuration)}})}return e.from=function(t,n){return t instanceof e?t.context!==n?new e({value:t.value,context:n,_event:t._event,_sessionid:null,historyValue:t.historyValue,history:t.history,actions:[],activities:t.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):t:new e({value:t,context:n,_event:ce,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},e.create=function(t){return new e(t)},e.inert=function(t,n){if(t instanceof e){if(!t.actions.length)return t;var r=ce;return new e({value:t.value,context:n,_event:r,_sessionid:null,historyValue:t.historyValue,history:t.history,activities:t.activities,configuration:t.configuration,transitions:[],children:{}})}return e.from(t,n)},e.prototype.toStrings=function(e,t){var n=this;if(void 0===e&&(e=this.value),void 0===t&&(t="."),G(e))return[e];var r=Object.keys(e);return r.concat.apply(r,f([],d(r.map((function(r){return n.toStrings(e[r],t).map((function(e){return r+t+e}))}))),!1))},e.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var t=e.tags;e.machine;var n=u(e,["configuration","transitions","tags","machine"]);return c(c({},n),{tags:Array.from(t)})},e.prototype.matches=function(e){return M(e,this.value)},e.prototype.hasTag=function(e){return this.tags.has(e)},e.prototype.can=function(e){var t;W(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=null===(t=this.machine)||void 0===t?void 0:t.getTransitionData(this,e);return!!(null==n?void 0:n.transitions.length)&&n.transitions.some((function(e){return void 0!==e.target||e.actions.length}))},e}(),je={deferEvents:!1},Ue=function(){function e(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=c(c({},je),e)}return e.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents)return void this.schedule(e);this.process(e)}this.flushEvents()},e.prototype.schedule=function(e){if(this.initialized&&!this.processingEvent){if(0!==this.queue.length)throw new Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()}else this.queue.push(e)},e.prototype.clear=function(){this.queue=[]},e.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},e.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(e){throw this.clear(),e}finally{this.processingEvent=!1}},e}(),Le=new Map,Ve=0,Fe=function(){return"x:".concat(Ve++)},He=function(e,t){return Le.set(e,t),e},Be=function(e){return Le.get(e)},ze=function(e){Le.delete(e)};function qe(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n.g?n.g:void 0}function Ke(e){if(qe()){var t=function(){var e=qe();if(e&&"__xstate__"in e)return e.__xstate__}();t&&t.register(e)}}function $e(e,t){void 0===t&&(t={});var n=e.initialState,r=new Set,i=[],o=!1,a=function(e){var t;return c(((t={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}})[X]=function(){return this},t),e)}({id:t.id,send:function(t){i.push(t),function(){if(!o){for(o=!0;i.length>0;){var t=i.shift();n=e.transition(n,t,s),r.forEach((function(e){return e.next(n)}))}o=!1}}()},getSnapshot:function(){return n},subscribe:function(e,t,i){var o=oe(e,t,i);return r.add(o),o.next(n),{unsubscribe:function(){r.delete(o)}}}}),s={parent:t.parent,self:a,id:t.id||"anonymous",observers:r};return n=e.start?e.start(s):n,a}var We,Ye={sync:!1,autoForward:!1};!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(We||(We={}));var Je=function(){function e(t,n){void 0===n&&(n=e.defaultOptions);var o=this;this.machine=t,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=We.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(e,t){if(Y(e))return o.batch(e),o.state;var n=te(ee(e,t));if(o.status===We.Stopped)return o.state;if(o.status!==We.Running&&!o.options.deferEvents)throw new Error('Event "'.concat(n.name,'" was sent to uninitialized service "').concat(o.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ').concat(JSON.stringify(n.data)));return o.scheduler.schedule((function(){o.forward(n);var e=o._nextState(n);o.update(e,n)})),o._state},this.sendTo=function(e,t,n){var r,a=o.parent&&(t===i.Parent||o.parent.id===t),s=a?o.parent:G(t)?t===i.Internal?o:o.children.get(t)||Be(t):(r=t)&&"function"==typeof r.send?t:void 0;if(s)if("machine"in s){if(o.status!==We.Stopped||o.parent!==s||o.state.done){var u=c(c({},e),{name:e.name===E?"".concat(ge(o.id)):e.name,origin:o.sessionId});!n&&o.machine.config.predictableActionArguments?o._outgoingQueue.push([s,u]):s.send(u)}}else!n&&o.machine.config.predictableActionArguments?o._outgoingQueue.push([s,e.data]):s.send(e.data);else if(!a)throw new Error("Unable to send event to child '".concat(t,"' from service '").concat(o.id,"'."))},this._exec=function(e,t,n,i){void 0===i&&(i=o.machine.options.actions);var a=e.exec||ue(e.type,i),s=J(a)?a:a?a.exec:e.exec;if(s)try{return s(t,n.data,o.machine.config.predictableActionArguments?{action:e,_event:n}:{action:e,state:o.state,_event:n})}catch(e){throw o.parent&&o.parent.send({type:"xstate.error",data:e}),e}switch(e.type){case g:var c=e;o.defer(c);break;case y:var u=e;if("number"==typeof u.delay)return void o.defer(u);u.to?o.sendTo(u._event,u.to,n===ce):o.send(u._event);break;case m:o.cancel(e.sendId);break;case h:if(o.status!==We.Running)return;var l=e.activity;if(!o.machine.config.predictableActionArguments&&!o.state.activities[l.id||l.type])break;if(l.type===r.Invoke){var d=ie(l.src),f=o.machine.options.services?o.machine.options.services[d.type]:void 0,p=l.id,S=l.data;0;var b="autoForward"in l?l.autoForward:!!l.forward;if(!f)return void 0;var x=S?z(S,t,n):void 0;if("string"==typeof f)return;var k=J(f)?f(t,n.data,{data:x,src:d,meta:l.meta}):f;if(!k)return;var I=void 0;Z(k)&&(k=x?k.withContext(x):k,I={autoForward:b}),o.spawn(k,p,I)}else o.spawnActivity(l);break;case v:o.stopChild(e.activity.id);break;case w:var E=e,O=E.label,D=E.value;O?o.logger(O,D):o.logger(D)}};var a=c(c({},e.defaultOptions),n),s=a.clock,u=a.logger,l=a.parent,d=a.id,f=void 0!==d?d:t.id;this.id=f,this.logger=u,this.clock=s,this.parent=l,this.options=a,this.scheduler=new Ue({deferEvents:this.options.deferEvents}),this.sessionId=Fe()}return Object.defineProperty(e.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:Se(this,(function(){return e._initialState=e.machine.initialState,e._initialState}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.execute=function(e,t){var n,r;try{for(var i=l(e.actions),o=i.next();!o.done;o=i.next()){var a=o.value;this.exec(a,e,t)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype.update=function(e,t){var n,r,i,o,a,s,c,u,d=this;if(e._sessionid=this.sessionId,this._state=e,this.machine.config.predictableActionArguments&&t!==ce||!this.options.execute)for(var f=void 0;f=this._outgoingQueue.shift();)f[0].send(f[1]);else this.execute(this.state);if(this.children.forEach((function(e){d.state.children[e.id]=e})),this.devTools&&this.devTools.send(t.data,e),e.event)try{for(var p=l(this.eventListeners),h=p.next();!h.done;h=p.next()){(0,h.value)(e.event)}}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}try{for(var v=l(this.listeners),g=v.next();!g.done;g=v.next()){(0,g.value)(e,e.event)}}catch(e){i={error:e}}finally{try{g&&!g.done&&(o=v.return)&&o.call(v)}finally{if(i)throw i.error}}try{for(var y=l(this.contextListeners),m=y.next();!m.done;m=y.next()){(0,m.value)(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(e){a={error:e}}finally{try{m&&!m.done&&(s=y.return)&&s.call(y)}finally{if(a)throw a.error}}if(this.state.done){var S=e.configuration.find((function(e){return"final"===e.type&&e.parent===d.machine})),b=S&&S.doneData?z(S.doneData,e.context,t):void 0;this._doneEvent=ve(this.id,b);try{for(var w=l(this.doneListeners),x=w.next();!x.done;x=w.next()){(0,x.value)(this._doneEvent)}}catch(e){c={error:e}}finally{try{x&&!x.done&&(u=w.return)&&u.call(w)}finally{if(c)throw c.error}}this._stop(),this._stopChildren(),ze(this.sessionId)}},e.prototype.onTransition=function(e){return this.listeners.add(e),this.status===We.Running&&e(this.state,this.state.event),this},e.prototype.subscribe=function(e,t,n){var r=this,i=oe(e,t,n);this.listeners.add(i.next),this.status!==We.NotStarted&&i.next(this.state);var o=function(){r.doneListeners.delete(o),r.stopListeners.delete(o),i.complete()};return this.status===We.Stopped?i.complete():(this.onDone(o),this.onStop(o)),{unsubscribe:function(){r.listeners.delete(i.next),r.doneListeners.delete(o),r.stopListeners.delete(o)}}},e.prototype.onEvent=function(e){return this.eventListeners.add(e),this},e.prototype.onSend=function(e){return this.sendListeners.add(e),this},e.prototype.onChange=function(e){return this.contextListeners.add(e),this},e.prototype.onStop=function(e){return this.stopListeners.add(e),this},e.prototype.onDone=function(e){return this.status===We.Stopped&&this._doneEvent?e(this._doneEvent):this.doneListeners.add(e),this},e.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},e.prototype.start=function(e){var t=this;if(this.status===We.Running)return this;this.machine._init(),He(this.sessionId,this),this.initialized=!0,this.status=We.Running;var n=void 0===e?this.initialState:Se(this,(function(){return Ne(e)?t.machine.resolveState(e):t.machine.resolveState(Pe.from(e,t.machine.context))}));return this.options.devTools&&this.attachDev(),this.scheduler.initialize((function(){t.update(n,ce)})),this},e.prototype._stopChildren=function(){this.children.forEach((function(e){J(e.stop)&&e.stop()})),this.children.clear()},e.prototype._stop=function(){var e,t,n,r,i,o,a,s,c,u;try{for(var d=l(this.listeners),f=d.next();!f.done;f=d.next()){var p=f.value;this.listeners.delete(p)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}try{for(var h=l(this.stopListeners),v=h.next();!v.done;v=h.next()){(p=v.value)(),this.stopListeners.delete(p)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}try{for(var g=l(this.contextListeners),y=g.next();!y.done;y=g.next()){p=y.value;this.contextListeners.delete(p)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(i)throw i.error}}try{for(var m=l(this.doneListeners),S=m.next();!S.done;S=m.next()){p=S.value;this.doneListeners.delete(p)}}catch(e){a={error:e}}finally{try{S&&!S.done&&(s=m.return)&&s.call(m)}finally{if(a)throw a.error}}if(!this.initialized)return this;this.initialized=!1,this.status=We.Stopped,this._initialState=void 0;try{for(var b=l(Object.keys(this.delayedEventsMap)),w=b.next();!w.done;w=b.next()){var x=w.value;this.clock.clearTimeout(this.delayedEventsMap[x])}}catch(e){c={error:e}}finally{try{w&&!w.done&&(u=b.return)&&u.call(b)}finally{if(c)throw c.error}}this.scheduler.clear(),this.scheduler=new Ue({deferEvents:this.options.deferEvents})},e.prototype.stop=function(){var e=this,t=this.scheduler;return this._stop(),t.schedule((function(){var t;if(!(null===(t=e._state)||void 0===t?void 0:t.done)){var n=te({type:"xstate.stop"}),r=Se(e,(function(){var t=F(f([],d(e.state.configuration),!1).sort((function(e,t){return t.order-e.order})).map((function(t){return de(t.onExit,e.machine.options.actions)}))),r=d(ye(e.machine,e.state,e.state.context,n,[{type:"exit",actions:t}],e.machine.config.predictableActionArguments?e._exec:void 0,e.machine.config.predictableActionArguments||e.machine.config.preserveActionOrder),2),i=r[0],o=r[1],a=new Pe({value:e.state.value,context:o,_event:n,_sessionid:e.sessionId,historyValue:void 0,history:e.state,actions:i.filter((function(e){return!se(e)})),activities:{},events:[],configuration:[],transitions:[],children:{},done:e.state.done,tags:e.state.tags,machine:e.machine});return a.changed=!0,a}));e.update(r,n),e._stopChildren(),ze(e.sessionId)}})),this},e.prototype.batch=function(e){var t=this;if(this.status===We.NotStarted&&this.options.deferEvents)0;else if(this.status!==We.Running)throw new Error("".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));if(e.length){var n=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule((function(){var r,i,o=t.state,a=!1,s=[],u=function(e){var r=te(e);t.forward(r),o=Se(t,(function(){return t.machine.transition(o,r,void 0,n||void 0)})),s.push.apply(s,f([],d(t.machine.config.predictableActionArguments?o.actions:o.actions.map((function(e){return function(e,t){var n=e.exec;return c(c({},e),{exec:void 0!==n?function(){return n(t.context,t.event,{action:e,state:t,_event:t._event})}:void 0})}(e,o)}))),!1)),a=a||!!o.changed};try{for(var p=l(e),h=p.next();!h.done;h=p.next()){u(h.value)}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}o.changed=a,o.actions=s,t.update(o,te(e[e.length-1]))}))}},e.prototype.sender=function(e){return this.send.bind(this,e)},e.prototype._nextState=function(e,t){var n=this;void 0===t&&(t=!!this.machine.config.predictableActionArguments&&this._exec);var r=te(e);if(0===r.name.indexOf(I)&&!this.state.nextEvents.some((function(e){return 0===e.indexOf(I)})))throw r.data.data;return Se(this,(function(){return n.machine.transition(n.state,r,void 0,t||void 0)}))},e.prototype.nextState=function(e){return this._nextState(e,!1)},e.prototype.forward=function(e){var t,n;try{for(var r=l(this.forwardTo),i=r.next();!i.done;i=r.next()){var o=i.value,a=this.children.get(o);if(!a)throw new Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(o,"'."));a.send(e)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},e.prototype.defer=function(e){var t=this,n=this.clock.setTimeout((function(){"to"in e&&e.to?t.sendTo(e._event,e.to,!0):t.send(e._event)}),e.delay);e.id&&(this.delayedEventsMap[e.id]=n)},e.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},e.prototype.exec=function(e,t,n){void 0===n&&(n=this.machine.options.actions),this._exec(e,t.context,t._event,n)},e.prototype.removeChild=function(e){var t;this.children.delete(e),this.forwardTo.delete(e),null===(t=this.state)||void 0===t||delete t.children[e]},e.prototype.stopChild=function(e){var t=this.children.get(e);t&&(this.removeChild(e),J(t.stop)&&t.stop())},e.prototype.spawn=function(e,t,n){if(this.status!==We.Running)return we(e,t);if(q(e))return this.spawnPromise(Promise.resolve(e),t);if(J(e))return this.spawnCallback(e,t);if(function(e){try{return"function"==typeof e.send}catch(e){return!1}}(i=e)&&"id"in i)return this.spawnActor(e,t);if(function(e){try{return"subscribe"in e&&J(e.subscribe)}catch(e){return!1}}(e))return this.spawnObservable(e,t);if(Z(e))return this.spawnMachine(e,c(c({},n),{id:t}));if(null!==(r=e)&&"object"==typeof r&&"transition"in r&&"function"==typeof r.transition)return this.spawnBehavior(e,t);throw new Error('Unable to spawn entity "'.concat(t,'" of type "').concat(typeof e,'".'));var r,i},e.prototype.spawnMachine=function(t,n){var r=this;void 0===n&&(n={});var i=new e(t,c(c({},this.options),{parent:this,id:n.id||t.id})),o=c(c({},Ye),n);o.sync&&i.onTransition((function(e){r.send(O,{state:e,id:i.id})}));var a=i;return this.children.set(i.id,a),o.autoForward&&this.forwardTo.add(i.id),i.onDone((function(e){r.removeChild(i.id),r.send(te(e,{origin:i.id}))})).start(),a},e.prototype.spawnBehavior=function(e,t){var n=$e(e,{id:t,parent:this});return this.children.set(t,n),n},e.prototype.spawnPromise=function(e,t){var n,r,i=this,o=!1;e.then((function(e){o||(r=e,i.removeChild(t),i.send(te(ve(t,e),{origin:t})))}),(function(e){if(!o){i.removeChild(t);var n=ge(t,e);try{i.send(te(n,{origin:t}))}catch(e){i.devTools&&i.devTools.send(n,i.state),i.machine.strict&&i.stop()}}}));var a=((n={id:t,send:function(){},subscribe:function(t,n,r){var i=oe(t,n,r),o=!1;return e.then((function(e){o||(i.next(e),o||i.complete())}),(function(e){o||i.error(e)})),{unsubscribe:function(){return o=!0}}},stop:function(){o=!0},toJSON:function(){return{id:t}},getSnapshot:function(){return r}})[X]=function(){return this},n);return this.children.set(t,a),a},e.prototype.spawnCallback=function(e,t){var n,r,i,o=this,a=!1,s=new Set,c=new Set;try{i=e((function(e){r=e,c.forEach((function(t){return t(e)})),a||o.send(te(e,{origin:t}))}),(function(e){s.add(e)}))}catch(e){this.send(ge(t,e))}if(q(i))return this.spawnPromise(i,t);var u=((n={id:t,send:function(e){return s.forEach((function(t){return t(e)}))},subscribe:function(e){var t=oe(e);return c.add(t.next),{unsubscribe:function(){c.delete(t.next)}}},stop:function(){a=!0,J(i)&&i()},toJSON:function(){return{id:t}},getSnapshot:function(){return r}})[X]=function(){return this},n);return this.children.set(t,u),u},e.prototype.spawnObservable=function(e,t){var n,r,i=this,o=e.subscribe((function(e){r=e,i.send(te(e,{origin:t}))}),(function(e){i.removeChild(t),i.send(te(ge(t,e),{origin:t}))}),(function(){i.removeChild(t),i.send(te(ve(t),{origin:t}))})),a=((n={id:t,send:function(){},subscribe:function(t,n,r){return e.subscribe(t,n,r)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return r},toJSON:function(){return{id:t}}})[X]=function(){return this},n);return this.children.set(t,a),a},e.prototype.spawnActor=function(e,t){return this.children.set(t,e),e},e.prototype.spawnActivity=function(e){var t=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(t){var n=t(this.state.context,e);this.spawnEffect(e.id,n)}},e.prototype.spawnEffect=function(e,t){var n;this.children.set(e,((n={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:t||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}})[X]=function(){return this},n))},e.prototype.attachDev=function(){var e=qe();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var t="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect(c(c({name:this.id,autoPause:!0,stateSanitizer:function(e){return{value:e.value,context:e.context,actions:e.actions}}},t),{features:c({jump:!1,skip:!1},t?t.features:void 0)}),this.machine),this.devTools.init(this.state)}Ke(this)}},e.prototype.toJSON=function(){return{id:this.id}},e.prototype[X]=function(){return this},e.prototype.getSnapshot=function(){return this.status===We.NotStarted?this.initialState:this._state},e.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,t){return setTimeout(e,t)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},e.interpret=Ge,e}();function Ge(e,t){return new Je(e,t)}function Qe(e){if("string"==typeof e){var t={type:e,toString:function(){return e}};return t}return e}function Xe(e){return c(c({type:k},e),{toJSON:function(){e.onDone,e.onError;var t=u(e,["onDone","onError"]);return c(c({},t),{type:k,src:Qe(e.src)})}})}var Ze="",et="*",tt={},nt=function(e){return"#"===e[0]},rt=function(){function e(t,n,r,i){void 0===r&&(r="context"in t?t.context:void 0);var o,a=this;this.config=t,this._context=r,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign({actions:{},guards:{},services:{},activities:{},delays:{}},n),this.parent=null==i?void 0:i.parent,this.key=this.config.key||(null==i?void 0:i.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:"."),this.id=this.config.id||f([this.machine.key],d(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:null!==(o=this.config.schema)&&void 0!==o?o:{},this.description=this.config.description,this.initial=this.config.initial,this.states=this.config.states?j(this.config.states,(function(t,n){var r,i=new e(t,{},void 0,{parent:a,key:n});return Object.assign(a.idMap,c(((r={})[i.id]=i,r),i.idMap)),i})):tt;var s=0;!function e(t){var n,r;t.order=s++;try{for(var i=l(ke(t)),o=i.next();!o.done;o=i.next()){e(o.value)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}(this),this.history=!0===this.config.history?"shallow":this.config.history||!1,this._transient=!!this.config.always||!!this.config.on&&(Array.isArray(this.config.on)?this.config.on.some((function(e){return e.event===Ze})):Ze in this.config.on),this.strict=!!this.config.strict,this.onEntry=B(this.config.entry||this.config.onEntry).map((function(e){return le(e)})),this.onExit=B(this.config.exit||this.config.onExit).map((function(e){return le(e)})),this.meta=this.config.meta,this.doneData="final"===this.type?this.config.data:void 0,this.invoke=B(this.config.invoke).map((function(e,t){var n,r;if(Z(e)){var i=ae(a.id,t);return a.machine.options.services=c(((n={})[i]=e,n),a.machine.options.services),Xe({src:i,id:i})}if(G(e.src)){i=e.id||ae(a.id,t);return Xe(c(c({},e),{id:i,src:e.src}))}if(Z(e.src)||J(e.src)){i=e.id||ae(a.id,t);return a.machine.options.services=c(((r={})[i]=e.src,r),a.machine.options.services),Xe(c(c({id:i},e),{src:i}))}var o=e.src;return Xe(c(c({id:ae(a.id,t)},e),{src:o}))})),this.activities=B(this.config.activities).concat(this.invoke).map((function(e){return fe(e)})),this.transition=this.transition.bind(this),this.tags=B(this.config.tags)}return e.prototype._init=function(){this.__cache.transitions||Ee(this).forEach((function(e){return e.on}))},e.prototype.withConfig=function(t,n){var r=this.options,i=r.actions,o=r.activities,a=r.guards,s=r.services,u=r.delays;return new e(this.config,{actions:c(c({},i),t.actions),activities:c(c({},o),t.activities),guards:c(c({},a),t.guards),services:c(c({},s),t.services),delays:c(c({},u),t.delays)},null!=n?n:this.context)},e.prototype.withContext=function(t){return new e(this.config,this.options,t)},Object.defineProperty(e.prototype,"context",{get:function(){return J(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:j(this.states,(function(e){return e.definition})),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){return this.definition},Object.defineProperty(e.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce((function(e,t){return e[t.eventType]=e[t.eventType]||[],e[t.eventType].push(t),e}),{})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),e.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var t=e===Ze,n=this.transitions.filter((function(n){var r=n.eventType===e;return t?r:r||n.eventType===et}));return this.__cache.candidates[e]=n,n},e.prototype.getDelayedTransitions=function(){var e=this,t=this.config.after;if(!t)return[];var n=function(t,n){var i=function(e,t){var n=t?"#".concat(t):"";return"".concat(r.After,"(").concat(e,")").concat(n)}(J(t)?"".concat(e.id,":delay[").concat(n,"]"):t,e.id);return e.onEntry.push(pe(i,{delay:t})),e.onExit.push({type:m,sendId:i}),i};return(Y(t)?t.map((function(e,t){var r=n(e.delay,t);return c(c({},e),{event:r})})):F(Object.keys(t).map((function(e,r){var i=t[e],o=G(i)?{target:i}:i,a=isNaN(+e)?e:+e,s=n(a,r);return B(o).map((function(e){return c(c({},e),{event:s,delay:a})}))})))).map((function(t){var n=t.delay;return c(c({},e.formatTransition(t)),{delay:n})}))},e.prototype.getStateNodes=function(e){var t,n=this;if(!e)return[];var r=e instanceof Pe?e.value:N(e,this.delimiter);if(G(r)){var i=this.getStateNode(r).initial;return void 0!==i?this.getStateNodes(((t={})[r]=i,t)):[this,this.states[r]]}var o=Object.keys(r),a=[this];return a.push.apply(a,f([],d(F(o.map((function(e){return n.getStateNode(e).getStateNodes(r[e])})))),!1)),a},e.prototype.handles=function(e){var t=_(e);return this.events.includes(t)},e.prototype.resolveState=function(e){var t=e instanceof Pe?e:Pe.create(e),n=Array.from(Oe([],this.getStateNodes(t.value)));return new Pe(c(c({},t),{value:this.resolve(t.value),configuration:n,done:Me(n,this),tags:_e(n),machine:this.machine}))},e.prototype.transitionLeafNode=function(e,t,n){var r=this.getStateNode(e).next(t,n);return r&&r.transitions.length?r:this.next(t,n)},e.prototype.transitionCompoundNode=function(e,t,n){var r=Object.keys(e),i=this.getStateNode(r[0])._transition(e[r[0]],t,n);return i&&i.transitions.length?i:this.next(t,n)},e.prototype.transitionParallelNode=function(e,t,n){var r,i,o={};try{for(var a=l(Object.keys(e)),s=a.next();!s.done;s=a.next()){var c=s.value,u=e[c];if(u){var d=this.getStateNode(c)._transition(u,t,n);d&&(o[c]=d)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}var f=Object.keys(o).map((function(e){return o[e]})),p=F(f.map((function(e){return e.transitions})));if(!f.some((function(e){return e.transitions.length>0})))return this.next(t,n);var h=F(Object.keys(o).map((function(e){return o[e].configuration})));return{transitions:p,exitSet:F(f.map((function(e){return e.exitSet}))),configuration:h,source:t,actions:F(Object.keys(o).map((function(e){return o[e].actions})))}},e.prototype._transition=function(e,t,n){return G(e)?this.transitionLeafNode(e,t,n):1===Object.keys(e).length?this.transitionCompoundNode(e,t,n):this.transitionParallelNode(e,t,n)},e.prototype.getTransitionData=function(e,t){return this._transition(e.value,e,te(t))},e.prototype.next=function(e,t){var n,r,i,o=this,a=t.name,s=[],c=[];try{for(var u=l(this.getCandidates(a)),p=u.next();!p.done;p=u.next()){var h=p.value,v=h.cond,g=h.in,y=e.context,m=!g||(G(g)&&nt(g)?e.matches(N(this.getStateNodeById(g).path,this.delimiter)):M(N(g,this.delimiter),L(this.path.slice(0,-2))(e.value))),S=!1;try{S=!v||re(this.machine,v,y,t,e)}catch(e){throw new Error("Unable to evaluate guard '".concat(v.name||v.type,"' in transition for event '").concat(a,"' in state node '").concat(this.id,"':\n").concat(e.message))}if(S&&m){void 0!==h.target&&(c=h.target),s.push.apply(s,f([],d(h.actions),!1)),i=h;break}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}if(i){if(!c.length)return{transitions:[i],exitSet:[],configuration:e.value?[this]:[],source:e,actions:s};var b=F(c.map((function(t){return o.getRelativeStateNodes(t,e.historyValue)})));return{transitions:[i],exitSet:!!i.internal?[]:F(c.map((function(e){return o.getPotentiallyReenteringNodes(e)}))),configuration:b,source:e,actions:s}}},e.prototype.getPotentiallyReenteringNodes=function(e){if(this.order<e.order)return[this];for(var t=[],n=this,r=e;n&&n!==r;)t.push(n),n=n.parent;return n!==r?[]:(t.push(r),t)},e.prototype.getActions=function(e,t,n,i,o,a,s){var c,u,p,h,v=this,y=a?Oe([],this.getStateNodes(a.value)):[],m=new Set;try{for(var S=l(Array.from(e).sort((function(e,t){return e.order-t.order}))),b=S.next();!b.done;b=S.next()){(!Ae(y,k=b.value)||Ae(n.exitSet,k)||k.parent&&m.has(k.parent))&&m.add(k)}}catch(e){c={error:e}}finally{try{b&&!b.done&&(u=S.return)&&u.call(S)}finally{if(c)throw c.error}}try{for(var w=l(y),x=w.next();!x.done;x=w.next()){var k;Ae(e,k=x.value)&&!Ae(n.exitSet,k.parent)||n.exitSet.push(k)}}catch(e){p={error:e}}finally{try{x&&!x.done&&(h=w.return)&&h.call(w)}finally{if(p)throw p.error}}n.exitSet.sort((function(e,t){return t.order-e.order}));var I=Array.from(m).sort((function(e,t){return e.order-t.order})),E=new Set(n.exitSet),O=F(I.map((function(e){var t=[];if("final"!==e.type)return t;var r=e.parent;if(!r.parent)return t;t.push(he(e.id,e.doneData),he(r.id,e.doneData?z(e.doneData,i,o):void 0));var a=r.parent;return"parallel"===a.type&&Ie(a).every((function(e){return Me(n.configuration,e)}))&&t.push(he(a.id)),t}))),D=I.map((function(e){var t=e.onEntry,n=e.activities.map((function(e){return function(e){var t=fe(e);return{type:r.Start,activity:t,exec:void 0}}(e)}));return{type:"entry",actions:de(s?f(f([],d(t),!1),d(n),!1):f(f([],d(n),!1),d(t),!1),v.machine.options.actions)}})).concat({type:"state_done",actions:O.map((function(e){return function(e,t){return{type:g,event:"function"==typeof e?e:ee(e),delay:t?t.delay:void 0,id:null==t?void 0:t.id}}(e)}))}),T=Array.from(E).map((function(e){return{type:"exit",actions:de(f(f([],d(e.onExit),!1),d(e.activities.map((function(e){return function(e){var t=J(e)?e:fe(e);return{type:r.Stop,activity:t,exec:void 0}}(e)}))),!1),v.machine.options.actions)}})).concat({type:"transition",actions:de(n.actions,this.machine.options.actions)}).concat(D);if(t){var R=de(F(f([],d(e),!1).sort((function(e,t){return t.order-e.order})).map((function(e){return e.onExit}))),this.machine.options.actions).filter((function(e){return!se(e)}));return T.concat({type:"stop",actions:R})}return T},e.prototype.transition=function(e,t,n,r){void 0===e&&(e=this.initialState);var i,o,a=te(t);if(e instanceof Pe)i=void 0===n?e:this.resolveState(Pe.from(e,n));else{var s=G(e)?this.resolve(P(this.getResolvedPath(e))):this.resolve(e),c=null!=n?n:this.machine.context;i=this.resolveState(Pe.from(s,c))}if(this.strict&&!this.events.includes(a.name)&&(o=a.name,!/^(done|error)\./.test(o)))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(a.name,"'"));var u=this._transition(i.value,i,a)||{transitions:[],configuration:[],exitSet:[],source:i,actions:[]},l=Oe([],this.getStateNodes(i.value)),p=u.configuration.length?Oe(l,u.configuration):l;return u.configuration=f([],d(p),!1),this.resolveTransition(u,i,i.context,r,a)},e.prototype.resolveRaisedTransition=function(e,t,n,r){var i,o=e.actions;return(e=this.transition(e,t,void 0,r))._event=n,e.event=n.data,(i=e.actions).unshift.apply(i,f([],d(o),!1)),e},e.prototype.resolveTransition=function(e,t,n,r,i){var o,a,s,u,f=this;void 0===i&&(i=ce);var p=e.configuration,g=!t||e.transitions.length>0,y=g?e.configuration:t?t.configuration:[],m=Me(y,this),b=g?Re(this.machine,p):void 0,w=t?t.historyValue?t.historyValue:e.source?this.machine.historyValue(t.value):void 0:void 0,x=this.getActions(new Set(y),m,e,n,i,t,r),I=t?c({},t.activities):{};try{for(var E=l(x),D=E.next();!D.done;D=E.next()){var T=D.value;try{for(var R=(s=void 0,l(T.actions)),A=R.next();!A.done;A=R.next()){var M=A.value;M.type===h?I[M.activity.id||M.activity.type]=M:M.type===v&&(I[M.activity.id||M.activity.type]=!1)}}catch(e){s={error:e}}finally{try{A&&!A.done&&(u=R.return)&&u.call(R)}finally{if(s)throw s.error}}}}catch(e){o={error:e}}finally{try{D&&!D.done&&(a=E.return)&&a.call(E)}finally{if(o)throw o.error}}var _,C,N=d(ye(this,t,n,i,x,r,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),P=N[0],j=N[1],U=d(function(e,t){var n,r,i=d([[],[]],2),o=i[0],a=i[1];try{for(var s=l(e),c=s.next();!c.done;c=s.next()){var u=c.value;t(u)?o.push(u):a.push(u)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return[o,a]}(P,se),2),L=U[0],V=U[1],F=P.filter((function(e){var t;return e.type===h&&(null===(t=e.activity)||void 0===t?void 0:t.type)===k})),H=F.reduce((function(e,t){return e[t.activity.id]=function(e,t,n,r){var i,o=ie(e.src),a=null===(i=null==t?void 0:t.options.services)||void 0===i?void 0:i[o.type],s=e.data?z(e.data,n,r):void 0,c=a?we(a,e.id,s):be(e.id);return c.meta=e,c}(t.activity,f.machine,j,i),e}),t?c({},t.children):{}),B=new Pe({value:b||t.value,context:j,_event:i,_sessionid:t?t._sessionid:null,historyValue:b?w?(_=w,C=b,{current:C,states:K(_,C)}):void 0:t?t.historyValue:void 0,history:!b||e.source?t:void 0,actions:b?V:[],activities:b?I:t?t.activities:{},events:[],configuration:y,transitions:e.transitions,children:H,done:m,tags:_e(y),machine:this}),q=n!==j;B.changed=i.name===O||q;var $=B.history;$&&delete $.history;var W=!m&&(this._transient||p.some((function(e){return e._transient})));if(!(g||W&&i.name!==Ze))return B;var Y=B;if(!m)for(W&&(Y=this.resolveRaisedTransition(Y,{type:S},i,r));L.length;){var J=L.shift();Y=this.resolveRaisedTransition(Y,J._event,i,r)}var G=Y.changed||($?!!Y.actions.length||q||typeof $.value!=typeof Y.value||!Ce(Y.value,$.value):void 0);return Y.changed=G,Y.history=$,Y},e.prototype.getStateNode=function(e){if(nt(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var t=this.states[e];if(!t)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return t},e.prototype.getStateNodeById=function(e){var t=nt(e)?e.slice(1):e;if(t===this.id)return this;var n=this.machine.idMap[t];if(!n)throw new Error("Child state node '#".concat(t,"' does not exist on machine '").concat(this.id,"'"));return n},e.prototype.getStateNodeByPath=function(e){if("string"==typeof e&&nt(e))try{return this.getStateNodeById(e.slice(1))}catch(e){}for(var t=C(e,this.delimiter).slice(),n=this;t.length;){var r=t.shift();if(!r.length)break;n=n.getStateNode(r)}return n},e.prototype.resolve=function(e){var t,n=this;if(!e)return this.initialStateValue||tt;switch(this.type){case"parallel":return j(this.initialStateValue,(function(t,r){return t?n.getStateNode(r).resolve(e[r]||t):tt}));case"compound":if(G(e)){var r=this.getStateNode(e);return"parallel"===r.type||"compound"===r.type?((t={})[e]=r.initialStateValue,t):e}return Object.keys(e).length?j(e,(function(e,t){return e?n.getStateNode(t).resolve(e):tt})):this.initialStateValue||{};default:return e||tt}},e.prototype.getResolvedPath=function(e){if(nt(e)){var t=this.machine.idMap[e.slice(1)];if(!t)throw new Error("Unable to find state node '".concat(e,"'"));return t.path}return C(e,this.delimiter)},Object.defineProperty(e.prototype,"initialStateValue",{get:function(){var e,t;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;if("parallel"===this.type)t=U(this.states,(function(e){return e.initialStateValue||tt}),(function(e){return!("history"===e.type)}));else if(void 0!==this.initial){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));t=xe(this.states[this.initial])?this.initial:((e={})[this.initial]=this.states[this.initial].initialStateValue,e)}else t={};return this.__cache.initialStateValue=t,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),e.prototype.getInitialState=function(e,t){this._init();var n=this.getStateNodes(e);return this.resolveTransition({configuration:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,null!=t?t:this.machine.context,void 0)},Object.defineProperty(e.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){var e;if("history"===this.type){var t=this.config;e=G(t.target)&&nt(t.target)?P(this.machine.getStateNodeById(t.target).path.slice(this.path.length-1)):t.target}return e},enumerable:!1,configurable:!0}),e.prototype.getRelativeStateNodes=function(e,t,n){return void 0===n&&(n=!0),n?"history"===e.type?e.resolveHistory(t):e.initialStateNodes:[e]},Object.defineProperty(e.prototype,"initialStateNodes",{get:function(){var e=this;return xe(this)?[this]:"compound"!==this.type||this.initial?F(V(this.initialStateValue).map((function(t){return e.getFromRelativePath(t)}))):[this]},enumerable:!1,configurable:!0}),e.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var t=d(e),n=t[0],r=t.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(n,"' from node with no states"));var i=this.getStateNode(n);if("history"===i.type)return i.resolveHistory();if(!this.states[n])throw new Error("Child state '".concat(n,"' does not exist on '").concat(this.id,"'"));return this.states[n].getFromRelativePath(r)},e.prototype.historyValue=function(e){if(Object.keys(this.states).length)return{current:e||this.initialStateValue,states:U(this.states,(function(t,n){if(!e)return t.historyValue();var r=G(e)?void 0:e[n];return t.historyValue(r||t.initialStateValue)}),(function(e){return!e.history}))}},e.prototype.resolveHistory=function(e){var t=this;if("history"!==this.type)return[this];var n=this.parent;if(!e){var r=this.target;return r?F(V(r).map((function(e){return n.getFromRelativePath(e)}))):n.initialStateNodes}var i,o,a=(i=n.path,o="states",function(e){var t,n,r=e;try{for(var a=l(i),s=a.next();!s.done;s=a.next()){var c=s.value;r=r[o][c]}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return r})(e).current;return G(a)?[n.getStateNode(a)]:F(V(a).map((function(e){return"deep"===t.history?n.getFromRelativePath(e):[n.states[e[0]]]})))},Object.defineProperty(e.prototype,"stateIds",{get:function(){var e=this,t=F(Object.keys(this.states).map((function(t){return e.states[t].stateIds})));return[this.id].concat(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"events",{get:function(){var e,t,n,r;if(this.__cache.events)return this.__cache.events;var i=this.states,o=new Set(this.ownEvents);if(i)try{for(var a=l(Object.keys(i)),s=a.next();!s.done;s=a.next()){var c=i[s.value];if(c.states)try{for(var u=(n=void 0,l(c.events)),d=u.next();!d.done;d=u.next()){var f=d.value;o.add("".concat(f))}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(o)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter((function(e){return!(!e.target&&!e.actions.length&&e.internal)})).map((function(e){return e.eventType})));return Array.from(e)},enumerable:!1,configurable:!0}),e.prototype.resolveTarget=function(e){var t=this;if(void 0!==e)return e.map((function(e){if(!G(e))return e;var n=e[0]===t.delimiter;if(n&&!t.parent)return t.getStateNodeByPath(e.slice(1));var r=n?t.key+e:e;if(!t.parent)return t.getStateNodeByPath(r);try{return t.parent.getStateNodeByPath(r)}catch(e){throw new Error("Invalid transition definition for state node '".concat(t.id,"':\n").concat(e.message))}}))},e.prototype.formatTransition=function(e){var t=this,n=function(e){if(void 0!==e&&""!==e)return B(e)}(e.target),r="internal"in e?e.internal:!n||n.some((function(e){return G(e)&&e[0]===t.delimiter})),i=this.machine.options.guards,o=this.resolveTarget(n),a=c(c({},e),{actions:de(B(e.actions)),cond:Q(e.cond,i),target:o,source:this,internal:r,eventType:e.event,toJSON:function(){return c(c({},a),{target:a.target?a.target.map((function(e){return"#".concat(e.id)})):void 0,source:"#".concat(t.id)})}});return a},e.prototype.formatTransitions=function(){var e,t,n,r=this;if(this.config.on)if(Array.isArray(this.config.on))n=this.config.on;else{var i=this.config.on,o=et,a=i[o],s=void 0===a?[]:a,c=u(i,["*"]);n=F(Object.keys(c).map((function(e){var t=ne(e,c[e]);return t})).concat(ne(et,s)))}else n=[];var p=this.config.always?ne("",this.config.always):[],h=this.config.onDone?ne(String(he(this.id)),this.config.onDone):[];var v=F(this.invoke.map((function(e){var t=[];return e.onDone&&t.push.apply(t,f([],d(ne(String(ve(e.id)),e.onDone)),!1)),e.onError&&t.push.apply(t,f([],d(ne(String(ge(e.id)),e.onError)),!1)),t}))),g=this.after,y=F(f(f(f(f([],d(h),!1),d(v),!1),d(n),!1),d(p),!1).map((function(e){return B(e).map((function(e){return r.formatTransition(e)}))})));try{for(var m=l(g),S=m.next();!S.done;S=m.next()){var b=S.value;y.push(b)}}catch(t){e={error:t}}finally{try{S&&!S.done&&(t=m.return)&&t.call(m)}finally{if(e)throw e.error}}return y},e}();var it=function(e){return{type:b,assignment:e}},ot=n(100),at=o.useLayoutEffect;function st(e){var t=o.useRef();return t.current||(t.current={v:e()}),t.current.v}var ct=function(){return ct=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ct.apply(this,arguments)},ut=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n};function lt(e,t){var n=st((function(){return"function"==typeof e?e():e})),r=t.context,i=t.guards,o=t.actions,a=t.activities,s=t.services,c=t.delays,u=(t.state,ut(t,["context","guards","actions","activities","services","delays","state"])),l=st((function(){var e={context:r,guards:i,actions:o,activities:a,services:s,delays:c};return Ge(n.withConfig(e,(function(){return ct(ct({},n.context),r)})),u)}));return at((function(){Object.assign(l.machine.options.actions,o),Object.assign(l.machine.options.guards,i),Object.assign(l.machine.options.activities,a),Object.assign(l.machine.options.services,s),Object.assign(l.machine.options.delays,c)}),[o,i,a,s,c]),l}var dt=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a};function ft(e){return e}function pt(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=dt(t,1)[0],i=void 0===r?{}:r,a=lt(e,i),s=(0,o.useCallback)((function(){return a.status===We.NotStarted?i.state?Pe.create(i.state):a.machine.initialState:a.getSnapshot()}),[a]),c=(0,o.useCallback)((function(e,t){return function(e,t,n){if(e.status===We.NotStarted)return!0;var r=void 0===n.changed&&(Object.keys(n.children).length>0||"boolean"==typeof t.changed);return!(n.changed||r)}(a,e,t)}),[a]),u=(0,o.useCallback)((function(e){return a.subscribe(e).unsubscribe}),[a]),l=(0,ot.useSyncExternalStoreWithSelector)(u,s,s,ft,c);return(0,o.useEffect)((function(){var e=i.state;return a.start(e?Pe.create(e):void 0),function(){a.stop(),a.status=We.NotStarted}}),[]),[l,a.send,a]}var ht=n(55);const vt=-1,gt=0,yt=1,mt=2,St=3,bt=4,wt=5,xt={id:"measurementTracking",initial:"idle",context:{activeViewportId:null,trackedStudy:"",trackedSeries:[],ignoredSeries:[],prevTrackedStudy:"",prevTrackedSeries:[],prevIgnoredSeries:[],ignoredSRSeriesForHydration:[],isDirty:!1},states:{off:{type:"final"},labellingOnly:{on:{TRACK_SERIES:[{target:"promptLabelAnnotation",actions:["setPreviousState"]},{target:"off"}]}},idle:{entry:"clearContext",on:{TRACK_SERIES:[{target:"promptLabelAnnotation",cond:"isLabelOnMeasure",actions:["setPreviousState"]},{target:"promptBeginTracking",actions:["setPreviousState"]}],SET_TRACKED_SERIES:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries","setIsDirtyToClean"]}],PROMPT_HYDRATE_SR:{target:"promptHydrateStructuredReport",cond:"hasNotIgnoredSRSeriesForHydration"},RESTORE_PROMPT_HYDRATE_SR:"promptHydrateStructuredReport",HYDRATE_SR:"hydrateStructuredReport",UPDATE_ACTIVE_VIEWPORT_ID:{actions:it({activeViewportId:(e,t)=>t.activeViewportId})}}},promptBeginTracking:{invoke:{src:"promptBeginTracking",onDone:[{target:"tracking",actions:["setTrackedStudyAndSeries","setIsDirty"],cond:"shouldSetStudyAndSeries"},{target:"labellingOnly",cond:"isLabelOnMeasureAndShouldKillMachine"},{target:"off",cond:"shouldKillMachine"},{target:"idle"}],onError:{target:"idle"}}},tracking:{on:{TRACK_SERIES:[{target:"promptLabelAnnotation",cond:"isLabelOnMeasure",actions:["setPreviousState"]},{target:"promptTrackNewStudy",cond:"isNewStudy"},{target:"promptTrackNewSeries",cond:"isNewSeries"}],UNTRACK_SERIES:[{target:"tracking",actions:["removeTrackedSeries","setIsDirty","clearDisplaySetHydratedState"],cond:"hasRemainingTrackedSeries"},{target:"idle"}],UNTRACK_ALL:[{target:"tracking",actions:["clearContext","setIsDirtyToClean","clearDisplaySetHydratedState","clearAllMeasurements"]},{target:"idle"}],SET_TRACKED_SERIES:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries"]}],SAVE_REPORT:"promptSaveReport",SET_DIRTY:[{target:"tracking",actions:["setIsDirty"],cond:"shouldSetDirty"},{target:"tracking"}],CHECK_DIRTY:{target:"promptHasDirtyAnnotations",cond:"hasDirtyAndSimplified"},PROMPT_HYDRATE_SR:{target:"promptHydrateStructuredReport",cond:"isSimplifiedConfig",actions:["clearAllMeasurements","clearDisplaySetHydratedState"]}}},promptTrackNewSeries:{invoke:{src:"promptTrackNewSeries",onDone:[{target:"tracking",actions:["addTrackedSeries","setIsDirty"],cond:"shouldAddSeries"},{target:"tracking",actions:["discardPreviouslyTrackedMeasurements","setTrackedStudyAndSeries","setIsDirty"],cond:"shouldSetStudyAndSeries"},{target:"promptSaveReport",cond:"shouldPromptSaveReport"},{target:"tracking"}],onError:{target:"idle"}}},promptTrackNewStudy:{invoke:{src:"promptTrackNewStudy",onDone:[{target:"tracking",actions:["discardPreviouslyTrackedMeasurements","setTrackedStudyAndSeries","setIsDirty"],cond:"shouldSetStudyAndSeries"},{target:"tracking",actions:["ignoreSeries"],cond:"shouldAddIgnoredSeries"},{target:"promptSaveReport",cond:"shouldPromptSaveReport"},{target:"tracking"}],onError:{target:"idle"}}},promptSaveReport:{invoke:{src:"promptSaveReport",onDone:[{target:"tracking",actions:["clearAllMeasurements","clearDisplaySetHydratedState","setIsDirty","updatedViewports"],cond:"simplifiedAndLoadSR"},{target:"idle",actions:["clearAllMeasurements","showStructuredReportDisplaySetInActiveViewport"],cond:"shouldSaveAndContinueWithSameReport"},{target:"tracking",actions:["discardPreviouslyTrackedMeasurements","setTrackedStudyAndSeries"],cond:"shouldSaveAndStartNewReport"},{target:"tracking"}],onError:{target:"idle"}}},promptHydrateStructuredReport:{invoke:{src:"promptHydrateStructuredReport",onDone:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries","jumpToSameImageInActiveViewport","setIsDirtyToClean"],cond:"shouldHydrateStructuredReport"},{target:"idle",actions:["ignoreHydrationForSRSeries"],cond:"shouldIgnoreHydrationForSR"}],onError:{target:"idle"}}},hydrateStructuredReport:{invoke:{src:"hydrateStructuredReport",onDone:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries","jumpToSameImageInActiveViewport","setIsDirtyToClean"]}],onError:{target:"idle"}}},promptLabelAnnotation:{invoke:{src:"promptLabelAnnotation",onDone:[{target:"labellingOnly",cond:"wasLabellingOnly"},{target:"promptBeginTracking",cond:"wasIdle"},{target:"promptTrackNewStudy",cond:"wasTrackingAndIsNewStudy"},{target:"promptTrackNewSeries",cond:"wasTrackingAndIsNewSeries"},{target:"tracking",cond:"wasTracking"},{target:"off"}]}},promptHasDirtyAnnotations:{invoke:{src:"promptHasDirtyAnnotations",onDone:[{target:"tracking",actions:["clearAllMeasurements","clearDisplaySetHydratedState","setIsDirty","updatedViewports"],cond:"shouldSetStudyAndSeries"},{target:"promptSaveReport",cond:"shouldPromptSaveReport"},{target:"tracking"}]}}},strict:!0},kt={services:{promptBeginTracking:(e,t)=>{},promptTrackNewStudy:(e,t)=>{},promptTrackNewSeries:(e,t)=>{}},actions:{discardPreviouslyTrackedMeasurements:(e,t)=>{console.log("discardPreviouslyTrackedMeasurements: not implemented")},clearAllMeasurements:(e,t)=>{console.log("clearAllMeasurements: not implemented")},jumpToFirstMeasurementInActiveViewport:(e,t)=>{console.warn("jumpToFirstMeasurementInActiveViewport: not implemented")},showStructuredReportDisplaySetInActiveViewport:(e,t)=>{console.warn("showStructuredReportDisplaySetInActiveViewport: not implemented")},clearContext:it({trackedStudy:"",trackedSeries:[],ignoredSeries:[],prevTrackedStudy:"",prevTrackedSeries:[],prevIgnoredSeries:[]}),setTrackedStudyAndSeries:it(((e,t)=>({prevTrackedStudy:e.trackedStudy,prevTrackedSeries:e.trackedSeries.slice(),prevIgnoredSeries:e.ignoredSeries.slice(),trackedStudy:t.data.StudyInstanceUID,trackedSeries:[t.data.SeriesInstanceUID],ignoredSeries:[]}))),setTrackedStudyAndMultipleSeries:it(((e,t)=>{const n=t.StudyInstanceUID||t.data.StudyInstanceUID,r=t.SeriesInstanceUIDs||t.data.SeriesInstanceUIDs;return{prevTrackedStudy:e.trackedStudy,prevTrackedSeries:e.trackedSeries.slice(),prevIgnoredSeries:e.ignoredSeries.slice(),trackedStudy:n,trackedSeries:[...e.trackedSeries,...r],ignoredSeries:[]}})),setIsDirtyToClean:it(((e,t)=>({isDirty:!1}))),setIsDirty:it(((e,t)=>({isDirty:!0}))),ignoreSeries:it(((e,t)=>({prevIgnoredSeries:[...e.ignoredSeries],ignoredSeries:[...e.ignoredSeries,t.data.SeriesInstanceUID]}))),ignoreHydrationForSRSeries:it(((e,t)=>({ignoredSRSeriesForHydration:[...e.ignoredSRSeriesForHydration,t.data.srSeriesInstanceUID]}))),addTrackedSeries:it(((e,t)=>({prevTrackedSeries:[...e.trackedSeries],trackedSeries:[...e.trackedSeries,t.data.SeriesInstanceUID]}))),removeTrackedSeries:it(((e,t)=>({prevTrackedSeries:e.trackedSeries.slice().filter((e=>e!==t.SeriesInstanceUID)),trackedSeries:e.trackedSeries.slice().filter((e=>e!==t.SeriesInstanceUID))}))),setPreviousState:it(((e,t,n)=>({prevState:n.state.value})))},guards:{shouldSetDirty:(e,t)=>void 0===t.SeriesInstanceUID||e.trackedSeries.includes(t.SeriesInstanceUID),wasLabellingOnly:(e,t,n)=>"labellingOnly"===e.prevState,wasIdle:(e,t,n)=>"idle"===e.prevState,wasTracking:(e,t,n)=>"tracking"===e.prevState,wasTrackingAndIsNewStudy:(e,t,n)=>"tracking"===e.prevState&&!e.ignoredSeries.includes(t.data.SeriesInstanceUID)&&e.trackedStudy!==t.data.StudyInstanceUID,wasTrackingAndIsNewSeries:(e,t,n)=>"tracking"===e.prevState&&!e.ignoredSeries.includes(t.data.SeriesInstanceUID)&&!e.trackedSeries.includes(t.data.SeriesInstanceUID),shouldKillMachine:(e,t)=>t.data&&t.data.userResponse===vt,shouldAddSeries:(e,t)=>t.data&&t.data.userResponse===mt,shouldSetStudyAndSeries:(e,t)=>t.data&&t.data.userResponse===St,shouldAddIgnoredSeries:(e,t)=>t.data&&t.data.userResponse===bt,shouldPromptSaveReport:(e,t)=>t.data&&t.data.userResponse===yt,shouldIgnoreHydrationForSR:(e,t)=>t.data&&t.data.userResponse===gt,shouldSaveAndContinueWithSameReport:(e,t)=>t.data&&t.data.userResponse===yt&&!0===t.data.isBackupSave,shouldSaveAndStartNewReport:(e,t)=>t.data&&t.data.userResponse===yt&&!1===t.data.isBackupSave,shouldHydrateStructuredReport:(e,t)=>t.data&&t.data.userResponse===wt,hasRemainingTrackedSeries:(e,t)=>e.trackedSeries.length>1||!e.trackedSeries.includes(t.SeriesInstanceUID),hasNotIgnoredSRSeriesForHydration:(e,t)=>!e.ignoredSRSeriesForHydration.includes(t.SeriesInstanceUID),isNewStudy:(e,t)=>!e.ignoredSeries.includes(t.SeriesInstanceUID)&&e.trackedStudy!==t.StudyInstanceUID,isNewSeries:(e,t)=>!e.ignoredSeries.includes(t.SeriesInstanceUID)&&!e.trackedSeries.includes(t.SeriesInstanceUID)}};var It=n(123),Et=n(838);const Ot=function({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},i,o){const{displaySetService:a}=e.services,{viewportId:s,displaySetInstanceUID:c}=o,u=a.getDisplaySetByUID(c);return new Promise(((i,a)=>{const l=(0,Et.hydrateStructuredReport)({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},c),d=l.StudyInstanceUID,f=l.SeriesInstanceUIDs;i({displaySetInstanceUID:o.displaySetInstanceUID,srSeriesInstanceUID:u.SeriesInstanceUID,viewportId:s,StudyInstanceUID:d,SeriesInstanceUIDs:f})}))},Dt=(0,o.createContext)(null),{Provider:Tt}=Dt;function Rt({children:e,value:t}){const[n,r]=(0,o.useState)(t);return o.createElement(Tt,{value:[n,r]},e)}Rt.propTypes={children:s().any,value:s().any};const At=({servicesManager:e,extensionManager:t},n,r)=>{const{customizationService:i}=e.services;return i.getCustomization("measurement.promptBeginTracking")({servicesManager:e,extensionManager:t},n,r)},Mt=({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},i,o)=>{const{customizationService:a}=e.services;return a.getCustomization("measurement.promptHydrateStructuredReport")({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},i,o)},_t=({servicesManager:e,extensionManager:t},n,r)=>{const{customizationService:i}=e.services;return i.getCustomization("measurement.promptTrackNewSeries")({servicesManager:e,extensionManager:t},n,r)},Ct=({servicesManager:e,extensionManager:t},n,r)=>{const{customizationService:i}=e.services;return i.getCustomization("measurement.promptTrackNewStudy")({servicesManager:e,extensionManager:t},n,r)},Nt=({servicesManager:e},t,n)=>{const{customizationService:r}=e.services;return r.getCustomization("measurement.promptLabelAnnotation")({servicesManager:e},t,n)},Pt=({servicesManager:e,commandsManager:t,extensionManager:n},r,i)=>{const{customizationService:o}=e.services;return o.getCustomization("measurement.promptSaveReport")({servicesManager:e,commandsManager:t,extensionManager:n},r,i)},jt=({servicesManager:e,commandsManager:t,extensionManager:n},r,i)=>{const{customizationService:o}=e.services;return o.getCustomization("measurement.promptHasDirtyAnnotations")({servicesManager:e,commandsManager:t,extensionManager:n},r,i)},Ut=o.createContext();Ut.displayName="TrackedMeasurementsContext";const Lt=()=>(0,o.useContext)(Ut),Vt="@ohif/extension-cornerstone-dicom-sr.sopClassHandlerModule.dicom-sr";function Ft({servicesManager:e,commandsManager:t,extensionManager:n},{children:r}){const[i]=(0,o.useContext)(Dt),[a,s]=(0,ht.useViewportGrid)(),{activeViewportId:c,viewports:u}=a,{measurementService:l,displaySetService:d,customizationService:f}=e.services,p=Object.assign({},kt);p.actions=Object.assign({},p.actions,{jumpToFirstMeasurementInActiveViewport:(e,t)=>{const{trackedStudy:n,trackedSeries:r}=e,{viewportId:i}=t.data,o=l.getMeasurements().filter((e=>n===e.referenceStudyUID&&r.includes(e.referenceSeriesUID)));console.log("jumping to measurement reset viewport",i,o[0]);const a=o[0].displaySetInstanceUID,c=d.getDisplaySetByUID(a).images,u=c[0].imageId.startsWith("volumeId"),f=o[0].data;let p=0;!u&&f&&(p=c.findIndex((e=>{const t=Object.keys(f)[0].substring(8);return e.imageId===t})),-1===p&&(console.warn("Could not find image index for tracked measurement, using 0"),p=0)),s.setDisplaySetsForViewport({viewportId:i,displaySetInstanceUIDs:[a],viewportOptions:{initialImageOptions:{index:p}}})},jumpToSameImageInActiveViewport:(e,n)=>{const{trackedStudy:r,trackedSeries:i}=e,{viewportId:o}=n.data,a=l.getMeasurements(),c=a.filter((e=>r===e.referenceStudyUID&&i.includes(e.referenceSeriesUID)));if(!c?.length)return void console.warn("Didn't find any tracked measurements",a,r,i);const u=c[c.length-1],d=u.displaySetInstanceUID;t.runCommand("updateStoredPositionPresentation",{viewportId:o,displaySetInstanceUID:d,referencedImageId:u.referencedImageId}),s.setDisplaySetsForViewport({viewportId:o,displaySetInstanceUIDs:[d]})},showStructuredReportDisplaySetInActiveViewport:(e,t)=>{if(t.data.createdDisplaySetInstanceUIDs.length>0){const e=t.data.createdDisplaySetInstanceUIDs[0];s.setDisplaySetsForViewport({viewportId:t.data.viewportId,displaySetInstanceUIDs:[e]})}},discardPreviouslyTrackedMeasurements:(e,t)=>{const n=l.getMeasurements().filter((t=>e.prevTrackedSeries.includes(t.referenceSeriesUID))).map((e=>e.id));for(let e=0;e<n.length;e++)l.remove(n[e])},clearAllMeasurements:(e,t)=>{const n=l.getMeasurements().map((e=>e.uid));for(let e=0;e<n.length;e++)l.remove(n[e]);l.setIsMeasurementDeletedIndividually(!1)},clearDisplaySetHydratedState:(e,t)=>{const{displaySetInstanceUID:n}=t.data??t,r=d.getActiveDisplaySets();r?.forEach((e=>{"SR"===e.Modality&&e.displaySetInstanceUID!==n&&e.isHydrated&&(e.isHydrated=!1,e.isLoaded=!1)}))},updatedViewports:(t,n)=>{const{hangingProtocolService:r}=e.services,{displaySetInstanceUID:i,viewportId:o}=n.data??n,a=r.getViewportsRequireUpdate(o,i);s.setDisplaySetsForViewports(a)}}),p.services=Object.assign({},p.services,{promptBeginTracking:At.bind(null,{servicesManager:e,extensionManager:n,appConfig:i}),promptTrackNewSeries:_t.bind(null,{servicesManager:e,extensionManager:n,appConfig:i}),promptTrackNewStudy:Ct.bind(null,{servicesManager:e,extensionManager:n,appConfig:i}),promptSaveReport:Pt.bind(null,{servicesManager:e,commandsManager:t,extensionManager:n,appConfig:i}),promptHydrateStructuredReport:Mt.bind(null,{servicesManager:e,extensionManager:n,commandsManager:t,appConfig:i}),promptHasDirtyAnnotations:jt.bind(null,{servicesManager:e,extensionManager:n,commandsManager:t,appConfig:i}),hydrateStructuredReport:Ot.bind(null,{servicesManager:e,extensionManager:n,commandsManager:t,appConfig:i}),promptLabelAnnotation:Nt.bind(null,{servicesManager:e,extensionManager:n,commandsManager:t})}),p.guards=Object.assign({},p.guards,{isLabelOnMeasure:(e,t,n)=>{const r=f.getCustomization("measurementLabels");return r?.labelOnMeasure},isLabelOnMeasureAndShouldKillMachine:(e,t,n)=>{const r=f.getCustomization("measurementLabels");return t.data&&t.data.userResponse===vt&&r?.labelOnMeasure},isSimplifiedConfig:(e,t,n)=>i?.measurementTrackingMode===It.v.SIMPLIFIED,simplifiedAndLoadSR:(e,t,n)=>i?.measurementTrackingMode===It.v.SIMPLIFIED&&!1===t.data.isBackupSave,hasDirtyAndSimplified:(e,t,n)=>{const r=l.getMeasurements(),o=r.some((e=>e.isDirty))||r.length&&l.getIsMeasurementDeletedIndividually();return i?.measurementTrackingMode===It.v.SIMPLIFIED&&o}});const h=(0,o.useMemo)((()=>{return e=xt,t=p,void 0===n&&(n=e.context),new rt(e,t,n);var e,t,n}),[]),[v,g]=pt(h);return(0,o.useEffect)((()=>{g("UPDATE_ACTIVE_VIEWPORT_ID",{activeViewportId:c})}),[c,g]),(0,o.useEffect)((()=>{(async()=>{if(u.size>0){const t=u.get(c);if(!t||!t?.displaySetInstanceUIDs?.length)return;const{displaySetService:n}=e.services,r=n.getDisplaySetByUID(t.displaySetInstanceUIDs[0]);if(!r)return;if(r.SOPClassHandlerId===Vt&&!r.isLoaded&&r.load&&await r.load(),r.SOPClassHandlerId===Vt&&!0===r.isRehydratable&&!r.isHydrated){const e={displaySetInstanceUID:r.displaySetInstanceUID,SeriesInstanceUID:r.SeriesInstanceUID,viewportId:c},t=i?.disableConfirmationPrompts;g(t?"HYDRATE_SR":"PROMPT_HYDRATE_SR",e)}}})()}),[v,c,g,e.services,u,i]),(0,o.useEffect)((()=>{t.registerCommand("DEFAULT","loadTrackedSRMeasurements",{commandFn:e=>g("HYDRATE_SR",e)})}),[t,g]),o.createElement(Ut.Provider,{value:[v,g]},r)}Ft.propTypes={children:s().oneOf([s().func,s().node]),appConfig:s().object};const Ht=function({servicesManager:e,extensionManager:t,commandsManager:n}){const r=Ft.bind(null,{servicesManager:e,extensionManager:t,commandsManager:n});return[{name:"TrackedMeasurementsContext",context:Ut,provider:r}]}},132:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>N});var r=n(326),i=n(598),o=n.n(i),a=n(55),s=n(713),c=n(440),u=n(557),l=n(111);var d=n(224);n(741);Object.create(null);function f(){if(console&&console.warn){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];"string"==typeof n[0]&&(n[0]="react-i18next:: ".concat(n[0])),(e=console).warn.apply(e,n)}}var p={};function h(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&p[t[0]]||("string"==typeof t[0]&&(p[t[0]]=new Date),f.apply(void 0,t))}var v=function(e,t){return function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}};function g(e,t,n){e.loadNamespaces(t,v(e,n))}function y(e,t,n,r){"string"==typeof n&&(n=[n]),n.forEach((function(t){e.options.ns.indexOf(t)<0&&e.options.ns.push(t)})),e.loadLanguages(t,v(e,r))}var m=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,S={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},b=function(e){return S[e]};var w,x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:function(e){return e.replace(m,b)}};var k=n(561),I=n(1);var E=(0,r.createContext)(),O=function(){function e(){(0,k.A)(this,e),this.usedNamespaces={}}return(0,I.A)(e,[{key:"addUsedNamespaces",value:function(e){var t=this;e.forEach((function(e){t.usedNamespaces[e]||(t.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}]),e}();var D=n(730);function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){(0,l.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function A(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.i18n,i=(0,r.useContext)(E)||{},o=i.i18n,a=i.defaultNS,s=n||o||w;if(s&&!s.reportNamespaces&&(s.reportNamespaces=new O),!s){h("You will need to pass in an i18next instance by using initReactI18next");var c=function(e,t){return"string"==typeof t?t:t&&"object"===(0,d.A)(t)&&"string"==typeof t.defaultValue?t.defaultValue:Array.isArray(e)?e[e.length-1]:e},u=[c,{},!1];return u.t=c,u.i18n={},u.ready=!1,u}s.options.react&&void 0!==s.options.react.wait&&h("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var l=R(R(R({},x),s.options.react),t),f=l.useSuspense,p=l.keyPrefix,v=e||a||s.options&&s.options.defaultNS;v="string"==typeof v?[v]:v||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(v);var m=(s.isInitialized||s.initializedStoreOnce)&&v.every((function(e){return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.languages&&t.languages.length?void 0!==t.options.ignoreJSONStructure?t.hasLoadedNamespace(e,{lng:n.lng,precheck:function(t,r){if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}):function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=t.languages[0],i=!!t.options&&t.options.fallbackLng,o=t.languages[t.languages.length-1];if("cimode"===r.toLowerCase())return!0;var a=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===r||2===r};return!(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)||!t.hasResourceBundle(r,e)&&t.services.backendConnector.backend&&(!t.options.resources||t.options.partialBundledLanguages)&&(!a(r,e)||i&&!a(o,e)))}(e,t,n):(h("i18n.languages were undefined or empty",t.languages),!0)}(e,s,l)}));function S(){return s.getFixedT(t.lng||null,"fallback"===l.nsMode?v:v[0],p)}var b=(0,r.useState)(S),k=(0,D.A)(b,2),I=k[0],T=k[1],A=v.join();t.lng&&(A="".concat(t.lng).concat(A));var M,_,C,N=(M=A,C=(0,r.useRef)(),(0,r.useEffect)((function(){C.current=_?C.current:M}),[M,_]),C.current),P=(0,r.useRef)(!0);(0,r.useEffect)((function(){var e=l.bindI18n,n=l.bindI18nStore;function r(){P.current&&T(S)}return P.current=!0,m||f||(t.lng?y(s,t.lng,v,(function(){P.current&&T(S)})):g(s,v,(function(){P.current&&T(S)}))),m&&N&&N!==A&&P.current&&T(S),e&&s&&s.on(e,r),n&&s&&s.store.on(n,r),function(){P.current=!1,e&&s&&e.split(" ").forEach((function(e){return s.off(e,r)})),n&&s&&n.split(" ").forEach((function(e){return s.store.off(e,r)}))}}),[s,A]);var j=(0,r.useRef)(!0);(0,r.useEffect)((function(){P.current&&!j.current&&T(S),j.current=!1}),[s,p]);var U=[I,s,m];if(U.t=I,U.i18n=s,U.ready=m,m)return U;if(!m&&!f)return U;throw new Promise((function(e){t.lng?y(s,t.lng,v,(function(){return e()})):g(s,v,(function(){return e()}))}))}function M(){return M=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},M.apply(null,arguments)}function _(e){const{displaySets:t,viewportId:n,servicesManager:i,extensionManager:o}=e,{measurementService:l,cornerstoneViewportService:d,viewportGridService:f,viewportActionCornersService:p}=i.services,h=t[0],{t:v}=A("Common"),[g]=(0,a.useViewportGrid)(),{activeViewportId:y}=g,[m,S]=(0,c.B)(),[b,w]=(0,r.useState)(!1),[x,k]=(0,r.useState)(null),[I,E]=(0,r.useState)(null),{trackedSeries:O}=m.context,{SeriesInstanceUID:D}=h,T=(0,r.useCallback)((()=>{const e=d.getCornerstoneViewport(n);if(e instanceof u.BaseVolumeViewport){const t=e?.getCurrentImageId();if(!t)return void(b&&w(!1))}O.includes(D)!==b&&w(!b)}),[b,m,n,D]),R=(0,r.useCallback)((e=>{e.detail.element!==I&&(e.detail.element?.addEventListener(u.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,T),E(e.detail.element))}),[T,I]),_=(0,r.useCallback)((()=>{I?.removeEventListener(u.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,T)}),[T,I]);(0,r.useEffect)(T,[T]),(0,r.useEffect)((()=>{const{unsubscribe:e}=d.subscribe(d.EVENTS.VIEWPORT_DATA_CHANGED,(e=>{e.viewportId===n&&T()}));return()=>{e()}}),[T,n]),(0,r.useEffect)((()=>b?(s.annotation.config.style.setViewportToolStyles(n,{ReferenceLines:{lineDash:"4,4"},global:{lineDash:""}}),void d.getRenderingEngine().renderViewport(n)):(s.annotation.config.style.setViewportToolStyles(n,{global:{lineDash:"4,4"}}),d.getRenderingEngine().renderViewport(n),()=>{s.annotation.config.style.setViewportToolStyles(n,{})})),[b]),(0,r.useEffect)((()=>{const e=l.EVENTS.MEASUREMENT_ADDED,t=l.EVENTS.RAW_MEASUREMENT_ADDED,r=[];return[e,t].forEach((e=>{r.push(l.subscribe(e,(({source:e,measurement:t})=>{const{activeViewportId:r}=f.getState();if(n===r){const{referenceStudyUID:e,referenceSeriesUID:r,uid:i,toolName:o}=t;S("SET_DIRTY",{SeriesInstanceUID:r}),S("TRACK_SERIES",{viewportId:n,StudyInstanceUID:e,SeriesInstanceUID:r,measurementId:i,toolName:o})}})).unsubscribe)})),()=>{r.forEach((e=>{e()}))}}),[l,S,n,f]);const N=(0,r.useCallback)((e=>{const t=function(e,t,n,r){const{measurementService:i,viewportGridService:o}=t.services,a=i.getMeasurements(),{activeViewportId:s,viewports:c}=o.getState(),{displaySetInstanceUIDs:u}=c.get(s),{trackedSeries:l}=r.context,d=a.filter((e=>l.includes(e.referenceSeriesUID)&&u.includes(e.displaySetInstanceUID)));if(!d.length)return;const f=d.length,p=d.map((e=>e.uid));let h=p.findIndex((e=>e===n));-1===h?h=0:(h+=e,h<0?h=f-1:h===f&&(h=0));return p[h]}(e,i,x,m);t&&(k(t),l.jumpToMeasurement(n,t))}),[l,i,x,m,n]);(0,r.useEffect)((()=>{const e=function(e,t){if(!e)return null;return r.createElement(a.Tooltip,null,r.createElement(a.TooltipTrigger,{asChild:!0},r.createElement("span",null,r.createElement(a.Icons.StatusTracking,{className:"text-muted-foreground mt-0.5 ml-0.5"}))),r.createElement(a.TooltipContent,{align:"start",side:"bottom"},e?r.createElement(r.Fragment,null,t("Series is tracked and can be viewed in the measurement panel")):r.createElement(r.Fragment,null,t("Measurements for untracked series will not be shown in the measurements panel"))))}(b,v),t=C(b,N,n===y);p.addComponents([{viewportId:n,id:"viewportStatusComponent",component:e,indexPriority:-100,location:p.LOCATIONS.topLeft},{viewportId:n,id:"viewportActionArrowsComponent",component:t,indexPriority:0,location:p.LOCATIONS.topRight}])}),[y,b,N,p,n]);return r.createElement("div",{className:"relative flex h-full w-full flex-row overflow-hidden"},(()=>{const{component:t}=o.getModuleEntry("@ohif/extension-cornerstone.viewportModule.cornerstone");return r.createElement(t,M({},e,{onElementEnabled:t=>{e.onElementEnabled?.(t),R(t)},onElementDisabled:_}))})())}_.propTypes={displaySets:o().arrayOf(o().object.isRequired).isRequired,viewportId:o().string.isRequired,dataSource:o().object,children:o().node};const C=(e,t,n)=>e?r.createElement(a.ViewportActionArrows,{onArrowsClick:e=>t(e),className:n?"visible":"invisible group-hover/pane:visible"}):null;const N=_},228:(e,t,n)=>{"use strict";n.d(t,{A:()=>B});var r=n(224),i=n(111);function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?Object(arguments[t]):{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach((function(t){(0,i.A)(e,t,n[t])}))}return e}var a=n(561),s=n(1);function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){if(t&&("object"==(0,r.A)(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}var p=n(85);var h=n(492);function v(e){return function(e){if(Array.isArray(e))return(0,p.A)(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||(0,h.A)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var g=n(730),y={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){var n;console&&console[e]&&(n=console)[e].apply(n,v(t))}},m=new(function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,a.A)(this,e),this.init(t,n)}return(0,s.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||y,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,r){return r&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,o({},{prefix:"".concat(this.prefix,":").concat(t,":")},this.options))}}]),e}()),S=function(){function e(){(0,a.A)(this,e),this.observers={}}return(0,s.A)(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach((function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==t})):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.observers[e]&&[].concat(this.observers[e]).forEach((function(e){e.apply(void 0,n)}));this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(n))}))}}]),e}();function b(){var e,t,n=new Promise((function(n,r){e=n,t=r}));return n.resolve=e,n.reject=t,n}function w(e){return null==e?"":""+e}function x(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var o="string"!=typeof t?[].concat(t):t.split(".");o.length>1;){if(i())return{};var a=r(o.shift());!e[a]&&n&&(e[a]=new n),e=e[a]}return i()?{}:{obj:e,k:r(o.shift())}}function k(e,t,n){var r=x(e,t,Object);r.obj[r.k]=n}function I(e,t){var n=x(e,t),r=n.obj,i=n.k;if(r)return r[i]}function E(e,t,n){var r=I(e,n);return void 0!==r?r:I(t,n)}function O(e,t,n){for(var r in t)r in e?"string"==typeof e[r]||e[r]instanceof String||"string"==typeof t[r]||t[r]instanceof String?n&&(e[r]=t[r]):O(e[r],t[r],n):e[r]=t[r];return e}function D(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var T={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function R(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return T[e]})):e}var A=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return(0,a.A)(this,t),n=u(this,l(t).call(this)),S.call(c(n)),n.data=e||{},n.options=r,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n}return f(t,e),(0,s.A)(t,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,o=[e,t];return n&&"string"!=typeof n&&(o=o.concat(n)),n&&"string"==typeof n&&(o=o.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(o=e.split(".")),I(this.data,o)}},{key:"addResource",value:function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},o=this.options.keySeparator;void 0===o&&(o=".");var a=[e,t];n&&(a=a.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(r=t,t=(a=e.split("."))[1]),this.addNamespaces(t),k(this.data,a,r),i.silent||this.emit("added",e,t,n,r)}},{key:"addResources",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in n)"string"!=typeof n[i]&&"[object Array]"!==Object.prototype.toString.apply(n[i])||this.addResource(e,t,i,n[i],{silent:!0});r.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,r,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},s=[e,t];e.indexOf(".")>-1&&(r=n,n=t,t=(s=e.split("."))[1]),this.addNamespaces(t);var c=I(this.data,s)||{};r?O(c,n,i):c=o({},c,n),k(this.data,s,c),a.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?o({},{},this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"toJSON",value:function(){return this.data}}]),t}(S),M={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,r,i){var o=this;return e.forEach((function(e){o.processors[e]&&(t=o.processors[e].process(t,n,r,i))})),t}},_=function(e){function t(e){var n,r,i,o,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,a.A)(this,t),n=u(this,l(t).call(this)),S.call(c(n)),r=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],i=e,o=c(n),r.forEach((function(e){i[e]&&(o[e]=i[e])})),n.options=s,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=m.create("translator"),n}return f(t,e),(0,s.A)(t,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=t.nsSeparator||this.options.nsSeparator;void 0===n&&(n=":");var r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS;if(n&&e.indexOf(n)>-1){var o=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(o[0])>-1)&&(i=o.shift()),e=o.join(r)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,t){var n=this;if("object"!==(0,r.A)(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,a=this.extractFromKey(e[e.length-1],t),s=a.key,c=a.namespaces,u=c[c.length-1],l=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(d){var f=t.nsSeparator||this.options.nsSeparator;return u+f+s}return s}var p=this.resolve(e,t),h=p&&p.res,v=p&&p.usedKey||s,g=p&&p.exactUsedKey||s,y=Object.prototype.toString.apply(h),m=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject;if(S&&h&&("string"!=typeof h&&"boolean"!=typeof h&&"number"!=typeof h)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(y)<0&&("string"!=typeof m||"[object Array]"!==y)){if(!t.returnObjects&&!this.options.returnObjects)return this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,h,t):"key '".concat(s," (").concat(this.language,")' returned an object instead of string.");if(i){var b="[object Array]"===y,w=b?[]:{},x=b?g:v;for(var k in h)if(Object.prototype.hasOwnProperty.call(h,k)){var I="".concat(x).concat(i).concat(k);w[k]=this.translate(I,o({},t,{joinArrays:!1,ns:c})),w[k]===I&&(w[k]=h[k])}h=w}}else if(S&&"string"==typeof m&&"[object Array]"===y)(h=h.join(m))&&(h=this.extendTranslation(h,e,t));else{var E=!1,O=!1;if(!this.isValidLookup(h)&&void 0!==t.defaultValue){if(E=!0,void 0!==t.count){var D=this.pluralResolver.getSuffix(l,t.count);h=t["defaultValue".concat(D)]}h||(h=t.defaultValue)}this.isValidLookup(h)||(O=!0,h=s);var T=t.defaultValue&&t.defaultValue!==h&&this.options.updateMissing;if(O||E||T){this.logger.log(T?"updateKey":"missingKey",l,u,s,T?t.defaultValue:h);var R=[],A=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&A&&A[0])for(var M=0;M<A.length;M++)R.push(A[M]);else"all"===this.options.saveMissingTo?R=this.languageUtils.toResolveHierarchy(t.lng||this.language):R.push(t.lng||this.language);var _=function(e,r){n.options.missingKeyHandler?n.options.missingKeyHandler(e,u,r,T?t.defaultValue:h,T,t):n.backendConnector&&n.backendConnector.saveMissing&&n.backendConnector.saveMissing(e,u,r,T?t.defaultValue:h,T,t),n.emit("missingKey",e,u,r,h)};if(this.options.saveMissing){var C=void 0!==t.count&&"string"!=typeof t.count;this.options.saveMissingPlurals&&C?R.forEach((function(e){n.pluralResolver.getPluralFormsOfKey(e,s).forEach((function(t){return _([e],t)}))})):_(R,s)}}h=this.extendTranslation(h,e,t,p),O&&h===s&&this.options.appendNamespaceToMissingKey&&(h="".concat(u,":").concat(s)),O&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(h))}return h}},{key:"extendTranslation",value:function(e,t,n,r){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,n,r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(o({},n,{interpolation:o({},this.options.interpolation,n.interpolation)}));var a=n.replace&&"string"!=typeof n.replace?n.replace:n;this.options.interpolation.defaultVariables&&(a=o({},this.options.interpolation.defaultVariables,a)),e=this.interpolator.interpolate(e,a,n.lng||this.language,n),!1!==n.nest&&(e=this.interpolator.nest(e,(function(){return i.translate.apply(i,arguments)}),n)),n.interpolation&&this.interpolator.reset()}var s=n.postProcess||this.options.postProcess,c="string"==typeof s?[s]:s;return null!=e&&c&&c.length&&!1!==n.applyPostProcessor&&(e=M.handle(c,e,t,this.options&&this.options.postProcessPassResolved?o({i18nResolved:r},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,r,i,o,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!a.isValidLookup(t)){var c=a.extractFromKey(e,s),u=c.key;n=u;var l=c.namespaces;a.options.fallbackNS&&(l=l.concat(a.options.fallbackNS));var d=void 0!==s.count&&"string"!=typeof s.count,f=void 0!==s.context&&"string"==typeof s.context&&""!==s.context,p=s.lngs?s.lngs:a.languageUtils.toResolveHierarchy(s.lng||a.language,s.fallbackLng);l.forEach((function(e){a.isValidLookup(t)||(o=e,a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(o)&&a.logger.warn('key "'.concat(n,'" for namespace "').concat(o,"\" won't get resolved as namespace was not yet loaded"),"This means something IS WRONG in your application setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"),p.forEach((function(n){if(!a.isValidLookup(t)){i=n;var o,c,l=u,p=[l];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(p,u,n,e,s);else d&&(o=a.pluralResolver.getSuffix(n,s.count)),d&&f&&p.push(l+o),f&&p.push(l+="".concat(a.options.contextSeparator).concat(s.context)),d&&p.push(l+=o);for(;c=p.pop();)a.isValidLookup(t)||(r=c,t=a.getResource(n,e,c,s))}})))}))}})),{res:t,usedKey:n,exactUsedKey:r,usedLng:i,usedNS:o}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}}]),t}(S);function C(e){return e.charAt(0).toUpperCase()+e.slice(1)}var N=function(){function e(t){(0,a.A)(this,e),this.options=t,this.whitelist=this.options.whitelist||!1,this.logger=m.create("languageUtils")}return(0,s.A)(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=C(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=C(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=C(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isWhitelisted",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitWhitelist)&&(e=this.getLanguagePartFromCode(e)),!this.whitelist||!this.whitelist.length||this.whitelist.indexOf(e)>-1}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,r=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],o=function(e){e&&(n.isWhitelisted(e)?i.push(e):n.logger.warn("rejecting non-whitelisted language code: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):"string"==typeof e&&o(this.formatLanguageCode(e)),r.forEach((function(e){i.indexOf(e)<0&&o(n.formatLanguageCode(e))})),i}}]),e}(),P=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","id","ja","jbo","ka","kk","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he"],nr:[1,2,20,21],fc:22}],j={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0===e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1===e?0:2===e?1:(e<0||e>10)&&e%10==0?2:3)}};var U=function(){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,a.A)(this,e),this.languageUtils=t,this.options=r,this.logger=m.create("pluralResolver"),this.rules=(n={},P.forEach((function(e){e.lngs.forEach((function(t){n[t]={numbers:e.nr,plurals:j[e.fc]}}))})),n)}return(0,s.A)(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=this.getRule(e);return t&&t.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=this,r=[],i=this.getRule(e);return i?(i.numbers.forEach((function(i){var o=n.getSuffix(e,i);r.push("".concat(t).concat(o))})),r):r}},{key:"getSuffix",value:function(e,t){var n=this,r=this.getRule(e);if(r){var i=r.noAbs?r.plurals(t):r.plurals(Math.abs(t)),o=r.numbers[i];this.options.simplifyPluralSuffix&&2===r.numbers.length&&1===r.numbers[0]&&(2===o?o="plural":1===o&&(o=""));var a=function(){return n.options.prepend&&o.toString()?n.options.prepend+o.toString():o.toString()};return"v1"===this.options.compatibilityJSON?1===o?"":"number"==typeof o?"_plural_".concat(o.toString()):a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===r.numbers.length&&1===r.numbers[0]?a():this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString()}return this.logger.warn("no plural rule found for: ".concat(e)),""}}]),e}(),L=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,a.A)(this,e),this.logger=m.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return(0,s.A)(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:R,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?D(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?D(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?D(t.nestingPrefix):t.nestingPrefixEscaped||D("$t("),this.nestingSuffix=t.nestingSuffix?D(t.nestingSuffix):t.nestingSuffixEscaped||D(")"),this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,r){var i,o,a,s=this,c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(e){return e.replace(/\$/g,"$$$$")}var l=function(e){if(e.indexOf(s.formatSeparator)<0)return E(t,c,e);var r=e.split(s.formatSeparator),i=r.shift().trim(),o=r.join(s.formatSeparator).trim();return s.format(E(t,c,i),o,n)};this.resetRegExp();var d=r&&r.missingInterpolationHandler||this.options.missingInterpolationHandler;for(a=0;i=this.regexpUnescape.exec(e);){if(void 0===(o=l(i[1].trim())))if("function"==typeof d){var f=d(e,i,r);o="string"==typeof f?f:""}else this.logger.warn("missed to pass in variable ".concat(i[1]," for interpolating ").concat(e)),o="";else"string"==typeof o||this.useRawValueToEscape||(o=w(o));if(e=e.replace(i[0],u(o)),this.regexpUnescape.lastIndex=0,++a>=this.maxReplaces)break}for(a=0;i=this.regexp.exec(e);){if(void 0===(o=l(i[1].trim())))if("function"==typeof d){var p=d(e,i,r);o="string"==typeof p?p:""}else this.logger.warn("missed to pass in variable ".concat(i[1]," for interpolating ").concat(e)),o="";else"string"==typeof o||this.useRawValueToEscape||(o=w(o));if(o=this.escapeValue?u(this.escape(o)):u(o),e=e.replace(i[0],o),this.regexp.lastIndex=0,++a>=this.maxReplaces)break}return e}},{key:"nest",value:function(e,t){var n,r,i=o({},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{});function a(e,t){if(e.indexOf(",")<0)return e;var n=e.split(",");e=n.shift();var r=n.join(",");r=(r=this.interpolate(r,i)).replace(/'/g,'"');try{i=JSON.parse(r),t&&(i=o({},t,i))}catch(t){this.logger.error("failed parsing options string in nesting for key ".concat(e),t)}return delete i.defaultValue,e}for(i.applyPostProcessor=!1,delete i.defaultValue;n=this.nestingRegexp.exec(e);){if((r=t(a.call(this,n[1].trim(),i),i))&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=w(r)),r||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),r=""),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}]),e}();var V=function(e){function t(e,n,r){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,a.A)(this,t),i=u(this,l(t).call(this)),S.call(c(i)),i.backend=e,i.store=n,i.services=r,i.languageUtils=r.languageUtils,i.options=o,i.logger=m.create("backendConnector"),i.state={},i.queue=[],i.backend&&i.backend.init&&i.backend.init(r,o.backend,o),i}return f(t,e),(0,s.A)(t,[{key:"queueLoad",value:function(e,t,n,r){var i=this,o=[],a=[],s=[],c=[];return e.forEach((function(e){var r=!0;t.forEach((function(t){var s="".concat(e,"|").concat(t);!n.reload&&i.store.hasResourceBundle(e,t)?i.state[s]=2:i.state[s]<0||(1===i.state[s]?a.indexOf(s)<0&&a.push(s):(i.state[s]=1,r=!1,a.indexOf(s)<0&&a.push(s),o.indexOf(s)<0&&o.push(s),c.indexOf(t)<0&&c.push(t)))})),r||s.push(e)})),(o.length||a.length)&&this.queue.push({pending:a,loaded:{},errors:[],callback:r}),{toLoad:o,pending:a,toLoadLanguages:s,toLoadNamespaces:c}}},{key:"loaded",value:function(e,t,n){var r=e.split("|"),i=(0,g.A)(r,2),o=i[0],a=i[1];t&&this.emit("failedLoading",o,a,t),n&&this.store.addResourceBundle(o,a,n),this.state[e]=t?-1:2;var s={};this.queue.forEach((function(n){var r,i,c,u,l,d;r=n.loaded,i=a,u=x(r,[o],Object),l=u.obj,d=u.k,l[d]=l[d]||[],c&&(l[d]=l[d].concat(i)),c||l[d].push(i),function(e,t){for(var n=e.indexOf(t);-1!==n;)e.splice(n,1),n=e.indexOf(t)}(n.pending,e),t&&n.errors.push(t),0!==n.pending.length||n.done||(Object.keys(n.loaded).forEach((function(e){s[e]||(s[e]=[]),n.loaded[e].length&&n.loaded[e].forEach((function(t){s[e].indexOf(t)<0&&s[e].push(t)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",s),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:250,a=arguments.length>5?arguments[5]:void 0;return e.length?this.backend[n](e,t,(function(s,c){s&&c&&i<5?setTimeout((function(){r.read.call(r,e,t,n,i+1,2*o,a)}),o):a(s,c)})):a(null,{})}},{key:"prepareLoading",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var o=this.queueLoad(e,t,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split("|"),i=(0,g.A)(r,2),o=i[0],a=i[1];this.read(o,a,"read",null,null,(function(r,i){r&&t.logger.warn("".concat(n,"loading namespace ").concat(a," for language ").concat(o," failed"),r),!r&&i&&t.logger.log("".concat(n,"loaded namespace ").concat(a," for language ").concat(o),i),t.loaded(e,r,i)}))}},{key:"saveMissing",value:function(e,t,n,r,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" for namespace "').concat(t,'" as the namespace was not yet loaded'),"This means something IS WRONG in your application setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):(this.backend&&this.backend.create&&this.backend.create(e,t,n,r,null,o({},a,{isUpdate:i})),e&&e[0]&&this.store.addResource(e[0],t,n,r))}}]),t}(S);function F(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.whitelist&&e.whitelist.indexOf("cimode")<0&&(e.whitelist=e.whitelist.concat(["cimode"])),e}function H(){}const B=new(function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,a.A)(this,t),e=u(this,l(t).call(this)),S.call(c(e)),e.options=F(n),e.services={},e.logger=m,e.modules={external:[]},r&&!e.isInitialized&&!n.isClone){if(!e.options.initImmediate)return e.init(n,r),u(e,c(e));setTimeout((function(){e.init(n,r)}),0)}return e}return f(t,e),(0,s.A)(t,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;function i(e){return e?"function"==typeof e?new e:e:null}if("function"==typeof t&&(n=t,t={}),this.options=o({},{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===(0,r.A)(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===(0,r.A)(e[2])||"object"===(0,r.A)(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",maxReplaces:1e3}},this.options,F(t)),this.format=this.options.interpolation.format,n||(n=H),!this.options.isClone){this.modules.logger?m.init(i(this.modules.logger),this.options):m.init(null,this.options);var a=new N(this.options);this.store=new A(this.options.resources,this.options);var s=this.services;s.logger=m,s.resourceStore=this.store,s.languageUtils=a,s.pluralResolver=new U(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),s.interpolator=new L(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new V(i(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.languageDetector&&(s.languageDetector=i(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=i(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new _(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}["getResource","addResource","addResources","addResourceBundle","removeResourceBundle","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}}));var c=b(),u=function(){e.changeLanguage(e.options.lng,(function(t,r){e.isInitialized=!0,e.logger.log("initialized",e.options),e.emit("initialized",e.options),c.resolve(r),n(t,r)}))};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}},{key:"loadResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:H;if(!this.options.resources||this.options.partialBundledLanguages){if(this.language&&"cimode"===this.language.toLowerCase())return t();var n=[],r=function(t){t&&e.services.languageUtils.toResolveHierarchy(t).forEach((function(e){n.indexOf(e)<0&&n.push(e)}))};if(this.language)r(this.language);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return r(e)}));this.options.preload&&this.options.preload.forEach((function(e){return r(e)})),this.services.backendConnector.load(n,this.options.ns,t)}else t(null)}},{key:"reloadResources",value:function(e,t,n){var r=b();return e||(e=this.languages),t||(t=this.options.ns),n||(n=H),this.services.backendConnector.reload(e,t,(function(e){r.resolve(),n(e)})),r}},{key:"use",value:function(e){return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&M.addPostProcessor(e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"changeLanguage",value:function(e,t){var n=this,r=b();this.emit("languageChanging",e);var i=function(e){e&&(n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.translator.language||n.translator.changeLanguage(e),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(e)),n.loadResources((function(i){!function(e,i){n.translator.changeLanguage(i),i&&(n.emit("languageChanged",i),n.logger.log("languageChanged",i)),r.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(i,e)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),r}},{key:"getFixedT",value:function(e,t){var n=this,i=function e(t,i){var a;if("object"!==(0,r.A)(i)){for(var s=arguments.length,c=new Array(s>2?s-2:0),u=2;u<s;u++)c[u-2]=arguments[u];a=n.options.overloadTranslationOptionHandler([t,i].concat(c))}else a=o({},i);return a.lng=a.lng||e.lng,a.lngs=a.lngs||e.lngs,a.ns=a.ns||e.ns,n.t(t,a)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this;if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var n=this.languages[0],r=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var o=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===r||2===r};return!!this.hasResourceBundle(n,e)||(!this.services.backendConnector.backend||!(!o(n,e)||r&&!o(i,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,r=b();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){r.resolve(),t&&t(e)})),r):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=b();"string"==typeof e&&(e=[e]);var r=this.options.preload||[],i=e.filter((function(e){return r.indexOf(e)<0}));return i.length?(this.options.preload=r.concat(i),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.languages&&this.languages.length>0?this.languages[0]:this.language),!e)return"rtl";return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>=0?"rtl":"ltr"}},{key:"createInstance",value:function(){return new t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}},{key:"cloneInstance",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:H,i=o({},this.options,n,{isClone:!0}),a=new t(i);return["store","services","language"].forEach((function(t){a[t]=e[t]})),a.translator=new _(a.services,a.options),a.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];a.emit.apply(a,[e].concat(n))})),a.init(i,r),a.translator.options=a.options,a}}]),t}(S))},856:(e,t,n)=>{"use strict";var r=n(183);function i(){}function o(){}o.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,o,a){if(a!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:i};return n.PropTypes=n,n}},598:(e,t,n)=>{e.exports=n(856)()},183:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},249:(e,t)=>{"use strict";var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}function m(){}function S(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},m.prototype=y.prototype;var b=S.prototype=new m;b.constructor=S,v(b,y.prototype),b.isPureReactComponent=!0;var w=Array.isArray,x=Object.prototype.hasOwnProperty,k={current:null},I={key:!0,ref:!0,__self:!0,__source:!0};function E(e,t,r){var i,o={},a=null,s=null;if(null!=t)for(i in void 0!==t.ref&&(s=t.ref),void 0!==t.key&&(a=""+t.key),t)x.call(t,i)&&!I.hasOwnProperty(i)&&(o[i]=t[i]);var c=arguments.length-2;if(1===c)o.children=r;else if(1<c){for(var u=Array(c),l=0;l<c;l++)u[l]=arguments[l+2];o.children=u}if(e&&e.defaultProps)for(i in c=e.defaultProps)void 0===o[i]&&(o[i]=c[i]);return{$$typeof:n,type:e,key:a,ref:s,props:o,_owner:k.current}}function O(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var D=/\/+/g;function T(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function R(e,t,i,o,a){var s=typeof e;"undefined"!==s&&"boolean"!==s||(e=null);var c=!1;if(null===e)c=!0;else switch(s){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case n:case r:c=!0}}if(c)return a=a(c=e),e=""===o?"."+T(c,0):o,w(a)?(i="",null!=e&&(i=e.replace(D,"$&/")+"/"),R(a,t,i,"",(function(e){return e}))):null!=a&&(O(a)&&(a=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(a,i+(!a.key||c&&c.key===a.key?"":(""+a.key).replace(D,"$&/")+"/")+e)),t.push(a)),1;if(c=0,o=""===o?".":o+":",w(e))for(var u=0;u<e.length;u++){var l=o+T(s=e[u],u);c+=R(s,t,i,l,a)}else if(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(e),"function"==typeof l)for(e=l.call(e),u=0;!(s=e.next()).done;)c+=R(s=s.value,t,i,l=o+T(s,u++),a);else if("object"===s)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function A(e,t,n){if(null==e)return e;var r=[],i=0;return R(e,r,"","",(function(e){return t.call(n,e,i++)})),r}function M(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var _={current:null},C={transition:null},N={ReactCurrentDispatcher:_,ReactCurrentBatchConfig:C,ReactCurrentOwner:k};function P(){throw Error("act(...) is not supported in production builds of React.")}t.Children={map:A,forEach:function(e,t,n){A(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return A(e,(function(){t++})),t},toArray:function(e){return A(e,(function(e){return e}))||[]},only:function(e){if(!O(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=y,t.Fragment=i,t.Profiler=a,t.PureComponent=S,t.StrictMode=o,t.Suspense=l,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=N,t.act=P,t.cloneElement=function(e,t,r){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var i=v({},e.props),o=e.key,a=e.ref,s=e._owner;if(null!=t){if(void 0!==t.ref&&(a=t.ref,s=k.current),void 0!==t.key&&(o=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(u in t)x.call(t,u)&&!I.hasOwnProperty(u)&&(i[u]=void 0===t[u]&&void 0!==c?c[u]:t[u])}var u=arguments.length-2;if(1===u)i.children=r;else if(1<u){c=Array(u);for(var l=0;l<u;l++)c[l]=arguments[l+2];i.children=c}return{$$typeof:n,type:e.type,key:o,ref:a,props:i,_owner:s}},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:s,_context:e},e.Consumer=e},t.createElement=E,t.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:u,render:e}},t.isValidElement=O,t.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:M}},t.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=C.transition;C.transition={};try{e()}finally{C.transition=t}},t.unstable_act=P,t.useCallback=function(e,t){return _.current.useCallback(e,t)},t.useContext=function(e){return _.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return _.current.useDeferredValue(e)},t.useEffect=function(e,t){return _.current.useEffect(e,t)},t.useId=function(){return _.current.useId()},t.useImperativeHandle=function(e,t,n){return _.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return _.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return _.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return _.current.useMemo(e,t)},t.useReducer=function(e,t,n){return _.current.useReducer(e,t,n)},t.useRef=function(e){return _.current.useRef(e)},t.useState=function(e){return _.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return _.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return _.current.useTransition()},t.version="18.3.1"},326:(e,t,n)=>{"use strict";e.exports=n(249)},785:(e,t,n)=>{"use strict";var r=n(326);var i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=r.useState,a=r.useEffect,s=r.useLayoutEffect,c=r.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=o({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s((function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})}),[e,n,t]),a((function(){return u(i)&&l({inst:i}),e((function(){u(i)&&l({inst:i})}))}),[e]),c(n),n};t.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:l},462:(e,t,n)=>{"use strict";var r=n(326),i=n(634);var o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=i.useSyncExternalStore,s=r.useRef,c=r.useEffect,u=r.useMemo,l=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=u((function(){function e(e){if(!c){if(c=!0,a=e,e=r(e),void 0!==i&&f.hasValue){var t=f.value;if(i(t,e))return s=t}return s=e}if(t=s,o(a,e))return t;var n=r(e);return void 0!==i&&i(t,n)?t:(a=e,s=n)}var a,s,c=!1,u=void 0===n?null:n;return[function(){return e(t())},null===u?void 0:function(){return e(u())}]}),[t,n,r,i]);var p=a(e,d[0],d[1]);return c((function(){f.hasValue=!0,f.value=p}),[p]),l(p),p}},634:(e,t,n)=>{"use strict";e.exports=n(785)},100:(e,t,n)=>{"use strict";e.exports=n(462)},741:e=>{e.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}},557:e=>{"use strict";e.exports=c},713:e=>{"use strict";e.exports=s},2:e=>{"use strict";e.exports=n},669:e=>{"use strict";e.exports=o},838:e=>{"use strict";e.exports=t},438:e=>{"use strict";e.exports=i},21:e=>{"use strict";e.exports=r},545:e=>{"use strict";e.exports=a},55:t=>{"use strict";t.exports=e},85:(e,t,n)=>{"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,{A:()=>r})},561:(e,t,n)=>{"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,{A:()=>r})},1:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(236);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(0,r.A)(i.key),i)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}},111:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(236);function i(e,t,n){return(t=(0,r.A)(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},730:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(492);function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||(0,r.A)(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},236:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(224);function i(e){var t=function(e,t){if("object"!=(0,r.A)(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=(0,r.A)(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==(0,r.A)(t)?t:t+""}},224:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}n.d(t,{A:()=>r})},492:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(85);function i(e,t){if(e){if("string"==typeof e)return(0,r.A)(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?(0,r.A)(e,t):void 0}}}},f={};function p(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return d[e](n,n.exports,p),n.exports}p.m=d,u=[],p.O=(e,t,n,r)=>{if(!t){var i=1/0;for(c=0;c<u.length;c++){for(var[t,n,r]=u[c],o=!0,a=0;a<t.length;a++)(!1&r||i>=r)&&Object.keys(p.O).every((e=>p.O[e](t[a])))?t.splice(a--,1):(o=!1,r<i&&(i=r));if(o){u.splice(c--,1);var s=n();void 0!==s&&(e=s)}}return e}r=r||0;for(var c=u.length;c>0&&u[c-1][2]>r;c--)u[c]=u[c-1];u[c]=[t,n,r]},p.F={},p.E=e=>{Object.keys(p.F).map((t=>{p.F[t](e)}))},p.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return p.d(t,{a:t}),t},p.d=(e,t)=>{for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l={524:0},p.F.j=e=>{if(!p.o(l,e)||void 0===l[e]){l[e]=null;var t=document.createElement("link");p.nc&&t.setAttribute("nonce",p.nc),t.rel="prefetch",t.as="script",t.href=p.p+p.u(e),document.head.appendChild(t)}},p.O.j=e=>0===l[e],p.O(0,[524],(()=>{p.E(524)}),5);var h={};return(()=>{"use strict";p.r(h),p.d(h,{default:()=>te,measurementTrackingMode:()=>_.v});var e=p(326),t=p(440),n=p(598),r=p.n(n),i=p(2),o=p(21),a=p.n(o),s=p(55);function c({hide:t,onConfirm:n,message:r}){return e.createElement("div",{className:"text-foreground text-[13px]"},e.createElement("div",null,e.createElement("p",null,r),e.createElement("p",{className:"mt-2"},"This action cannot be undone and will delete all your existing measurements.")),e.createElement(s.FooterAction,{className:"mt-4"},e.createElement(s.FooterAction.Right,null,e.createElement(s.FooterAction.Secondary,{onClick:t},"Cancel"),e.createElement(s.FooterAction.Primary,{onClick:()=>{n(),t()}},"Untrack"))))}const u=["SR","SEG","SM","RTSTRUCT","RTPLAN","RTDOSE","DOC","OT","PMAP"];function l({getImageSrc:n,getStudiesForPatientByMRN:r,requestDisplaySetCreationForStudy:o,dataSource:s}){const{servicesManager:l}=(0,i.useSystem)(),{displaySetService:d,uiModalService:f,measurementService:p,viewportGridService:h}=l.services,[v,g]=(0,t.B)(),{trackedSeries:y}=v.context,m=e=>{if("SR"===d.getDisplaySetByUID(e).Modality){const t=h.getActiveViewportId();g("CHECK_DIRTY",{viewportId:t,displaySetInstanceUID:e})}};(0,e.useEffect)((()=>{const e=h.subscribe(h.EVENTS.VIEWPORT_ONDROP_HANDLED,(({eventData:e})=>{m(e.displaySetInstanceUID)}));return()=>{e.unsubscribe()}}),[]);const S=e=>u.includes(e.Modality)||e?.unsupported?"thumbnailNoImage":"thumbnailTracked";return e.createElement(a(),{getImageSrc:n,getStudiesForPatientByMRN:r,requestDisplaySetCreationForStudy:o,dataSource:s,customMapDisplaySets:(e,t,n,r)=>{const i=[],o=[];return e.filter((e=>!e.excludeFromThumbnailBrowser)).forEach((e=>{const{thumbnailSrc:r,displaySetInstanceUID:a}=e,s=S(e),c="thumbnailTracked"===s?i:o,u=t?.[a];c.push({displaySetInstanceUID:a,description:e.SeriesDescription||"",seriesNumber:e.SeriesNumber,modality:e.Modality,seriesDate:e.SeriesDate?new Date(e.SeriesDate).toLocaleDateString():"",numInstances:e.numImageFrames,loadingProgress:u,countIcon:e.countIcon,messages:e.messages,StudyInstanceUID:e.StudyInstanceUID,componentType:s,imageSrc:r||n[a],dragData:{type:"displayset",displaySetInstanceUID:a},isTracked:y.includes(e.SeriesInstanceUID),isHydratedForDerivedDisplaySet:e.isHydrated})})),[...i,...o]},onClickUntrack:e=>{f.show({title:"Untrack Series",content:c,contentProps:{onConfirm:()=>{const t=d.getDisplaySetByUID(e);g("UNTRACK_SERIES",{SeriesInstanceUID:t.SeriesInstanceUID});p.getMeasurements().forEach((e=>{e.referenceSeriesUID===t.SeriesInstanceUID&&p.remove(e.uid)}))},message:"Are you sure you want to untrack this series?"}})},onDoubleClickThumbnailHandlerCallBack:m})}l.propTypes={dataSource:r().shape({getImageIdsForDisplaySet:r().func.isRequired}).isRequired,getImageSrc:r().func.isRequired,getStudiesForPatientByMRN:r().func.isRequired,requestDisplaySetCreationForStudy:r().func.isRequired};const d=function(e,t){return new Promise(((n,r)=>{const i=document.createElement("canvas");e.utilities.loadImageToCanvas({canvas:i,imageId:t,thumbnail:!0}).then((e=>{n(i.toDataURL())})).catch(r)}))};var f=p(438);const v=function(){const{extensionManager:t}=(0,i.useSystem)(),n=t.getActiveDataSource()[0],r=function(e){const t=e.getModuleEntry("@ohif/extension-default.utilityModule.common"),{getStudiesForPatientByMRN:n}=t.exports;return n}(t).bind(null,n),o=(0,e.useCallback)(function(e){const t=e.getModuleEntry("@ohif/extension-cornerstone.utilityModule.common");try{const{cornerstone:e}=t.exports.getCornerstoneLibraries();return d.bind(null,e)}catch(e){throw new Error("Required command not found")}}(t),[]),a=f.requestDisplaySetCreationForStudy.bind(null,n);return e.createElement(l,{dataSource:n,getImageSrc:o,getStudiesForPatientByMRN:r,requestDisplaySetCreationForStudy:a})};var g=p(669);function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(null,arguments)}const{filterAnd:m,filterPlanarMeasurement:S,filterMeasurementsBySeriesUID:b}=i.utils.MeasurementFilters;const w=function(n){const[r]=(0,s.useViewportGrid)(),{measurementService:i,uiModalService:o}=n.servicesManager.services,[a,u]=(0,t.B)(),{trackedStudy:l,trackedSeries:d}=a.context,f=l?m(S,b(d)):S,p=()=>{u("UNTRACK_ALL",{})},h={createSR:({StudyInstanceUID:e})=>{u("SAVE_REPORT",{viewportId:r.activeViewportId,isBackupSave:!0,StudyInstanceUID:e,measurementFilter:f})},onDelete:()=>{i.getMeasurements().some((e=>e.isDirty))?o.show({title:"Untrack Study",content:c,contentProps:{onConfirm:p,message:"Are you sure you want to untrack study and delete all measurements?"}}):p()}},v=t=>e.createElement(s.AccordionTrigger,{asChild:!0,className:"px-0"},e.createElement("div",{"data-cy":"TrackingHeader"},e.createElement(g.StudySummaryFromMetadata,y({},t,{actions:h}))));return e.createElement(s.ScrollArea,null,e.createElement("div",{"data-cy":"trackedMeasurements-panel"},e.createElement(g.PanelMeasurement,{measurementFilter:f,emptyComponent:()=>e.createElement("div",{"data-cy":"trackedMeasurements-panel"},e.createElement(s.MeasurementTable,{title:"Measurements",isExpanded:!1},e.createElement(s.MeasurementTable.Body,null))),sourceChildren:n.children},e.createElement(g.StudyMeasurements,{grouping:n.grouping},e.createElement(g.AccordionGroup.Trigger,{key:"trackingMeasurementsHeader",asChild:!0},e.createElement(v,{key:"trackingHeadChild"})),e.createElement(g.MeasurementsOrAdditionalFindings,{key:"measurementsOrAdditionalFindings",activeStudyUID:l,customHeader:g.StudyMeasurementsActions,measurementFilter:f,actions:h})))))};var x=p(228);function k(){return k=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},k.apply(null,arguments)}const I=function({commandsManager:t,extensionManager:n,servicesManager:r}){return[{name:"seriesList",iconName:"tab-studies",iconLabel:"Studies",label:x.A.t("SidePanel:Studies"),component:t=>e.createElement(v,t)},{name:"trackedMeasurements",iconName:"tab-linear",iconLabel:"Measure",label:x.A.t("SidePanel:Measurements"),component:i=>e.createElement(w,k({},i,{key:"trackedMeasurements-panel",commandsManager:t,extensionManager:n,servicesManager:r}))}]};function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},E.apply(null,arguments)}const O=e.lazy((()=>Promise.resolve().then(p.bind(p,132)))),D=t=>e.createElement(e.Suspense,{fallback:e.createElement("div",null,"Loading...")},e.createElement(O,t));const T=function({servicesManager:t,commandsManager:n,extensionManager:r}){return[{name:"cornerstone-tracked",component:i=>e.createElement(D,E({servicesManager:t,commandsManager:n,extensionManager:r},i)),isReferenceViewable:e=>g.utils.isReferenceViewable({...e,servicesManager:t})}]},R=JSON.parse('{"UU":"@ohif/extension-measurement-tracking"}').UU;var A=p(545),M=p.n(A),_=p(123);const C=0,N=1,P=3;const j=function({servicesManager:e},t,n){const{viewportId:r,displaySetInstanceUID:i}=n.data||n;return new Promise((async function(t,n){const{uiViewportDialogService:o,customizationService:a}=e.services,s=await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.discardDirtyMessage"),a=[{id:"cancel",type:"cancel",text:"Cancel",value:C},{id:"discard-existing",type:"secondary",text:"No, discard existing",value:P},{id:"save-existing",type:"primary",text:"Yes",value:N}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,id:"measurement-tracking-prompt-dirty-measurement",type:"info",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r(C)},onKeyPress:e=>{if("Enter"===e.key){const e=a.find((e=>"save-existing"===e.id));s(e.value)}}})}))}(o,a,r);t({displaySetInstanceUID:i,userResponse:s,viewportId:r,isBackupSave:!1})}))};var U=p(838);const L=0,V=5;const F=function({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},i,o){const{uiViewportDialogService:a,displaySetService:s,customizationService:c}=e.services,{viewportId:u,displaySetInstanceUID:l}=o,d=s.getDisplaySetByUID(l);return new Promise((async function(i,s){const f=r?.measurementTrackingMode===_.v.STANDARD?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.hydrateSRMessage"),a=[{id:"no-hydrate",type:"secondary",text:"No",value:L},{id:"yes-hydrate",type:"primary",text:"Yes",value:V}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"info",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r(L)},onKeyPress:e=>{if("Enter"===e.key){const e=a.find((e=>e.value===V));s(e.value)}}})}))}(a,c,u):V;let p,h;if(f===V){console.warn("!! HYDRATING STRUCTURED REPORT");const i=(0,U.hydrateStructuredReport)({servicesManager:e,extensionManager:t,commandsManager:n,appConfig:r},l);p=i.StudyInstanceUID,h=i.SeriesInstanceUIDs}i({userResponse:f,displaySetInstanceUID:o.displaySetInstanceUID,srSeriesInstanceUID:d.SeriesInstanceUID,viewportId:u,StudyInstanceUID:p,SeriesInstanceUIDs:h})}))},H=0,B=1,z=2,q=3;const K=function({servicesManager:e,extensionManager:t},n,r){const{UIViewportDialogService:i,customizationService:o}=e.services,{viewportId:a,StudyInstanceUID:s,SeriesInstanceUID:c}=r.data||r;return new Promise((async function(e,r){const u=t._appConfig;let l=u?.measurementTrackingMode===_.v.STANDARD?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.trackNewSeriesMessage"),a=[{type:"secondary",text:"Cancel",value:H},{type:"primary",text:"Create new report",value:B},{type:"primary",text:"Add to existing report",value:z}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"info",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r(H)}})}))}(i,o,a):z;l===B&&(l=n.isDirty?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.discardSeriesMessage"),a=[{type:"secondary",text:"Cancel",value:H},{type:"secondary",text:"Save",value:B},{type:"primary",text:"Discard",value:q}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"warning",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r(H)}})}))}(i,o,a):q),e({userResponse:l,StudyInstanceUID:s,SeriesInstanceUID:c,viewportId:a,isBackupSave:!1})}))},$=0,W=1,Y=3,J=4;const G=function({servicesManager:e,extensionManager:t},n,r){const{uiViewportDialogService:i,customizationService:o}=e.services,{viewportId:a,StudyInstanceUID:s,SeriesInstanceUID:c}=r.data||r;return new Promise((async function(e,r){const u=t._appConfig,l=u?.measurementTrackingMode===_.v.STANDARD,d=u?.measurementTrackingMode===_.v.SIMPLIFIED;let f=l?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.trackNewStudyMessage"),a=[{type:"cancel",text:x.A.t("MeasurementTable:No"),value:$},{type:"secondary",text:x.A.t("MeasurementTable:No, do not ask again"),value:J},{type:"primary",text:x.A.t("MeasurementTable:Yes"),value:Y}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"info",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r($)},onKeyPress:e=>{if("Enter"===e.key){const e=a.find((e=>e.value===Y));s(e.value)}}})}))}(i,o,a):Y;f===Y&&(f=n.isDirty&&(l||d)?await function(e,t,n){return new Promise((function(r,i){const o=t.getCustomization("viewportNotification.discardStudyMessage"),a=[{type:"cancel",text:"Cancel",value:$},{type:"secondary",text:"No, discard previously tracked series & measurements",value:Y},{type:"primary",text:"Yes",value:W}],s=t=>{e.hide(),r(t)};e.show({viewportId:n,type:"warning",message:o,actions:a,onSubmit:s,onOutsideClick:()=>{e.hide(),r($)}})}))}(i,o,a):Y),e({userResponse:f,StudyInstanceUID:s,SeriesInstanceUID:c,viewportId:a,isBackupSave:!1})}))},Q={"measurement.promptBeginTracking":_.A,"measurement.promptHydrateStructuredReport":F,"measurement.promptTrackNewSeries":K,"measurement.promptTrackNewStudy":G,"measurement.promptLabelAnnotation":f.promptLabelAnnotation,"measurement.promptSaveReport":f.promptSaveReport,"measurement.promptHasDirtyAnnotations":j};const X={callbacks:[({activeViewportId:e,servicesManager:t,isHangingProtocolLayout:n,appConfig:r})=>async i=>{const{hangingProtocolService:o,viewportGridService:a,uiNotificationService:s}=t.services;let c=[];const u=e,l=ee({servicesManager:t,appConfig:r,displaySetInstanceUID:i});try{l||(c=o.getViewportsRequireUpdate(u,i,n),a.setDisplaySetsForViewports(c))}catch(e){console.warn(e),s.show({title:"Thumbnail Double Click",message:"The selected display sets could not be added to the viewport.",type:"error",duration:3e3})}}]},Z=async e=>{const t=ee(e);return Promise.resolve({handled:t})},ee=e=>{const{servicesManager:t,appConfig:n,displaySetInstanceUID:r}=e,i=n.measurementTrackingMode===_.v.SIMPLIFIED,{measurementService:o,displaySetService:a}=t.services,s=o.getMeasurements(),c=s.some((e=>e.isDirty))||s.length&&o.getIsMeasurementDeletedIndividually();return"SR"===a.getDisplaySetByUID(r).Modality&&i&&c},te={id:R,getContextModule:t.A,getPanelModule:I,getViewportModule:T,onModeEnter({servicesManager:t}){const{toolbarService:n,customizationService:r}=t.services;r.setCustomizations({"studyBrowser.thumbnailDoubleClickCallback":{$set:X},customOnDropHandler:{$set:Z}}),n.addButtons([{id:"loadSRMeasurements",component:t=>e.createElement(s.ViewportActionButton,t,M().t("Common:LOAD")),props:{commands:["loadTrackedSRMeasurements"]}}],!0)},getCustomizationModule:function(){return[{name:"default",value:{...Q}}]}}})(),h=p.O(h)})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohif/extension-measurement-tracking",
3
- "version": "3.10.0",
3
+ "version": "3.10.2",
4
4
  "description": "Tracking features and functionality for basic image viewing",
5
5
  "author": "OHIF Core Team",
6
6
  "license": "MIT",
@@ -32,12 +32,12 @@
32
32
  "start": "yarn run dev"
33
33
  },
34
34
  "peerDependencies": {
35
- "@cornerstonejs/core": "^3.9.5",
36
- "@cornerstonejs/tools": "^3.9.5",
37
- "@ohif/core": "3.10.0",
38
- "@ohif/extension-cornerstone-dicom-sr": "3.10.0",
39
- "@ohif/extension-default": "3.10.0",
40
- "@ohif/ui": "3.10.0",
35
+ "@cornerstonejs/core": "^3.11.6",
36
+ "@cornerstonejs/tools": "^3.11.6",
37
+ "@ohif/core": "3.10.2",
38
+ "@ohif/extension-cornerstone-dicom-sr": "3.10.2",
39
+ "@ohif/extension-default": "3.10.2",
40
+ "@ohif/ui": "3.10.2",
41
41
  "classnames": "^2.3.2",
42
42
  "dcmjs": "*",
43
43
  "lodash.debounce": "^4.0.8",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@babel/runtime": "^7.20.13",
52
- "@ohif/ui": "3.10.0",
52
+ "@ohif/ui": "3.10.2",
53
53
  "@xstate/react": "^3.2.2",
54
54
  "xstate": "^4.10.0"
55
55
  }