(window.webpackJsonp=window.webpackJsonp||[]).push([["4F3S"],{Lx7c:function(e,o,t){"use strict";var r=t("TqRt");Object.defineProperty(o,"__esModule",{value:!0}),o.default=void 0;var s=r(t("pVnL"));t("q1tI");var n=function(e,o){if(!o&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=m(o);if(t&&t.has(e))return t.get(e);var r={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if("default"!==n&&Object.prototype.hasOwnProperty.call(e,n)){var a=s?Object.getOwnPropertyDescriptor(e,n):null;a&&(a.get||a.set)?Object.defineProperty(r,n,a):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(t("whzC")),a=r(t("12ks")),i=r(t("Q8Wn")),l=r(t("8Kom")),c=t("4PhQ"),u=t("VwrD"),d=t("Js+d");function m(e){if("function"!=typeof WeakMap)return null;var o=new WeakMap,t=new WeakMap;return(m=function(e){return e?t:o})(e)}const g=n.safeLinkTo("https://classroom.google.com/share"),p=()=>i.default.IS_DEV_SERVER?"179486897809-nedb177f1iatc8dra55e9g4ei2d908mo.apps.googleusercontent.com":"179486897809-vot6i8d4ohsqvv7rui9vbjd53k6eo5mo.apps.googleusercontent.com";const h=["https://www.googleapis.com/auth/classroom.courses.readonly","https://www.googleapis.com/auth/classroom.rosters.readonly","https://www.googleapis.com/auth/classroom.profile.emails"];var f={ROSTER_SCOPES:h,SHARE_SCOPES:["https://www.googleapis.com/auth/classroom.coursework.students"],allScopes:function(){return[].concat(h)},_gapiPromise:void 0,_getHostname:()=>l.default.hostname.toLowerCase(),canLoadGoogleApi(){const e=this,o=e._getHostname().startsWith("static-"),t=e._getHostname().startsWith("pubcommit-"),r=e._getHostname().endsWith(".khanacademy.org");return i.default.IS_DEV_SERVER||r&&!(o||t)},loadGoogleAPI(){const e=this;return e.canLoadGoogleApi()?e._gapiPromise?e._gapiPromise:(0,u.loadGoogleClient)(d.GoogleClient.GAPI).then((e=>e)):Promise.reject(new c.KAError("Google Classroom not enabled for user",c.Errors.NotAllowed))},classroomAPI(){const e=window.gapi;return e?e.client.classroom?Promise.resolve(e.client.classroom):new Promise(((o,t)=>{e.client.load("classroom","v1",(r=>{r&&r.error&&t(r.error),o(e.client.classroom)}))})):Promise.reject(new c.KAError("Google APIs need to be loaded. Call loadGoogleAPI",c.Errors.NotAllowed))},_queryPagedList(e,o,t={},r=0){if(r>=10)return Promise.resolve([]);const n=(0,s.default)({},t,{pageSize:100});return new Promise(((a,i)=>{e.list(n).execute((n=>{if(!n||n.error)return i(new c.KAError("Failed to get Google Classroom response",c.Errors.TransientService,{cause:(null==n?void 0:n.error)||"Did not receive a response"}));if(!n.nextPageToken)return a(o(n)||[]);const l=this._queryPagedList(e,o,(0,s.default)({},t,{pageToken:n.nextPageToken}),r+1).then((e=>[].concat(o(n)||[],e)));a(l)}))}))},getCourses(){const e=this;return(0,u.authorizeWithImplicitGrant)(p(),h).then((()=>e.classroomAPI())).then((o=>e._queryPagedList(o.courses,(e=>e.courses),{courseStates:["ACTIVE"],teacherId:"me"})))},getStudents(e){const o=this;if(!e)return Promise.reject(new c.KAError("getStudents(courseId) missing parameter!",c.Errors.InvalidInput));function t(e){return!!e.profile.emailAddress}function r(e){return!!e.userId}return(0,u.authorizeWithImplicitGrant)(p(),h).then((()=>o.classroomAPI())).then((t=>{function n(e){return t.userProfiles.get({userId:e.userId}).then((o=>{const t=(0,s.default)({},e,{profile:o.result,isPending:!0});return delete t.id,t}))}const a=o._queryPagedList(t.courses.students,(e=>e.students),{courseId:e}),i=o._queryPagedList(t.invitations,(e=>e.invitations),{courseId:e}).then((e=>Promise.all(e.filter(r).map(n))));return Promise.all([a,i])})).then((([e,o])=>[].concat(e,o))).then((e=>e.filter(t)))},getShareLink(e){const o=document.createElement("a");o.href=e;return`${`${o.protocol}//${o.host}`}/gclassroom${o.pathname}${o.search}`},markSharingConversion(e){a.default.markConversion("content_shared_to_google_classroom",{shareLink:e})},shareToClassroom(e,o,t){const r=this.getShareLink(e);let s=`url=${encodeURIComponent(r)}`;s+=`&title=${encodeURIComponent(o)}`,s+=`&body=${encodeURIComponent(t)}`,this.markSharingConversion(r),window.open(`${g}?${s}`,null,"width=640, height=450,toolbar=no, scrollbars=yes")}};o.default=f}}]);
//# sourceMappingURL=../../sourcemaps/en/4F3S.7497182be7871ceae5b4.js.map