@sparkle-learning/core 0.0.53 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{PrivateRoute-074c584e.js → PrivateRoute-f97245ce.js} +18 -30
- package/dist/cjs/{feed.service-b4f09441.js → appdata.service-c8d71e05.js} +4 -56
- package/dist/cjs/{assets.service-0c759d51.js → assets.service-bfa75092.js} +1 -1
- package/dist/cjs/assignment.service-690fb59c.js +19 -0
- package/dist/cjs/{environment-config.service-0e02b049.js → environment-config.service-c8ff1f3d.js} +0 -1
- package/dist/cjs/{facilitator.service-9e990274.js → facilitator.service-ff0e1659.js} +1 -1
- package/dist/cjs/feed.service-8eca4de6.js +57 -0
- package/dist/cjs/header-mobile-collapse_61.cjs.entry.js +76 -87
- package/dist/cjs/{httpService-7211d93b.js → httpService-d2e7bf8f.js} +13 -11
- package/dist/cjs/index.cjs.js +5 -4
- package/dist/cjs/{ion-action-sheet_4.cjs.entry.js → ion-action-sheet_7.cjs.entry.js} +728 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/media.service-8a1b9bc5.js +40 -0
- package/dist/cjs/{signalR.service-5672eebc.js → signalR.service-bd6b42f9.js} +18 -20
- package/dist/cjs/sparkle-animation-player.cjs.entry.js +1 -1
- package/dist/cjs/sparkle-assignment.cjs.entry.js +110 -0
- package/dist/cjs/sparkle-character-intro.cjs.entry.js +2 -2
- package/dist/cjs/sparkle-core.cjs.js +1 -1
- package/dist/cjs/sparkle-discussion-questions_2.cjs.entry.js +20 -11
- package/dist/cjs/sparkle-discussion.cjs.entry.js +6 -4
- package/dist/cjs/sparkle-facilitator-notes-form.cjs.entry.js +5 -3
- package/dist/cjs/sparkle-feed-post.cjs.entry.js +116 -0
- package/dist/cjs/sparkle-feedback.cjs.entry.js +5 -3
- package/dist/cjs/sparkle-file-upload.cjs.entry.js +53 -0
- package/dist/cjs/sparkle-goal-form.cjs.entry.js +11 -8
- package/dist/cjs/sparkle-input.cjs.entry.js +56 -0
- package/dist/cjs/sparkle-quiz-container.cjs.entry.js +1 -1
- package/dist/cjs/sparkle-quiz-old.cjs.entry.js +120 -0
- package/dist/cjs/sparkle-quiz.cjs.entry.js +31 -48
- package/dist/cjs/{student.service-2e58f237.js → student.service-7e5385be.js} +1 -1
- package/dist/cjs/token.service-7a41953d.js +97 -0
- package/dist/cjs/{util-d383acb8.js → util-47e320b2.js} +2 -2
- package/dist/collection/PrivateRoute.js +2 -2
- package/dist/collection/collection-manifest.json +5 -2
- package/dist/collection/components/layout/facilitator/facilitator-page.js +2 -3
- package/dist/collection/components/layout/page/page.css +4 -0
- package/dist/collection/components/layout/page/page.js +39 -26
- package/dist/collection/components/sparkle-assignment/sparkle-assignment.css +30 -0
- package/dist/collection/components/sparkle-assignment/sparkle-assignment.js +159 -0
- package/dist/collection/components/sparkle-character-intro/sparkle-character-intro.css +8 -1
- package/dist/collection/components/sparkle-character-intro/sparkle-character-intro.js +10 -6
- package/dist/collection/components/sparkle-course-root/sparkle-course-root.js +13 -2
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.js +4 -2
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.js +15 -9
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.css +5 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.js +5 -3
- package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.js +54 -75
- package/dist/collection/components/sparkle-file-upload/sparkle-file-upload.css +0 -0
- package/dist/collection/components/sparkle-file-upload/sparkle-file-upload.js +105 -0
- package/dist/collection/components/sparkle-input/sparkle-input.css +0 -0
- package/dist/collection/components/sparkle-input/sparkle-input.js +212 -0
- package/dist/collection/components/sparkle-login/sparkle-login.js +2 -1
- package/dist/collection/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.css → sparkle-quiz-old/sparkle-quiz-old.css} +1 -1
- package/dist/collection/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.js → sparkle-quiz-old/sparkle-quiz-old.js} +4 -4
- package/dist/collection/components/sparkle-quiz/{sparkle-quiz-v1.js → sparkle-quiz.js} +23 -25
- package/dist/collection/components/sparkle-quiz-container/sparkle-quiz-container.js +1 -1
- package/dist/collection/components/sparkle-root/sparkle-root.js +12 -10
- package/dist/collection/services/assignment.service.js +14 -0
- package/dist/collection/services/auth/auth.service.js +15 -14
- package/dist/collection/services/environment/environment-config.js +1 -1
- package/dist/collection/services/environment/environment-config.service.js +0 -1
- package/dist/collection/services/httpService.js +12 -10
- package/dist/collection/services/signalR.service.js +17 -19
- package/dist/collection/services/token.service.js +79 -0
- package/dist/collection/util.js +5 -2
- package/dist/esm/{PrivateRoute-c5441f35.js → PrivateRoute-90ac95b8.js} +17 -29
- package/dist/esm/{feed.service-8fbe4ce3.js → appdata.service-2e84e167.js} +5 -55
- package/dist/esm/{assets.service-66e848b8.js → assets.service-def1d63c.js} +1 -1
- package/dist/esm/assignment.service-8d31f141.js +17 -0
- package/dist/esm/{environment-config.service-2b5d692b.js → environment-config.service-b191f276.js} +0 -1
- package/dist/esm/{facilitator.service-b0292f7f.js → facilitator.service-18c47bdf.js} +1 -1
- package/dist/esm/feed.service-b4f3cae4.js +54 -0
- package/dist/esm/header-mobile-collapse_61.entry.js +71 -82
- package/dist/esm/{httpService-7b75b095.js → httpService-7986aeed.js} +14 -12
- package/dist/esm/index.js +6 -5
- package/dist/esm/{ion-action-sheet_4.entry.js → ion-action-sheet_7.entry.js} +729 -4
- package/dist/esm/ion-loading.entry.js +1 -1
- package/dist/esm/ion-menu.entry.js +1 -1
- package/dist/esm/ion-modal.entry.js +1 -1
- package/dist/esm/ion-picker.entry.js +1 -1
- package/dist/esm/ion-toast.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/media.service-6e90bc41.js +37 -0
- package/dist/esm/{overlays-3b4dca92.js → overlays-4233a39d.js} +1 -1
- package/dist/esm/{signalR.service-9d5b9f36.js → signalR.service-c33fba50.js} +18 -20
- package/dist/esm/sparkle-animation-player.entry.js +1 -1
- package/dist/esm/sparkle-assignment.entry.js +106 -0
- package/dist/esm/sparkle-character-intro.entry.js +3 -3
- package/dist/esm/sparkle-core.js +1 -1
- package/dist/esm/sparkle-discussion-questions_2.entry.js +20 -11
- package/dist/esm/sparkle-discussion.entry.js +6 -4
- package/dist/esm/sparkle-facilitator-notes-form.entry.js +6 -4
- package/dist/esm/sparkle-feed-post.entry.js +112 -0
- package/dist/esm/sparkle-feedback.entry.js +6 -4
- package/dist/esm/sparkle-file-upload.entry.js +49 -0
- package/dist/esm/sparkle-goal-form.entry.js +9 -6
- package/dist/esm/sparkle-input.entry.js +52 -0
- package/dist/esm/sparkle-quiz-container.entry.js +1 -1
- package/dist/esm/sparkle-quiz-old.entry.js +116 -0
- package/dist/esm/sparkle-quiz.entry.js +31 -48
- package/dist/esm/{student.service-0746418b.js → student.service-08af124f.js} +1 -1
- package/dist/esm/token.service-71a5d33f.js +94 -0
- package/dist/esm/{util-6ef753e9.js → util-57cc8006.js} +2 -2
- package/dist/sparkle-core/index.esm.js +1 -1
- package/dist/sparkle-core/p-08420531.entry.js +1 -0
- package/dist/sparkle-core/p-08cca80d.entry.js +1 -0
- package/dist/sparkle-core/p-0e8e539f.entry.js +1 -0
- package/dist/sparkle-core/p-13ec39db.entry.js +1 -0
- package/dist/sparkle-core/p-1adc98f6.js +1 -0
- package/dist/sparkle-core/p-38c842d5.entry.js +1 -0
- package/dist/sparkle-core/{p-fbccd30c.js → p-39a31e43.js} +1 -1
- package/dist/sparkle-core/{p-0a5d7c4f.entry.js → p-3daf2915.entry.js} +26 -26
- package/dist/sparkle-core/{p-9a443f51.js → p-408176ba.js} +1 -1
- package/dist/sparkle-core/p-42ed7d5f.entry.js +1 -0
- package/dist/sparkle-core/p-4b4a8703.js +1 -0
- package/dist/sparkle-core/p-4d1cfcbe.entry.js +1 -0
- package/dist/sparkle-core/p-4fba3e4c.js +1 -0
- package/dist/sparkle-core/{p-54dd894f.entry.js → p-6bde0192.entry.js} +1 -1
- package/dist/sparkle-core/{p-6faa194c.entry.js → p-6d2f4093.entry.js} +1 -1
- package/dist/sparkle-core/{p-162bff1a.entry.js → p-72053ae0.entry.js} +1 -1
- package/dist/sparkle-core/p-7dae0f0e.js +1 -0
- package/dist/sparkle-core/{p-18cdd458.entry.js → p-85d4cd5c.entry.js} +1 -1
- package/dist/sparkle-core/p-973fe404.entry.js +22 -0
- package/dist/sparkle-core/{p-ff0e0d4e.entry.js → p-98daeddb.entry.js} +1 -1
- package/dist/sparkle-core/p-b06e2bef.js +1 -0
- package/dist/sparkle-core/{p-e863bf1d.entry.js → p-b6fec622.entry.js} +1 -1
- package/dist/sparkle-core/p-b8d71ff4.js +1 -0
- package/dist/sparkle-core/p-bd90903e.js +1 -0
- package/dist/sparkle-core/{p-a49ab4e8.entry.js → p-c64a34cd.entry.js} +1 -1
- package/dist/sparkle-core/{p-5efc6566.js → p-c9f753a4.js} +1 -1
- package/dist/sparkle-core/p-da391f3f.js +1 -0
- package/dist/sparkle-core/p-e0cad1bb.js +1 -0
- package/dist/sparkle-core/{p-ce4b22f7.entry.js → p-f196c124.entry.js} +1 -1
- package/dist/sparkle-core/p-f47fe1fe.entry.js +1 -0
- package/dist/sparkle-core/p-f714f77a.entry.js +1 -0
- package/dist/sparkle-core/p-f891c79a.entry.js +1 -0
- package/dist/sparkle-core/{p-377b04c2.entry.js → p-ff080f82.entry.js} +1 -1
- package/dist/sparkle-core/{p-2ff67662.js → p-ff7a8a71.js} +1 -1
- package/dist/sparkle-core/sparkle-core.esm.js +1 -1
- package/dist/types/components/layout/page/page.d.ts +2 -0
- package/dist/types/components/sparkle-assignment/sparkle-assignment.d.ts +16 -0
- package/dist/types/components/sparkle-course-root/sparkle-course-root.d.ts +1 -0
- package/dist/types/components/sparkle-feed-post/sparkle-feed-post.d.ts +4 -3
- package/dist/types/components/sparkle-file-upload/sparkle-file-upload.d.ts +15 -0
- package/dist/types/components/sparkle-input/sparkle-input.d.ts +23 -0
- package/dist/types/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.d.ts → sparkle-quiz-old/sparkle-quiz-old.d.ts} +1 -1
- package/dist/types/components/sparkle-quiz/{sparkle-quiz-v1.d.ts → sparkle-quiz.d.ts} +1 -1
- package/dist/types/components.d.ts +111 -36
- package/dist/types/models/class.model.d.ts +4 -0
- package/dist/types/services/assignment.service.d.ts +8 -0
- package/dist/types/services/auth/auth.service.d.ts +1 -1
- package/dist/types/services/environment/environment-config.d.ts +3 -0
- package/dist/types/services/token.service.d.ts +13 -0
- package/dist/types/util.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/ion-select_3.cjs.entry.js +0 -618
- package/dist/cjs/ion-textarea.cjs.entry.js +0 -248
- package/dist/cjs/sparkle-quiz-v1.cjs.entry.js +0 -105
- package/dist/esm/ion-select_3.entry.js +0 -612
- package/dist/esm/ion-textarea.entry.js +0 -244
- package/dist/esm/sparkle-quiz-v1.entry.js +0 -101
- package/dist/sparkle-core/p-0f1c5899.entry.js +0 -18
- package/dist/sparkle-core/p-1d4c7c11.js +0 -1
- package/dist/sparkle-core/p-30767c1c.entry.js +0 -1
- package/dist/sparkle-core/p-3265ed87.entry.js +0 -1
- package/dist/sparkle-core/p-370609ba.entry.js +0 -1
- package/dist/sparkle-core/p-44334ef3.entry.js +0 -4
- package/dist/sparkle-core/p-462bffba.js +0 -1
- package/dist/sparkle-core/p-4c9f994f.js +0 -1
- package/dist/sparkle-core/p-58e4bbe5.entry.js +0 -1
- package/dist/sparkle-core/p-600cf6a3.js +0 -1
- package/dist/sparkle-core/p-641bfc92.entry.js +0 -1
- package/dist/sparkle-core/p-80d6b0e6.entry.js +0 -1
- package/dist/sparkle-core/p-af3cc111.entry.js +0 -1
- package/dist/sparkle-core/p-b226f54d.js +0 -1
- /package/dist/collection/components/sparkle-quiz/{sparkle-quiz-v1.css → sparkle-quiz.css} +0 -0
- /package/dist/sparkle-core/{p-935e7cfc.js → p-8b56f734.js} +0 -0
@@ -1,4 +0,0 @@
|
|
1
|
-
import{r as t,i as e,h as i,H as s,e as n}from"./p-ee1e0eb4.js";import{g as o}from"./p-871106e0.js";import{f as a,k as r,b as l,d}from"./p-d68092b7.js";import{f as c,h,a as p}from"./p-2ff67662.js";import{h as u}from"./p-0e4de1d0.js";import{E as g}from"./p-b226f54d.js";import"./p-2f569553.js";import"./p-add30d46.js";
|
2
|
-
/*!
|
3
|
-
* (C) Ionic http://ionicframework.com - MIT License
|
4
|
-
*/const m=(t,e)=>{if(1===t.nodeType)return(t.tagName===e.toUpperCase()?[t]:Array.from(t.querySelectorAll(e))).find((e=>e.value===t.value))},b=class{constructor(i){t(this,i),this.ionChange=e(this,"ionChange",7),this.ionCancel=e(this,"ionCancel",7),this.ionDismiss=e(this,"ionDismiss",7),this.ionFocus=e(this,"ionFocus",7),this.ionBlur=e(this,"ionBlur",7),this.ionStyle=e(this,"ionStyle",7),this.inputId="ion-sel-"+C++,this.didInit=!1,this.isExpanded=!1,this.disabled=!1,this.cancelText="Cancel",this.okText="OK",this.name=this.inputId,this.multiple=!1,this.interface="alert",this.interfaceOptions={},this.onClick=t=>{this.setFocus(),this.open(t)},this.onFocus=()=>{this.ionFocus.emit()},this.onBlur=()=>{this.ionBlur.emit()}}styleChanged(){this.emitStyle()}valueChanged(){this.emitStyle(),this.didInit&&this.ionChange.emit({value:this.value})}async connectedCallback(){this.updateOverlayOptions(),this.emitStyle(),this.mutationO=((t,e,i)=>{if("undefined"==typeof MutationObserver)return;const s=new MutationObserver((t=>{i(((t,e)=>{let i;t.forEach((t=>{for(let s=0;s<t.addedNodes.length;s++)i=m(t.addedNodes[s],e)||i}))})(t,"ion-select-option"))}));return s.observe(t,{childList:!0,subtree:!0}),s})(this.el,0,(async()=>{this.updateOverlayOptions()}))}disconnectedCallback(){this.mutationO&&(this.mutationO.disconnect(),this.mutationO=void 0)}componentDidLoad(){this.didInit=!0}async open(t){if(this.disabled||this.isExpanded)return;this.isExpanded=!0;const e=this.overlay=await this.createOverlay(t);if(e.onDidDismiss().then((()=>{this.overlay=void 0,this.isExpanded=!1,this.ionDismiss.emit(),this.setFocus()})),await e.present(),"popover"===this.interface){let t=this.childOpts.map((t=>t.value)).indexOf(this.value);t=t>-1?t:0;const i=e.querySelector(`.select-interface-option:nth-child(${t+1})`);i&&a(i)}return e}createOverlay(t){let e=this.interface;return"action-sheet"===e&&this.multiple&&(console.warn(`Select interface cannot be "${e}" with a multi-value select. Using the "alert" interface instead.`),e="alert"),"popover"!==e||t||(console.warn(`Select interface cannot be a "${e}" without passing an event. Using the "alert" interface instead.`),e="alert"),"action-sheet"===e?this.openActionSheet():"popover"===e?this.openPopover(t):this.openAlert()}updateOverlayOptions(){const t=this.overlay;if(!t)return;const e=this.childOpts,i=this.value;switch(this.interface){case"action-sheet":t.buttons=this.createActionSheetButtons(e,i);break;case"popover":const s=t.querySelector("ion-select-popover");s&&(s.options=this.createPopoverOptions(e,i));break;case"alert":t.inputs=this.createAlertInputs(e,this.multiple?"checkbox":"radio",i)}}createActionSheetButtons(t,e){const i=t.map((t=>{const i=v(t),s=Array.from(t.classList).filter((t=>"hydrated"!==t)).join(" "),n=`${j} ${s}`;return{role:f(e,i,this.compareWith)?"selected":"",text:t.textContent,cssClass:n,handler:()=>{this.value=i}}}));return i.push({text:this.cancelText,role:"cancel",handler:()=>{this.ionCancel.emit()}}),i}createAlertInputs(t,e,i){return t.map((t=>{const s=v(t),n=Array.from(t.classList).filter((t=>"hydrated"!==t)).join(" ");return{type:e,cssClass:`${j} ${n}`,label:t.textContent||"",value:s,checked:f(i,s,this.compareWith),disabled:t.disabled}}))}createPopoverOptions(t,e){return t.map((t=>{const i=v(t),s=Array.from(t.classList).filter((t=>"hydrated"!==t)).join(" ");return{text:t.textContent||"",cssClass:`${j} ${s}`,value:i,checked:f(e,i,this.compareWith),disabled:t.disabled,handler:t=>{this.value=t,this.multiple||this.close()}}}))}async openPopover(t){const e=this.interfaceOptions,i=o(this),s="md"!==i,n=this.multiple,a=this.value;let r=t,l="auto";const d=this.el.closest("ion-item");d&&(d.classList.contains("item-label-floating")||d.classList.contains("item-label-stacked"))&&(r=Object.assign(Object.assign({},t),{detail:{ionShadowTarget:d}}),l="cover");const h=Object.assign(Object.assign({mode:i,event:r,alignment:"center",size:l,showBackdrop:s},e),{component:"ion-select-popover",cssClass:["select-popover",e.cssClass],componentProps:{header:e.header,subHeader:e.subHeader,message:e.message,multiple:n,value:a,options:this.createPopoverOptions(this.childOpts,a)}});return c.create(h)}async openActionSheet(){const t=o(this),e=this.interfaceOptions,i=Object.assign(Object.assign({mode:t},e),{buttons:this.createActionSheetButtons(this.childOpts,this.value),cssClass:["select-action-sheet",e.cssClass]});return h.create(i)}async openAlert(){const t=this.getLabel(),e=t?t.textContent:null,i=this.interfaceOptions,s=this.multiple?"checkbox":"radio",n=o(this),a=Object.assign(Object.assign({mode:n},i),{header:i.header?i.header:e,inputs:this.createAlertInputs(this.childOpts,s,this.value),buttons:[{text:this.cancelText,role:"cancel",handler:()=>{this.ionCancel.emit()}},{text:this.okText,handler:t=>{this.value=t}}],cssClass:["select-alert",i.cssClass,this.multiple?"multiple-select-alert":"single-select-alert"]});return p.create(a)}close(){return this.overlay?this.overlay.dismiss():Promise.resolve(!1)}getLabel(){return r(this.el)}hasValue(){return""!==this.getText()}get childOpts(){return Array.from(this.el.querySelectorAll("ion-select-option"))}getText(){const t=this.selectedText;return null!=t&&""!==t?t:w(this.childOpts,this.value,this.compareWith)}setFocus(){this.focusEl&&this.focusEl.focus()}emitStyle(){this.ionStyle.emit({interactive:!0,"interactive-disabled":this.disabled,select:!0,"select-disabled":this.disabled,"has-placeholder":void 0!==this.placeholder,"has-value":this.hasValue(),"has-focus":this.isExpanded})}render(){const{disabled:t,el:e,inputId:n,isExpanded:a,name:r,placeholder:c,value:h}=this,p=o(this),{labelText:g,labelId:m}=l(e,n);d(!0,e,r,x(h),t);let b=!1,f=this.getText();""===f&&void 0!==c&&(f=c,b=!0);const v={"select-text":!0,"select-placeholder":b},y=b?"placeholder":"text",w=void 0!==g?""!==f?`${f}, ${g}`:g:f;return i(s,{onClick:this.onClick,role:"button","aria-haspopup":"listbox","aria-disabled":t?"true":null,"aria-label":w,class:{[p]:!0,"in-item":u("ion-item",e),"select-disabled":t,"select-expanded":a}},i("div",{"aria-hidden":"true",class:v,part:y},f),i("div",{class:"select-icon",role:"presentation",part:"icon"},i("div",{class:"select-icon-inner"})),i("label",{id:m},w),i("button",{type:"button",disabled:t,id:n,"aria-labelledby":m,"aria-haspopup":"listbox","aria-expanded":`${a}`,onFocus:this.onFocus,onBlur:this.onBlur,ref:t=>this.focusEl=t}))}get el(){return n(this)}static get watchers(){return{disabled:["styleChanged"],placeholder:["styleChanged"],isExpanded:["styleChanged"],value:["valueChanged"]}}},f=(t,e,i)=>void 0!==t&&(Array.isArray(t)?t.some((t=>y(t,e,i))):y(t,e,i)),v=t=>{const e=t.value;return void 0===e?t.textContent||"":e},x=t=>{if(null!=t)return Array.isArray(t)?t.join(","):t.toString()},y=(t,e,i)=>"function"==typeof i?i(t,e):"string"==typeof i?t[i]===e[i]:Array.isArray(e)?e.includes(t):t===e,w=(t,e,i)=>void 0===e?"":Array.isArray(e)?e.map((e=>k(t,e,i))).filter((t=>null!==t)).join(", "):k(t,e,i)||"",k=(t,e,i)=>{const s=t.find((t=>y(v(t),e,i)));return s?s.textContent:null};let C=0;const j="select-interface-option";b.style={ios:":host{--placeholder-color:currentColor;--placeholder-opacity:0.33;padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);display:flex;position:relative;align-items:center;font-family:var(--ion-font-family, inherit);overflow:hidden;z-index:2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){:host{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}:host(.in-item){position:static;max-width:45%}:host(.select-disabled){opacity:0.4;pointer-events:none}:host(.ion-focused) button{border:2px solid #5e9ed6}.select-placeholder{color:var(--placeholder-color);opacity:var(--placeholder-opacity)}label{left:0;top:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;position:absolute;width:100%;height:100%;border:0;background:transparent;cursor:pointer;appearance:none;outline:none;display:flex;align-items:center;opacity:0}[dir=rtl] label,:host-context([dir=rtl]) label{left:unset;right:unset;right:0}label::-moz-focus-inner{border:0}button{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;margin:0;padding:0;border:0;outline:0;clip:rect(0 0 0 0);opacity:0;overflow:hidden;-webkit-appearance:none;-moz-appearance:none}.select-icon{position:relative}.select-text{flex:1;min-width:16px;font-size:inherit;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.select-icon-inner{left:5px;top:50%;margin-top:-2px;position:absolute;width:0;height:0;border-top:5px solid;border-right:5px solid transparent;border-left:5px solid transparent;color:currentColor;pointer-events:none}[dir=rtl] .select-icon-inner,:host-context([dir=rtl]) .select-icon-inner{left:unset;right:unset;right:5px}:host{--padding-top:10px;--padding-end:10px;--padding-bottom:10px;--padding-start:20px}.select-icon{width:12px;height:18px;opacity:0.33}",md:":host{--placeholder-color:currentColor;--placeholder-opacity:0.33;padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);display:flex;position:relative;align-items:center;font-family:var(--ion-font-family, inherit);overflow:hidden;z-index:2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){:host{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}:host(.in-item){position:static;max-width:45%}:host(.select-disabled){opacity:0.4;pointer-events:none}:host(.ion-focused) button{border:2px solid #5e9ed6}.select-placeholder{color:var(--placeholder-color);opacity:var(--placeholder-opacity)}label{left:0;top:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;position:absolute;width:100%;height:100%;border:0;background:transparent;cursor:pointer;appearance:none;outline:none;display:flex;align-items:center;opacity:0}[dir=rtl] label,:host-context([dir=rtl]) label{left:unset;right:unset;right:0}label::-moz-focus-inner{border:0}button{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;margin:0;padding:0;border:0;outline:0;clip:rect(0 0 0 0);opacity:0;overflow:hidden;-webkit-appearance:none;-moz-appearance:none}.select-icon{position:relative}.select-text{flex:1;min-width:16px;font-size:inherit;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.select-icon-inner{left:5px;top:50%;margin-top:-2px;position:absolute;width:0;height:0;border-top:5px solid;border-right:5px solid transparent;border-left:5px solid transparent;color:currentColor;pointer-events:none}[dir=rtl] .select-icon-inner,:host-context([dir=rtl]) .select-icon-inner{left:unset;right:unset;right:5px}:host{--padding-top:10px;--padding-end:0;--padding-bottom:10px;--padding-start:16px}.select-icon{width:19px;height:19px;transition:transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);opacity:0.55}:host-context(.item-label-stacked) .select-icon,:host-context(.item-label-floating:not(.item-fill-outline)) .select-icon,:host-context(.item-label-floating.item-fill-outline){transform:translate3d(0, -9px, 0)}:host-context(.item-has-focus) .select-icon{transform:rotate(180deg)}:host-context(.item-has-focus.item-label-stacked) .select-icon,:host-context(.item-has-focus.item-label-floating:not(.item-fill-outline)) .select-icon{transform:translate3d(0, -9px, 0) rotate(180deg)}:host-context(ion-item.ion-focused) .select-icon,:host-context(.item-has-focus) .select-icon{color:var(--highlight-color-focused);opacity:1}"};const P=class{constructor(e){t(this,e),this.inputId="ion-selopt-"+O++,this.disabled=!1}render(){return i(s,{role:"option",id:this.inputId,class:o(this)})}get el(){return n(this)}};let O=0;P.style=":host{display:none}";const A=class{constructor(e){t(this,e)}componentDidLoad(){this.postText=this.textValue,this.ref&&this.ref.innerText&&(this.assignmentName=this.ref.innerText,console.log(this.assignmentName))}setText(t){this.postText=t}isAuthenticated(){try{var t=g.getInstance().get("sparkle");if(t&&t.auth&&t.auth.getToken())return!0}catch(t){return!1}}submitPost(){this.errorMessage="",this.successMessage="",this.el.getElementsByClassName("PostExternalUrl"),this.el.getElementsByClassName("IsPublic")}uploadImage(t){}selectFile(){document.getElementById("fileInput").click()}renderUserInfo(){var t={Token:null,ProfileImageUrl:null};return null!=t&&t.Token?i("ion-avatar",{class:"header-avatar",slot:"end"},i("img",{src:"/assets/img/avatar.png"})):i("ion-button",{slot:"end",href:"/login"},"Login to Post")}render(){const t=this.renderUserInfo();return i(s,null,i("div",{class:"assignment-name",ref:t=>this.ref=t},i("slot",null)),i("ion-card",null,i("ion-item",{class:"header",lines:"full"},t),i("ion-card-content",null,i("form",null,i("ion-list",null,i("ion-item",{class:"padding"},i("ion-textarea",{class:"PostText",required:!0,placeholder:"Post Text",name:"PostText",value:this.postText})),i("ion-item",{class:"padding"},i("ion-input",{class:"PostExternalUrl",required:!0,type:"text",placeholder:"URL",name:"ExternalResourceUrl",value:this.externalResourceUrl})),this.uploadedImage?i("ion-item",{class:"padding"},i("img",{class:"uploaded-image",src:this.uploadedImage})):"",i("ion-item",{lines:"none"},i("input",{type:"file",id:"fileInput",onChange:t=>this.uploadImage(t),style:{display:"none"},accept:"image/*"}),this.uploadImageLoading?i("ion-spinner",{color:"primary"}):"",i("ion-button",{slot:"start",onClick:()=>this.selectFile()},i("ion-icon",{name:"add"}),"Upload Image")),i("div",{class:"public-post-toggle"},i("ion-toggle",{class:"IsPublic",color:"primary",name:"IsPublic"}),i("div",null,"Public Post")),i("div",{class:"post-footer-container"},i("div",{class:"post-footer"},i("div",null,i("div",{class:"error"},this.errorMessage),i("div",{class:"success"},this.successMessage)),i("ion-button",{slot:"end",size:"default",onClick:()=>this.submitPost(),disabled:!this.isAuthenticated()},"Post"))))))))}get el(){return n(this)}};A.style=":host{display:block}.post-footer-container{display:flex;justify-content:flex-end}.post-footer{display:flex;justify-content:space-between;align-items:center}.error{color:red;margin-right:10px}.success{color:green;margin-right:10px}.uploaded-image{display:block;max-height:140px;width:auto !important}.public-post-toggle{display:flex;justify-content:flex-end;align-items:center}.assignment-name{display:none}";export{b as ion_select,P as ion_select_option,A as sparkle_feed_post}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{c as t,h as e}from"./p-ee1e0eb4.js";import{s as r,r as n,g as a}from"./p-5d409601.js";import{H as o}from"./p-1d4c7c11.js";import{A as s}from"./p-2f569553.js";const i=new class{constructor(){this.sample=t=>t[Math.floor(Math.random()*t.length)],this.keyBy=(t,e,r)=>t.reduce(((t,n)=>(t[e(n)]=r?r(n):n,t)),{}),this.debounce=(t,e)=>{let r=null;return(...n)=>{clearTimeout(r),r=setTimeout(t,e,...n)}}}loadScript(t){var e=document.createElement("script");e.type="text/javascript",e.src=t,document.body.appendChild(e)}loadScriptAsync(t){return new Promise((function(e,r){const n=document.createElement("script");let a=!1;n.type="text/javascript",n.src=t,n.async=!0,n.onerror=function(t){r(t)},n.onload=n.onreadystatechange=function(){a||this.readyState&&"complete"!=this.readyState||(a=!0,e(!0))};const o=document.getElementsByTagName("script")[0];o.parentElement.insertBefore(n,o)}))}extend(...t){let e,r,n,a,o,s,i,c=t[0]||{},l=1,u=t.length,p=!1;for("boolean"==typeof c&&(p=c,c=t[l]||{},l++),"object"!=typeof c&&"function"!=typeof c&&(c={}),l===u&&(c=this,l--);l<u;l++)if(null!==(e=t[l]))for(r in e)n=c[r],o=e[r],c!==o&&(a=Array.isArray(n)?"array":typeof n,p&&o&&((s=Array.isArray(o))||"object"==typeof o)?(s?(s=!1,i=n&&"array"===a?n:[]):i=n&&"object"===a?n:{},c[r]=this.extend(p,i,o)):void 0!==o&&(c[r]=o));return c}setLocalization(){if(!sparkle.utils.getCookieValue("Sparkle.Localization.CultureName")){let t=navigator.language;sparkle.utils.setCookieValue("Sparkle.Localization.CultureName",t,new Date((new Date).getTime()+15768e7),sparkle.appPath)}}};async function c(t){if(!window)return;const e=window,r=e.Sparkle;if(!r||!r.config||"Object"===r.config.constructor.name)return e.Sparkle=e.Sparkle||{},e.Sparkle.config=Object.assign(Object.assign({},e.Sparkle.config),t),e.Sparkle.config;console.error("Sparkle config was already initialized")}async function l(e){await i.loadScriptAsync(t("../assets/lib/sparkle.js")),await c(e)}const u="enc_auth_token";class p{constructor(){}static getInstance(){return p.instance||(p.instance=new p),p.instance}async authenticate(t){const e={"Content-Type":"application/json"};let n;s.state.loading=!0;try{if(n=await o.http.post("api/Account/Authenticate",t,{headers:e}),n){const e=n.Data,a={Id:e.Id,UserName:e.UserName,Email:e.Email,Roles:e.Roles,IsVerified:e.IsVerified,JWToken:e.JWToken,IssuedOn:e.IssuedOn,ExpiresOn:e.ExpiresOn,RefreshToken:e.RefreshToken,PhotoUrl:"",IsFacilitator:e.Roles.indexOf("Facilitator")>0},o=t.RememberClient?new Date(a.ExpiresOn):void 0;return sparkle.auth.setToken(a.JWToken,o),sparkle.utils.setCookieValue(u,a.JWToken,o,sparkle.appPath),await r("CurrentUser",a),s.state.authUser=Object.assign({},a),s.state.loading=!1,a}}catch(t){return s.state.loading=!1,t}}async signOut(){await n("CurrentUser"),sessionStorage.clear(),sparkle.auth.clearToken(),s.state.authUser=null,s.state.isAuthenticated=!1}async getLocalAuthUser(){return a("CurrentUser")}}const f=t=>{var{component:r,permission:n,render:a}=t,o=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(t);a<n.length;a++)e.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(t,n[a])&&(r[n[a]]=t[n[a]])}return r}(t,["component","permission","render"]);const i=r;return e("stencil-route",Object.assign({},o,{routeRender:t=>s.state.isAuthenticated?n&&!sparkle.auth.isGranted(n)?e("stencil-router-redirect",{url:"/unauthorized"}):i?e(i,Object.assign({},t,t.componentProps)):a(t):e("stencil-router-redirect",{url:"/login"})}))};export{p as A,f as P,l as i,c as s}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{E as t}from"./p-b226f54d.js";import{d as e}from"./p-2f569553.js";class s extends Error{constructor(t,e){const s=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=s}}class n extends Error{constructor(t="A timeout occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class i extends Error{constructor(t="An abort occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class r extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=s}}class o extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=s}}class h extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=s}}class c extends Error{constructor(t){const e=new.target.prototype;super(t),this.errorType="FailedToNegotiateWithServerError",this.__proto__=e}}class a extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=s}}class l{constructor(t,e,s){this.statusCode=t,this.statusText=e,this.content=s}}class u{get(t,e){return this.send({...e,method:"GET",url:t})}post(t,e){return this.send({...e,method:"POST",url:t})}delete(t,e){return this.send({...e,method:"DELETE",url:t})}getCookieString(t){return""}}var d,p,f;!function(t){t[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None"}(d||(d={}));class w{constructor(){}log(t,e){}}w.instance=new w;class g{static isRequired(t,e){if(null==t)throw new Error(`The '${e}' argument is required.`)}static isNotEmpty(t,e){if(!t||t.match(/^\s*$/))throw new Error(`The '${e}' argument should not be empty.`)}static isIn(t,e,s){if(!(t in e))throw new Error(`Unknown ${s} value: ${t}.`)}}class m{static get isBrowser(){return"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return"object"==typeof self&&"importScripts"in self}static get isReactNative(){return"object"==typeof window&&void 0===window.document}static get isNode(){return!this.isBrowser&&!this.isWebWorker&&!this.isReactNative}}function y(t,e){let s="";return b(t)?(s=`Binary data of length ${t.byteLength}`,e&&(s+=`. Content: '${function(t){const e=new Uint8Array(t);let s="";return e.forEach((t=>{s+=`0x${t<16?"0":""}${t.toString(16)} `})),s.substr(0,s.length-1)}(t)}'`)):"string"==typeof t&&(s=`String data of length ${t.length}`,e&&(s+=`. Content: '${t}'`)),s}function b(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function v(t,e,s,n,i,r,o){let h={};if(i){const t=await i();t&&(h={Authorization:`Bearer ${t}`})}const[c,a]=C();h[c]=a,t.log(d.Trace,`(${e} transport) sending data. ${y(r,o.logMessageContent)}.`);const l=b(r)?"arraybuffer":"text",u=await s.post(n,{content:r,headers:{...h,...o.headers},responseType:l,timeout:o.timeout,withCredentials:o.withCredentials});t.log(d.Trace,`(${e} transport) request complete. Response status: ${u.statusCode}.`)}class ${constructor(t,e){this._subject=t,this._observer=e}dispose(){const t=this._subject.observers.indexOf(this._observer);t>-1&&this._subject.observers.splice(t,1),0===this._subject.observers.length&&this._subject.cancelCallback&&this._subject.cancelCallback().catch((()=>{}))}}class E{constructor(t){this._minLevel=t,this.out=console}log(t,e){if(t>=this._minLevel){const s=`[${(new Date).toISOString()}] ${d[t]}: ${e}`;switch(t){case d.Critical:case d.Error:this.out.error(s);break;case d.Warning:this.out.warn(s);break;case d.Information:this.out.info(s);break;default:this.out.log(s)}}}}function C(){let t="X-SignalR-User-Agent";return m.isNode&&(t="User-Agent"),[t,S("6.0.3",k(),m.isNode?"NodeJS":"Browser",_())]}function S(t,e,s,n){let i="Microsoft SignalR/";const r=t.split(".");return i+=`${r[0]}.${r[1]}`,i+=` (${t}; `,i+=e&&""!==e?`${e}; `:"Unknown OS; ",i+=`${s}`,i+=n?`; ${n}`:"; Unknown Runtime Version",i+=")",i}function k(){if(!m.isNode)return"";switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}function _(){if(m.isNode)return process.versions.node}function P(t){return t.stack?t.stack:t.message?t.message:`${t}`}class T extends u{constructor(t){if(super(),this._logger=t,"undefined"==typeof fetch){const t="function"==typeof __webpack_require__?__non_webpack_require__:require;this._jar=new(t("tough-cookie").CookieJar),this._fetchType=t("node-fetch"),this._fetchType=t("fetch-cookie")(this._fetchType,this._jar)}else this._fetchType=fetch.bind(function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("could not find global")}());if("undefined"==typeof AbortController){const t="function"==typeof __webpack_require__?__non_webpack_require__:require;this._abortControllerType=t("abort-controller")}else this._abortControllerType=AbortController}async send(t){if(t.abortSignal&&t.abortSignal.aborted)throw new i;if(!t.method)throw new Error("No method defined.");if(!t.url)throw new Error("No url defined.");const e=new this._abortControllerType;let r;t.abortSignal&&(t.abortSignal.onabort=()=>{e.abort(),r=new i});let o,h=null;t.timeout&&(h=setTimeout((()=>{e.abort(),this._logger.log(d.Warning,"Timeout from HTTP request."),r=new n}),t.timeout));try{o=await this._fetchType(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:e.signal})}catch(t){if(r)throw r;throw this._logger.log(d.Warning,`Error from HTTP request. ${t}.`),t}finally{h&&clearTimeout(h),t.abortSignal&&(t.abortSignal.onabort=null)}if(!o.ok){const t=await I(o,"text");throw new s(t||o.statusText,o.status)}const c=I(o,t.responseType),a=await c;return new l(o.status,o.statusText,a)}getCookieString(t){let e="";return m.isNode&&this._jar&&this._jar.getCookies(t,((t,s)=>e=s.join("; "))),e}}function I(t,e){let s;switch(e){case"arraybuffer":s=t.arrayBuffer();break;case"text":s=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`);default:s=t.text()}return s}class H extends u{constructor(t){super(),this._logger=t}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new i):t.method?t.url?new Promise(((e,r)=>{const o=new XMLHttpRequest;o.open(t.method,t.url,!0),o.withCredentials=void 0===t.withCredentials||t.withCredentials,o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-Type","text/plain;charset=UTF-8");const h=t.headers;h&&Object.keys(h).forEach((t=>{o.setRequestHeader(t,h[t])})),t.responseType&&(o.responseType=t.responseType),t.abortSignal&&(t.abortSignal.onabort=()=>{o.abort(),r(new i)}),t.timeout&&(o.timeout=t.timeout),o.onload=()=>{t.abortSignal&&(t.abortSignal.onabort=null),o.status>=200&&o.status<300?e(new l(o.status,o.statusText,o.response||o.responseText)):r(new s(o.response||o.responseText||o.statusText,o.status))},o.onerror=()=>{this._logger.log(d.Warning,`Error from HTTP request. ${o.status}: ${o.statusText}.`),r(new s(o.statusText,o.status))},o.ontimeout=()=>{this._logger.log(d.Warning,"Timeout from HTTP request."),r(new n)},o.send(t.content||"")})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class R extends u{constructor(t){if(super(),"undefined"!=typeof fetch||m.isNode)this._httpClient=new T(t);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this._httpClient=new H(t)}}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new i):t.method?t.url?this._httpClient.send(t):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(t){return this._httpClient.getCookieString(t)}}class D{static write(t){return`${t}${D.RecordSeparator}`}static parse(t){if(t[t.length-1]!==D.RecordSeparator)throw new Error("Message is incomplete.");const e=t.split(D.RecordSeparator);return e.pop(),e}}D.RecordSeparatorCode=30,D.RecordSeparator=String.fromCharCode(D.RecordSeparatorCode);class x{writeHandshakeRequest(t){return D.write(JSON.stringify(t))}parseHandshakeResponse(t){let e,s;if(b(t)){const n=new Uint8Array(t),i=n.indexOf(D.RecordSeparatorCode);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=String.fromCharCode.apply(null,Array.prototype.slice.call(n.slice(0,r))),s=n.byteLength>r?n.slice(r).buffer:null}else{const n=t,i=n.indexOf(D.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=n.substring(0,r),s=n.length>r?n.substring(r):null}const n=D.parse(e),i=JSON.parse(n[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[s,i]}}!function(t){t[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close"}(p||(p={}));class N{constructor(){this.observers=[]}next(t){for(const e of this.observers)e.next(t)}error(t){for(const e of this.observers)e.error&&e.error(t)}complete(){for(const t of this.observers)t.complete&&t.complete()}subscribe(t){return this.observers.push(t),new $(this,t)}}!function(t){t.Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting"}(f||(f={}));class q{constructor(t,e,s,n){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(d.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},g.isRequired(t,"connection"),g.isRequired(e,"logger"),g.isRequired(s,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this._logger=e,this._protocol=s,this.connection=t,this._reconnectPolicy=n,this._handshakeProtocol=new x,this.connection.onreceive=t=>this._processIncomingData(t),this.connection.onclose=t=>this._connectionClosed(t),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=f.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:p.Ping})}static create(t,e,s,n){return new q(t,e,s,n)}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(t){if(this._connectionState!==f.Disconnected&&this._connectionState!==f.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!t)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=t}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==f.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=f.Connecting,this._logger.log(d.Debug,"Starting HubConnection.");try{await this._startInternal(),m.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=f.Connected,this._connectionStarted=!0,this._logger.log(d.Debug,"HubConnection connected successfully.")}catch(t){return this._connectionState=f.Disconnected,this._logger.log(d.Debug,`HubConnection failed to start successfully because of error '${t}'.`),Promise.reject(t)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;const t=new Promise(((t,e)=>{this._handshakeResolver=t,this._handshakeRejecter=e}));await this.connection.start(this._protocol.transferFormat);try{const e={protocol:this._protocol.name,version:this._protocol.version};if(this._logger.log(d.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(e)),this._logger.log(d.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await t,this._stopDuringStartError)throw this._stopDuringStartError}catch(t){throw this._logger.log(d.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(t),t}}async stop(){const t=this._startPromise;this._stopPromise=this._stopInternal(),await this._stopPromise;try{await t}catch(t){}}_stopInternal(t){return this._connectionState===f.Disconnected?(this._logger.log(d.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve()):this._connectionState===f.Disconnecting?(this._logger.log(d.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState=f.Disconnecting,this._logger.log(d.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(d.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=t||new Error("The connection was stopped before the hub handshake could complete."),this.connection.stop(t)))}stream(t,...e){const[s,n]=this._replaceStreamingParams(e),i=this._createStreamInvocation(t,e,n);let r;const o=new N;return o.cancelCallback=()=>{const t=this._createCancelInvocation(i.invocationId);return delete this._callbacks[i.invocationId],r.then((()=>this._sendWithProtocol(t)))},this._callbacks[i.invocationId]=(t,e)=>{e?o.error(e):t&&(t.type===p.Completion?t.error?o.error(new Error(t.error)):o.complete():o.next(t.item))},r=this._sendWithProtocol(i).catch((t=>{o.error(t),delete this._callbacks[i.invocationId]})),this._launchStreams(s,r),o}_sendMessage(t){return this._resetKeepAliveInterval(),this.connection.send(t)}_sendWithProtocol(t){return this._sendMessage(this._protocol.writeMessage(t))}send(t,...e){const[s,n]=this._replaceStreamingParams(e),i=this._sendWithProtocol(this._createInvocation(t,e,!0,n));return this._launchStreams(s,i),i}invoke(t,...e){const[s,n]=this._replaceStreamingParams(e),i=this._createInvocation(t,e,!1,n);return new Promise(((t,e)=>{this._callbacks[i.invocationId]=(s,n)=>{n?e(n):s&&(s.type===p.Completion?s.error?e(new Error(s.error)):t(s.result):e(new Error(`Unexpected message type: ${s.type}`)))};const n=this._sendWithProtocol(i).catch((t=>{e(t),delete this._callbacks[i.invocationId]}));this._launchStreams(s,n)}))}on(t,e){t&&e&&(t=t.toLowerCase(),this._methods[t]||(this._methods[t]=[]),-1===this._methods[t].indexOf(e)&&this._methods[t].push(e))}off(t,e){if(!t)return;t=t.toLowerCase();const s=this._methods[t];if(s)if(e){const n=s.indexOf(e);-1!==n&&(s.splice(n,1),0===s.length&&delete this._methods[t])}else delete this._methods[t]}onclose(t){t&&this._closedCallbacks.push(t)}onreconnecting(t){t&&this._reconnectingCallbacks.push(t)}onreconnected(t){t&&this._reconnectedCallbacks.push(t)}_processIncomingData(t){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(t=this._processHandshakeResponse(t),this._receivedHandshakeResponse=!0),t){const e=this._protocol.parseMessages(t,this._logger);for(const t of e)switch(t.type){case p.Invocation:this._invokeClientMethod(t);break;case p.StreamItem:case p.Completion:{const e=this._callbacks[t.invocationId];if(e){t.type===p.Completion&&delete this._callbacks[t.invocationId];try{e(t)}catch(t){this._logger.log(d.Error,`Stream callback threw error: ${P(t)}`)}}break}case p.Ping:break;case p.Close:{this._logger.log(d.Information,"Close message received from server.");const e=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(e):this._stopPromise=this._stopInternal(e);break}default:this._logger.log(d.Warning,`Invalid message type: ${t.type}.`)}}this._resetTimeoutPeriod()}_processHandshakeResponse(t){let e,s;try{[s,e]=this._handshakeProtocol.parseHandshakeResponse(t)}catch(t){const e="Error parsing handshake response: "+t;this._logger.log(d.Error,e);const s=new Error(e);throw this._handshakeRejecter(s),s}if(e.error){const t="Server returned handshake error: "+e.error;this._logger.log(d.Error,t);const s=new Error(t);throw this._handshakeRejecter(s),s}return this._logger.log(d.Debug,"Server handshake complete."),this._handshakeResolver(),s}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this._timeoutHandle=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this._pingServerHandle))){let t=this._nextKeepAlive-(new Date).getTime();t<0&&(t=0),this._pingServerHandle=setTimeout((async()=>{if(this._connectionState===f.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}_invokeClientMethod(t){const e=this._methods[t.target.toLowerCase()];if(e){try{e.forEach((e=>e.apply(this,t.arguments)))}catch(e){this._logger.log(d.Error,`A callback for the method ${t.target.toLowerCase()} threw error '${e}'.`)}if(t.invocationId){const t="Server requested a response, which is not supported in this version of the client.";this._logger.log(d.Error,t),this._stopPromise=this._stopInternal(new Error(t))}}else this._logger.log(d.Warning,`No client method with the name '${t.target}' found.`)}_connectionClosed(t){this._logger.log(d.Debug,`HubConnection.connectionClosed(${t}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||t||new Error("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(t||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===f.Disconnecting?this._completeClose(t):this._connectionState===f.Connected&&this._reconnectPolicy?this._reconnect(t):this._connectionState===f.Connected&&this._completeClose(t)}_completeClose(t){if(this._connectionStarted){this._connectionState=f.Disconnected,this._connectionStarted=!1,m.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach((e=>e.apply(this,[t])))}catch(e){this._logger.log(d.Error,`An onclose callback called with error '${t}' threw error '${e}'.`)}}}async _reconnect(t){const e=Date.now();let s=0,n=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),i=this._getNextRetryDelay(s++,0,n);if(null===i)return this._logger.log(d.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this._completeClose(t);if(this._connectionState=f.Reconnecting,this._logger.log(d.Information,t?`Connection reconnecting because of error '${t}'.`:"Connection reconnecting."),0!==this._reconnectingCallbacks.length){try{this._reconnectingCallbacks.forEach((e=>e.apply(this,[t])))}catch(e){this._logger.log(d.Error,`An onreconnecting callback called with error '${t}' threw error '${e}'.`)}if(this._connectionState!==f.Reconnecting)return void this._logger.log(d.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==i;){if(this._logger.log(d.Information,`Reconnect attempt number ${s} will start in ${i} ms.`),await new Promise((t=>{this._reconnectDelayHandle=setTimeout(t,i)})),this._reconnectDelayHandle=void 0,this._connectionState!==f.Reconnecting)return void this._logger.log(d.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this._startInternal(),this._connectionState=f.Connected,this._logger.log(d.Information,"HubConnection reconnected successfully."),0!==this._reconnectedCallbacks.length)try{this._reconnectedCallbacks.forEach((t=>t.apply(this,[this.connection.connectionId])))}catch(t){this._logger.log(d.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${t}'.`)}return}catch(t){if(this._logger.log(d.Information,`Reconnect attempt failed because of error '${t}'.`),this._connectionState!==f.Reconnecting)return this._logger.log(d.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this._connectionState===f.Disconnecting&&this._completeClose());n=t instanceof Error?t:new Error(t.toString()),i=this._getNextRetryDelay(s++,Date.now()-e,n)}}this._logger.log(d.Information,`Reconnect retries have been exhausted after ${Date.now()-e} ms and ${s} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(t,e,s){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:e,previousRetryCount:t,retryReason:s})}catch(s){return this._logger.log(d.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${e}) threw error '${s}'.`),null}}_cancelCallbacksWithError(t){const e=this._callbacks;this._callbacks={},Object.keys(e).forEach((s=>{const n=e[s];try{n(null,t)}catch(e){this._logger.log(d.Error,`Stream 'error' callback called with '${t}' threw error: ${P(e)}`)}}))}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(t,e,s,n){if(s)return 0!==n.length?{arguments:e,streamIds:n,target:t,type:p.Invocation}:{arguments:e,target:t,type:p.Invocation};{const s=this._invocationId;return this._invocationId++,0!==n.length?{arguments:e,invocationId:s.toString(),streamIds:n,target:t,type:p.Invocation}:{arguments:e,invocationId:s.toString(),target:t,type:p.Invocation}}}_launchStreams(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const s in t)t[s].subscribe({complete:()=>{e=e.then((()=>this._sendWithProtocol(this._createCompletionMessage(s))))},error:t=>{let n;n=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this._sendWithProtocol(this._createCompletionMessage(s,n))))},next:t=>{e=e.then((()=>this._sendWithProtocol(this._createStreamItemMessage(s,t))))}})}}_replaceStreamingParams(t){const e=[],s=[];for(let n=0;n<t.length;n++){const i=t[n];if(this._isObservable(i)){const r=this._invocationId;this._invocationId++,e[r]=i,s.push(r.toString()),t.splice(n,1)}}return[e,s]}_isObservable(t){return t&&t.subscribe&&"function"==typeof t.subscribe}_createStreamInvocation(t,e,s){const n=this._invocationId;return this._invocationId++,0!==s.length?{arguments:e,invocationId:n.toString(),streamIds:s,target:t,type:p.StreamInvocation}:{arguments:e,invocationId:n.toString(),target:t,type:p.StreamInvocation}}_createCancelInvocation(t){return{invocationId:t,type:p.CancelInvocation}}_createStreamItemMessage(t,e){return{invocationId:t,item:e,type:p.StreamItem}}_createCompletionMessage(t,e,s){return e?{error:e,invocationId:t,type:p.Completion}:{invocationId:t,result:s,type:p.Completion}}}const U=[0,2e3,1e4,3e4,null];class A{constructor(t){this._retryDelays=void 0!==t?[...t,null]:U}nextRetryDelayInMilliseconds(t){return this._retryDelays[t.previousRetryCount]}}class L{}var M,W;L.Authorization="Authorization",L.Cookie="Cookie",function(t){t[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling"}(M||(M={})),function(t){t[t.Text=1]="Text",t[t.Binary=2]="Binary"}(W||(W={}));class F{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}}class O{constructor(t,e,s,n){this._httpClient=t,this._accessTokenFactory=e,this._logger=s,this._pollAbort=new F,this._options=n,this._running=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this._pollAbort.aborted}async connect(t,e){if(g.isRequired(t,"url"),g.isRequired(e,"transferFormat"),g.isIn(e,W,"transferFormat"),this._url=t,this._logger.log(d.Trace,"(LongPolling transport) Connecting."),e===W.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[n,i]=C(),r={[n]:i,...this._options.headers},o={abortSignal:this._pollAbort.signal,headers:r,timeout:1e5,withCredentials:this._options.withCredentials};e===W.Binary&&(o.responseType="arraybuffer");const h=await this._getAccessToken();this._updateHeaderToken(o,h);const c=`${t}&_=${Date.now()}`;this._logger.log(d.Trace,`(LongPolling transport) polling: ${c}.`);const a=await this._httpClient.get(c,o);200!==a.statusCode?(this._logger.log(d.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this._closeError=new s(a.statusText||"",a.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,o)}async _getAccessToken(){return this._accessTokenFactory?await this._accessTokenFactory():null}_updateHeaderToken(t,e){t.headers||(t.headers={}),e?t.headers[L.Authorization]=`Bearer ${e}`:t.headers[L.Authorization]&&delete t.headers[L.Authorization]}async _poll(t,e){try{for(;this._running;){const i=await this._getAccessToken();this._updateHeaderToken(e,i);try{const n=`${t}&_=${Date.now()}`;this._logger.log(d.Trace,`(LongPolling transport) polling: ${n}.`);const i=await this._httpClient.get(n,e);204===i.statusCode?(this._logger.log(d.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):200!==i.statusCode?(this._logger.log(d.Error,`(LongPolling transport) Unexpected response code: ${i.statusCode}.`),this._closeError=new s(i.statusText||"",i.statusCode),this._running=!1):i.content?(this._logger.log(d.Trace,`(LongPolling transport) data received. ${y(i.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(i.content)):this._logger.log(d.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this._running?t instanceof n?this._logger.log(d.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=t,this._running=!1):this._logger.log(d.Trace,`(LongPolling transport) Poll errored after shutdown: ${t.message}`)}}}finally{this._logger.log(d.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(t){return this._running?v(this._logger,"LongPolling",this._httpClient,this._url,this._accessTokenFactory,t,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(d.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(d.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const t={},[e,s]=C();t[e]=s;const n={headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials},i=await this._getAccessToken();this._updateHeaderToken(n,i),await this._httpClient.delete(this._url,n),this._logger.log(d.Trace,"(LongPolling transport) DELETE request sent.")}finally{this._logger.log(d.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this._closeError&&(t+=" Error: "+this._closeError),this._logger.log(d.Trace,t),this.onclose(this._closeError)}}}class j{constructor(t,e,s,n){this._httpClient=t,this._accessTokenFactory=e,this._logger=s,this._options=n,this.onreceive=null,this.onclose=null}async connect(t,e){if(g.isRequired(t,"url"),g.isRequired(e,"transferFormat"),g.isIn(e,W,"transferFormat"),this._logger.log(d.Trace,"(SSE transport) Connecting."),this._url=t,this._accessTokenFactory){const e=await this._accessTokenFactory();e&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`)}return new Promise(((s,n)=>{let i,r=!1;if(e===W.Text){if(m.isBrowser||m.isWebWorker)i=new this._options.EventSource(t,{withCredentials:this._options.withCredentials});else{const e=this._httpClient.getCookieString(t),s={};s.Cookie=e;const[n,r]=C();s[n]=r,i=new this._options.EventSource(t,{withCredentials:this._options.withCredentials,headers:{...s,...this._options.headers}})}try{i.onmessage=t=>{if(this.onreceive)try{this._logger.log(d.Trace,`(SSE transport) data received. ${y(t.data,this._options.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this._close(t)}},i.onerror=()=>{r?this._close():n(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},i.onopen=()=>{this._logger.log(d.Information,`SSE connected to ${this._url}`),this._eventSource=i,r=!0,s()}}catch(t){return void n(t)}}else n(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))}async send(t){return this._eventSource?v(this._logger,"SSE",this._httpClient,this._url,this._accessTokenFactory,t,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(t){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(t))}}class B{constructor(t,e,s,n,i,r){this._logger=s,this._accessTokenFactory=e,this._logMessageContent=n,this._webSocketConstructor=i,this._httpClient=t,this.onreceive=null,this.onclose=null,this._headers=r}async connect(t,e){if(g.isRequired(t,"url"),g.isRequired(e,"transferFormat"),g.isIn(e,W,"transferFormat"),this._logger.log(d.Trace,"(WebSockets transport) Connecting."),this._accessTokenFactory){const e=await this._accessTokenFactory();e&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`)}return new Promise(((s,n)=>{let i;t=t.replace(/^http/,"ws");const r=this._httpClient.getCookieString(t);let o=!1;if(m.isNode){const e={},[s,n]=C();e[s]=n,r&&(e[L.Cookie]=`${r}`),i=new this._webSocketConstructor(t,void 0,{headers:{...e,...this._headers}})}i||(i=new this._webSocketConstructor(t)),e===W.Binary&&(i.binaryType="arraybuffer"),i.onopen=()=>{this._logger.log(d.Information,`WebSocket connected to ${t}.`),this._webSocket=i,o=!0,s()},i.onerror=t=>{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this._logger.log(d.Information,`(WebSockets transport) ${e}.`)},i.onmessage=t=>{if(this._logger.log(d.Trace,`(WebSockets transport) data received. ${y(t.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this._close(t)}},i.onclose=t=>{if(o)this._close(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",n(new Error(e))}}}))}send(t){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(d.Trace,`(WebSockets transport) sending data. ${y(t,this._logMessageContent)}.`),this._webSocket.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(t){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(d.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this._isCloseEvent(t)||!1!==t.wasClean&&1e3===t.code?t instanceof Error?this.onclose(t):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${t.code} (${t.reason||"no reason given"}).`)))}_isCloseEvent(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class X{constructor(t,e={}){var s;if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,g.isRequired(t,"url"),this._logger=void 0===(s=e.logger)?new E(d.Information):null===s?w.instance:void 0!==s.log?s:new E(s),this.baseUrl=this._resolveUrl(t),(e=e||{}).logMessageContent=void 0!==e.logMessageContent&&e.logMessageContent,"boolean"!=typeof e.withCredentials&&void 0!==e.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");e.withCredentials=void 0===e.withCredentials||e.withCredentials,e.timeout=void 0===e.timeout?1e5:e.timeout;let n=null,i=null;if(m.isNode&&"undefined"!=typeof require){const t="function"==typeof __webpack_require__?__non_webpack_require__:require;n=t("ws"),i=t("eventsource")}m.isNode||"undefined"==typeof WebSocket||e.WebSocket?m.isNode&&!e.WebSocket&&n&&(e.WebSocket=n):e.WebSocket=WebSocket,m.isNode||"undefined"==typeof EventSource||e.EventSource?m.isNode&&!e.EventSource&&void 0!==i&&(e.EventSource=i):e.EventSource=EventSource,this._httpClient=e.httpClient||new R(this._logger),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=e,this.onreceive=null,this.onclose=null}async start(t){if(g.isIn(t=t||W.Binary,W,"transferFormat"),this._logger.log(d.Debug,`Starting connection with transfer format '${W[t]}'.`),"Disconnected"!==this._connectionState)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(t),await this._startInternalPromise,"Disconnecting"===this._connectionState){const t="Failed to start the HttpConnection before stop() was called.";return this._logger.log(d.Error,t),await this._stopPromise,Promise.reject(new Error(t))}if("Connected"!==this._connectionState){const t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(d.Error,t),Promise.reject(new Error(t))}this._connectionStarted=!0}send(t){return"Connected"!==this._connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new J(this.transport)),this._sendQueue.send(t))}async stop(t){return"Disconnected"===this._connectionState?(this._logger.log(d.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this._connectionState?(this._logger.log(d.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState="Disconnecting",this._stopPromise=new Promise((t=>{this._stopPromiseResolver=t})),await this._stopInternal(t),void await this._stopPromise)}async _stopInternal(t){this._stopError=t;try{await this._startInternalPromise}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this._logger.log(d.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(d.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(t){let e=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory;try{if(this._options.skipNegotiation){if(this._options.transport!==M.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this._constructTransport(M.WebSockets),await this._startTransport(e,t)}else{let s=null,n=0;do{if(s=await this._getNegotiationResponse(e),"Disconnecting"===this._connectionState||"Disconnected"===this._connectionState)throw new Error("The connection was stopped during negotiation.");if(s.error)throw new Error(s.error);if(s.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(s.url&&(e=s.url),s.accessToken){const t=s.accessToken;this._accessTokenFactory=()=>t}n++}while(s.url&&n<100);if(100===n&&s.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(e,this._options.transport,s,t)}this.transport instanceof O&&(this.features.inherentKeepAlive=!0),"Connecting"===this._connectionState&&(this._logger.log(d.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(t){return this._logger.log(d.Error,"Failed to start the connection: "+t),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(t)}}async _getNegotiationResponse(t){const e={};if(this._accessTokenFactory){const t=await this._accessTokenFactory();t&&(e[L.Authorization]=`Bearer ${t}`)}const[n,i]=C();e[n]=i;const r=this._resolveNegotiateUrl(t);this._logger.log(d.Debug,`Sending negotiation request: ${r}.`);try{const t=await this._httpClient.post(r,{content:"",headers:{...e,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(200!==t.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${t.statusCode}'`));const s=JSON.parse(t.content);return(!s.negotiateVersion||s.negotiateVersion<1)&&(s.connectionToken=s.connectionId),s}catch(t){let e="Failed to complete negotiation with the server: "+t;return t instanceof s&&404===t.statusCode&&(e+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(d.Error,e),Promise.reject(new c(e))}}_createConnectUrl(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async _createTransport(t,e,s,n){let i=this._createConnectUrl(t,s.connectionToken);if(this._isITransport(e))return this._logger.log(d.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=e,await this._startTransport(i,n),void(this.connectionId=s.connectionId);const r=[],o=s.availableTransports||[];let c=s;for(const s of o){const o=this._resolveTransportOrError(s,e,n);if(o instanceof Error)r.push(`${s.transport} failed:`),r.push(o);else if(this._isITransport(o)){if(this.transport=o,!c){try{c=await this._getNegotiationResponse(t)}catch(t){return Promise.reject(t)}i=this._createConnectUrl(t,c.connectionToken)}try{return await this._startTransport(i,n),void(this.connectionId=c.connectionId)}catch(t){if(this._logger.log(d.Error,`Failed to start the transport '${s.transport}': ${t}`),c=void 0,r.push(new h(`${s.transport} failed: ${t}`,M[s.transport])),"Connecting"!==this._connectionState){const t="Failed to select transport before stop() was called.";return this._logger.log(d.Debug,t),Promise.reject(new Error(t))}}}}return Promise.reject(r.length>0?new a(`Unable to connect to the server with any of the available transports. ${r.join(" ")}`,r):new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(t){switch(t){case M.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new B(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case M.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new j(this._httpClient,this._accessTokenFactory,this._logger,this._options);case M.LongPolling:return new O(this._httpClient,this._accessTokenFactory,this._logger,this._options);default:throw new Error(`Unknown transport: ${t}.`)}}_startTransport(t,e){return this.transport.onreceive=this.onreceive,this.transport.onclose=t=>this._stopConnection(t),this.transport.connect(t,e)}_resolveTransportOrError(t,e,s){const n=M[t.transport];if(null==n)return this._logger.log(d.Debug,`Skipping transport '${t.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${t.transport}' because it is not supported by this client.`);if(!function(t,e){return!t||0!=(e&t)}(e,n))return this._logger.log(d.Debug,`Skipping transport '${M[n]}' because it was disabled by the client.`),new o(`'${M[n]}' is disabled by the client.`,n);if(!(t.transferFormats.map((t=>W[t])).indexOf(s)>=0))return this._logger.log(d.Debug,`Skipping transport '${M[n]}' because it does not support the requested transfer format '${W[s]}'.`),new Error(`'${M[n]}' does not support ${W[s]}.`);if(n===M.WebSockets&&!this._options.WebSocket||n===M.ServerSentEvents&&!this._options.EventSource)return this._logger.log(d.Debug,`Skipping transport '${M[n]}' because it is not supported in your environment.'`),new r(`'${M[n]}' is not supported in your environment.`,n);this._logger.log(d.Debug,`Selecting transport '${M[n]}'.`);try{return this._constructTransport(n)}catch(t){return t}}_isITransport(t){return t&&"object"==typeof t&&"connect"in t}_stopConnection(t){if(this._logger.log(d.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this._connectionState}.`),this.transport=void 0,t=this._stopError||t,this._stopError=void 0,"Disconnected"!==this._connectionState){if("Connecting"===this._connectionState)throw this._logger.log(d.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this._connectionState&&this._stopPromiseResolver(),t?this._logger.log(d.Error,`Connection disconnected with error '${t}'.`):this._logger.log(d.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch((t=>{this._logger.log(d.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(t)}catch(e){this._logger.log(d.Error,`HttpConnection.onclose(${t}) threw error '${e}'.`)}}}else this._logger.log(d.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}_resolveUrl(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!m.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const e=window.document.createElement("a");return e.href=t,this._logger.log(d.Information,`Normalizing '${t}' to '${e.href}'.`),e.href}_resolveNegotiateUrl(t){const e=t.indexOf("?");let s=t.substring(0,-1===e?t.length:e);return"/"!==s[s.length-1]&&(s+="/"),s+="negotiate",s+=-1===e?"":t.substring(e),-1===s.indexOf("negotiateVersion")&&(s+=-1===e?"?":"&",s+="negotiateVersion="+this._negotiateVersion),s}}class J{constructor(t){this._transport=t,this._buffer=[],this._executing=!0,this._sendBufferedData=new z,this._transportResult=new z,this._sendLoopPromise=this._sendLoop()}send(t){return this._bufferData(t),this._transportResult||(this._transportResult=new z),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(t){if(this._buffer.length&&typeof this._buffer[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof t}`);this._buffer.push(t),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new z;const t=this._transportResult;this._transportResult=void 0;const e="string"==typeof this._buffer[0]?this._buffer.join(""):J._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(e),t.resolve()}catch(e){t.reject(e)}}}static _concatBuffers(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),s=new Uint8Array(e);let n=0;for(const e of t)s.set(new Uint8Array(e),n),n+=e.byteLength;return s.buffer}}class z{constructor(){this.promise=new Promise(((t,e)=>[this._resolver,this._rejecter]=[t,e]))}resolve(){this._resolver()}reject(t){this._rejecter(t)}}class V{constructor(){this.name="json",this.version=1,this.transferFormat=W.Text}parseMessages(t,e){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===e&&(e=w.instance);const s=D.parse(t),n=[];for(const t of s){const s=JSON.parse(t);if("number"!=typeof s.type)throw new Error("Invalid payload.");switch(s.type){case p.Invocation:this._isInvocationMessage(s);break;case p.StreamItem:this._isStreamItemMessage(s);break;case p.Completion:this._isCompletionMessage(s);break;case p.Ping:case p.Close:break;default:e.log(d.Information,"Unknown message type '"+s.type+"' ignored.");continue}n.push(s)}return n}writeMessage(t){return D.write(JSON.stringify(t))}_isInvocationMessage(t){this._assertNotEmptyString(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this._assertNotEmptyString(t.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(t){if(this._assertNotEmptyString(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this._assertNotEmptyString(t.error,"Invalid payload for Completion message."),this._assertNotEmptyString(t.invocationId,"Invalid payload for Completion message.")}_assertNotEmptyString(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const G={trace:d.Trace,debug:d.Debug,info:d.Information,information:d.Information,warn:d.Warning,warning:d.Warning,error:d.Error,critical:d.Critical,none:d.None};class K{configureLogging(t){if(g.isRequired(t,"logging"),void 0!==t.log)this.logger=t;else if("string"==typeof t){const e=function(t){const e=G[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new E(e)}else this.logger=new E(t);return this}withUrl(t,e){return g.isRequired(t,"url"),g.isNotEmpty(t,"url"),this.url=t,this.httpConnectionOptions="object"==typeof e?{...this.httpConnectionOptions,...e}:{...this.httpConnectionOptions,transport:e},this}withHubProtocol(t){return g.isRequired(t,"protocol"),this.protocol=t,this}withAutomaticReconnect(t){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return this.reconnectPolicy=t?Array.isArray(t)?new A(t):t:new A,this}build(){const t=this.httpConnectionOptions||{};if(void 0===t.logger&&(t.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const e=new X(this.url,t);return q.create(e,this.logger||w.instance,this.protocol||new V,this.reconnectPolicy)}}const{state:Q,onChange:Y,reset:Z}=e({connecting:!1,connected:!1}),tt={state:Q,onChange:Y,reset:Z};class et{constructor(){console.log("Starting signalR");var e=t.getInstance().get("sparkle");this.connection=(new K).withUrl(`${e.apiUrl}hubs/sparkle?url=${window.location.href}&courseClassId=1`,{accessTokenFactory:()=>this.getToken(),skipNegotiation:!0,transport:M.WebSockets}).configureLogging(d.Debug).withAutomaticReconnect({nextRetryDelayInMilliseconds:t=>t.elapsedMilliseconds<6e4?1e4*Math.random():null}).build(),this.connection.on("SendMessage",((t,e)=>{let s=JSON.parse(e);console.log("Server said ",t,s)})),this.connection.onclose((()=>{})),this.connection.onreconnecting((()=>{console.assert(this.connection.state===f.Reconnecting)})),this.connection.onreconnected((()=>{console.assert(this.connection.state===f.Connected)}))}static getInstance(){return et.instance||(et.instance=new et),et.instance}async start(){console.log("start");try{tt.state.connecting=!0,tt.state.connected=!tt.state.connecting,await this.connection.start(),console.log(this.connection),tt.state.connecting=!1,tt.state.connected=!tt.state.connecting,console.assert(this.connection.state===f.Connected),console.log("SignalR Connected.")}catch(t){console.assert(this.connection.state===f.Disconnected),console.log(t)}}async callSignalR(t,e){console.log("signalR invoke",t,this.connection.connectionState),this.getToken()?(this.connection.invoke(t,JSON.stringify(e)),console.log("After signalR invoke",t,this.connection.connectionState)):console.log("Cannot connect to signalR. Not logged in")}getToken(){var e=t.getInstance().get("sparkle");return e&&e.auth&&e.auth.getToken()?sparkle.auth.getToken():null}}export{et as S,tt as s}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as i,h as t,e as s}from"./p-ee1e0eb4.js";import{S as e,G as a,e as o,f as n}from"./p-935e7cfc.js";import{E as l}from"./p-b226f54d.js";import{A as h}from"./p-9a443f51.js";import{A as r,F as d,g as p,f as c}from"./p-600cf6a3.js";import"./p-1d4c7c11.js";import"./p-2f569553.js";import"./p-2ff67662.js";import"./p-871106e0.js";import"./p-add30d46.js";import"./p-d68092b7.js";const u=class{constructor(t){i(this,t),this.name={valid:!1,value:""},this.description={valid:!1,value:""},this.category={valid:!1,value:""},this.progress=0,this.public=!0,this.goalUpdateText={valid:!0,value:""},this.submitted=!1}goalHanlder(i){this.updateGoal(i.AppData)}componentWillLoad(){this.appData&&this.updateGoal(this.appData.AppData)}updateGoal(i){i&&(this.name=Object.assign(Object.assign({},this.name),{value:i.Name}),this.description=Object.assign(Object.assign({},this.description),{value:i.Description}),this.category=Object.assign(Object.assign({},this.category),{value:i.Category}),this.goalUpdateText=Object.assign(Object.assign({},this.goalUpdateText),{value:i.GoalText}),this.progress=i.Percentage)}handleTitle(i){this.validateTitle(),this.name=Object.assign(Object.assign({},this.name),{value:i.target.value})}handleDescription(i){this.validateDescription(),this.description=Object.assign(Object.assign({},this.description),{value:i.target.value})}handleCategory(i){this.validateCategoy(),this.category=Object.assign(Object.assign({},this.category),{value:i.target.value})}handleGoalProgressInfo(i){this.goalUpdateText=Object.assign(Object.assign({},this.goalUpdateText),{value:i.target.value})}validateTitle(){this.name=Object.assign(Object.assign({},this.name),this.name.value&&this.name.value.length>0?{valid:!0}:{valid:!1})}validateDescription(){this.description=Object.assign(Object.assign({},this.description),this.description.value&&this.description.value.length>0?{valid:!0}:{valid:!1})}validateCategoy(){this.category=Object.assign(Object.assign({},this.category),this.category.value&&this.category.value.length>0?{valid:!0}:{valid:!1})}validateGoalUpdateText(){this.goalUpdateText=Object.assign(Object.assign({},this.goalUpdateText),this.goalUpdateText.value&&this.goalUpdateText.value.length>0?{valid:!0}:{valid:!1})}async onSubmit(i){if(i.preventDefault(),console.log("clicked signup"),this.validateTitle(),this.validateDescription(),this.validateCategoy(),this.submitted=!0,this.appData&&this.appData.Id>0){if(this.validateGoalUpdateText(),this.name.valid&&this.description.valid&&this.category.valid&&this.goalUpdateText.valid){var t=a(this.name.value,this.description.value,this.category.value,this.progress,this.goalUpdateText.value);(await r.getInstance().updateGoal({Id:this.appData.Id,MiniAppId:e.MY_GOALS_APP_ID,AppJsonData:JSON.stringify(t)})).Succeeded&&(this.public?await this.postToFeed():this.dismiss())}}else this.name.valid&&this.description.valid&&this.category.valid&&(t=a(this.name.value,this.description.value,this.category.value,this.progress,this.goalUpdateText.value),(await r.getInstance().createGoal({MiniAppId:e.MY_GOALS_APP_ID,AppJsonData:JSON.stringify(t)})).Succeeded&&this.dismiss())}async postToFeed(){const i=l.getInstance().get("sparkle");var t={CourseId:(await h.getInstance().loadJsonFile(i.tocPath)).id,MiniAppId:e.MY_GOALS_APP_ID,PostText:o(this.name.value,this.goalUpdateText.value,this.progress),PostTextJSON:n(this.name.value,this.goalUpdateText.value,this.progress),IsPublic:this.public,ExternalResourceUrl:""};(await d.getInstance().createPost(t)).Succeeded&&this.dismiss()}dismiss(i){this.el.closest("ion-modal").dismiss({dismissed:!0})}renderEditBookingFields(){if(this.appData)return t("div",null,t("ion-item",null,t("ion-label",{position:"stacked",color:"primary"},"Goal Progress Info"),t("ion-input",{name:"title",type:"text",value:this.goalUpdateText.value,onInput:i=>this.handleGoalProgressInfo(i)})),t("ion-text",{color:"danger"},t("p",{hidden:this.goalUpdateText.valid||!1===this.submitted,class:"ion-padding-start"},"Goal Progress text is required")),t("ion-item",null,t("ion-label",{position:"stacked"},"Progress"),t("ion-range",{value:this.progress,min:1,max:100,step:1,snaps:!0,pin:!0,onIonChange:i=>this.progress=+i.detail.value},t("ion-icon",{size:"small",slot:"start",name:"pulse"}),t("ion-icon",{name:"pulse",size:"small"}),t("strong",{slot:"end"},this.progress))),t("ion-text",{color:"danger"},t("p",{hidden:this.progress>0||!1===this.submitted,class:"ion-padding-start"},"Min Progress value should be 1")),t("ion-item",{lines:"none"},t("ion-label",null,"Share to Community Wall"),t("ion-checkbox",{slot:"start",onChange:i=>this.public=i.detail.checked,checked:!0})))}render(){return[t("div",null,t("ion-toolbar",{color:"primary"},t("ion-buttons",{slot:"start"},t("ion-back-button",{defaultHref:"home",onClick:()=>this.dismiss()})),t("ion-title",null,"Add New Goal")),t("div",{class:"inner-content"},t("form",{class:"ion-padding",novalidate:!0,onSubmit:i=>this.onSubmit(i)},t("ion-list",{"no-lines":!0},t("ion-item",null,t("ion-label",{position:"stacked",color:"primary"},"Title"),t("ion-input",{name:"title",type:"text",value:this.name.value,onInput:i=>this.handleTitle(i),required:!0})),t("ion-text",{color:"danger"},t("p",{hidden:this.name.valid||!1===this.submitted,class:"ion-padding-start"},"Title is required")),t("ion-item",null,t("ion-label",{position:"stacked",color:"primary"},"Description"),t("ion-textarea",{name:"desciption",value:this.description.value,onInput:i=>this.handleDescription(i),required:!0})),t("ion-text",{color:"danger"},t("p",{hidden:this.description.valid||!1===this.submitted,class:"ion-padding-start"},"Description is required")),t("ion-item",null,t("ion-label",null,"Category"),t("ion-select",{value:this.category.value,onIonChange:i=>this.handleCategory(i)},t("ion-select-option",{value:"Emotional"},"Emotional"),t("ion-select-option",{value:"Interpersonal"},"Interpersonal"),t("ion-select-option",{value:"Learning"},"Learning"),t("ion-select-option",{value:"Financial"},"Financial"),t("ion-select-option",{value:"Physical"},"Physical"))),t("ion-text",{color:"danger"},t("p",{hidden:this.category.valid||!1===this.submitted,class:"ion-padding-start"},"Category is required")),this.renderEditBookingFields()),t("div",{class:"ion-padding"},this.appData&&t("ion-button",{type:"submit",expand:"block",disabled:p.state.goalLoading||c.state.postIdLoading>0},p.state.goalLoading&&t("ion-spinner",{name:"dots"})," Update"),!this.appData&&t("ion-button",{type:"submit",expand:"block",disabled:p.state.goalLoading},p.state.goalLoading&&t("ion-spinner",{name:"dots"})," Add")))))]}get el(){return s(this)}static get watchers(){return{appData:["goalHanlder"]}}};u.style=":host{display:block}";export{u as sparkle_goal_form}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{H as t}from"./p-1d4c7c11.js";import{d as a}from"./p-2f569553.js";import{S as e}from"./p-935e7cfc.js";const{state:s,onChange:n}=a({goals:[],goalsLoading:!1,goalLoading:!1}),r={state:s,onChange:n};class o{constructor(){}static getInstance(){return o.instance||(o.instance=new o),o.instance}async getAllAppData(a){return await t.http.get(`api/v1/AppData/${a}`)}async createAppData(a){return await t.http.post("api/v1/AppData/",a)}async updateAppData(a){return await t.http.put(`api/v1/AppData/${a.Id}`,a)}async getAllGoals(){r.state.goalsLoading=!0;let t=await this.getAllAppData(e.MY_GOALS_APP_ID);return t&&(r.state.goals=t.Data.map((t=>Object.assign(Object.assign({},t),{AppData:JSON.parse(t.AppJsonData)}))),r.state.goalsLoading=!1),t}async createGoal(t){r.state.goalLoading=!0;let a=await this.createAppData(t);return a&&(a.Data.AppData=JSON.parse(a.Data.AppJsonData),r.state.goals=[...r.state.goals,a.Data],r.state.goalLoading=!1),a}async updateGoal(t){r.state.goalLoading=!0;let a=await this.updateAppData(t);return a&&(a.Data.AppData=JSON.parse(a.Data.AppJsonData),r.state.goals=r.state.goals.map((t=>t.Id==a.Data.Id?Object.assign(Object.assign({},a.Data),{AppData:JSON.parse(a.Data.AppJsonData)}):t)),r.state.goalLoading=!1),a}}const{state:c,reset:p}=a({posts:[],postsLoading:!1,createPostLoading:!1,postIdLoading:null}),i={state:c,reset:p};class l{constructor(){}static getInstance(){return l.instance||(l.instance=new l),l.instance}async getAllPosts(){i.state.postsLoading=!0;let a=await t.http.get("api/v1/Feed/GetAll");return a&&(i.state.posts=a.Data,i.state.postsLoading=!1),a}async createPost(a){i.state.createPostLoading=!0;let e=await t.http.post("api/v1/Feed/PostFeed",a);return e&&(i.state.posts=[e.Data,...i.state.posts],i.state.createPostLoading=!1),e}async createPostComment(a){i.state.postIdLoading=a.PostId;let e=await t.http.post("api/v1/Feed/Comment",a);return e&&(i.state.posts=i.state.posts.map((t=>t.Id==e.Data.ClassFeedPostId?Object.assign(Object.assign({},t),{Comments:[...t.Comments,e.Data]}):t)),i.state.postIdLoading=null),e}}export{o as A,l as F,i as f,r as g}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,i,w as e,h as a,H as n,e as o}from"./p-ee1e0eb4.js";import{g as r}from"./p-871106e0.js";import{e as s,i as d,j as h,k as l}from"./p-d68092b7.js";import{c as p}from"./p-0e4de1d0.js";const c=class{constructor(e){t(this,e),this.ionChange=i(this,"ionChange",7),this.ionInput=i(this,"ionInput",7),this.ionStyle=i(this,"ionStyle",7),this.ionBlur=i(this,"ionBlur",7),this.ionFocus=i(this,"ionFocus",7),this.inputId="ion-textarea-"+g++,this.didBlurAfterEdit=!1,this.inheritedAttributes={},this.fireFocusEvents=!0,this.hasFocus=!1,this.autocapitalize="none",this.autofocus=!1,this.clearOnEdit=!1,this.debounce=0,this.disabled=!1,this.name=this.inputId,this.readonly=!1,this.required=!1,this.spellcheck=!1,this.autoGrow=!1,this.value="",this.onInput=t=>{this.nativeInput&&(this.value=this.nativeInput.value),this.emitStyle(),this.ionInput.emit(t)},this.onFocus=t=>{this.hasFocus=!0,this.focusChange(),this.fireFocusEvents&&this.ionFocus.emit(t)},this.onBlur=t=>{this.hasFocus=!1,this.focusChange(),this.fireFocusEvents&&this.ionBlur.emit(t)},this.onKeyDown=()=>{this.checkClearOnEdit()}}debounceChanged(){this.ionChange=s(this.ionChange,this.debounce)}disabledChanged(){this.emitStyle()}valueChanged(){const t=this.nativeInput,i=this.getValue();t&&t.value!==i&&(t.value=i),this.runAutoGrow(),this.emitStyle(),this.ionChange.emit({value:i})}connectedCallback(){this.emitStyle(),this.debounceChanged(),document.dispatchEvent(new CustomEvent("ionInputDidLoad",{detail:this.el}))}disconnectedCallback(){document.dispatchEvent(new CustomEvent("ionInputDidUnload",{detail:this.el}))}componentWillLoad(){this.inheritedAttributes=Object.assign(Object.assign({},d(this.el)),h(this.el,["title"]))}componentDidLoad(){this.runAutoGrow()}async setFocus(){this.nativeInput&&this.nativeInput.focus()}async setBlur(){this.nativeInput&&this.nativeInput.blur()}getInputElement(){return Promise.resolve(this.nativeInput)}emitStyle(){this.ionStyle.emit({interactive:!0,textarea:!0,input:!0,"interactive-disabled":this.disabled,"has-placeholder":void 0!==this.placeholder,"has-value":this.hasValue(),"has-focus":this.hasFocus})}runAutoGrow(){this.nativeInput&&this.autoGrow&&e((()=>{var t;this.textareaWrapper&&(this.textareaWrapper.dataset.replicatedValue=null!==(t=this.value)&&void 0!==t?t:"")}))}checkClearOnEdit(){this.clearOnEdit&&(this.didBlurAfterEdit&&this.hasValue()&&(this.value=""),this.didBlurAfterEdit=!1)}focusChange(){this.clearOnEdit&&!this.hasFocus&&this.hasValue()&&(this.didBlurAfterEdit=!0),this.emitStyle()}hasValue(){return""!==this.getValue()}getValue(){return this.value||""}render(){const t=r(this),i=this.getValue(),e=this.inputId+"-lbl",o=l(this.el);return o&&(o.id=e),a(n,{"aria-disabled":this.disabled?"true":null,class:p(this.color,{[t]:!0})},a("div",{class:"textarea-wrapper",ref:t=>this.textareaWrapper=t},a("textarea",Object.assign({class:"native-textarea","aria-labelledby":o?e:null,ref:t=>this.nativeInput=t,autoCapitalize:this.autocapitalize,autoFocus:this.autofocus,enterKeyHint:this.enterkeyhint,inputMode:this.inputmode,disabled:this.disabled,maxLength:this.maxlength,minLength:this.minlength,name:this.name,placeholder:this.placeholder||"",readOnly:this.readonly,required:this.required,spellcheck:this.spellcheck,cols:this.cols,rows:this.rows,wrap:this.wrap,onInput:this.onInput,onBlur:this.onBlur,onFocus:this.onFocus,onKeyDown:this.onKeyDown},this.inheritedAttributes),i)))}get el(){return o(this)}static get watchers(){return{debounce:["debounceChanged"],disabled:["disabledChanged"],value:["valueChanged"]}}};let g=0;c.style={ios:'.sc-ion-textarea-ios-h{--background:initial;--color:initial;--placeholder-color:initial;--placeholder-font-style:initial;--placeholder-font-weight:initial;--placeholder-opacity:0.5;--padding-top:0;--padding-end:0;--padding-bottom:0;--padding-start:0;--border-radius:0;display:block;position:relative;flex:1;width:100%;background:var(--background);color:var(--color);font-family:var(--ion-font-family, inherit);white-space:pre-wrap;z-index:2;box-sizing:border-box}.ion-color.sc-ion-textarea-ios-h{background:initial}.ion-color.sc-ion-textarea-ios-h{color:var(--ion-color-base)}ion-item.sc-ion-textarea-ios-h,ion-item .sc-ion-textarea-ios-h{align-self:baseline}ion-item.sc-ion-textarea-ios-h:not(.item-label),ion-item:not(.item-label) .sc-ion-textarea-ios-h{--padding-start:0}.textarea-wrapper.sc-ion-textarea-ios{display:grid;min-width:inherit;max-width:inherit;min-height:inherit;max-height:inherit}.textarea-wrapper.sc-ion-textarea-ios::after{white-space:pre-wrap;content:attr(data-replicated-value) " ";visibility:hidden}.native-textarea.sc-ion-textarea-ios,.textarea-wrapper.sc-ion-textarea-ios::after{padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-indent:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit;grid-area:1/1/2/2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){.native-textarea.sc-ion-textarea-ios,.textarea-wrapper.sc-ion-textarea-ios::after{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}.native-textarea.sc-ion-textarea-ios{border-radius:var(--border-radius);margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:block;width:100%;max-width:100%;max-height:100%;border:0;outline:none;background:transparent;box-sizing:border-box;resize:none;appearance:none;overflow:hidden}.native-textarea.sc-ion-textarea-ios::placeholder{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.native-textarea[disabled].sc-ion-textarea-ios{opacity:0.4}.cloned-input.sc-ion-textarea-ios{left:0;top:0;position:absolute;pointer-events:none}[dir=rtl].sc-ion-textarea-ios .cloned-input.sc-ion-textarea-ios,[dir=rtl].sc-ion-textarea-ios-h .cloned-input.sc-ion-textarea-ios,[dir=rtl] .sc-ion-textarea-ios-h .cloned-input.sc-ion-textarea-ios{left:unset;right:unset;right:0}[auto-grow].sc-ion-textarea-ios-h .cloned-input.sc-ion-textarea-ios{height:100%}.item-label-floating.item-has-placeholder.sc-ion-textarea-ios-h:not(.item-has-value),.item-label-floating.item-has-placeholder:not(.item-has-value) .sc-ion-textarea-ios-h{opacity:0}.item-label-floating.item-has-placeholder.sc-ion-textarea-ios-h:not(.item-has-value).item-has-focus,.item-label-floating.item-has-placeholder:not(.item-has-value).item-has-focus .sc-ion-textarea-ios-h{transition:opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1);opacity:1}.sc-ion-textarea-ios-h{--padding-top:10px;--padding-end:10px;--padding-bottom:10px;--padding-start:0;font-size:inherit}.item-label-stacked.sc-ion-textarea-ios-h,.item-label-stacked .sc-ion-textarea-ios-h,.item-label-floating.sc-ion-textarea-ios-h,.item-label-floating .sc-ion-textarea-ios-h{--padding-top:8px;--padding-bottom:8px;--padding-start:0px}',md:'.sc-ion-textarea-md-h{--background:initial;--color:initial;--placeholder-color:initial;--placeholder-font-style:initial;--placeholder-font-weight:initial;--placeholder-opacity:0.5;--padding-top:0;--padding-end:0;--padding-bottom:0;--padding-start:0;--border-radius:0;display:block;position:relative;flex:1;width:100%;background:var(--background);color:var(--color);font-family:var(--ion-font-family, inherit);white-space:pre-wrap;z-index:2;box-sizing:border-box}.ion-color.sc-ion-textarea-md-h{background:initial}.ion-color.sc-ion-textarea-md-h{color:var(--ion-color-base)}ion-item.sc-ion-textarea-md-h,ion-item .sc-ion-textarea-md-h{align-self:baseline}ion-item.sc-ion-textarea-md-h:not(.item-label),ion-item:not(.item-label) .sc-ion-textarea-md-h{--padding-start:0}.textarea-wrapper.sc-ion-textarea-md{display:grid;min-width:inherit;max-width:inherit;min-height:inherit;max-height:inherit}.textarea-wrapper.sc-ion-textarea-md::after{white-space:pre-wrap;content:attr(data-replicated-value) " ";visibility:hidden}.native-textarea.sc-ion-textarea-md,.textarea-wrapper.sc-ion-textarea-md::after{padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-indent:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit;grid-area:1/1/2/2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){.native-textarea.sc-ion-textarea-md,.textarea-wrapper.sc-ion-textarea-md::after{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}.native-textarea.sc-ion-textarea-md{border-radius:var(--border-radius);margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:block;width:100%;max-width:100%;max-height:100%;border:0;outline:none;background:transparent;box-sizing:border-box;resize:none;appearance:none;overflow:hidden}.native-textarea.sc-ion-textarea-md::placeholder{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.native-textarea[disabled].sc-ion-textarea-md{opacity:0.4}.cloned-input.sc-ion-textarea-md{left:0;top:0;position:absolute;pointer-events:none}[dir=rtl].sc-ion-textarea-md .cloned-input.sc-ion-textarea-md,[dir=rtl].sc-ion-textarea-md-h .cloned-input.sc-ion-textarea-md,[dir=rtl] .sc-ion-textarea-md-h .cloned-input.sc-ion-textarea-md{left:unset;right:unset;right:0}[auto-grow].sc-ion-textarea-md-h .cloned-input.sc-ion-textarea-md{height:100%}.item-label-floating.item-has-placeholder.sc-ion-textarea-md-h:not(.item-has-value),.item-label-floating.item-has-placeholder:not(.item-has-value) .sc-ion-textarea-md-h{opacity:0}.item-label-floating.item-has-placeholder.sc-ion-textarea-md-h:not(.item-has-value).item-has-focus,.item-label-floating.item-has-placeholder:not(.item-has-value).item-has-focus .sc-ion-textarea-md-h{transition:opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1);opacity:1}.sc-ion-textarea-md-h{--padding-top:10px;--padding-end:0;--padding-bottom:11px;--padding-start:8px;margin-left:0;margin-right:0;margin-top:8px;margin-bottom:0;font-size:inherit}.item-label-stacked.sc-ion-textarea-md-h,.item-label-stacked .sc-ion-textarea-md-h,.item-label-floating.sc-ion-textarea-md-h,.item-label-floating .sc-ion-textarea-md-h{--padding-top:8px;--padding-bottom:8px;--padding-start:0}'};export{c as ion_textarea}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as i,h as t,H as e,e as o}from"./p-ee1e0eb4.js";import{S as s}from"./p-5efc6566.js";import{t as l}from"./p-2ff67662.js";import"./p-1d4c7c11.js";import"./p-2f569553.js";import"./p-b226f54d.js";import"./p-871106e0.js";import"./p-add30d46.js";import"./p-d68092b7.js";const n=class{constructor(t){i(this,t),this.formControls={type:{isValid:!0,value:1,validate:i=>!!i},note:{isValid:!1,value:"",validate:i=>!!i}},this.submitted=!0}async onSubmit(i){i.preventDefault(),this.submitted=!0;let t=!0;for(let i in this.formControls){let e=this.formControls[i];e.validate(e.value),e.isValid||(t=!1)}if(t){let i=await s.getInstance().submitFeedback({Note:this.formControls.note.value,Type:this.formControls.type.value});console.log(i),i.Succeeded?((await l.create({message:"Feedback submitted successfully",duration:3e3})).present(),this.dismiss()):(await l.create({message:i.Message,duration:3e3})).present()}}dismiss(i){this.el.closest("ion-modal").dismiss({dismissed:!0})}changeFormValue(i,t){this.formControls=Object.assign(Object.assign({},this.formControls),{[i]:Object.assign(Object.assign({},this.formControls[i]),{value:t,isValid:this.formControls[i].validate(t)})})}render(){return t(e,null,t("ion-header",{translucent:!0},t("ion-toolbar",null,t("ion-title",null,"Feedback"),t("ion-buttons",{slot:"end"},t("ion-button",{onClick:()=>this.dismiss()},"Close")))),t("ion-content",{class:"ion-padding"},t("form",{onSubmit:i=>this.onSubmit(i),novalidate:!0},t("ion-list",null,t("ion-radio-group",{value:this.formControls.type.value,onChange:i=>this.changeFormValue("type",+i.target.value)},t("ion-list-header",null,t("ion-label",null,"Feedback Type")),t("ion-item",null,t("ion-label",null,"Comments"),t("ion-radio",{value:1})),t("ion-item",null,t("ion-label",null,"Suggestions"),t("ion-radio",{value:2})),t("ion-item",null,t("ion-label",null,"Questions"),t("ion-radio",{value:3}))),t("ion-item",null,t("ion-label",{position:"floating"},"Notes"),t("ion-textarea",{value:this.formControls.note.value,onChange:i=>this.changeFormValue("note",i.target.value)})),t("br",null),t("ion-button",{color:"primary",type:"submit"},"Submit")))))}get el(){return o(this)}};n.style=":host{display:block}";export{n as sparkle_feedback}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{h as t,r as s,H as e,e as i}from"./p-ee1e0eb4.js";import{t as a}from"./p-2ff67662.js";import{F as o,f as l}from"./p-fbccd30c.js";import"./p-871106e0.js";import"./p-add30d46.js";import"./p-d68092b7.js";import"./p-1d4c7c11.js";import"./p-2f569553.js";import"./p-b226f54d.js";const r=()=>t("div",{class:"spinner-border",role:"status"}),n=class{constructor(t){s(this,t),this.formControls={noteText:{isValid:!0,value:"",errorMessage:"",validate:t=>(console.log(t),t&&t.length>0?{valid:!0,errorMessage:""}:{valid:!1,errorMessage:"Notes is required"})}},this.submitted=!1}componentDidLoad(){this.initialValues&&this.changeFormValue("noteText",this.initialValues.NoteText)}async onSubmit(t){t.preventDefault(),this.submitted=!0;let s=!0;for(let t in this.formControls){let e=this.formControls[t];e.isValid=e.validate(e.value).valid,e.errorMessage=e.validate(e.value).errorMessage,e.isValid||(s=!1)}if(s)if(this.initialValues&&this.initialValues.Id>0){let t=await o.getInstance().updateFacilitatorNote({NoteText:this.formControls.noteText.value,Id:this.initialValues.Id});t.Succeeded?((await a.create({message:"Notes updated successfully",duration:3e3})).present(),this.dismiss()):(await a.create({message:t.Message,duration:3e3})).present()}else{let t=await o.getInstance().addFacilitatorNote({NoteText:this.formControls.noteText.value});t.Succeeded?((await a.create({message:"Notes added successfully",duration:3e3})).present(),this.dismiss()):(await a.create({message:t.Message,duration:3e3})).present()}}dismiss(t){this.el.closest("ion-modal").dismiss({dismissed:!0})}changeFormValue(t,s){this.formControls=Object.assign(Object.assign({},this.formControls),{[t]:Object.assign(Object.assign({},this.formControls[t]),{value:s,isValid:this.formControls[t].validate(s).valid,errorMessage:this.formControls[t].validate(s).errorMessage})})}render(){const s=this.formControls.noteText.isValid?"is-valid":"is-invalid";return t(e,null,t("ion-header",{translucent:!0},t("ion-toolbar",null,t("ion-title",null,"Facilitator Note"),t("ion-buttons",{slot:"end"},t("ion-button",{onClick:()=>this.dismiss()},"Close")))),t("ion-content",{class:"ion-padding"},t("form",{onSubmit:t=>this.onSubmit(t),novalidate:!0},t("div",{class:"mb-3"},t("label",{htmlFor:"validationTextarea",class:"form-label"},"Notes"),t("textarea",{class:`form-control ${this.submitted&&s}`,placeholder:"Notes",value:this.formControls.noteText.value,onChange:t=>this.changeFormValue("noteText",t.target.value)}),this.formControls.noteText.errorMessage&&t("div",{class:"invalid-feedback"},this.formControls.noteText.errorMessage)),t("div",{class:"mb-3"},l.state.notesLoading&&t(r,null),t("button",{class:"btn btn-primary",type:"submit",disabled:l.state.notesLoading},"Submit")))))}get el(){return i(this)}};n.style=":host{display:block}";export{n as sparkle_facilitator_notes_form}
|
@@ -1 +0,0 @@
|
|
1
|
-
class t{constructor(){this.init()}static getInstance(){return t.instance||(t.instance=new t),t.instance}init(){if(!window)return;const t=window.Sparkle;console.log("getting info"),this.m=new Map(Object.entries(t.config))}get(t,n){const e=this.m.get(t);return void 0!==e?e:n}}export{t as E}
|
File without changes
|
File without changes
|