{"version":3,"file":"alfresco-aca-content-ms-office.mjs","sources":["../../../../projects/aca-content/ms-office/src/aos-extension.service.ts","../../../../projects/aca-content/ms-office/src/actions/aos.actions.ts","../../../../projects/aca-content/ms-office/src/effects/aos.effects.ts","../../../../projects/aca-content/ms-office/src/aos-extension.module.ts","../../../../projects/aca-content/ms-office/src/public-api.ts","../../../../projects/aca-content/ms-office/src/alfresco-aca-content-ms-office.ts"],"sourcesContent":["/*!\n * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.\n *\n * Alfresco Example Content Application\n *\n * This file is part of the Alfresco Example Content Application.\n * If the software was purchased under a paid Alfresco license, the terms of\n * the paid license agreement will prevail. Otherwise, the software is\n * provided under the following open source license terms:\n *\n * The Alfresco Example Content Application is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The Alfresco Example Content Application is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.\n */\n\n/* cspell:disable */\nimport { AuthenticationService, NotificationService } from '@alfresco/adf-core';\nimport { Injectable } from '@angular/core';\nimport { Node } from '@alfresco/js-api';\nimport { getFileExtension, supportedExtensions } from '@alfresco/aca-shared/rules';\nimport { AppSettingsService } from '@alfresco/aca-shared';\n\nexport interface IAosEditOnlineService {\n  onActionEditOnlineAos(node: Node): void;\n}\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class AosEditOnlineService implements IAosEditOnlineService {\n  constructor(\n    private authenticationService: AuthenticationService,\n    private appSettings: AppSettingsService,\n    private notificationService: NotificationService\n  ) {}\n\n  onActionEditOnlineAos(node: Node): void {\n    if (node && this.isFile(node) && node.properties) {\n      if (node.isLocked) {\n        // const checkedOut = node.aspectNames.find(\n        //   (aspect: string) => aspect === 'cm:checkedOut'\n        // );\n        const checkedOut = node.properties['cm:lockType'] === 'WRITE_LOCK' || node.properties['cm:lockType'] === 'READ_ONLY_LOCK';\n        const lockOwner = node.properties['cm:lockOwner'];\n        const differentLockOwner = lockOwner.id !== this.authenticationService.getUsername();\n\n        if (checkedOut && differentLockOwner) {\n          this.onAlreadyLockedNotification(node.id, lockOwner.id);\n        } else {\n          this.triggerEditOnlineAos(node);\n        }\n      } else {\n        this.triggerEditOnlineAos(node);\n      }\n    }\n  }\n\n  private getUserAgent(): string {\n    return navigator.userAgent.toLowerCase();\n  }\n\n  private isWindows(): boolean {\n    return this.getUserAgent().indexOf('win') !== -1;\n  }\n\n  private isMacOs(): boolean {\n    return this.getUserAgent().indexOf('mac') !== -1;\n  }\n\n  private onAlreadyLockedNotification(nodeId: string, lockOwner: string) {\n    this.notificationService.showError(`AOS.ERRORS.ALREADY_LOCKED`, null, {\n      nodeId,\n      lockOwner\n    });\n  }\n\n  private getProtocolForFileExtension(fileExtension: string) {\n    return fileExtension && supportedExtensions[fileExtension];\n  }\n\n  private triggerEditOnlineAos(node: Node): void {\n    const aosHost = this.appSettings.aosHost;\n    let url: string;\n    const pathElements = (node.path?.elements || []).map((segment) => segment.name);\n\n    if (!pathElements.length) {\n      url = `${aosHost}/Company Home/_aos_nodeid/${this.getNodeId(node)}/${encodeURIComponent(node.name)}`;\n    }\n\n    if (pathElements.length === 1) {\n      url = `${aosHost}/${encodeURIComponent(node.name)}`;\n    }\n\n    if (pathElements.length > 1) {\n      const root = pathElements[1];\n      url = `${aosHost}/${root}/_aos_nodeid/${this.getNodeId(node)}/${encodeURIComponent(node.name)}`;\n    }\n\n    const fileExtension = getFileExtension(node.name);\n    const protocolHandler = this.getProtocolForFileExtension(fileExtension);\n\n    if (protocolHandler === undefined) {\n      this.notificationService.showError(`AOS.ERRORS.MISSING_PROTOCOL_HANDLER`, null, { nodeName: node.name });\n      return;\n    }\n\n    if (!this.isWindows() && !this.isMacOs()) {\n      this.notificationService.showError('AOS.ERRORS.UNSUPPORTED_PLATFORM');\n    } else {\n      this.openByUrl(protocolHandler, url);\n    }\n  }\n\n  openByUrl(protocolHandler: string, url: string) {\n    const finalUrl = protocolHandler + ':ofe%7Cu%7C' + url;\n\n    const iframe = document.createElement('iframe');\n    iframe.style.display = 'none';\n    iframe.src = finalUrl;\n\n    document.body.appendChild(iframe);\n\n    setTimeout(() => {\n      if (iframe) {\n        document.body.removeChild(iframe);\n      }\n    }, 500);\n  }\n\n  private isFile(node: Node): boolean {\n    const implicitFile = (node as any).nodeId || (node as any).guid;\n\n    return !!implicitFile || node.isFile;\n  }\n\n  private getNodeId(node: Node): string {\n    return (node as any).nodeId || (node as any).guid || node.id;\n  }\n}\n","/*!\n * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.\n *\n * Alfresco Example Content Application\n *\n * This file is part of the Alfresco Example Content Application.\n * If the software was purchased under a paid Alfresco license, the terms of\n * the paid license agreement will prevail. Otherwise, the software is\n * provided under the following open source license terms:\n *\n * The Alfresco Example Content Application is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The Alfresco Example Content Application is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { Action } from '@ngrx/store';\nimport { Node } from '@alfresco/js-api';\n\nexport const AOS_ACTION = 'AOS_ACTION';\n\nexport class AosAction implements Action {\n  readonly type = AOS_ACTION;\n  constructor(public payload: Node) {}\n}\n","/*!\n * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.\n *\n * Alfresco Example Content Application\n *\n * This file is part of the Alfresco Example Content Application.\n * If the software was purchased under a paid Alfresco license, the terms of\n * the paid license agreement will prevail. Otherwise, the software is\n * provided under the following open source license terms:\n *\n * The Alfresco Example Content Application is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The Alfresco Example Content Application is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { inject, Injectable } from '@angular/core';\nimport { Actions, createEffect, ofType } from '@ngrx/effects';\nimport { map } from 'rxjs/operators';\n\nimport { AOS_ACTION, AosAction } from '../actions/aos.actions';\nimport { AosEditOnlineService } from '../aos-extension.service';\n\n@Injectable()\nexport class AosEffects {\n  private actions$ = inject(Actions);\n  private aosEditOnlineService = inject(AosEditOnlineService);\n\n  openOffice$ = createEffect(\n    () =>\n      this.actions$.pipe(\n        ofType<AosAction>(AOS_ACTION),\n        map((action) => {\n          if (action.payload) {\n            this.aosEditOnlineService.onActionEditOnlineAos(action.payload);\n          }\n        })\n      ),\n    { dispatch: false }\n  );\n}\n","/*!\n * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.\n *\n * Alfresco Example Content Application\n *\n * This file is part of the Alfresco Example Content Application.\n * If the software was purchased under a paid Alfresco license, the terms of\n * the paid license agreement will prevail. Otherwise, the software is\n * provided under the following open source license terms:\n *\n * The Alfresco Example Content Application is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The Alfresco Example Content Application is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { provideExtensionConfig, provideExtensions } from '@alfresco/adf-extensions';\nimport { EnvironmentProviders, NgModule, Provider } from '@angular/core';\nimport { provideEffects } from '@ngrx/effects';\nimport { AosEffects } from './effects/aos.effects';\nimport { provideTranslations } from '@alfresco/adf-core';\nimport { canOpenWithOffice } from '@alfresco/aca-shared/rules';\n\nexport function provideAosExtension(): (Provider | EnvironmentProviders)[] {\n  return [\n    provideExtensionConfig(['aos.plugin.json']),\n    provideTranslations('ms-office', 'assets/ms-office'),\n    provideEffects(AosEffects),\n    provideExtensions({\n      evaluators: {\n        'aos.canOpenWithOffice': canOpenWithOffice\n      }\n    })\n  ];\n}\n\n/* @deprecated use `provideAosExtension()` provider api instead */\n@NgModule({\n  providers: [...provideAosExtension()]\n})\nexport class AosExtensionModule {}\n","/*!\n * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.\n *\n * Alfresco Example Content Application\n *\n * This file is part of the Alfresco Example Content Application.\n * If the software was purchased under a paid Alfresco license, the terms of\n * the paid license agreement will prevail. Otherwise, the software is\n * provided under the following open source license terms:\n *\n * The Alfresco Example Content Application is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The Alfresco Example Content Application is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport * from './aos-extension.service';\nexport * from './actions/aos.actions';\nexport * from './effects/aos.effects';\n\nexport * from './aos-extension.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;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