PageSourceSearch

https://sometimesdataoftendogs.com/posts/2025-09-pet-insurance-expense-sharing/index.html

html sometimesdataoftendogs.com collected 2026-10-09 22:08:45 UTC 110,998 bytes, 1,079 lines download raw bytes

1<!DOCTYPE html>
2<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
3
4<meta charset="utf-8">
5<meta name="generator" content="quarto-1.7.33">
6
7<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
8
9<meta name="dcterms.date" content="2025-09-10">
10
11<title>Pet Insurance Expense Sharing Visualizer – Home</title>
12<style>
13code{white-space: pre-wrap;}
14span.smallcaps{font-variant: small-caps;}
15div.columns{display: flex; gap: min(4vw, 1.5em);}
16div.column{flex: auto; overflow-x: auto;}
17div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
18ul.task-list{list-style: none;}
19ul.task-list li input[type="checkbox"] {
20  width: 0.8em;
21  margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ 
22  vertical-align: middle;
23}
24/* CSS for syntax highlighting */
25html { -webkit-text-size-adjust: 100%; }
26pre > code.sourceCode { white-space: pre; position: relative; }
27pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
28pre > code.sourceCode > span:empty { height: 1.2em; }
29.sourceCode { overflow: visible; }
30code.sourceCode > span { color: inherit; text-decoration: inherit; }
31div.sourceCode { margin: 1em 0; }
32pre.sourceCode { margin: 0; }
33@media screen {
34div.sourceCode { overflow: auto; }
35}
36@media print {
37pre > code.sourceCode { white-space: pre-wrap; }
38pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
39}
40pre.numberSource code
41  { counter-reset: source-line 0; }
42pre.numberSource code > span
43  { position: relative; left: -4em; counter-increment: source-line; }
44pre.numberSource code > span > a:first-child::before
45  { content: counter(source-line);
46    position: relative; left: -1em; text-align: right; vertical-align: baseline;
47    border: none; display: inline-block;
48    -webkit-touch-callout: none; -webkit-user-select: none;
49    -khtml-user-select: none; -moz-user-select: none;
50    -ms-user-select: none; user-select: none;
51    padding: 0 4px; width: 4em;
52  }
53pre.numberSource { margin-left: 3em;  padding-left: 4px; }
54div.sourceCode
55  {   }
56@media screen {
57pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
58}
59</style>
60
61
62<script src="../../site_libs/quarto-nav/quarto-nav.js"></script>
vendor: 1 bytes, line 62
62
63<script src="../../site_libs/quarto-nav/headroom.min.js"></script>
vendor: 1 bytes, line 63
63
64<script src="../../site_libs/clipboard/clipboard.min.js"></script>
vendor: 1 bytes, line 64
64
65<script src="../../site_libs/quarto-search/autocomplete.umd.js"></script>
vendor: 1 bytes, line 65
65
66<script src="../../site_libs/quarto-search/fuse.min.js"></script>
vendor: 1 bytes, line 66
66
67<script src="../../site_libs/quarto-search/quarto-search.js"></script>
67
68<meta name="quarto:offset" content="../../">
69<script src="../../site_libs/quarto-html/quarto.js" type="module"></script>
vendor: 1 bytes, line 69
69
70<script src="../../site_libs/quarto-html/tabsets/tabsets.js" type="module"></script>
vendor: 1 bytes, line 70
70
71<script src="../../site_libs/quarto-html/popper.min.js"></script>
vendor: 1 bytes, line 71
71
72<script src="../../site_libs/quarto-html/tippy.umd.min.js"></script>
vendor: 1 bytes, line 72
72
73<script src="../../site_libs/quarto-html/anchor.min.js"></script>
73
74<link href="../../site_libs/quarto-html/tippy.css" rel="stylesheet">
75<link href="../../site_libs/quarto-html/quarto-syntax-highlighting-ea385d0e468b0dd5ea5bf0780b1290d9.css" rel="stylesheet" id="quarto-text-highlighting-styles">
76<script src="../../site_libs/bootstrap/bootstrap.min.js"></script>
76
77<link href="../../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
78<link href="../../site_libs/bootstrap/bootstrap-2ddaa217da8dd6342224e1652ad10ccf.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
79<script id="quarto-search-options" type="application/json">{
80  "location": "navbar",
81  "copy-button": false,
82  "collapse-after": 3,
83  "panel-placement": "end",
84  "type": "overlay",
85  "limit": 50,
86  "keyboard-shortcut": [
87    "f",
88    "/",
89    "s"
90  ],
91  "show-item-context": false,
92  "language": {
93    "search-no-results-text": "No results",
94    "search-matching-documents-text": "matching documents",
95    "search-copy-link-title": "Copy link to search",
96    "search-hide-matches-text": "Hide additional matches",
97    "search-more-match-text": "more match in this document",
98    "search-more-matches-text": "more matches in this document",
99    "search-clear-button-title": "Clear",
100    "search-text-placeholder": "",
101    "search-detached-cancel-button-title": "Cancel",
102    "search-submit-button-title": "Submit",
103    "search-label": "Search"
104  }
105}</script>
105
106<style>
107
108      .quarto-title-block .quarto-title-banner h1,
109      .quarto-title-block .quarto-title-banner h2,
110      .quarto-title-block .quarto-title-banner h3,
111      .quarto-title-block .quarto-title-banner h4,
112      .quarto-title-block .quarto-title-banner h5,
113      .quarto-title-block .quarto-title-banner h6
114      {
115        color: #212429ff;
116      }
117
118      .quarto-title-block .quarto-title-banner {
119        color: #212429ff;
120background: #f8f9faff;
121      }
122</style>
123<script type="module" src="../../site_libs/quarto-ojs/quarto-ojs-runtime.js"></script>
123
124<link href="../../site_libs/quarto-ojs/quarto-ojs.css" rel="stylesheet">
125<meta name="robots" content="noimageindex">
126<link rel="canonical" href="https://sometimesdataoftendogs.com/posts/2025-09-pet-insurance-expense-sharing/">
127
128
129<link rel="stylesheet" href="../../styles.css">
130</head>
131
132<body class="nav-fixed quarto-light">
133
134<div id="quarto-search-results"></div>
135  <header id="quarto-header" class="headroom fixed-top quarto-banner">
136    <nav class="navbar navbar-expand-lg " data-bs-theme="dark">
137      <div class="navbar-container container-fluid">
138      <div class="navbar-brand-container mx-auto">
139    <a class="navbar-brand" href="../../index.html">
140    <span class="navbar-title">Home</span>
141    </a>
142  </div>
143            <div id="quarto-search" class="" title="Search"></div>
144          <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" role="menu" aria-expanded="false" aria-label="Toggle navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
145  <span class="navbar-toggler-icon"></span>
146</button>
147          <div class="collapse navbar-collapse" id="navbarCollapse">
148            <ul class="navbar-nav navbar-nav-scroll ms-auto">
149  <li class="nav-item">
150    <a class="nav-link" href="../../about.html"> 
151<span class="menu-text">About</span></a>
152  </li>  
153  <li class="nav-item">
154    <a class="nav-link" href="../../index.html"> 
155<span class="menu-text">Blog</span></a>
156  </li>  
157  <li class="nav-item compact">
158    <a class="nav-link" href="../../index.xml"> <i class="bi bi-rss" role="img">
159</i> 
160<span class="menu-text"></span></a>
161  </li>  
162</ul>
163          </div> <!-- /navcollapse -->
164            <div class="quarto-navbar-tools">
165</div>
166      </div> <!-- /container-fluid -->
167    </nav>
168</header>
169<!-- content -->
170<header id="title-block-header" class="quarto-title-block default page-columns page-full">
171  <div class="quarto-title-banner page-columns page-full">
172    <div class="quarto-title column-body">
173      <h1 class="title">Pet Insurance Expense Sharing Visualizer</h1>
174            <p class="subtitle lead">Explore how policy choices affect what you pay (and what the insurer earns vs.&nbsp;pays)</p>
175                                <div class="quarto-categories">
176                <div class="quarto-category">pet insurance</div>
177                <div class="quarto-category">data visualization</div>
178              </div>
179                  </div>
180  </div>
181    
182  
183  <div class="quarto-title-meta">
184
185      
186      <div>
187      <div class="quarto-title-meta-heading">Published</div>
188      <div class="quarto-title-meta-contents">
189        <p class="date">September 10, 2025</p>
190      </div>
191    </div>
192    
193      <div>
194      <div class="quarto-title-meta-heading">Modified</div>
195      <div class="quarto-title-meta-contents">
196        <p class="date-modified">September 14, 2025</p>
197      </div>
198    </div>
199      
200    </div>
201    
202  
203  </header><div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar">
204<!-- sidebar -->
205<!-- margin-sidebar -->
206    <div id="quarto-margin-sidebar" class="sidebar margin-sidebar zindex-bottom">
207    </div>
208<!-- main -->
209<main class="content quarto-banner-title-block page-columns page-full" id="quarto-document-content">
210
211
212
213
214
215<p>How does pet insurance actually play out when the vet bills show up? This interactive tool helps you see the full picture - how much of the vet bill you pay, how much the insurer pays, and the cost to you for the insurance protection.</p>
216<p>Adjust the values related to the policy parameters, set the estimated annual vet expense and covered vet expense and see in real time how your policy choices affect these numbers, so you can better understand the value-add of the pet insurance policy and make more informed decisions about your coverage options.</p>
217<div class="callout callout-style-simple callout-note callout-titled">
218<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-1-contents" aria-controls="callout-1" aria-expanded="false" aria-label="Toggle callout">
219<div class="callout-icon-container">
220<i class="callout-icon"></i>
221</div>
222<div class="callout-title-container flex-fill">
223Definitions
224</div>
225<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
226</div>
227<div id="callout-1" class="callout-1-contents callout-collapse collapse">
228<div class="callout-body-container callout-body">
229<section id="monthly-premium" class="level5">
230<h5 class="anchored" data-anchor-id="monthly-premium">Monthly Premium $</h5>
231<p>The payment you make to the insurer every month in order to keep your policy active.</p>
232</section>
233<section id="maximum-benefit" class="level5">
234<h5 class="anchored" data-anchor-id="maximum-benefit">Maximum Benefit $</h5>
235<p>This is the maximum amount the insurer will reimburse. This cap may apply in different ways - a lifetime maximum (total paid over the pet’s life), an annual maximum (total paid in one year), or a per-condition maximum (total paid for a specific condition).</p>
236</section>
237<section id="reimbursement-level" class="level5">
238<h5 class="anchored" data-anchor-id="reimbursement-level">
238Reimbursement Level %</h5>
239<p>The insurer’s share of the covered vet medical expenses expressed as a percentage. The complementary percentage (100 - Reimbursement Level) is referred to as the co-insurance percentage.</p>
240</section>
241<section id="annual-deductible" class="level5">
242<h5 class="anchored" data-anchor-id="annual-deductible">Annual Deductible $</h5>
243<p>This is the amount you must first pay before the insurer will begin paying their reimbursement. This amount resets every year.</p>
244</section>
245<section id="deductible-withdrawn-before-or-after-calculating-co-insurance" class="level5">
246<h5 class="anchored" data-anchor-id="deductible-withdrawn-before-or-after-calculating-co-insurance">Deductible withdrawn before or after calculating co-insurance</h5>
247<p>Some insurers apply the deductible to the covered amount i.e.&nbsp;<em>before</em> calculating the co-insurance amount. Others apply the deductible <em>after</em> calculating the co-insurance amount. The latter is more common among pet insurers (hence the default for this tool), though there are more than a couple insurers that calculate it according to the former method.</p>
248</section>
249<section id="annual-total-vet-medical-expense" class="level5">
250<h5 class="anchored" data-anchor-id="annual-total-vet-medical-expense">Annual Total Vet Medical Expense $</h5>
251<p>Total vet medical expenses for a year. This can be an estimate for next year, or based on data collected from the previous year, or based on a specific kind of emergency the cost of which you have an estimate for that you are trying this visualization for.</p>
252</section>
253<section id="annual-total-vet-medical-expense-not-covered-by-insurance" class="level5">
254<h5 class="anchored" data-anchor-id="annual-total-vet-medical-expense-not-covered-by-insurance">Annual Total Vet Medical Expense Not Covered By Insurance $</h5>
255<p>The portion, in dollars, of the total annual vet medical expenses that is <em>not</em> covered by the insurer. Preventative care expenses, elective procedures, vet exam fees, cost of shipping of diagnostic tests to labs, pre-existing conditions, etc. are some examples of expenses that might be excluded, i.e.&nbsp;not covered, by some insurers.</p>
256</section>
257</div>
258</div>
259</div>
260
261<div class="no-row-height column-margin column-container"><div class="" style="font: Garamond">
262<section id="parameters" class="level4">
263<h4 class="anchored" data-anchor-id="parameters">Parameters</h4>
264<div class="cell">
265<div class="sourceCode cell-code hidden" id="cb1" data-startfrom="75" data-source-offset="0"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 74;"><span id="cb1-75"><a href="#cb1-75" aria-hidden="true" tabindex="-1"></a>viewof policy_parameters <span class="op">=</span> Inputs<span class="op">.</span><span class="fu">form</span>({</span>
266<span id="cb1-76"><a href="#cb1-76" aria-hidden="true" tabindex="-1"></a>  <span class="dt">premium_monthly</span><span class="op">:</span> Inputs<span class="op">.</span><span class="fu">range</span>([<span class="dv">0</span><span class="op">,</span> <span class="dv">5000</span>]<span class="op">,</span> {<span class="dt">label</span><span class="op">:</span> <span class="st">"Monthly Premium $"</span><span class="op">,</span> <span class="dt">step</span><span class="op">:</span> <span class="fl">0.01</span><span class="op">,</span> <span class="dt">value</span><span class="op">:</span> <span class="dv">100</span>})<span class="op">,</span></span>
267<span id="cb1-77"><a href="#cb1-77" aria-hidden="true" tabindex="-1"></a>  <span class="dt">limit</span><span class="op">:</span> Inputs<span class="op">.</span><span class="fu">select</span>([<span class="st">"Unlimited"</span><span class="op">,</span> <span class="dv">20000</span><span class="op">,</span> <span class="dv">10000</span><span class="op">,</span> <span class="dv">7500</span><span class="op">,</span> <span class="dv">5000</span><span class="op">,</span> <span class="dv">3500</span><span class="op">,</span> <span class="dv">2000</span>]<span class="op">,</span> {<span class="dt">label</span><span class="op">:</span> <span class="st">"Maximum Benefit $"</span><span class="op">,</span> <span class="dt">value</span><span class="op">:</span> <span class="st">"Unlimited"</span>})<span class="op">,</span></span>
268<span id="cb1-78"><a href="#cb1-78" aria-hidden="true" tabindex="-1"></a>  <span class="dt">reimbursement</span><span class="op">:</span> Inputs<span class="op">.</span><span class="fu">range</span>([<span class="dv">0</span><span class="op">,</span> <span class="dv">100</span>]<span class="op">,</span> {<span class="dt">label</span><span class="op">:</span> <span class="st">
268"Reimbursement Level %"</span><span class="op">,</span> <span class="dt">step</span><span class="op">:</span> <span class="dv">10</span><span class="op">,</span> <span class="dt">value</span><span class="op">:</span> <span class="dv">90</span>})<span class="op">,</span></span>
269<span id="cb1-79"><a href="#cb1-79" aria-hidden="true" tabindex="-1"></a>  <span class="dt">deductible</span><span class="op">:</span> Inputs<span class="op">.</span><span class="fu">radio</span>([<span class="dv">100</span><span class="op">,</span> <span class="dv">200</span><span class="op">,</span> <span class="dv">250</span><span class="op">,</span> <span class="dv">500</span><span class="op">,</span> <span class="dv">700</span><span class="op">,</span> <span class="dv">750</span><span class="op">,</span> <span class="dv">1000</span><span class="op">,</span> <span class="dv">1500</span><span class="op">,</span> <span class="dv">2000</span><span class="op">,</span> <span class="dv">3000</span><span class="op">,</span> <span class="dv">4000</span><span class="op">,</span> <span class="dv">5000</span>]<span class="op">,</span> {<span class="dt">label</span><span class="op">:</span> <span class="st">"Annual Deductible $"</span><span class="op">,</span> <span class="dt">value</span><span class="op">:</span> <span class="dv">250</span>})<span class="op">,</span></span>
270<span id="cb1-80"><a href="#cb1-80" aria-hidden="true" tabindex="-1"></a>  <span class="dt">deductible_stage</span><span class="op">:</span> Inputs<span class="op">.</span><span class="fu">radio</span>([<span class="st">"before"</span><span class="op">,</span> <span class="st">"after"</span>]<span class="op">,</span> {<span class="dt">label</span><span class="op">:</span> <span class="st">"Deductible withdrawn before or after calculating co-insurance"</span><span class="op">,</span> <span class="dt">value</span><span class="op">:</span> <span class="st">"after"</span>})<span class="op">,</span></span>
271<span id="cb1-81"><a href="#cb1-81" aria-hidden="true" tabindex="-1"></a>  <span class="dt">invoice</span><span class="op">:</span> Inputs<span class="op">.</span><span class="fu">range</span>([<span class="dv">0</span><span class="op">,</span> <span class="dv">60000</span>]<span class="op">,</span> {<span class="dt">label</span><span class="op">:</span> <span class="st">"Annual Total Vet Medical Expense $"</span><span class="op">,</span> <span class="dt">step</span><span class="op">:</span> <span class="fl">0.01</span><span class="op">,</span> <span class="dt">value</span><span class="op">:</span> <span class="dv">10000</span>})<span class="op">,</span></span>
272<span id="cb1-82"><a href="#cb1-82" aria-hidden="true" tabindex="-1"></a>  <span class="dt">invoice_not_covered</span><span class="op">:</span> Inputs<span class="op">.</span><span class="fu">range</span>([<span class="dv">0</span><span class="op">,</span> <span class="dv">60000</span>]<span class="op">,</span> {<span class="dt">label</span><span class="op">:</span> <span class="st">"Annual Total Vet Medical Expense Not Covered By Insurance $"</span><span class="op">,</span> <span class="dt">step</span><span class="op">:</span> <span class="fl">0.01</span><span class="op">,</span> <span class="dt">value</span><span class="op">:</span> <span class="dv">1500</span>})<span class="op">,</span></span>
273<span id="cb1-83"><a href="#cb1-83" aria-hidden="true" tabindex="-1"></a>  <span class="dt">notes</span><span class="op">:</span> Inputs<span class="op">.</span><span class="fu">text</span>({<span class="dt">label</span><span class="op">:</span> <span class="st">"Your Note"</span><span class="op">,</span> <span class="dt">value</span><span class="op">:</span> <span class="st">""</span><span class="op">,</span> <span class="dt">placeholder</span><span class="op">:</span> <span class="st">""</span>})<span class="op">,</span></span>
274<span id="cb1-84"><a href="#cb1-84" aria-hidden="true" tabindex="-1"></a>  <span class="co">//option7: Inputs.checkbox(["Before", "After"], {label: "Select boxes", value: "After"})//</span></span>
275<span id="cb1-85"><a href="#cb1-85" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
276<div class="cell-output cell-output-display">
277<div id="ojs-cell-1" data-nodetype="declaration">
278
279</div>
280</div>
281</div>
282<!--https://observablehq.com/@saneef/is-observable-inputs-style-able-->
283<div class="cell">
284<div class="sourceCode cell-code hidden" id="cb2" data-startfrom="92" data-source-offset="-0"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 91;"><span id="cb2-92"><a href="#cb2-92" aria-hidden="true" tabindex="-1"></a>ns <span class="op">=</span> Inputs<span class="op">.</span><span class="fu">range</span>()<span class="op">.</span><span class="at">classList</span>[<span class="dv">0</span>]</span>
285<span id="cb2-93"><a href="#cb2-93" aria-hidden="true" tabindex="-1"></a></span>
286<span id="cb2-94"><a href="#cb2-94" aria-hidden="true" tabindex="-1"></a><span class="fu">html</span> <span class="vs">`&lt;style&gt;</span></span>
287<span id="cb2-95"><a href="#cb2-95" aria-hidden="true" tabindex="-1"></a><span class="vs">.</span><span class="sc">${</span>ns<span class="sc">}</span><span class="vs"> div label {</span></span>
288<span id="cb2-96"><a href="#cb2-96" aria-hidden="true" tabindex="-1"></a><span class="vs">  background-color: #f4f4f4;</span></span>
289<span id="cb2-97"><a href="#cb2-97" aria-hidden="true" tabindex="-1"></a><span class="vs">}</span></span>
290<span id="cb2-98"><a href="#cb2-98" aria-hidden="true" tabindex="-1"></a><span class="vs">.</span><span class="sc">${</span>ns<span class="sc">}</span><span class="vs"> div label:hover,</span></span>
291<span id="cb2-99"><a href="#cb2-99" aria-hidden="true" tabindex="-1"></a><span class="vs">.</span><span class="sc">${</span>ns<span class="sc">}</span><span class="vs"> div label:active,</span></span>
292<span id="cb2-100"><a href="#cb2-100" aria-hidden="true" tabindex="-1"></a><span class="vs">.</span><span class="sc">${</span>ns<span class="sc">}</span><span class="vs"> div label:focus {</span></span>
293<span id="cb2-101"><a href="#cb2-101" aria-hidden="true" tabindex="-1"></a><span class="vs">  background-color: #fefefe;</span></span>
294<span id="cb2-102"><a href="#cb2-102" aria-hidden="true" tabindex="-1"></a><span class="vs">}</span></span>
295<span id="cb2-103"><a href="#cb2-103" aria-hidden="true" tabindex="-1"></a><span class="vs">.</span><span class="sc">${</span>ns<span class="sc">}</span><span class="vs"> div input {</span></span>
296<span id="cb2-104"><a href="#cb2-104" aria-hidden="true" tabindex="-1"></a><span class="vs">  accent-color: #888</span></span>
297<span id="cb2-105"><a href="#cb2-105" aria-hidden="true" tabindex="-1"></a><span class="vs">}</span></span>
298<span id="cb2-106"><a href="#cb2-106" aria-hidden="true" tabindex="-1"></a><span class="vs">&lt;/style&gt;`</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
299<div class="cell-output cell-output-display">
300<div>
301<div id="ojs-cell-2-1" data-nodetype="declaration">
302
303</div>
304</div>
305</div>
306<div class="cell-output cell-output-display">
307<div>
308<div id="ojs-cell-2-2" data-nodetype="expression">
309
310</div>
311</div>
312</div>
313</div>
314</section>
315<section id="expense-sharing-tabulated" class="level4">
316<h4 class="anchored" data-anchor-id="expense-sharing-tabulated">Expense Sharing Tabulated</h4>
317<table class="caption-top table">
318<colgroup>
319<col style="width: 5%">
320<col style="width: 5%">
321<col style="width: 65%">
322<col style="width: 25%">
323</colgroup>
324<thead>
325<tr class="header">
326<th>from</th>
327<th>to</th>
328<th>category</th>
329<th style="text-align: right;">amount ($)</th>
330</tr>
331</thead>
332<tbody>
333<tr class="odd">
334<td>you</td>
335<td>insurer</td>
336<td><span style="color: #4e79a7;"><strong>premium</strong></span></td>
337<td style="text-align: right;"><span><span id="ojs-element-id-1"></span></span></td>
338</tr>
339<tr class="even">
340<td>you</td>
341<td>vet</td>
342<td><span style="color: #4e79a7;"><strong>deductible</strong></span></td>
343<td style="text-align: right;"><span><span id="ojs-element-id-2"></span></span></td>
344</tr>
345<tr class="odd">
346<td>you</td>
347<td>vet</td>
348<td><span style="color: #4e79a7;"><strong>co-insurance</strong></span></td>
349<td style="text-align: right;"><span><span id="ojs-element-id-3"></span></span></td>
350</tr>
351<tr class="even">
352<td>you</td>
353<td>vet</td>
354<td><span style="color: #4e79a7;"><strong>not-covered</strong></span></td>
355<td style="text-align: right;"><span><span id="ojs-element-id-4"></span></span></td>
356</tr>
357<tr class="odd">
358<td>you</td>
359<td>vet</td>
360<td><span style="color: #4e79a7;"><strong>max-benefit-spillover</strong></span></td>
361<td style="text-align: right;"><span><span id="ojs-element-id-5"></span></span></td>
362</tr>
363<tr class="even">
364<td>insurer</td>
365<td>vet</td>
366<td><span style="color: #f28e2c;"><strong>reimbursement</strong></span></td>
367<td style="text-align: right;"><span><span id="ojs-element-id-6"></span></span></td>
368</tr>
369</tbody>
370</table>
371</section>
372</div></div><div class="cell">
373<div class="sourceCode cell-code hidden" id="cb3" data-startfrom="123" data-source-offset="0"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 122;"><span id="cb3-123"><a href="#cb3-123" aria-hidden="true" tabindex="-1"></a>data <span class="op">=</span> {</span>
374<span id="cb3-124"><a href="#cb3-124" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> links <span class="op">=</span> <span class="cf">await</span> <span class="fu">FileAttachment</span>(<span class="st">"data/links.csv"</span>)<span class="op">.</span><span class="fu">csv</span>({<span class="dt">typed</span><span class="op">:</span> <span class="kw">true</span>})<span class="op">;</span></span>
375<span id="cb3-125"><a href="#cb3-125" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> nodes <span class="op">=</span> <span class="cf">await</span> <span class="fu">FileAttachment</span>(<span class="st">"data/nodes.csv"</span>)<span class="op">.</span><span class="fu">csv</span>({<span class="dt">typed</span><span class="op">:</span> <span class="kw">true</span>})<span class="op">;</span></span>
376<span id="cb3-126"><a href="#cb3-126" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> {nodes<span class="op">,</span> links}<span class="op">;</span></span>
377<span id="cb3-127"><a href="#cb3-127" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
378<div class="cell-output cell-output-display">
379<div id="ojs-cell-3" data-nodetype="declaration">
380
381</div>
382</div>
383</div>
384<div class="cell">
385<div class="sourceCode cell-code hidden" id="cb4" data-startfrom="131" data-source-offset="0"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 130;"><span id="cb4-131"><a href="#cb4-131" aria-hidden="true" tabindex="-1"></a>calculated_policy_parameters <span class="op">=</span> ((in_premium_monthly<span class="op">,</span> in_reimbursement<span class="op">,</span> in_deductible<span class="op">,</span> in_limit<span class="op">,</span> in_invoice<span class="op">,</span> in_invoice_not_covered<span class="op">,</span> in_deductible_stage) <span class="kw">=&gt;</span> {</span>
386<span id="cb4-132"><a href="#cb4-132" aria-hidden="true" tabindex="-1"></a>    <span class="kw">let</span> calculated_parameters <span class="op">=</span> {}<span class="op">;</span></span>
387<span id="cb4-133"><a href="#cb4-133" aria-hidden="true" tabindex="-1"></a>    <span class="kw">let</span> no_insurer <span class="op">=</span> (in_premium_monthly <span class="op">&lt;</span> <span class="dv">1</span>)<span class="op">;</span></span>
388<span id="cb4-134"><a href="#cb4-134" aria-hidden="true" tabindex="-1"></a>    <span class="kw">let</span> no_expense <span class="op">=</span> (in_invoice <span class="op">&lt;</span> <span class="dv">1</span>)<span class="op">;</span></span>
389<span id="cb4-135"><a href="#cb4-135" aria-hidden="true" tabindex="-1"></a></span>
390<span id="cb4-136"><a href="#cb4-136" aria-hidden="true" tabindex="-1"></a>    calculated_parameters<span class="op">.</span><span class="at">annual_premium</span> <span class="op">=</span> (() <span class="kw">=&gt;</span> {</span>
391<span id="cb4-137"><a href="#cb4-137" aria-hidden="true" tabindex="-1"></a>
391        <span class="cf">return</span> no_insurer <span class="op">?</span> <span class="dv">0</span> <span class="op">:</span> <span class="bu">Number</span>((<span class="dv">12</span> <span class="op">*</span> in_premium_monthly)<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))<span class="op">;</span></span>
392<span id="cb4-138"><a href="#cb4-138" aria-hidden="true" tabindex="-1"></a>    })()</span>
393<span id="cb4-139"><a href="#cb4-139" aria-hidden="true" tabindex="-1"></a></span>
394<span id="cb4-140"><a href="#cb4-140" aria-hidden="true" tabindex="-1"></a>    calculated_parameters<span class="op">.</span><span class="at">limit</span> <span class="op">=</span> (() <span class="kw">=&gt;</span> {</span>
395<span id="cb4-141"><a href="#cb4-141" aria-hidden="true" tabindex="-1"></a>        <span class="cf">return</span> (in_limit <span class="op">===</span> <span class="st">"Unlimited"</span>) <span class="op">?</span> <span class="bu">Number</span><span class="op">.</span><span class="cn">MAX_VALUE</span> <span class="op">:</span> in_limit<span class="op">;</span></span>
396<span id="cb4-142"><a href="#cb4-142" aria-hidden="true" tabindex="-1"></a>    })()</span>
397<span id="cb4-143"><a href="#cb4-143" aria-hidden="true" tabindex="-1"></a></span>
398<span id="cb4-144"><a href="#cb4-144" aria-hidden="true" tabindex="-1"></a>    calculated_parameters<span class="op">.</span><span class="at">not_covered</span> <span class="op">=</span> (() <span class="kw">=&gt;</span> {</span>
399<span id="cb4-145"><a href="#cb4-145" aria-hidden="true" tabindex="-1"></a>        <span class="cf">if</span> (no_insurer) {</span>
400<span id="cb4-146"><a href="#cb4-146" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> in_invoice<span class="op">;</span></span>
401<span id="cb4-147"><a href="#cb4-147" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (no_expense) {</span>
402<span id="cb4-148"><a href="#cb4-148" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
403<span id="cb4-149"><a href="#cb4-149" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (in_invoice_not_covered <span class="op">&gt;</span> in_invoice) {</span>
404<span id="cb4-150"><a href="#cb4-150" aria-hidden="true" tabindex="-1"></a>            <span class="co">// not covered expenses cannot be greater than total expenses</span></span>
405<span id="cb4-151"><a href="#cb4-151" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> in_invoice<span class="op">;</span></span>
406<span id="cb4-152"><a href="#cb4-152" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> {</span>
407<span id="cb4-153"><a href="#cb4-153" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> in_invoice_not_covered<span class="op">;</span></span>
408<span id="cb4-154"><a href="#cb4-154" aria-hidden="true" tabindex="-1"></a>        }</span>
409<span id="cb4-155"><a href="#cb4-155" aria-hidden="true" tabindex="-1"></a>    })()</span>
410<span id="cb4-156"><a href="#cb4-156" aria-hidden="true" tabindex="-1"></a></span>
411<span id="cb4-157"><a href="#cb4-157" aria-hidden="true" tabindex="-1"></a>    calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">=</span> <span class="bu">Number</span>((</span>
412<span id="cb4-158"><a href="#cb4-158" aria-hidden="true" tabindex="-1"></a>        in_invoice <span class="op">-</span> calculated_parameters<span class="op">.</span><span class="at">not_covered</span></span>
413<span id="cb4-159"><a href="#cb4-159" aria-hidden="true" tabindex="-1"></a>            )<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))<span class="op">;</span></span>
414<span id="cb4-160"><a href="#cb4-160" aria-hidden="true" tabindex="-1"></a></span>
415<span id="cb4-161"><a href="#cb4-161" aria-hidden="true" tabindex="-1"></a>    calculated_parameters<span class="op">.</span><span class="at">deductible</span> <span class="op">=</span> (() <span class="kw">=&gt;</span> {</span>
416<span id="cb4-162"><a href="#cb4-162" aria-hidden="true" tabindex="-1"></a>
416        <span class="cf">if</span> (no_insurer) {</span>
417<span id="cb4-163"><a href="#cb4-163" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
418<span id="cb4-164"><a href="#cb4-164" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (no_expense) {</span>
419<span id="cb4-165"><a href="#cb4-165" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
420<span id="cb4-166"><a href="#cb4-166" aria-hidden="true" tabindex="-1"></a>        }</span>
421<span id="cb4-167"><a href="#cb4-167" aria-hidden="true" tabindex="-1"></a>        <span class="cf">if</span> (in_deductible_stage <span class="op">===</span> <span class="st">"after"</span>) {</span>
422<span id="cb4-168"><a href="#cb4-168" aria-hidden="true" tabindex="-1"></a>            <span class="cf">if</span> (calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">*</span> in_reimbursement<span class="op">/</span><span class="dv">100</span> <span class="op">&lt;</span> in_deductible) {</span>
423<span id="cb4-169"><a href="#cb4-169" aria-hidden="true" tabindex="-1"></a>                <span class="co">// Vet expenses to be reimbursed are less than the deductible</span></span>
424<span id="cb4-170"><a href="#cb4-170" aria-hidden="true" tabindex="-1"></a>                <span class="cf">return</span> <span class="bu">Number</span>((calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">*</span> in_reimbursement<span class="op">/</span><span class="dv">100</span>)<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))<span class="op">;</span></span>
425<span id="cb4-171"><a href="#cb4-171" aria-hidden="true" tabindex="-1"></a>            } <span class="cf">else</span> {</span>
426<span id="cb4-172"><a href="#cb4-172" aria-hidden="true" tabindex="-1"></a>                <span class="cf">return</span> in_deductible<span class="op">;</span></span>
427<span id="cb4-173"><a href="#cb4-173" aria-hidden="true" tabindex="-1"></a>            }</span>
428<span id="cb4-174"><a href="#cb4-174" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (in_deductible_stage <span class="op">===</span> <span class="st">"before"</span>) {</span>
429<span id="cb4-175"><a href="#cb4-175" aria-hidden="true" tabindex="-1"></a>            <span class="cf">if</span> (calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">&lt;</span> in_deductible) {</span>
430<span id="cb4-176"><a href="#cb4-176" aria-hidden="true" tabindex="-1"></a>                <span class="co">// Vet expenses to be covered are less than the deductible</span></span>
431<span id="cb4-177"><a href="#cb4-177" aria-hidden="true" tabindex="-1"></a>                <span class="cf">return</span> calculated_parameters<span class="op">.</span><span class="at">covered</span><span class="op">;</span></span>
432<span id="cb4-178"><a href="#cb4-178" aria-hidden="true" tabindex="-1"></a>            } <span class="cf">else</span> {</span>
433<span id="cb4-179"><a href="#cb4-179" aria-hidden="true" tabindex="-1"></a>                <span class="cf">return</span> in_deductible<span class="op">;</span></span>
434<span id="cb4-180"><a href="#cb4-180" aria-hidden="true" tabindex="-1"></a>            }</span>
435<span id="cb4-181"><a href="#cb4-181" aria-hidden="true" tabindex="-1"></a>        }</span>
436<span id="cb4-182"><a href="#cb4-182" aria-hidden="true" tabindex="-1"></a>    })()</span>
437<span id="cb4-183"><a href="#cb4-183" aria-hidden="true" tabindex="-1"></a></span>
438<span id="cb4-184"><a href="#cb4-184" aria-hidden="true" tabindex="-1"></a>    calculated_parameters<span class="op">.</span><span class="at">co_insurance</span> <span class="op">=</span> (() <span class="kw">=&gt;</span> {</span>
439<span id="cb4-185"><a href="#cb4-185" aria-hidden="true" tabindex="-1"></a>        <span class="cf">if</span> (no_insurer) {</span>
440<span id="cb4-186"><a href="#cb4-186" aria-hidden="true" tabindex="-1"></a>
440            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
441<span id="cb4-187"><a href="#cb4-187" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (no_expense) {</span>
442<span id="cb4-188"><a href="#cb4-188" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
443<span id="cb4-189"><a href="#cb4-189" aria-hidden="true" tabindex="-1"></a>        }</span>
444<span id="cb4-190"><a href="#cb4-190" aria-hidden="true" tabindex="-1"></a>        <span class="cf">if</span> (in_deductible_stage <span class="op">===</span> <span class="st">"after"</span>) {</span>
445<span id="cb4-191"><a href="#cb4-191" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="bu">Number</span>((calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">*</span> (<span class="dv">1</span> <span class="op">-</span> in_reimbursement<span class="op">/</span><span class="dv">100</span>))<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))<span class="op">;</span></span>
446<span id="cb4-192"><a href="#cb4-192" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (in_deductible_stage <span class="op">===</span> <span class="st">"before"</span>) {</span>
447<span id="cb4-193"><a href="#cb4-193" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="bu">Number</span>((</span>
448<span id="cb4-194"><a href="#cb4-194" aria-hidden="true" tabindex="-1"></a>                (calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">-</span> calculated_parameters<span class="op">.</span><span class="at">deductible</span>) <span class="op">*</span> (<span class="dv">1</span> <span class="op">-</span> in_reimbursement<span class="op">/</span><span class="dv">100</span>)</span>
449<span id="cb4-195"><a href="#cb4-195" aria-hidden="true" tabindex="-1"></a>            )<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))<span class="op">;</span></span>
450<span id="cb4-196"><a href="#cb4-196" aria-hidden="true" tabindex="-1"></a>        }</span>
451<span id="cb4-197"><a href="#cb4-197" aria-hidden="true" tabindex="-1"></a>    })()</span>
452<span id="cb4-198"><a href="#cb4-198" aria-hidden="true" tabindex="-1"></a></span>
453<span id="cb4-199"><a href="#cb4-199" aria-hidden="true" tabindex="-1"></a>    calculated_parameters<span class="op">.</span><span class="at">reimbursement</span> <span class="op">=</span> (() <span class="kw">=&gt;</span> {</span>
454<span id="cb4-200"><a href="#cb4-200" aria-hidden="true" tabindex="-1"></a>        <span class="cf">if</span> (no_insurer) {</span>
455<span id="cb4-201"><a href="#cb4-201" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
456<span id="cb4-202"><a href="#cb4-202" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (no_expense) {</span>
457<span id="cb4-203"><a href="#cb4-203" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
458<span id="cb4-204"><a href="#cb4-204" aria-hidden="true" tabindex="-1"></a>        } </span>
459<span id="cb4-205"><a href="#cb4-205" aria-hidden="true" tabindex="-1"></a>        <span class="cf">if</span> (in_deductible_stage <span class="op">===</span> <span class="st">"after"</span>) {</span>
460<span id="cb4-206"><a href="#cb4-206" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="bu">Math</span><span class="op">.</span><span class="fu">min</span>(</span>
461<span id="cb4-207"><a href="#cb4-207" aria-hidden="true" tabindex="-1"></a>                calculated_parameters<span class="op">.</span><span class="at">limit</span><span class="op">,</span></span>
462<span id="cb4-208"><a href="#cb4-208" aria-hidden="true" tabindex="-1"></a>
462                <span class="bu">Number</span>((</span>
463<span id="cb4-209"><a href="#cb4-209" aria-hidden="true" tabindex="-1"></a>                    calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">*</span> in_reimbursement<span class="op">/</span><span class="dv">100</span> <span class="op">-</span> calculated_parameters<span class="op">.</span><span class="at">deductible</span></span>
464<span id="cb4-210"><a href="#cb4-210" aria-hidden="true" tabindex="-1"></a>                )<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))</span>
465<span id="cb4-211"><a href="#cb4-211" aria-hidden="true" tabindex="-1"></a>            )<span class="op">;</span></span>
466<span id="cb4-212"><a href="#cb4-212" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (in_deductible_stage <span class="op">===</span> <span class="st">"before"</span>) {</span>
467<span id="cb4-213"><a href="#cb4-213" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="bu">Math</span><span class="op">.</span><span class="fu">min</span>(</span>
468<span id="cb4-214"><a href="#cb4-214" aria-hidden="true" tabindex="-1"></a>                calculated_parameters<span class="op">.</span><span class="at">limit</span><span class="op">,</span></span>
469<span id="cb4-215"><a href="#cb4-215" aria-hidden="true" tabindex="-1"></a>                <span class="bu">Number</span>((</span>
470<span id="cb4-216"><a href="#cb4-216" aria-hidden="true" tabindex="-1"></a>                    (calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">-</span> calculated_parameters<span class="op">.</span><span class="at">deductible</span>) <span class="op">*</span> in_reimbursement<span class="op">/</span><span class="dv">100</span></span>
471<span id="cb4-217"><a href="#cb4-217" aria-hidden="true" tabindex="-1"></a>                )<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))</span>
472<span id="cb4-218"><a href="#cb4-218" aria-hidden="true" tabindex="-1"></a>            )<span class="op">;</span></span>
473<span id="cb4-219"><a href="#cb4-219" aria-hidden="true" tabindex="-1"></a>        }</span>
474<span id="cb4-220"><a href="#cb4-220" aria-hidden="true" tabindex="-1"></a>    })()</span>
475<span id="cb4-221"><a href="#cb4-221" aria-hidden="true" tabindex="-1"></a></span>
476<span id="cb4-222"><a href="#cb4-222" aria-hidden="true" tabindex="-1"></a>    calculated_parameters<span class="op">.</span><span class="at">limit_spillover</span> <span class="op">=</span> (() <span class="kw">=&gt;</span> {</span>
477<span id="cb4-223"><a href="#cb4-223" aria-hidden="true" tabindex="-1"></a>        <span class="cf">if</span> (no_insurer) {</span>
478<span id="cb4-224"><a href="#cb4-224" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
479<span id="cb4-225"><a href="#cb4-225" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (no_expense) {</span>
480<span id="cb4-226"><a href="#cb4-226" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
481<span id="cb4-227"><a href="#cb4-227" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (calculated_parameters<span class="op">.</span><span class="at">reimbursement</span> <span class="op">&lt;</span> calculated_parameters<span class="op">.</span><span class="at">limit</span>) {</span>
482<span id="cb4-228"><a href="#cb4-228" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
483<span id="cb4-229"><a href="#cb4-229" aria-hidden="true" tabindex="-1"></a>        }</span>
484<span id="cb4-230"><a href="#cb4-230" aria-hidden="true" tabindex="-1"></a>        <span class="cf">if</span> (in_deductible_stage <span class="op">===</span> <span class="st">"after"</span>) {</span>
485<span id="cb4-231"><a href="#cb4-231" aria-hidden="true" tabindex="-1"></a>
485            <span class="cf">return</span> <span class="bu">Number</span>((</span>
486<span id="cb4-232"><a href="#cb4-232" aria-hidden="true" tabindex="-1"></a>                calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">*</span> in_reimbursement<span class="op">/</span><span class="dv">100</span> <span class="op">-</span> calculated_parameters<span class="op">.</span><span class="at">deductible</span> <span class="op">-</span> calculated_parameters<span class="op">.</span><span class="at">limit</span></span>
487<span id="cb4-233"><a href="#cb4-233" aria-hidden="true" tabindex="-1"></a>            )<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))<span class="op">;</span></span>
488<span id="cb4-234"><a href="#cb4-234" aria-hidden="true" tabindex="-1"></a>        } <span class="cf">else</span> <span class="cf">if</span> (in_deductible_stage <span class="op">===</span> <span class="st">"before"</span>) {</span>
489<span id="cb4-235"><a href="#cb4-235" aria-hidden="true" tabindex="-1"></a>            <span class="cf">return</span> <span class="bu">Number</span>((</span>
490<span id="cb4-236"><a href="#cb4-236" aria-hidden="true" tabindex="-1"></a>                (calculated_parameters<span class="op">.</span><span class="at">covered</span> <span class="op">-</span> calculated_parameters<span class="op">.</span><span class="at">deductible</span>) <span class="op">*</span> in_reimbursement<span class="op">/</span><span class="dv">100</span> <span class="op">-</span> calculated_parameters<span class="op">.</span><span class="at">limit</span></span>
491<span id="cb4-237"><a href="#cb4-237" aria-hidden="true" tabindex="-1"></a>            )<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))<span class="op">;</span></span>
492<span id="cb4-238"><a href="#cb4-238" aria-hidden="true" tabindex="-1"></a>        }</span>
493<span id="cb4-239"><a href="#cb4-239" aria-hidden="true" tabindex="-1"></a>    })()<span class="op">;</span></span>
494<span id="cb4-240"><a href="#cb4-240" aria-hidden="true" tabindex="-1"></a></span>
495<span id="cb4-241"><a href="#cb4-241" aria-hidden="true" tabindex="-1"></a>    calculated_parameters<span class="op">.</span><span class="at">total_out_of_pocket</span> <span class="op">=</span> (() <span class="kw">=&gt;</span> {</span>
496<span id="cb4-242"><a href="#cb4-242" aria-hidden="true" tabindex="-1"></a>        <span class="cf">return</span> <span class="bu">Number</span>((calculated_parameters<span class="op">.</span><span class="at">annual_premium</span> <span class="op">+</span></span>
497<span id="cb4-243"><a href="#cb4-243" aria-hidden="true" tabindex="-1"></a>            calculated_parameters<span class="op">.</span><span class="at">deductible</span> <span class="op">+</span></span>
498<span id="cb4-244"><a href="#cb4-244" aria-hidden="true" tabindex="-1"></a>            calculated_parameters<span class="op">.</span><span class="at">co_insurance</span> <span class="op">+</span></span>
499<span id="cb4-245"><a href="#cb4-245" aria-hidden="true" tabindex="-1"></a>            calculated_parameters<span class="op">.</span><span class="at">not_covered</span> <span class="op">+</span></span>
500<span id="cb4-246"><a href="#cb4-246" aria-hidden="true" tabindex="-1"></a>            calculated_parameters<span class="op">.</span><span class="at">limit_spillover</span></span>
501<span id="cb4-247"><a href="#cb4-247" aria-hidden="true" tabindex="-1"></a>        )<span class="op">.</span><span class="fu">toFixed</span>(<span class="dv">2</span>))<span class="op">;</span></span>
502<span id="cb4-248"><a href="#cb4-248" aria-hidden="true" tabindex="-1"></a>    })()<span class="op">;</span></span>
503<span id="cb4-249"><a href="#cb4-249" aria-hidden="true" tabindex="-1"></a></span>
504<span id="cb4-250"><a href="#cb4-250" aria-hidden="true" tabindex="-1"></a>    <span class="cf">return</span> calculated_parameters<span class="op">;</span></span>
505<span id="cb4-251"><a href="#cb4-251" aria-hidden="true" tabindex="-1"></a>})(policy_parameters<span class="op">.</span><span class="at">premium_monthly</span><span class="op">,</span> policy_parameters<span class="op">.</span><span class="at">reimbursement</span><span class="op">,</span> policy_parameters<span class="op">.</span><span class="at">deductible</span><span class="op">,</span> policy_parameters<span class="op">.</span><span class="at">limit</span><span class="op">,</span> policy_parameters<span class="op">.</span><span class="at">invoice</span><span class="op">,</span> policy_parameters<span class="op">.</span><span class="at">invoice_not_covered</span><span class="op">,</span> policy_parameters<span class="op">.</span><span class="at">deductible_stage</span>)<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
506<div class="cell-output cell-output-display">
507<div id="ojs-cell-4" data-nodetype="declaration">
508
509</div>
510</div>
511</div>
512<p>For this annual <span style="color: #e15759;"><strong>vet expense</strong></span> of <span><span id="ojs-element-id-7"></span>,</span> of which the <span style="color: #f28e2c;"><strong>insurer will reimburse</strong></span> <span><span id="ojs-element-id-8"></span>,</span> <span style="color: #4e79a7;"><strong>your total out-of-pocket expense</strong></span> will be <span><span id="ojs-element-id-9"></span>.</span></p>
513<div class="tabset-margin-container"></div><div class="panel-tabset">
514<ul class="nav nav-tabs" role="tablist"><li class="nav-item" role="presentation"><a class="nav-link active" id="tabset-1-1-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-1" role="tab" aria-controls="tabset-1-1" aria-selected="true">Expense Sharing Visualized</a></li></ul>
515<div class="tab-content">
516<div id="tabset-1-1" class="tab-pane active" role="tabpanel" aria-labelledby="tabset-1-1-tab">
517<div class="cell">
518<div class="sourceCode cell-code hidden" id="cb5" data-startfrom="262" data-source-offset="-0"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 261;"><span id="cb5-262"><a href="#cb5-262" aria-hidden="true" tabindex="-1"></a>d3 <span class="op">=</span> <span class="pp">require</span>(<span class="st">"d3@7"</span><span class="op">,</span> <span class="st">"[email protected]"</span>)</span>
519<span id="cb5-263"><a href="#cb5-263" aria-hidden="true" tabindex="-1"></a><span class="co">
519//d3Sankey = require.alias({"d3-array": d3, "d3-shape": d3, "d3-sankey": "[email protected]/dist/d3-sankey.min.js"})("d3-sankey")</span></span>
520<span id="cb5-264"><a href="#cb5-264" aria-hidden="true" tabindex="-1"></a></span>
521<span id="cb5-265"><a href="#cb5-265" aria-hidden="true" tabindex="-1"></a>chart <span class="op">=</span> {</span>
522<span id="cb5-266"><a href="#cb5-266" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Specify the dimensions of the chart.</span></span>
523<span id="cb5-267"><a href="#cb5-267" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> width <span class="op">=</span> <span class="dv">928</span><span class="op">;</span></span>
524<span id="cb5-268"><a href="#cb5-268" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> height <span class="op">=</span> <span class="dv">600</span><span class="op">;</span></span>
525<span id="cb5-269"><a href="#cb5-269" aria-hidden="true" tabindex="-1"></a>  </span>
526<span id="cb5-270"><a href="#cb5-270" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> format <span class="op">=</span> d3<span class="op">.</span><span class="fu">format</span>(<span class="st">",.2f"</span>)</span>
527<span id="cb5-271"><a href="#cb5-271" aria-hidden="true" tabindex="-1"></a></span>
528<span id="cb5-272"><a href="#cb5-272" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Create an SVG container.</span></span>
529<span id="cb5-273"><a href="#cb5-273" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> svg <span class="op">=</span> d3<span class="op">.</span><span class="fu">create</span>(<span class="st">"svg"</span>)</span>
530<span id="cb5-274"><a href="#cb5-274" aria-hidden="true" tabindex="-1"></a>
530      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"width"</span><span class="op">,</span> width)</span>
531<span id="cb5-275"><a href="#cb5-275" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"height"</span><span class="op">,</span> height)</span>
532<span id="cb5-276"><a href="#cb5-276" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"viewBox"</span><span class="op">,</span> [<span class="dv">0</span><span class="op">,</span> <span class="dv">0</span><span class="op">,</span> width<span class="op">,</span> height])</span>
533<span id="cb5-277"><a href="#cb5-277" aria-hidden="true" tabindex="-1"></a>      <span class="co">//.attr("style", "max-width: 100%; height: auto; font: 20px sans-serif;");</span></span>
534<span id="cb5-278"><a href="#cb5-278" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"style"</span><span class="op">,</span> <span class="st">"max-width: 100%; height: auto; font: 20px Garamond;"</span>)<span class="op">;</span></span>
535<span id="cb5-279"><a href="#cb5-279" aria-hidden="true" tabindex="-1"></a></span>
536<span id="cb5-280"><a href="#cb5-280" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Constructs and configures a Sankey generator.</span></span>
537<span id="cb5-281"><a href="#cb5-281" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> sankey <span class="op">=</span> d3<span class="op">.</span><span class="fu">sankey</span>()</span>
538<span id="cb5-282"><a href="#cb5-282" aria-hidden="true" tabindex="-1"></a>
538      <span class="op">.</span><span class="fu">nodeId</span>(d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">name</span>)</span>
539<span id="cb5-283"><a href="#cb5-283" aria-hidden="true" tabindex="-1"></a>      <span class="co">// d3.sankeyLeft, d3.sankeyRight, d3.sankeyCenter, d3.sankeyJustify, d3[nodeAlign]</span></span>
540<span id="cb5-284"><a href="#cb5-284" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">nodeAlign</span>(d3<span class="op">.</span><span class="at">sankeyJustify</span>) </span>
541<span id="cb5-285"><a href="#cb5-285" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">nodeSort</span>(<span class="kw">null</span>) <span class="co">//(inputOrder ? null : undefined)</span></span>
542<span id="cb5-286"><a href="#cb5-286" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">nodeWidth</span>(<span class="dv">15</span>)</span>
543<span id="cb5-287"><a href="#cb5-287" aria-hidden="true" tabindex="-1"></a>
543      <span class="op">.</span><span class="fu">nodePadding</span>(<span class="dv">10</span>)</span>
544<span id="cb5-288"><a href="#cb5-288" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">extent</span>([[<span class="dv">1</span><span class="op">,</span> <span class="dv">5</span>]<span class="op">,</span> [width <span class="op">-</span> <span class="dv">1</span><span class="op">,</span> height <span class="op">-</span> <span class="dv">15</span>]])<span class="op">;</span></span>
545<span id="cb5-289"><a href="#cb5-289" aria-hidden="true" tabindex="-1"></a></span>
546<span id="cb5-290"><a href="#cb5-290" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Changes data to reflect the values in the input selections</span></span>
547<span id="cb5-291"><a href="#cb5-291" aria-hidden="true" tabindex="-1"></a>  <span class="co">// premium -&gt; reimbursement</span></span>
548<span id="cb5-292"><a href="#cb5-292" aria-hidden="true" tabindex="-1"></a>  data<span class="op">.</span><span class="at">links</span>[<span class="dv">0</span>]<span class="op">.</span><span class="at">value</span> <span class="op">=</span> calculated_policy_parameters<span class="op">.</span><span class="at">annual_premium</span></span>
549<span id="cb5-293"><a href="#cb5-293" aria-hidden="true" tabindex="-1"></a>  <span class="co">// deductible -&gt; medical-expense</span></span>
550<span id="cb5-294"><a href="#cb5-294" aria-hidden="true" tabindex="-1"></a>  data<span class="op">.</span><span class="at">links</span>[<span class="dv">1</span>]<span class="op">.</span><span class="at">value</span> <span class="op">=</span> calculated_policy_parameters<span class="op">.</span><span class="at">deductible</span></span>
551<span id="cb5-295"><a href="#cb5-295" aria-hidden="true" tabindex="-1"></a>  <span class="co">// coinsurance -&gt; medical-expense</span></span>
552<span id="cb5-296"><a href="#cb5-296" aria-hidden="true" tabindex="-1"></a>  data<span class="op">.</span><span class="at">links</span>[<span class="dv">2</span>]<span class="op">.</span><span class="at">value</span> <span class="op">=</span> calculated_policy_parameters<span class="op">.</span><span class="at">co_insurance</span></span>
553<span id="cb5-297"><a href="#cb5-297" aria-hidden="true" tabindex="-1"></a>  <span class="co">// not-covered -&gt; medical-expense</span></span>
554<span id="cb5-298"><a href="#cb5-298" aria-hidden="true" tabindex="-1"></a>  data<span class="op">.</span><span class="at">links</span>[<span class="dv">3</span>]<span class="op">.</span><span class="at">value</span> <span class="op">=</span> calculated_policy_parameters<span class="op">.</span><span class="at">not_covered</span></span>
555<span id="cb5-299"><a href="#cb5-299" aria-hidden="true" tabindex="-1"></a>  <span class="co">// limit-spillover -&gt; medical-expense</span></span>
556<span id="cb5-300"><a href="#cb5-300" aria-hidden="true" tabindex="-1"></a>  data<span class="op">.</span><span class="at">links</span>[<span class="dv">4</span>]<span class="op">.</span><span class="at">value</span> <span class="op">=</span> calculated_policy_parameters<span class="op">.</span><span class="at">limit_spillover</span></span>
557<span id="cb5-301"><a href="#cb5-301" aria-hidden="true" tabindex="-1"></a>  <span class="co">// reimbursement -&gt; medical-expense</span></span>
558<span id="cb5-302"><a href="#cb5-302" aria-hidden="true" tabindex="-1"></a>  data<span class="op">.</span><span class="at">links</span>[<span class="dv">5</span>]<span class="op">.</span><span class="at">value</span> <span class="op">=</span> calculated_policy_parameters<span class="op">.</span><span class="at">reimbursement</span></span>
559<span id="cb5-303"><a href="#cb5-303" aria-hidden="true" tabindex="-1"></a>  </span>
560<span id="cb5-304"><a href="#cb5-304" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Applies it to the data. We make a copy of the nodes and links objects</span></span>
561<span id="cb5-305"><a href="#cb5-305" aria-hidden="true" tabindex="-1"></a>  <span class="co">// so as to avoid mutating the original.</span></span>
562<span id="cb5-306"><a href="#cb5-306" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> {nodes<span class="op">,</span> links} <span class="op">=</span> <span class="fu">sankey</span>({</span>
563<span id="cb5-307"><a href="#cb5-307" aria-hidden="true" tabindex="-1"></a>    <span class="dt">nodes</span><span class="op">:</span> data<span class="op">.</span><span class="at">nodes</span><span class="op">.</span><span class="fu">map</span>(d <span class="kw">=&gt;</span> <span class="bu">Object</span><span class="op">.</span><span class="fu">assign</span>({}<span class="op">,</span> d))<span class="op">,</span></span>
564<span id="cb5-308"><a href="#cb5-308" aria-hidden="true" tabindex="-1"></a>    <span class="dt">links</span><span class="op">:</span> data<span class="op">.</span><span class="at">links</span><span class="op">.</span><span class="fu">map</span>(d <span class="kw">=&gt;</span> <span class="bu">Object</span><span class="op">.</span><span class="fu">assign</span>({}<span class="op">,</span> d))</span>
565<span id="cb5-309"><a href="#cb5-309" aria-hidden="true" tabindex="-1"></a>  })<span class="op">;</span></span>
566<span id="cb5-310"><a href="#cb5-310" aria-hidden="true" tabindex="-1"></a>    </span>
567<span id="cb5-311"><a href="#cb5-311" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Defines a color scale.</span></span>
568<span id="cb5-312"><a href="#cb5-312" aria-hidden="true" tabindex="-1"></a>  <span class="co">// options: d3.schemeCategory10 d3.schemeTableau10</span></span>
569<span id="cb5-313"><a href="#cb5-313" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> color <span class="op">=</span> d3<span class="op">.</span><span class="fu">scaleOrdinal</span>(d3<span class="op">.</span><span class="at">schemeTableau10</span>)<span class="op">;</span> </span>
570<span id="cb5-314"><a href="#cb5-314" aria-hidden="true" tabindex="-1"></a></span>
571<span id="cb5-315"><a href="#cb5-315" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Creates the rects that represent the nodes.</span></span>
572<span id="cb5-316"><a href="#cb5-316" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> rect <span class="op">=</span> svg<span class="op">.</span><span class="fu">append</span>(<span class="st">"g"</span>)</span>
573<span id="cb5-317"><a href="#cb5-317" aria-hidden="true" tabindex="-1"></a>
573      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"stroke"</span><span class="op">,</span> <span class="st">"#d4d4d4"</span>) <span class="co">//#000</span></span>
574<span id="cb5-318"><a href="#cb5-318" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">selectAll</span>()</span>
575<span id="cb5-319"><a href="#cb5-319" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">data</span>(nodes)</span>
576<span id="cb5-320"><a href="#cb5-320" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">join</span>(<span class="st">"rect"</span>)</span>
577<span id="cb5-321"><a href="#cb5-321" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"x"</span><span class="op">,</span> d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">x0</span>)</span>
578<span id="cb5-322"><a href="#cb5-322" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"y"</span><span class="op">,</span> d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">y0</span>)</span>
579<span id="cb5-323"><a href="#cb5-323" aria-hidden="true" tabindex="-1"></a>
579      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"height"</span><span class="op">,</span> d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">y1</span> <span class="op">-</span> d<span class="op">.</span><span class="at">y0</span>)</span>
580<span id="cb5-324"><a href="#cb5-324" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"width"</span><span class="op">,</span> d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">x1</span> <span class="op">-</span> d<span class="op">.</span><span class="at">x0</span>)</span>
581<span id="cb5-325"><a href="#cb5-325" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"fill"</span><span class="op">,</span> d <span class="kw">=&gt;</span> <span class="fu">color</span>(d<span class="op">.</span><span class="at">category</span>))<span class="op">;</span></span>
582<span id="cb5-326"><a href="#cb5-326" aria-hidden="true" tabindex="-1"></a></span>
583<span id="cb5-327"><a href="#cb5-327" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Adds a title on the nodes.</span></span>
584<span id="cb5-328"><a href="#cb5-328" aria-hidden="true" tabindex="-1"></a>  rect<span class="op">.</span><span class="fu">append</span>(<span class="st">"title"</span>)</span>
585<span id="cb5-329"><a href="#cb5-329" aria-hidden="true" tabindex="-1"></a>
585      <span class="op">.</span><span class="fu">text</span>(d <span class="kw">=&gt;</span> <span class="vs">`</span><span class="sc">${</span>d<span class="op">.</span><span class="at">name</span><span class="sc">}\n${</span><span class="fu">format</span>(d<span class="op">.</span><span class="at">value</span>)<span class="sc">}</span><span class="vs">`</span>)<span class="op">;</span></span>
586<span id="cb5-330"><a href="#cb5-330" aria-hidden="true" tabindex="-1"></a>      </span>
587<span id="cb5-331"><a href="#cb5-331" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Creates the paths that represent the links.</span></span>
588<span id="cb5-332"><a href="#cb5-332" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> link <span class="op">=</span> svg<span class="op">.</span><span class="fu">append</span>(<span class="st">"g"</span>)</span>
589<span id="cb5-333"><a href="#cb5-333" aria-hidden="true" tabindex="-1"></a>    <span class="op">.</span><span class="fu">attr</span>(<span class="st">"fill"</span><span class="op">,</span> <span class="st">"none"</span>)</span>
590<span id="cb5-334"><a href="#cb5-334" aria-hidden="true" tabindex="-1"></a>    <span class="op">.</span><span class="fu">attr</span>(<span class="st">"stroke-opacity"</span><span class="op">,</span> <span class="fl">0.5</span>)</span>
591<span id="cb5-335"><a href="#cb5-335" aria-hidden="true" tabindex="-1"></a>    <span class="op">.</span><span class="fu">selectAll</span>()</span>
592<span id="cb5-336"><a href="#cb5-336" aria-hidden="true" tabindex="-1"></a>    <span class="op">.</span><span class="fu">data</span>(links)</span>
593<span id="cb5-337"><a href="#cb5-337" aria-hidden="true" tabindex="-1"></a>    <span class="op">.</span><span class="fu">join</span>(<span class="st">"g"</span>)</span>
594<span id="cb5-338"><a href="#cb5-338" aria-hidden="true" tabindex="-1"></a>    <span class="op">.</span><span class="fu">style</span>(<span class="st">"mix-blend-mode"</span><span class="op">,</span> <span class="st">"multiply"</span>)<span class="op">;</span></span>
595<span id="cb5-339"><a href="#cb5-339" aria-hidden="true" tabindex="-1"></a></span>
596<span id="cb5-340"><a href="#cb5-340" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Creates a gradient, if necessary, for the source-target color option.</span></span>
597<span id="cb5-341"><a href="#cb5-341" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> linkColor <span class="op">=</span> <span class="st">"#d4d4d4"</span><span class="op">;</span> <span class="co">//"source";</span></span>
598<span id="cb5-342"><a href="#cb5-342" aria-hidden="true" tabindex="-1"></a>  <span class="cf">if</span> (linkColor <span class="op">===</span> <span class="st">"source-target"</span>) {</span>
599<span id="cb5-343"><a href="#cb5-343" aria-hidden="true" tabindex="-1"></a>    <span class="kw">const</span> gradient <span class="op">=</span> link<span class="op">.</span><span class="fu">append</span>(<span class="st">"linearGradient"</span>)</span>
600<span id="cb5-344"><a href="#cb5-344" aria-hidden="true" tabindex="-1"></a>        <span class="op">.</span><span class="fu">attr</span>(<span class="st">"id"</span><span class="op">,</span> d <span class="kw">=&gt;</span> (d<span class="op">.</span><span class="at">uid</span> <span class="op">=</span> DOM<span class="op">.</span><span class="fu">uid</span>(<span class="st">"link"</span>))<span class="op">.</span><span class="at">id</span>)</span>
601<span id="cb5-345"><a href="#cb5-345" aria-hidden="true" tabindex="-1"></a>        <span class="op">.</span><span class="fu">attr</span>(<span class="st">"gradientUnits"</span><span class="op">,</span> <span class="st">"userSpaceOnUse"</span>)</span>
602<span id="cb5-346"><a href="#cb5-346" aria-hidden="true" tabindex="-1"></a>        <span class="op">.</span><span class="fu">attr</span>(<span class="st">"x1"</span><span class="op">,</span> d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">source</span><span class="op">.</span><span class="at">x1</span>)</span>
603<span id="cb5-347"><a href="#cb5-347" aria-hidden="true" tabindex="-1"></a>
603        <span class="op">.</span><span class="fu">attr</span>(<span class="st">"x2"</span><span class="op">,</span> d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">target</span><span class="op">.</span><span class="at">x0</span>)<span class="op">;</span></span>
604<span id="cb5-348"><a href="#cb5-348" aria-hidden="true" tabindex="-1"></a>    gradient<span class="op">.</span><span class="fu">append</span>(<span class="st">"stop"</span>)</span>
605<span id="cb5-349"><a href="#cb5-349" aria-hidden="true" tabindex="-1"></a>        <span class="op">.</span><span class="fu">attr</span>(<span class="st">"offset"</span><span class="op">,</span> <span class="st">"0%"</span>)</span>
606<span id="cb5-350"><a href="#cb5-350" aria-hidden="true" tabindex="-1"></a>        <span class="op">.</span><span class="fu">attr</span>(<span class="st">"stop-color"</span><span class="op">,</span> d <span class="kw">=&gt;</span> <span class="fu">color</span>(d<span class="op">.</span><span class="at">source</span><span class="op">.</span><span class="at">category</span>))<span class="op">;</span></span>
607<span id="cb5-351"><a href="#cb5-351" aria-hidden="true" tabindex="-1"></a>    gradient<span class="op">.</span><span class="fu">append</span>(<span class="st">"stop"</span>)</span>
608<span id="cb5-352"><a href="#cb5-352" aria-hidden="true" tabindex="-1"></a>        <span class="op">.</span><span class="fu">attr</span>(<span class="st">"offset"</span><span class="op">,</span> <span class="st">"100%"</span>)</span>
609<span id="cb5-353"><a href="#cb5-353" aria-hidden="true" tabindex="-1"></a>        <span class="op">.</span><span class="fu">attr</span>(<span class="st">"stop-color"</span><span class="op">,</span> d <span class="kw">=&gt;</span> <span class="fu">color</span>(d<span class="op">.</span><span class="at">target</span><span class="op">.</span><span class="at">category</span>))<span class="op">;</span></span>
610<span id="cb5-354"><a href="#cb5-354" aria-hidden="true" tabindex="-1"></a>  }</span>
611<span id="cb5-355"><a href="#cb5-355" aria-hidden="true" tabindex="-1"></a> link<span class="op">.</span><span class="fu">append</span>(<span class="st">"path"</span>)</span>
612<span id="cb5-356"><a href="#cb5-356" aria-hidden="true" tabindex="-1"></a>
612      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"d"</span><span class="op">,</span> d3<span class="op">.</span><span class="fu">sankeyLinkHorizontal</span>())</span>
613<span id="cb5-357"><a href="#cb5-357" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"stroke"</span><span class="op">,</span> linkColor <span class="op">===</span> <span class="st">"source-target"</span> <span class="op">?</span> (d) <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">uid</span></span>
614<span id="cb5-358"><a href="#cb5-358" aria-hidden="true" tabindex="-1"></a>          <span class="op">:</span> linkColor <span class="op">===</span> <span class="st">"source"</span> <span class="op">?</span> (d) <span class="kw">=&gt;</span> <span class="fu">color</span>(d<span class="op">.</span><span class="at">source</span><span class="op">.</span><span class="at">category</span>)</span>
615<span id="cb5-359"><a href="#cb5-359" aria-hidden="true" tabindex="-1"></a>          <span class="op">:</span> linkColor <span class="op">===</span> <span class="st">"target"</span> <span class="op">?</span> (d) <span class="kw">=&gt;</span> <span class="fu">color</span>(d<span class="op">.</span><span class="at">target</span><span class="op">.</span><span class="at">category</span>
615) </span>
616<span id="cb5-360"><a href="#cb5-360" aria-hidden="true" tabindex="-1"></a>          <span class="op">:</span> linkColor)</span>
617<span id="cb5-361"><a href="#cb5-361" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"stroke-width"</span><span class="op">,</span> d <span class="kw">=&gt;</span> <span class="bu">Math</span><span class="op">.</span><span class="fu">max</span>(<span class="dv">1</span><span class="op">,</span> d<span class="op">.</span><span class="at">width</span>))<span class="op">;</span></span>
618<span id="cb5-362"><a href="#cb5-362" aria-hidden="true" tabindex="-1"></a></span>
619<span id="cb5-363"><a href="#cb5-363" aria-hidden="true" tabindex="-1"></a>  link<span class="op">.</span><span class="fu">append</span>(<span class="st">"title"</span>)</span>
620<span id="cb5-364"><a href="#cb5-364" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">text</span>(d <span class="kw">=&gt;</span> <span class="vs">`</span><span class="sc">${</span>d<span class="op">.</span><span class="at">source</span><span class="op">.</span><span class="at">name</span><span class="sc">}</span><span class="vs"> → </span><span class="sc">${</span>d<span class="op">.</span><span class="at">target</span><span class="op">.</span><span class="at">name</span><span class="sc">}\n\$${</span><span class="fu">format</span>(d<span class="op">.</span><span class="at">value</span>)<span class="sc">}</span><span class="vs">`</span>)<span class="op">;</span></span>
621<span id="cb5-365"><a href="#cb5-365" aria-hidden="true" tabindex="-1"></a></span>
622<span id="cb5-366"><a href="#cb5-366" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Adds labels on the nodes.</span></span>
623<span id="cb5-367"><a href="#cb5-367" aria-hidden="true" tabindex="-1"></a>  svg<span class="op">.</span><span class="fu">append</span>(<span class="st">"g"</span>)</span>
624<span id="cb5-368"><a href="#cb5-368" aria-hidden="true" tabindex="-1"></a>    <span class="op">.</span><span class="fu">selectAll</span>()</span>
625<span id="cb5-369"><a href="#cb5-369" aria-hidden="true" tabindex="-1"></a>    <span class="op">.</span><span class="fu">data</span>(nodes)</span>
626<span id="cb5-370"><a href="#cb5-370" aria-hidden="true" tabindex="-1"></a>    <span class="op">.</span><span class="fu">join</span>(<span class="st">"text"</span>)</span>
627<span id="cb5-371"><a href="#cb5-371" aria-hidden="true" tabindex="-1"></a>
627      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"x"</span><span class="op">,</span> d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">x0</span> <span class="op">&lt;</span> width <span class="op">/</span> <span class="dv">2</span> <span class="op">?</span> d<span class="op">.</span><span class="at">x1</span> <span class="op">+</span> <span class="dv">6</span> <span class="op">:</span> d<span class="op">.</span><span class="at">x0</span> <span class="op">-</span> <span class="dv">6</span>)</span>
628<span id="cb5-372"><a href="#cb5-372" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"y"</span><span class="op">,</span> d <span class="kw">=&gt;</span> (d<span class="op">.</span><span class="at">y1</span> <span class="op">+</span> d<span class="op">.</span><span class="at">y0</span>) <span class="op">/</span> <span class="dv">2</span>)</span>
629<span id="cb5-373"><a href="#cb5-373" aria-hidden="true" tabindex="-1"></a>
629      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"dy"</span><span class="op">,</span> <span class="st">"0.35em"</span>)</span>
630<span id="cb5-374"><a href="#cb5-374" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">attr</span>(<span class="st">"text-anchor"</span><span class="op">,</span> d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">x0</span> <span class="op">&lt;</span> width <span class="op">/</span> <span class="dv">2</span> <span class="op">?</span> <span class="st">"start"</span> <span class="op">:</span> <span class="st">"end"</span>)</span>
631<span id="cb5-375"><a href="#cb5-375" aria-hidden="true" tabindex="-1"></a>      <span class="op">.</span><span class="fu">text</span>(d <span class="kw">=&gt;</span> d<span class="op">.</span><span class="at">name</span>)<span class="op">;</span></span>
632<span id="cb5-376"><a href="#cb5-376" aria-hidden="true" tabindex="-1"></a></span>
633<span id="cb5-377"><a href="#cb5-377" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> svg<span class="op">.</span><span class="fu">node</span>()<span class="op">;</span></span>
634<span id="cb5-378"><a href="#cb5-378" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
635<div class="cell-output cell-output-display">
636<div>
637<div id="ojs-cell-5-1" data-nodetype="declaration">
638
639</div>
640</div>
641</div>
642<div class="cell-output cell-output-display">
643<div>
644<div id="ojs-cell-5-2" data-nodetype="declaration">
645
646</div>
647</div>
648</div>
649</div>
650</div>
651</div>
652</div>
653<hr>
654<p>Thoughts on this visualizer, want to request additional functionality or report an issue? <a href="mailto:[email protected]?subject=Re:Pet-Insurance-Expense-Sharing">Reply by email</a>.</p>
655
656
657<div class="ojs-auto-generated hidden">
658<script type="ojs-module-contents">
659eyJjb250ZW50cyI6WyAgeyJtZXRob2ROYW1lIjoiaW50ZXJwcmV0IiwiaW5saW5lIjoidHJ1ZSIsInNvdXJjZSI6Imh0bC5odG1sYDxzcGFuPiR7Y2FsY3VsYXRlZF9wb2xpY3lfcGFyYW1ldGVycy5hbm51YWxfcHJlbWl1bX08L3NwYW4+YCIsICJjZWxsTmFtZSI6Im9qcy1lbGVtZW50LWlkLTEifSwgIHsibWV0aG9kTmFtZSI6ImludGVycHJldCIsImlubGluZSI6InRydWUiLCJzb3VyY2UiOiJodGwuaHRtbGA8c3Bhbj4ke2NhbGN1bGF0ZWRfcG9saWN5X3BhcmFtZXRlcnMuZGVkdWN0aWJsZX08L3NwYW4+YCIsICJjZWxsTmFtZSI6Im9qcy1lbGVtZW50LWlkLTIifSwgIHsibWV0aG9kTmFtZSI6ImludGVycHJldCIsImlubGluZSI6InRydWUiLCJzb3VyY2UiOiJodGwuaHRtbGA8c3Bhbj4ke2NhbGN1bGF0ZWRfcG9saWN5X3BhcmFtZXRlcnMuY29faW5zdXJhbmNlfTwvc3Bhbj5gIiwgImNlbGxOYW1lIjoib2pzLWVsZW1lbnQtaWQtMyJ9LCAgeyJtZXRob2ROYW1lIjoiaW50ZXJwcmV0IiwiaW5saW5lIjoidHJ1ZSIsInNvdXJjZSI6Imh0bC5odG1sYDxzcGFuPiR7Y2FsY3VsYXRlZF9wb2xpY3lfcGFyYW1ldGVycy5ub3RfY292ZXJlZH08L3NwYW4+YCIsICJjZWxsTmFtZSI6Im9qcy1lbGVtZW50LWlkLTQifSwgIH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gaWYgKG5vX2luc3VyZXIpIHtcbiAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICB9IGVsc2UgaWYgKG5vX2V4cGVuc2UpIHtcbiAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpbl9kZWR1Y3RpYmxlX3N0YWdlID09PSBcImFmdGVyXCIpIHtcbiAgICAgICAgICAgIHJldHVybiBOdW1iZXIoKGNhbGN1bGF0ZWRfcGFyYW1ldGVycy5jb3ZlcmVkICogKDEgLSBpbl9yZWltYnVyc2VtZW50LzEwMCkpLnRvRml4ZWQoMikpO1xuICAgICAgICB9IGVsc2UgaWYgKGluX2RlZHVjdGlibGVfc3RhZ2UgPT09IFwiYmVmb3JlXCIpIHtcbiAgICAgICAgICAgIHJldHVybiBOdW1iZXIoKFxuICAgICAgICAgICAgICAgIChjYWxjdWxhdGVkX3BhcmFtZXRlcnMuY292ZXJlZCAtIGNhbGN1bGF0ZWRfcGFyYW1ldGVycy5kZWR1Y3RpYmxlKSAqICgxIC0gaW5fcmVpbWJ1cnNlbWVudC8xMDApXG4gICAgICAgICAgICApLnRvRml4ZWQoMikpO1xuICAgICAgICB9XG4gICAgfSkoKVxuXG4gICAgY2FsY3VsYXRlZF9wYXJhbWV0ZXJzLnJlaW1idXJzZW1lbnQgPSAoKCkgPT4ge1xuICAgICAgICBpZiAobm9faW5zdXJlcikge1xuICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgIH0gZWxzZSBpZiAobm9fZXhwZW5zZSkge1xuICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgIH0gXG4gICAgICAgIGlmIChpbl9kZWR1Y3RpYmxlX3N0YWdlID09PSBcImFmdGVyXCIpIHtcbiAgICAgICAgICAgIHJldHVybiBNYXRoLm1pbihcbiAgICAgICAgICAgICAgICBjYWxjdWxhdGVkX3BhcmFtZXRlcnMubGltaXQsXG4gICAgICAgICAgICAgICAgTnVtYmVyKChcbiAgICAgICAgICAgICAg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dCgncG9saWN5X3BhcmFtZXRlcnMnKSJ9XX0=
666</script>
vendor: 1 bytes, line 666
666
667<script type="module">
668if (window.location.protocol === "file:") { alert("The OJS runtime does not work with file:// URLs. Please use a web server to view this document."); }
669window._ojs.paths.runtimeToDoc = "../../posts/2025-09-pet-insurance-expense-sharing";
670window._ojs.paths.runtimeToRoot = "../..";
671window._ojs.paths.docToRoot = "../..";
672window._ojs.selfContained = false;
673window._ojs.runtime.interpretFromScriptTags();
674</script>
vendor: 1 bytes, line 674
674
675<script id="quarto-html-after-body" type="application/javascript">
676  window.document.addEventListener("DOMContentLoaded", function (event) {
677    const icon = "";
678    const anchorJS = new window.AnchorJS();
679    anchorJS.options = {
680      placement: 'right',
681      icon: icon
682    };
683    anchorJS.add('.anchored');
684    const isCodeAnnotation = (el) => {
685      for (const clz of el.classList) {
686        if (clz.startsWith('code-annotation-')) {                     
687          return true;
688        }
689      }
690      return false;
691    }
692    const onCopySuccess = function(e) {
693      // button target
694      const button = e.trigger;
695      // don't keep focus
696      button.blur();
697      // flash "checked"
698      button.classList.add('code-copy-button-checked');
699      var currentTitle = button.getAttribute("title");
700      button.setAttribute("title", "Copied!");
701      let tooltip;
702      if (window.bootstrap) {
703        button.setAttribute("data-bs-toggle", "tooltip");
704        button.setAttribute("data-bs-placement", "left");
705        button.setAttribute("data-bs-title", "Copied!");
706        tooltip = new bootstrap.Tooltip(button, 
707          { trigger: "manual", 
708            customClass: "code-copy-button-tooltip",
709            offset: [0, -8]});
710        tooltip.show();    
711      }
712      setTimeout(function() {
713        if (tooltip) {
714          tooltip.hide();
715          button.removeAttribute("data-bs-title");
716          button.removeAttribute("data-bs-toggle");
717          button.removeAttribute("data-bs-placement");
718        }
719        button.setAttribute("title", currentTitle);
720        button.classList.remove('code-copy-button-checked');
721      }, 1000);
722      // clear code selection
723      e.clearSelection();
724    }
725    const getTextToCopy = function(trigger) {
726        const codeEl = trigger.previousElementSibling.cloneNode(true);
727        for (const childEl of codeEl.children) {
728          if (isCodeAnnotation(childEl)) {
729            childEl.remove();
730          }
731        }
732        return codeEl.innerText;
733    }
734    const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', {
735      text: getTextToCopy
736    });
737    clipboard.on('success', onCopySuccess);
738    if (window.document.getElementById('quarto-embedded-source-code-modal')) {
739      const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', {
740        text: getTextToCopy,
741        container: window.document.getElementById('quarto-embedded-source-code-modal')
742      });
743      clipboardModal.on('success', onCopySuccess);
744    }
745      var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
746      var mailtoRegex = new RegExp(/^mailto:/);
747        var filterRegex = new RegExp("https:\/\/sometimesdataoftendogs\.com\/");
748      var isInternal = (href) => {
749          return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
750      }
751      // Inspect non-navigation links and adorn them if external
752     var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool):not(.about-link)');
753      for (var i=0; i<links.length; i++) {
754        const link = links[i];
755        if (!isInternal(link.href)) {
756          // undo the damage that might have been done by quarto-nav.js in the case of
757          // links that we want to consider external
758          if (link.dataset.originalHref !== undefined) {
759            link.href = link.dataset.originalHref;
760          }
761        }
762      }
763    function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
764      const config = {
765        allowHTML: true,
766        maxWidth: 500,
767        delay: 100,
768        arrow: false,
769        appendTo: function(el) {
770            return el.parentElement;
771        },
772        interactive: true,
773        interactiveBorder: 10,
774        theme: 'quarto',
775        placement: 'bottom-start',
776      };
777      if (contentFn) {
778        config.content = contentFn;
779      }
780      if (onTriggerFn) {
781        config.onTrigger = onTriggerFn;
782      }
783      if (onUntriggerFn) {
784        config.onUntrigger = onUntriggerFn;
785      }
786      window.tippy(el, config); 
787    }
788    const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
789    for (var i=0; i<noterefs.length; i++) {
790      const ref = noterefs[i];
791      tippyHover(ref, function() {
792        // use id or data attribute instead here
793        let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
794        try { href = new URL(href).hash; } catch {}
795        const id = href.replace(/^#\/?/, "");
796        const note = window.document.getElementById(id);
797        if (note) {
798          return note.innerHTML;
799        } else {
800          return "";
801        }
802      });
803    }
804    const xrefs = window.document.querySelectorAll('a.quarto-xref');
805    const processXRef = (id, note) => {
806      // Strip column container classes
807      const stripColumnClz = (el) => {
808        el.classList.remove("page-full", "page-columns");
809        if (el.children) {
810          for (const child of el.children) {
811            stripColumnClz(child);
812          }
813        }
814      }
815      stripColumnClz(note)
816      if (id === null || id.startsWith('sec-')) {
817        // Special case sections, only their first couple elements
818        const container = document.createElement("div");
819        if (note.children && note.children.length > 2) {
820          container.appendChild(note.children[0].cloneNode(true));
821          for (let i = 1; i < note.children.length; i++) {
822            const child = note.children[i];
823            if (child.tagName === "P" && child.innerText === "") {
824              continue;
825            } else {
826              container.appendChild(child.cloneNode(true));
827              break;
828            }
829          }
830          if (window.Quarto?.typesetMath) {
831            window.Quarto.typesetMath(container);
832          }
833          return container.innerHTML
834        } else {
835          if (window.Quarto?.typesetMath) {
836            window.Quarto.typesetMath(note);
837          }
838          return note.innerHTML;
839        }
840      } else {
841        // Remove any anchor links if they are present
842        const anchorLink = note.querySelector('a.anchorjs-link');
843        if (anchorLink) {
844          anchorLink.remove();
845        }
846        if (window.Quarto?.typesetMath) {
847          window.Quarto.typesetMath(note);
848        }
849        if (note.classList.contains("callout")) {
850          return note.outerHTML;
851        } else {
852          return note.innerHTML;
853        }
854      }
855    }
856    for (var i=0; i<xrefs.length; i++) {
857      const xref = xrefs[i];
858      tippyHover(xref, undefined, function(instance) {
859        instance.disable();
860        let url = xref.getAttribute('href');
861        let hash = undefined; 
862        if (url.startsWith('#')) {
863          hash = url;
864        } else {
865          try { hash = new URL(url).hash; } catch {}
866        }
867        if (hash) {
868          const id = hash.replace(/^#\/?/, "");
869          const note = window.document.getElementById(id);
870          if (note !== null) {
871            try {
872              const html = processXRef(id, note.cloneNode(true));
873              instance.setContent(html);
874            } finally {
875              instance.enable();
876              instance.show();
877            }
878          } else {
879            // See if we can fetch this
880            fetch(url.split('#')[0])
881            .then(res => res.text())
882            .then(html => {
883              const parser = new DOMParser();
884              const htmlDoc = parser.parseFromString(html, "text/html");
885              const note = htmlDoc.getElementById(id);
886              if (note !== null) {
887                const html = processXRef(id, note);
888                instance.setContent(html);
889              } 
890            }).finally(() => {
891              instance.enable();
892              instance.show();
893            });
894          }
895        } else {
896          // See if we can fetch a full url (with no hash to target)
897          // This is a special case and we should probably do some content thinning / targeting
898          fetch(url)
899          .then(res => res.text())
900          .then(html => {
901            const parser = new DOMParser();
902            const htmlDoc = parser.parseFromString(html, "text/html");
903            const note = htmlDoc.querySelector('main.content');
904            if (note !== null) {
905              // This should only happen for chapter cross references
906              // (since there is no id in the URL)
907              // remove the first header
908              if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
909                note.children[0].remove();
910              }
911              const html = processXRef(null, note);
912              instance.setContent(html);
913            } 
914          }).finally(() => {
915            instance.enable();
916            instance.show();
917          });
918        }
919      }, function(instance) {
920      });
921    }
922        let selectedAnnoteEl;
923        const selectorForAnnotation = ( cell, annotation) => {
924          let cellAttr = 'data-code-cell="' + cell + '"';
925          let lineAttr = 'data-code-annotation="' +  annotation + '"';
926          const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
927          return selector;
928        }
929        const selectCodeLines = (annoteEl) => {
930          const doc = window.document;
931          const targetCell = annoteEl.getAttribute("data-target-cell");
932          const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
933          const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
934          const lines = annoteSpan.getAttribute("data-code-lines").split(",");
935          const lineIds = lines.map((line) => {
936            return targetCell + "-" + line;
937          })
938          let top = null;
939          let height = null;
940          let parent = null;
941          if (lineIds.length > 0) {
942              //compute the position of the single el (top and bottom and make a div)
943              const el = window.document.getElementById(lineIds[0]);
944              top = el.offsetTop;
945              height = el.offsetHeight;
946              parent = el.parentElement.parentElement;
947            if (lineIds.length > 1) {
948              const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
949              const bottom = lastEl.offsetTop + lastEl.offsetHeight;
950              height = bottom - top;
951            }
952            if (top !== null && height !== null && parent !== null) {
953              // cook up a div (if necessary) and position it 
954              let div = window.document.getElementById("code-annotation-line-highlight");
955              if (div === null) {
956                div = window.document.createElement("div");
957                div.setAttribute("id", "code-annotation-line-highlight");
958                div.style.position = 'absolute';
959                parent.appendChild(div);
960              }
961              div.style.top = top - 2 + "px";
962              div.style.height = height + 4 + "px";
963              div.style.left = 0;
964              let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
965              if (gutterDiv === null) {
966                gutterDiv = window.document.createElement("div");
967                gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
968                gutterDiv.style.position = 'absolute';
969                const codeCell = window.document.getElementById(targetCell);
970                const gutter = codeCell.querySelector('.code-annotation-gutter');
971                gutter.appendChild(gutterDiv);
972              }
973              gutterDiv.style.top = top - 2 + "px";
974              gutterDiv.style.height = height + 4 + "px";
975            }
976            selectedAnnoteEl = annoteEl;
977          }
978        };
979        const unselectCodeLines = () => {
980          const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
981          elementsIds.forEach((elId) => {
982            const div = window.document.getElementById(elId);
983            if (div) {
984              div.remove();
985            }
986          });
987          selectedAnnoteEl = undefined;
988        };
989          // Handle positioning of the toggle
990      window.addEventListener(
991        "resize",
992        throttle(() => {
993          elRect = undefined;
994          if (selectedAnnoteEl) {
995            selectCodeLines(selectedAnnoteEl);
996          }
997        }, 10)
998      );
999      function throttle(fn, ms) {
1000      let throttle = false;
1001      let timer;
1002        return (...args) => {
1003          if(!throttle) { // first call gets through
1004              fn.apply(this, args);
1005              throttle = true;
1006          } else { // all the others get throttled
1007              if(timer) clearTimeout(timer); // cancel #2
1008              timer = setTimeout(() => {
1009                fn.apply(this, args);
1010                timer = throttle = false;
1011              }, ms);
1012          }
1013        };
1014      }
1015        // Attach click handler to the DT
1016        const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
1017        for (const annoteDlNode of annoteDls) {
1018          annoteDlNode.addEventListener('click', (event) => {
1019            const clickedEl = event.target;
1020            if (clickedEl !== selectedAnnoteEl) {
1021              unselectCodeLines();
1022              const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
1023              if (activeEl) {
1024                activeEl.classList.remove('code-annotation-active');
1025              }
1026              selectCodeLines(clickedEl);
1027              clickedEl.classList.add('code-annotation-active');
1028            } else {
1029              // Unselect the line
1030              unselectCodeLines();
1031              clickedEl.classList.remove('code-annotation-active');
1032            }
1033          });
1034        }
1035    const findCites = (el) => {
1036      const parentEl = el.parentElement;
1037      if (parentEl) {
1038        const cites = parentEl.dataset.cites;
1039        if (cites) {
1040          return {
1041            el,
1042            cites: cites.split(' ')
1043          };
1044        } else {
1045          return findCites(el.parentElement)
1046        }
1047      } else {
1048        return undefined;
1049      }
1050    };
1051    var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
1052    for (var i=0; i<bibliorefs.length; i++) {
1053      const ref = bibliorefs[i];
1054      const citeInfo = findCites(ref);
1055      if (citeInfo) {
1056        tippyHover(citeInfo.el, function() {
1057          var popup = window.document.createElement('div');
1058          citeInfo.cites.forEach(function(cite) {
1059            var citeDiv = window.document.createElement('div');
1060            citeDiv.classList.add('hanging-indent');
1061            citeDiv.classList.add('csl-entry');
1062            var biblioDiv = window.document.getElementById('ref-' + cite);
1063            if (biblioDiv) {
1064              citeDiv.innerHTML = biblioDiv.innerHTML;
1065            }
1066            popup.appendChild(citeDiv);
1067          });
1068          return popup.innerHTML;
1069        });
1070      }
1071    }
1072  });
1073  </script>
1073
1074</div> <!-- /content -->
1075
1076
1077
1078
1079</body></html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.