friday-widgets
Version:
Professional embeddable accounting widgets for vertical SaaS platforms. Layer Financial-inspired design with comprehensive financial reporting capabilities.
682 lines (594 loc) • 52.8 kB
JavaScript
var FridayCashFlowStatementWidget=function(t){"use strict";function e(t,e,r,s){var a,i=arguments.length,o=i<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,s);else for(var n=t.length-1;n>=0;n--)(a=t[n])&&(o=(i<3?a(o):i>3?a(e,r,o):a(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o}"function"==typeof SuppressedError&&SuppressedError;
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const r=globalThis,s=r.ShadowRoot&&(void 0===r.ShadyCSS||r.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,a=Symbol(),i=new WeakMap;let o=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==a)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(s&&void 0===t){const r=void 0!==e&&1===e.length;r&&(t=i.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&i.set(e,t))}return t}toString(){return this.cssText}};const n=(t,...e)=>{const r=1===t.length?t[0]:e.reduce((e,r,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+t[s+1],t[0]);return new o(r,t,a)},d=s?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const r of t.cssRules)e+=r.cssText;return(t=>new o("string"==typeof t?t:t+"",void 0,a))(e)})(t):t,{is:c,defineProperty:l,getOwnPropertyDescriptor:h,getOwnPropertyNames:p,getOwnPropertySymbols:u,getPrototypeOf:g}=Object,m=globalThis,y=m.trustedTypes,v=y?y.emptyScript:"",f=m.reactiveElementPolyfillSupport,_=(t,e)=>t,b={toAttribute(t,e){switch(e){case Boolean:t=t?v:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=null!==t;break;case Number:r=null===t?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch(t){r=null}}return r}},w=(t,e)=>!c(t,e),$={attribute:!0,type:String,converter:b,reflect:!1,useDefault:!1,hasChanged:w};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/Symbol.metadata??=Symbol("metadata"),m.litPropertyMetadata??=new WeakMap;let x=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=$){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const r=Symbol(),s=this.getPropertyDescriptor(t,r,e);void 0!==s&&l(this.prototype,t,s)}}static getPropertyDescriptor(t,e,r){const{get:s,set:a}=h(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:s,set(e){const i=s?.call(this);a?.call(this,e),this.requestUpdate(t,i,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$}static _$Ei(){if(this.hasOwnProperty(_("elementProperties")))return;const t=g(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(_("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(_("properties"))){const t=this.properties,e=[...p(t),...u(t)];for(const r of e)this.createProperty(r,t[r])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,r]of e)this.elementProperties.set(t,r)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const r=this._$Eu(t,e);void 0!==r&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const r=new Set(t.flat(1/0).reverse());for(const t of r)e.unshift(d(t))}else void 0!==t&&e.push(d(t));return e}static _$Eu(t,e){const r=e.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(s)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const s of e){const e=document.createElement("style"),a=r.litNonce;void 0!==a&&e.setAttribute("nonce",a),e.textContent=s.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$ET(t,e){const r=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,r);if(void 0!==s&&!0===r.reflect){const a=(void 0!==r.converter?.toAttribute?r.converter:b).toAttribute(e,r.type);this._$Em=t,null==a?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(t,e){const r=this.constructor,s=r._$Eh.get(t);if(void 0!==s&&this._$Em!==s){const t=r.getPropertyOptions(s),a="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:b;this._$Em=s;const i=a.fromAttribute(e,t.type);this[s]=i??this._$Ej?.get(s)??i,this._$Em=null}}requestUpdate(t,e,r){if(void 0!==t){const s=this.constructor,a=this[t];if(r??=s.getPropertyOptions(t),!((r.hasChanged??w)(a,e)||r.useDefault&&r.reflect&&a===this._$Ej?.get(t)&&!this.hasAttribute(s._$Eu(t,r))))return;this.C(t,e,r)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:s,wrapped:a},i){r&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,i??e??this[t]),!0!==a||void 0!==i)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),!0===s&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,r]of t){const{wrapped:t}=r,s=this[e];!0!==t||this._$AL.has(e)||void 0===s||this.C(e,void 0,r,s)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};x.elementStyles=[],x.shadowRootOptions={mode:"open"},x[_("elementProperties")]=new Map,x[_("finalized")]=new Map,f?.({ReactiveElement:x}),(m.reactiveElementVersions??=[]).push("2.1.1");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const A=globalThis,F=A.trustedTypes,S=F?F.createPolicy("lit-html",{createHTML:t=>t}):void 0,E="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,k="?"+C,P=`<${k}>`,D=document,T=()=>D.createComment(""),O=t=>null===t||"object"!=typeof t&&"function"!=typeof t,I=Array.isArray,R="[ \t\n\f\r]",U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,q=/-->/g,N=/>/g,M=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),H=/'/g,z=/"/g,L=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...r)=>({_$litType$:t,strings:e,values:r}))(1),j=Symbol.for("lit-noChange"),W=Symbol.for("lit-nothing"),J=new WeakMap,V=D.createTreeWalker(D,129);function K(t,e){if(!I(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(e):e}const G=(t,e)=>{const r=t.length-1,s=[];let a,i=2===e?"<svg>":3===e?"<math>":"",o=U;for(let e=0;e<r;e++){const r=t[e];let n,d,c=-1,l=0;for(;l<r.length&&(o.lastIndex=l,d=o.exec(r),null!==d);)l=o.lastIndex,o===U?"!--"===d[1]?o=q:void 0!==d[1]?o=N:void 0!==d[2]?(L.test(d[2])&&(a=RegExp("</"+d[2],"g")),o=M):void 0!==d[3]&&(o=M):o===M?">"===d[0]?(o=a??U,c=-1):void 0===d[1]?c=-2:(c=o.lastIndex-d[2].length,n=d[1],o=void 0===d[3]?M:'"'===d[3]?z:H):o===z||o===H?o=M:o===q||o===N?o=U:(o=M,a=void 0);const h=o===M&&t[e+1].startsWith("/>")?" ":"";i+=o===U?r+P:c>=0?(s.push(n),r.slice(0,c)+E+r.slice(c)+C+h):r+C+(-2===c?e:h)}return[K(t,i+(t[r]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),s]};class Y{constructor({strings:t,_$litType$:e},r){let s;this.parts=[];let a=0,i=0;const o=t.length-1,n=this.parts,[d,c]=G(t,e);if(this.el=Y.createElement(d,r),V.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(s=V.nextNode())&&n.length<o;){if(1===s.nodeType){if(s.hasAttributes())for(const t of s.getAttributeNames())if(t.endsWith(E)){const e=c[i++],r=s.getAttribute(t).split(C),o=/([.?@])?(.*)/.exec(e);n.push({type:1,index:a,name:o[2],strings:r,ctor:"."===o[1]?et:"?"===o[1]?rt:"@"===o[1]?st:tt}),s.removeAttribute(t)}else t.startsWith(C)&&(n.push({type:6,index:a}),s.removeAttribute(t));if(L.test(s.tagName)){const t=s.textContent.split(C),e=t.length-1;if(e>0){s.textContent=F?F.emptyScript:"";for(let r=0;r<e;r++)s.append(t[r],T()),V.nextNode(),n.push({type:2,index:++a});s.append(t[e],T())}}}else if(8===s.nodeType)if(s.data===k)n.push({type:2,index:a});else{let t=-1;for(;-1!==(t=s.data.indexOf(C,t+1));)n.push({type:7,index:a}),t+=C.length-1}a++}}static createElement(t,e){const r=D.createElement("template");return r.innerHTML=t,r}}function Z(t,e,r=t,s){if(e===j)return e;let a=void 0!==s?r._$Co?.[s]:r._$Cl;const i=O(e)?void 0:e._$litDirective$;return a?.constructor!==i&&(a?._$AO?.(!1),void 0===i?a=void 0:(a=new i(t),a._$AT(t,r,s)),void 0!==s?(r._$Co??=[])[s]=a:r._$Cl=a),void 0!==a&&(e=Z(t,a._$AS(t,e.values),a,s)),e}class Q{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,s=(t?.creationScope??D).importNode(e,!0);V.currentNode=s;let a=V.nextNode(),i=0,o=0,n=r[0];for(;void 0!==n;){if(i===n.index){let e;2===n.type?e=new X(a,a.nextSibling,this,t):1===n.type?e=new n.ctor(a,n.name,n.strings,this,t):6===n.type&&(e=new at(a,this,t)),this._$AV.push(e),n=r[++o]}i!==n?.index&&(a=V.nextNode(),i++)}return V.currentNode=D,s}p(t){let e=0;for(const r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}class X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,s){this.type=2,this._$AH=W,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),O(t)?t===W||null==t||""===t?(this._$AH!==W&&this._$AR(),this._$AH=W):t!==this._$AH&&t!==j&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>I(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==W&&O(this._$AH)?this._$AA.nextSibling.data=t:this.T(D.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:r}=t,s="number"==typeof r?this._$AC(t):(void 0===r.el&&(r.el=Y.createElement(K(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===s)this._$AH.p(e);else{const t=new Q(s,this),r=t.u(this.options);t.p(e),this.T(r),this._$AH=t}}_$AC(t){let e=J.get(t.strings);return void 0===e&&J.set(t.strings,e=new Y(t)),e}k(t){I(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,s=0;for(const a of t)s===e.length?e.push(r=new X(this.O(T()),this.O(T()),this,this.options)):r=e[s],r._$AI(a),s++;s<e.length&&(this._$AR(r&&r._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,s,a){this.type=1,this._$AH=W,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=a,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=W}_$AI(t,e=this,r,s){const a=this.strings;let i=!1;if(void 0===a)t=Z(this,t,e,0),i=!O(t)||t!==this._$AH&&t!==j,i&&(this._$AH=t);else{const s=t;let o,n;for(t=a[0],o=0;o<a.length-1;o++)n=Z(this,s[r+o],e,o),n===j&&(n=this._$AH[o]),i||=!O(n)||n!==this._$AH[o],n===W?t=W:t!==W&&(t+=(n??"")+a[o+1]),this._$AH[o]=n}i&&!s&&this.j(t)}j(t){t===W?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class et extends tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===W?void 0:t}}class rt extends tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==W)}}class st extends tt{constructor(t,e,r,s,a){super(t,e,r,s,a),this.type=5}_$AI(t,e=this){if((t=Z(this,t,e,0)??W)===j)return;const r=this._$AH,s=t===W&&r!==W||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,a=t!==W&&(r===W||s);s&&this.element.removeEventListener(this.name,this,r),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class at{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Z(this,t)}}const it=A.litHtmlPolyfillSupport;it?.(Y,X),(A.litHtmlVersions??=[]).push("3.3.1");const ot=globalThis;
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class nt extends x{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,r)=>{const s=r?.renderBefore??e;let a=s._$litPart$;if(void 0===a){const t=r?.renderBefore??null;s._$litPart$=a=new X(e.insertBefore(T(),t),t,void 0,r??{})}return a._$AI(t),a})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return j}}nt._$litElement$=!0,nt.finalized=!0,ot.litElementHydrateSupport?.({LitElement:nt});const dt=ot.litElementPolyfillSupport;dt?.({LitElement:nt}),(ot.litElementVersions??=[]).push("4.2.1");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const ct={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:w},lt=(t=ct,e,r)=>{const{kind:s,metadata:a}=r;let i=globalThis.litPropertyMetadata.get(a);if(void 0===i&&globalThis.litPropertyMetadata.set(a,i=new Map),"setter"===s&&((t=Object.create(t)).wrapped=!0),i.set(r.name,t),"accessor"===s){const{name:s}=r;return{set(r){const a=e.get.call(this);e.set.call(this,r),this.requestUpdate(s,a,t)},init(e){return void 0!==e&&this.C(s,void 0,t,e),e}}}if("setter"===s){const{name:s}=r;return function(r){const a=this[s];e.call(this,r),this.requestUpdate(s,a,t)}}throw Error("Unsupported decorator location: "+s)};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function ht(t){return(e,r)=>"object"==typeof r?lt(t,e,r):((t,e,r)=>{const s=e.hasOwnProperty(r);return e.constructor.createProperty(r,t),s?Object.getOwnPropertyDescriptor(e,r):void 0})(t,e,r)}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function pt(t){return ht({...t,state:!0,attribute:!1})}class ut{constructor(t){this.config={timeout:3e4,retryAttempts:3,...t},this.defaultHeaders={"Content-Type":"application/json","X-API-Key":t.apiKey}}setBusinessContext(t){this.config.businessId=t}getBusinessContext(){return this.config.businessId}async request(t,e={}){const r=`${this.config.baseURL}${t}`,s={...this.defaultHeaders,...e.headers},a={...e,headers:s,signal:AbortSignal.timeout(this.config.timeout)};try{const t=await fetch(r,a);if(!t.ok){const e=await t.json().catch(()=>({}));return{success:!1,error:e.error||`HTTP ${t.status}: ${t.statusText}`,details:e.details}}return{success:!0,data:await t.json()}}catch(t){return console.error("API Request failed:",t),{success:!1,error:t instanceof Error?t.message:"Network error occurred"}}}async getBusinesses(){return this.request("/v1/businesses/")}async getBusiness(t){return this.request(`/v1/businesses/${t}/`)}async createBusiness(t){return this.request("/v1/businesses/",{method:"POST",body:JSON.stringify(t)})}async updateBusiness(t,e){return this.request(`/v1/businesses/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async getBusinessStats(t){return this.request(`/v1/businesses/${t}/stats/`)}async lookupBusinessByExternalId(t){return this.request(`/v1/businesses/lookup/?external_id=${encodeURIComponent(t)}`)}async getInvoices(t,e){const r=new URLSearchParams({business_id:t});return e?.status&&r.append("status",e.status),e?.customer_id&&r.append("customer_id",e.customer_id),e?.date_from&&r.append("date_from",e.date_from),e?.date_to&&r.append("date_to",e.date_to),e?.overdue&&r.append("overdue","true"),e?.outstanding&&r.append("outstanding","true"),e?.search&&r.append("search",e.search),this.request(`/invoices/?${r.toString()}`)}async getInvoice(t){return this.request(`/invoices/${t}/`)}async createInvoice(t){return this.request("/invoices/",{method:"POST",body:JSON.stringify(t)})}async updateInvoice(t,e){return this.request(`/invoices/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async deleteInvoice(t){return this.request(`/invoices/${t}/`,{method:"DELETE"})}async recordInvoicePayment(t,e){return this.request(`/invoices/${t}/payment/`,{method:"POST",body:JSON.stringify(e)})}async sendInvoice(t){return this.request(`/invoices/${t}/send/`,{method:"POST"})}async getInvoicePayments(t){return this.request(`/invoices/${t}/payments/list/`)}async getCustomers(t){return this.request(`/customers/?business_id=${t}`)}async getCustomer(t){return this.request(`/customers/${t}/`)}async createCustomer(t){return this.request("/customers/",{method:"POST",body:JSON.stringify(t)})}async updateCustomer(t,e){return this.request(`/customers/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async archiveCustomer(t){return this.request(`/customers/${t}/archive/`,{method:"POST"})}async reactivateCustomer(t){return this.request(`/customers/${t}/reactivate/`,{method:"POST"})}async getAccounts(t,e){const r=new URLSearchParams({business_id:t});return e?.account_type&&r.append("account_type",e.account_type),void 0!==e?.is_active&&r.append("is_active",e.is_active.toString()),e?.search&&r.append("search",e.search),this.request(`/accounts/?${r.toString()}`)}async getAccount(t){return this.request(`/accounts/${t}/`)}async createAccount(t){return this.request("/accounts/",{method:"POST",body:JSON.stringify(t)})}async updateAccount(t,e){return this.request(`/accounts/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async deleteAccount(t){return this.request(`/accounts/${t}/`,{method:"DELETE"})}async getBankAccounts(t){return this.request(`/accounts/bank/?business_id=${t}`)}async getAccountHierarchy(t){return this.request(`/accounts/hierarchy/?business_id=${t}`)}async syncAccount(t){return this.request(`/accounts/${t}/sync/`,{method:"POST"})}async getPayments(t,e){const r=new URLSearchParams({business_id:t});return e?.status&&r.append("status",e.status),e?.customer_id&&r.append("customer_id",e.customer_id),e?.date_from&&r.append("date_from",e.date_from),e?.date_to&&r.append("date_to",e.date_to),e?.search&&r.append("search",e.search),this.request(`/payments/?${r.toString()}`)}async getPayment(t){return this.request(`/payments/${t}/`)}async createPayment(t){return this.request("/payments/",{method:"POST",body:JSON.stringify(t)})}async updatePayment(t,e){return this.request(`/payments/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async completePayment(t){return this.request(`/payments/${t}/complete/`,{method:"POST"})}async failPayment(t){return this.request(`/payments/${t}/fail/`,{method:"POST"})}async getBalanceSheet(t,e){const r=new URLSearchParams({business_id:t});return e&&r.append("effective_date",e),this.request(`/reports/balance-sheet/?${r.toString()}`)}async getPnLData(t,e,r){const s=new URLSearchParams({business_id:t,date_from:e,date_to:r});return this.request(`/reports/pnl/?${s.toString()}`)}async getCashFlowData(t,e,r){const s=new URLSearchParams({business_id:t,date_from:e,date_to:r});return this.request(`/reports/cash-flow/?${s.toString()}`)}async healthCheck(){return this.request("/health/")}formatCurrency(t,e="GBP"){const r="number"==typeof t?t:parseFloat(t.toString());return new Intl.NumberFormat("en-GB",{style:"currency",currency:e}).format(r)}formatDate(t){return new Date(t).toLocaleDateString("en-GB",{year:"numeric",month:"short",day:"numeric"})}validateBusinessAccess(t){return this.config.businessId===t||!!t}handleApiError(t){let e="An unexpected error occurred";return 401===t.response?.status?e="Authentication failed. Check your API key.":404===t.response?.status?e="Business not found or not accessible.":403===t.response?.status?e="Permission denied. Business not accessible.":t.response?.data?.error&&(e=t.response.data.error),{success:!1,error:e,details:t.response?.data?.details}}}class gt extends nt{constructor(){super(...arguments),this.apiKey="",this.businessId="",this.theme="light",this.baseUrl="http://localhost:8000/api",this.loading=!1,this.error=null,this.apiClient=null}connectedCallback(){super.connectedCallback(),this.initializeApiClient(),this.loadData()}initializeApiClient(){if("undefined"!=typeof window&&window.FridayProvider){const t=window.FridayProvider.getApiClient();if(t)return void(this.apiClient=t);const e=window.FridayProvider.getWidgetConfig();if(e)return void(this.apiClient=new ut({baseURL:e.baseUrl,apiKey:e.apiKey,businessId:e.businessId}))}this.apiKey?this.apiClient=new ut({baseURL:this.baseUrl,apiKey:this.apiKey,businessId:this.businessId||void 0}):this.setError("API key is required. Configure FridayProvider or provide api-key attribute.")}async loadData(){}setError(t){if(this.error=t,this.loading=!1,this.emitEvent("error",{message:t}),"undefined"!=typeof window&&window.FridayProvider)try{window.FridayProvider.handleError(new Error(t))}catch(t){}}clearError(){this.error=null}handleApiError(t,e="API request"){let r=`${e} failed`;t?.error?r=t.error:t?.message?r=t.message:"string"==typeof t&&(r=t),t?.details&&(r+=` (${t.details})`),this.setError(r),this.emitEvent("api-error",{context:e,error:t,message:r})}async makeApiRequest(t,e="Request"){try{if(this.setLoading(!0),!this.apiClient)throw new Error("API client not initialized");const r=await t();return r.success?(this.clearError(),r.data||null):(this.handleApiError(r,e),null)}catch(t){return this.handleApiError(t,e),null}finally{this.setLoading(!1)}}setLoading(t){this.loading=t,t&&this.clearError()}emitEvent(t,e={}){const r={type:t,data:e,timestamp:Date.now()};this.dispatchEvent(new CustomEvent(`friday-${t}`,{detail:r,bubbles:!0,composed:!0}))}renderLoading(){return B`
<div class="Friday__loading">
<div class="Friday__spinner"></div>
<span>Loading...</span>
</div>
`}renderError(){return B`
<div class="Friday__error">
<span>⚠️ ${this.error}</span>
</div>
`}static get baseStyles(){return n`
@import url('https://rsms.me/inter/inter.css');
:host {
display: block;
/* Friday Design System - Layer Financial Inspired */
--color-black: #1a1a1a;
--color-white: white;
--color-info: #0968f8;
--color-info-bg: #d6e6ff;
--color-info-fg: #0056d7;
--color-success: hsl(145deg 45% 42%);
--color-success-bg: hsl(145deg 59% 86%);
--color-success-fg: hsl(145deg 63% 29%);
--color-warning: hsl(43deg 100% 44%);
--color-warning-bg: hsl(43deg 100% 84%);
--color-warning-fg: hsl(43deg 88% 26%);
--color-error: hsl(0deg 76% 50%);
--color-error-bg: hsl(0deg 83% 86%);
--color-error-fg: hsl(0deg 88% 32%);
--color-dark-h: 220;
--color-dark-s: 15%;
--color-dark-l: 7%;
--color-dark: hsl(var(--color-dark-h) var(--color-dark-s) var(--color-dark-l));
--color-base-0: #fff;
--color-base-50: hsl(var(--color-dark-h) 5% 98%);
--color-base-100: hsl(var(--color-dark-h) 5% 95%);
--color-base-200: hsl(var(--color-dark-h) 5% 91%);
--color-base-300: hsl(var(--color-dark-h) 6% 85%);
--color-base-400: hsl(var(--color-dark-h) 7% 75%);
--color-base-500: hsl(var(--color-dark-h) 8% 50%);
--color-base-600: hsl(var(--color-dark-h) 10% 40%);
--color-base-700: hsl(var(--color-dark-h) 12% 27%);
--color-base-800: hsl(var(--color-dark-h) 15% 20%);
--color-base-900: hsl(var(--color-dark-h) 18% 14%);
--text-color-primary: var(--color-dark);
--text-color-secondary: var(--color-base-600);
--text-color-muted: var(--color-base-500);
--text-color-inverse: var(--color-white);
--bg-primary: var(--color-base-0);
--bg-secondary: var(--color-base-50);
--bg-tertiary: var(--color-base-100);
--bg-element-hover: var(--color-base-100);
--border-primary: var(--color-base-200);
--border-secondary: var(--color-base-300);
--border-focus: var(--color-info);
--font-family: 'InterVariable', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
--text-2xs: 10px;
--text-xs: 11px;
--text-sm: 12px;
--text-md: 14px;
--text-lg: 16px;
--text-xl: 18px;
--text-2xl: 20px;
--text-3xl: 24px;
--font-weight-normal: 460;
--font-weight-medium: 500;
--font-weight-semibold: 540;
--font-weight-bold: 600;
--spacing-2xs: 6px;
--spacing-xs: 8px;
--spacing-sm: 12px;
--spacing-md: 16px;
--spacing-lg: 20px;
--spacing-xl: 24px;
--spacing-2xl: 32px;
--spacing-3xl: 40px;
--spacing-4xl: 48px;
--radius-sm: 6px;
--radius-md: 8px;
--radius-lg: 12px;
--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--transition-fast: 150ms ease;
}
.Friday__component {
font-family: var(--font-family);
font-size: var(--text-md);
line-height: 1.5;
color: var(--text-color-primary);
background: var(--bg-primary);
border: 1px solid var(--border-primary);
border-radius: var(--radius-md);
box-shadow: var(--shadow-sm);
overflow: hidden;
}
.Friday__loading {
display: flex;
align-items: center;
justify-content: center;
padding: var(--spacing-4xl);
color: var(--text-color-muted);
font-size: var(--text-sm);
gap: var(--spacing-xs);
}
.Friday__spinner {
width: 20px;
height: 20px;
border: 2px solid var(--border-primary);
border-top-color: var(--color-info);
border-radius: 50%;
animation: Friday__spin 1s linear infinite;
}
@keyframes Friday__spin {
to { transform: rotate(360deg); }
}
.Friday__error {
display: flex;
align-items: center;
gap: var(--spacing-xs);
padding: var(--spacing-md);
margin: var(--spacing-md);
background: var(--color-error-bg);
color: var(--color-error-fg);
border: 1px solid var(--color-error);
border-radius: var(--radius-sm);
font-size: var(--text-sm);
}
.Friday__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: var(--spacing-lg) var(--spacing-xl);
border-bottom: 1px solid var(--border-primary);
background: var(--bg-secondary);
}
.Friday__header-title {
font-size: var(--text-xl);
font-weight: var(--font-weight-semibold);
color: var(--text-color-primary);
margin: 0;
}
.Friday__header-actions {
display: flex;
align-items: center;
gap: var(--spacing-sm);
}
.Friday__content {
padding: var(--spacing-xl);
}
.Friday__button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--spacing-xs);
padding: var(--spacing-xs) var(--spacing-md);
border: 1px solid transparent;
border-radius: var(--radius-sm);
font-family: var(--font-family);
font-size: var(--text-sm);
font-weight: var(--font-weight-medium);
line-height: 1.5;
text-decoration: none;
cursor: pointer;
transition: all var(--transition-fast);
white-space: nowrap;
user-select: none;
}
.Friday__button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.Friday__button--primary {
background: var(--color-info);
color: var(--text-color-inverse);
border-color: var(--color-info);
}
.Friday__button--primary:hover:not(:disabled) {
background: var(--color-info-fg);
border-color: var(--color-info-fg);
}
.Friday__button--secondary {
background: var(--bg-primary);
color: var(--text-color-primary);
border-color: var(--border-primary);
}
.Friday__button--secondary:hover:not(:disabled) {
background: var(--bg-element-hover);
border-color: var(--border-secondary);
}
.Friday__button--success {
background: var(--color-success);
color: var(--text-color-inverse);
border-color: var(--color-success);
}
.Friday__button--success:hover:not(:disabled) {
background: var(--color-success-fg);
border-color: var(--color-success-fg);
}
.Friday__button--error {
background: var(--color-error);
color: var(--text-color-inverse);
border-color: var(--color-error);
}
.Friday__button--sm {
padding: var(--spacing-2xs) var(--spacing-sm);
font-size: var(--text-xs);
}
.Friday__input {
display: block;
width: 100%;
padding: var(--spacing-xs) var(--spacing-sm);
border: 1px solid var(--border-primary);
border-radius: var(--radius-sm);
font-family: var(--font-family);
font-size: var(--text-sm);
line-height: 1.5;
color: var(--text-color-primary);
background: var(--bg-primary);
transition: all var(--transition-fast);
}
.Friday__input:focus {
outline: none;
border-color: var(--border-focus);
box-shadow: 0 0 0 3px hsla(217, 100%, 50%, 0.1);
}
.Friday__select {
display: block;
width: 100%;
padding: var(--spacing-xs) var(--spacing-sm);
border: 1px solid var(--border-primary);
border-radius: var(--radius-sm);
font-family: var(--font-family);
font-size: var(--text-sm);
color: var(--text-color-primary);
background: var(--bg-primary);
cursor: pointer;
transition: all var(--transition-fast);
}
.Friday__table {
width: 100%;
border-collapse: collapse;
font-size: var(--text-sm);
}
.Friday__table th,
.Friday__table td {
padding: var(--spacing-sm) var(--spacing-md);
text-align: left;
border-bottom: 1px solid var(--border-primary);
}
.Friday__table th {
font-weight: var(--font-weight-semibold);
color: var(--text-color-secondary);
background: var(--bg-secondary);
font-size: var(--text-xs);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.Friday__table tbody tr:hover {
background: var(--bg-element-hover);
}
.Friday__badge {
display: inline-flex;
align-items: center;
padding: 2px var(--spacing-xs);
border-radius: 9999px;
font-size: var(--text-2xs);
font-weight: var(--font-weight-medium);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.Friday__badge--success {
background: var(--color-success-bg);
color: var(--color-success-fg);
}
.Friday__badge--warning {
background: var(--color-warning-bg);
color: var(--color-warning-fg);
}
.Friday__badge--error {
background: var(--color-error-bg);
color: var(--color-error-fg);
}
.Friday__badge--info {
background: var(--color-info-bg);
color: var(--color-info-fg);
}
/* Typography utilities */
.Friday__text-xs { font-size: var(--text-xs); }
.Friday__text-sm { font-size: var(--text-sm); }
.Friday__text-md { font-size: var(--text-md); }
.Friday__text-lg { font-size: var(--text-lg); }
.Friday__text-muted { color: var(--text-color-muted); }
.Friday__text-secondary { color: var(--text-color-secondary); }
.Friday__font-medium { font-weight: var(--font-weight-medium); }
.Friday__font-semibold { font-weight: var(--font-weight-semibold); }
.Friday__font-bold { font-weight: var(--font-weight-bold); }
@media (max-width: 768px) {
.Friday__component {
border-radius: 0;
border-left: none;
border-right: none;
box-shadow: none;
}
.Friday__header {
padding: var(--spacing-md) var(--spacing-lg);
}
.Friday__content {
padding: var(--spacing-lg);
}
.Friday__table th,
.Friday__table td {
padding: var(--spacing-xs) var(--spacing-sm);
}
}
`}}return e([ht({type:String,attribute:"api-key"})],gt.prototype,"apiKey",void 0),e([ht({type:String,attribute:"business-id"})],gt.prototype,"businessId",void 0),e([ht({type:String})],gt.prototype,"theme",void 0),e([ht({type:String,attribute:"base-url"})],gt.prototype,"baseUrl",void 0),e([pt()],gt.prototype,"loading",void 0),e([pt()],gt.prototype,"error",void 0),t.CashFlowStatementWidget=class extends gt{constructor(){super(...arguments),this.defaultDatePickerMode="monthPicker",this.allowedDatePickerModes=["monthPicker","quarterPicker","yearPicker"],this.label="Select Period",this.showDemo=!1,this.cashFlowData=null,this.selectedDateMode="monthPicker",this.expandedItems=new Set(["operating","investing","financing"])}static get styles(){return[gt.baseStyles,n`
.Friday__cash-flow-container {
padding: var(--spacing-lg);
}
.Friday__cash-flow-controls {
display: flex;
align-items: center;
gap: var(--spacing-md);
margin-bottom: var(--spacing-lg);
flex-wrap: wrap;
}
.Friday__date-picker-group {
display: flex;
align-items: center;
gap: var(--spacing-sm);
}
.Friday__date-picker-label {
font-size: var(--text-sm);
font-weight: var(--font-weight-medium);
color: var(--text-color-primary);
}
.Friday__date-picker-select {
padding: var(--spacing-sm) var(--spacing-md);
border: 1px solid var(--border-primary);
border-radius: var(--radius-sm);
background: var(--bg-primary);
color: var(--text-color-primary);
font-size: var(--text-sm);
cursor: pointer;
transition: border-color var(--transition-fast);
}
.Friday__date-picker-select:hover {
border-color: var(--color-primary);
}
.Friday__date-picker-select:focus {
outline: none;
border-color: var(--color-primary);
box-shadow: 0 0 0 3px var(--color-primary-bg);
}
.Friday__cash-flow-table-wrapper {
background: var(--bg-primary);
border: 1px solid var(--border-primary);
border-radius: var(--radius-md);
overflow: hidden;
}
.Friday__cash-flow-table {
width: 100%;
border-collapse: collapse;
font-size: var(--text-sm);
}
.Friday__cash-flow-table-header {
background: var(--bg-secondary);
border-bottom: 2px solid var(--border-primary);
}
.Friday__cash-flow-table-header th {
padding: var(--spacing-lg) var(--spacing-md);
text-align: left;
font-weight: var(--font-weight-semibold);
color: var(--text-color-primary);
font-size: var(--text-xs);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.Friday__cash-flow-table-header th:last-child {
text-align: right;
}
.Friday__cash-flow-section-header {
background: var(--color-info-bg);
border-bottom: 1px solid var(--color-info);
font-weight: var(--font-weight-bold);
color: var(--color-info-fg);
}
.Friday__cash-flow-table-row {
border-bottom: 1px solid var(--border-primary);
transition: background-color var(--transition-fast);
}
.Friday__cash-flow-table-row:hover {
background: var(--bg-element-hover);
}
.Friday__cash-flow-table-row--level-0 {
background: var(--bg-secondary);
font-weight: var(--font-weight-semibold);
}
.Friday__cash-flow-table-row--level-1 {
background: var(--bg-primary);
}
.Friday__cash-flow-table-row--level-2 {
background: var(--bg-primary);
color: var(--text-color-secondary);
}
.Friday__cash-flow-table-row--total {
background: var(--color-success-bg);
border-top: 2px solid var(--color-success);
font-weight: var(--font-weight-bold);
color: var(--color-success-fg);
}
.Friday__cash-flow-table-row--subtotal {
background: var(--bg-tertiary);
border-top: 1px solid var(--border-secondary);
font-weight: var(--font-weight-semibold);
}
.Friday__cash-flow-table-row--final-total {
background: var(--color-primary-bg);
border-top: 3px solid var(--color-primary);
border-bottom: 3px solid var(--color-primary);
font-weight: var(--font-weight-bold);
color: var(--color-primary-fg);
}
.Friday__cash-flow-table-cell {
padding: var(--spacing-md);
vertical-align: middle;
}
.Friday__cash-flow-table-cell--amount {
text-align: right;
font-family: var(--font-family-numeric);
font-weight: var(--font-weight-medium);
}
.Friday__cash-flow-table-cell--amount.positive {
color: var(--color-success-fg);
}
.Friday__cash-flow-table-cell--amount.negative {
color: var(--color-error-fg);
}
.Friday__cash-flow-item-name {
display: flex;
align-items: center;
gap: var(--spacing-xs);
}
.Friday__cash-flow-expand-button {
width: 20px;
height: 20px;
border: none;
background: transparent;
color: var(--text-color-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--radius-sm);
transition: all var(--transition-fast);
font-size: 12px;
}
.Friday__cash-flow-expand-button:hover {
background: var(--bg-element-hover);
color: var(--text-color-primary);
}
.Friday__cash-flow-expand-button.expanded {
transform: rotate(90deg);
}
.Friday__cash-flow-item-indent {
height: 1px;
}
.Friday__demo-notice {
background: var(--color-info-bg);
border: 1px solid var(--color-info);
color: var(--color-info-fg);
padding: var(--spacing-md);
border-radius: var(--radius-sm);
margin: var(--spacing-lg);
font-size: var(--text-sm);
text-align: center;
}
.Friday__cash-flow-summary {
padding: var(--spacing-lg);
background: var(--bg-secondary);
border-top: 1px solid var(--border-primary);
display: flex;
justify-content: space-between;
align-items: center;
font-size: var(--text-sm);
color: var(--text-color-secondary);
}
.Friday__cash-flow-method-note {
padding: var(--spacing-md);
background: var(--bg-tertiary);
border-left: 4px solid var(--color-primary);
margin: var(--spacing-lg);
font-size: var(--text-xs);
color: var(--text-color-secondary);
font-style: italic;
}
@media (max-width: 768px) {
.Friday__cash-flow-container {
padding: var(--spacing-md);
}
.Friday__cash-flow-controls {
flex-direction: column;
align-items: stretch;
}
.Friday__cash-flow-table-cell {
padding: var(--spacing-sm);
}
.Friday__cash-flow-table-header th {
padding: var(--spacing-md) var(--spacing-sm);
}
}
`]}async loadData(){if(this.apiClient){this.setLoading(!0);try{this.showDemo,this.loadDemoData(),this.emitEvent("cash-flow-loaded",{data:this.cashFlowData})}catch(t){this.setError("Failed to load cash flow statement data")}finally{this.setLoading(!1)}}}loadDemoData(){const t=this.startDate||"2024-01-01",e=this.endDate||"2024-12-31";this.cashFlowData={period:"Year Ended December 31, 2024",startDate:t,endDate:e,operatingActivities:{netIncome:{id:"net_income",name:"Net Income",amount:85e3,level:1,type:"item"},adjustments:{id:"adjustments",name:"Adjustments to reconcile net income",amount:45e3,level:1,type:"category",children:[{id:"depreciation",name:"Depreciation expense",amount:25e3,level:2,type:"item"},{id:"amortization",name:"Amortization expense",amount:8e3,level:2,type:"item"},{id:"bad_debt",name:"Bad debt expense",amount:12e3,level:2,type:"item"}]},workingCapitalChanges:{id:"working_capital",name:"Changes in working capital",amount:-18e3,level:1,type:"category",children:[{id:"accounts_receivable",name:"Increase in accounts receivable",amount:-25e3,level:2,type:"item"},{id:"inventory",name:"Increase in inventory",amount:-15e3,level:2,type:"item"},{id:"accounts_payable",name:"Increase in accounts payable",amount:22e3,level:2,type:"item"}]},totalOperating:{id:"total_operating",name:"Net cash provided by operating activities",amount:112e3,level:0,type:"subtotal"}},investingActivities:{items:[{id:"equipment_purchase",name:"Purchase of equipment",amount:-45e3,level:1,type:"item"},{id:"investment_sale",name:"Sale of investments",amount:15e3,level:1,type:"item"},{id:"software_purchase",name:"Purchase of software",amount:-12e3,level:1,type:"item"}],totalInvesting:{id:"total_investing",name:"Net cash used in investing activities",amount:-42e3,level:0,type:"subtotal"}},financingActivities:{items:[{id:"loan_proceeds",name:"Proceeds from bank loan",amount:5e4,level:1,type:"item"},{id:"loan_repayment",name:"Repayment of long-term debt",amount:-25e3,level:1,type:"item"},{id:"dividends",name:"Dividends paid",amount:-3e4,level:1,type:"item"},{id:"capital_contribution",name:"Owner capital contribution",amount:2e4,level:1,type:"item"}],totalFinancing:{id:"total_financing",name:"Net cash provided by financing activities",amount:15e3,level:0,type:"subtotal"}},netCashChange:{id:"net_change",name:"Net increase in cash and cash equivalents",amount:85e3,level:0,type:"total"},beginningCash:{id:"beginning_cash",name:"Cash and cash equivalents at beginning of period",amount:125e3,level:0,type:"item"},endingCash:{id:"ending_cash",name:"Cash and cash equivalents at end of period",amount:21e4,level:0,type:"total"}}}toggleExpand(t){this.expandedItems.has(t)?this.expandedItems.delete(t):this.expandedItems.add(t),this.requestUpdate()}isExpanded(t){return this.expandedItems.has(t)}getAmountClass(t){return t>0?"positive":t<0?"negative":""}onDateModeChange(t){const e=t.target;this.selectedDateMode=e.value,this.emitEvent("date-picker-mode-changed",{mode:this.selectedDateMode}),this.loadData(),this.requestUpdate()}renderTableRow(t,e=!0){const r=[],s=t.children&&t.children.length>0,a=this.isExpanded(t.id);return r.push(B`
<tr class="Friday__cash-flow-table-row Friday__cash-flow-table-row--level-${t.level} Friday__cash-flow-table-row--${t.type}">
<td class="Friday__cash-flow-table-cell">
<div class="Friday__cash-flow-item-name">
<div class="Friday__cash-flow-item-indent" style="width: ${20*t.level}px;"></div>
${s?B`
<button
class="Friday__cash-flow-expand-button ${a?"expanded":""}"
@click=${()=>this.toggleExpand(t.id)}
>
▶
</button>
`:B`<div style="width: 20px;"></div>`}
${t.name}
</div>
</td>
<td class="Friday__cash-flow-table-cell Friday__cash-flow-table-cell--amount ${this.getAmountClass(t.amount)}">
${this.apiClient?.formatCurrency(100*Math.abs(t.amount),"GBP")}${t.amount<0?" (outflow)":""}
</td>
</tr>
`),s&&e&&a&&t.children.forEach(t=>{r.push(...this.renderTableRow(t,!0))}),r}renderSectionHeader(t){return B`
<tr class="Friday__cash-flow-section-header">
<td class="Friday__cash-flow-table-cell" colspan="2">
<strong>${t}</strong>
</td>
</tr>
`}renderAllRows(){if(!this.cashFlowData)return[];const t=[];t.push(this.renderSectionHeader("CASH FLOWS FROM OPERATING ACTIVITIES")),t.push(...this.renderTableRow(this.cashFlowData.operatingActivities.netIncome,!1)),t.push(...this.renderTableRow(this.cashFlowData.operatingActivities.adjustments)),t.push(...this.renderTableRow(this.cashFlowData.operatingActivities.workingCapitalChanges)),t.push(...this.renderTableRow(this.cashFlowData.operatingActivities.totalOperating,!1)),t.push(this.renderSectionHeader("CASH FLOWS FROM INVESTING ACTIVITIES")),this.cashFlowData.investingActivities.items.forEach(e=>{t.push(...this.renderTableRow(e,!1))}),t.push(...this.renderTableRow(this.cashFlowData.investingActivities.totalInvesting,!1)),t.push(this.renderSectionHeader("CASH FLOWS FROM FINANCING ACTIVITIES")),this.cashFlowData.financingActivities.items.forEach(e=>{t.push(...this.renderTableRow(e,!1))}),t.push(...this.renderTableRow(this.cashFlowData.financingActivities.totalFinancing,!1)),t.push(this.renderSectionHeader("NET CHANGE IN CASH"));const e=this.renderTableRow(this.cashFlowData.netCashChange,!1)[0],r=this.renderTableRow(this.cashFlowData.beginningCash,!1)[0];this.renderTableRow(this.cashFlowData.endingCash,!1)[0];const s=B`
<tr class="Friday__cash-flow-table-row Friday__cash-flow-table-row--final-total">
<td class="Friday__cash-flow-table-cell">
<div class="Friday__cash-flow-item-name">
<div style="width: 20px;"></div>
${this.cashFlowData.endingCash.name}
</div>
</td>
<td class="Friday__cash-flow-table-cell Friday__cash-flow-table-cell--amount ${this.getAmountClass(this.cashFlowData.endingCash.amount)}">
${this.apiClient?.formatCurrency(100*Math.abs(this.cashFlowData.endingCash.amount),"GBP")}
</td>
</tr>
`;return t.push(e),t.push(r),t.push(s),t}render(){return this.loading?B`<div class="Friday__component">${this.renderLoading()}</div>`:this.error?B`<div class="Friday__component">${this.renderError()}</div>`:B`
<div class="Friday__component">
<div class="Friday__header">
<h2 class="Friday__header-title">Cash Flow Statement</h2>
</div>
${this.showDemo?B`
<div class="Friday__demo-notice">
<strong>Demo Mode:</strong> Showing sample cash flow statement data using the indirect method
</div>