@fnndsc/argus 0.37.0 → 0.37.1

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.
Files changed (25) hide show
  1. package/dist/assets/{Settings-CZ3JnQ0s.js → Settings-CiFb_at6.js} +1 -1
  2. package/dist/assets/{Texture-DN4nnuQU.js → Texture-DhflYwlm.js} +1 -1
  3. package/dist/assets/{addVolumesToViewports-I9qMhr8x.js → addVolumesToViewports-BvxIbA7o.js} +1 -1
  4. package/dist/assets/{cornerstoneEngine-6cb4qtUU.js → cornerstoneEngine-D1k_eGOf.js} +2 -2
  5. package/dist/assets/{field-D_1hHgxN.js → field-CVqP2pjA.js} +3 -3
  6. package/dist/assets/{index-9IJ0xse9.js → index--MRRVo__.js} +20 -20
  7. package/dist/assets/{index-6Z7HsM43.js → index-7Ulblajz.js} +1 -1
  8. package/dist/assets/{index-CT814q15.js → index-B2EEDQ0S.js} +1 -1
  9. package/dist/assets/{index-Co74L2hr.js → index-BLByZ5mm.js} +1 -1
  10. package/dist/assets/{index-Cbp8pEtU.js → index-BXHkr7Bw.js} +1 -1
  11. package/dist/assets/{index-71keycbK.js → index-BbBa1uNR.js} +1 -1
  12. package/dist/assets/{index-CbGOYpkN.js → index-BpUGoSu9.js} +1 -1
  13. package/dist/assets/{index-CilvCpdu.js → index-C2JM3oDu.js} +1 -1
  14. package/dist/assets/{index-BlayAFw4.js → index-CcOc5bdF.js} +1 -1
  15. package/dist/assets/{index-BIhCHZVs.js → index-D1BriUrd.js} +1 -1
  16. package/dist/assets/{index-aRaJY9Z8.js → index-D3jvh9AY.js} +1 -1
  17. package/dist/assets/{index-CLwmnLeZ.js → index-DKcPBiab.js} +1 -1
  18. package/dist/assets/{index-CQw-Bjzp.js → index-gWdcJ-9p.js} +1 -1
  19. package/dist/assets/{index-CwLCtjpC.js → index-hxIuWoKe.js} +1 -1
  20. package/dist/assets/{niivueEngine-CP2F-jXg.js → niivueEngine-ByYkmgV5.js} +2 -2
  21. package/dist/assets/{slabScene-BMO_3kWF.js → slabScene-CnGTvh8e.js} +1 -1
  22. package/dist/build.json +1 -1
  23. package/dist/index.html +1 -1
  24. package/dist/notes.json +1 -1
  25. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import We,{data as A,normalizers as k,utilities as D,derivations as Ie,constants as hn,sr as yn}from"./dcmjs.es-DfWkgqfk.js";import{bY as Bt,bZ as Yt,dA as Dn,at as Tn,cD as Kt,t as Cn,e as bn,bi as q,cp as $e,cs as Rn}from"./Settings-CZ3JnQ0s.js";import"./cornerstoneEngine-6cb4qtUU.js";import"./Texture-DN4nnuQU.js";import{m as Mn,t as Pn}from"./throttle-CjIII7Yf.js";import"./index-9IJ0xse9.js";import"./refusal-DOpm8I8L.js";import"./_commonjsHelpers-CE1G-McA.js";const R=r=>Array.isArray(r)?r:r!==void 0?[r]:[],Pe=r=>e=>e.ConceptNameCodeSequence.CodeMeaning===r;A.datasetToBlob;const vn=Bt;let Nn=vn;function E(r,e){let t=r.is3DMeasurement,n=r.referencedImageId;if(t)return{x:e[0],y:e[1],z:e[2]};const a=Nn(n,e);return{x:a[0],y:a[1]}}function Q(r,e){return e.map(t=>E(r,t))}const En=Yt;function pe(r,e){let t=r.is3DMeasurement,n=r.referencedImageId;const a=[];if(t){const o=e.GraphicData;for(let s=0;s<o.length;s+=3){const i=[o[s],o[s+1],o[s+2]];a.push(i)}}else{const o=e.GraphicData;for(let s=0;s<o.length;s+=2){const i=En(n,[o[s],o[s+1]]);a.push(i)}}return a}const zt=D.TID1500,st=D.addAccessors,wn=Ie.StructuredReport,An=k.Normalizer,Un=zt.TID1500MeasurementReport,jn=zt.TID1501MeasurementGroup,xn=A.DicomMetaDictionary,Gn={CodingSchemeDesignator:"DCM",CodeValue:"121071"},_n={CodingSchemeDesignator:"SCT",CodeValue:"363698007"},Vn={CodingSchemeDesignator:"SRT",CodeValue:"G-C0E3"},it=(r,e,t)=>{const n=r.ConceptNameCodeSequence;if(!n)return;const a=n.CodingSchemeDesignator,o=n.CodeValue;return a==e.CodingSchemeDesignator&&o==e.CodeValue||t&&a==t.CodingSchemeDesignator&&o==t.CodeValue};function $n(r,e,t){const n=t.getTID300RepresentationArguments(r);return n.ReferencedSOPSequence=e,n.ReferencedFrameOfReferenceUID=n.use3DSpatialCoordinates?r.metadata.FrameOfReferenceUID:null,new t.TID300Representation(n)}function qn(r,e,t){const n=e[r],a=M.CORNERSTONE_TOOL_CLASSES_BY_TOOL_TYPE[r];if(!n||!n.data||!n.data.length||!a)return;const o=n.data.map(s=>$n(s,t,a));return new jn(o)}let M=class ue{static getSetupMeasurementData(e){const t=e.ContentSequence,n=R(t),a=n.find(g=>it(g,Gn)),o=n.filter(g=>it(g,_n,Vn))||[],s=n.find(g=>g.ValueType==="NUM"),i=R(s.ContentSequence).find(g=>g.ValueType==="SCOORD"),c=i.ContentSequence.ReferencedSOPSequence,u=c.ReferencedSOPInstanceUID,l=c.ReferencedFrameNumber,d={sopInstanceUid:u,frameIndex:l||1,complete:!0,finding:a?st(a.ConceptCodeSequence):void 0,findingSites:o.map(g=>st(g.ConceptCodeSequence))};d.finding&&(d.description=d.finding.CodeMeaning);const p=d.findingSites&&d.findingSites[0];return p&&(d.location=p[0]&&p[0].CodeMeaning||p.CodeMeaning),{defaultState:d,findingGroup:a,findingSiteGroups:o,NUMGroup:s,SCOORDGroup:i,ReferencedSOPSequence:c,ReferencedSOPInstanceUID:u,ReferencedFrameNumber:l}}static generateReport(e,t,n){let a=[];const o=Object.keys(e)[0];if(!o)throw new Error("No measurements provided.");const s=t.get("generalSeriesModule",o),i=s.studyInstanceUID,c=s.seriesInstanceUID;Object.keys(e).forEach(m=>{const h=t.get("sopCommonModule",m),O=t.get("frameNumber",m),y=e[m],S=Object.keys(y),b={ReferencedSOPClassUID:h.sopClassUID,ReferencedSOPInstanceUID:h.sopInstanceUID};An.isMultiframeSOPClassUID(h.sopClassUID)&&(b.ReferencedFrameNumber=O);const T=[];S.forEach(v=>{const j=qn(v,y,b);j&&T.push(j)}),a=a.concat(T)});const u=new Un({TID1501MeasurementGroups:a},n),l=new Uint8Array(2);l[1]=1;const d={StudyInstanceUID:i,SeriesInstanceUID:c},p={FileMetaInformationVersion:{Value:[l.buffer],vr:"OB"},TransferSyntaxUID:{Value:["1.2.840.10008.1.2.1"],vr:"UI"},ImplementationClassUID:{Value:[xn.uid()],vr:"UI"},ImplementationVersionName:{Value:["dcmjs"],vr:"SH"}},g={PixelData:"OW"};d._meta=p,d._vrMap=g;const f=new wn([d]),I=u.contentItem(d);return f.dataset=Object.assign(f.dataset,I),f.dataset._meta=p,f.dataset.SpecificCharacterSet="ISO_IR 192",f}static generateToolState(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e.ContentTemplateSequence.TemplateIdentifier!=="1500")throw new Error("This package can currently only interpret DICOM SR TID 1500");const n="Imaging Measurements",a="Measurement Group",o="Tracking Identifier",s=R(e.ContentSequence).find(Pe(n)),i=R(s.ContentSequence).filter(Pe(a)),c={},u=ue.CORNERSTONE_TOOL_CLASSES_BY_UTILITY_TYPE,l=[];return Object.keys(u).forEach(d=>{l.push(u[d]),c[d]=[]}),i.forEach(d=>{const f=R(d.ContentSequence).find(m=>m.ConceptNameCodeSequence.CodeMeaning===o).TextValue,I=t.getToolClass?t.getToolClass(d,e,l):l.find(m=>m.isValidCornerstoneTrackingIdentifier(f));if(I){const m=I.getMeasurementData(d);console.log("=== ".concat(I.toolType," ===")),console.log(m),c[I.toolType].push(m)}}),c}static registerTool(e){ue.CORNERSTONE_TOOL_CLASSES_BY_UTILITY_TYPE[e.utilityToolType]=e,ue.CORNERSTONE_TOOL_CLASSES_BY_TOOL_TYPE[e.toolType]=e,ue.MEASUREMENT_BY_TOOLTYPE[e.toolType]=e.utilityToolType}};M.MEASUREMENT_BY_TOOLTYPE={};M.CORNERSTONE_TOOL_CLASSES_BY_UTILITY_TYPE={};M.CORNERSTONE_TOOL_CLASSES_BY_TOOL_TYPE={};function Fn(r){if(Array.isArray(r))return r}function Ln(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,a,o,s,i=[],c=!0,u=!1;try{if(o=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=o.call(t)).done)&&(i.push(n.value),i.length!==e);c=!0);}catch(l){u=!0,a=l}finally{try{if(!c&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(u)throw a}}return i}}function ct(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function kn(r,e){if(r){if(typeof r=="string")return ct(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ct(r,e):void 0}}function Bn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import We,{data as A,normalizers as k,utilities as D,derivations as Ie,constants as hn,sr as yn}from"./dcmjs.es-DfWkgqfk.js";import{bY as Bt,bZ as Yt,dA as Dn,at as Tn,cD as Kt,t as Cn,e as bn,bi as q,cp as $e,cs as Rn}from"./Settings-CiFb_at6.js";import"./cornerstoneEngine-D1k_eGOf.js";import"./Texture-DhflYwlm.js";import{m as Mn,t as Pn}from"./throttle-CjIII7Yf.js";import"./index--MRRVo__.js";import"./refusal-DOpm8I8L.js";import"./_commonjsHelpers-CE1G-McA.js";const R=r=>Array.isArray(r)?r:r!==void 0?[r]:[],Pe=r=>e=>e.ConceptNameCodeSequence.CodeMeaning===r;A.datasetToBlob;const vn=Bt;let Nn=vn;function E(r,e){let t=r.is3DMeasurement,n=r.referencedImageId;if(t)return{x:e[0],y:e[1],z:e[2]};const a=Nn(n,e);return{x:a[0],y:a[1]}}function Q(r,e){return e.map(t=>E(r,t))}const En=Yt;function pe(r,e){let t=r.is3DMeasurement,n=r.referencedImageId;const a=[];if(t){const o=e.GraphicData;for(let s=0;s<o.length;s+=3){const i=[o[s],o[s+1],o[s+2]];a.push(i)}}else{const o=e.GraphicData;for(let s=0;s<o.length;s+=2){const i=En(n,[o[s],o[s+1]]);a.push(i)}}return a}const zt=D.TID1500,st=D.addAccessors,wn=Ie.StructuredReport,An=k.Normalizer,Un=zt.TID1500MeasurementReport,jn=zt.TID1501MeasurementGroup,xn=A.DicomMetaDictionary,Gn={CodingSchemeDesignator:"DCM",CodeValue:"121071"},_n={CodingSchemeDesignator:"SCT",CodeValue:"363698007"},Vn={CodingSchemeDesignator:"SRT",CodeValue:"G-C0E3"},it=(r,e,t)=>{const n=r.ConceptNameCodeSequence;if(!n)return;const a=n.CodingSchemeDesignator,o=n.CodeValue;return a==e.CodingSchemeDesignator&&o==e.CodeValue||t&&a==t.CodingSchemeDesignator&&o==t.CodeValue};function $n(r,e,t){const n=t.getTID300RepresentationArguments(r);return n.ReferencedSOPSequence=e,n.ReferencedFrameOfReferenceUID=n.use3DSpatialCoordinates?r.metadata.FrameOfReferenceUID:null,new t.TID300Representation(n)}function qn(r,e,t){const n=e[r],a=M.CORNERSTONE_TOOL_CLASSES_BY_TOOL_TYPE[r];if(!n||!n.data||!n.data.length||!a)return;const o=n.data.map(s=>$n(s,t,a));return new jn(o)}let M=class ue{static getSetupMeasurementData(e){const t=e.ContentSequence,n=R(t),a=n.find(g=>it(g,Gn)),o=n.filter(g=>it(g,_n,Vn))||[],s=n.find(g=>g.ValueType==="NUM"),i=R(s.ContentSequence).find(g=>g.ValueType==="SCOORD"),c=i.ContentSequence.ReferencedSOPSequence,u=c.ReferencedSOPInstanceUID,l=c.ReferencedFrameNumber,d={sopInstanceUid:u,frameIndex:l||1,complete:!0,finding:a?st(a.ConceptCodeSequence):void 0,findingSites:o.map(g=>st(g.ConceptCodeSequence))};d.finding&&(d.description=d.finding.CodeMeaning);const p=d.findingSites&&d.findingSites[0];return p&&(d.location=p[0]&&p[0].CodeMeaning||p.CodeMeaning),{defaultState:d,findingGroup:a,findingSiteGroups:o,NUMGroup:s,SCOORDGroup:i,ReferencedSOPSequence:c,ReferencedSOPInstanceUID:u,ReferencedFrameNumber:l}}static generateReport(e,t,n){let a=[];const o=Object.keys(e)[0];if(!o)throw new Error("No measurements provided.");const s=t.get("generalSeriesModule",o),i=s.studyInstanceUID,c=s.seriesInstanceUID;Object.keys(e).forEach(m=>{const h=t.get("sopCommonModule",m),O=t.get("frameNumber",m),y=e[m],S=Object.keys(y),b={ReferencedSOPClassUID:h.sopClassUID,ReferencedSOPInstanceUID:h.sopInstanceUID};An.isMultiframeSOPClassUID(h.sopClassUID)&&(b.ReferencedFrameNumber=O);const T=[];S.forEach(v=>{const j=qn(v,y,b);j&&T.push(j)}),a=a.concat(T)});const u=new Un({TID1501MeasurementGroups:a},n),l=new Uint8Array(2);l[1]=1;const d={StudyInstanceUID:i,SeriesInstanceUID:c},p={FileMetaInformationVersion:{Value:[l.buffer],vr:"OB"},TransferSyntaxUID:{Value:["1.2.840.10008.1.2.1"],vr:"UI"},ImplementationClassUID:{Value:[xn.uid()],vr:"UI"},ImplementationVersionName:{Value:["dcmjs"],vr:"SH"}},g={PixelData:"OW"};d._meta=p,d._vrMap=g;const f=new wn([d]),I=u.contentItem(d);return f.dataset=Object.assign(f.dataset,I),f.dataset._meta=p,f.dataset.SpecificCharacterSet="ISO_IR 192",f}static generateToolState(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e.ContentTemplateSequence.TemplateIdentifier!=="1500")throw new Error("This package can currently only interpret DICOM SR TID 1500");const n="Imaging Measurements",a="Measurement Group",o="Tracking Identifier",s=R(e.ContentSequence).find(Pe(n)),i=R(s.ContentSequence).filter(Pe(a)),c={},u=ue.CORNERSTONE_TOOL_CLASSES_BY_UTILITY_TYPE,l=[];return Object.keys(u).forEach(d=>{l.push(u[d]),c[d]=[]}),i.forEach(d=>{const f=R(d.ContentSequence).find(m=>m.ConceptNameCodeSequence.CodeMeaning===o).TextValue,I=t.getToolClass?t.getToolClass(d,e,l):l.find(m=>m.isValidCornerstoneTrackingIdentifier(f));if(I){const m=I.getMeasurementData(d);console.log("=== ".concat(I.toolType," ===")),console.log(m),c[I.toolType].push(m)}}),c}static registerTool(e){ue.CORNERSTONE_TOOL_CLASSES_BY_UTILITY_TYPE[e.utilityToolType]=e,ue.CORNERSTONE_TOOL_CLASSES_BY_TOOL_TYPE[e.toolType]=e,ue.MEASUREMENT_BY_TOOLTYPE[e.toolType]=e.utilityToolType}};M.MEASUREMENT_BY_TOOLTYPE={};M.CORNERSTONE_TOOL_CLASSES_BY_UTILITY_TYPE={};M.CORNERSTONE_TOOL_CLASSES_BY_TOOL_TYPE={};function Fn(r){if(Array.isArray(r))return r}function Ln(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,a,o,s,i=[],c=!0,u=!1;try{if(o=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=o.call(t)).done)&&(i.push(n.value),i.length!==e);c=!0);}catch(l){u=!0,a=l}finally{try{if(!c&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(u)throw a}}return i}}function ct(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function kn(r,e){if(r){if(typeof r=="string")return ct(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ct(r,e):void 0}}function Bn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function w(r,e){return Fn(r)||Ln(r,e)||kn(r,e)||Bn()}function me(r){"@babel/helpers - typeof";return me=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},me(r)}function Yn(r,e){if(me(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(me(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Kn(r){var e=Yn(r,"string");return me(e)=="symbol"?e:e+""}function P(r,e,t){return(e=Kn(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var $="cornerstoneTools@^4.0.0";function ut(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function dt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ut(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ut(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const zn=D.TID300.Length,Qe="Length";let J=class Xt{static getMeasurementData(e){const t=M.getSetupMeasurementData(e),n=t.defaultState,a=t.NUMGroup,o=t.SCOORDGroup,s=dt(dt({},n),{},{length:a.MeasuredValueSequence.NumericValue,toolType:Xt.toolType,handles:{start:{},end:{},textBox:{hasMoved:!1,movesIndependently:!1,drawnIndependently:!0,allowedOutsideImage:!0,hasBoundingBox:!0}}});var i=w(o.GraphicData,4);return s.handles.start.x=i[0],s.handles.start.y=i[1],s.handles.end.x=i[2],s.handles.end.y=i[3],s}static getTID300RepresentationArguments(e){const t=e.handles,n=e.finding,a=e.findingSites,o=t.start,s=t.end,i=e.length;return{point1:o,point2:s,distance:i,trackingIdentifierTextValue:"cornerstoneTools@^4.0.0:Length",finding:n,findingSites:a||[]}}};J.toolType=Qe;J.utilityToolType=Qe;J.TID300Representation=zn;J.isValidCornerstoneTrackingIdentifier=r=>{if(!r.includes(":"))return!1;const e=r.split(":"),t=w(e,2),n=t[0],a=t[1];return n!==$?!1:a===Qe};M.registerTool(J);function lt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function pt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?lt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):lt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Xn=D.TID300.Polyline;class _{static getMeasurementData(e){const t=M.getSetupMeasurementData(e),n=t.defaultState,a=t.SCOORDGroup,o=t.NUMGroup,s=pt(pt({},n),{},{toolType:_.toolType,handles:{points:[],textBox:{active:!1,hasMoved:!1,movesIndependently:!1,drawnIndependently:!0,allowedOutsideImage:!0,hasBoundingBox:!0}},cachedStats:{area:o?o.MeasuredValueSequence.NumericValue:0},color:void 0,invalidated:!0}),i=a.GraphicData;for(let c=0;c<i.length;c+=2)s.handles.points.push({x:i[c],y:i[c+1]});return s}static getTID300RepresentationArguments(e){const t=e.handles,n=e.finding,a=e.findingSites,o=e.cachedStats,s=o===void 0?{}:o,i=t.points,c=s.area,u=c===void 0?0:c,l=s.perimeter;return{points:i,area:u,perimeter:l===void 0?0:l,trackingIdentifierTextValue:"cornerstoneTools@^4.0.0:FreehandRoi",finding:n,findingSites:a||[]}}}_.toolType="FreehandRoi";_.utilityToolType="FreehandRoi";_.TID300Representation=Xn;_.isValidCornerstoneTrackingIdentifier=r=>{if(!r.includes(":"))return!1;const e=r.split(":"),t=w(e,2),n=t[0],a=t[1];return n!==$?!1:a===_.toolType};M.registerTool(_);const Hn=D.TID300.Bidirectional,Je="Bidirectional",Wn="Long Axis",Qn="Short Axis",Jn="121071",Zn="G-C0E3";let Z=class Ht{static getMeasurementData(e){const t=e.ContentSequence,n=R(t).find(m=>m.ConceptNameCodeSequence.CodeValue===Jn),a=R(t).filter(m=>m.ConceptNameCodeSequence.CodeValue===Zn),o=R(t).find(m=>m.ConceptNameCodeSequence.CodeMeaning===Wn),s=R(o.ContentSequence).find(m=>m.ValueType==="SCOORD"),i=R(t).find(m=>m.ConceptNameCodeSequence.CodeMeaning===Qn),c=R(i.ContentSequence).find(m=>m.ValueType==="SCOORD"),u=s.ContentSequence.ReferencedSOPSequence,l=u.ReferencedSOPInstanceUID,d=u.ReferencedFrameNumber,p=String(o.MeasuredValueSequence.NumericValue),g=String(i.MeasuredValueSequence.NumericValue),f={x:Math.max(s.GraphicData[0],s.GraphicData[2],c.GraphicData[0],c.GraphicData[2]),y:Math.max(s.GraphicData[1],s.GraphicData[3],c.GraphicData[1],c.GraphicData[3])};return{sopInstanceUid:l,frameIndex:d||1,toolType:Ht.toolType,active:!1,handles:{start:{x:s.GraphicData[0],y:s.GraphicData[1],drawnIndependently:!1,allowedOutsideImage:!1,active:!1,highlight:!1,index:0},end:{x:s.GraphicData[2],y:s.GraphicData[3],drawnIndependently:!1,allowedOutsideImage:!1,active:!1,highlight:!1,index:1},perpendicularStart:{x:c.GraphicData[0],y:c.GraphicData[1],drawnIndependently:!1,allowedOutsideImage:!1,active:!1,highlight:!1,index:2},perpendicularEnd:{x:c.GraphicData[2],y:c.GraphicData[3],drawnIndependently:!1,allowedOutsideImage:!1,active:!1,highlight:!1,index:3},textBox:{highlight:!1,hasMoved:!0,active:!1,movesIndependently:!1,drawnIndependently:!0,allowedOutsideImage:!0,hasBoundingBox:!0,x:f.x+10,y:f.y+10}},invalidated:!1,isCreating:!1,longestDiameter:p,shortestDiameter:g,toolName:"Bidirectional",visible:!0,finding:n?n.ConceptCodeSequence:void 0,findingSites:a.map(m=>m.ConceptCodeSequence)}}static getTID300RepresentationArguments(e){const t=e.handles,n=t.start,a=t.end,o=t.perpendicularStart,s=t.perpendicularEnd,i=e.shortestDiameter,c=e.longestDiameter,u=e.finding,l=e.findingSites;return{longAxis:{point1:n,point2:a},shortAxis:{point1:o,point2:s},longAxisLength:c,shortAxisLength:i,trackingIdentifierTextValue:"cornerstoneTools@^4.0.0:Bidirectional",finding:u,findingSites:l||[]}}};Z.toolType=Je;Z.utilityToolType=Je;Z.TID300Representation=Hn;Z.isValidCornerstoneTrackingIdentifier=r=>{if(!r.includes(":"))return!1;const e=r.split(":"),t=w(e,2),n=t[0],a=t[1];return n!==$?!1:a===Je};M.registerTool(Z);function gt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function ft(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?gt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):gt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const er=D.TID300.Ellipse,Ze="EllipticalRoi";class B{static getMeasurementData(e){const t=M.getSetupMeasurementData(e),n=t.defaultState,a=t.NUMGroup,s=t.SCOORDGroup.GraphicData,i=[{x:s[0],y:s[1]},{x:s[2],y:s[3]}],c=[{x:s[4],y:s[5]},{x:s[6],y:s[7]}],u=Math.sqrt(Math.pow(c[0].x-c[1].x,2)+Math.pow(c[0].y-c[1].y,2)),l={x:(c[1].x-c[0].x)/u,y:(c[1].y-c[0].y)/u},d=u/2,p={x:i[0].x+l.x*d,y:i[0].y+l.y*d},g={x:i[1].x-l.x*d,y:i[1].y-l.y*d};return ft(ft({},n),{},{toolType:B.toolType,active:!1,cachedStats:{area:a?a.MeasuredValueSequence.NumericValue:0},handles:{end:{x:p.x,y:p.y,highlight:!1,active:!1},initialRotation:0,start:{x:g.x,y:g.y,highlight:!1,active:!1},textBox:{hasMoved:!1,movesIndependently:!1,drawnIndependently:!0,allowedOutsideImage:!0,hasBoundingBox:!0}},invalidated:!0,visible:!0})}static getTID300RepresentationArguments(e){const t=e.cachedStats,n=t===void 0?{}:t,a=e.handles,o=e.finding,s=e.findingSites,i=a.start,c=a.end,u=n.area,l=Math.abs(i.x-c.x)/2,d=Math.abs(i.y-c.y)/2,p=[],g={x:(i.x+c.x)/2,y:(i.y+c.y)/2};return l>d?(p.push({x:g.x-l,y:g.y}),p.push({x:g.x+l,y:g.y}),p.push({x:g.x,y:g.y-d}),p.push({x:g.x,y:g.y+d})):(p.push({x:g.x,y:g.y-d}),p.push({x:g.x,y:g.y+d}),p.push({x:g.x-l,y:g.y}),p.push({x:g.x+l,y:g.y})),{area:u,points:p,trackingIdentifierTextValue:"cornerstoneTools@^4.0.0:EllipticalRoi",finding:o,findingSites:s||[]}}}B.toolType=Ze;B.utilityToolType=Ze;B.TID300Representation=er;B.isValidCornerstoneTrackingIdentifier=r=>{if(!r.includes(":"))return!1;const e=r.split(":"),t=w(e,2),n=t[0],a=t[1];return n!==$?!1:a===Ze};M.registerTool(B);function mt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function X(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?mt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):mt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const tr=D.TID300.Circle,et="CircleRoi";class Y{static getMeasurementData(e){const t=M.getSetupMeasurementData(e),n=t.defaultState,a=t.NUMGroup,s=t.SCOORDGroup.GraphicData,i={x:s[0],y:s[1]},c={x:s[2],y:s[3]};return X(X({},n),{},{toolType:Y.toolType,active:!1,cachedStats:{area:a?a.MeasuredValueSequence.NumericValue:0,radius:0,perimeter:0},handles:{end:X(X({},c),{},{highlight:!1,active:!1}),initialRotation:0,start:X(X({},i),{},{highlight:!1,active:!1}),textBox:{hasMoved:!1,movesIndependently:!1,drawnIndependently:!0,allowedOutsideImage:!0,hasBoundingBox:!0}},invalidated:!0,visible:!0})}static getTID300RepresentationArguments(e){const t=e.cachedStats,n=t===void 0?{}:t,a=e.handles,o=e.finding,s=e.findingSites,i=a.start,c=a.end,u=n.area,l=n.radius,d=2*Math.PI*l,p=[];return p.push(i),p.push(c),{area:u,perimeter:d,radius:l,points:p,trackingIdentifierTextValue:"cornerstoneTools@^4.0.0:CircleRoi",finding:o,findingSites:s||[]}}}Y.toolType=et;Y.utilityToolType=et;Y.TID300Representation=tr;Y.isValidCornerstoneTrackingIdentifier=r=>{if(!r.includes(":"))return!1;const e=r.split(":"),t=w(e,2),n=t[0],a=t[1];return n!==$?!1:a===et};M.registerTool(Y);function It(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function St(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?It(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):It(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const nr=D.TID300.Point,tt="ArrowAnnotate",Ot="CORNERSTONEFREETEXT";let ee=class Wt{static getMeasurementData(e){const t=M.getSetupMeasurementData(e),n=t.defaultState,a=t.SCOORDGroup;t.findingGroup;const o=a.GraphicData;return St(St({},n),{},{toolType:Wt.toolType,active:!1,handles:{start:{x:o[0],y:o[1],highlight:!0,active:!1},end:{x:o.length==4?o[2]:o[0]+20,y:o.length==4?o[3]:o[1]+20,highlight:!0,active:!1},textBox:{hasMoved:!1,movesIndependently:!1,drawnIndependently:!0,allowedOutsideImage:!0,hasBoundingBox:!0}},invalidated:!0,visible:!0})}static getTID300RepresentationArguments(e){const t=[e.handles.start,e.handles.end],n=e.findingSites;let a=e.finding;const o={points:t,trackingIdentifierTextValue:"cornerstoneTools@^4.0.0:ArrowAnnotate",findingSites:n||[]};return(!a||a.CodeValue!==Ot)&&(a={CodeValue:Ot,CodingSchemeDesignator:"CST4",CodeMeaning:e.label}),o.finding=a,o}};ee.toolType=tt;ee.utilityToolType=tt;ee.TID300Representation=nr;ee.isValidCornerstoneTrackingIdentifier=r=>{if(!r.includes(":"))return!1;const e=r.split(":"),t=w(e,2),n=t[0],a=t[1];return n!==$?!1:a===tt};M.registerTool(ee);function ht(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function yt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ht(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ht(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const rr=D.TID300.CobbAngle,nt="CobbAngle";let te=class Qt{static getMeasurementData(e){const t=M.getSetupMeasurementData(e),n=t.defaultState,a=t.NUMGroup,o=t.SCOORDGroup,s=yt(yt({},n),{},{rAngle:a.MeasuredValueSequence.NumericValue,toolType:Qt.toolType,handles:{start:{},end:{},start2:{highlight:!0,drawnIndependently:!0},end2:{highlight:!0,drawnIndependently:!0},textBox:{hasMoved:!1,movesIndependently:!1,drawnIndependently:!0,allowedOutsideImage:!0,hasBoundingBox:!0}}});var i=w(o.GraphicData,8);return s.handles.start.x=i[0],s.handles.start.y=i[1],s.handles.end.x=i[2],s.handles.end.y=i[3],s.handles.start2.x=i[4],s.handles.start2.y=i[5],s.handles.end2.x=i[6],s.handles.end2.y=i[7],s}static getTID300RepresentationArguments(e){const t=e.handles,n=e.finding,a=e.findingSites,o=t.start,s=t.end,i=t.start2,c=t.end2,u=e.rAngle;return{point1:o,point2:s,point3:i,point4:c,rAngle:u,trackingIdentifierTextValue:"cornerstoneTools@^4.0.0:CobbAngle",finding:n,findingSites:a||[]}}};te.toolType=nt;te.utilityToolType=nt;te.TID300Representation=rr;te.isValidCornerstoneTrackingIdentifier=r=>{if(!r.includes(":"))return!1;const e=r.split(":"),t=w(e,2),n=t[0],a=t[1];return n!==$?!1:a===nt};M.registerTool(te);function Dt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function Tt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Dt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Dt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const ar=D.TID300.Angle,rt="Angle";let ne=class Jt{static getMeasurementData(e){const t=M.getSetupMeasurementData(e),n=t.defaultState,a=t.NUMGroup,o=t.SCOORDGroup,s=Tt(Tt({},n),{},{rAngle:a.MeasuredValueSequence.NumericValue,toolType:Jt.toolType,handles:{start:{},middle:{},end:{},textBox:{hasMoved:!1,movesIndependently:!1,drawnIndependently:!0,allowedOutsideImage:!0,hasBoundingBox:!0}}});var i=w(o.GraphicData,8);return s.handles.start.x=i[0],s.handles.start.y=i[1],s.handles.middle.x=i[2],s.handles.middle.y=i[3],s.handles.middle.x=i[4],s.handles.middle.y=i[5],s.handles.end.x=i[6],s.handles.end.y=i[7],s}static getTID300RepresentationArguments(e){const t=e.handles,n=e.finding,a=e.findingSites,o=t.start,s=t.middle,i=t.middle,c=t.end,u=e.rAngle;return{point1:o,point2:s,point3:i,point4:c,rAngle:u,trackingIdentifierTextValue:"cornerstoneTools@^4.0.0:Angle",finding:n,findingSites:a||[]}}};ne.toolType=rt;ne.utilityToolType=rt;ne.TID300Representation=ar;ne.isValidCornerstoneTrackingIdentifier=r=>{if(!r.includes(":"))return!1;const e=r.split(":"),t=w(e,2),n=t[0],a=t[1];return n!==$?!1:a===rt};M.registerTool(ne);function Ct(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function bt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ct(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Ct(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const or=D.TID300.Polyline;class V{static getMeasurementData(e){const t=M.getSetupMeasurementData(e),n=t.defaultState,a=t.SCOORDGroup,o=t.NUMGroup,s=bt(bt({},n),{},{toolType:V.toolType,handles:{start:{},end:{},textBox:{active:!1,hasMoved:!1,movesIndependently:!1,drawnIndependently:!0,allowedOutsideImage:!0,hasBoundingBox:!0},initialRotation:0},cachedStats:{area:o?o.MeasuredValueSequence.NumericValue:0},color:void 0,invalidated:!0});var i=w(a.GraphicData,6);return s.handles.start.x=i[0],s.handles.start.y=i[1],i[2],i[3],s.handles.end.x=i[4],s.handles.end.y=i[5],s}static getTID300RepresentationArguments(e){const t=e.finding,n=e.findingSites,a=e.cachedStats,o=a===void 0?{}:a,s=e.handles,i=s.start,c=s.end,u=[i,{x:i.x,y:c.y},c,{x:c.x,y:i.y}],l=o.area,d=o.perimeter;return{points:u,area:l,perimeter:d,trackingIdentifierTextValue:"cornerstoneTools@^4.0.0:RectangleRoi",finding:t,findingSites:n||[]}}}V.toolType="RectangleRoi";V.utilityToolType="RectangleRoi";V.TID300Representation=or;V.isValidCornerstoneTrackingIdentifier=r=>{if(!r.includes(":"))return!1;const e=r.split(":"),t=w(e,2),n=t[0],a=t[1];return n!==$?!1:a===V.toolType};M.registerTool(V);A.DicomMessage;A.DicomMetaDictionary;k.Normalizer;const we=D.orientation;we.rotateDirectionCosinesInPlane;we.flipImageOrientationPatient;we.flipMatrix2D;we.rotateMatrix902D;D.datasetToBlob;D.BitArray;D.DicomMessage;D.DicomMetaDictionary;k.Normalizer;Ie.Segmentation;hn.EXPLICIT_LITTLE_ENDIAN;var qe;(function(r){r.SEGMENTATION_LOAD_PROGRESS="CORNERSTONE_ADAPTER_SEGMENTATION_LOAD_PROGRESS"})(qe||(qe={}));const Ae=D.orientation;Ae.rotateDirectionCosinesInPlane;Ae.flipImageOrientationPatient;Ae.flipMatrix2D;Ae.rotateMatrix902D;A.BitArray;A.DicomMessage;A.DicomMetaDictionary;k.Normalizer;Ie.Segmentation;const Zt=D.compression;Zt.encode;Zt.decode;A.DicomMessage;A.DicomMetaDictionary;k.Normalizer;const sr={Length:J,FreehandRoi:_,Bidirectional:Z,EllipticalRoi:B,CircleRoi:Y,ArrowAnnotate:ee,MeasurementReport:M,CobbAngle:te,Angle:ne,RectangleRoi:V};var ge="Cornerstone3DTools@^0.1.0";const ir=["PatientName","PatientID","PatientBirthDate","PatientBirthTime","IssuerOfPatientID","OtherPatientIDs","OtherPatientIDsSequence","PatientSex","PatientIdentityRemoved","DeidentificationMethodCodeSequence"],cr=["StudyDate","StudyTime","StudyStatusID","StudyPriorityID","StudyInstanceUID","StudyDescription","AccessionNumber","StudyID","ReferringPhysicianName","TimezoneOffsetFromUTC"],ur=[...ir,...cr];function dr(r){const e={_meta:r._meta,_vrMap:r._vrMap};for(const t of ur){const n=r[t];n!==void 0&&(e[t]=n)}return e}const lr=["SeriesInstanceUID","SeriesNumber","SeriesDescription","Modality","SeriesDate","SeriesTime","_meta","_vrMap"];function pr(r){const e={};for(const t of lr){const n=r[t];n!==void 0&&(e[t]=n)}return e}function gr(r){const e=[];if(!(r!=null&&r.length))return e;const t=r.length;if(t%3!==0)throw new Error("Points array should be divisible by 3 for SCOORD3D, but contents are: ".concat(JSON.stringify(r)," of length ").concat(t));for(let n=0;n<t;n+=3)e.push([r[n],r[n+1],r[n+2]]);return e}const fr="CORNERSTONEFREETEXT",mr="CORNERSTONEJS",en={CodingSchemeDesignator:mr,codeValues:{CORNERSTONEFREETEXT:fr}};function Rt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function Mt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Rt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Rt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Fe="none",at="99CS3D",ve={schemeDesignator:at,meaning:"Text Annotation Position",value:"TextPosition"},F={schemeDesignator:at,meaning:"Control Points",value:"ControlPoints"},fe={schemeDesignator:at,meaning:"Spline Type",value:"SplineType"},Ne={schemeDesignator:"DCM",meaning:"Comment",value:"121106"},Ir=new Uint8Array(2);Ir[1]=1;const tn=new Uint8Array(2);tn[1]=2;const Sr="2.25.2470123695996825859949881583571202391.1.0.1",Or="2.25.2470123695996825859949881583571202391.2.0.1",hr=new Uint8Array(2);hr[1]=1;const ot={FileMetaInformationVersion:{Value:[tn.buffer],vr:"OB"},TransferSyntaxUID:{Value:["1.2.840.10008.1.2"],vr:"UI"},ImplementationClassUID:{Value:[Sr],vr:"UI"},ImplementationVersionName:{Value:["cs3d-4.8.4"],vr:"SH"}},yr=Mt(Mt({},ot),{},{ImplementationClassUID:{Value:[Or],vr:"UI"}}),nn=We.sr,x=nn.valueTypes,Pt=nn.coding,Dr=We.adapters.Cornerstone3D;class Tr{constructor(e,t){this.tid300Item=e,this.annotation=t,this.ReferencedSOPSequence=e.ReferencedSOPSequence}contentItem(){var e;const t=this.tid300Item.contentItem();this.fixScoordRelationships(t);const n=this.annotation.data,a=n.label,o=n.handles;return a&&(t.push(this.createQualitativeLabel(a)),this.filterCornerstoneFreeText(t)),o!=null&&(e=o.textBox)!==null&&e!==void 0&&e.hasMoved&&t.push(this.createQualitativeLabelPosition(this.annotation)),t}fixScoordRelationships(e){const t=x.RelationshipTypes.INFERRED_FROM;for(const n of e){const o=n.ContentSequence,s=this.normalizeContentSequence(o);for(const i of s)(i.ValueType==="SCOORD"||i.ValueType==="SCOORD3D")&&(i.RelationshipType==="CONTAINS"||i.RelationshipType==="Contains")&&(i.RelationshipType=t)}}normalizeContentSequence(e){return e?Array.isArray(e)?e:[e]:[]}filterCornerstoneFreeText(e){const t=Dr.CodeScheme.codeValues,n=[t.FREE_TEXT_CODE_VALUE,t.CORNERSTONEFREETEXT];for(let a=0;a<e.length;a++){const o=e[a];if(!o.ConceptCodeSequence)continue;const s=o.ConceptCodeSequence.findIndex(i=>n.includes(i.CodeValue));if(s!==-1){o.ConceptCodeSequence.splice(s,1),o.ConceptCodeSequence.length===0&&e.splice(a,1);return}}}createQualitativeLabel(e){const t=x.RelationshipTypes.CONTAINS;return new x.TextContentItem({name:new Pt.CodedConcept(Ne),relationshipType:t,value:e})}createQualitativeLabelPosition(e){const t=e.data.handles.textBox,n=e.metadata,a=n.referencedImageId,o=n.FrameOfReferenceUID,s=!a,i=E({is3DMeasurement:s,referencedImageId:a},t.worldPosition),c=i.x,u=i.y,l=i.z,d=x.GraphicTypes.POINT,p=x.RelationshipTypes.CONTAINS,g=new Pt.CodedConcept(ve),f=s?new x.Scoord3DContentItem({name:g,relationshipType:p,graphicType:d,graphicData:[c,u,l],frameOfReferenceUID:o}):new x.ScoordContentItem({name:g,relationshipType:p,graphicType:d,graphicData:[c,u]});return f.ContentSequence=[{RelationshipType:x.RelationshipTypes.SELECTED_FROM,ValueType:x.ValueTypes.IMAGE,ReferencedSOPSequence:this.ReferencedSOPSequence}],f}}var z;function vt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function W(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?vt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):vt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Cr=Kt,rn=D.TID1500,Nt=D.addAccessors,br=Ie.StructuredReport,Rr=k.Normalizer,Mr=rn.TID1500MeasurementReport,Pr=rn.TID1501MeasurementGroup,Se=A.DicomMetaDictionary,vr={CodingSchemeDesignator:"DCM",CodeValue:"121071"},Nr={CodingSchemeDesignator:Ne.schemeDesignator,CodeValue:Ne.value},Er={CodingSchemeDesignator:ve.schemeDesignator,CodeValue:ve.value},Ee={CodingSchemeDesignator:F.schemeDesignator,CodeValue:F.value},wr={CodingSchemeDesignator:"SCT",CodeValue:"363698007"},Ar={CodingSchemeDesignator:"SRT",CodeValue:"G-C0E3"};function Et(r){if(r.ValueType!=="SCOORD"&&r.ValueType!=="SCOORD3D")return!1;const e=r.ConceptNameCodeSequence,t=Array.isArray(e)?e[0]:e;return!!t&&t.CodingSchemeDesignator===Ee.CodingSchemeDesignator&&t.CodeValue===Ee.CodeValue}class N{static getTID300ContentItem(e,t,n,a){const o=n.getTID300RepresentationArguments(e,a);o.ReferencedSOPSequence=t,o.use3DSpatialCoordinates&&(o.ReferencedFrameOfReferenceUID=e.metadata.FrameOfReferenceUID);const s=new n.TID300Representation(o);return new Tr(s,e)}static getMeasurementGroup(e,t,n,a){const o=t[e],s=this.measurementAdapterByToolType.get(e);if(!o||!o.data||!o.data.length||!s)return;const i=o.data.map(c=>this.getTID300ContentItem(c,n,s,a));return new Pr(i)}static getCornerstoneLabelFromDefaultState(e){const t=e.findingSites,n=t===void 0?[]:t,a=e.finding,o=e.commentGroup;if(o!=null&&o.TextValue)return o.TextValue;const s=en.codeValues.CORNERSTONEFREETEXT,i=n.find(c=>c.CodeValue===s);if(i)return i.CodeMeaning;if(a&&a.CodeValue===s)return a.CodeMeaning}static generateDatasetMeta(){return ot}static processSCOORDGroup(e){let t=e.SCOORDGroup,n=e.toolType,a=e.sopInstanceUIDToImageIdMap,o=e.metadata;const s=t.ContentSequence.ReferencedSOPSequence,i=s.ReferencedSOPInstanceUID,c=s.ReferencedFrameNumber,u=c===void 0?1:c,l=a["".concat(i,":").concat(u)],d=o.get("imagePlaneModule",l),p=Se.uid();return{SCOORDGroup:t,ReferencedSOPSequence:s,ReferencedSOPInstanceUID:i,ReferencedFrameNumber:u,referencedImageId:l,state:{description:void 0,sopInstanceUid:i,annotation:{data:{annotationUID:p,cachedStats:{},handles:{activeHandleIndex:0,textBox:{hasMoved:!1}}},annotationUID:p,metadata:{toolName:n,referencedImageId:l,FrameOfReferenceUID:d.frameOfReferenceUID}}}}}static processSCOORD3DGroup(e){let t=e.SCOORD3DGroup,n=e.toolType;const a=Se.uid(),o={SCOORD3DGroup:t,FrameOfReferenceUID:t.ReferencedFrameOfReferenceUID,state:{description:void 0,annotation:{annotationUID:a,data:{annotationUID:a,cachedStats:{},handles:{activeHandleIndex:0,textBox:{hasMoved:!1}}},metadata:{toolName:n,FrameOfReferenceUID:t.ReferencedFrameOfReferenceUID}}}};return Dn(gr(t.GraphicData),o.state.annotation.metadata),o}static getSpatialCoordinatesState(e){var t,n;let a=e.NUMGroup,o=e.sopInstanceUIDToImageIdMap,s=e.metadata,i=e.toolType;const c=R(a.ContentSequence),u=(t=c.find(p=>p.ValueType==="SCOORD"&&!Et(p)))!==null&&t!==void 0?t:c.find(p=>p.ValueType==="SCOORD"),l=(n=c.find(p=>p.ValueType==="SCOORD3D"&&!Et(p)))!==null&&n!==void 0?n:c.find(p=>p.ValueType==="SCOORD3D"),d=l&&this.processSCOORD3DGroup({SCOORD3DGroup:l,toolType:i})||u&&this.processSCOORDGroup({SCOORDGroup:u,toolType:i,metadata:s,sopInstanceUIDToImageIdMap:o});if(!d)throw new Error("No spatial coordinates group found.");return d}static processSpatialCoordinatesGroup(e){let t=e.NUMGroup,n=e.sopInstanceUIDToImageIdMap,a=e.metadata,o=e.findingGroup,s=e.findingSiteGroups,i=e.commentGroup,c=e.commentPositionGroup,u=e.controlPointsGroup,l=e.toolType;const d=this.getSpatialCoordinatesState({NUMGroup:t,sopInstanceUIDToImageIdMap:n,metadata:a,toolType:l}),p=d.state,g=d.SCOORDGroup,f=d.ReferencedSOPSequence,I=d.ReferencedSOPInstanceUID,m=d.ReferencedFrameNumber,h=d.SCOORD3DGroup,O=d.FrameOfReferenceUID,y=d.referencedImageId,S=d.textBoxPosition,b=o?Nt(o.ConceptCodeSequence):void 0,T=s.map(v=>Nt(v.ConceptCodeSequence));if(c){p.commentPositionGroup=c;const v=pe({is3DMeasurement:!y,referencedImageId:y},c);p.annotation.data.handles.textBox={hasMoved:!0,worldPosition:v[0]}}if(u){const v=pe({is3DMeasurement:!y,referencedImageId:y},u);p.annotation.data.handles.points=v}return p.finding=b,p.findingSites=T,p.commentGroup=i,p.commentPositionGroup=c,b&&(p.description=b.CodeMeaning),p.annotation.data.label=this.getCornerstoneLabelFromDefaultState(p),{defaultState:p,state:p,NUMGroup:t,scoord:h||g,SCOORDGroup:g,ReferencedSOPSequence:f,ReferencedSOPInstanceUID:I,referencedImageId:y,textBoxPosition:S,ReferencedFrameNumber:m,SCOORD3DGroup:h,FrameOfReferenceUID:O}}static getSetupMeasurementData(e,t,n,a){const o=e.ContentSequence,s=R(o),i=s.find(S=>this.codeValueMatch(S,vr)),c=s.find(S=>this.codeValueMatch(S,Nr)),u=s.find(S=>this.codeValueMatch(S,Er));let l=s.find(S=>this.codeValueMatch(S,Ee));const d=s.find(S=>S.ValueType==="NUM");!l&&d!==null&&d!==void 0&&d.ContentSequence&&(l=R(d.ContentSequence).find(S=>this.codeValueMatch(S,Ee)));const p=s.filter(S=>this.codeValueMatch(S,wr,Ar))||[],g=d||{ContentSequence:s.filter(S=>S.ValueType==="SCOORD"||S.ValueType==="SCOORD3D")},f=this.processSpatialCoordinatesGroup({NUMGroup:g,sopInstanceUIDToImageIdMap:t,metadata:n,findingGroup:i,findingSiteGroups:p,commentGroup:c,commentPositionGroup:u,controlPointsGroup:l,toolType:a}),I=f.state.annotation.metadata.referencedImageId,m=!!f.SCOORD3DGroup,h={referencedImageId:I,is3DMeasurement:m},O=f.SCOORD3DGroup||f.SCOORDGroup,y=pe(h,O);return W(W({},f),{},{is3DMeasurement:m,scoordArgs:h,scoord:O,worldCoords:y})}static generateReferencedSOPSequence(e){let t=e.toolData,n=e.toolTypes,a=e.metadataProvider,o=e.imageId,s=e.sopInstanceUIDsToSeriesInstanceUIDMap,i=e.derivationSourceDatasets;const c=o===Fe?this.getImageIdFromVolume({toolData:t,toolTypes:n}):o,u=a.get("sopCommonModule",c),l=a.get("instance",c),d=u.sopInstanceUID,p=u.sopClassUID,g=l.SeriesInstanceUID;if(s[d]=g,!i.find(m=>m.SeriesInstanceUID===g)){const m=N.generateDerivationSourceDataset(l);i.push(m)}const f=a.get("frameNumber",c),I={ReferencedSOPClassUID:p,ReferencedSOPInstanceUID:d,ReferencedFrameNumber:void 0};return(l&&l.NumberOfFrames&&l.NumberOfFrames>1||Rr.isMultiframeSOPClassUID(p))&&(I.ReferencedFrameNumber=f),I}static getImageIdFromVolume(e){var t,n;let a=e.toolData,o=e.toolTypes;const s=a==null||(t=a[o?.[0]])===null||t===void 0||(t=t.data)===null||t===void 0?void 0:t[0],i=s==null||(n=s.metadata)===null||n===void 0?void 0:n.volumeId,c=Tn.getVolume(i);if(!c)throw new Error("No volume found for ".concat(i));return c.imageIds[0]}static generateReport(e,t,n){var a;let o=[];const s={},i=[],c=N.generateDatasetMeta();let u=!1;Object.keys(e).forEach(g=>{const f=e[g],I=Object.keys(f),m=g===Fe,h=this.generateReferencedSOPSequence({toolData:f,toolTypes:I,metadataProvider:t,imageId:g,sopInstanceUIDsToSeriesInstanceUIDMap:s,derivationSourceDatasets:i});m&&(u=!0);const O=[];I.forEach(y=>{const S=this.getMeasurementGroup(y,f,h,m);S&&O.push(S)}),o=o.concat(O)});const l=new Mr({TID1501MeasurementGroups:o},n),d=new br(i,n),p=l.contentItem(i,W(W({},n),{},{sopInstanceUIDsToSeriesInstanceUIDMap:s}));if(d.dataset=Object.assign(d.dataset,p),d.dataset._meta=c,d.SpecificCharacterSet="ISO_IR 192",(a=d.dataset).InstanceNumber||(a.InstanceNumber=n.InstanceNumber||1),n.predecessorImageId&&Object.assign(d.dataset,t.get(Cr.PREDECESSOR_SEQUENCE,n.predecessorImageId)),u&&(d.dataset.SOPClassUID=Se.sopClassUIDsByName.Comprehensive3DSR,!d.dataset.SOPClassUID))throw new Error("NO sop class defined for Comprehensive3DSR in ".concat(JSON.stringify(Se.sopClassUIDsByName)));return d}static generateToolState(e,t,n,a){if(e.ContentTemplateSequence.TemplateIdentifier!=="1500")throw new Error("This package can currently only interpret DICOM SR TID 1500");const o="Imaging Measurements",s="Measurement Group",i="Tracking Identifier",c="Tracking Unique Identifier",u=e.imageId,l=R(e.ContentSequence).find(Pe(o)),d=R(l.ContentSequence).filter(Pe(s)),p={};return d.forEach(g=>{try{var f;const m=R(g.ContentSequence),O=m.find(T=>T.ConceptNameCodeSequence.CodeMeaning===i).TextValue,y=m.find(T=>T.ConceptNameCodeSequence.CodeMeaning===c),S=y?.UID,b=(a==null||(f=a.getToolClass)===null||f===void 0?void 0:f.call(a,g,e,this.measurementAdapterByToolType))||this.getAdapterForTrackingIdentifier(O)||this.getAdapterForCodeType(g);if(b){var I;const T=b.getMeasurementData(g,t,n,O);T.TrackingUniqueIdentifier=S,T.predecessorImageId=u,console.log("=== ".concat(b.toolType," ===")),console.log(T),p[I=b.toolType]||(p[I]=[]),p[b.toolType].push(T)}}catch(m){console.warn("Unable to generate tool state for",g,m)}}),p}static registerTool(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.toolType;if(this.measurementAdapterByToolType.has(n)){if(!t)throw new Error("The registered tool name ".concat(n," already exists in adapters, use a different toolType or use replace"));typeof t=="function"&&t(this.measurementAdapterByToolType.get(n))}this.measurementAdapterByToolType.set(e.toolType,e),this.measurementAdapterByTrackingIdentifier.set(e.trackingIdentifierTextValue,e)}static registerTrackingIdentifier(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];for(const o of n)this.measurementAdapterByTrackingIdentifier.set(o,e)}static getAdapterForTrackingIdentifier(e){const t=this.measurementAdapterByTrackingIdentifier.get(e);if(t)return t;for(const n of[...this.measurementAdapterByToolType.values()])if(n.isValidCornerstoneTrackingIdentifier(e))return this.measurementAdapterByTrackingIdentifier.set(e,n),n}static getAdapterForCodeType(e){for(const t of this.measurementAdapterByTrackingIdentifier.values())if(t.isValidMeasurement(e))return t}static registerAdapterTypes(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];for(const o of n){this.measurementAdaptersByType.has(o)||this.measurementAdaptersByType.set(o,[]);const s=this.measurementAdaptersByType.get(o);s.indexOf(e)===-1&&s.push(e)}}static getAdaptersForTypes(e,t,n){const a=[];return Oe(a,this.measurementAdaptersByType.get("".concat(e,"-").concat(t,"-").concat(n))),Oe(a,this.measurementAdaptersByType.get("".concat(e,"-").concat(t))),Oe(a,this.measurementAdaptersByType.get(e)),Oe(a,this.measurementAdaptersByType.get(t)),a}}z=N;z.CORNERSTONE_3D_TAG=ge;z.measurementAdapterByToolType=new Map;z.measurementAdaptersByType=new Map;z.measurementAdapterByTrackingIdentifier=new Map;z.codeValueMatch=(r,e,t)=>{const n=r.ConceptNameCodeSequence;if(!n)return;const a=Array.isArray(n)?n[0]:n;if(!a)return;const o=a.CodingSchemeDesignator,s=a.CodeValue;return o==e.CodingSchemeDesignator&&s==e.CodeValue||t&&o==t.CodingSchemeDesignator&&s==t.CodeValue};z.generateDerivationSourceDataset=r=>{const e=dr(r),t=pr(r);return W(W({},e),t)};function Oe(r,e){e!=null&&e.length&&r.push(...e)}class U{static registerType(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=e;t&&(a="".concat(a).concat(a.length?"-":"").concat(t)),n&&(a="".concat(a).concat(a.length?"-":"").concat(n)),N.registerAdapterTypes(this,a)}static getPointsCount(e){const n=e.ValueType==="SCOORD3D"?3:2;return e.GraphicData.length/n}static getGraphicItems(e,t){const n=e.ContentSequence.filter(a=>a.ValueType==="SCOORD"||a.ValueType==="SCOORD3D");return t?n.filter(t):n}static getGraphicItem(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;return this.getGraphicItems(e,n&&(o=>o.ValueType===n))[t]}static getGraphicCode(e){const t=e.ConceptNameCodeSequence,n=t.CodeValue,a=t.CodingSchemeDesignator;return"".concat(a,":").concat(n)}static getGraphicType(e){return e.GraphicType}static isValidMeasurement(e){return!1}static init(e,t,n){if(this.toolType=e,U.toolType)throw new Error("Base adapter tool type set to ".concat(this.toolType," while setting ").concat(e));if(this.parentType=n?.parentType,this.trackingIdentifiers=new Set,this.TID300Representation=t,this.parentType){this.trackingIdentifierTextValue="".concat(ge,":").concat(this.parentType,":").concat(this.toolType);const a="".concat(ge,":").concat(this.toolType);this.trackingIdentifiers.add(a)}else this.trackingIdentifierTextValue="".concat(ge,":").concat(e);this.trackingIdentifiers.add(this.trackingIdentifierTextValue),N.registerTool(this)}static registerLegacy(){this.trackingIdentifiers.add("cornerstoneTools@^4.0.0:".concat(this.toolType))}static registerSubType(e,t,n){const a=Object.create(e);return a.init(t,e.TID300Representation,{parentType:e.parentType||e.toolType,replace:n}),a}static isValidCornerstoneTrackingIdentifier(e){return this.trackingIdentifiers.has(e)?!0:e.includes(":")?e.startsWith(this.trackingIdentifierTextValue):!1}static getMeasurementData(e,t,n,a){const o=N.getSetupMeasurementData(e,t,n,this.toolType),s=o.defaultState,i=o.ReferencedFrameNumber;return s.annotation.data={cachedStats:{},frameNumber:i,seriesLevel:a?.indexOf(":Series")>0},s}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.metadata,a=e.finding,o=e.findingSites,s=n.referencedImageId;return{points:Q({is3DMeasurement:t,referencedImageId:s},e.data.handles.points),trackingIdentifierTextValue:this.trackingIdentifierTextValue,findingSites:o||[],finding:a,ReferencedFrameOfReferenceUID:t?n.FrameOfReferenceUID:null}}static getCachedStats(e,t){const n=t.referencedImageId,a=t.volumeId;return e["imageId:".concat(n)]||e["volumeId:".concat(a)]||{}}}var Le;function wt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function he(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?wt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):wt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Ur=D.TID300.ArrowAnnotate,jr=Yt;class an extends U{static getMeasurementData(e,t,n,a){const o=N.getSetupMeasurementData(e,t,n,this.toolType),s=o.state,i=o.SCOORDGroup,c=o.worldCoords,u=o.referencedImageId,l=o.ReferencedFrameNumber,d=s.annotation.data.label;if(c.length===1&&i){const p=n.get("imagePixelModule",u);let g=10,f=10;if(p){const h=p.columns,O=p.rows;g=h/10,f=O/10}const I=i.GraphicData,m=jr(u,[I[0]+g,I[1]+f]);c.push(m)}return s.annotation.data=he(he({},s.annotation.data),{},{text:d,handles:he(he({},s.annotation.data.handles),{},{arrowFirst:!0,points:c}),frameNumber:l}),s}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.data,a=e.metadata,o=e.findingSites,s=e.finding,i=a.referencedImageId,c={is3DMeasurement:t,referencedImageId:i},u=n.handles,l=u.points,d=u.arrowFirst,p=d?l[0]:l[1],g=d?l[1]:l[0],f=E(c,p),I=E(c,g);return{points:[f,I],trackingIdentifierTextValue:this.trackingIdentifierTextValue,findingSites:o||[],finding:s,ReferencedFrameOfReferenceUID:t?a.FrameOfReferenceUID:null,use3DSpatialCoordinates:t}}}Le=an;Le.init("ArrowAnnotate",Ur),Le.registerLegacy();var ke;function At(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function ye(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?At(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):At(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const xr=D.TID300.Bidirectional,Gr="Long Axis",_r="Short Axis";class on extends U{static getMeasurementData(e,t,n){const a=N.getSetupMeasurementData(e,t,n,this.toolType),o=a.state,s=a.scoordArgs,i=a.referencedImageId,c=a.ReferencedFrameNumber,u=e.ContentSequence,l=R(u).find(I=>I.ConceptNameCodeSequence.CodeMeaning===Gr),d=R(u).find(I=>I.ConceptNameCodeSequence.CodeMeaning===_r),p=R(l.ContentSequence).find(I=>I.ValueType==="SCOORD3D"||I.ValueType==="SCOORD"),g=R(d.ContentSequence).find(I=>I.ValueType==="SCOORD3D"||I.ValueType==="SCOORD"),f=[];return f.push(...pe(s,p)),f.push(...pe(s,g)),o.annotation.data=ye(ye({},o.annotation.data),{},{handles:ye(ye({},o.annotation.data.handles),{},{points:[f[0],f[1],f[2],f[3]]}),frameNumber:c}),i&&(o.annotation.data.cachedStats={["imageId:".concat(i)]:{length:l.MeasuredValueSequence.NumericValue,width:d.MeasuredValueSequence.NumericValue,unit:l.MeasuredValueSequence.MeasurementUnitsCodeSequence.CodeValue,widthUnit:d.MeasuredValueSequence.MeasurementUnitsCodeSequence.CodeValue}}),o}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.data,a=e.finding,o=e.findingSites,s=e.metadata,i=n.cachedStats,c=i===void 0?{}:i,u=n.handles,l=s.referencedImageId,d={is3DMeasurement:t,referencedImageId:l},p=u.points,g=[p[0],p[1]],f=[p[2],p[3]],I=Math.sqrt(Math.pow(g[0][0]-g[1][0],2)+Math.pow(g[0][1]-g[1][1],2)+Math.pow(g[0][2]-g[1][2],2)),m=Math.sqrt(Math.pow(f[0][0]-f[1][0],2)+Math.pow(f[0][1]-f[1][1],2)+Math.pow(f[0][2]-f[1][2],2));let h,O;I>m?(h=g,O=f):(h=f,O=g);const y=E(d,h[0]),S=E(d,h[1]),b=E(d,O[0]),T=E(d,O[1]),v=super.getCachedStats(c,s),j=v.length,re=v.width,ae=v.unit;return{longAxis:{point1:y,point2:S},shortAxis:{point1:b,point2:T},longAxisLength:j,shortAxisLength:re,unit:ae,trackingIdentifierTextValue:this.trackingIdentifierTextValue,finding:a,findingSites:o||[],ReferencedFrameOfReferenceUID:t?s.FrameOfReferenceUID:null,use3DSpatialCoordinates:t}}}ke=on;ke.init("Bidirectional",xr),ke.registerLegacy();var Be;function Ut(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function De(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ut(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Ut(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Vr=D.TID300.CobbAngle;class sn extends U{static getMeasurementData(e,t,n){const a=N.getSetupMeasurementData(e,t,n,this.toolType),o=a.state,s=a.NUMGroup,i=a.worldCoords,c=a.referencedImageId,u=a.ReferencedFrameNumber,l=c?{["imageId:".concat(c)]:{angle:s?s.MeasuredValueSequence.NumericValue:null}}:{};return o.annotation.data=De(De({},o.annotation.data),{},{handles:De(De({},o.annotation.data.handles),{},{points:[i[0],i[1],i[3]]}),cachedStats:l,frameNumber:u}),o}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.data,a=e.finding,o=e.findingSites,s=e.metadata,i=n.cachedStats,c=i===void 0?{}:i,u=n.handles,l=s.referencedImageId,d={is3DMeasurement:t,referencedImageId:l},p=E(d,u.points[0]),g=E(d,u.points[1]),f=E(d,u.points[1]),I=E(d,u.points[2]),m=super.getCachedStats(c,s),h=m.angle;return{point1:p,point2:g,point3:f,point4:I,rAngle:h,trackingIdentifierTextValue:this.trackingIdentifierTextValue,finding:a,findingSites:o||[],ReferencedFrameOfReferenceUID:t?s.FrameOfReferenceUID:null,use3DSpatialCoordinates:t}}}Be=sn;Be.init("Angle",Vr),Be.registerLegacy();var Ye;function jt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function Te(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?jt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):jt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const $r=D.TID300.CobbAngle;class Ue extends U{static getMeasurementData(e,t,n){const a=N.getSetupMeasurementData(e,t,n,Ue.toolType),o=a.state,s=a.NUMGroup,i=a.referencedImageId,c=a.worldCoords,u=a.ReferencedFrameNumber;return o.annotation.data=Te(Te({},o.annotation.data),{},{handles:Te(Te({},o.annotation.data.handles),{},{points:[c[0],c[1],c[2],c[3]]}),frameNumber:u}),i&&(o.annotation.data.cachedStats={["imageId:".concat(i)]:{angle:s?s.MeasuredValueSequence.NumericValue:null}}),o}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.data,a=e.finding,o=e.findingSites,s=e.metadata,i=n.cachedStats,c=i===void 0?{}:i,u=n.handles,l=s.referencedImageId,p=Q({is3DMeasurement:t,referencedImageId:l},u.points),g=w(p,4),f=g[0],I=g[1],m=g[2],h=g[3],O=c["imageId:".concat(l)]||{},y=O.angle;return{point1:f,point2:I,point3:m,point4:h,rAngle:y,trackingIdentifierTextValue:this.trackingIdentifierTextValue,finding:a,findingSites:o||[],ReferencedFrameOfReferenceUID:t?s.FrameOfReferenceUID:null,use3DSpatialCoordinates:t}}}Ye=Ue;Ye.init("CobbAngle",$r),Ye.registerLegacy();const qr="[hnsf'U]",Fr="HU",Lr="mm2",kr="mm²",Br={[qr]:Fr,[Lr]:kr};function cn(r){return r&&(Br[r]||r)}const Ke=new Set(["Mean","Standard Deviation","Maximum","Minimum"]);function je(r,e){const t={};return r.ContentSequence&&r.ContentSequence.forEach(n=>{if(n.ValueType==="NUM"&&n.ConceptNameCodeSequence){var a,o;const s=n.ConceptNameCodeSequence.CodeMeaning,i=(a=n.MeasuredValueSequence)===null||a===void 0?void 0:a.NumericValue,c=(o=n.MeasuredValueSequence)===null||o===void 0||(o=o.MeasurementUnitsCodeSequence)===null||o===void 0?void 0:o.CodeValue;if(i!==void 0&&e){t[e]||(t[e]={});let u="";c&&(u=Yr(s,c)),t[e][s]={value:i,unit:u}}}}),t}function xe(r){const e={};let t="";const n={Mean:"mean","Standard Deviation":"stdDev",Maximum:"max",Minimum:"min",Area:"area",Radius:"radius",Perimeter:"perimeter",Length:"length",Width:"width"},a={mean:"modalityUnit",stdDev:"modalityUnit",max:"modalityUnit",min:"modalityUnit",area:"areaUnit",radius:"radiusUnit",perimeter:"unit",length:"unit",width:"widthUnit"};for(const s of Object.entries(n)){var o=w(s,2);const i=o[0],c=o[1],u=r[i];if(!u)continue;const l=u.value,d=u.unit;if(l==null||(e[c]=l,!d))continue;const p=cn(d);if(!p)continue;Ke.has(i)&&!t&&(t=p);const g=a[c];g?e[g]||(e[g]=p):e["".concat(c,"Unit")]=p}return e.modalityUnit=t,e}function Yr(r,e){if(!e)return"";const t=e.CodeValue,n=e.CodeMeaning;return t==="1"?!Ke.has(r)&&r==="Area"?"".concat(n,"²"):Ke.has(r)?"":n:t}var ze;function xt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function oe(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?xt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):xt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Kr=D.TID300.Circle;class un extends U{static getMeasurementData(e,t,n){const a=N.getSetupMeasurementData(e,t,n,this.toolType),o=a.state,s=a.NUMGroup,i=a.worldCoords,c=a.referencedImageId,u=a.ReferencedFrameNumber,l=o.sopInstanceUid,p=je(e,l)[l]||{};return o.annotation.data=oe(oe({},o.annotation.data),{},{handles:oe(oe({},o.annotation.data.handles),{},{points:i}),frameNumber:u}),c&&(o.annotation.data.cachedStats={["imageId:".concat(c)]:oe({area:s?s.MeasuredValueSequence.NumericValue:0,radius:0,perimeter:0},xe(p))}),o}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.data,a=e.finding,o=e.findingSites,s=e.metadata,i=n.cachedStats,c=i===void 0?{}:i,u=n.handles,l=s.referencedImageId,d={is3DMeasurement:t,referencedImageId:l},p=E(d,u.points[0]),g=E(d,u.points[1]),f=super.getCachedStats(c,s),I=f.area,m=f.radius,h=f.max,O=f.min,y=f.stdDev,S=f.mean,b=f.modalityUnit,T=f.radiusUnit,v=f.areaUnit,j=2*Math.PI*m;return{area:I,areaUnit:v,perimeter:j,modalityUnit:b,radiusUnit:T,radius:m,max:h,min:O,stdDev:y,mean:S,points:[p,g],trackingIdentifierTextValue:this.trackingIdentifierTextValue,finding:a,findingSites:o||[],ReferencedFrameOfReferenceUID:t?s.FrameOfReferenceUID:null,use3DSpatialCoordinates:t}}}ze=un;ze.init("CircleROI",Kr),ze.registerLegacy();var dn;function Gt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function se(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Gt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Gt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const zr=D.TID300.Ellipse;class Ge extends U{static getMeasurementData(e,t,n){const a=N.getSetupMeasurementData(e,t,n,Ge.toolType),o=a.state,s=a.NUMGroup,i=a.worldCoords,c=a.referencedImageId,u=a.ReferencedFrameNumber,l=o.sopInstanceUid,p=je(e,l)[l]||{};return o.annotation.data=se(se({},o.annotation.data),{},{handles:se(se({},o.annotation.data.handles),{},{points:i}),frameNumber:u}),o.annotation.data.cachedStats=c?{["imageId:".concat(c)]:se({area:s?s.MeasuredValueSequence.NumericValue:0},xe(p))}:{},o}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.data,a=e.finding,o=e.findingSites,s=e.metadata,i=n.cachedStats,c=i===void 0?{}:i,u=n.handles,l=n.initialRotation||0,d=s.referencedImageId,p={is3DMeasurement:t,referencedImageId:d};let g,f,I,m;l==90||l==270?(f=u.points[2],g=u.points[3],I=u.points[0],m=u.points[1]):(g=u.points[0],f=u.points[1],I=u.points[2],m=u.points[3]);const h=Math.sqrt((g[0]-f[0])**2+(g[1]-f[1])**2+(g[2]-f[2])**2),O=Math.sqrt((I[0]-m[0])**2+(I[1]-m[1])**2+(I[2]-m[2])**2),y=[];h>O?y.push(g,f,I,m):y.push(I,m,g,f);const S=super.getCachedStats(c,s),b=S.area,T=S.max,v=S.min,j=S.mean,re=S.stdDev,ae=S.modalityUnit,Ve=S.areaUnit,Sn=y.map(On=>E(p,On));return{area:b,areaUnit:Ve,max:T,min:v,mean:j,stdDev:re,modalityUnit:ae,points:Sn,trackingIdentifierTextValue:this.trackingIdentifierTextValue,finding:a,findingSites:o||[],ReferencedFrameOfReferenceUID:t?s.FrameOfReferenceUID:null,use3DSpatialCoordinates:t}}}dn=Ge;dn.init("EllipticalROI",zr);var de;function _t(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function ie(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?_t(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):_t(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Xr=D.TID300.Polyline;class ln extends U{static isValidMeasurement(e){const t=this.getGraphicItem(e),n=this.getPointsCount(t);return this.getGraphicType(t)==="POLYLINE"&&(n===4||n===5)}static getMeasurementData(e,t,n){var a,o;const s=N.getSetupMeasurementData(e,t,n,this.toolType),i=s.state,c=s.worldCoords,u=s.referencedImageId,l=s.ReferencedFrameNumber,d=c.length===5?c.slice(0,4):c,p=e.ContentSequence.find(T=>T.ValueType==="NUM"&&T.ConceptNameCodeSequence.CodeMeaning==="Area"),g=i.sopInstanceUid,I=je(e,g)[g]||{},m=xe(I),h=p==null||(a=p.MeasuredValueSequence)===null||a===void 0||(a=a[0])===null||a===void 0?void 0:a.MeasurementUnitsCodeSequence,O=h?.CodeValue,y=O?cn(O):m.areaUnit,S=u?{["imageId:".concat(u)]:ie({area:(p==null||(o=p.MeasuredValueSequence)===null||o===void 0||(o=o[0])===null||o===void 0?void 0:o.NumericValue)||0,areaUnit:y},m)}:{},b=[d[0],d[1],d[3],d[2]];return i.annotation.data=ie(ie({},i.annotation.data),{},{handles:ie(ie({},i.annotation.data.handles),{},{points:b}),cachedStats:S,frameNumber:l}),i}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.data,a=e.finding,o=e.findingSites,s=e.metadata,i=s.referencedImageId,u=Q({is3DMeasurement:t,referencedImageId:i},n.handles.points),l=super.getCachedStats(n.cachedStats,s),d=l.area,p=l.perimeter,g=l.max,f=l.mean,I=l.stdDev,m=l.areaUnit,h=l.modalityUnit;return{points:[u[0],u[1],u[3],u[2],u[0]],area:d,perimeter:p,max:g,mean:f,stdDev:I,areaUnit:m,modalityUnit:h,trackingIdentifierTextValue:this.trackingIdentifierTextValue,finding:a,findingSites:o||[],use3DSpatialCoordinates:t}}}de=ln;de.init("RectangleROI",Xr),de.registerLegacy(),de.registerType("DCM:111030","POLYLINE",4),de.registerType("DCM:111030","POLYLINE",5);var Xe;function Vt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function Ce(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Vt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Vt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Hr=D.TID300.Length,Wr="Length";class pn extends U{static getMeasurementData(e,t,n){const a=N.getSetupMeasurementData(e,t,n,this.toolType),o=a.state,s=a.NUMGroup,i=a.worldCoords,c=a.referencedImageId,u=a.ReferencedFrameNumber,l=c?{["imageId:".concat(c)]:{length:s?s.MeasuredValueSequence.NumericValue:0,unit:s.MeasuredValueSequence.MeasurementUnitsCodeSequence.CodeValue}}:{};return o.annotation.data=Ce(Ce({},o.annotation.data),{},{handles:Ce(Ce({},o.annotation.data.handles),{},{points:[i[0],i[1]],activeHandleIndex:0}),cachedStats:l,frameNumber:u}),o}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.data,a=e.finding,o=e.findingSites,s=e.metadata,i=n.cachedStats,c=i===void 0?{}:i,u=n.handles,l=s.referencedImageId,d={is3DMeasurement:t,referencedImageId:l},p=E(d,u.points[0]),g=E(d,u.points[1]),f=super.getCachedStats(c,s),I=f.length;return{point1:p,point2:g,distance:I,trackingIdentifierTextValue:this.trackingIdentifierTextValue,finding:a,findingSites:o||[],use3DSpatialCoordinates:t}}}Xe=pn;Xe.init(Wr,Hr),Xe.registerLegacy();const G=yn.valueTypes,Qr=D.TID300.Polyline;class Jr extends Qr{contentItem(){const e=super.contentItem(),t=this,n=t.props,a=n.controlPoints,o=n.use3DSpatialCoordinates,s=n.ReferencedSOPSequence,i=n.ReferencedFrameOfReferenceUID,c=n.use3DSpatialCoordinates;if(!(a!=null&&a.length))return e;const u=t.flattenPoints({points:a,use3DSpatialCoordinates:o}),l=G.GraphicTypes.MULTIPOINT,d=c?{RelationshipType:G.RelationshipTypes.CONTAINS,ValueType:"SCOORD3D",ConceptNameCodeSequence:[{CodeValue:F.value,CodingSchemeDesignator:F.schemeDesignator,CodeMeaning:F.meaning}],GraphicType:l,GraphicData:u,ReferencedFrameOfReferenceUID:i,ContentSequence:[{RelationshipType:G.RelationshipTypes.SELECTED_FROM,ValueType:G.ValueTypes.IMAGE,ReferencedSOPSequence:s}]}:{RelationshipType:G.RelationshipTypes.CONTAINS,ValueType:"SCOORD",ConceptNameCodeSequence:[{CodeValue:F.value,CodingSchemeDesignator:F.schemeDesignator,CodeMeaning:F.meaning}],GraphicType:l,GraphicData:u,ContentSequence:[{RelationshipType:G.RelationshipTypes.SELECTED_FROM,ValueType:G.ValueTypes.IMAGE,ReferencedSOPSequence:s}]},p=t.props.splineType,g=e,f=g.find(I=>I.ValueType==="NUM");if(f){const I=f.ContentSequence,m=Array.isArray(I)?I:I?[I]:[];f.ContentSequence=[...m,d]}else g.push(d);if(p){const I={RelationshipType:G.RelationshipTypes.HAS_OBS_CONTEXT,ValueType:"TEXT",ConceptNameCodeSequence:{CodeValue:fe.value,CodingSchemeDesignator:fe.schemeDesignator,CodeMeaning:fe.meaning},TextValue:p},m=g.findIndex(O=>O.RelationshipType===G.RelationshipTypes.HAS_OBS_CONTEXT),h=m>=0?m+2:2;g.splice(h,0,I)}return g}}var K;function $t(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function H(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?$t(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):$t(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}class gn extends U{static getMeasurementData(e,t,n){var a,o,s;const i=N.getSetupMeasurementData(e,t,n,this.toolType),c=i.state,u=i.NUMGroup,l=i.worldCoords,d=i.referencedImageId,p=i.ReferencedFrameNumber,g=Mn(l[l.length-1],l[0]);let f=!0;g<this.closedContourThreshold&&(l.pop(),f=!1);let I=(a=(o=c.annotation.data.handles)===null||o===void 0?void 0:o.points)!==null&&a!==void 0?a:[];f&&I.length===0&&(I=[l[0],l[l.length-1]]);const m=c.sopInstanceUid,O=je(e,m)[m]||{},y={CodingSchemeDesignator:fe.schemeDesignator,CodeValue:fe.value},S=u?R(u.ContentSequence):[],b=R(e.ContentSequence),T=(s=S.find(v=>N.codeValueMatch(v,y)))!==null&&s!==void 0?s:b.find(v=>N.codeValueMatch(v,y));return c.annotation.data=H(H({},c.annotation.data),{},{contour:{polyline:l,closed:!f},handles:H(H({},c.annotation.data.handles),{},{points:I}),frameNumber:p},T&&{spline:{type:T.TextValue}}),d&&(c.annotation.data.cachedStats={["imageId:".concat(d)]:H(H({},!f&&u?{area:u.MeasuredValueSequence.NumericValue}:{}),xe(O))}),c}static getTID300RepresentationArguments(e){var t,n;let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const o=e.data,s=e.finding,i=e.findingSites,c=e.metadata,u=o.handles,l=o.contour,d=l.polyline,g=l.closed!==!0,f=c.referencedImageId,I={is3DMeasurement:a,referencedImageId:f},m=Q(I,d);if(!g){const Ve=m[0];m.push(Ve)}const h=(u==null||(t=u.points)===null||t===void 0?void 0:t.length)&&Q(I,u.points),O=super.getCachedStats(o.cachedStats,c),y=O.area,S=O.areaUnit,b=O.modalityUnit,T=O.perimeter,v=O.mean,j=O.max,re=O.stdDev,ae=O.length;return{points:m,controlPoints:h,area:y,areaUnit:S,perimeter:T??ae,modalityUnit:b,mean:v,max:j,stdDev:re,splineType:(n=o.spline)===null||n===void 0?void 0:n.type,trackingIdentifierTextValue:this.trackingIdentifierTextValue,finding:s,findingSites:i||[],ReferencedFrameOfReferenceUID:a?c.FrameOfReferenceUID:null,use3DSpatialCoordinates:a}}}K=gn;K.closedContourThreshold=1e-5;K.init("PlanarFreehandROI",Jr),K.registerSubType(K,"LivewireContour"),K.registerSubType(K,"SplineROI");var le;function qt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function be(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?qt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):qt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Zr=D.TID300.Point;class _e extends U{static isValidMeasurement(e){const t=this.getGraphicItem(e);return this.getGraphicType(t)==="POINT"&&this.getPointsCount(t)<=2}static getMeasurementData(e,t,n,a){var o,s;const i=N.getSetupMeasurementData(e,t,n,this.toolType),c=i.state,u=i.NUMGroup,l=i.worldCoords,d=i.referencedImageId,p=i.ReferencedFrameNumber,g=d?{["imageId:".concat(d)]:{value:(o=u==null||(s=u.MeasuredValueSequence)===null||s===void 0?void 0:s.NumericValue)!==null&&o!==void 0?o:null}}:{};return c.annotation.data=be(be({},c.annotation.data),{},{handles:be(be({},c.annotation.data.handles),{},{points:l}),cachedStats:g,frameNumber:p,invalidated:!0}),c}static getTID300RepresentationArguments(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=e.data,a=e.metadata,o=e.finding,s=e.findingSites,i=a.referencedImageId,c={is3DMeasurement:t,referencedImageId:i},u=n.handles.points;return{points:Q(c,u===void 0?[]:u),trackingIdentifierTextValue:this.trackingIdentifierTextValue,findingSites:s||[],finding:o,ReferencedFrameOfReferenceUID:t?a.FrameOfReferenceUID:null,use3DSpatialCoordinates:t}}}le=_e;le.init("Probe",Zr),le.registerLegacy(),le.registerType("DCM:111030","POINT",1),le.registerType("DCM:111030","POINT",2);var fn;function Ft(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function Re(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ft(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Ft(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const ea=D.TID300.Length,Lt=Bt;class mn extends U{static getMeasurementData(e,t,n){const a=N.getSetupMeasurementData(e,t,n,this.toolType),o=a.state,s=a.worldCoords,i=a.ReferencedFrameNumber;return o.annotation.data=Re(Re({},o.annotation.data),{},{handles:Re(Re({},o.annotation.data.handles),{},{points:s}),frameNumber:i}),o}static getTID300RepresentationArguments(e,t){const n=e.data,a=e.finding,o=e.findingSites,s=e.metadata,i=n.handles,c=s.referencedImageId;if(!c)throw new Error("UltrasoundDirectionalTool.getTID300RepresentationArguments: referencedImageId is not defined");const u=Lt(c,i.points[0]),l=Lt(c,i.points[1]),d={x:u[0],y:u[1]},p={x:l[0],y:l[1]};return{point1:d,point2:p,trackingIdentifierTextValue:this.trackingIdentifierTextValue,finding:a,findingSites:o||[]}}}fn=mn;fn.init("UltrasoundDirectionalTool",ea);k.SEGImageNormalizer;Ie.Segmentation;A.DicomMessage;A.DicomMetaDictionary;k.Normalizer;Pn(r=>{Cn(bn,qe.SEGMENTATION_LOAD_PROGRESS,{percentComplete:r})},200);function kt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function ce(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?kt(Object(t),!0).forEach(function(n){P(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):kt(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Me=We.data.DicomMetaDictionary,C=Kt,ta=[C.GENERAL_STUDY,C.PATIENT_STUDY,C.PATIENT],na=[C.GENERAL_SERIES],ra=[C.GENERAL_IMAGE,C.IMAGE_PLANE,C.CINE,C.VOI_LUT,C.MODALITY_LUT,C.SOP_COMMON],He={get:function(r,e,t){var n;return(n=He[r])===null||n===void 0?void 0:n.call(He,e,t)},[C.IMAGE_SOP_INSTANCE_REFERENCE]:function(r){const e=q(C.FRAME_MODULE,r),t=e.sopClassUID,n=e.sopInstanceUID,a=e.frameNumber;return e.numberOfFrames>1?{ReferencedSOPClassUID:t,ReferencedSOPInstanceUID:n,ReferencedFrameNumber:a}:{ReferencedSOPClassUID:e.sopClassUID,ReferencedSOPInstanceUID:e.sopInstanceUID}},[C.REFERENCED_SERIES_REFERENCE]:r=>{const e=q(C.SOP_COMMON,r);return{SeriesInstanceUID:q(C.GENERAL_SERIES,r).seriesInstanceUID,ReferencedInstanceSequence:[{ReferencedSOPClassUID:e.sopClassUID,ReferencedSOPInstanceUID:e.sopInstanceUID}]}},[C.PREDECESSOR_SEQUENCE]:r=>{const e=ce({},q(C.SERIES_DATA,r)),t=q(C.GENERAL_IMAGE,r),n=q(C.GENERAL_STUDY,r);return e.InstanceNumber=1+Number(t.instanceNumber),e.PredecessorDocumentsSequence={StudyInstanceUID:n.studyInstanceUID,ReferencedSeriesSequence:{SeriesInstanceUID:e.SeriesInstanceUID,ReferencedSOPSequence:{ReferencedSOPClassUID:t.sopClassUID,ReferencedSOPInstanceUID:t.sopInstanceUID}}},e},[C.STUDY_DATA]:r=>$e(r,ta),[C.SERIES_DATA]:r=>$e(r,na),[C.IMAGE_DATA]:r=>$e(r,ra),[C.RTSS_INSTANCE_DATA]:r=>{const e=q(C.NEW_INSTANCE_DATA,r);return ce(ce({},e),{},{SeriesNumber:"3201",StructureSetROISequence:[],ROIContourSequence:[],RTROIObservationsSequence:[],ReferencedFrameOfReferenceSequence:[],Modality:"RTSTRUCT",SOPClassUID:"1.2.840.10008.5.1.4.1.1.481.3",PositionReferenceIndicator:"",StructureSetLabel:"",StructureSetName:"",StructureSetDate:Me.date(),StructureSetTime:Me.time()})},[C.NEW_INSTANCE_DATA]:r=>{const e=q(C.STUDY_DATA,r);return ce(ce({},e),{},{SeriesNumber:"50000",InstanceNumber:"1",OperatorsName:"",ReferringPhysicianName:"",SpecificCharacterSet:"ISO_IR 192",Manufacturer:"cs3d",SOPInstanceUID:Me.uid(),SeriesInstanceUID:Me.uid()})},[C.RTSS_CONTOUR]:()=>yr,[C.SR_ANNOTATION]:()=>ot};Rn(He.get,9023);var L;const aa=D.TID300.Point;class In extends _e{static getMeasurementData(e,t,n,a){const o=super.getMeasurementData(e,t,n,a),s=o.annotation.data;return s.isPoint=a.indexOf("Point")!==-1,o}static getTID300RepresentationArguments(e){const t=super.getTID300RepresentationArguments(e),n=e.data;return n.isPoint&&(n.seriesLevel?t.trackingIdentifierTextValue=this.trackingSeriesPointIdentifier:t.trackingIdentifierTextValue=this.trackingPointIdentifier),n.seriesLevel&&(t.trackingIdentifierTextValue=this.trackingSeriesIdentifier),t.points.length||t.points.push({x:0,y:0}),t}}L=In;L.init("KeyImage",aa,{parentType:_e.toolType});L.trackingSeriesIdentifier="".concat(L.trackingIdentifierTextValue,":Series");L.trackingPointIdentifier="".concat(L.trackingIdentifierTextValue,":Point");L.trackingSeriesPointIdentifier="".concat(L.trackingIdentifierTextValue,":SeriesPoint");const oa={BaseAdapter3D:U,Bidirectional:on,CobbAngle:Ue,Angle:sn,Length:pn,CircleROI:un,EllipticalROI:Ge,RectangleROI:ln,ArrowAnnotate:an,Probe:_e,PlanarFreehandROI:gn,UltrasoundDirectional:mn,KeyImage:In,MeasurementReport:N,CodeScheme:en,CORNERSTONE_3D_TAG:ge,COMMENT_CODE:Ne,NO_IMAGE_ID:Fe,TEXT_ANNOTATION_POSITION:ve};A.Colors;A.BitArray;const fa={Cornerstone:sr,Cornerstone3D:oa};export{Fe as NO_IMAGE_ID,fa as adaptersSR};
@@ -1 +1 @@
1
- import{P as L,g as $,N as E,O as j,e as y,h as S,I as G}from"./field-D_1hHgxN.js";var N={};class v{constructor(t,e,s,i,h,r,n,o,a,u=0,f){this.p=t,this.stack=e,this.state=s,this.reducePos=i,this.pos=h,this.score=r,this.buffer=n,this.bufferBase=o,this.curContext=a,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,s=0){let i=t.parser.context;return new v(t,[],e,s,s,0,[],0,i?new R(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let s=t>>19,i=t&65535,{parser:h}=this.p,r=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),n=h.dynamicPrecedence(i);if(n&&(this.score+=n),s==0){i<h.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(h.getGoto(this.state,i,!0),this.reducePos),i<h.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,r?8:4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(s-1)*3-(t&262144?6:0),a=o?this.stack[o-2]:this.p.ranges[0].from;i<h.minRepeatTerm&&a==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let u=this.reducePos-a;u>=2e3&&!(!((e=this.p.parser.nodeSet.types[i])===null||e===void 0)&&e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=u));let f=o?this.stack[o-1]:0,d=this.bufferBase+this.buffer.length-f;if(i<h.minRepeatTerm||t&131072){let c=h.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,c,d+4,!0)}if(t&262144)this.state=this.stack[o];else{let c=this.stack[o-3];this.state=h.getGoto(c,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,a)}storeNode(t,e,s,i=4,h=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let r=this.buffer.length;if(r>0&&this.buffer[r-4]==0&&this.buffer[r-1]>-1){if(e==s)return;if(this.buffer[r-2]>=e){this.buffer[r-2]=s;return}}}if(!h||this.pos==s)this.buffer.push(t,e,s,i);else{let r=this.buffer.length;if(r>0&&(this.buffer[r-4]!=0||this.buffer[r-1]<0)){let n=!1;for(let o=r;o>0&&this.buffer[o-2]>s;o-=4)if(this.buffer[o-1]>=0){n=!0;break}if(n)for(;r>0&&this.buffer[r-2]>s;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=t,this.buffer[r+1]=e,this.buffer[r+2]=s,this.buffer[r+3]=i}}shift(t,e,s,i){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let h=t,{parser:r}=this.p;this.pos=i;let n=r.stateFlag(h,1);!n&&(i>s||e<=r.maxNode)&&(this.reducePos=i),this.pushState(h,n?s:Math.min(s,this.reducePos)),this.shiftContext(e,s),e<=r.maxNode&&this.buffer.push(e,s,i,4)}else this.pos=i,this.shiftContext(e,s),e<=this.p.parser.maxNode&&this.buffer.push(e,s,i,4)}apply(t,e,s,i){t&65536?this.reduce(t):this.shift(t,e,s,i)}useNode(t,e){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=t)&&(this.p.reused.push(t),s++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(e,i),this.buffer.push(s,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&t.buffer[e-4]==0&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let s=t.buffer.slice(e),i=t.bufferBase+e;for(;t&&i==t.bufferBase;)t=t.parent;return new v(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let s=t<=this.p.parser.maxNode;s&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,s?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new U(this);;){let s=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(s==0)return!1;if((s&65536)==0)return!0;e.reduce(s)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let h=0,r;h<e.length;h+=2)(r=e[h+1])!=this.state&&this.p.parser.hasAction(r,t)&&i.push(e[h],r);if(this.stack.length<120)for(let h=0;i.length<8&&h<e.length;h+=2){let r=e[h+1];i.some((n,o)=>o&1&&n==r)||i.push(e[h],r)}e=i}let s=[];for(let i=0;i<e.length&&s.length<4;i+=2){let h=e[i+1];if(h==this.state)continue;let r=this.split();r.pushState(h,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(e[i],this.pos),r.reducePos=this.pos,r.score-=200,s.push(r)}return s}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let s=e>>19,i=e&65535,h=this.stack.length-s*3;if(h<0||t.getGoto(this.stack[h],i,!1)<0){let r=this.findForcedReduction();if(r==null)return!1;e=r}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],s=(i,h)=>{if(!e.includes(i))return e.push(i),t.allActions(i,r=>{if(!(r&393216))if(r&65536){let n=(r>>19)-h;if(n>1){let o=r&65535,a=this.stack.length-n*3;if(a>=0&&t.getGoto(this.stack[a],o,!1)>=0)return n<<19|65536|o}}else{let n=s(r,h+1);if(n!=null)return n}})};return s(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new R(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class R{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class U{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,s=t>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=i}}class A{constructor(t,e,s){this.stack=t,this.pos=e,this.index=s,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new A(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new A(this.stack,this.pos,this.index)}}function x(l,t=Uint16Array){if(typeof l!="string")return l;let e=null;for(let s=0,i=0;s<l.length;){let h=0;for(;;){let r=l.charCodeAt(s++),n=!1;if(r==126){h=65535;break}r>=92&&r--,r>=34&&r--;let o=r-32;if(o>=46&&(o-=46,n=!0),h+=o,n)break;h*=46}e?e[i++]=h:e=new t(h)}return e}class P{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const z=new P;class H{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=z,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let s=this.range,i=this.rangeIndex,h=this.pos+t;for(;h<s.from;){if(!i)return null;let r=this.ranges[--i];h-=s.from-r.to,s=r}for(;e<0?h>s.to:h>=s.to;){if(i==this.ranges.length-1)return null;let r=this.ranges[++i];h+=r.from-s.to,s=r}return h}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,s,i;if(e>=0&&e<this.chunk.length)s=this.pos+t,i=this.chunk.charCodeAt(e);else{let h=this.resolveOffset(t,1);if(h==null)return-1;if(s=h,s>=this.chunk2Pos&&s<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(s-this.chunk2Pos);else{let r=this.rangeIndex,n=this.range;for(;n.to<=s;)n=this.ranges[++r];this.chunk2=this.input.chunk(this.chunk2Pos=s),s+this.chunk2.length>n.to&&(this.chunk2=this.chunk2.slice(0,n.to-s)),i=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),i}acceptToken(t,e=0){let s=e?this.resolveOffset(e,-1):this.pos;if(s==null||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=s}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=z,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let s="";for(let i of this.ranges){if(i.from>=e)break;i.to>t&&(s+=this.input.read(Math.max(i.from,t),Math.min(i.to,e)))}return s}}class m{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:s}=e.p;F(this.data,t,e,this.id,s.data,s.tokenPrecTable)}}m.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class W{constructor(t,e,s){this.precTable=e,this.elseToken=s,this.data=typeof t=="string"?x(t):t}token(t,e){let s=t.pos,i=0;for(;;){let h=t.next<0,r=t.resolveOffset(1,1);if(F(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(h||i++,r==null)break;t.reset(r,t.token)}i&&(t.reset(s,t.token),t.acceptToken(this.elseToken,i))}}W.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class Z{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function F(l,t,e,s,i,h){let r=0,n=1<<s,{dialect:o}=e.p.parser;t:for(;(n&l[r])!=0;){let a=l[r+1];for(let c=r+3;c<a;c+=2)if((l[c+1]&n)>0){let p=l[c];if(o.allows(p)&&(t.token.value==-1||t.token.value==p||q(p,t.token.value,i,h))){t.acceptToken(p);break}}let u=t.next,f=0,d=l[r+2];if(t.next<0&&d>f&&l[a+d*3-3]==65535){r=l[a+d*3-1];continue t}for(;f<d;){let c=f+d>>1,p=a+c+(c<<1),b=l[p],M=l[p+1]||65536;if(u<b)d=c;else if(u>=M)f=c+1;else{r=l[p+2],t.advance();continue t}}break}}function I(l,t,e){for(let s=t,i;(i=l[s])!=65535;s++)if(i==e)return s-t;return-1}function q(l,t,e,s){let i=I(e,s,t);return i<0||I(e,s,l)<i}const g=typeof process<"u"&&N&&/\bparse\b/.test(N.LOG);let T=null;function D(l,t,e){let s=l.cursor(G.IncludeAnonymous);for(s.moveTo(t);;)if(!(e<0?s.childBefore(t):s.childAfter(t)))for(;;){if((e<0?s.to<t:s.from>t)&&!s.type.isError)return e<0?Math.max(0,Math.min(s.to-1,t-25)):Math.min(l.length,Math.max(s.from+1,t+25));if(e<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return e<0?0:l.length}}class J{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?D(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?D(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let s=this.trees[e],i=this.index[e];if(i==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let h=s.children[i],r=this.start[e]+s.positions[i];if(r>t)return this.nextStart=r,null;if(h instanceof S){if(r==t){if(r<this.safeFrom)return null;let n=r+h.length;if(n<=this.safeTo){let o=h.prop(y.lookAhead);if(!o||n+o<this.fragment.to)return h}}this.index[e]++,r+h.length>=Math.max(this.safeFrom,t)&&(this.trees.push(h),this.start.push(r),this.index.push(0))}else this.index[e]++,this.nextStart=r+h.length}}}class K{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(s=>new P)}getActions(t){let e=0,s=null,{parser:i}=t.p,{tokenizers:h}=i,r=i.stateSlot(t.state,3),n=t.curContext?t.curContext.hash:0,o=0;for(let a=0;a<h.length;a++){if((1<<a&r)==0)continue;let u=h[a],f=this.tokens[a];if(!(s&&!u.fallback)&&((u.contextual||f.start!=t.pos||f.mask!=r||f.context!=n)&&(this.updateCachedToken(f,u,t),f.mask=r,f.context=n),f.lookAhead>f.end+25&&(o=Math.max(f.lookAhead,o)),f.value!=0)){let d=e;if(f.extended>-1&&(e=this.addActions(t,f.extended,f.end,e)),e=this.addActions(t,f.value,f.end,e),!u.extend&&(s=f,e>d))break}}for(;this.actions.length>e;)this.actions.pop();return o&&t.setLookAhead(o),!s&&t.pos==this.stream.end&&(s=new P,s.value=t.p.parser.eofTerm,s.start=s.end=t.pos,e=this.addActions(t,s.value,s.end,e)),this.mainToken=s,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new P,{pos:s,p:i}=t;return e.start=s,e.end=Math.min(s+1,i.stream.end),e.value=s==i.stream.end?i.parser.eofTerm:0,e}updateCachedToken(t,e,s){let i=this.stream.clipPos(s.pos);if(e.token(this.stream.reset(i,t),s),t.value>-1){let{parser:h}=s.p;for(let r=0;r<h.specialized.length;r++)if(h.specialized[r]==t.value){let n=h.specializers[r](this.stream.read(t.start,t.end),s);if(n>=0&&s.p.parser.dialect.allows(n>>1)){(n&1)==0?t.value=n>>1:t.extended=n>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,e,s,i){for(let h=0;h<i;h+=3)if(this.actions[h]==t)return i;return this.actions[i++]=t,this.actions[i++]=e,this.actions[i++]=s,i}addActions(t,e,s,i){let{state:h}=t,{parser:r}=t.p,{data:n}=r;for(let o=0;o<2;o++)for(let a=r.stateSlot(h,o?2:1);;a+=3){if(n[a]==65535)if(n[a+1]==1)a=k(n,a+2);else{i==0&&n[a+1]==2&&(i=this.putAction(k(n,a+2),e,s,i));break}n[a]==e&&(i=this.putAction(k(n,a+1),e,s,i))}return i}}class Q{constructor(t,e,s,i){this.parser=t,this.input=e,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new H(e,i),this.tokens=new K(t,this.stream),this.topTerm=t.top[1];let{from:h}=i[0];this.stacks=[v.start(this,t.top[0],h)],this.fragments=s.length&&this.stream.end-h>t.bufferLength*4?new J(s,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,s=this.stacks=[],i,h;if(this.bigReductionCount>300&&t.length==1){let[r]=t;for(;r.forceReduce()&&r.stack.length&&r.stack[r.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<t.length;r++){let n=t[r];for(;;){if(this.tokens.mainToken=null,n.pos>e)s.push(n);else{if(this.advanceStack(n,s,t))continue;{i||(i=[],h=[]),i.push(n);let o=this.tokens.getMainToken(n);h.push(o.value,o.end)}}break}}if(!s.length){let r=i&&X(i);if(r)return g&&console.log("Finish with "+this.stackID(r)),this.stackToTree(r);if(this.parser.strict)throw g&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&i){let r=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,h,s);if(r)return g&&console.log("Force-finish "+this.stackID(r)),this.stackToTree(r.forceAll())}if(this.recovering){let r=this.recovering==1?1:this.recovering*3;if(s.length>r)for(s.sort((n,o)=>o.score-n.score);s.length>r;)s.pop();s.some(n=>n.reducePos>e)&&this.recovering--}else if(s.length>1){t:for(let r=0;r<s.length-1;r++){let n=s[r];for(let o=r+1;o<s.length;o++){let a=s[o];if(n.sameState(a)||n.buffer.length>500&&a.buffer.length>500)if((n.score-a.score||n.buffer.length-a.buffer.length)>0)s.splice(o--,1);else{s.splice(r--,1);continue t}}}s.length>12&&(s.sort((r,n)=>n.score-r.score),s.splice(12,s.length-12))}this.minStackPos=s[0].pos;for(let r=1;r<s.length;r++)s[r].pos<this.minStackPos&&(this.minStackPos=s[r].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,s){let i=t.pos,{parser:h}=this,r=g?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let a=t.curContext&&t.curContext.tracker.strict,u=a?t.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?h.getGoto(t.state,f.type.id):-1;if(d>-1&&f.length&&(!a||(f.prop(y.contextHash)||0)==u))return t.useNode(f,d),g&&console.log(r+this.stackID(t)+` (via reuse of ${h.getName(f.type.id)})`),!0;if(!(f instanceof S)||f.children.length==0||f.positions[0]>0)break;let c=f.children[0];if(c instanceof S&&f.positions[0]==0)f=c;else break}}let n=h.stateSlot(t.state,4);if(n>0)return t.reduce(n),g&&console.log(r+this.stackID(t)+` (via always-reduce ${h.getName(n&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let o=this.tokens.getActions(t);for(let a=0;a<o.length;){let u=o[a++],f=o[a++],d=o[a++],c=a==o.length||!s,p=c?t:t.split(),b=this.tokens.mainToken;if(p.apply(u,f,b?b.start:p.pos,d),g&&console.log(r+this.stackID(p)+` (via ${(u&65536)==0?"shift":`reduce of ${h.getName(u&65535)}`} for ${h.getName(f)} @ ${i}${p==t?"":", split"})`),c)return!0;p.pos>i?e.push(p):s.push(p)}return!1}advanceFully(t,e){let s=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>s)return B(t,e),!0}}runRecovery(t,e,s){let i=null,h=!1;for(let r=0;r<t.length;r++){let n=t[r],o=e[r<<1],a=e[(r<<1)+1],u=g?this.stackID(n)+" -> ":"";if(n.deadEnd&&(h||(h=!0,n.restart(),g&&console.log(u+this.stackID(n)+" (restarted)"),this.advanceFully(n,s))))continue;let f=n.split(),d=u;for(let c=0;c<10&&f.forceReduce()&&(g&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,s));c++)g&&(d=this.stackID(f)+" -> ");for(let c of n.recoverByInsert(o))g&&console.log(u+this.stackID(c)+" (via recover-insert)"),this.advanceFully(c,s);this.stream.end>n.pos?(a==n.pos&&(a++,o=0),n.recoverByDelete(o,a),g&&console.log(u+this.stackID(n)+` (via recover-delete ${this.parser.getName(o)})`),B(n,s)):(!i||i.score<f.score)&&(i=f)}return i}stackToTree(t){return t.close(),S.build({buffer:A.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(T||(T=new WeakMap)).get(t);return e||T.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function B(l,t){for(let e=0;e<t.length;e++){let s=t[e];if(s.pos==l.pos&&s.sameState(l)){t[e].score<l.score&&(t[e]=l);return}}t.push(l)}class V{constructor(t,e,s){this.source=t,this.flags=e,this.disabled=s}allows(t){return!this.disabled||this.disabled[t]==0}}const C=l=>l;class _{constructor(t){this.start=t.start,this.shift=t.shift||C,this.reduce=t.reduce||C,this.reuse=t.reuse||C,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class w extends L{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let n=0;n<t.repeatNodeCount;n++)e.push("");let s=Object.keys(t.topRules).map(n=>t.topRules[n][1]),i=[];for(let n=0;n<e.length;n++)i.push([]);function h(n,o,a){i[n].push([o,o.deserialize(String(a))])}if(t.nodeProps)for(let n of t.nodeProps){let o=n[0];typeof o=="string"&&(o=y[o]);for(let a=1;a<n.length;){let u=n[a++];if(u>=0)h(u,o,n[a++]);else{let f=n[a+-u];for(let d=-u;d>0;d--)h(n[a++],o,f);a++}}}this.nodeSet=new $(e.map((n,o)=>E.define({name:o>=this.minRepeatTerm?void 0:n,id:o,props:i[o],top:s.indexOf(o)>-1,error:o==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(o)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=j;let r=x(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let n=0;n<this.specializerSpecs.length;n++)this.specialized[n]=this.specializerSpecs[n].term;this.specializers=this.specializerSpecs.map(O),this.states=x(t.states,Uint32Array),this.data=x(t.stateData),this.goto=x(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(n=>typeof n=="number"?new m(r,n):n),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,s){let i=new Q(this,t,e,s);for(let h of this.wrappers)i=h(i,t,e,s);return i}getGoto(t,e,s=!1){let i=this.goto;if(e>=i[0])return-1;for(let h=i[e+1];;){let r=i[h++],n=r&1,o=i[h++];if(n&&s)return o;for(let a=h+(r>>1);h<a;h++)if(i[h]==t)return o;if(n)return-1}}hasAction(t,e){let s=this.data;for(let i=0;i<2;i++)for(let h=this.stateSlot(t,i?2:1),r;;h+=3){if((r=s[h])==65535)if(s[h+1]==1)r=s[h=k(s,h+2)];else{if(s[h+1]==2)return k(s,h+2);break}if(r==e||r==0)return k(s,h+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,s=>s==e?!0:null)}allActions(t,e){let s=this.stateSlot(t,4),i=s?e(s):void 0;for(let h=this.stateSlot(t,1);i==null;h+=3){if(this.data[h]==65535)if(this.data[h+1]==1)h=k(this.data,h+2);else break;i=e(k(this.data,h+1))}return i}nextStates(t){let e=[];for(let s=this.stateSlot(t,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=k(this.data,s+2);else break;if((this.data[s+2]&1)==0){let i=this.data[s+1];e.some((h,r)=>r&1&&h==i)||e.push(this.data[s],i)}}return e}configure(t){let e=Object.assign(Object.create(w.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let s=this.topRules[t.top];if(!s)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=s}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(s=>{let i=t.tokenizers.find(h=>h.from==s);return i?i.to:s})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((s,i)=>{let h=t.specializers.find(n=>n.from==s.external);if(!h)return s;let r=Object.assign(Object.assign({},s),{external:h.to});return e.specializers[i]=O(r),r})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),s=e.map(()=>!1);if(t)for(let h of t.split(" ")){let r=e.indexOf(h);r>=0&&(s[r]=!0)}let i=null;for(let h=0;h<e.length;h++)if(!s[h])for(let r=this.dialects[e[h]],n;(n=this.data[r++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[n]=1;return new V(t,s,i)}static deserialize(t){return new w(t)}}function k(l,t){return l[t]|l[t+1]<<16}function X(l){let t=null;for(let e of l){let s=e.p.stoppedAt;(e.pos==e.p.stream.end||s!=null&&e.pos>s)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function O(l){if(l.external){let t=l.extend?1:0;return(e,s)=>l.external(e,s)<<1|t}return l.get}export{_ as C,Z as E,w as L,W as a};
1
+ import{P as L,g as $,N as E,O as j,e as y,h as S,I as G}from"./field-CVqP2pjA.js";var N={};class v{constructor(t,e,s,i,h,r,n,o,a,u=0,f){this.p=t,this.stack=e,this.state=s,this.reducePos=i,this.pos=h,this.score=r,this.buffer=n,this.bufferBase=o,this.curContext=a,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,s=0){let i=t.parser.context;return new v(t,[],e,s,s,0,[],0,i?new R(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let s=t>>19,i=t&65535,{parser:h}=this.p,r=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),n=h.dynamicPrecedence(i);if(n&&(this.score+=n),s==0){i<h.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(h.getGoto(this.state,i,!0),this.reducePos),i<h.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,r?8:4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(s-1)*3-(t&262144?6:0),a=o?this.stack[o-2]:this.p.ranges[0].from;i<h.minRepeatTerm&&a==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let u=this.reducePos-a;u>=2e3&&!(!((e=this.p.parser.nodeSet.types[i])===null||e===void 0)&&e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=u));let f=o?this.stack[o-1]:0,d=this.bufferBase+this.buffer.length-f;if(i<h.minRepeatTerm||t&131072){let c=h.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,c,d+4,!0)}if(t&262144)this.state=this.stack[o];else{let c=this.stack[o-3];this.state=h.getGoto(c,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,a)}storeNode(t,e,s,i=4,h=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let r=this.buffer.length;if(r>0&&this.buffer[r-4]==0&&this.buffer[r-1]>-1){if(e==s)return;if(this.buffer[r-2]>=e){this.buffer[r-2]=s;return}}}if(!h||this.pos==s)this.buffer.push(t,e,s,i);else{let r=this.buffer.length;if(r>0&&(this.buffer[r-4]!=0||this.buffer[r-1]<0)){let n=!1;for(let o=r;o>0&&this.buffer[o-2]>s;o-=4)if(this.buffer[o-1]>=0){n=!0;break}if(n)for(;r>0&&this.buffer[r-2]>s;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=t,this.buffer[r+1]=e,this.buffer[r+2]=s,this.buffer[r+3]=i}}shift(t,e,s,i){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let h=t,{parser:r}=this.p;this.pos=i;let n=r.stateFlag(h,1);!n&&(i>s||e<=r.maxNode)&&(this.reducePos=i),this.pushState(h,n?s:Math.min(s,this.reducePos)),this.shiftContext(e,s),e<=r.maxNode&&this.buffer.push(e,s,i,4)}else this.pos=i,this.shiftContext(e,s),e<=this.p.parser.maxNode&&this.buffer.push(e,s,i,4)}apply(t,e,s,i){t&65536?this.reduce(t):this.shift(t,e,s,i)}useNode(t,e){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=t)&&(this.p.reused.push(t),s++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(e,i),this.buffer.push(s,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&t.buffer[e-4]==0&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let s=t.buffer.slice(e),i=t.bufferBase+e;for(;t&&i==t.bufferBase;)t=t.parent;return new v(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let s=t<=this.p.parser.maxNode;s&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,s?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new U(this);;){let s=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(s==0)return!1;if((s&65536)==0)return!0;e.reduce(s)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let h=0,r;h<e.length;h+=2)(r=e[h+1])!=this.state&&this.p.parser.hasAction(r,t)&&i.push(e[h],r);if(this.stack.length<120)for(let h=0;i.length<8&&h<e.length;h+=2){let r=e[h+1];i.some((n,o)=>o&1&&n==r)||i.push(e[h],r)}e=i}let s=[];for(let i=0;i<e.length&&s.length<4;i+=2){let h=e[i+1];if(h==this.state)continue;let r=this.split();r.pushState(h,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(e[i],this.pos),r.reducePos=this.pos,r.score-=200,s.push(r)}return s}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let s=e>>19,i=e&65535,h=this.stack.length-s*3;if(h<0||t.getGoto(this.stack[h],i,!1)<0){let r=this.findForcedReduction();if(r==null)return!1;e=r}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],s=(i,h)=>{if(!e.includes(i))return e.push(i),t.allActions(i,r=>{if(!(r&393216))if(r&65536){let n=(r>>19)-h;if(n>1){let o=r&65535,a=this.stack.length-n*3;if(a>=0&&t.getGoto(this.stack[a],o,!1)>=0)return n<<19|65536|o}}else{let n=s(r,h+1);if(n!=null)return n}})};return s(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new R(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class R{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class U{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,s=t>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=i}}class A{constructor(t,e,s){this.stack=t,this.pos=e,this.index=s,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new A(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new A(this.stack,this.pos,this.index)}}function x(l,t=Uint16Array){if(typeof l!="string")return l;let e=null;for(let s=0,i=0;s<l.length;){let h=0;for(;;){let r=l.charCodeAt(s++),n=!1;if(r==126){h=65535;break}r>=92&&r--,r>=34&&r--;let o=r-32;if(o>=46&&(o-=46,n=!0),h+=o,n)break;h*=46}e?e[i++]=h:e=new t(h)}return e}class P{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const z=new P;class H{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=z,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let s=this.range,i=this.rangeIndex,h=this.pos+t;for(;h<s.from;){if(!i)return null;let r=this.ranges[--i];h-=s.from-r.to,s=r}for(;e<0?h>s.to:h>=s.to;){if(i==this.ranges.length-1)return null;let r=this.ranges[++i];h+=r.from-s.to,s=r}return h}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,s,i;if(e>=0&&e<this.chunk.length)s=this.pos+t,i=this.chunk.charCodeAt(e);else{let h=this.resolveOffset(t,1);if(h==null)return-1;if(s=h,s>=this.chunk2Pos&&s<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(s-this.chunk2Pos);else{let r=this.rangeIndex,n=this.range;for(;n.to<=s;)n=this.ranges[++r];this.chunk2=this.input.chunk(this.chunk2Pos=s),s+this.chunk2.length>n.to&&(this.chunk2=this.chunk2.slice(0,n.to-s)),i=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),i}acceptToken(t,e=0){let s=e?this.resolveOffset(e,-1):this.pos;if(s==null||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=s}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=z,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let s="";for(let i of this.ranges){if(i.from>=e)break;i.to>t&&(s+=this.input.read(Math.max(i.from,t),Math.min(i.to,e)))}return s}}class m{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:s}=e.p;F(this.data,t,e,this.id,s.data,s.tokenPrecTable)}}m.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class W{constructor(t,e,s){this.precTable=e,this.elseToken=s,this.data=typeof t=="string"?x(t):t}token(t,e){let s=t.pos,i=0;for(;;){let h=t.next<0,r=t.resolveOffset(1,1);if(F(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(h||i++,r==null)break;t.reset(r,t.token)}i&&(t.reset(s,t.token),t.acceptToken(this.elseToken,i))}}W.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class Z{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function F(l,t,e,s,i,h){let r=0,n=1<<s,{dialect:o}=e.p.parser;t:for(;(n&l[r])!=0;){let a=l[r+1];for(let c=r+3;c<a;c+=2)if((l[c+1]&n)>0){let p=l[c];if(o.allows(p)&&(t.token.value==-1||t.token.value==p||q(p,t.token.value,i,h))){t.acceptToken(p);break}}let u=t.next,f=0,d=l[r+2];if(t.next<0&&d>f&&l[a+d*3-3]==65535){r=l[a+d*3-1];continue t}for(;f<d;){let c=f+d>>1,p=a+c+(c<<1),b=l[p],M=l[p+1]||65536;if(u<b)d=c;else if(u>=M)f=c+1;else{r=l[p+2],t.advance();continue t}}break}}function I(l,t,e){for(let s=t,i;(i=l[s])!=65535;s++)if(i==e)return s-t;return-1}function q(l,t,e,s){let i=I(e,s,t);return i<0||I(e,s,l)<i}const g=typeof process<"u"&&N&&/\bparse\b/.test(N.LOG);let T=null;function D(l,t,e){let s=l.cursor(G.IncludeAnonymous);for(s.moveTo(t);;)if(!(e<0?s.childBefore(t):s.childAfter(t)))for(;;){if((e<0?s.to<t:s.from>t)&&!s.type.isError)return e<0?Math.max(0,Math.min(s.to-1,t-25)):Math.min(l.length,Math.max(s.from+1,t+25));if(e<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return e<0?0:l.length}}class J{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?D(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?D(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let s=this.trees[e],i=this.index[e];if(i==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let h=s.children[i],r=this.start[e]+s.positions[i];if(r>t)return this.nextStart=r,null;if(h instanceof S){if(r==t){if(r<this.safeFrom)return null;let n=r+h.length;if(n<=this.safeTo){let o=h.prop(y.lookAhead);if(!o||n+o<this.fragment.to)return h}}this.index[e]++,r+h.length>=Math.max(this.safeFrom,t)&&(this.trees.push(h),this.start.push(r),this.index.push(0))}else this.index[e]++,this.nextStart=r+h.length}}}class K{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(s=>new P)}getActions(t){let e=0,s=null,{parser:i}=t.p,{tokenizers:h}=i,r=i.stateSlot(t.state,3),n=t.curContext?t.curContext.hash:0,o=0;for(let a=0;a<h.length;a++){if((1<<a&r)==0)continue;let u=h[a],f=this.tokens[a];if(!(s&&!u.fallback)&&((u.contextual||f.start!=t.pos||f.mask!=r||f.context!=n)&&(this.updateCachedToken(f,u,t),f.mask=r,f.context=n),f.lookAhead>f.end+25&&(o=Math.max(f.lookAhead,o)),f.value!=0)){let d=e;if(f.extended>-1&&(e=this.addActions(t,f.extended,f.end,e)),e=this.addActions(t,f.value,f.end,e),!u.extend&&(s=f,e>d))break}}for(;this.actions.length>e;)this.actions.pop();return o&&t.setLookAhead(o),!s&&t.pos==this.stream.end&&(s=new P,s.value=t.p.parser.eofTerm,s.start=s.end=t.pos,e=this.addActions(t,s.value,s.end,e)),this.mainToken=s,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new P,{pos:s,p:i}=t;return e.start=s,e.end=Math.min(s+1,i.stream.end),e.value=s==i.stream.end?i.parser.eofTerm:0,e}updateCachedToken(t,e,s){let i=this.stream.clipPos(s.pos);if(e.token(this.stream.reset(i,t),s),t.value>-1){let{parser:h}=s.p;for(let r=0;r<h.specialized.length;r++)if(h.specialized[r]==t.value){let n=h.specializers[r](this.stream.read(t.start,t.end),s);if(n>=0&&s.p.parser.dialect.allows(n>>1)){(n&1)==0?t.value=n>>1:t.extended=n>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,e,s,i){for(let h=0;h<i;h+=3)if(this.actions[h]==t)return i;return this.actions[i++]=t,this.actions[i++]=e,this.actions[i++]=s,i}addActions(t,e,s,i){let{state:h}=t,{parser:r}=t.p,{data:n}=r;for(let o=0;o<2;o++)for(let a=r.stateSlot(h,o?2:1);;a+=3){if(n[a]==65535)if(n[a+1]==1)a=k(n,a+2);else{i==0&&n[a+1]==2&&(i=this.putAction(k(n,a+2),e,s,i));break}n[a]==e&&(i=this.putAction(k(n,a+1),e,s,i))}return i}}class Q{constructor(t,e,s,i){this.parser=t,this.input=e,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new H(e,i),this.tokens=new K(t,this.stream),this.topTerm=t.top[1];let{from:h}=i[0];this.stacks=[v.start(this,t.top[0],h)],this.fragments=s.length&&this.stream.end-h>t.bufferLength*4?new J(s,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,s=this.stacks=[],i,h;if(this.bigReductionCount>300&&t.length==1){let[r]=t;for(;r.forceReduce()&&r.stack.length&&r.stack[r.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<t.length;r++){let n=t[r];for(;;){if(this.tokens.mainToken=null,n.pos>e)s.push(n);else{if(this.advanceStack(n,s,t))continue;{i||(i=[],h=[]),i.push(n);let o=this.tokens.getMainToken(n);h.push(o.value,o.end)}}break}}if(!s.length){let r=i&&X(i);if(r)return g&&console.log("Finish with "+this.stackID(r)),this.stackToTree(r);if(this.parser.strict)throw g&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&i){let r=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,h,s);if(r)return g&&console.log("Force-finish "+this.stackID(r)),this.stackToTree(r.forceAll())}if(this.recovering){let r=this.recovering==1?1:this.recovering*3;if(s.length>r)for(s.sort((n,o)=>o.score-n.score);s.length>r;)s.pop();s.some(n=>n.reducePos>e)&&this.recovering--}else if(s.length>1){t:for(let r=0;r<s.length-1;r++){let n=s[r];for(let o=r+1;o<s.length;o++){let a=s[o];if(n.sameState(a)||n.buffer.length>500&&a.buffer.length>500)if((n.score-a.score||n.buffer.length-a.buffer.length)>0)s.splice(o--,1);else{s.splice(r--,1);continue t}}}s.length>12&&(s.sort((r,n)=>n.score-r.score),s.splice(12,s.length-12))}this.minStackPos=s[0].pos;for(let r=1;r<s.length;r++)s[r].pos<this.minStackPos&&(this.minStackPos=s[r].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,s){let i=t.pos,{parser:h}=this,r=g?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let a=t.curContext&&t.curContext.tracker.strict,u=a?t.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?h.getGoto(t.state,f.type.id):-1;if(d>-1&&f.length&&(!a||(f.prop(y.contextHash)||0)==u))return t.useNode(f,d),g&&console.log(r+this.stackID(t)+` (via reuse of ${h.getName(f.type.id)})`),!0;if(!(f instanceof S)||f.children.length==0||f.positions[0]>0)break;let c=f.children[0];if(c instanceof S&&f.positions[0]==0)f=c;else break}}let n=h.stateSlot(t.state,4);if(n>0)return t.reduce(n),g&&console.log(r+this.stackID(t)+` (via always-reduce ${h.getName(n&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let o=this.tokens.getActions(t);for(let a=0;a<o.length;){let u=o[a++],f=o[a++],d=o[a++],c=a==o.length||!s,p=c?t:t.split(),b=this.tokens.mainToken;if(p.apply(u,f,b?b.start:p.pos,d),g&&console.log(r+this.stackID(p)+` (via ${(u&65536)==0?"shift":`reduce of ${h.getName(u&65535)}`} for ${h.getName(f)} @ ${i}${p==t?"":", split"})`),c)return!0;p.pos>i?e.push(p):s.push(p)}return!1}advanceFully(t,e){let s=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>s)return B(t,e),!0}}runRecovery(t,e,s){let i=null,h=!1;for(let r=0;r<t.length;r++){let n=t[r],o=e[r<<1],a=e[(r<<1)+1],u=g?this.stackID(n)+" -> ":"";if(n.deadEnd&&(h||(h=!0,n.restart(),g&&console.log(u+this.stackID(n)+" (restarted)"),this.advanceFully(n,s))))continue;let f=n.split(),d=u;for(let c=0;c<10&&f.forceReduce()&&(g&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,s));c++)g&&(d=this.stackID(f)+" -> ");for(let c of n.recoverByInsert(o))g&&console.log(u+this.stackID(c)+" (via recover-insert)"),this.advanceFully(c,s);this.stream.end>n.pos?(a==n.pos&&(a++,o=0),n.recoverByDelete(o,a),g&&console.log(u+this.stackID(n)+` (via recover-delete ${this.parser.getName(o)})`),B(n,s)):(!i||i.score<f.score)&&(i=f)}return i}stackToTree(t){return t.close(),S.build({buffer:A.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(T||(T=new WeakMap)).get(t);return e||T.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function B(l,t){for(let e=0;e<t.length;e++){let s=t[e];if(s.pos==l.pos&&s.sameState(l)){t[e].score<l.score&&(t[e]=l);return}}t.push(l)}class V{constructor(t,e,s){this.source=t,this.flags=e,this.disabled=s}allows(t){return!this.disabled||this.disabled[t]==0}}const C=l=>l;class _{constructor(t){this.start=t.start,this.shift=t.shift||C,this.reduce=t.reduce||C,this.reuse=t.reuse||C,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class w extends L{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let n=0;n<t.repeatNodeCount;n++)e.push("");let s=Object.keys(t.topRules).map(n=>t.topRules[n][1]),i=[];for(let n=0;n<e.length;n++)i.push([]);function h(n,o,a){i[n].push([o,o.deserialize(String(a))])}if(t.nodeProps)for(let n of t.nodeProps){let o=n[0];typeof o=="string"&&(o=y[o]);for(let a=1;a<n.length;){let u=n[a++];if(u>=0)h(u,o,n[a++]);else{let f=n[a+-u];for(let d=-u;d>0;d--)h(n[a++],o,f);a++}}}this.nodeSet=new $(e.map((n,o)=>E.define({name:o>=this.minRepeatTerm?void 0:n,id:o,props:i[o],top:s.indexOf(o)>-1,error:o==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(o)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=j;let r=x(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let n=0;n<this.specializerSpecs.length;n++)this.specialized[n]=this.specializerSpecs[n].term;this.specializers=this.specializerSpecs.map(O),this.states=x(t.states,Uint32Array),this.data=x(t.stateData),this.goto=x(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(n=>typeof n=="number"?new m(r,n):n),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,s){let i=new Q(this,t,e,s);for(let h of this.wrappers)i=h(i,t,e,s);return i}getGoto(t,e,s=!1){let i=this.goto;if(e>=i[0])return-1;for(let h=i[e+1];;){let r=i[h++],n=r&1,o=i[h++];if(n&&s)return o;for(let a=h+(r>>1);h<a;h++)if(i[h]==t)return o;if(n)return-1}}hasAction(t,e){let s=this.data;for(let i=0;i<2;i++)for(let h=this.stateSlot(t,i?2:1),r;;h+=3){if((r=s[h])==65535)if(s[h+1]==1)r=s[h=k(s,h+2)];else{if(s[h+1]==2)return k(s,h+2);break}if(r==e||r==0)return k(s,h+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,s=>s==e?!0:null)}allActions(t,e){let s=this.stateSlot(t,4),i=s?e(s):void 0;for(let h=this.stateSlot(t,1);i==null;h+=3){if(this.data[h]==65535)if(this.data[h+1]==1)h=k(this.data,h+2);else break;i=e(k(this.data,h+1))}return i}nextStates(t){let e=[];for(let s=this.stateSlot(t,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=k(this.data,s+2);else break;if((this.data[s+2]&1)==0){let i=this.data[s+1];e.some((h,r)=>r&1&&h==i)||e.push(this.data[s],i)}}return e}configure(t){let e=Object.assign(Object.create(w.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let s=this.topRules[t.top];if(!s)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=s}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(s=>{let i=t.tokenizers.find(h=>h.from==s);return i?i.to:s})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((s,i)=>{let h=t.specializers.find(n=>n.from==s.external);if(!h)return s;let r=Object.assign(Object.assign({},s),{external:h.to});return e.specializers[i]=O(r),r})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),s=e.map(()=>!1);if(t)for(let h of t.split(" ")){let r=e.indexOf(h);r>=0&&(s[r]=!0)}let i=null;for(let h=0;h<e.length;h++)if(!s[h])for(let r=this.dialects[e[h]],n;(n=this.data[r++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[n]=1;return new V(t,s,i)}static deserialize(t){return new w(t)}}function k(l,t){return l[t]|l[t+1]<<16}function X(l){let t=null;for(let e of l){let s=e.p.stoppedAt;(e.pos==e.p.stream.end||s!=null&&e.pos>s)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function O(l){if(l.external){let t=l.extend?1:0;return(e,s)=>l.external(e,s)<<1|t}return l.get}export{_ as C,Z as E,w as L,W as a};
@@ -1 +1 @@
1
- import{j as E,D as T,F as D,S as x,v as L,G as A,m as k,H as g,J as O,E as w,n as P,o as M,M as v,W as R,K as j,R as B}from"./field-D_1hHgxN.js";class te{constructor(t,e,n,i){this.state=t,this.pos=e,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=E(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),i=e.text.slice(n-e.from,this.pos-e.from),l=i.search(H(t));return l<0?null:{from:n+l,to:this.pos,text:i.slice(l)}}get aborted(){return this.abortListeners==null}addEventListener(t,e,n){t=="abort"&&this.abortListeners&&(this.abortListeners.push(e),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function S(o){let t=Object.keys(o).join(""),e=/\w/.test(t);return e&&(t=t.replace(/\w/g,"")),`[${e?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function W(o){let t=Object.create(null),e=Object.create(null);for(let{label:i}of o){t[i[0]]=!0;for(let l=1;l<i.length;l++)e[i[l]]=!0}let n=S(t)+S(e)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function ne(o){let t=o.map(i=>typeof i=="string"?{label:i}:i),[e,n]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:W(t);return i=>{let l=i.matchBefore(n);return l||i.explicit?{from:l?l.from:i.pos,options:t,validFor:e}:null}}function oe(o,t){return e=>{for(let n=E(e.state).resolveInner(e.pos,-1);n;n=n.parent){if(o.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return t(e)}}function H(o,t){var e;let{source:n}=o,i=n[n.length-1]!="$";return i?new RegExp(`(?:${n})${i?"$":""}`,(e=o.flags)!==null&&e!==void 0?e:o.ignoreCase?"i":""):o}const V=A.define(),q=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class z{constructor(t,e,n,i){this.field=t,this.line=e,this.from=n,this.to=i}}class b{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,v.TrackDel),n=t.mapPos(this.to,1,v.TrackDel);return e==null||n==null?null:new b(this.field,e,n)}}class I{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],i=[e],l=t.doc.lineAt(e),p=/^\s*/.exec(l.text)[0];for(let r of this.lines){if(n.length){let f=p,c=/^\t*/.exec(r)[0].length;for(let s=0;s<c;s++)f+=t.facet(L);i.push(e+f.length-c),r=f+r.slice(c)}n.push(r),e+=r.length+1}let a=this.fieldPositions.map(r=>new b(r.field,i[r.line]+r.from,i[r.line]+r.to));return{text:n,ranges:a}}static parse(t){let e=[],n=[],i=[],l;for(let p of t.split(/\r\n?|\n/)){for(;l=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(p);){let a=l[1]?+l[1]:null,r=l[2]||l[3]||"",f=-1;a===0&&(a=1e9);let c=r.replace(/\\[{}]/g,s=>s[1]);for(let s=0;s<e.length;s++)(a!=null?e[s].seq==a:c&&e[s].name==c)&&(f=s);if(f<0){let s=0;for(;s<e.length&&(a==null||e[s].seq!=null&&e[s].seq<a);)s++;e.splice(s,0,{seq:a,name:c}),f=s;for(let d of i)d.field>=f&&d.field++}for(let s of i)if(s.line==n.length&&s.from>l.index){let d=l[2]?3+(l[1]||"").length:2;s.from-=d,s.to-=d}i.push(new z(f,n.length,l.index,l.index+c.length)),p=p.slice(0,l.index)+r+p.slice(l.index+l[0].length)}p=p.replace(/\\([{}])/g,(a,r,f)=>{for(let c of i)c.line==n.length&&c.from>f&&(c.from--,c.to--);return r}),n.push(p)}return new I(n,i)}}let K=g.widget({widget:new class extends R{toDOM(){let o=document.createElement("span");return o.className="cm-snippetFieldPosition",o}ignoreEvent(){return!1}}}),N=g.mark({class:"cm-snippetField"});class m{constructor(t,e){this.ranges=t,this.active=e,this.deco=g.set(t.map(n=>(n.from==n.to?K:N).range(n.from,n.to)),!0)}map(t){let e=[];for(let n of this.ranges){let i=n.map(t);if(!i)return null;e.push(i)}return new m(e,this.active)}selectionInsideField(t){return t.ranges.every(e=>this.ranges.some(n=>n.field==this.active&&n.from<=e.from&&n.to>=e.to))}}const h=x.define({map(o,t){return o&&o.map(t)}}),X=x.define(),u=O.define({create(){return null},update(o,t){for(let e of t.effects){if(e.is(h))return e.value;if(e.is(X)&&o)return new m(o.ranges,e.value)}return o&&t.docChanged&&(o=o.map(t.changes)),o&&t.selection&&!o.selectionInsideField(t.selection)&&(o=null),o},provide:o=>w.decorations.from(o,t=>t?t.deco:g.none)});function y(o,t){return k.create(o.filter(e=>e.field==t).map(e=>k.range(e.from,e.to)))}function G(o){let t=I.parse(o);return(e,n,i,l)=>{let{text:p,ranges:a}=t.instantiate(e.state,i),{main:r}=e.state.selection,f={changes:{from:i,to:l==r.from?r.to:l,insert:D.of(p)},scrollIntoView:!0,annotations:n?[V.of(n),T.userEvent.of("input.complete")]:void 0};if(a.length&&(f.selection=y(a,0)),a.some(c=>c.field>0)){let c=new m(a,0),s=f.effects=[h.of(c)];e.state.field(u,!1)===void 0&&s.push(x.appendConfig.of([u,Z,_,q]))}e.dispatch(e.state.update(f))}}function $(o){return({state:t,dispatch:e})=>{let n=t.field(u,!1);if(!n||o<0&&n.active==0)return!1;let i=n.active+o,l=o>0&&!n.ranges.some(p=>p.field==i+o);return e(t.update({selection:y(n.ranges,i),effects:h.of(l?null:new m(n.ranges,i)),scrollIntoView:!0})),!0}}const J=({state:o,dispatch:t})=>o.field(u,!1)?(t(o.update({effects:h.of(null)})),!0):!1,U=$(1),Y=$(-1),Q=[{key:"Tab",run:U,shift:Y},{key:"Escape",run:J}],F=j.define({combine(o){return o.length?o[0]:Q}}),Z=P.highest(M.compute([F],o=>o.facet(F)));function ie(o,t){return{...t,apply:G(o)}}const _=w.domEventHandlers({mousedown(o,t){let e=t.state.field(u,!1),n;if(!e||(n=t.posAtCoords({x:o.clientX,y:o.clientY}))==null)return!1;let i=e.ranges.find(l=>l.from<=n&&l.to>=n);return!i||i.field==e.active?!1:(t.dispatch({selection:y(e.ranges,i.field),effects:h.of(e.ranges.some(l=>l.field>i.field)?new m(e.ranges,i.field):null),scrollIntoView:!0}),!0)}}),C=new class extends B{};C.startSide=1;C.endSide=-1;export{te as C,ne as c,oe as i,ie as s};
1
+ import{j as E,D as T,F as D,S as x,v as L,G as A,m as k,H as g,J as O,E as w,n as P,o as M,M as v,W as R,K as j,R as B}from"./field-CVqP2pjA.js";class te{constructor(t,e,n,i){this.state=t,this.pos=e,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=E(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),i=e.text.slice(n-e.from,this.pos-e.from),l=i.search(H(t));return l<0?null:{from:n+l,to:this.pos,text:i.slice(l)}}get aborted(){return this.abortListeners==null}addEventListener(t,e,n){t=="abort"&&this.abortListeners&&(this.abortListeners.push(e),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function S(o){let t=Object.keys(o).join(""),e=/\w/.test(t);return e&&(t=t.replace(/\w/g,"")),`[${e?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function W(o){let t=Object.create(null),e=Object.create(null);for(let{label:i}of o){t[i[0]]=!0;for(let l=1;l<i.length;l++)e[i[l]]=!0}let n=S(t)+S(e)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function ne(o){let t=o.map(i=>typeof i=="string"?{label:i}:i),[e,n]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:W(t);return i=>{let l=i.matchBefore(n);return l||i.explicit?{from:l?l.from:i.pos,options:t,validFor:e}:null}}function oe(o,t){return e=>{for(let n=E(e.state).resolveInner(e.pos,-1);n;n=n.parent){if(o.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return t(e)}}function H(o,t){var e;let{source:n}=o,i=n[n.length-1]!="$";return i?new RegExp(`(?:${n})${i?"$":""}`,(e=o.flags)!==null&&e!==void 0?e:o.ignoreCase?"i":""):o}const V=A.define(),q=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class z{constructor(t,e,n,i){this.field=t,this.line=e,this.from=n,this.to=i}}class b{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,v.TrackDel),n=t.mapPos(this.to,1,v.TrackDel);return e==null||n==null?null:new b(this.field,e,n)}}class I{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],i=[e],l=t.doc.lineAt(e),p=/^\s*/.exec(l.text)[0];for(let r of this.lines){if(n.length){let f=p,c=/^\t*/.exec(r)[0].length;for(let s=0;s<c;s++)f+=t.facet(L);i.push(e+f.length-c),r=f+r.slice(c)}n.push(r),e+=r.length+1}let a=this.fieldPositions.map(r=>new b(r.field,i[r.line]+r.from,i[r.line]+r.to));return{text:n,ranges:a}}static parse(t){let e=[],n=[],i=[],l;for(let p of t.split(/\r\n?|\n/)){for(;l=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(p);){let a=l[1]?+l[1]:null,r=l[2]||l[3]||"",f=-1;a===0&&(a=1e9);let c=r.replace(/\\[{}]/g,s=>s[1]);for(let s=0;s<e.length;s++)(a!=null?e[s].seq==a:c&&e[s].name==c)&&(f=s);if(f<0){let s=0;for(;s<e.length&&(a==null||e[s].seq!=null&&e[s].seq<a);)s++;e.splice(s,0,{seq:a,name:c}),f=s;for(let d of i)d.field>=f&&d.field++}for(let s of i)if(s.line==n.length&&s.from>l.index){let d=l[2]?3+(l[1]||"").length:2;s.from-=d,s.to-=d}i.push(new z(f,n.length,l.index,l.index+c.length)),p=p.slice(0,l.index)+r+p.slice(l.index+l[0].length)}p=p.replace(/\\([{}])/g,(a,r,f)=>{for(let c of i)c.line==n.length&&c.from>f&&(c.from--,c.to--);return r}),n.push(p)}return new I(n,i)}}let K=g.widget({widget:new class extends R{toDOM(){let o=document.createElement("span");return o.className="cm-snippetFieldPosition",o}ignoreEvent(){return!1}}}),N=g.mark({class:"cm-snippetField"});class m{constructor(t,e){this.ranges=t,this.active=e,this.deco=g.set(t.map(n=>(n.from==n.to?K:N).range(n.from,n.to)),!0)}map(t){let e=[];for(let n of this.ranges){let i=n.map(t);if(!i)return null;e.push(i)}return new m(e,this.active)}selectionInsideField(t){return t.ranges.every(e=>this.ranges.some(n=>n.field==this.active&&n.from<=e.from&&n.to>=e.to))}}const h=x.define({map(o,t){return o&&o.map(t)}}),X=x.define(),u=O.define({create(){return null},update(o,t){for(let e of t.effects){if(e.is(h))return e.value;if(e.is(X)&&o)return new m(o.ranges,e.value)}return o&&t.docChanged&&(o=o.map(t.changes)),o&&t.selection&&!o.selectionInsideField(t.selection)&&(o=null),o},provide:o=>w.decorations.from(o,t=>t?t.deco:g.none)});function y(o,t){return k.create(o.filter(e=>e.field==t).map(e=>k.range(e.from,e.to)))}function G(o){let t=I.parse(o);return(e,n,i,l)=>{let{text:p,ranges:a}=t.instantiate(e.state,i),{main:r}=e.state.selection,f={changes:{from:i,to:l==r.from?r.to:l,insert:D.of(p)},scrollIntoView:!0,annotations:n?[V.of(n),T.userEvent.of("input.complete")]:void 0};if(a.length&&(f.selection=y(a,0)),a.some(c=>c.field>0)){let c=new m(a,0),s=f.effects=[h.of(c)];e.state.field(u,!1)===void 0&&s.push(x.appendConfig.of([u,Z,_,q]))}e.dispatch(e.state.update(f))}}function $(o){return({state:t,dispatch:e})=>{let n=t.field(u,!1);if(!n||o<0&&n.active==0)return!1;let i=n.active+o,l=o>0&&!n.ranges.some(p=>p.field==i+o);return e(t.update({selection:y(n.ranges,i),effects:h.of(l?null:new m(n.ranges,i)),scrollIntoView:!0})),!0}}const J=({state:o,dispatch:t})=>o.field(u,!1)?(t(o.update({effects:h.of(null)})),!0):!1,U=$(1),Y=$(-1),Q=[{key:"Tab",run:U,shift:Y},{key:"Escape",run:J}],F=j.define({combine(o){return o.length?o[0]:Q}}),Z=P.highest(M.compute([F],o=>o.facet(F)));function ie(o,t){return{...t,apply:G(o)}}const _=w.domEventHandlers({mousedown(o,t){let e=t.state.field(u,!1),n;if(!e||(n=t.posAtCoords({x:o.clientX,y:o.clientY}))==null)return!1;let i=e.ranges.find(l=>l.from<=n&&l.to>=n);return!i||i.field==e.active?!1:(t.dispatch({selection:y(e.ranges,i.field),effects:h.of(e.ranges.some(l=>l.field>i.field)?new m(e.ranges,i.field):null),scrollIntoView:!0}),!0)}}),C=new class extends B{};C.startSide=1;C.endSide=-1;export{te as C,ne as c,oe as i,ie as s};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CilvCpdu.js","./_commonjsHelpers-CE1G-McA.js","./index-9IJ0xse9.js","./index-D5OEevqH.css"])))=>i.map(i=>d[i]);
2
- import{_ as u,b as a,I as c}from"./index-9IJ0xse9.js";import{r as p}from"./refusal-DOpm8I8L.js";const m={gray:"gray",hot:"hot",jet:"jet",cool:"cool"},d={wl:"contrast",pan:"pan",length:"measurement",angle:"angle"};class g{name="niivue";host;path;nv=null;module=null;layout="mpr";tool="wl";colormap="gray";slice=0;slices=0;refused=0;disposed=!1;constructor(s,t){this.host=s,this.path=t}async open(s){const t=document.createElement("canvas");t.className="image-canvas",s.appendChild(t),this.host.readout_set("LOADING"),this.host.progress_set({label:"READING VOLUME",done:0,total:0});const e=performance.now();if(this.module=await u(()=>import("./index-CilvCpdu.js"),__vite__mapDeps([0,1,2,3]),import.meta.url),this.disposed)return;const i=new this.module.Niivue({isResizeCanvas:!0,logLevel:"error",dragAndDropEnabled:!1,crosshairWidth:.4,crosshairWidthUnit:"percent"});i.onLocationChange=o=>{const r=o,l=r.vox?.[2];l!==void 0&&(this.slice=l+1),this.host.readout_set(`${this.slices>0?`SLICE ${this.slice} OF ${this.slices} · `:""}${r.string??""}`)},await i.attachToCanvas(t);const n=this.path.split("/").pop()??"volume.nii.gz";try{await i.loadVolumes([{url:a(this.host.source.url_of(this.path),location.href),name:n}])}catch(o){this.refused=1,this.host.progress_set(null),this.host.readout_set("REFUSED 1 OF 1"),this.host.note(`image: ${this.path}: ${o instanceof Error?o.message:String(o)}`);const r=await p(a(this.host.source.url_of(this.path),location.href));this.host.readout_set(`REFUSED 1 OF 1 · ${r}`),this.host.note(`image: ${this.path}: ${r.toLowerCase()}`);return}if(this.host.progress_set(null),this.disposed)return;this.nv=i;const h=i.volumes[0]?.dims;this.slices=h?.[3]??0,i.setSliceType(i.sliceTypeMultiplanar),this.layout="mpr",this.host.readout_set(`${this.slices} SLICES`),this.host.note(`image: ${n} drawn in ${Math.round(performance.now()-e)} ms`),this.host.regard(this.path)}async layout_set(s){return s==="slab"||this.nv===null?!1:(this.nv.setSliceType(s==="single"?this.nv.sliceTypeAxial:s==="mpr"?this.nv.sliceTypeMultiplanar:this.nv.sliceTypeRender),this.layout=s,this.host.readout_set(`${this.slices} SLICES`),!0)}slice_set(s){if(this.nv===null||this.slices===0)return!1;const t=Math.max(1,Math.min(s,this.slices)),e=this.slice>0?this.slice:Math.ceil(this.slices/2);return this.nv.moveCrosshairInVox(0,0,t-e),this.slice=t,!0}wl_set(s,t){const e=this.nv?.volumes[0];return this.nv===null||e===void 0?!1:(e.cal_min=s,e.cal_max=t,this.nv.updateGLVolume(),!0)}colormap_set(s){const t=this.nv?.volumes[0];return this.nv===null||t?.id===void 0?!1:(this.colormap=s,this.nv.setColormap(t.id,m[s]),!0)}toolsOffered_get(){return c}ghost_set(s){return!1}tool_set(s){const t=d[s];return this.nv===null||t===void 0?!1:(this.nv.setDragMode(t),this.tool=s,!0)}annotations_export(){return Promise.resolve(null)}annotations_import(){return Promise.resolve(0)}async slices_fill(){return this.nv!==null}state_get(){return{engine:"niivue",layout:this.layout,slice:this.slice,slices:this.slices,tool:this.tool,primaryTool:this.tool,refused:this.refused,annotations:0,filled:this.nv!==null,colormap:this.colormap}}dispose(){this.disposed=!0,this.nv=null}}export{g as NiivueEngine};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-C2JM3oDu.js","./_commonjsHelpers-CE1G-McA.js","./index--MRRVo__.js","./index-D5OEevqH.css"])))=>i.map(i=>d[i]);
2
+ import{_ as u,b as a,I as c}from"./index--MRRVo__.js";import{r as p}from"./refusal-DOpm8I8L.js";const m={gray:"gray",hot:"hot",jet:"jet",cool:"cool"},d={wl:"contrast",pan:"pan",length:"measurement",angle:"angle"};class g{name="niivue";host;path;nv=null;module=null;layout="mpr";tool="wl";colormap="gray";slice=0;slices=0;refused=0;disposed=!1;constructor(s,t){this.host=s,this.path=t}async open(s){const t=document.createElement("canvas");t.className="image-canvas",s.appendChild(t),this.host.readout_set("LOADING"),this.host.progress_set({label:"READING VOLUME",done:0,total:0});const e=performance.now();if(this.module=await u(()=>import("./index-C2JM3oDu.js"),__vite__mapDeps([0,1,2,3]),import.meta.url),this.disposed)return;const i=new this.module.Niivue({isResizeCanvas:!0,logLevel:"error",dragAndDropEnabled:!1,crosshairWidth:.4,crosshairWidthUnit:"percent"});i.onLocationChange=o=>{const r=o,l=r.vox?.[2];l!==void 0&&(this.slice=l+1),this.host.readout_set(`${this.slices>0?`SLICE ${this.slice} OF ${this.slices} · `:""}${r.string??""}`)},await i.attachToCanvas(t);const n=this.path.split("/").pop()??"volume.nii.gz";try{await i.loadVolumes([{url:a(this.host.source.url_of(this.path),location.href),name:n}])}catch(o){this.refused=1,this.host.progress_set(null),this.host.readout_set("REFUSED 1 OF 1"),this.host.note(`image: ${this.path}: ${o instanceof Error?o.message:String(o)}`);const r=await p(a(this.host.source.url_of(this.path),location.href));this.host.readout_set(`REFUSED 1 OF 1 · ${r}`),this.host.note(`image: ${this.path}: ${r.toLowerCase()}`);return}if(this.host.progress_set(null),this.disposed)return;this.nv=i;const h=i.volumes[0]?.dims;this.slices=h?.[3]??0,i.setSliceType(i.sliceTypeMultiplanar),this.layout="mpr",this.host.readout_set(`${this.slices} SLICES`),this.host.note(`image: ${n} drawn in ${Math.round(performance.now()-e)} ms`),this.host.regard(this.path)}async layout_set(s){return s==="slab"||this.nv===null?!1:(this.nv.setSliceType(s==="single"?this.nv.sliceTypeAxial:s==="mpr"?this.nv.sliceTypeMultiplanar:this.nv.sliceTypeRender),this.layout=s,this.host.readout_set(`${this.slices} SLICES`),!0)}slice_set(s){if(this.nv===null||this.slices===0)return!1;const t=Math.max(1,Math.min(s,this.slices)),e=this.slice>0?this.slice:Math.ceil(this.slices/2);return this.nv.moveCrosshairInVox(0,0,t-e),this.slice=t,!0}wl_set(s,t){const e=this.nv?.volumes[0];return this.nv===null||e===void 0?!1:(e.cal_min=s,e.cal_max=t,this.nv.updateGLVolume(),!0)}colormap_set(s){const t=this.nv?.volumes[0];return this.nv===null||t?.id===void 0?!1:(this.colormap=s,this.nv.setColormap(t.id,m[s]),!0)}toolsOffered_get(){return c}ghost_set(s){return!1}tool_set(s){const t=d[s];return this.nv===null||t===void 0?!1:(this.nv.setDragMode(t),this.tool=s,!0)}annotations_export(){return Promise.resolve(null)}annotations_import(){return Promise.resolve(0)}async slices_fill(){return this.nv!==null}state_get(){return{engine:"niivue",layout:this.layout,slice:this.slice,slices:this.slices,tool:this.tool,primaryTool:this.tool,refused:this.refused,annotations:0,filled:this.nv!==null,colormap:this.colormap}}dispose(){this.disposed=!0,this.nv=null}}export{g as NiivueEngine};
@@ -1,4 +1,4 @@
1
- import{m as v,as as _e,R as ft,K as Ge,L as Le,W as ke,N as We,k as de,E as X,t as vt,i as Me,x as ce,F as ht,Z as St,h as dt,D as Tt,al as wt,c as yt,at as Ct,d as Ve,au as xt,y as ue,ak as le,av as ze,j as pe}from"./cornerstoneEngine-6cb4qtUU.js";import{ae as Ne,am as De,an as re,K as B,k as Z,al as $,D as se,U as $e,X as Be,B as Q,J as Et,E as Rt,ak as _t,$ as He,a2 as Mt,Z as Vt,b as Dt,_ as Ke,ao as Bt,ap as be,aq as mt,ar as Te,as as Ot,z as Ut,at as Ft,au as Pt,av as ae,ad as Gt,R as Lt,aw as Y,ah as kt,ai as Wt,C as zt,P as Nt,I as $t,a as Ht}from"./Texture-DN4nnuQU.js";import"./index-9IJ0xse9.js";import"./refusal-DOpm8I8L.js";import"./_commonjsHelpers-CE1G-McA.js";function Kt(t){return t}function ye(t){if(t===null||t==="null")return null;if(t==="true")return!0;if(t==="false")return!1;if(!(t===void 0||t==="undefined"))return t[0]==="["&&t[t.length-1]==="]"?t.substring(1,t.length-1).split(",").map(e=>ye(e.trim())):t===""||Number.isNaN(Number(t))?t:Number(t)}function bt(t=!0,e=window.location.search){const r={},s=t?ye:Kt;return new URLSearchParams(e).forEach((n,a)=>{a&&(r[a]=n?s(n):!0)}),r}var It={toNativeType:ye,extractURLParameters:bt},jt={IS_START:0,IS_NONE:0,IS_ROTATE:1,IS_PAN:2,IS_SPIN:3,IS_DOLLY:4,IS_CAMERA_POSE:11,IS_WINDOW_LEVEL:1024,IS_SLICE:1025},Ce={States:jt},{vtkErrorMacro:Qt,VOID:Yt}=v;function Xt(t,e,r,s){return t.getRenderWindow().getViews()[0].worldToDisplay(e,r,s,t)}function Zt(t,e,r,s){return t.getRenderWindow().getViews()[0].displayToWorld(e,r,s,t)}var Jt={computeWorldToDisplay:Xt,computeDisplayToWorld:Zt};function qt(t,e){e.classHierarchy.push("vtkInteractorObserver");const r={...t};function s(){for(;e.subscribedEvents.length;)e.subscribedEvents.pop().unsubscribe()}function n(){Ne.handledEvents.forEach(a=>{t[`handle${a}`]&&e.subscribedEvents.push(e._interactor[`on${a}`](o=>e.processEvents?t[`handle${a}`](o):Yt,e.priority))})}t.setInteractor=a=>{a!==e._interactor&&(s(),e._interactor=a,a&&e.enabled&&n(),t.modified())},t.setEnabled=a=>{a!==e.enabled&&(s(),a&&(e._interactor?n():Qt(`
1
+ import{m as v,as as _e,R as ft,K as Ge,L as Le,W as ke,N as We,k as de,E as X,t as vt,i as Me,x as ce,F as ht,Z as St,h as dt,D as Tt,al as wt,c as yt,at as Ct,d as Ve,au as xt,y as ue,ak as le,av as ze,j as pe}from"./cornerstoneEngine-D1k_eGOf.js";import{ae as Ne,am as De,an as re,K as B,k as Z,al as $,D as se,U as $e,X as Be,B as Q,J as Et,E as Rt,ak as _t,$ as He,a2 as Mt,Z as Vt,b as Dt,_ as Ke,ao as Bt,ap as be,aq as mt,ar as Te,as as Ot,z as Ut,at as Ft,au as Pt,av as ae,ad as Gt,R as Lt,aw as Y,ah as kt,ai as Wt,C as zt,P as Nt,I as $t,a as Ht}from"./Texture-DhflYwlm.js";import"./index--MRRVo__.js";import"./refusal-DOpm8I8L.js";import"./_commonjsHelpers-CE1G-McA.js";function Kt(t){return t}function ye(t){if(t===null||t==="null")return null;if(t==="true")return!0;if(t==="false")return!1;if(!(t===void 0||t==="undefined"))return t[0]==="["&&t[t.length-1]==="]"?t.substring(1,t.length-1).split(",").map(e=>ye(e.trim())):t===""||Number.isNaN(Number(t))?t:Number(t)}function bt(t=!0,e=window.location.search){const r={},s=t?ye:Kt;return new URLSearchParams(e).forEach((n,a)=>{a&&(r[a]=n?s(n):!0)}),r}var It={toNativeType:ye,extractURLParameters:bt},jt={IS_START:0,IS_NONE:0,IS_ROTATE:1,IS_PAN:2,IS_SPIN:3,IS_DOLLY:4,IS_CAMERA_POSE:11,IS_WINDOW_LEVEL:1024,IS_SLICE:1025},Ce={States:jt},{vtkErrorMacro:Qt,VOID:Yt}=v;function Xt(t,e,r,s){return t.getRenderWindow().getViews()[0].worldToDisplay(e,r,s,t)}function Zt(t,e,r,s){return t.getRenderWindow().getViews()[0].displayToWorld(e,r,s,t)}var Jt={computeWorldToDisplay:Xt,computeDisplayToWorld:Zt};function qt(t,e){e.classHierarchy.push("vtkInteractorObserver");const r={...t};function s(){for(;e.subscribedEvents.length;)e.subscribedEvents.pop().unsubscribe()}function n(){Ne.handledEvents.forEach(a=>{t[`handle${a}`]&&e.subscribedEvents.push(e._interactor[`on${a}`](o=>e.processEvents?t[`handle${a}`](o):Yt,e.priority))})}t.setInteractor=a=>{a!==e._interactor&&(s(),e._interactor=a,a&&e.enabled&&n(),t.modified())},t.setEnabled=a=>{a!==e.enabled&&(s(),a&&(e._interactor?n():Qt(`
2
2
  The interactor must be set before subscribing to events
3
3
  `)),e.enabled=a,t.modified())},t.computeDisplayToWorld=(a,o,i,u)=>a?e._interactor.getView().displayToWorld(o,i,u,a):null,t.computeWorldToDisplay=(a,o,i,u)=>a?e._interactor.getView().worldToDisplay(o,i,u,a):null,t.setPriority=a=>{r.setPriority(a)&&e._interactor&&(s(),n())}}var At={enabled:!0,priority:0,processEvents:!0,subscribedEvents:[]};function Ie(t,e,r={}){Object.assign(e,At,r),v.obj(t,e),v.event(t,e,"InteractionEvent"),v.event(t,e,"StartInteractionEvent"),v.event(t,e,"EndInteractionEvent"),v.get(t,e,["_interactor","enabled"]),v.setGet(t,e,["priority","processEvents"]),v.moveToProtected(t,e,["interactor"]),qt(t,e)}var en=v.newInstance(Ie,"vtkInteractorObserver"),tn={newInstance:en,extend:Ie,...Jt},{States:N}=Ce,ge={Rotate:N.IS_ROTATE,Pan:N.IS_PAN,Spin:N.IS_SPIN,Dolly:N.IS_DOLLY,CameraPose:N.IS_CAMERA_POSE,WindowLevel:N.IS_WINDOW_LEVEL,Slice:N.IS_SLICE};function nn(t,e){e.classHierarchy.push("vtkInteractorStyle"),Object.keys(ge).forEach(r=>{v.event(t,e,`Start${r}Event`),t[`start${r}`]=()=>{e.state===N.IS_NONE&&(e.state=ge[r],e._interactor.requestAnimation(t),t.invokeStartInteractionEvent({type:"StartInteractionEvent"}),t[`invokeStart${r}Event`]({type:`Start${r}Event`}))},v.event(t,e,`End${r}Event`),t[`end${r}`]=()=>{e.state===ge[r]&&(e.state=N.IS_NONE,e._interactor.cancelAnimation(t),t.invokeEndInteractionEvent({type:"EndInteractionEvent"}),t[`invokeEnd${r}Event`]({type:`End${r}Event`}),e._interactor.render())}}),e.getRenderer=r=>e.focusedRenderer||r.pokedRenderer,t.handleKeyPress=r=>{const s=e._interactor;let n=null;switch(r.key){case"r":case"R":e.getRenderer(r).resetCamera(),s.render();break;case"w":case"W":n=e.getRenderer(r).getActors(),n.forEach(a=>{const o=a.getProperty();o.setRepresentationToWireframe&&o.setRepresentationToWireframe()}),s.render();break;case"s":case"S":n=e.getRenderer(r).getActors(),n.forEach(a=>{const o=a.getProperty();o.setRepresentationToSurface&&o.setRepresentationToSurface()}),s.render();break;case"v":case"V":n=e.getRenderer(r).getActors(),n.forEach(a=>{const o=a.getProperty();o.setRepresentationToPoints&&o.setRepresentationToPoints()}),s.render();break}}}var rn={state:N.IS_NONE,handleObservers:1,autoAdjustCameraClippingRange:1};function je(t,e,r={}){Object.assign(e,rn,r),tn.extend(t,e,r),v.setGet(t,e,["focusedRenderer"]),nn(t,e)}var an=v.newInstance(je,"vtkInteractorStyle"),xe={newInstance:an,extend:je,...Ce},{States:W}=Ce;function sn(t,e){e.classHierarchy.push("vtkInteractorStyleTrackballCamera"),t.handleMouseMove=r=>{const s=r.position,n=e.getRenderer(r);switch(e.state){case W.IS_ROTATE:t.handleMouseRotate(n,s),t.invokeInteractionEvent({type:"InteractionEvent"});break;case W.IS_PAN:t.handleMousePan(n,s),t.invokeInteractionEvent({type:"InteractionEvent"});break;case W.IS_DOLLY:e.wheelDolly||(t.handleMouseDolly(n,s),t.invokeInteractionEvent({type:"InteractionEvent"}));break;case W.IS_SPIN:t.handleMouseSpin(n,s),t.invokeInteractionEvent({type:"InteractionEvent"});break}e.previousPosition=s},t.handleButton3D=r=>{if(r&&r.pressed&&r.device===De.RightController&&(r.input===re.Trigger||r.input===re.TrackPad)){t.startCameraPose();return}r&&!r.pressed&&r.device===De.RightController&&(r.input===re.Trigger||r.input===re.TrackPad)&&e.state===W.IS_CAMERA_POSE&&t.endCameraPose()},t.handleMove3D=r=>{e.state===W.IS_CAMERA_POSE&&t.updateCameraPose(r)},t.updateCameraPose=r=>{const s=e.getRenderer(r).getActiveCamera(),n=s.getPhysicalTranslation(),a=.5*.05*s.getPhysicalScale(),o=s.physicalOrientationToWorldDirection([r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w]);s.setPhysicalTranslation(n[0]+o[0]*a,n[1]+o[1]*a,n[2]+o[2]*a)},t.handleLeftButtonPress=r=>{e.previousPosition=r.position,r.shiftKey?r.controlKey||r.altKey?t.startDolly():t.startPan():r.controlKey||r.altKey?t.startSpin():t.startRotate()},t.handleLeftButtonRelease=()=>{switch(e.state){case W.IS_DOLLY:t.endDolly();break;case W.IS_PAN:t.endPan();break;case W.IS_SPIN:t.endSpin();break;case W.IS_ROTATE:t.endRotate();break}},t.handleStartMouseWheel=()=>{e.wheelDolly=!0,t.startDolly()},t.handleEndMouseWheel=()=>{t.endDolly(),e.wheelDolly=!1},t.handleStartPinch=r=>{e.previousScale=r.scale,t.startDolly()},t.handleEndPinch=()=>{t.endDolly()},t.handleStartRotate=r=>{e.previousRotation=r.rotation,t.startRotate()},t.handleEndRotate=()=>{t.endRotate()},t.handleStartPan=r=>{e.previousTranslation=r.translation,t.startPan()},t.handleEndPan=()=>{t.endPan()},t.handlePinch=r=>{t.dollyByFactor(e.getRenderer(r),r.scale/e.previousScale),e.previousScale=r.scale},t.handlePan=r=>{const s=e.getRenderer(r).getActiveCamera();let n=s.getFocalPoint();n=t.computeWorldToDisplay(e.getRenderer(r),n[0],n[1],n[2]);const a=n[2],o=r.translation,i=e.previousTranslation,u=t.computeDisplayToWorld(e.getRenderer(r),n[0]+o[0]-i[0],n[1]+o[1]-i[1],a),p=t.computeDisplayToWorld(e.getRenderer(r),n[0],n[1],a),c=[];c[0]=p[0]-u[0],c[1]=p[1]-u[1],c[2]=p[2]-u[2],n=s.getFocalPoint();const l=s.getPosition();s.setFocalPoint(c[0]+n[0],c[1]+n[1],c[2]+n[2]),s.setPosition(c[0]+l[0],c[1]+l[1],c[2]+l[2]),e._interactor.getLightFollowCamera()&&e.getRenderer(r).updateLightsGeometryToFollowCamera(),s.orthogonalizeViewUp(),e.previousTranslation=r.translation},t.handleRotate=r=>{const s=e.getRenderer(r).getActiveCamera();s.roll(r.rotation-e.previousRotation),s.orthogonalizeViewUp(),e.previousRotation=r.rotation},t.handleMouseRotate=(r,s)=>{if(!e.previousPosition)return;const n=e._interactor,a=s.x-e.previousPosition.x,o=s.y-e.previousPosition.y,i=n.getView().getViewportSize(r);let u=-.1,p=-.1;i[0]&&i[1]&&(u=-20/i[1],p=-20/i[0]);const c=a*p*e.motionFactor,l=o*u*e.motionFactor,g=r.getActiveCamera();!Number.isNaN(c)&&!Number.isNaN(l)&&(g.azimuth(c),g.elevation(l),g.orthogonalizeViewUp()),e.autoAdjustCameraClippingRange&&r.resetCameraClippingRange(),n.getLightFollowCamera()&&r.updateLightsGeometryToFollowCamera()},t.handleMouseSpin=(r,s)=>{if(!e.previousPosition)return;const n=e._interactor,a=r.getActiveCamera(),o=n.getView().getViewportCenter(r),i=_e(Math.atan2(e.previousPosition.y-o[1],e.previousPosition.x-o[0])),u=_e(Math.atan2(s.y-o[1],s.x-o[0]))-i;Number.isNaN(u)||(a.roll(u),a.orthogonalizeViewUp())},t.handleMousePan=(r,s)=>{if(!e.previousPosition)return;const n=r.getActiveCamera();let a=n.getFocalPoint();a=t.computeWorldToDisplay(r,a[0],a[1],a[2]);const o=a[2],i=t.computeDisplayToWorld(r,s.x,s.y,o),u=t.computeDisplayToWorld(r,e.previousPosition.x,e.previousPosition.y,o),p=[];p[0]=u[0]-i[0],p[1]=u[1]-i[1],p[2]=u[2]-i[2],a=n.getFocalPoint();const c=n.getPosition();n.setFocalPoint(p[0]+a[0],p[1]+a[1],p[2]+a[2]),n.setPosition(p[0]+c[0],p[1]+c[1],p[2]+c[2]),e._interactor.getLightFollowCamera()&&r.updateLightsGeometryToFollowCamera()},t.handleMouseDolly=(r,s)=>{if(!e.previousPosition)return;const n=s.y-e.previousPosition.y,a=e._interactor.getView().getViewportCenter(r),o=e.motionFactor*n/a[1];t.dollyByFactor(r,1.1**o)},t.handleMouseWheel=r=>{const s=1-r.spinY/e.zoomFactor;t.dollyByFactor(e.getRenderer(r),s)},t.dollyByFactor=(r,s)=>{if(Number.isNaN(s))return;const n=r.getActiveCamera();n.getParallelProjection()?n.setParallelScale(n.getParallelScale()/s):(n.dolly(s),e.autoAdjustCameraClippingRange&&r.resetCameraClippingRange()),e._interactor.getLightFollowCamera()&&r.updateLightsGeometryToFollowCamera()}}var on={motionFactor:10,zoomFactor:10,wheelDolly:!1};function Qe(t,e,r={}){Object.assign(e,on,r),xe.extend(t,e,r),v.setGet(t,e,["motionFactor","zoomFactor"]),sn(t,e)}var cn=v.newInstance(Qe,"vtkInteractorStyleTrackballCamera"),un={newInstance:cn,extend:Qe},{vtkErrorMacro:ln}=ft,fe=["setBindGroup","setIndexBuffer","setVertexBuffer","draw","drawIndexed"];function pn(t,e){e.classHierarchy.push("vtkWebGPURenderEncoder"),t.begin=r=>{e.drawCallbacks=[],e.handle=r.beginRenderPass(e.description),e.label&&e.handle.pushDebugGroup(e.label)},t.end=()=>{for(let r=0;r<e.drawCallbacks.length;r++){const s=e.drawCallbacks[r],n=s.pipeline;t.setPipeline(n);for(let a=0;a<s.callbacks.length;a++)s.callbacks[a](t)}e.label&&e.handle.popDebugGroup(),e.handle.end(),e.boundPipeline=null},t.setPipeline=r=>{if(e.boundPipeline===r)return;e.handle.setPipeline(r.getHandle());const s=r.getPipelineDescription(),n=s.fragment?.targets;if(e.colorTextureViews.length!==n.length)console.log(`mismatched attachment counts on pipeline ${n.length} while encoder has ${e.colorTextureViews.length}`),console.trace();else for(let a=0;a<e.colorTextureViews.length;a++){const o=e.colorTextureViews[a].getTexture()?.getFormat();o&&o!==n[a].format&&(console.log(`mismatched attachments for attachment ${a} on pipeline ${n[a].format} while encoder has ${o}`),console.trace())}if(!!e.depthTextureView!="depthStencil"in s)console.log("mismatched depth attachments"),console.trace();else if(e.depthTextureView){const a=e.depthTextureView.getTexture()?.getFormat();a&&a!==s.depthStencil.format&&(console.log(`mismatched depth attachments on pipeline ${s.depthStencil.format} while encoder has ${a}`),console.trace())}e.boundPipeline=r},t.replaceShaderCode=r=>{e.replaceShaderCodeFunction(r)},t.setColorTextureView=(r,s)=>{e.colorTextureViews[r]!==s&&(e.colorTextureViews[r]=s)},t.activateBindGroup=r=>{const s=e.boundPipeline.getDevice(),n=e.boundPipeline.getBindGroupLayoutIndex(r.getLabel());if(n<0){ln(`vtkWebGPURenderEncoder: could not find bind group layout ${r.getLabel()}`);return}e.handle.setBindGroup(n,r.getBindGroup(s));const a=s.getBindGroupLayoutDescription(r.getBindGroupLayout(s)),o=s.getBindGroupLayoutDescription(e.boundPipeline.getBindGroupLayout(n));a!==o&&(console.log(`renderEncoder ${e.pipelineHash} mismatched bind group layouts bind group has
4
4
  ${a}
package/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"git":"270052c5","built":"2026-10-22 16:50"}
1
+ {"git":"95f22a2d","built":"2026-10-22 20:13"}
package/dist/index.html CHANGED
@@ -19,7 +19,7 @@
19
19
  href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap"
20
20
  rel="stylesheet"
21
21
  />
22
- <script type="module" crossorigin src="./assets/index-9IJ0xse9.js"></script>
22
+ <script type="module" crossorigin src="./assets/index--MRRVo__.js"></script>
23
23
  <link rel="stylesheet" crossorigin href="./assets/index-D5OEevqH.css">
24
24
  </head>
25
25
  <body>